@binsky/passman-client-ts 0.1.10 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +12 -0
  2. package/lib/Interfaces/Credential/{CredentialInterface.d.ts → DecryptedCredentialInterface.d.ts} +5 -1
  3. package/lib/Interfaces/Credential/EncryptedCredentialInterface.d.ts +12 -11
  4. package/lib/Interfaces/Credential/EncryptedOwnedCredentialFromServerInterface.d.ts +35 -0
  5. package/lib/Interfaces/Credential/EncryptedOwnedCredentialFromServerInterface.js +2 -0
  6. package/lib/Interfaces/Credential/EncryptedOwnedCredentialToUpdateForServerInterface.d.ts +8 -0
  7. package/lib/Interfaces/Credential/EncryptedOwnedCredentialToUpdateForServerInterface.js +2 -0
  8. package/lib/Interfaces/Credential/SerializableTransferCredentialInterface.d.ts +7 -0
  9. package/lib/Interfaces/Credential/SerializableTransferCredentialInterface.js +2 -0
  10. package/lib/Interfaces/DecryptedDataCachingHandlerInterface.d.ts +20 -0
  11. package/lib/Interfaces/DecryptedDataCachingHandlerInterface.js +2 -0
  12. package/lib/Interfaces/NextcloudServer/NextcloudServerInterface.d.ts +8 -3
  13. package/lib/Interfaces/PassmanCrypto/EncryptedStringType.d.ts +4 -0
  14. package/lib/Interfaces/PassmanCrypto/EncryptedStringType.js +2 -0
  15. package/lib/Interfaces/PersistenceInterface.d.ts +10 -0
  16. package/lib/Interfaces/PersistenceInterface.js +2 -0
  17. package/lib/Interfaces/RequestCachingHandlerInterface.d.ts +5 -1
  18. package/lib/Interfaces/Revision/RevisionInterface.d.ts +2 -2
  19. package/lib/Interfaces/ShareService/CredentialShareRequestInterface.d.ts +2 -2
  20. package/lib/Interfaces/ShareService/SerializableACLInterface.d.ts +14 -0
  21. package/lib/Interfaces/ShareService/SerializableACLInterface.js +2 -0
  22. package/lib/Interfaces/Vault/GenericVaultInformationFromServerInterface.d.ts +17 -0
  23. package/lib/Interfaces/Vault/GenericVaultInformationFromServerInterface.js +2 -0
  24. package/lib/Interfaces/Vault/SerializableSpecificVaultInformationFromServerInterface.d.ts +12 -0
  25. package/lib/Interfaces/Vault/SerializableSpecificVaultInformationFromServerInterface.js +2 -0
  26. package/lib/Interfaces/Vault/SerializableTransferFullVaultInterface.d.ts +6 -0
  27. package/lib/Interfaces/Vault/SerializableTransferFullVaultInterface.js +2 -0
  28. package/lib/Interfaces/Vault/SpecificVaultInformationFromServerInterface.d.ts +14 -0
  29. package/lib/Interfaces/Vault/SpecificVaultInformationFromServerInterface.js +2 -0
  30. package/lib/Interfaces/Vault/VaultCreateServerResponseInterface.d.ts +8 -0
  31. package/lib/Interfaces/Vault/VaultCreateServerResponseInterface.js +2 -0
  32. package/lib/Model/Credential.d.ts +70 -19
  33. package/lib/Model/Credential.js +138 -25
  34. package/lib/Model/File.d.ts +7 -7
  35. package/lib/Model/NextcloudServer.d.ts +9 -8
  36. package/lib/Model/NextcloudServer.js +14 -14
  37. package/lib/Model/PreloadedVault.d.ts +20 -0
  38. package/lib/Model/PreloadedVault.js +54 -0
  39. package/lib/Model/Revision.d.ts +3 -3
  40. package/lib/Model/Revision.js +3 -3
  41. package/lib/Model/SharingACL.d.ts +3 -2
  42. package/lib/Model/SharingACL.js +9 -6
  43. package/lib/Model/Vault.d.ts +48 -5
  44. package/lib/Model/Vault.js +141 -61
  45. package/lib/PassmanClient.d.ts +51 -10
  46. package/lib/PassmanClient.js +101 -35
  47. package/lib/Service/CredentialFilterService.d.ts +2 -1
  48. package/lib/Service/CredentialFilterService.js +24 -9
  49. package/lib/Service/DefaultLoggingService.d.ts +3 -0
  50. package/lib/Service/DefaultLoggingService.js +3 -0
  51. package/lib/Service/DefaultPersistenceService.d.ts +12 -0
  52. package/lib/Service/DefaultPersistenceService.js +20 -0
  53. package/lib/Service/OTPService.d.ts +6 -6
  54. package/lib/Service/OTPService.js +17 -7
  55. package/lib/Service/PassmanCrypto.d.ts +9 -4
  56. package/lib/Service/PassmanCrypto.js +6 -6
  57. package/lib/Service/ReEncryptionService.js +2 -2
  58. package/lib/Service/RequestCachingService.d.ts +5 -2
  59. package/lib/Service/RequestCachingService.js +3 -0
  60. package/lib/Service/ShareService.js +2 -4
  61. package/lib/tsconfig.tsbuildinfo +1 -1
  62. package/package.json +3 -1
  63. /package/lib/Interfaces/Credential/{CredentialInterface.js → DecryptedCredentialInterface.js} +0 -0
