@credo-ts/askar 0.6.1-pr-2091-20241119140918 → 0.6.1
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.
- package/build/AskarApi.d.mts +68 -0
- package/build/AskarApi.d.mts.map +1 -0
- package/build/AskarApi.mjs +94 -0
- package/build/AskarApi.mjs.map +1 -0
- package/build/AskarApiOptions.d.mts +29 -0
- package/build/AskarApiOptions.d.mts.map +1 -0
- package/build/AskarModule.d.mts +18 -0
- package/build/AskarModule.d.mts.map +1 -0
- package/build/AskarModule.mjs +61 -0
- package/build/AskarModule.mjs.map +1 -0
- package/build/AskarModuleConfig.d.mts +125 -0
- package/build/AskarModuleConfig.d.mts.map +1 -0
- package/build/AskarModuleConfig.mjs +41 -0
- package/build/AskarModuleConfig.mjs.map +1 -0
- package/build/AskarStorageConfig.d.mts +32 -0
- package/build/AskarStorageConfig.d.mts.map +1 -0
- package/build/AskarStorageConfig.mjs +11 -0
- package/build/AskarStorageConfig.mjs.map +1 -0
- package/build/AskarStoreManager.d.mts +109 -0
- package/build/AskarStoreManager.d.mts.map +1 -0
- package/build/AskarStoreManager.mjs +386 -0
- package/build/AskarStoreManager.mjs.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs +10 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateMetadata.mjs +7 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateParam.mjs +9 -0
- package/build/error/AskarError.d.mts +1 -0
- package/build/error/AskarError.mjs +12 -0
- package/build/error/AskarError.mjs.map +1 -0
- package/build/error/AskarStoreDuplicateError.d.mts +13 -0
- package/build/error/AskarStoreDuplicateError.d.mts.map +1 -0
- package/build/error/AskarStoreDuplicateError.mjs +12 -0
- package/build/error/AskarStoreDuplicateError.mjs.map +1 -0
- package/build/error/AskarStoreError.d.mts +13 -0
- package/build/error/AskarStoreError.d.mts.map +1 -0
- package/build/error/AskarStoreError.mjs +12 -0
- package/build/error/AskarStoreError.mjs.map +1 -0
- package/build/error/AskarStoreExportPathExistsError.d.mts +13 -0
- package/build/error/AskarStoreExportPathExistsError.d.mts.map +1 -0
- package/build/error/AskarStoreExportPathExistsError.mjs +12 -0
- package/build/error/AskarStoreExportPathExistsError.mjs.map +1 -0
- package/build/error/AskarStoreExportUnsupportedError.d.mts +13 -0
- package/build/error/AskarStoreExportUnsupportedError.d.mts.map +1 -0
- package/build/error/AskarStoreExportUnsupportedError.mjs +12 -0
- package/build/error/AskarStoreExportUnsupportedError.mjs.map +1 -0
- package/build/error/AskarStoreImportPathExistsError.d.mts +13 -0
- package/build/error/AskarStoreImportPathExistsError.d.mts.map +1 -0
- package/build/error/AskarStoreImportPathExistsError.mjs +12 -0
- package/build/error/AskarStoreImportPathExistsError.mjs.map +1 -0
- package/build/error/AskarStoreInvalidKeyError.d.mts +13 -0
- package/build/error/AskarStoreInvalidKeyError.d.mts.map +1 -0
- package/build/error/AskarStoreInvalidKeyError.mjs +12 -0
- package/build/error/AskarStoreInvalidKeyError.mjs.map +1 -0
- package/build/error/AskarStoreNotFoundError.d.mts +13 -0
- package/build/error/AskarStoreNotFoundError.d.mts.map +1 -0
- package/build/error/AskarStoreNotFoundError.mjs +12 -0
- package/build/error/AskarStoreNotFoundError.mjs.map +1 -0
- package/build/error/index.d.mts +8 -0
- package/build/error/index.mjs +8 -0
- package/build/index.d.mts +19 -0
- package/build/index.mjs +19 -0
- package/build/kms/AskarKeyManagementService.d.mts +30 -0
- package/build/kms/AskarKeyManagementService.d.mts.map +1 -0
- package/build/kms/AskarKeyManagementService.mjs +415 -0
- package/build/kms/AskarKeyManagementService.mjs.map +1 -0
- package/build/kms/crypto/decrypt.mjs +21 -0
- package/build/kms/crypto/decrypt.mjs.map +1 -0
- package/build/kms/crypto/deriveKey.mjs +87 -0
- package/build/kms/crypto/deriveKey.mjs.map +1 -0
- package/build/kms/crypto/encrypt.mjs +24 -0
- package/build/kms/crypto/encrypt.mjs.map +1 -0
- package/build/kms/crypto/randomBytes.mjs +19 -0
- package/build/kms/crypto/randomBytes.mjs.map +1 -0
- package/build/storage/AskarStorageService.d.mts +34 -0
- package/build/storage/AskarStorageService.d.mts.map +1 -0
- package/build/storage/AskarStorageService.mjs +169 -0
- package/build/storage/AskarStorageService.mjs.map +1 -0
- package/build/storage/index.d.mts +1 -0
- package/build/storage/index.mjs +1 -0
- package/build/storage/utils.d.mts +8 -0
- package/build/storage/utils.d.mts.map +1 -0
- package/build/storage/utils.mjs +58 -0
- package/build/storage/utils.mjs.map +1 -0
- package/build/tenants.mjs +42 -0
- package/build/tenants.mjs.map +1 -0
- package/build/utils/askarError.d.mts +1 -0
- package/build/utils/askarError.mjs +21 -0
- package/build/utils/askarError.mjs.map +1 -0
- package/build/utils/askarKeyTypes.d.mts +2 -0
- package/build/utils/askarKeyTypes.mjs +25 -0
- package/build/utils/askarKeyTypes.mjs.map +1 -0
- package/build/utils/askarStoreConfig.d.mts +2 -0
- package/build/utils/askarStoreConfig.mjs +47 -0
- package/build/utils/askarStoreConfig.mjs.map +1 -0
- package/build/utils/index.d.mts +4 -0
- package/build/utils/index.mjs +4 -0
- package/build/utils/transformPrivateKey.d.mts +73 -0
- package/build/utils/transformPrivateKey.d.mts.map +1 -0
- package/build/utils/transformPrivateKey.mjs +73 -0
- package/build/utils/transformPrivateKey.mjs.map +1 -0
- package/package.json +21 -29
- package/build/AskarModule.d.ts +0 -9
- package/build/AskarModule.js +0 -58
- package/build/AskarModule.js.map +0 -1
- package/build/AskarModuleConfig.d.ts +0 -68
- package/build/AskarModuleConfig.js +0 -33
- package/build/AskarModuleConfig.js.map +0 -1
- package/build/index.d.ts +0 -4
- package/build/index.js +0 -16
- package/build/index.js.map +0 -1
- package/build/secureEnvironment/index.d.ts +0 -1
- package/build/secureEnvironment/index.js +0 -18
- package/build/secureEnvironment/index.js.map +0 -1
- package/build/secureEnvironment/secureEnvironment.d.ts +0 -5
- package/build/secureEnvironment/secureEnvironment.js +0 -7
- package/build/secureEnvironment/secureEnvironment.js.map +0 -1
- package/build/secureEnvironment/secureEnvironment.native.d.ts +0 -1
- package/build/secureEnvironment/secureEnvironment.native.js +0 -14
- package/build/secureEnvironment/secureEnvironment.native.js.map +0 -1
- package/build/storage/AskarStorageService.d.ts +0 -17
- package/build/storage/AskarStorageService.js +0 -141
- package/build/storage/AskarStorageService.js.map +0 -1
- package/build/storage/index.d.ts +0 -1
- package/build/storage/index.js +0 -18
- package/build/storage/index.js.map +0 -1
- package/build/storage/utils.d.ts +0 -15
- package/build/storage/utils.js +0 -109
- package/build/storage/utils.js.map +0 -1
- package/build/utils/askarError.d.ts +0 -14
- package/build/utils/askarError.js +0 -20
- package/build/utils/askarError.js.map +0 -1
- package/build/utils/askarKeyBackend.d.ts +0 -3
- package/build/utils/askarKeyBackend.js +0 -15
- package/build/utils/askarKeyBackend.js.map +0 -1
- package/build/utils/askarKeyTypes.d.ts +0 -8
- package/build/utils/askarKeyTypes.js +0 -46
- package/build/utils/askarKeyTypes.js.map +0 -1
- package/build/utils/askarWalletConfig.d.ts +0 -14
- package/build/utils/askarWalletConfig.js +0 -75
- package/build/utils/askarWalletConfig.js.map +0 -1
- package/build/utils/assertAskarWallet.d.ts +0 -3
- package/build/utils/assertAskarWallet.js +0 -14
- package/build/utils/assertAskarWallet.js.map +0 -1
- package/build/utils/index.d.ts +0 -3
- package/build/utils/index.js +0 -20
- package/build/utils/index.js.map +0 -1
- package/build/wallet/AskarBaseWallet.d.ts +0 -112
- package/build/wallet/AskarBaseWallet.js +0 -540
- package/build/wallet/AskarBaseWallet.js.map +0 -1
- package/build/wallet/AskarProfileWallet.d.ts +0 -24
- package/build/wallet/AskarProfileWallet.js +0 -150
- package/build/wallet/AskarProfileWallet.js.map +0 -1
- package/build/wallet/AskarWallet.d.ts +0 -58
- package/build/wallet/AskarWallet.js +0 -342
- package/build/wallet/AskarWallet.js.map +0 -1
- package/build/wallet/AskarWalletStorageConfig.d.ts +0 -31
- package/build/wallet/AskarWalletStorageConfig.js +0 -11
- package/build/wallet/AskarWalletStorageConfig.js.map +0 -1
- package/build/wallet/JweEnvelope.d.ts +0 -32
- package/build/wallet/JweEnvelope.js +0 -55
- package/build/wallet/JweEnvelope.js.map +0 -1
- package/build/wallet/didcommV1.d.ts +0 -8
- package/build/wallet/didcommV1.js +0 -155
- package/build/wallet/didcommV1.js.map +0 -1
- package/build/wallet/index.d.ts +0 -3
- package/build/wallet/index.js +0 -23
- package/build/wallet/index.js.map +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AskarModuleConfig } from "./AskarModuleConfig.mjs";
|
|
2
|
+
import { AskarStoreExportOptions, AskarStoreImportOptions, AskarStoreRotateKeyOptions } from "./AskarApiOptions.mjs";
|
|
3
|
+
import { AskarStoreManager } from "./AskarStoreManager.mjs";
|
|
4
|
+
import { AgentContext } from "@credo-ts/core";
|
|
5
|
+
|
|
6
|
+
//#region src/AskarApi.d.ts
|
|
7
|
+
declare class AskarApi {
|
|
8
|
+
private agentContext;
|
|
9
|
+
private askarStoreManager;
|
|
10
|
+
readonly config: AskarModuleConfig;
|
|
11
|
+
constructor(agentContext: AgentContext, askarStoreManager: AskarStoreManager, config: AskarModuleConfig);
|
|
12
|
+
get isStoreOpen(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @throws {AskarStoreDuplicateError} if the wallet already exists
|
|
15
|
+
* @throws {AskarStoreError} if another error occurs
|
|
16
|
+
*/
|
|
17
|
+
provisionStore(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* @throws {AskarStoreNotFoundError} if the wallet does not exist
|
|
20
|
+
* @throws {AskarStoreError} if another error occurs
|
|
21
|
+
*/
|
|
22
|
+
openStore(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Rotate the key of the current askar store.
|
|
25
|
+
*
|
|
26
|
+
* NOTE: multiple agent contexts (tenants) can use the same store. This method rotates the key for the whole store,
|
|
27
|
+
* it is advised to only run this method on the root tenant agent when using profile per wallet database strategy.
|
|
28
|
+
* After running this method you should change the store configuration in the Askar module.
|
|
29
|
+
*
|
|
30
|
+
* @throws {AskarStoreNotFoundError} if the wallet does not exist
|
|
31
|
+
* @throws {AskarStoreError} if another error occurs
|
|
32
|
+
*/
|
|
33
|
+
rotateStoreKey(options: AskarStoreRotateKeyOptions): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Exports the current askar store.
|
|
36
|
+
*
|
|
37
|
+
* NOTE: a store can contain profiles for multiple tenants. When you export a store
|
|
38
|
+
* all profiles will be exported with it.
|
|
39
|
+
*
|
|
40
|
+
* NOTE: store must be open before store can be expored
|
|
41
|
+
*/
|
|
42
|
+
exportStore(options: AskarStoreExportOptions): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Imports from an external store config into the current askar store config.
|
|
45
|
+
*
|
|
46
|
+
* NOTE: store must be closed first (using `closeStore`) before store can be imported
|
|
47
|
+
*/
|
|
48
|
+
importStore(options: AskarStoreImportOptions): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Delete the current askar store.
|
|
51
|
+
*
|
|
52
|
+
* NOTE: multiple agent contexts (tenants) can use the same store. This method deletes the whole store.
|
|
53
|
+
*
|
|
54
|
+
*
|
|
55
|
+
* @throws {AskarStoreNotFoundError} if the wallet does not exist
|
|
56
|
+
* @throws {AskarStoreError} if another error occurs
|
|
57
|
+
*/
|
|
58
|
+
deleteStore(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Close the current askar store.
|
|
61
|
+
*
|
|
62
|
+
* This will close all sessions (also for tenants) in this store.
|
|
63
|
+
*/
|
|
64
|
+
closeStore(): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { AskarApi };
|
|
68
|
+
//# sourceMappingURL=AskarApi.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarApi.d.mts","names":[],"sources":["../src/AskarApi.ts"],"sourcesContent":[],"mappings":";;;;;;cAQa,QAAA;;EAAA,QAAA,iBAAQ;EAIO,SAAA,MAAA,EAAA,iBAAA;EAFF,WAAA,CAAA,YAAA,EAAA,YAAA,EAAA,iBAAA,EACK,iBADL,EAAA,MAAA,EAEE,iBAFF;EACK,IAAA,WAAA,CAAA,CAAA,EAAA,OAAA;EACH;;;;EAiCwC,cAAA,CAAA,CAAA,EAtBnC,OAsBmC,CAAA,IAAA,CAAA;EAYhC;;;;EAsBN,SAAA,CAAA,CAAA,EAhDF,OAgDE,CAAA,IAAA,CAAA;EASL;;;;;;;;;;0BA3Cc,6BAA6B;;;;;;;;;uBAYhC,0BAAuB;;;;;;uBASvB,0BAAuB;;;;;;;;;;iBAa7B;;;;;;gBASL"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { AskarModuleConfig } from "./AskarModuleConfig.mjs";
|
|
2
|
+
import { __decorateMetadata } from "./_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateMetadata.mjs";
|
|
3
|
+
import { __decorate } from "./_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
4
|
+
import { AskarStoreManager } from "./AskarStoreManager.mjs";
|
|
5
|
+
import { AgentContext } from "@credo-ts/core";
|
|
6
|
+
import { injectable as injectable$1 } from "tsyringe";
|
|
7
|
+
|
|
8
|
+
//#region src/AskarApi.ts
|
|
9
|
+
var _ref, _ref2, _ref3;
|
|
10
|
+
let AskarApi = class AskarApi$1 {
|
|
11
|
+
constructor(agentContext, askarStoreManager, config) {
|
|
12
|
+
this.agentContext = agentContext;
|
|
13
|
+
this.askarStoreManager = askarStoreManager;
|
|
14
|
+
this.config = config;
|
|
15
|
+
}
|
|
16
|
+
get isStoreOpen() {
|
|
17
|
+
return this.askarStoreManager.isStoreOpen(this.agentContext);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @throws {AskarStoreDuplicateError} if the wallet already exists
|
|
21
|
+
* @throws {AskarStoreError} if another error occurs
|
|
22
|
+
*/
|
|
23
|
+
async provisionStore() {
|
|
24
|
+
await this.askarStoreManager.provisionStore(this.agentContext);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @throws {AskarStoreNotFoundError} if the wallet does not exist
|
|
28
|
+
* @throws {AskarStoreError} if another error occurs
|
|
29
|
+
*/
|
|
30
|
+
async openStore() {
|
|
31
|
+
await this.askarStoreManager.openStore(this.agentContext);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Rotate the key of the current askar store.
|
|
35
|
+
*
|
|
36
|
+
* NOTE: multiple agent contexts (tenants) can use the same store. This method rotates the key for the whole store,
|
|
37
|
+
* it is advised to only run this method on the root tenant agent when using profile per wallet database strategy.
|
|
38
|
+
* After running this method you should change the store configuration in the Askar module.
|
|
39
|
+
*
|
|
40
|
+
* @throws {AskarStoreNotFoundError} if the wallet does not exist
|
|
41
|
+
* @throws {AskarStoreError} if another error occurs
|
|
42
|
+
*/
|
|
43
|
+
async rotateStoreKey(options) {
|
|
44
|
+
await this.askarStoreManager.rotateStoreKey(this.agentContext, options);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Exports the current askar store.
|
|
48
|
+
*
|
|
49
|
+
* NOTE: a store can contain profiles for multiple tenants. When you export a store
|
|
50
|
+
* all profiles will be exported with it.
|
|
51
|
+
*
|
|
52
|
+
* NOTE: store must be open before store can be expored
|
|
53
|
+
*/
|
|
54
|
+
async exportStore(options) {
|
|
55
|
+
await this.askarStoreManager.exportStore(this.agentContext, options);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Imports from an external store config into the current askar store config.
|
|
59
|
+
*
|
|
60
|
+
* NOTE: store must be closed first (using `closeStore`) before store can be imported
|
|
61
|
+
*/
|
|
62
|
+
async importStore(options) {
|
|
63
|
+
await this.askarStoreManager.importStore(this.agentContext, options);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Delete the current askar store.
|
|
67
|
+
*
|
|
68
|
+
* NOTE: multiple agent contexts (tenants) can use the same store. This method deletes the whole store.
|
|
69
|
+
*
|
|
70
|
+
*
|
|
71
|
+
* @throws {AskarStoreNotFoundError} if the wallet does not exist
|
|
72
|
+
* @throws {AskarStoreError} if another error occurs
|
|
73
|
+
*/
|
|
74
|
+
async deleteStore() {
|
|
75
|
+
await this.askarStoreManager.deleteStore(this.agentContext);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Close the current askar store.
|
|
79
|
+
*
|
|
80
|
+
* This will close all sessions (also for tenants) in this store.
|
|
81
|
+
*/
|
|
82
|
+
async closeStore() {
|
|
83
|
+
await this.askarStoreManager.closeStore(this.agentContext);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
AskarApi = __decorate([injectable$1(), __decorateMetadata("design:paramtypes", [
|
|
87
|
+
typeof (_ref = typeof AgentContext !== "undefined" && AgentContext) === "function" ? _ref : Object,
|
|
88
|
+
typeof (_ref2 = typeof AskarStoreManager !== "undefined" && AskarStoreManager) === "function" ? _ref2 : Object,
|
|
89
|
+
typeof (_ref3 = typeof AskarModuleConfig !== "undefined" && AskarModuleConfig) === "function" ? _ref3 : Object
|
|
90
|
+
])], AskarApi);
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
export { AskarApi };
|
|
94
|
+
//# sourceMappingURL=AskarApi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarApi.mjs","names":["AskarApi","agentContext: AgentContext","askarStoreManager: AskarStoreManager","config: AskarModuleConfig","injectable"],"sources":["../src/AskarApi.ts"],"sourcesContent":["import { AgentContext } from '@credo-ts/core'\nimport { injectable } from 'tsyringe'\n\nimport type { AskarStoreExportOptions, AskarStoreImportOptions, AskarStoreRotateKeyOptions } from './AskarApiOptions'\nimport { AskarModuleConfig } from './AskarModuleConfig'\nimport { AskarStoreManager } from './AskarStoreManager'\n\n@injectable()\nexport class AskarApi {\n public constructor(\n private agentContext: AgentContext,\n private askarStoreManager: AskarStoreManager,\n public readonly config: AskarModuleConfig\n ) {}\n\n public get isStoreOpen() {\n return this.askarStoreManager.isStoreOpen(this.agentContext)\n }\n\n /**\n * @throws {AskarStoreDuplicateError} if the wallet already exists\n * @throws {AskarStoreError} if another error occurs\n */\n public async provisionStore(): Promise<void> {\n await this.askarStoreManager.provisionStore(this.agentContext)\n }\n\n /**\n * @throws {AskarStoreNotFoundError} if the wallet does not exist\n * @throws {AskarStoreError} if another error occurs\n */\n public async openStore(): Promise<void> {\n await this.askarStoreManager.openStore(this.agentContext)\n }\n\n /**\n * Rotate the key of the current askar store.\n *\n * NOTE: multiple agent contexts (tenants) can use the same store. This method rotates the key for the whole store,\n * it is advised to only run this method on the root tenant agent when using profile per wallet database strategy.\n * After running this method you should change the store configuration in the Askar module.\n *\n * @throws {AskarStoreNotFoundError} if the wallet does not exist\n * @throws {AskarStoreError} if another error occurs\n */\n public async rotateStoreKey(options: AskarStoreRotateKeyOptions): Promise<void> {\n await this.askarStoreManager.rotateStoreKey(this.agentContext, options)\n }\n\n /**\n * Exports the current askar store.\n *\n * NOTE: a store can contain profiles for multiple tenants. When you export a store\n * all profiles will be exported with it.\n *\n * NOTE: store must be open before store can be expored\n */\n public async exportStore(options: AskarStoreExportOptions) {\n await this.askarStoreManager.exportStore(this.agentContext, options)\n }\n\n /**\n * Imports from an external store config into the current askar store config.\n *\n * NOTE: store must be closed first (using `closeStore`) before store can be imported\n */\n public async importStore(options: AskarStoreImportOptions) {\n await this.askarStoreManager.importStore(this.agentContext, options)\n }\n\n /**\n * Delete the current askar store.\n *\n * NOTE: multiple agent contexts (tenants) can use the same store. This method deletes the whole store.\n *\n *\n * @throws {AskarStoreNotFoundError} if the wallet does not exist\n * @throws {AskarStoreError} if another error occurs\n */\n public async deleteStore(): Promise<void> {\n await this.askarStoreManager.deleteStore(this.agentContext)\n }\n\n /**\n * Close the current askar store.\n *\n * This will close all sessions (also for tenants) in this store.\n */\n public async closeStore() {\n await this.askarStoreManager.closeStore(this.agentContext)\n }\n}\n"],"mappings":";;;;;;;;;AAQO,qBAAMA,WAAS;CACpB,AAAO,YACL,AAAQC,cACR,AAAQC,mBACR,AAAgBC,QAChB;EAHQ;EACA;EACQ;;CAGlB,IAAW,cAAc;AACvB,SAAO,KAAK,kBAAkB,YAAY,KAAK,aAAa;;;;;;CAO9D,MAAa,iBAAgC;AAC3C,QAAM,KAAK,kBAAkB,eAAe,KAAK,aAAa;;;;;;CAOhE,MAAa,YAA2B;AACtC,QAAM,KAAK,kBAAkB,UAAU,KAAK,aAAa;;;;;;;;;;;;CAa3D,MAAa,eAAe,SAAoD;AAC9E,QAAM,KAAK,kBAAkB,eAAe,KAAK,cAAc,QAAQ;;;;;;;;;;CAWzE,MAAa,YAAY,SAAkC;AACzD,QAAM,KAAK,kBAAkB,YAAY,KAAK,cAAc,QAAQ;;;;;;;CAQtE,MAAa,YAAY,SAAkC;AACzD,QAAM,KAAK,kBAAkB,YAAY,KAAK,cAAc,QAAQ;;;;;;;;;;;CAYtE,MAAa,cAA6B;AACxC,QAAM,KAAK,kBAAkB,YAAY,KAAK,aAAa;;;;;;;CAQ7D,MAAa,aAAa;AACxB,QAAM,KAAK,kBAAkB,WAAW,KAAK,aAAa;;;uBAlF7DC,cAAY"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AskarModuleConfigStoreOptions } from "./AskarModuleConfig.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/AskarApiOptions.d.ts
|
|
4
|
+
interface AskarStoreExportOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The store config to export the current store to.
|
|
7
|
+
*/
|
|
8
|
+
exportToStore: AskarModuleConfigStoreOptions;
|
|
9
|
+
}
|
|
10
|
+
interface AskarStoreImportOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The store config to import the current store from.
|
|
13
|
+
*/
|
|
14
|
+
importFromStore: AskarModuleConfigStoreOptions;
|
|
15
|
+
}
|
|
16
|
+
interface AskarStoreRotateKeyOptions {
|
|
17
|
+
/**
|
|
18
|
+
* The new key to use for the store.
|
|
19
|
+
*/
|
|
20
|
+
newKey: string;
|
|
21
|
+
/**
|
|
22
|
+
* The new key derivation method to use for the store. If not provided the
|
|
23
|
+
* key derivation method from the current store config will be used.
|
|
24
|
+
*/
|
|
25
|
+
newKeyDerivationMethod?: AskarModuleConfigStoreOptions['keyDerivationMethod'];
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { AskarStoreExportOptions, AskarStoreImportOptions, AskarStoreRotateKeyOptions };
|
|
29
|
+
//# sourceMappingURL=AskarApiOptions.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarApiOptions.d.mts","names":[],"sources":["../src/AskarApiOptions.ts"],"sourcesContent":[],"mappings":";;;UAEiB,uBAAA;;AAAjB;AAOA;EAOiB,aAAA,EAVA,6BAoBU;;UAjBV,uBAAA;;;;mBAIE;;UAGF,0BAAA;;;;;;;;;2BAUU"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AskarModuleConfig, AskarModuleConfigOptions } from "./AskarModuleConfig.mjs";
|
|
2
|
+
import { AskarApi } from "./AskarApi.mjs";
|
|
3
|
+
import { AgentContext, DependencyManager, Module } from "@credo-ts/core";
|
|
4
|
+
|
|
5
|
+
//#region src/AskarModule.d.ts
|
|
6
|
+
declare class AskarModule implements Module {
|
|
7
|
+
readonly config: AskarModuleConfig;
|
|
8
|
+
constructor(config: AskarModuleConfigOptions);
|
|
9
|
+
api: typeof AskarApi;
|
|
10
|
+
register(dependencyManager: DependencyManager): void;
|
|
11
|
+
onInitializeContext(agentContext: AgentContext): Promise<void>;
|
|
12
|
+
onProvisionContext(agentContext: AgentContext): Promise<void>;
|
|
13
|
+
onDeleteContext(agentContext: AgentContext): Promise<void>;
|
|
14
|
+
onCloseContext(agentContext: AgentContext): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { AskarModule };
|
|
18
|
+
//# sourceMappingURL=AskarModule.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarModule.d.mts","names":[],"sources":["../src/AskarModule.ts"],"sourcesContent":[],"mappings":";;;;;cAYa,WAAA,YAAuB;EAAvB,SAAA,MAAY,EACC,iBADD;EACC,WAAA,CAAA,MAAA,EAEG,wBAFH;EAEG,GAAA,EAAA,OAIjB,QAJiB;EAIjB,QAAA,CAAA,iBAAA,EAEyB,iBAFzB,CAAA,EAAA,IAAA;EAEyB,mBAAA,CAAA,YAAA,EAgCY,YAhCZ,CAAA,EAgCwB,OAhCxB,CAAA,IAAA,CAAA;EAgCY,kBAAA,CAAA,YAAA,EAKD,YALC,CAAA,EAKW,OALX,CAAA,IAAA,CAAA;EAAY,eAAA,CAAA,YAAA,EAoChB,YApCgB,CAAA,EAoCJ,OApCI,CAAA,IAAA,CAAA;EAKb,cAAA,CAAA,YAAA,EAsCJ,YAtCI,CAAA,EAsCW,OAtCX,CAAA,IAAA,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { AskarModuleConfig, AskarMultiWalletDatabaseScheme } from "./AskarModuleConfig.mjs";
|
|
2
|
+
import { storeAskarStoreConfigForContextCorrelationId } from "./tenants.mjs";
|
|
3
|
+
import { AskarErrorCode } from "./utils/askarError.mjs";
|
|
4
|
+
import "./utils/index.mjs";
|
|
5
|
+
import { AskarStoreManager } from "./AskarStoreManager.mjs";
|
|
6
|
+
import { AskarApi } from "./AskarApi.mjs";
|
|
7
|
+
import { AskarKeyManagementService } from "./kms/AskarKeyManagementService.mjs";
|
|
8
|
+
import { AskarStorageService } from "./storage/AskarStorageService.mjs";
|
|
9
|
+
import "./storage/index.mjs";
|
|
10
|
+
import { AgentConfig, CredoError, InjectionSymbols, Kms } from "@credo-ts/core";
|
|
11
|
+
import { AskarError } from "@openwallet-foundation/askar-shared";
|
|
12
|
+
|
|
13
|
+
//#region src/AskarModule.ts
|
|
14
|
+
var AskarModule = class {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.api = AskarApi;
|
|
17
|
+
this.config = new AskarModuleConfig(config);
|
|
18
|
+
}
|
|
19
|
+
register(dependencyManager) {
|
|
20
|
+
dependencyManager.registerInstance(AskarModuleConfig, this.config);
|
|
21
|
+
if (!this.config.enableKms && !this.config.enableStorage) dependencyManager.resolve(AgentConfig).logger.warn(`Both 'enableKms' and 'enableStorage' are disabled, meaning Askar won't be used by the agent.`);
|
|
22
|
+
if (this.config.enableKms) {
|
|
23
|
+
const kmsConfig = dependencyManager.resolve(Kms.KeyManagementModuleConfig);
|
|
24
|
+
if (kmsConfig.backends.find((backend) => backend.backend === AskarKeyManagementService.backend)) throw new CredoError(`Unable to register AskarKeyManagementService. There is a key management backend with name '${AskarKeyManagementService.backend}' already registered. If you have manually registered the AskarKeyManagementService on the KeyManagementModule, set 'enableKms' to false in the AskarModule.`);
|
|
25
|
+
kmsConfig.registerBackend(new AskarKeyManagementService());
|
|
26
|
+
}
|
|
27
|
+
if (this.config.enableStorage) {
|
|
28
|
+
if (dependencyManager.isRegistered(InjectionSymbols.StorageService)) throw new CredoError("Unable to register AskarStorageService. There is an instance of StorageService already registered");
|
|
29
|
+
dependencyManager.registerSingleton(InjectionSymbols.StorageService, AskarStorageService);
|
|
30
|
+
}
|
|
31
|
+
dependencyManager.registerSingleton(AskarStoreManager);
|
|
32
|
+
}
|
|
33
|
+
async onInitializeContext(agentContext) {
|
|
34
|
+
await agentContext.dependencyManager.resolve(AskarStoreManager).getInitializedStoreWithProfile(agentContext);
|
|
35
|
+
}
|
|
36
|
+
async onProvisionContext(agentContext) {
|
|
37
|
+
if (agentContext.isRootAgentContext) return;
|
|
38
|
+
if (this.config.multiWalletDatabaseScheme === AskarMultiWalletDatabaseScheme.ProfilePerWallet) {
|
|
39
|
+
const { store, profile } = await agentContext.dependencyManager.resolve(AskarStoreManager).getInitializedStoreWithProfile(agentContext);
|
|
40
|
+
if (!profile) return;
|
|
41
|
+
try {
|
|
42
|
+
await store.createProfile(profile);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
if (err instanceof AskarError && err.code === AskarErrorCode.Duplicate) return;
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await storeAskarStoreConfigForContextCorrelationId(agentContext, { key: this.config.askar.storeGenerateRawKey({}) });
|
|
50
|
+
}
|
|
51
|
+
async onDeleteContext(agentContext) {
|
|
52
|
+
await agentContext.dependencyManager.resolve(AskarStoreManager).deleteContext(agentContext);
|
|
53
|
+
}
|
|
54
|
+
async onCloseContext(agentContext) {
|
|
55
|
+
await agentContext.dependencyManager.resolve(AskarStoreManager).closeContext(agentContext);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { AskarModule };
|
|
61
|
+
//# sourceMappingURL=AskarModule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarModule.mjs","names":[],"sources":["../src/AskarModule.ts"],"sourcesContent":["import type { AgentContext, DependencyManager, Module } from '@credo-ts/core'\nimport { AgentConfig, CredoError, InjectionSymbols, Kms } from '@credo-ts/core'\nimport { AskarError } from '@openwallet-foundation/askar-shared'\nimport { AskarApi } from './AskarApi'\nimport type { AskarModuleConfigOptions } from './AskarModuleConfig'\nimport { AskarModuleConfig, AskarMultiWalletDatabaseScheme } from './AskarModuleConfig'\nimport { AskarStoreManager } from './AskarStoreManager'\nimport { AskarKeyManagementService } from './kms/AskarKeyManagementService'\nimport { AskarStorageService } from './storage'\nimport { storeAskarStoreConfigForContextCorrelationId } from './tenants'\nimport { AskarErrorCode } from './utils'\n\nexport class AskarModule implements Module {\n public readonly config: AskarModuleConfig\n\n public constructor(config: AskarModuleConfigOptions) {\n this.config = new AskarModuleConfig(config)\n }\n\n public api = AskarApi\n\n public register(dependencyManager: DependencyManager) {\n dependencyManager.registerInstance(AskarModuleConfig, this.config)\n\n if (!this.config.enableKms && !this.config.enableStorage) {\n dependencyManager\n .resolve(AgentConfig)\n .logger.warn(`Both 'enableKms' and 'enableStorage' are disabled, meaning Askar won't be used by the agent.`)\n }\n\n if (this.config.enableKms) {\n const kmsConfig = dependencyManager.resolve(Kms.KeyManagementModuleConfig)\n if (kmsConfig.backends.find((backend) => backend.backend === AskarKeyManagementService.backend)) {\n throw new CredoError(\n `Unable to register AskarKeyManagementService. There is a key management backend with name '${AskarKeyManagementService.backend}' already registered. If you have manually registered the AskarKeyManagementService on the KeyManagementModule, set 'enableKms' to false in the AskarModule.`\n )\n }\n\n kmsConfig.registerBackend(new AskarKeyManagementService())\n }\n\n if (this.config.enableStorage) {\n if (dependencyManager.isRegistered(InjectionSymbols.StorageService)) {\n throw new CredoError(\n 'Unable to register AskarStorageService. There is an instance of StorageService already registered'\n )\n }\n dependencyManager.registerSingleton(InjectionSymbols.StorageService, AskarStorageService)\n }\n\n dependencyManager.registerSingleton(AskarStoreManager)\n }\n\n public async onInitializeContext(agentContext: AgentContext) {\n const storeManager = agentContext.dependencyManager.resolve(AskarStoreManager)\n await storeManager.getInitializedStoreWithProfile(agentContext)\n }\n\n public async onProvisionContext(agentContext: AgentContext) {\n // We don't have any side effects to run\n if (agentContext.isRootAgentContext) {\n return\n }\n\n // Ensure we have a profile for context\n if (this.config.multiWalletDatabaseScheme === AskarMultiWalletDatabaseScheme.ProfilePerWallet) {\n const storeManager = agentContext.dependencyManager.resolve(AskarStoreManager)\n const { store, profile } = await storeManager.getInitializedStoreWithProfile(agentContext)\n if (!profile) return\n\n try {\n await store.createProfile(profile)\n } catch (err) {\n if (err instanceof AskarError && err.code === AskarErrorCode.Duplicate) {\n return\n }\n\n throw err\n }\n\n return\n }\n\n // For new stores (so not profiles) we need to generate a wallet key\n await storeAskarStoreConfigForContextCorrelationId(agentContext, {\n key: this.config.askar.storeGenerateRawKey({}),\n })\n }\n\n public async onDeleteContext(agentContext: AgentContext) {\n const storeManager = agentContext.dependencyManager.resolve(AskarStoreManager)\n\n // Will delete either the store (when root agent context or database per wallet) or profile (when not root agent context and profile per wallet)\n await storeManager.deleteContext(agentContext)\n }\n\n public async onCloseContext(agentContext: AgentContext): Promise<void> {\n const storeManager = agentContext.dependencyManager.resolve(AskarStoreManager)\n\n await storeManager.closeContext(agentContext)\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAa,cAAb,MAA2C;CAGzC,AAAO,YAAY,QAAkC;OAI9C,MAAM;AAHX,OAAK,SAAS,IAAI,kBAAkB,OAAO;;CAK7C,AAAO,SAAS,mBAAsC;AACpD,oBAAkB,iBAAiB,mBAAmB,KAAK,OAAO;AAElE,MAAI,CAAC,KAAK,OAAO,aAAa,CAAC,KAAK,OAAO,cACzC,mBACG,QAAQ,YAAY,CACpB,OAAO,KAAK,+FAA+F;AAGhH,MAAI,KAAK,OAAO,WAAW;GACzB,MAAM,YAAY,kBAAkB,QAAQ,IAAI,0BAA0B;AAC1E,OAAI,UAAU,SAAS,MAAM,YAAY,QAAQ,YAAY,0BAA0B,QAAQ,CAC7F,OAAM,IAAI,WACR,8FAA8F,0BAA0B,QAAQ,8JACjI;AAGH,aAAU,gBAAgB,IAAI,2BAA2B,CAAC;;AAG5D,MAAI,KAAK,OAAO,eAAe;AAC7B,OAAI,kBAAkB,aAAa,iBAAiB,eAAe,CACjE,OAAM,IAAI,WACR,oGACD;AAEH,qBAAkB,kBAAkB,iBAAiB,gBAAgB,oBAAoB;;AAG3F,oBAAkB,kBAAkB,kBAAkB;;CAGxD,MAAa,oBAAoB,cAA4B;AAE3D,QADqB,aAAa,kBAAkB,QAAQ,kBAAkB,CAC3D,+BAA+B,aAAa;;CAGjE,MAAa,mBAAmB,cAA4B;AAE1D,MAAI,aAAa,mBACf;AAIF,MAAI,KAAK,OAAO,8BAA8B,+BAA+B,kBAAkB;GAE7F,MAAM,EAAE,OAAO,YAAY,MADN,aAAa,kBAAkB,QAAQ,kBAAkB,CAChC,+BAA+B,aAAa;AAC1F,OAAI,CAAC,QAAS;AAEd,OAAI;AACF,UAAM,MAAM,cAAc,QAAQ;YAC3B,KAAK;AACZ,QAAI,eAAe,cAAc,IAAI,SAAS,eAAe,UAC3D;AAGF,UAAM;;AAGR;;AAIF,QAAM,6CAA6C,cAAc,EAC/D,KAAK,KAAK,OAAO,MAAM,oBAAoB,EAAE,CAAC,EAC/C,CAAC;;CAGJ,MAAa,gBAAgB,cAA4B;AAIvD,QAHqB,aAAa,kBAAkB,QAAQ,kBAAkB,CAG3D,cAAc,aAAa;;CAGhD,MAAa,eAAe,cAA2C;AAGrE,QAFqB,aAAa,kBAAkB,QAAQ,kBAAkB,CAE3D,aAAa,aAAa"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { AskarPostgresStorageConfig, AskarSqliteStorageConfig } from "./AskarStorageConfig.mjs";
|
|
2
|
+
import { Askar, KdfMethod } from "@openwallet-foundation/askar-shared";
|
|
3
|
+
|
|
4
|
+
//#region src/AskarModuleConfig.d.ts
|
|
5
|
+
declare enum AskarMultiWalletDatabaseScheme {
|
|
6
|
+
/**
|
|
7
|
+
* Each wallet get its own database and uses a separate store.
|
|
8
|
+
*/
|
|
9
|
+
DatabasePerWallet = "DatabasePerWallet",
|
|
10
|
+
/**
|
|
11
|
+
* All wallets are stored in a single database, but each wallet uses a separate profile.
|
|
12
|
+
*/
|
|
13
|
+
ProfilePerWallet = "ProfilePerWallet",
|
|
14
|
+
}
|
|
15
|
+
interface AskarModuleConfigStoreOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The id of the store, and also the default profile that will be used for the root agent instance.
|
|
18
|
+
*
|
|
19
|
+
* - When SQLite is used that is not in-memory this will influence the path where the SQLite database is stored.
|
|
20
|
+
* - When Postgres is used, this determines the database.
|
|
21
|
+
*/
|
|
22
|
+
id: string;
|
|
23
|
+
/**
|
|
24
|
+
* The key to open the store
|
|
25
|
+
*/
|
|
26
|
+
key: string;
|
|
27
|
+
/**
|
|
28
|
+
* Key derivation method to use for opening the store.
|
|
29
|
+
*
|
|
30
|
+
* - `kdf:argon2i:mod` - most secure
|
|
31
|
+
* - `kdf:argon2i:int` - faster, less secure
|
|
32
|
+
* - `raw` - no key derivation. Useful if key is stored in e.g. the keychain on-device backed by biometrics.
|
|
33
|
+
*
|
|
34
|
+
* @default 'kdf:argon2i:mod'
|
|
35
|
+
*/
|
|
36
|
+
keyDerivationMethod?: `${KdfMethod.Argon2IInt}` | `${KdfMethod.Argon2IMod}` | `${KdfMethod.Raw}`;
|
|
37
|
+
/**
|
|
38
|
+
* The backend to use with backend specific configuraiton options.
|
|
39
|
+
*
|
|
40
|
+
* If not provided SQLite will be used by default
|
|
41
|
+
*/
|
|
42
|
+
database?: AskarSqliteStorageConfig | AskarPostgresStorageConfig;
|
|
43
|
+
}
|
|
44
|
+
interface AskarModuleConfigOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Store configuration used for askar.
|
|
47
|
+
*
|
|
48
|
+
* If `multiWalletDatabaseScheme` is set to `AskarMultiWalletDatabaseScheme.DatabasePerWallet` a new store will be created
|
|
49
|
+
* for each tenant. For performance reasons it is recommended to use `AskarMultiWalletDatabaseScheme.ProfilePerWallet`.
|
|
50
|
+
*/
|
|
51
|
+
store: AskarModuleConfigStoreOptions;
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* ## Node.JS
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { askar } from '@openwallet-foundation/askar-nodejs'
|
|
58
|
+
*
|
|
59
|
+
* const agent = new Agent({
|
|
60
|
+
* config: {},
|
|
61
|
+
* dependencies: agentDependencies,
|
|
62
|
+
* modules: {
|
|
63
|
+
* askar: new AskarModule({
|
|
64
|
+
* askar,
|
|
65
|
+
* })
|
|
66
|
+
* }
|
|
67
|
+
* })
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* ## React Native
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { askar } from '@openwallet-foundation/askar-react-native'
|
|
74
|
+
*
|
|
75
|
+
* const agent = new Agent({
|
|
76
|
+
* config: {},
|
|
77
|
+
* dependencies: agentDependencies,
|
|
78
|
+
* modules: {
|
|
79
|
+
* askar: new AskarModule({
|
|
80
|
+
* askar,
|
|
81
|
+
* })
|
|
82
|
+
* }
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
askar: Askar;
|
|
87
|
+
/**
|
|
88
|
+
* Determine the strategy for storing wallets if multiple wallets are used in a single agent.
|
|
89
|
+
* This is mostly the case in multi-tenancy, and determines whether each tenant will get a separate
|
|
90
|
+
* database, or whether all wallets will be stored in a single database, using a different profile
|
|
91
|
+
* for each wallet.
|
|
92
|
+
*
|
|
93
|
+
* @default {@link AskarMultiWalletDatabaseScheme.DatabasePerWallet} (for backwards compatibility)
|
|
94
|
+
*/
|
|
95
|
+
multiWalletDatabaseScheme?: AskarMultiWalletDatabaseScheme;
|
|
96
|
+
/**
|
|
97
|
+
* Whether to enable and register the `AskarKeyManagementService` for key management and cryptographic operations.
|
|
98
|
+
*
|
|
99
|
+
* @default true
|
|
100
|
+
*/
|
|
101
|
+
enableKms?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Whether to enable and register the `AskarStorageService` for storage
|
|
104
|
+
*
|
|
105
|
+
* @default true
|
|
106
|
+
*/
|
|
107
|
+
enableStorage?: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
declare class AskarModuleConfig {
|
|
113
|
+
private options;
|
|
114
|
+
constructor(options: AskarModuleConfigOptions);
|
|
115
|
+
/** See {@link AskarModuleConfigOptions.askar} */
|
|
116
|
+
get askar(): Askar;
|
|
117
|
+
/** See {@link AskarModuleConfigOptions.multiWalletDatabaseScheme} */
|
|
118
|
+
get multiWalletDatabaseScheme(): AskarMultiWalletDatabaseScheme;
|
|
119
|
+
get store(): AskarModuleConfigStoreOptions;
|
|
120
|
+
get enableKms(): boolean;
|
|
121
|
+
get enableStorage(): boolean;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { AskarModuleConfig, AskarModuleConfigOptions, AskarModuleConfigStoreOptions, AskarMultiWalletDatabaseScheme };
|
|
125
|
+
//# sourceMappingURL=AskarModuleConfig.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarModuleConfig.d.mts","names":[],"sources":["../src/AskarModuleConfig.ts"],"sourcesContent":[],"mappings":";;;;aAGY,8BAAA;;AAAZ;AAYA;EAuB2B,iBAAU,GAAA,mBAAA;EAAkB;;;EAOf,gBAAA,GAAA,kBAAA;;AAGvB,UAjCA,6BAAA,CAiCwB;EAOhC;;;;AAkET;;EAQkB,EAAA,EAAA,MAAA;EAKoB;;;;;;;;;;;;;2BAhGX,SAAA,CAAU,kBAAkB,SAAA,CAAU,kBAAkB,SAAA,CAAU;;;;;;aAOhF,2BAA2B;;UAGvB,wBAAA;;;;;;;SAOR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAoCA;;;;;;;;;8BAUqB;;;;;;;;;;;;;;;;;cAoBjB,iBAAA;;uBAGiB;;eAKZ;;mCAKoB;eAIpB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/AskarModuleConfig.ts
|
|
2
|
+
let AskarMultiWalletDatabaseScheme = /* @__PURE__ */ function(AskarMultiWalletDatabaseScheme$1) {
|
|
3
|
+
/**
|
|
4
|
+
* Each wallet get its own database and uses a separate store.
|
|
5
|
+
*/
|
|
6
|
+
AskarMultiWalletDatabaseScheme$1["DatabasePerWallet"] = "DatabasePerWallet";
|
|
7
|
+
/**
|
|
8
|
+
* All wallets are stored in a single database, but each wallet uses a separate profile.
|
|
9
|
+
*/
|
|
10
|
+
AskarMultiWalletDatabaseScheme$1["ProfilePerWallet"] = "ProfilePerWallet";
|
|
11
|
+
return AskarMultiWalletDatabaseScheme$1;
|
|
12
|
+
}({});
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
var AskarModuleConfig = class {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
}
|
|
20
|
+
/** See {@link AskarModuleConfigOptions.askar} */
|
|
21
|
+
get askar() {
|
|
22
|
+
return this.options.askar;
|
|
23
|
+
}
|
|
24
|
+
/** See {@link AskarModuleConfigOptions.multiWalletDatabaseScheme} */
|
|
25
|
+
get multiWalletDatabaseScheme() {
|
|
26
|
+
return this.options.multiWalletDatabaseScheme ?? AskarMultiWalletDatabaseScheme.DatabasePerWallet;
|
|
27
|
+
}
|
|
28
|
+
get store() {
|
|
29
|
+
return this.options.store;
|
|
30
|
+
}
|
|
31
|
+
get enableKms() {
|
|
32
|
+
return this.options.enableKms ?? true;
|
|
33
|
+
}
|
|
34
|
+
get enableStorage() {
|
|
35
|
+
return this.options.enableStorage ?? true;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { AskarModuleConfig, AskarMultiWalletDatabaseScheme };
|
|
41
|
+
//# sourceMappingURL=AskarModuleConfig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarModuleConfig.mjs","names":[],"sources":["../src/AskarModuleConfig.ts"],"sourcesContent":["import type { Askar, KdfMethod } from '@openwallet-foundation/askar-shared'\nimport type { AskarPostgresStorageConfig, AskarSqliteStorageConfig } from './AskarStorageConfig'\n\nexport enum AskarMultiWalletDatabaseScheme {\n /**\n * Each wallet get its own database and uses a separate store.\n */\n DatabasePerWallet = 'DatabasePerWallet',\n\n /**\n * All wallets are stored in a single database, but each wallet uses a separate profile.\n */\n ProfilePerWallet = 'ProfilePerWallet',\n}\n\nexport interface AskarModuleConfigStoreOptions {\n /**\n * The id of the store, and also the default profile that will be used for the root agent instance.\n *\n * - When SQLite is used that is not in-memory this will influence the path where the SQLite database is stored.\n * - When Postgres is used, this determines the database.\n */\n id: string\n\n /**\n * The key to open the store\n */\n key: string\n\n /**\n * Key derivation method to use for opening the store.\n *\n * - `kdf:argon2i:mod` - most secure\n * - `kdf:argon2i:int` - faster, less secure\n * - `raw` - no key derivation. Useful if key is stored in e.g. the keychain on-device backed by biometrics.\n *\n * @default 'kdf:argon2i:mod'\n */\n keyDerivationMethod?: `${KdfMethod.Argon2IInt}` | `${KdfMethod.Argon2IMod}` | `${KdfMethod.Raw}`\n\n /**\n * The backend to use with backend specific configuraiton options.\n *\n * If not provided SQLite will be used by default\n */\n database?: AskarSqliteStorageConfig | AskarPostgresStorageConfig\n}\n\nexport interface AskarModuleConfigOptions {\n /**\n * Store configuration used for askar.\n *\n * If `multiWalletDatabaseScheme` is set to `AskarMultiWalletDatabaseScheme.DatabasePerWallet` a new store will be created\n * for each tenant. For performance reasons it is recommended to use `AskarMultiWalletDatabaseScheme.ProfilePerWallet`.\n */\n store: AskarModuleConfigStoreOptions\n\n /**\n *\n * ## Node.JS\n *\n * ```ts\n * import { askar } from '@openwallet-foundation/askar-nodejs'\n *\n * const agent = new Agent({\n * config: {},\n * dependencies: agentDependencies,\n * modules: {\n * askar: new AskarModule({\n * askar,\n * })\n * }\n * })\n * ```\n *\n * ## React Native\n *\n * ```ts\n * import { askar } from '@openwallet-foundation/askar-react-native'\n *\n * const agent = new Agent({\n * config: {},\n * dependencies: agentDependencies,\n * modules: {\n * askar: new AskarModule({\n * askar,\n * })\n * }\n * })\n * ```\n */\n askar: Askar\n\n /**\n * Determine the strategy for storing wallets if multiple wallets are used in a single agent.\n * This is mostly the case in multi-tenancy, and determines whether each tenant will get a separate\n * database, or whether all wallets will be stored in a single database, using a different profile\n * for each wallet.\n *\n * @default {@link AskarMultiWalletDatabaseScheme.DatabasePerWallet} (for backwards compatibility)\n */\n multiWalletDatabaseScheme?: AskarMultiWalletDatabaseScheme\n\n /**\n * Whether to enable and register the `AskarKeyManagementService` for key management and cryptographic operations.\n *\n * @default true\n */\n enableKms?: boolean\n\n /**\n * Whether to enable and register the `AskarStorageService` for storage\n *\n * @default true\n */\n enableStorage?: boolean\n}\n\n/**\n * @public\n */\nexport class AskarModuleConfig {\n private options: AskarModuleConfigOptions\n\n public constructor(options: AskarModuleConfigOptions) {\n this.options = options\n }\n\n /** See {@link AskarModuleConfigOptions.askar} */\n public get askar() {\n return this.options.askar\n }\n\n /** See {@link AskarModuleConfigOptions.multiWalletDatabaseScheme} */\n public get multiWalletDatabaseScheme() {\n return this.options.multiWalletDatabaseScheme ?? AskarMultiWalletDatabaseScheme.DatabasePerWallet\n }\n\n public get store() {\n return this.options.store\n }\n\n public get enableKms() {\n return this.options.enableKms ?? true\n }\n\n public get enableStorage() {\n return this.options.enableStorage ?? true\n }\n}\n"],"mappings":";AAGA,IAAY,4FAAL;;;;AAIL;;;;AAKA;;;;;;AA6GF,IAAa,oBAAb,MAA+B;CAG7B,AAAO,YAAY,SAAmC;AACpD,OAAK,UAAU;;;CAIjB,IAAW,QAAQ;AACjB,SAAO,KAAK,QAAQ;;;CAItB,IAAW,4BAA4B;AACrC,SAAO,KAAK,QAAQ,6BAA6B,+BAA+B;;CAGlF,IAAW,QAAQ;AACjB,SAAO,KAAK,QAAQ;;CAGtB,IAAW,YAAY;AACrB,SAAO,KAAK,QAAQ,aAAa;;CAGnC,IAAW,gBAAgB;AACzB,SAAO,KAAK,QAAQ,iBAAiB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/AskarStorageConfig.d.ts
|
|
2
|
+
interface AskarPostgresConfig {
|
|
3
|
+
host: string;
|
|
4
|
+
connectTimeout?: number;
|
|
5
|
+
idleTimeout?: number;
|
|
6
|
+
maxConnections?: number;
|
|
7
|
+
minConnections?: number;
|
|
8
|
+
}
|
|
9
|
+
interface AskarSqliteConfig {
|
|
10
|
+
maxConnections?: number;
|
|
11
|
+
minConnections?: number;
|
|
12
|
+
inMemory?: boolean;
|
|
13
|
+
path?: string;
|
|
14
|
+
}
|
|
15
|
+
interface AskarPostgresCredentials {
|
|
16
|
+
account: string;
|
|
17
|
+
password: string;
|
|
18
|
+
adminAccount?: string;
|
|
19
|
+
adminPassword?: string;
|
|
20
|
+
}
|
|
21
|
+
interface AskarPostgresStorageConfig {
|
|
22
|
+
type: 'postgres';
|
|
23
|
+
config: AskarPostgresConfig;
|
|
24
|
+
credentials: AskarPostgresCredentials;
|
|
25
|
+
}
|
|
26
|
+
interface AskarSqliteStorageConfig {
|
|
27
|
+
type: 'sqlite';
|
|
28
|
+
config?: AskarSqliteConfig;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { AskarPostgresConfig, AskarPostgresCredentials, AskarPostgresStorageConfig, AskarSqliteConfig, AskarSqliteStorageConfig };
|
|
32
|
+
//# sourceMappingURL=AskarStorageConfig.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarStorageConfig.d.mts","names":[],"sources":["../src/AskarStorageConfig.ts"],"sourcesContent":[],"mappings":";UAAiB,mBAAA;EAAA,IAAA,EAAA,MAAA;EAQA,cAAA,CAAA,EAAA,MAAiB;EAUjB,WAAA,CAAA,EAAA,MAAA;EAOA,cAAA,CAAA,EAAA,MAAA;EAMA,cAAA,CAAA,EAAA,MAAA;;UAvBA,iBAAA;;;;;;UAUA,wBAAA;;;;;;UAOA,0BAAA;;UAEP;eACK;;UAGE,wBAAA;;WAEN"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/AskarStorageConfig.ts
|
|
2
|
+
function isAskarSqliteStorageConfig(config) {
|
|
3
|
+
return config?.type === "sqlite";
|
|
4
|
+
}
|
|
5
|
+
function isAskarPostgresStorageConfig(config) {
|
|
6
|
+
return config?.type === "postgres";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { isAskarPostgresStorageConfig, isAskarSqliteStorageConfig };
|
|
11
|
+
//# sourceMappingURL=AskarStorageConfig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarStorageConfig.mjs","names":[],"sources":["../src/AskarStorageConfig.ts"],"sourcesContent":["export interface AskarPostgresConfig {\n host: string\n connectTimeout?: number\n idleTimeout?: number\n maxConnections?: number\n minConnections?: number\n}\n\nexport interface AskarSqliteConfig {\n // TODO: add other sqlite config options\n maxConnections?: number\n minConnections?: number\n\n // TODO: split this up into two separate types SqliteInMemory and Sqlite\n inMemory?: boolean\n path?: string\n}\n\nexport interface AskarPostgresCredentials {\n account: string\n password: string\n adminAccount?: string\n adminPassword?: string\n}\n\nexport interface AskarPostgresStorageConfig {\n type: 'postgres'\n config: AskarPostgresConfig\n credentials: AskarPostgresCredentials\n}\n\nexport interface AskarSqliteStorageConfig {\n type: 'sqlite'\n config?: AskarSqliteConfig\n}\n\nexport type AskarStorageConfig = AskarPostgresStorageConfig | AskarSqliteStorageConfig\n\nexport function isAskarSqliteStorageConfig(config?: AskarStorageConfig): config is AskarSqliteStorageConfig {\n return config?.type === 'sqlite'\n}\n\nexport function isAskarPostgresStorageConfig(config?: AskarStorageConfig): config is AskarPostgresStorageConfig {\n return config?.type === 'postgres'\n}\n"],"mappings":";AAsCA,SAAgB,2BAA2B,QAAiE;AAC1G,QAAO,QAAQ,SAAS;;AAG1B,SAAgB,6BAA6B,QAAmE;AAC9G,QAAO,QAAQ,SAAS"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { AskarModuleConfig } from "./AskarModuleConfig.mjs";
|
|
2
|
+
import { AskarStoreExportOptions, AskarStoreImportOptions, AskarStoreRotateKeyOptions } from "./AskarApiOptions.mjs";
|
|
3
|
+
import { AgentContext, FileSystem } from "@credo-ts/core";
|
|
4
|
+
import { Session, Store } from "@openwallet-foundation/askar-shared";
|
|
5
|
+
|
|
6
|
+
//#region src/AskarStoreManager.d.ts
|
|
7
|
+
declare class AskarStoreManager {
|
|
8
|
+
private fileSystem;
|
|
9
|
+
private config;
|
|
10
|
+
constructor(fileSystem: FileSystem, config: AskarModuleConfig);
|
|
11
|
+
isStoreOpen(agentContext: AgentContext): boolean;
|
|
12
|
+
private getStoreConfig;
|
|
13
|
+
/**
|
|
14
|
+
* When we create storage for a context we need to store the version record
|
|
15
|
+
*/
|
|
16
|
+
private setCurrentFrameworkStorageVersionOnSession;
|
|
17
|
+
/**
|
|
18
|
+
* Deletes all storage related to a context. If on store level, meaning root agent
|
|
19
|
+
* or when using database per wallet storage, the whole store will be deleted.
|
|
20
|
+
* Otherwise only a profile within the store will be removed.
|
|
21
|
+
*/
|
|
22
|
+
deleteContext(agentContext: AgentContext): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Closes an active context. If on store level, meaning root agent
|
|
25
|
+
* or when using database per wallet storage, the whole store will be closed.
|
|
26
|
+
* Otherwise nothing will be done as profiles are opened on a store from higher level.
|
|
27
|
+
*/
|
|
28
|
+
closeContext(agentContext: AgentContext): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* @throws {AskarStoreDuplicateError} if the wallet already exists
|
|
31
|
+
* @throws {AskarStoreError} if another error occurs
|
|
32
|
+
*/
|
|
33
|
+
provisionStore(agentContext: AgentContext): Promise<Store>;
|
|
34
|
+
/**
|
|
35
|
+
* @throws {AskarStoreNotFoundError} if the wallet does not exist
|
|
36
|
+
* @throws {AskarStoreError} if another error occurs
|
|
37
|
+
*/
|
|
38
|
+
openStore(agentContext: AgentContext): Promise<Store>;
|
|
39
|
+
/**
|
|
40
|
+
* Rotate the key of the current askar store.
|
|
41
|
+
*
|
|
42
|
+
* NOTE: multiple agent contexts (tenants) can use the same store. This method rotates the key for the whole store,
|
|
43
|
+
* it is advised to only run this method on the root tenant agent when using profile per wallet database strategy.
|
|
44
|
+
* After running this method you should change the store configuration in the Askar module.
|
|
45
|
+
*
|
|
46
|
+
* @throws {AskarStoreNotFoundError} if the wallet does not exist
|
|
47
|
+
* @throws {AskarStoreError} if another error occurs
|
|
48
|
+
*/
|
|
49
|
+
rotateStoreKey(agentContext: AgentContext, options: AskarStoreRotateKeyOptions): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Exports the current askar store.
|
|
52
|
+
*
|
|
53
|
+
* NOTE: a store can contain profiles for multiple tenants. When you export a store
|
|
54
|
+
* all profiles will be exported with it.
|
|
55
|
+
*/
|
|
56
|
+
exportStore(agentContext: AgentContext, options: AskarStoreExportOptions): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Imports from an external store config into the current askar store config.
|
|
59
|
+
*/
|
|
60
|
+
importStore(agentContext: AgentContext, options: AskarStoreImportOptions): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Delete the current askar store.
|
|
63
|
+
*
|
|
64
|
+
* NOTE: multiple agent contexts (tenants) can use the same store. This method deletes the whole store,
|
|
65
|
+
* and if you're using multi-tenancy with profile per wallet it is advised to only run this method on the root tenant agent.
|
|
66
|
+
*
|
|
67
|
+
* @throws {AskarStoreNotFoundError} if the wallet does not exist
|
|
68
|
+
* @throws {AskarStoreError} if another error occurs
|
|
69
|
+
*/
|
|
70
|
+
deleteStore(agentContext: AgentContext): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Close the current askar store
|
|
73
|
+
*/
|
|
74
|
+
closeStore(agentContext: AgentContext): Promise<void>;
|
|
75
|
+
private getAskarStoreConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Run callback with a transaction. If the callback resolves the transaction
|
|
78
|
+
* will be committed if the transaction is not closed yet. If the callback rejects
|
|
79
|
+
* the transaction will be rolled back if the transaction is not closed yet.
|
|
80
|
+
*
|
|
81
|
+
* TODO: update to new `using` syntax so we don't have to use a callback
|
|
82
|
+
*/
|
|
83
|
+
withTransaction<Return>(agentContext: AgentContext, callback: (session: Session) => Return): Promise<Awaited<Return>>;
|
|
84
|
+
/**
|
|
85
|
+
* Run callback with the session provided, the session will
|
|
86
|
+
* be closed once the callback resolves or rejects if it is not closed yet.
|
|
87
|
+
*
|
|
88
|
+
* TODO: update to new `using` syntax so we don't have to use a callback
|
|
89
|
+
*/
|
|
90
|
+
withSession<Return>(agentContext: AgentContext, callback: (session: Session) => Return): Promise<Awaited<Return>>;
|
|
91
|
+
private getStore;
|
|
92
|
+
private _withSession;
|
|
93
|
+
getInitializedStoreWithProfile(agentContext: AgentContext): Promise<{
|
|
94
|
+
profile: string | undefined;
|
|
95
|
+
store: Store;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Ensures a command is ran on a store level, preventing a tenant instance from
|
|
99
|
+
* removing a whole store (and potentially other tennats).
|
|
100
|
+
*/
|
|
101
|
+
private ensureStoreLevel;
|
|
102
|
+
/**
|
|
103
|
+
* Checks whether the current agent context is on store level
|
|
104
|
+
*/
|
|
105
|
+
private isStoreLevel;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { AskarStoreManager };
|
|
109
|
+
//# sourceMappingURL=AskarStoreManager.d.mts.map
|