Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.mdns.eu/nextcloud/passwords-client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model/Password')
-rw-r--r--src/Model/Password/EnhancedPassword.js130
-rw-r--r--src/Model/Password/Password.js232
2 files changed, 362 insertions, 0 deletions
diff --git a/src/Model/Password/EnhancedPassword.js b/src/Model/Password/EnhancedPassword.js
new file mode 100644
index 0000000..9290910
--- /dev/null
+++ b/src/Model/Password/EnhancedPassword.js
@@ -0,0 +1,130 @@
+import Password from './Password';
+import Url from 'url-parse';
+
+export default class EnhancedPassword extends Password {
+
+ /**
+ *
+ * @param {BasicPasswordsClient} api
+ * @param {Object} [data={}]
+ */
+ constructor(data = {}, api) {
+ super(data);
+ this._api = api;
+ }
+
+ /**
+ *
+ * @returns {Server}
+ */
+ getServer() {
+ return this._api.getServer();
+ }
+
+ /**
+ *
+ * @param {Number} [size=32]
+ * @param {Boolean} [pathOnly=false]
+ * @return {String}
+ */
+ getFaviconUrl(size = 32, pathOnly = false) {
+ let host = 'default';
+
+ if(this.getUrl()) {
+ let url = Url(this.getUrl());
+
+ if(url.host.length !== 0) {
+ host = url.host;
+ }
+ }
+
+ if(pathOnly) return `1.0/service/favicon/${host}/${size}`;
+
+ return `${this.getServer().getApiUrl()}1.0/service/favicon/${host}/${size}`;
+ }
+
+ /**
+ *
+ * @param size
+ * @returns {Promise<Blob>}
+ */
+ async getFavicon(size = 32) {
+ let path = this.getFaviconUrl(size, true),
+ response = await this._api.getRequest().setPath(path).setResponseType('image/png').send();
+
+ return response.getData();
+ }
+
+ /**
+ *
+ * @param {(String|Number)} width
+ * @param {(String|Number)} height
+ * @param {String} view
+ * @param {Boolean} [pathOnly=false]
+ * @return {String}
+ */
+ getPreviewUrl(width = 640, height = '360...', view = 'desktop', pathOnly = false) {
+ let host = 'default';
+
+ if(this.getUrl()) {
+ let url = Url(this.getUrl());
+
+ if(url.host.length !== 0) {
+ host = url.host;
+ }
+ }
+
+ if(pathOnly) return `1.0/service/preview/${host}/${view}/${width}/${height}`;
+
+ return `${this.getServer().getApiUrl()}1.0/service/preview/${host}/${view}/${width}/${height}`;
+ }
+
+ /**
+ *
+ * @param {(String|Number)} width
+ * @param {(String|Number)} height
+ * @param {String} view
+ * @returns {Promise<Blob>}
+ */
+ async getPreview(width = 640, height = '360...', view) {
+ let path = this.getPreviewUrl(width, height, view, true),
+ response = await this._api.getRequest().setPath(path).setResponseType('image/jpeg').send();
+
+ return response.getData();
+ }
+
+ /**
+ *
+ * @returns {Promise<PasswordCollection>}
+ */
+ async fetchRevisions() {
+ }
+
+ /**
+ *
+ * @returns {Promise<Share>}
+ */
+ async fetchShare() {
+ }
+
+ /**
+ *
+ * @returns {Promise<ShareCollection>}
+ */
+ async fetchShares() {
+ }
+
+ /**
+ *
+ * @returns {Promise<TagCollection>}
+ */
+ async fetchTags() {
+ }
+
+ /**
+ *
+ * @returns {Promise<FolderCollection>}
+ */
+ async fetchFolder() {
+ }
+} \ No newline at end of file
diff --git a/src/Model/Password/Password.js b/src/Model/Password/Password.js
new file mode 100644
index 0000000..da2692f
--- /dev/null
+++ b/src/Model/Password/Password.js
@@ -0,0 +1,232 @@
+import Properties from '../../Configuration/Password';
+import AbstractRevisionModel from '../AbstractRevisionModel';
+
+export default class Password extends AbstractRevisionModel {
+
+ /**
+ *
+ * @param {Object} [data={}]
+ */
+ constructor(data = {}) {
+ super(Properties, data);
+ }
+
+ /**
+ * @return {String}
+ */
+ getLabel() {
+ return this.getProperty('label');
+ }
+
+ /**
+ * @param {String} value
+ *
+ * @return {Password}
+ */
+ setLabel(value) {
+ return this.setProperty('label', value);
+ }
+
+ /**
+ * @return {String}
+ */
+ getUserName() {
+ return this.getProperty('username');
+ }
+
+ /**
+ * @param {String} value
+ *
+ * @return {Password}
+ */
+ setUserName(value) {
+ return this.setProperty('username', value);
+ }
+
+ /**
+ * @return {String}
+ */
+ getPassword() {
+ return this.getProperty('password');
+ }
+
+ /**
+ * @param {String} value
+ *
+ * @return {Password}
+ */
+ setPassword(value) {
+ return this.setProperty('password', value);
+ }
+
+ /**
+ * @return {String}
+ */
+ getUrl() {
+ return this.getProperty('url');
+ }
+
+ /**
+ * @param {String} value
+ *
+ * @return {Password}
+ */
+ setUrl(value) {
+ return this.setProperty('url', value);
+ }
+
+ /**
+ * @return {String}
+ */
+ getNotes() {
+ return this.getProperty('notes');
+ }
+
+ /**
+ * @param {String} value
+ *
+ * @return {Password}
+ */
+ setNotes(value) {
+ return this.setProperty('notes', value);
+ }
+
+ /**
+ * @return {CustomFieldCollection}
+ */
+ getCustomFields() {
+ return this.getProperty('customFields');
+ }
+
+ /**
+ * @param {CustomFieldCollection} value
+ * @return {Password}
+ */
+ setCustomFields(value) {
+ return this.setProperty('customFields', value);
+ }
+
+ /**
+ * @return {Number}
+ */
+ getStatus() {
+ return this.getProperty('status');
+ }
+
+ /**
+ * @param {Number} value
+ *
+ * @return {Password}
+ */
+ setStatus(value) {
+ return this.setProperty('status', value);
+ }
+
+ /**
+ * @return {String}
+ */
+ getStatusCode() {
+ return this.getProperty('statusCode');
+ }
+
+ /**
+ * @param {String} value
+ *
+ * @return {Password}
+ */
+ setStatusCode(value) {
+ return this.setProperty('statusCode', value);
+ }
+
+ /**
+ * @return {String}
+ */
+ getHash() {
+ return this.getProperty('hash');
+ }
+
+ /**
+ * @param {String} value
+ *
+ * @return {Password}
+ */
+ setHash(value) {
+ return this.setProperty('hash', value);
+ }
+
+ /**
+ * @return {String}
+ */
+ getFolder() {
+ return this.getProperty('folder');
+ }
+
+ /**
+ * @param {String} value
+ *
+ * @return {Password}
+ */
+ setFolder(value) {
+ return this.setProperty('folder', value);
+ }
+
+ /**
+ * @return {(string|null)}
+ */
+ getShare() {
+ return this.getProperty('share');
+ }
+
+ /**
+ * @param {(string|null)} value
+ *
+ * @return {Password}
+ */
+ setShare(value) {
+ return this.setProperty('share', value);
+ }
+
+ /**
+ * @return {Boolean}
+ */
+ isShared() {
+ return this.getProperty('shared');
+ }
+
+ /**
+ * @return {Boolean}
+ */
+ getShared() {
+ return this.getProperty('shared');
+ }
+
+ /**
+ * @return {Boolean}
+ */
+ setShared(value) {
+ return this.setProperty('shared', value);
+ }
+
+ /**
+ * @return {Boolean}
+ */
+ isEditable() {
+ return this.getProperty('editable');
+ }
+
+ /**
+ * @return {Boolean}
+ */
+ getEditable() {
+ return this.getProperty('editable');
+ }
+
+ /**
+ * @param {Boolean} value
+ *
+ * @return {Password}
+ */
+ setEditable(value) {
+ return this.setProperty('editable', value);
+ }
+} \ No newline at end of file