package/README.md CHANGED
@@ -7,3 +7,15 @@ A TypeScript based Passman client library
7
7
 
8
8
  ---
9
9
 
10
+ ## Notes about PassmanClient initialization workflow and caching
11
+
12
+ - Create a PassmanClient instance as data and api (connection) manager to the Passman server part.
13
+ - providing a PersistenceInterface instance like an overwritten instance of DefaultPersistenceService, allows you to configure PassmanClient internal data reconstruction based on the persistence service (configuration)
14
+ - Preload the available vaults using `passmanClient.preloadVaults()` and use them to create a vault list and to authenticate the users vault password against.
15
+ - preloaded vaults only contain some metadata without modification options or credentials
16
+ - Call `preloadedVault.testVaultKey('myPassword123')` for one of the preloaded vaults in `passmanClient.preloadedVaults`
17
+ - If the vault key got validated, you can load the full vault including its credentials, calling `Vault.fetchFullVaultFromServer(...)`
18
+
19
+ Vault cache reconstruction is currently solved by specialized request caching. This also contains the owned, encrypted credential data.
20
+
21
+ Credential decrypted data will be cached by providing a custom DecryptedDataCachingHandlerInterface implementation.
@@ -3,7 +3,11 @@ import { TagInterface } from "./TagInterface";
3
3
  import { IconInterface } from "./IconInterface";
4
4
  import { FileInterface } from "../File/FileInterface";
5
5
  import { OTPConfigInterface } from "./OTPConfigInterface";
