@credo-ts/askar 0.7.2-pr-2704-20260918194459 → 0.7.2
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 +1 -3
- package/build/AskarApi.d.mts.map +1 -1
- package/build/AskarApi.mjs +6 -8
- package/build/AskarApi.mjs.map +1 -1
- package/build/AskarApiOptions.d.mts +3 -5
- package/build/AskarApiOptions.d.mts.map +1 -1
- package/build/AskarModule.d.mts +1 -3
- package/build/AskarModule.d.mts.map +1 -1
- package/build/AskarModule.mjs +4 -6
- package/build/AskarModule.mjs.map +1 -1
- package/build/AskarModuleConfig.d.mts +22 -11
- package/build/AskarModuleConfig.d.mts.map +1 -1
- package/build/AskarModuleConfig.mjs +4 -3
- package/build/AskarModuleConfig.mjs.map +1 -1
- package/build/AskarStorageConfig.d.mts +6 -7
- package/build/AskarStorageConfig.d.mts.map +1 -1
- package/build/AskarStorageConfig.mjs +1 -1
- package/build/AskarStorageConfig.mjs.map +1 -1
- package/build/AskarStoreManager.d.mts +1 -3
- package/build/AskarStoreManager.d.mts.map +1 -1
- package/build/AskarStoreManager.mjs +15 -17
- package/build/AskarStoreManager.mjs.map +1 -1
- package/build/_virtual/{_@oxc-project_runtime@0.112.0/helpers → _@oxc-project_runtime@0.151.0/helpers/esm}/decorate.mjs +2 -3
- package/build/_virtual/{_@oxc-project_runtime@0.112.0/helpers → _@oxc-project_runtime@0.151.0/helpers/esm}/decorateMetadata.mjs +2 -3
- package/build/_virtual/{_@oxc-project_runtime@0.112.0/helpers → _@oxc-project_runtime@0.151.0/helpers/esm}/decorateParam.mjs +2 -3
- package/build/error/AskarError.mjs +1 -2
- package/build/error/AskarError.mjs.map +1 -1
- package/build/error/AskarStoreDuplicateError.d.mts +2 -6
- package/build/error/AskarStoreDuplicateError.d.mts.map +1 -1
- package/build/error/AskarStoreDuplicateError.mjs +1 -2
- package/build/error/AskarStoreDuplicateError.mjs.map +1 -1
- package/build/error/AskarStoreError.d.mts +2 -6
- package/build/error/AskarStoreError.d.mts.map +1 -1
- package/build/error/AskarStoreError.mjs +1 -2
- package/build/error/AskarStoreError.mjs.map +1 -1
- package/build/error/AskarStoreExportPathExistsError.d.mts +2 -6
- package/build/error/AskarStoreExportPathExistsError.d.mts.map +1 -1
- package/build/error/AskarStoreExportPathExistsError.mjs +1 -2
- package/build/error/AskarStoreExportPathExistsError.mjs.map +1 -1
- package/build/error/AskarStoreExportUnsupportedError.d.mts +2 -6
- package/build/error/AskarStoreExportUnsupportedError.d.mts.map +1 -1
- package/build/error/AskarStoreExportUnsupportedError.mjs +1 -2
- package/build/error/AskarStoreExportUnsupportedError.mjs.map +1 -1
- package/build/error/AskarStoreImportPathExistsError.d.mts +2 -6
- package/build/error/AskarStoreImportPathExistsError.d.mts.map +1 -1
- package/build/error/AskarStoreImportPathExistsError.mjs +1 -2
- package/build/error/AskarStoreImportPathExistsError.mjs.map +1 -1
- package/build/error/AskarStoreInvalidKeyError.d.mts +2 -6
- package/build/error/AskarStoreInvalidKeyError.d.mts.map +1 -1
- package/build/error/AskarStoreInvalidKeyError.mjs +1 -2
- package/build/error/AskarStoreInvalidKeyError.mjs.map +1 -1
- package/build/error/AskarStoreNotFoundError.d.mts +2 -6
- package/build/error/AskarStoreNotFoundError.d.mts.map +1 -1
- package/build/error/AskarStoreNotFoundError.mjs +1 -2
- package/build/error/AskarStoreNotFoundError.mjs.map +1 -1
- package/build/error/index.d.mts +2 -1
- package/build/error/index.mjs +1 -0
- package/build/index.d.mts +2 -2
- package/build/index.mjs +1 -2
- package/build/kms/AskarKeyManagementService.d.mts +1 -3
- package/build/kms/AskarKeyManagementService.d.mts.map +1 -1
- package/build/kms/AskarKeyManagementService.mjs +27 -62
- package/build/kms/AskarKeyManagementService.mjs.map +1 -1
- package/build/kms/crypto/decrypt.mjs +2 -3
- package/build/kms/crypto/decrypt.mjs.map +1 -1
- package/build/kms/crypto/deriveKey.mjs +6 -119
- package/build/kms/crypto/deriveKey.mjs.map +1 -1
- package/build/kms/crypto/encrypt.mjs +2 -3
- package/build/kms/crypto/encrypt.mjs.map +1 -1
- package/build/kms/crypto/hpke.mjs +2 -3
- package/build/kms/crypto/hpke.mjs.map +1 -1
- package/build/kms/crypto/randomBytes.mjs +1 -2
- package/build/kms/crypto/randomBytes.mjs.map +1 -1
- package/build/storage/AskarStorageService.d.mts +1 -3
- package/build/storage/AskarStorageService.d.mts.map +1 -1
- package/build/storage/AskarStorageService.mjs +10 -12
- package/build/storage/AskarStorageService.mjs.map +1 -1
- package/build/storage/index.d.mts +2 -1
- package/build/storage/index.mjs +1 -0
- package/build/storage/utils.d.mts +1 -3
- package/build/storage/utils.d.mts.map +1 -1
- package/build/storage/utils.mjs +2 -3
- package/build/storage/utils.mjs.map +1 -1
- package/build/tenants.mjs +1 -2
- package/build/tenants.mjs.map +1 -1
- package/build/utils/askarError.mjs +2 -16
- package/build/utils/askarError.mjs.map +1 -1
- package/build/utils/askarKeyTypes.mjs +2 -3
- package/build/utils/askarKeyTypes.mjs.map +1 -1
- package/build/utils/askarStoreConfig.mjs +8 -8
- package/build/utils/askarStoreConfig.mjs.map +1 -1
- package/build/utils/index.d.mts +2 -1
- package/build/utils/index.mjs +2 -1
- package/build/utils/transformPrivateKey.d.mts +2 -10
- package/build/utils/transformPrivateKey.d.mts.map +1 -1
- package/build/utils/transformPrivateKey.mjs +2 -3
- package/build/utils/transformPrivateKey.mjs.map +1 -1
- package/package.json +3 -3
package/build/AskarApi.d.mts
CHANGED
|
@@ -2,9 +2,8 @@ import { AskarModuleConfig } from "./AskarModuleConfig.mjs";
|
|
|
2
2
|
import { AskarStoreExportOptions, AskarStoreImportOptions, AskarStoreRotateKeyOptions } from "./AskarApiOptions.mjs";
|
|
3
3
|
import { AskarStoreManager } from "./AskarStoreManager.mjs";
|
|
4
4
|
import { AgentContext } from "@credo-ts/core";
|
|
5
|
-
|
|
6
5
|
//#region src/AskarApi.d.ts
|
|
7
|
-
declare class AskarApi {
|
|
6
|
+
export declare class AskarApi {
|
|
8
7
|
private agentContext;
|
|
9
8
|
private askarStoreManager;
|
|
10
9
|
readonly config: AskarModuleConfig;
|
|
@@ -64,5 +63,4 @@ declare class AskarApi {
|
|
|
64
63
|
closeStore(): Promise<void>;
|
|
65
64
|
}
|
|
66
65
|
//#endregion
|
|
67
|
-
export { AskarApi };
|
|
68
66
|
//# sourceMappingURL=AskarApi.d.mts.map
|
package/build/AskarApi.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskarApi.d.mts","names":[],"sources":["../src/AskarApi.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AskarApi.d.mts","names":[],"sources":["../src/AskarApi.ts"],"mappings":";;;;;qBAOa;UAED;UACA;WACQ,QAAQ;EAFhB,YAAA,cAAc,cACd,mBAAmB,mBACX,QAAQ;MAGf;;;;;EAQE,kBAAkB;;;;;EAQlB,aAAa;;;;;;;;;;;EAcb,eAAe,SAAS,6BAA6B;;;;;;;;;EAYrD,YAAY,SAAS,0BAAuB;;;;;;EAS5C,YAAY,SAAS,0BAAuB;;;;;;;;;;EAa5C,eAAe;;;;;;EASf,cAAU"}
|
package/build/AskarApi.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { AskarModuleConfig } from "./AskarModuleConfig.mjs";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import __decorateMetadata from "./_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.mjs";
|
|
3
|
+
import __decorate from "./_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.mjs";
|
|
4
4
|
import { AskarStoreManager } from "./AskarStoreManager.mjs";
|
|
5
5
|
import { AgentContext, injectable } from "@credo-ts/core";
|
|
6
|
-
|
|
7
6
|
//#region src/AskarApi.ts
|
|
8
|
-
var _ref, _ref2, _ref3;
|
|
9
7
|
let AskarApi = class AskarApi {
|
|
10
8
|
constructor(agentContext, askarStoreManager, config) {
|
|
11
9
|
this.agentContext = agentContext;
|
|
@@ -83,11 +81,11 @@ let AskarApi = class AskarApi {
|
|
|
83
81
|
}
|
|
84
82
|
};
|
|
85
83
|
AskarApi = __decorate([injectable(), __decorateMetadata("design:paramtypes", [
|
|
86
|
-
typeof
|
|
87
|
-
typeof
|
|
88
|
-
typeof
|
|
84
|
+
typeof AgentContext === "undefined" ? Object : AgentContext,
|
|
85
|
+
typeof AskarStoreManager === "undefined" ? Object : AskarStoreManager,
|
|
86
|
+
typeof AskarModuleConfig === "undefined" ? Object : AskarModuleConfig
|
|
89
87
|
])], AskarApi);
|
|
90
|
-
|
|
91
88
|
//#endregion
|
|
92
89
|
export { AskarApi };
|
|
90
|
+
|
|
93
91
|
//# sourceMappingURL=AskarApi.mjs.map
|
package/build/AskarApi.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskarApi.mjs","names":[],"sources":["../src/AskarApi.ts"],"sourcesContent":["import { AgentContext, injectable } from '@credo-ts/core'\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":"
|
|
1
|
+
{"version":3,"file":"AskarApi.mjs","names":[],"sources":["../src/AskarApi.ts"],"sourcesContent":["import { AgentContext, injectable } from '@credo-ts/core'\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":";;;;;;AAOO,IAAM,WAAN,MAAM,SAAS;CACpB,YACE,cACA,mBACA,QACA;EAHQ,KAAA,eAAA;EACA,KAAA,oBAAA;EACQ,KAAA,SAAA;CACf;CAEH,IAAW,cAAc;EACvB,OAAO,KAAK,kBAAkB,YAAY,KAAK,YAAY;CAC7D;;;;;CAMA,MAAa,iBAAgC;EAC3C,MAAM,KAAK,kBAAkB,eAAe,KAAK,YAAY;CAC/D;;;;;CAMA,MAAa,YAA2B;EACtC,MAAM,KAAK,kBAAkB,UAAU,KAAK,YAAY;CAC1D;;;;;;;;;;;CAYA,MAAa,eAAe,SAAoD;EAC9E,MAAM,KAAK,kBAAkB,eAAe,KAAK,cAAc,OAAO;CACxE;;;;;;;;;CAUA,MAAa,YAAY,SAAkC;EACzD,MAAM,KAAK,kBAAkB,YAAY,KAAK,cAAc,OAAO;CACrE;;;;;;CAOA,MAAa,YAAY,SAAkC;EACzD,MAAM,KAAK,kBAAkB,YAAY,KAAK,cAAc,OAAO;CACrE;;;;;;;;;;CAWA,MAAa,cAA6B;EACxC,MAAM,KAAK,kBAAkB,YAAY,KAAK,YAAY;CAC5D;;;;;;CAOA,MAAa,aAAa;EACxB,MAAM,KAAK,kBAAkB,WAAW,KAAK,YAAY;CAC3D;AACF;AApFC,WAAA,WAAA,CAAA,WAAW,GAAA,mBAAA,qBAAA"}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { AskarModuleConfigStoreOptions } from "./AskarModuleConfig.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/AskarApiOptions.d.ts
|
|
4
|
-
interface AskarStoreExportOptions {
|
|
3
|
+
export interface AskarStoreExportOptions {
|
|
5
4
|
/**
|
|
6
5
|
* The store config to export the current store to.
|
|
7
6
|
*/
|
|
8
7
|
exportToStore: AskarModuleConfigStoreOptions;
|
|
9
8
|
}
|
|
10
|
-
interface AskarStoreImportOptions {
|
|
9
|
+
export interface AskarStoreImportOptions {
|
|
11
10
|
/**
|
|
12
11
|
* The store config to import the current store from.
|
|
13
12
|
*/
|
|
14
13
|
importFromStore: AskarModuleConfigStoreOptions;
|
|
15
14
|
}
|
|
16
|
-
interface AskarStoreRotateKeyOptions {
|
|
15
|
+
export interface AskarStoreRotateKeyOptions {
|
|
17
16
|
/**
|
|
18
17
|
* The new key to use for the store.
|
|
19
18
|
*/
|
|
@@ -25,5 +24,4 @@ interface AskarStoreRotateKeyOptions {
|
|
|
25
24
|
newKeyDerivationMethod?: AskarModuleConfigStoreOptions['keyDerivationMethod'];
|
|
26
25
|
}
|
|
27
26
|
//#endregion
|
|
28
|
-
export { AskarStoreExportOptions, AskarStoreImportOptions, AskarStoreRotateKeyOptions };
|
|
29
27
|
//# sourceMappingURL=AskarApiOptions.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskarApiOptions.d.mts","names":[],"sources":["../src/AskarApiOptions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AskarApiOptions.d.mts","names":[],"sources":["../src/AskarApiOptions.ts"],"mappings":";;iBAEiB;;;;EAIf,eAAe;;iBAGA;;;;EAIf,iBAAiB;;iBAGF;;;;EAIf;;;;;EAMA,yBAAyB"}
|
package/build/AskarModule.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { AskarModuleConfig, AskarModuleConfigOptions } from "./AskarModuleConfig.mjs";
|
|
2
2
|
import { AskarApi } from "./AskarApi.mjs";
|
|
3
3
|
import { AgentContext, DependencyManager, Module } from "@credo-ts/core";
|
|
4
|
-
|
|
5
4
|
//#region src/AskarModule.d.ts
|
|
6
|
-
declare class AskarModule implements Module {
|
|
5
|
+
export declare class AskarModule implements Module {
|
|
7
6
|
readonly config: AskarModuleConfig;
|
|
8
7
|
constructor(config: AskarModuleConfigOptions);
|
|
9
8
|
api: typeof AskarApi;
|
|
@@ -14,5 +13,4 @@ declare class AskarModule implements Module {
|
|
|
14
13
|
onCloseContext(agentContext: AgentContext): Promise<void>;
|
|
15
14
|
}
|
|
16
15
|
//#endregion
|
|
17
|
-
export { AskarModule };
|
|
18
16
|
//# sourceMappingURL=AskarModule.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskarModule.d.mts","names":[],"sources":["../src/AskarModule.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AskarModule.d.mts","names":[],"sources":["../src/AskarModule.ts"],"mappings":";;;;qBAYa,uBAAuB;WAClB,QAAQ;EAEL,YAAA,QAAQ;EAIpB,YAAG;EAEH,SAAS,mBAAmB;EAgCtB,oBAAoB,cAAc,eAAY;EAK9C,mBAAmB,cAAc,eAAY;EA+B7C,gBAAgB,cAAc,eAAY;EAO1C,eAAe,cAAc,eAAe"}
|
package/build/AskarModule.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AskarModuleConfig
|
|
1
|
+
import { AskarModuleConfig } from "./AskarModuleConfig.mjs";
|
|
2
2
|
import { storeAskarStoreConfigForContextCorrelationId } from "./tenants.mjs";
|
|
3
|
-
import { AskarErrorCode } from "./utils/askarError.mjs";
|
|
4
3
|
import "./utils/index.mjs";
|
|
5
4
|
import { AskarStoreManager } from "./AskarStoreManager.mjs";
|
|
6
5
|
import { AskarApi } from "./AskarApi.mjs";
|
|
@@ -9,7 +8,6 @@ import { AskarStorageService } from "./storage/AskarStorageService.mjs";
|
|
|
9
8
|
import "./storage/index.mjs";
|
|
10
9
|
import { AgentConfig, CredoError, InjectionSymbols, Kms } from "@credo-ts/core";
|
|
11
10
|
import { AskarError } from "@openwallet-foundation/askar-shared";
|
|
12
|
-
|
|
13
11
|
//#region src/AskarModule.ts
|
|
14
12
|
var AskarModule = class {
|
|
15
13
|
constructor(config) {
|
|
@@ -35,13 +33,13 @@ var AskarModule = class {
|
|
|
35
33
|
}
|
|
36
34
|
async onProvisionContext(agentContext) {
|
|
37
35
|
if (agentContext.isRootAgentContext) return;
|
|
38
|
-
if (this.config.multiWalletDatabaseScheme ===
|
|
36
|
+
if (this.config.multiWalletDatabaseScheme === "ProfilePerWallet") {
|
|
39
37
|
const { store, profile } = await agentContext.dependencyManager.resolve(AskarStoreManager).getInitializedStoreWithProfile(agentContext);
|
|
40
38
|
if (!profile) return;
|
|
41
39
|
try {
|
|
42
40
|
await store.createProfile(profile);
|
|
43
41
|
} catch (err) {
|
|
44
|
-
if (err instanceof AskarError && err.code ===
|
|
42
|
+
if (err instanceof AskarError && err.code === 3) return;
|
|
45
43
|
throw err;
|
|
46
44
|
}
|
|
47
45
|
return;
|
|
@@ -55,7 +53,7 @@ var AskarModule = class {
|
|
|
55
53
|
await agentContext.dependencyManager.resolve(AskarStoreManager).closeContext(agentContext);
|
|
56
54
|
}
|
|
57
55
|
};
|
|
58
|
-
|
|
59
56
|
//#endregion
|
|
60
57
|
export { AskarModule };
|
|
58
|
+
|
|
61
59
|
//# sourceMappingURL=AskarModule.mjs.map
|
|
@@ -1 +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":"
|
|
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,YAAmB,QAAkC;EAIrD,KAAO,MAAM;EAHX,KAAK,SAAS,IAAI,kBAAkB,MAAM;CAC5C;CAIA,SAAgB,mBAAsC;EACpD,kBAAkB,iBAAiB,mBAAmB,KAAK,MAAM;EAEjE,IAAI,CAAC,KAAK,OAAO,aAAa,CAAC,KAAK,OAAO,eACzC,kBACG,QAAQ,WAAW,CAAC,CACpB,OAAO,KAAK,8FAA8F;EAG/G,IAAI,KAAK,OAAO,WAAW;GACzB,MAAM,YAAY,kBAAkB,QAAQ,IAAI,yBAAyB;GACzE,IAAI,UAAU,SAAS,MAAM,YAAY,QAAQ,YAAY,0BAA0B,OAAO,GAC5F,MAAM,IAAI,WACR,8FAA8F,0BAA0B,QAAQ,6JAClI;GAGF,UAAU,gBAAgB,IAAI,0BAA0B,CAAC;EAC3D;EAEA,IAAI,KAAK,OAAO,eAAe;GAC7B,IAAI,kBAAkB,aAAa,iBAAiB,cAAc,GAChE,MAAM,IAAI,WACR,mGACF;GAEF,kBAAkB,kBAAkB,iBAAiB,gBAAgB,mBAAmB;EAC1F;EAEA,kBAAkB,kBAAkB,iBAAiB;CACvD;CAEA,MAAa,oBAAoB,cAA4B;EAE3D,MADqB,aAAa,kBAAkB,QAAQ,iBAC3C,CAAC,CAAC,+BAA+B,YAAY;CAChE;CAEA,MAAa,mBAAmB,cAA4B;EAE1D,IAAI,aAAa,oBACf;EAIF,IAAI,KAAK,OAAO,8BAAA,oBAA+E;GAE7F,MAAM,EAAE,OAAO,YAAY,MADN,aAAa,kBAAkB,QAAQ,iBAChB,CAAC,CAAC,+BAA+B,YAAY;GACzF,IAAI,CAAC,SAAS;GAEd,IAAI;IACF,MAAM,MAAM,cAAc,OAAO;GACnC,SAAS,KAAK;IACZ,IAAI,eAAe,cAAc,IAAI,SAAA,GACnC;IAGF,MAAM;GACR;GAEA;EACF;EAGA,MAAM,6CAA6C,cAAc,EAC/D,KAAK,KAAK,OAAO,MAAM,oBAAoB,CAAC,CAAC,EAC/C,CAAC;CACH;CAEA,MAAa,gBAAgB,cAA4B;EAIvD,MAHqB,aAAa,kBAAkB,QAAQ,iBAG3C,CAAC,CAAC,cAAc,YAAY;CAC/C;CAEA,MAAa,eAAe,cAA2C;EAGrE,MAFqB,aAAa,kBAAkB,QAAQ,iBAE3C,CAAC,CAAC,aAAa,YAAY;CAC9C;AACF"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AskarPostgresStorageConfig, AskarSqliteStorageConfig } from "./AskarStorageConfig.mjs";
|
|
2
2
|
import { Askar, KdfMethod } from "@openwallet-foundation/askar-shared";
|
|
3
|
-
|
|
4
3
|
//#region src/AskarModuleConfig.d.ts
|
|
5
|
-
declare enum AskarMultiWalletDatabaseScheme {
|
|
4
|
+
export declare enum AskarMultiWalletDatabaseScheme {
|
|
6
5
|
/**
|
|
7
6
|
* Each wallet get its own database and uses a separate store.
|
|
8
7
|
*/
|
|
@@ -12,7 +11,15 @@ declare enum AskarMultiWalletDatabaseScheme {
|
|
|
12
11
|
*/
|
|
13
12
|
ProfilePerWallet = "ProfilePerWallet"
|
|
14
13
|
}
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The `NativeAskar` class exported from `@openwallet-foundation/askar-shared` (and re-exported by the platform packages)
|
|
16
|
+
* since version 0.6.0. It is typed structurally so older versions of askar-shared, which don't export `NativeAskar`,
|
|
17
|
+
* remain supported.
|
|
18
|
+
*/
|
|
19
|
+
export interface NativeAskarLike {
|
|
20
|
+
readonly instance: Askar;
|
|
21
|
+
}
|
|
22
|
+
export interface AskarModuleConfigStoreOptions {
|
|
16
23
|
/**
|
|
17
24
|
* The id of the store, and also the default profile that will be used for the root agent instance.
|
|
18
25
|
*
|
|
@@ -41,7 +48,7 @@ interface AskarModuleConfigStoreOptions {
|
|
|
41
48
|
*/
|
|
42
49
|
database?: AskarSqliteStorageConfig | AskarPostgresStorageConfig;
|
|
43
50
|
}
|
|
44
|
-
interface AskarModuleConfigOptions {
|
|
51
|
+
export interface AskarModuleConfigOptions {
|
|
45
52
|
/**
|
|
46
53
|
* Store configuration used for askar.
|
|
47
54
|
*
|
|
@@ -50,18 +57,23 @@ interface AskarModuleConfigOptions {
|
|
|
50
57
|
*/
|
|
51
58
|
store: AskarModuleConfigStoreOptions;
|
|
52
59
|
/**
|
|
60
|
+
* The askar instance to use. You can pass either the `NativeAskar` class (askar 0.6.0+), which resolves the registered
|
|
61
|
+
* native binding lazily on each access, or an `Askar` instance directly (e.g. the deprecated `askar` export).
|
|
62
|
+
*
|
|
63
|
+
* Passing `NativeAskar` is recommended, as the deprecated `askar` export is only populated after the platform package
|
|
64
|
+
* has been imported, which can result in `undefined` depending on import order (e.g. with ESM or bundlers).
|
|
53
65
|
*
|
|
54
66
|
* ## Node.JS
|
|
55
67
|
*
|
|
56
68
|
* ```ts
|
|
57
|
-
* import {
|
|
69
|
+
* import { NativeAskar } from '@openwallet-foundation/askar-nodejs'
|
|
58
70
|
*
|
|
59
71
|
* const agent = new Agent({
|
|
60
72
|
* config: {},
|
|
61
73
|
* dependencies: agentDependencies,
|
|
62
74
|
* modules: {
|
|
63
75
|
* askar: new AskarModule({
|
|
64
|
-
* askar,
|
|
76
|
+
* askar: NativeAskar,
|
|
65
77
|
* })
|
|
66
78
|
* }
|
|
67
79
|
* })
|
|
@@ -70,20 +82,20 @@ interface AskarModuleConfigOptions {
|
|
|
70
82
|
* ## React Native
|
|
71
83
|
*
|
|
72
84
|
* ```ts
|
|
73
|
-
* import {
|
|
85
|
+
* import { NativeAskar } from '@openwallet-foundation/askar-react-native'
|
|
74
86
|
*
|
|
75
87
|
* const agent = new Agent({
|
|
76
88
|
* config: {},
|
|
77
89
|
* dependencies: agentDependencies,
|
|
78
90
|
* modules: {
|
|
79
91
|
* askar: new AskarModule({
|
|
80
|
-
* askar,
|
|
92
|
+
* askar: NativeAskar,
|
|
81
93
|
* })
|
|
82
94
|
* }
|
|
83
95
|
* })
|
|
84
96
|
* ```
|
|
85
97
|
*/
|
|
86
|
-
askar: Askar;
|
|
98
|
+
askar: Askar | NativeAskarLike;
|
|
87
99
|
/**
|
|
88
100
|
* Determine the strategy for storing wallets if multiple wallets are used in a single agent.
|
|
89
101
|
* This is mostly the case in multi-tenancy, and determines whether each tenant will get a separate
|
|
@@ -109,7 +121,7 @@ interface AskarModuleConfigOptions {
|
|
|
109
121
|
/**
|
|
110
122
|
* @public
|
|
111
123
|
*/
|
|
112
|
-
declare class AskarModuleConfig {
|
|
124
|
+
export declare class AskarModuleConfig {
|
|
113
125
|
private options;
|
|
114
126
|
constructor(options: AskarModuleConfigOptions);
|
|
115
127
|
/** See {@link AskarModuleConfigOptions.askar} */
|
|
@@ -121,5 +133,4 @@ declare class AskarModuleConfig {
|
|
|
121
133
|
get enableStorage(): boolean;
|
|
122
134
|
}
|
|
123
135
|
//#endregion
|
|
124
|
-
export { AskarModuleConfig, AskarModuleConfigOptions, AskarModuleConfigStoreOptions, AskarMultiWalletDatabaseScheme };
|
|
125
136
|
//# sourceMappingURL=AskarModuleConfig.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskarModuleConfig.d.mts","names":[],"sources":["../src/AskarModuleConfig.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"AskarModuleConfig.d.mts","names":[],"sources":["../src/AskarModuleConfig.ts"],"mappings":";;;oBAGY;;;;EAIV;;;;EAKA;;;;;;;iBAQe;WACN,UAAU;;iBAGJ;;;;;;;EAOf;;;;EAKA;;;;;;;;;;EAWA,yBAAyB,UAAU,kBAAkB,UAAU,kBAAkB,UAAU;;;;;;EAO3F,WAAW,2BAA2B;;iBAGvB;;;;;;;EAOf,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCP,OAAO,QAAQ;;;;;;;;;EAUf,4BAA4B;;;;;;EAO5B;;;;;;EAOA;;;;;qBAMW;UACH;EAEW,YAAA,SAAS;;MAKjB,SAAS;;MAQT,6BAAyB;MAIzB,SAAK;MAIL;MAIA"}
|
|
@@ -19,11 +19,12 @@ var AskarModuleConfig = class {
|
|
|
19
19
|
}
|
|
20
20
|
/** See {@link AskarModuleConfigOptions.askar} */
|
|
21
21
|
get askar() {
|
|
22
|
-
|
|
22
|
+
const askar = this.options.askar;
|
|
23
|
+
return "instance" in askar ? askar.instance : askar;
|
|
23
24
|
}
|
|
24
25
|
/** See {@link AskarModuleConfigOptions.multiWalletDatabaseScheme} */
|
|
25
26
|
get multiWalletDatabaseScheme() {
|
|
26
|
-
return this.options.multiWalletDatabaseScheme ??
|
|
27
|
+
return this.options.multiWalletDatabaseScheme ?? "DatabasePerWallet";
|
|
27
28
|
}
|
|
28
29
|
get store() {
|
|
29
30
|
return this.options.store;
|
|
@@ -35,7 +36,7 @@ var AskarModuleConfig = class {
|
|
|
35
36
|
return this.options.enableStorage ?? true;
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
|
-
|
|
39
39
|
//#endregion
|
|
40
40
|
export { AskarModuleConfig, AskarMultiWalletDatabaseScheme };
|
|
41
|
+
|
|
41
42
|
//# sourceMappingURL=AskarModuleConfig.mjs.map
|
|
@@ -1 +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 {
|
|
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\n/**\n * The `NativeAskar` class exported from `@openwallet-foundation/askar-shared` (and re-exported by the platform packages)\n * since version 0.6.0. It is typed structurally so older versions of askar-shared, which don't export `NativeAskar`,\n * remain supported.\n */\nexport interface NativeAskarLike {\n readonly instance: Askar\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 * The askar instance to use. You can pass either the `NativeAskar` class (askar 0.6.0+), which resolves the registered\n * native binding lazily on each access, or an `Askar` instance directly (e.g. the deprecated `askar` export).\n *\n * Passing `NativeAskar` is recommended, as the deprecated `askar` export is only populated after the platform package\n * has been imported, which can result in `undefined` depending on import order (e.g. with ESM or bundlers).\n *\n * ## Node.JS\n *\n * ```ts\n * import { NativeAskar } from '@openwallet-foundation/askar-nodejs'\n *\n * const agent = new Agent({\n * config: {},\n * dependencies: agentDependencies,\n * modules: {\n * askar: new AskarModule({\n * askar: NativeAskar,\n * })\n * }\n * })\n * ```\n *\n * ## React Native\n *\n * ```ts\n * import { NativeAskar } 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: NativeAskar,\n * })\n * }\n * })\n * ```\n */\n askar: Askar | NativeAskarLike\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(): Askar {\n const askar = this.options.askar\n\n // NativeAskar resolves the registered native binding on each access\n return 'instance' in askar ? askar.instance : 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,iCAAL,yBAAA,gCAAA;;;;CAIL,+BAAA,uBAAA;;;;CAKA,+BAAA,sBAAA;;AACF,EAAA,CAAA,CAAA;;;;AA0HA,IAAa,oBAAb,MAA+B;CAG7B,YAAmB,SAAmC;EACpD,KAAK,UAAU;CACjB;;CAGA,IAAW,QAAe;EACxB,MAAM,QAAQ,KAAK,QAAQ;EAG3B,OAAO,cAAc,QAAQ,MAAM,WAAW;CAChD;;CAGA,IAAW,4BAA4B;EACrC,OAAO,KAAK,QAAQ,6BAAA;CACtB;CAEA,IAAW,QAAQ;EACjB,OAAO,KAAK,QAAQ;CACtB;CAEA,IAAW,YAAY;EACrB,OAAO,KAAK,QAAQ,aAAa;CACnC;CAEA,IAAW,gBAAgB;EACzB,OAAO,KAAK,QAAQ,iBAAiB;CACvC;AACF"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @see https://docs.rs/sqlx/latest/sqlx/postgres/struct.PgConnectOptions.html#parameters
|
|
6
6
|
*/
|
|
7
|
-
interface AskarPostgresConnectionParameters {
|
|
7
|
+
export interface AskarPostgresConnectionParameters {
|
|
8
8
|
sslmode?: 'disable' | 'allow' | 'prefer' | 'require' | 'verify-ca' | 'verify-full';
|
|
9
9
|
sslrootcert?: string;
|
|
10
10
|
sslcert?: string;
|
|
@@ -14,7 +14,7 @@ interface AskarPostgresConnectionParameters {
|
|
|
14
14
|
options?: string;
|
|
15
15
|
[key: string]: string | number | boolean | undefined;
|
|
16
16
|
}
|
|
17
|
-
interface AskarPostgresConfig {
|
|
17
|
+
export interface AskarPostgresConfig {
|
|
18
18
|
host: string;
|
|
19
19
|
connectTimeout?: number;
|
|
20
20
|
idleTimeout?: number;
|
|
@@ -33,27 +33,26 @@ interface AskarPostgresConfig {
|
|
|
33
33
|
*/
|
|
34
34
|
connectionParameters?: AskarPostgresConnectionParameters;
|
|
35
35
|
}
|
|
36
|
-
interface AskarSqliteConfig {
|
|
36
|
+
export interface AskarSqliteConfig {
|
|
37
37
|
maxConnections?: number;
|
|
38
38
|
minConnections?: number;
|
|
39
39
|
inMemory?: boolean;
|
|
40
40
|
path?: string;
|
|
41
41
|
}
|
|
42
|
-
interface AskarPostgresCredentials {
|
|
42
|
+
export interface AskarPostgresCredentials {
|
|
43
43
|
account: string;
|
|
44
44
|
password: string;
|
|
45
45
|
adminAccount?: string;
|
|
46
46
|
adminPassword?: string;
|
|
47
47
|
}
|
|
48
|
-
interface AskarPostgresStorageConfig {
|
|
48
|
+
export interface AskarPostgresStorageConfig {
|
|
49
49
|
type: 'postgres';
|
|
50
50
|
config: AskarPostgresConfig;
|
|
51
51
|
credentials: AskarPostgresCredentials;
|
|
52
52
|
}
|
|
53
|
-
interface AskarSqliteStorageConfig {
|
|
53
|
+
export interface AskarSqliteStorageConfig {
|
|
54
54
|
type: 'sqlite';
|
|
55
55
|
config?: AskarSqliteConfig;
|
|
56
56
|
}
|
|
57
57
|
//#endregion
|
|
58
|
-
export { AskarPostgresConfig, AskarPostgresConnectionParameters, AskarPostgresCredentials, AskarPostgresStorageConfig, AskarSqliteConfig, AskarSqliteStorageConfig };
|
|
59
58
|
//# sourceMappingURL=AskarStorageConfig.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskarStorageConfig.d.mts","names":[],"sources":["../src/AskarStorageConfig.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AskarStorageConfig.d.mts","names":[],"sources":["../src/AskarStorageConfig.ts"],"mappings":";;;;;;iBAKiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;GAEC;;iBAGc;EACf;EACA;EACA;EACA;EACA;;;;;;;;;;;;EAaA,uBAAuB;;iBAGR;EAEf;EACA;EAGA;EACA;;iBAGe;EACf;EACA;EACA;EACA;;iBAGe;EACf;EACA,QAAQ;EACR,aAAa;;iBAGE;EACf;EACA,SAAS"}
|
|
@@ -5,7 +5,7 @@ function isAskarSqliteStorageConfig(config) {
|
|
|
5
5
|
function isAskarPostgresStorageConfig(config) {
|
|
6
6
|
return config?.type === "postgres";
|
|
7
7
|
}
|
|
8
|
-
|
|
9
8
|
//#endregion
|
|
10
9
|
export { isAskarPostgresStorageConfig, isAskarSqliteStorageConfig };
|
|
10
|
+
|
|
11
11
|
//# sourceMappingURL=AskarStorageConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskarStorageConfig.mjs","names":[],"sources":["../src/AskarStorageConfig.ts"],"sourcesContent":["/**\n * Connection parameters that are passed to the underlying postgres driver (sqlx).\n *\n * @see https://docs.rs/sqlx/latest/sqlx/postgres/struct.PgConnectOptions.html#parameters\n */\nexport interface AskarPostgresConnectionParameters {\n sslmode?: 'disable' | 'allow' | 'prefer' | 'require' | 'verify-ca' | 'verify-full'\n sslrootcert?: string\n sslcert?: string\n sslkey?: string\n 'statement-cache-capacity'?: number\n application_name?: string\n options?: string\n\n [key: string]: string | number | boolean | undefined\n}\n\nexport interface AskarPostgresConfig {\n host: string\n connectTimeout?: number\n idleTimeout?: number\n maxConnections?: number\n minConnections?: number\n\n /**\n * Additional connection parameters that will be added as query parameters to the\n * postgres connection url. This allows configuring e.g. ssl for the connection\n * without having to set environment variables.\n *\n * Parameters that are derived from the other config and credentials options (`connect_timeout`,\n * `idle_timeout`, `max_connections`, `min_connections`, `admin_account`, `admin_password`, `host`,\n * `port`, `user`, `password` and `dbname`) are not allowed.\n *\n * @see https://docs.rs/sqlx/latest/sqlx/postgres/struct.PgConnectOptions.html#parameters\n */\n connectionParameters?: AskarPostgresConnectionParameters\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":";AAoEA,SAAgB,2BAA2B,QAAiE;
|
|
1
|
+
{"version":3,"file":"AskarStorageConfig.mjs","names":[],"sources":["../src/AskarStorageConfig.ts"],"sourcesContent":["/**\n * Connection parameters that are passed to the underlying postgres driver (sqlx).\n *\n * @see https://docs.rs/sqlx/latest/sqlx/postgres/struct.PgConnectOptions.html#parameters\n */\nexport interface AskarPostgresConnectionParameters {\n sslmode?: 'disable' | 'allow' | 'prefer' | 'require' | 'verify-ca' | 'verify-full'\n sslrootcert?: string\n sslcert?: string\n sslkey?: string\n 'statement-cache-capacity'?: number\n application_name?: string\n options?: string\n\n [key: string]: string | number | boolean | undefined\n}\n\nexport interface AskarPostgresConfig {\n host: string\n connectTimeout?: number\n idleTimeout?: number\n maxConnections?: number\n minConnections?: number\n\n /**\n * Additional connection parameters that will be added as query parameters to the\n * postgres connection url. This allows configuring e.g. ssl for the connection\n * without having to set environment variables.\n *\n * Parameters that are derived from the other config and credentials options (`connect_timeout`,\n * `idle_timeout`, `max_connections`, `min_connections`, `admin_account`, `admin_password`, `host`,\n * `port`, `user`, `password` and `dbname`) are not allowed.\n *\n * @see https://docs.rs/sqlx/latest/sqlx/postgres/struct.PgConnectOptions.html#parameters\n */\n connectionParameters?: AskarPostgresConnectionParameters\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":";AAoEA,SAAgB,2BAA2B,QAAiE;CAC1G,OAAO,QAAQ,SAAS;AAC1B;AAEA,SAAgB,6BAA6B,QAAmE;CAC9G,OAAO,QAAQ,SAAS;AAC1B"}
|
|
@@ -2,9 +2,8 @@ import { AskarModuleConfig } from "./AskarModuleConfig.mjs";
|
|
|
2
2
|
import { AskarStoreExportOptions, AskarStoreImportOptions, AskarStoreRotateKeyOptions } from "./AskarApiOptions.mjs";
|
|
3
3
|
import { AgentContext, FileSystem } from "@credo-ts/core";
|
|
4
4
|
import { Session, Store } from "@openwallet-foundation/askar-shared";
|
|
5
|
-
|
|
6
5
|
//#region src/AskarStoreManager.d.ts
|
|
7
|
-
declare class AskarStoreManager {
|
|
6
|
+
export declare class AskarStoreManager {
|
|
8
7
|
private fileSystem;
|
|
9
8
|
private config;
|
|
10
9
|
constructor(fileSystem: FileSystem, config: AskarModuleConfig);
|
|
@@ -105,5 +104,4 @@ declare class AskarStoreManager {
|
|
|
105
104
|
private isStoreLevel;
|
|
106
105
|
}
|
|
107
106
|
//#endregion
|
|
108
|
-
export { AskarStoreManager };
|
|
109
107
|
//# sourceMappingURL=AskarStoreManager.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskarStoreManager.d.mts","names":[],"sources":["../src/AskarStoreManager.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AskarStoreManager.d.mts","names":[],"sources":["../src/AskarStoreManager.ts"],"mappings":";;;;;qBAqCa;UAEoC;UACrC;EADqC,YAAA,YAAY,YACjD,QAAQ;EAGX,YAAY,cAAc;UAInB;;;;UAuBA;;;;;;EAkBD,cAAc,cAAc,eAAY;;;;;;EAsBxC,aAAa,cAAc,eAAY;;;;;EAYvC,eAAe,cAAc,eAAe,QAAQ;;;;;EAoEpD,UAAU,cAAc,eAAe,QAAQ;;;;;;;;;;;EAqD/C,eAAe,cAAc,cAAc,SAAS,6BAA6B;;;;;;;EAkCjF,YAAY,cAAc,cAAc,SAAS,0BAAuB;;;;EA8CxE,YAAY,cAAc,cAAc,SAAS,0BAAuB;;;;;;;;;;EAoExE,YAAY,cAAc,eAAe;;;;EA6BzC,WAAW,cAAc,eAAY;UA0B1C;;;;;;;;EAqBK,gBAAgB,QAC3B,cAAc,cACd,WAAW,SAAS,YAAY,SAC/B,QAAQ,QAAQ;;;;;;;EAUN,YAAY,QACvB,cAAc,cACd,WAAW,SAAS,YAAY,SAC/B,QAAQ,QAAQ;UAIX;UAeM;EAgCD,+BAA+B,cAAc,eAAY;;;;;;;;UAgC9D;;;;UAWA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AskarModuleConfig
|
|
1
|
+
import { AskarModuleConfig } from "./AskarModuleConfig.mjs";
|
|
2
2
|
import { AskarError as AskarError$1 } from "./error/AskarError.mjs";
|
|
3
3
|
import { AskarStoreError } from "./error/AskarStoreError.mjs";
|
|
4
4
|
import { AskarStoreDuplicateError } from "./error/AskarStoreDuplicateError.mjs";
|
|
@@ -9,17 +9,15 @@ import { AskarStoreNotFoundError } from "./error/AskarStoreNotFoundError.mjs";
|
|
|
9
9
|
import "./error/index.mjs";
|
|
10
10
|
import { transformFromRecordTagValues } from "./storage/utils.mjs";
|
|
11
11
|
import { getAskarStoreConfigForContextCorrelationId } from "./tenants.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { isAskarError } from "./utils/askarError.mjs";
|
|
13
13
|
import { isSqliteInMemoryUri, keyDerivationMethodFromStoreConfig, uriFromStoreConfig } from "./utils/askarStoreConfig.mjs";
|
|
14
14
|
import "./utils/index.mjs";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import { KdfMethod,
|
|
20
|
-
|
|
15
|
+
import __decorateMetadata from "./_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.mjs";
|
|
16
|
+
import __decorateParam from "./_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.mjs";
|
|
17
|
+
import __decorate from "./_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.mjs";
|
|
18
|
+
import { InjectionSymbols, JsonTransformer, StorageVersionRecord, inject, injectable } from "@credo-ts/core";
|
|
19
|
+
import { KdfMethod, Store, StoreKeyMethod } from "@openwallet-foundation/askar-shared";
|
|
21
20
|
//#region src/AskarStoreManager.ts
|
|
22
|
-
var _ref;
|
|
23
21
|
let AskarStoreManager = class AskarStoreManager {
|
|
24
22
|
constructor(fileSystem, config) {
|
|
25
23
|
this.fileSystem = fileSystem;
|
|
@@ -29,7 +27,7 @@ let AskarStoreManager = class AskarStoreManager {
|
|
|
29
27
|
return !!this.getStore(agentContext)?.handle;
|
|
30
28
|
}
|
|
31
29
|
async getStoreConfig(agentContext) {
|
|
32
|
-
if (agentContext.isRootAgentContext || this.config.multiWalletDatabaseScheme ===
|
|
30
|
+
if (agentContext.isRootAgentContext || this.config.multiWalletDatabaseScheme === "ProfilePerWallet") return this.config.store;
|
|
33
31
|
const storeConfig = await getAskarStoreConfigForContextCorrelationId(agentContext);
|
|
34
32
|
return {
|
|
35
33
|
id: agentContext.contextCorrelationId,
|
|
@@ -99,7 +97,7 @@ let AskarStoreManager = class AskarStoreManager {
|
|
|
99
97
|
return store;
|
|
100
98
|
} catch (error) {
|
|
101
99
|
if (error instanceof AskarStoreDuplicateError) throw error;
|
|
102
|
-
if (isAskarError(error) && (error.code ===
|
|
100
|
+
if (isAskarError(error) && (error.code === 4 || error.code === 3)) {
|
|
103
101
|
const errorMessage = `Store '${storeConfig.id}' already exists`;
|
|
104
102
|
agentContext.config.logger.debug(errorMessage);
|
|
105
103
|
throw new AskarStoreDuplicateError(errorMessage, { cause: error });
|
|
@@ -130,12 +128,12 @@ let AskarStoreManager = class AskarStoreManager {
|
|
|
130
128
|
agentContext.dependencyManager.registerInstance(Store, store);
|
|
131
129
|
return store;
|
|
132
130
|
} catch (error) {
|
|
133
|
-
if (isAskarError(error) && (error.code ===
|
|
131
|
+
if (isAskarError(error) && (error.code === 6 || error.code === 1 && isSqliteInMemoryUri(askarStoreConfig.uri))) {
|
|
134
132
|
const errorMessage = `Store '${storeConfig.id}' not found`;
|
|
135
133
|
agentContext.config.logger.debug(errorMessage);
|
|
136
134
|
throw new AskarStoreNotFoundError(errorMessage, { cause: error });
|
|
137
135
|
}
|
|
138
|
-
if (isAskarError(error) && error.code ===
|
|
136
|
+
if (isAskarError(error) && error.code === 4) {
|
|
139
137
|
const errorMessage = `Incorrect key for store '${storeConfig.id}'`;
|
|
140
138
|
agentContext.config.logger.debug(errorMessage);
|
|
141
139
|
throw new AskarStoreInvalidKeyError(errorMessage, { cause: error });
|
|
@@ -346,7 +344,7 @@ let AskarStoreManager = class AskarStoreManager {
|
|
|
346
344
|
}
|
|
347
345
|
}
|
|
348
346
|
async getInitializedStoreWithProfile(agentContext) {
|
|
349
|
-
let store = this.getStore(agentContext, { recursive: this.config.multiWalletDatabaseScheme ===
|
|
347
|
+
let store = this.getStore(agentContext, { recursive: this.config.multiWalletDatabaseScheme === "ProfilePerWallet" });
|
|
350
348
|
if (!store) try {
|
|
351
349
|
store = await this.openStore(agentContext);
|
|
352
350
|
} catch (error) {
|
|
@@ -371,15 +369,15 @@ let AskarStoreManager = class AskarStoreManager {
|
|
|
371
369
|
*/
|
|
372
370
|
isStoreLevel(agentContext) {
|
|
373
371
|
if (agentContext.isRootAgentContext) return true;
|
|
374
|
-
return this.config.multiWalletDatabaseScheme ===
|
|
372
|
+
return this.config.multiWalletDatabaseScheme === "DatabasePerWallet";
|
|
375
373
|
}
|
|
376
374
|
};
|
|
377
375
|
AskarStoreManager = __decorate([
|
|
378
376
|
injectable(),
|
|
379
377
|
__decorateParam(0, inject(InjectionSymbols.FileSystem)),
|
|
380
|
-
__decorateMetadata("design:paramtypes", [Object, typeof
|
|
378
|
+
__decorateMetadata("design:paramtypes", [Object, typeof AskarModuleConfig === "undefined" ? Object : AskarModuleConfig])
|
|
381
379
|
], AskarStoreManager);
|
|
382
|
-
|
|
383
380
|
//#endregion
|
|
384
381
|
export { AskarStoreManager };
|
|
382
|
+
|
|
385
383
|
//# sourceMappingURL=AskarStoreManager.mjs.map
|