6
- export interface CredentialInterface {
6
+ /**
7
+ * Credential interface type of decrypted credential data, as well as more complex field types like files: FileInterface[].
8
+ * Useful for credential object based in-memory decrypted data cache.
9
+ */
10
+ export interface DecryptedCredentialInterface {
7
11
  credential_id?: number;
8
12
  guid?: string;
9
13
  user_id: string;
@@ -1,22 +1,23 @@
1
1
  import { IconInterface } from "./IconInterface";
2
2
  import { ACLInterface } from "../ShareService/ACLInterface";
3
+ import { EncryptedStringType } from "../PassmanCrypto/EncryptedStringType";
3
4
  export interface EncryptedCredentialInterface {
4
5
  credential_id?: number;
5
6
  guid?: string;
6
7
  user_id: string;
7
8
  vault_id: number;
8
9
  label: string;
9
- description: string;
10
- tags: string;
11
- email: string;
12
- username: string;
13
- password: string;
14
- url: string;
15
- files: string;
16
- custom_fields: string;
17
- otp: string;
18
- compromised: string;
19
- shared_key: string | null;
10
+ description: EncryptedStringType;
11
+ tags: EncryptedStringType;
12
+ email: EncryptedStringType;
13
+ username: EncryptedStringType;
14
+ password: EncryptedStringType;
15
+ url: EncryptedStringType;
16
+ files: EncryptedStringType;
17
+ custom_fields: EncryptedStringType;
18
+ otp: EncryptedStringType;
19
+ compromised: EncryptedStringType;
20
+ shared_key: EncryptedStringType | null;
20
21
  favicon: string;
21
22
  icon: IconInterface | null;
22
23
  renew_interval: number | null;
@@ -0,0 +1,35 @@
1
+ import { IconInterface } from "./IconInterface";
2
+ import { EncryptedStringType } from "../PassmanCrypto/EncryptedStringType";
3
+ /**
4
+ * Response type of the PATCH, POST and DELETE /api/v2/credentials/{credentialGuid} api, even for simply owned, owned but shared with others and credentials shared with us.
5
+ */
6
+ export interface EncryptedOwnedCredentialFromServerInterface {
7
+ credential_id: number;
8
+ guid: string;
9
+ user_id: string;
10
+ vault_id: number;
11
+ label: string;
12
+ description: EncryptedStringType;
13
+ tags: EncryptedStringType;
14
+ email: EncryptedStringType;
15
+ username: EncryptedStringType;
16
+ password: EncryptedStringType;
17
+ url: EncryptedStringType;
18
+ files: EncryptedStringType;
19
+ custom_fields: EncryptedStringType;
20
+ otp: EncryptedStringType;
21
+ compromised: EncryptedStringType;
22
+ shared_key: EncryptedStringType | null;
23
+ /**
24
+ * old, does this field still exist?
25
+ * @deprecated
26
+ */
27
+ favicon: string;
28
+ icon: IconInterface | null;
29
+ renew_interval: number | null;
30
+ expire_time: number;
31
+ delete_time: number;
32
+ hidden: boolean;
33
+ created: number;
34
+ changed: number;
35
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import { ACLInterface } from "../ShareService/ACLInterface";
2
+ import { EncryptedOwnedCredentialFromServerInterface } from "./EncryptedOwnedCredentialFromServerInterface";
3
+ export type SpacialCredentialFieldsToUpdateForServerInterface = {
4
+ set_share_key: boolean | null;
5
+ skip_revision: boolean | null;
6
+ acl?: ACLInterface;
7
+ };
8
+ export type EncryptedOwnedCredentialToUpdateForServerInterface = EncryptedOwnedCredentialFromServerInterface & SpacialCredentialFieldsToUpdateForServerInterface;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { EncryptedOwnedCredentialFromServerInterface } from "./EncryptedOwnedCredentialFromServerInterface";
2
+ import { SerializableACLInterface } from "../ShareService/SerializableACLInterface";
3
+ export interface SerializableTransferCredentialInterface {
4
+ encryptedData: EncryptedOwnedCredentialFromServerInterface;
5
+ encryptedSharedCredentialEncryptionKey?: string;
6
+ acl?: SerializableACLInterface;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,20 @@
1
+ export interface DecryptedDataCachingHandlerInterface {
2
+ /**
3
+ * Setting value as undefined equals deleting the key-value pair from that cache.
4
+ * @param cacheName unique cache name (the uniqueness is important to prevent unwanted data exchange between the cache entries)
5
+ * @param key
6
+ * @param value
7
+ */
8
+ set(cacheName: string, key: string, value: string | number | boolean | null | undefined): Promise<void>;
9
+ /**
10
+ * Returns undefined is no value is stored for the given key.
11
+ * @param cacheName unique cache name (the uniqueness is important to prevent unwanted data exchange between the cache entries)
12
+ * @param key
13
+ */
14
+ get(cacheName: string, key: string): Promise<string | number | boolean | null | undefined>;
15
+ /**
16
+ * Clear all data stored in the cache with the given name.
17
+ * @param cacheName
18
+ */
19
+ clearCacheByName(cacheName: string): Promise<void>;
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +1,17 @@
1
1
  import { LoggingHandlerInterface } from "../LoggingHandlerInterface";
2
+ import { PersistenceInterface } from "../PersistenceInterface";
2
3
  export interface NextcloudServerInterface {
3
4
  logger: LoggingHandlerInterface;
5
+ /**
6
+ * Easy way to pass the available cache handlers into the vaults and credentials-
7
+ */
8
+ persistence: PersistenceInterface;
4
9
  getBaseUrl(): string;
5
- setBaseUrl(value: string): string;
10
+ setBaseUrl(value: string): void;
6
11
  getUser(): string;
7
- setUser(value: string): string;
12
+ setUser(value: string): void;
8
13
  getToken(): string;
9
- setToken(value: string): string;
14
+ setToken(value: string): void;
10
15
  getApiUrl(): string;
11
16
  getJson<T>(endpoint: string, errorCallback: (response: Error) => void, getCachedIfPossible?: boolean): Promise<T | void>;
12
17
  deleteJson<T>(endpoint: string, errorCallback: (response: Error) => void): Promise<T | void>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * A base64 encoded string of a Passman SJCL encryption (v1).
3
+ */
4
+ export type EncryptedStringType = string;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import { RequestCachingHandlerInterface } from "./RequestCachingHandlerInterface";
2
+ import { DecryptedDataCachingHandlerInterface } from "./DecryptedDataCachingHandlerInterface";
3
+ export interface PersistenceInterface {
4
+ /**
5
+ * Configures whether to auto-restore "all" internal PassmanClient data on constructing PassmanClient.
6
+ */
7
+ autoRestoreOnReconstruction(): boolean;
8
+ getRequestCacheHandler(): RequestCachingHandlerInterface | undefined;
9
+ getDecryptedDataCacheHandler(): DecryptedDataCachingHandlerInterface | undefined;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,8 @@
1
1
  export interface RequestCachingHandlerInterface {
2
2
  set(key: string, value: string): Promise<void>;
3
- get(key: string): Promise<string>;
3
+ /**
4
+ * Returns undefined if this is the value of if no value was defined for the given key.
5
+ * @param key
6
+ */
7
+ get(key: string): Promise<string | undefined>;
4
8
  }
@@ -1,8 +1,8 @@
1
- import { EncryptedCredentialInterface } from "../Credential/EncryptedCredentialInterface";
1
+ import { EncryptedOwnedCredentialFromServerInterface } from "../Credential/EncryptedOwnedCredentialFromServerInterface";
2
2
  export interface RevisionInterface {
3
3
  revision_id: number;
4
4
  guid: string;
5
5
  created: number;
6
- credential_data: EncryptedCredentialInterface;
6
+ credential_data: EncryptedOwnedCredentialFromServerInterface;
7
7
  edited_by: string;
8
8
  }
@@ -1,4 +1,4 @@
1
- import { EncryptedCredentialInterface } from "../Credential/EncryptedCredentialInterface";
1
+ import { EncryptedOwnedCredentialFromServerInterface } from "../Credential/EncryptedOwnedCredentialFromServerInterface";
2
2
  export interface CredentialShareRequestInterface {
3
3
  acl_id: number;
4
4
  item_id: number;
@@ -12,5 +12,5 @@ export interface CredentialShareRequestInterface {
12
12
  vault_guid: string;
13
13
  shared_key: string;
14
14
  pending: boolean;
15
- credential_data?: EncryptedCredentialInterface;
15
+ credential_data?: EncryptedOwnedCredentialFromServerInterface;
16
16
  }
@@ -0,0 +1,14 @@
1
+ export interface SerializableACLInterface {
2
+ acl_id: number;
3
+ item_id: number;
4
+ item_guid: string;
5
+ user_id: string;
6
+ created: number;
7
+ expire: number;
8
+ expire_views: number;
9
+ permission: number;
10
+ vault_id: number;
11
+ vault_guid: string;
12
+ shared_key: string;
13
+ pending: boolean;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A single vault response object of api/v2/vaults since it returns an array
3
+ */
4
+ export interface GenericVaultInformationFromServerInterface {
5
+ vault_id: number;
6
+ guid: string;
7
+ name: string;
8
+ created: number;
9
+ public_sharing_key: string | null;
10
+ last_access: number;
11
+ challenge_password: string;
12
+ delete_request_pending: boolean;
13
+ }
14
+ /**
15
+ * Response of GET api/v2/vaults
16
+ */
17
+ export type VaultsGetResponseFromServer = GenericVaultInformationFromServerInterface[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import { GenericVaultInformationFromServerInterface } from "./GenericVaultInformationFromServerInterface";
2
+ /**
3
+ * The vault response object of GET api/v2/vaults/{guid}
4
+ */
5
+ export type SerializableSpecificVaultInformationFromServerInterface = GenericVaultInformationFromServerInterface & {
6
+ public_sharing_key: string;
7
+ private_sharing_key: string;
8
+ sharing_keys_generated: number;
9
+ last_access: number;
10
+ delete_request_pending: boolean;
11
+ vault_settings: null;
12
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { SerializableTransferCredentialInterface } from "../Credential/SerializableTransferCredentialInterface";
2
+ import { SerializableSpecificVaultInformationFromServerInterface } from "./SerializableSpecificVaultInformationFromServerInterface";
3
+ export interface SerializableTransferFullVaultInterface {
4
+ serializableSpecificVaultInformation: SerializableSpecificVaultInformationFromServerInterface;
5
+ encryptedSerializableCredentials: SerializableTransferCredentialInterface[];
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import { GenericVaultInformationFromServerInterface } from "./GenericVaultInformationFromServerInterface";
2
+ import { EncryptedOwnedCredentialFromServerInterface } from "../Credential/EncryptedOwnedCredentialFromServerInterface";
3
+ /**
4
+ * The vault response object of GET api/v2/vaults/{guid}
5
+ */
6
+ export type SpecificVaultInformationFromServerInterface = GenericVaultInformationFromServerInterface & {
7
+ public_sharing_key: string;
8
+ private_sharing_key: string;
9
+ sharing_keys_generated: number;
10
+ last_access: number;
11
+ delete_request_pending: boolean;
12
+ vault_settings: null;
13
+ credentials: EncryptedOwnedCredentialFromServerInterface[];
14
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export interface VaultCreateServerResponseInterface {
2
+ vault_id: number;
3
+ guid: string;
4
+ name: string;
5
+ created: number;
6
+ public_sharing_key: null;
7
+ last_access: number;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,6 @@
1
1
  import { NextcloudServerInterface } from "../Interfaces/NextcloudServer/NextcloudServerInterface";
2
2
  import Vault from "./Vault";
3
- import { CredentialInterface } from "../Interfaces/Credential/CredentialInterface";
4
- import { EncryptedCredentialInterface } from "../Interfaces/Credential/EncryptedCredentialInterface";
3
+ import { DecryptedCredentialInterface } from "../Interfaces/Credential/DecryptedCredentialInterface";
5
4
  import { CustomFieldInterface } from "../Interfaces/Credential/CustomFieldInterface";
6
5
  import { TagInterface } from "../Interfaces/Credential/TagInterface";
7
6
  import { IconInterface } from "../Interfaces/Credential/IconInterface";
@@ -10,44 +9,86 @@ import { FileUploadResponseInterface } from "../Interfaces/File/FileUploadRespon
10
9
  import { RevisionInterface } from "../Interfaces/Revision/RevisionInterface";
11
10
  import { OTPConfigInterface } from "../Interfaces/Credential/OTPConfigInterface";
12
11
  import { ACLInterface } from "../Interfaces/ShareService/ACLInterface";
12
+ import { EncryptedOwnedCredentialFromServerInterface } from "../Interfaces/Credential/EncryptedOwnedCredentialFromServerInterface";
13
+ import { SpacialCredentialFieldsToUpdateForServerInterface } from "../Interfaces/Credential/EncryptedOwnedCredentialToUpdateForServerInterface";
14
+ import { SerializableTransferCredentialInterface } from "../Interfaces/Credential/SerializableTransferCredentialInterface";
13
15
  export default class Credential {
14
16
  protected vault: Vault;
15
17
  protected server: NextcloudServerInterface;
16
18
  ENCRYPTED_FIELDS: string[];
17
- protected encryptedData: EncryptedCredentialInterface;
19
+ /**
20
+ * Contains all ENCRYPTED_FIELDS that matches to one of the types: string|number|boolean|null
21
+ */
22
+ SERIALIZABLE_ENCRYPTED_FIELDS: string[];
23
+ /**
24
+ * encryptedData & spacialServerUpdateFields needs to be merged in order to save to credential to the server (api)
25
+ * @protected
26
+ */
27
+ protected encryptedData: EncryptedOwnedCredentialFromServerInterface;
28
+ /**
29
+ * Should not be overwritten/cleared during Credential instance lifetime, since it contains acl data managed by ShareService.
30
+ * @protected
31
+ */
32
+ protected _spacialServerUpdateFields: SpacialCredentialFieldsToUpdateForServerInterface;
33
+ /**
34
+ * This is always set if the credential is shared with us.
35
+ *
36
+ * The sharedCredentialEncryptionKey is encrypted with the vault key and injected by ShareService.
37
+ * To be able to hold this credential instance in an (initial, fully) unencrypted state (needed to fetch the full vault without vault key given),
38
+ * we need to split the encrypted and unencrypted shared credential encryption keys.
39
+ */
40
+ encryptedSharedCredentialEncryptionKey?: string;
41
+ private sharedCredentialEncryptionKey?;
18
42
  private decryptedDataCache;
19
- sharedCredentialEncryptionKey: string;
20
43
  private foundUnspecifiedEncryptionError;
44
+ private readonly decryptedDataCacheName;
21
45
  overwriteVaultKey: string | undefined;
22
- constructor(vault: Vault, server: NextcloudServerInterface, encryptedData?: EncryptedCredentialInterface);
46
+ constructor(vault: Vault, server: NextcloudServerInterface, encryptedData?: EncryptedOwnedCredentialFromServerInterface);
23
47
  private initializeAllFields;
24
48
  /**
25
49
  * Save new credential on the server.
26
50
  * The current credential object will be updated with the server response data if possible.
27
51
  */
28
- save(): Promise<void | EncryptedCredentialInterface>;
52
+ save(): Promise<void | EncryptedOwnedCredentialFromServerInterface>;
29
53
  /**
30
54
  * Update / edit an existing credential on the server.
31
55
  * The current credential object will be updated with the server response data if possible.
56
+ * This will not touch the virtual acl field.
32
57
  */
33
- update(): Promise<void | EncryptedCredentialInterface>;
58
+ update(): Promise<void | EncryptedOwnedCredentialFromServerInterface>;
34
59
  /**
35
60
  * Refresh the local credential data based on the server, using the credentials guid.
36
- * It is not supported to do that for credentials, shared with us.
61
+ * It is not supported to do that for credentials, shared with us. (Therefore this will not touch the virtual acl field.)
37
62
  */
38
- refresh(): Promise<void | EncryptedCredentialInterface>;
63
+ refresh(): Promise<void | EncryptedOwnedCredentialFromServerInterface>;
39
64
  /**
40
65
  * Destroys the credential on the server and removes itself from its local vault.
41
66
  */
42
- destroy(): Promise<void | EncryptedCredentialInterface>;
43
- clearDecryptedDataCache(): void;
67
+ destroy(): Promise<void | EncryptedOwnedCredentialFromServerInterface>;
68
+ /**
69
+ * This is the correct function to "lock" the credential (to be called subsequently when the vault got locked).
70
+ * It clears the decrypted credential data cache as well as a potential sharedCredentialEncryptionKey.
71
+ * This will not clear the serialized decrypted data cache, managed by the used DecryptedDataCachingHandlerInterface implementation.
72
+ * Set clearCachingHandlerManagedDecryptedData=true to do so (by calling getDecryptedDataCacheHandler().clearCacheByName('...'))
73
+ */
74
+ clearDecryptedDataCache(clearCachingHandlerManagedDecryptedData?: boolean): void;
75
+ /**
76
+ * Restore only serializable fields of the CredentialInterface.
77
+ */
78
+ restoreSerializedDecryptedDataCache(): Promise<void>;
79
+ /**
80
+ * Update or delete an entry in the decrypted data cache.
81
+ * @param propertyName
82
+ * @param deleteFromCache
83
+ */
84
+ private updateSerializedDecryptedDataCacheEntry;
44
85
  /**
45
86
  * Create a credential object based on its encrypted data.
46
87
  * @param data
47
88
  * @param vault
48
89
  * @param server
49
90
  */
50
- static fromData(data: EncryptedCredentialInterface, vault: Vault, server: NextcloudServerInterface): Promise<Credential>;
91
+ static fromData(data: EncryptedOwnedCredentialFromServerInterface, vault: Vault, server: NextcloudServerInterface): Credential;
51
92
  /**
52
93
  * Create a credential object based on its guid. This will fetch the current credential data from the server.
53
94
  * @param guid
@@ -55,16 +96,17 @@ export default class Credential {
55
96
  * @param server
56
97
  */
57
98
  static fromGuid(guid: string, vault: Vault, server: NextcloudServerInterface): Promise<Credential>;
99
+ static fromSerializable(serialized: SerializableTransferCredentialInterface, vault: Vault, server: NextcloudServerInterface): Credential;
58
100
  getRevisions(): Promise<void | RevisionInterface[]>;
59
101
  /**
60
102
  * Update credential (encryptedData store) with the new values, if they have changed.
61
103
  * This does not update the servers credential instance.
62
104
  * @param decryptedCredentialData
63
105
  */
64
- updateData(decryptedCredentialData: CredentialInterface): void;
65
- exportData(): CredentialInterface;
106
+ updateData(decryptedCredentialData: DecryptedCredentialInterface): void;
107
+ exportData(): DecryptedCredentialInterface;
66
108
  /**
67
- * Creates a local 100% clone of the current credential.
109
+ * Creates a local 100% clone of the current credential. The clone contains only encrypted data.
68
110
  */
69
111
  clone(): Credential;
70
112
  /**
@@ -100,6 +142,10 @@ export default class Credential {
100
142
  * @param plainFile
101
143
  */
102
144
  encryptUploadFile(plainFile: FileInterface): Promise<void | FileUploadResponseInterface>;
145
+ /**
146
+ * Serialized, encrypted credential data from non-object (string only) transfer methods (like WebExtension messaging api).
147
+ */
148
+ getAsSerializable(): SerializableTransferCredentialInterface;
103
149
  /**
104
150
  * Deletes the given file from the server.
105
151
  * This method does *not* delete the file from the local credential files list!
@@ -107,7 +153,7 @@ export default class Credential {
107
153
  */
108
154
  deleteFile(file: FileInterface): Promise<void | FileUploadResponseInterface>;
109
155
  getVaultGuid(): string;
110
- getEncrypted(): EncryptedCredentialInterface;
156
+ getEncrypted(): EncryptedOwnedCredentialFromServerInterface;
111
157
  hasUnspecifiedEncryptionError(): boolean;
112
158
  get credential_id(): number;
113
159
  set credential_id(value: number);
@@ -164,10 +210,15 @@ export default class Credential {
164
210
  set created(value: number);
165
211
  get changed(): number;
166
212
  set changed(value: number);
167
- get set_share_key(): boolean;
213
+ get set_share_key(): boolean | undefined;
168
214
  set set_share_key(value: boolean);
169
- get skip_revision(): boolean;
215
+ get skip_revision(): boolean | undefined;
170
216
  set skip_revision(value: boolean);
171
- get acl(): ACLInterface;
217
+ get acl(): ACLInterface | undefined;
218
+ /**
219
+ * Will be called short after credential instantiation by the ShareService.
220
+ * @param value
221
+ */
172
222
  set acl(value: ACLInterface);
223
+ get spacialServerUpdateFields(): SpacialCredentialFieldsToUpdateForServerInterface;
173
224
  }