@nmshd/consumption 7.3.0-openid4vc.8 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/buildInformation.js +5 -5
  2. package/dist/consumption/ConsumptionConfig.d.ts +0 -1
  3. package/dist/consumption/ConsumptionConfig.d.ts.map +1 -1
  4. package/dist/consumption/ConsumptionController.d.ts +1 -3
  5. package/dist/consumption/ConsumptionController.d.ts.map +1 -1
  6. package/dist/consumption/ConsumptionController.js +1 -7
  7. package/dist/consumption/ConsumptionController.js.map +1 -1
  8. package/dist/consumption/ConsumptionControllerName.d.ts +1 -2
  9. package/dist/consumption/ConsumptionControllerName.d.ts.map +1 -1
  10. package/dist/consumption/ConsumptionControllerName.js +0 -1
  11. package/dist/consumption/ConsumptionControllerName.js.map +1 -1
  12. package/dist/consumption/ConsumptionIds.d.ts +0 -1
  13. package/dist/consumption/ConsumptionIds.d.ts.map +1 -1
  14. package/dist/consumption/ConsumptionIds.js +0 -1
  15. package/dist/consumption/ConsumptionIds.js.map +1 -1
  16. package/dist/modules/index.d.ts +0 -1
  17. package/dist/modules/index.d.ts.map +1 -1
  18. package/dist/modules/index.js +0 -1
  19. package/dist/modules/index.js.map +1 -1
  20. package/dist/modules/requests/events/index.d.ts +0 -1
  21. package/dist/modules/requests/events/index.d.ts.map +1 -1
  22. package/dist/modules/requests/events/index.js +0 -1
  23. package/dist/modules/requests/events/index.js.map +1 -1
  24. package/dist/modules/requests/index.d.ts +0 -3
  25. package/dist/modules/requests/index.d.ts.map +1 -1
  26. package/dist/modules/requests/index.js +0 -3
  27. package/dist/modules/requests/index.js.map +1 -1
  28. package/dist/modules/requests/outgoing/OutgoingRequestsController.d.ts.map +1 -1
  29. package/dist/modules/requests/outgoing/OutgoingRequestsController.js +1 -3
  30. package/dist/modules/requests/outgoing/OutgoingRequestsController.js.map +1 -1
  31. package/package.json +16 -38
  32. package/dist/modules/openid4vc/OpenId4VcController.d.ts +0 -36
  33. package/dist/modules/openid4vc/OpenId4VcController.d.ts.map +0 -1
  34. package/dist/modules/openid4vc/OpenId4VcController.js +0 -100
  35. package/dist/modules/openid4vc/OpenId4VcController.js.map +0 -1
  36. package/dist/modules/openid4vc/index.d.ts +0 -8
  37. package/dist/modules/openid4vc/index.d.ts.map +0 -1
  38. package/dist/modules/openid4vc/index.js +0 -24
  39. package/dist/modules/openid4vc/index.js.map +0 -1
  40. package/dist/modules/openid4vc/local/BaseAgent.d.ts +0 -17
  41. package/dist/modules/openid4vc/local/BaseAgent.d.ts.map +0 -1
  42. package/dist/modules/openid4vc/local/BaseAgent.js +0 -72
  43. package/dist/modules/openid4vc/local/BaseAgent.js.map +0 -1
  44. package/dist/modules/openid4vc/local/EnmeshedHolderFileSystem.d.ts +0 -14
  45. package/dist/modules/openid4vc/local/EnmeshedHolderFileSystem.d.ts.map +0 -1
  46. package/dist/modules/openid4vc/local/EnmeshedHolderFileSystem.js +0 -29
  47. package/dist/modules/openid4vc/local/EnmeshedHolderFileSystem.js.map +0 -1
  48. package/dist/modules/openid4vc/local/EnmeshedHolderKeyManagmentService.d.ts +0 -33
  49. package/dist/modules/openid4vc/local/EnmeshedHolderKeyManagmentService.d.ts.map +0 -1
  50. package/dist/modules/openid4vc/local/EnmeshedHolderKeyManagmentService.js +0 -345
  51. package/dist/modules/openid4vc/local/EnmeshedHolderKeyManagmentService.js.map +0 -1
  52. package/dist/modules/openid4vc/local/EnmeshedStorageService.d.ts +0 -24
  53. package/dist/modules/openid4vc/local/EnmeshedStorageService.d.ts.map +0 -1
  54. package/dist/modules/openid4vc/local/EnmeshedStorageService.js +0 -138
  55. package/dist/modules/openid4vc/local/EnmeshedStorageService.js.map +0 -1
  56. package/dist/modules/openid4vc/local/Holder.d.ts +0 -43
  57. package/dist/modules/openid4vc/local/Holder.d.ts.map +0 -1
  58. package/dist/modules/openid4vc/local/Holder.js +0 -184
  59. package/dist/modules/openid4vc/local/Holder.js.map +0 -1
  60. package/dist/modules/openid4vc/local/KeyStorage.d.ts +0 -12
  61. package/dist/modules/openid4vc/local/KeyStorage.d.ts.map +0 -1
  62. package/dist/modules/openid4vc/local/KeyStorage.js +0 -67
  63. package/dist/modules/openid4vc/local/KeyStorage.js.map +0 -1
  64. package/dist/modules/openid4vc/local/OpenId4VciCredentialResponseJSON.d.ts +0 -7
  65. package/dist/modules/openid4vc/local/OpenId4VciCredentialResponseJSON.d.ts.map +0 -1
  66. package/dist/modules/openid4vc/local/OpenId4VciCredentialResponseJSON.js +0 -3
  67. package/dist/modules/openid4vc/local/OpenId4VciCredentialResponseJSON.js.map +0 -1
  68. package/dist/modules/openid4vc/local/RequestedCredentialCache.d.ts +0 -9
  69. package/dist/modules/openid4vc/local/RequestedCredentialCache.d.ts.map +0 -1
  70. package/dist/modules/openid4vc/local/RequestedCredentialCache.js +0 -57
  71. package/dist/modules/openid4vc/local/RequestedCredentialCache.js.map +0 -1
  72. package/dist/modules/requests/events/ShareCredentialOfferRequestItemProcessedByRecipientEvent.d.ts +0 -12
  73. package/dist/modules/requests/events/ShareCredentialOfferRequestItemProcessedByRecipientEvent.d.ts.map +0 -1
  74. package/dist/modules/requests/events/ShareCredentialOfferRequestItemProcessedByRecipientEvent.js +0 -12
  75. package/dist/modules/requests/events/ShareCredentialOfferRequestItemProcessedByRecipientEvent.js.map +0 -1
  76. package/dist/modules/requests/itemProcessors/shareAuthorizationRequest/AcceptShareAuthorizationRequestRequestItemParameters.d.ts +0 -11
  77. package/dist/modules/requests/itemProcessors/shareAuthorizationRequest/AcceptShareAuthorizationRequestRequestItemParameters.d.ts.map +0 -1
  78. package/dist/modules/requests/itemProcessors/shareAuthorizationRequest/AcceptShareAuthorizationRequestRequestItemParameters.js +0 -29
  79. package/dist/modules/requests/itemProcessors/shareAuthorizationRequest/AcceptShareAuthorizationRequestRequestItemParameters.js.map +0 -1
  80. package/dist/modules/requests/itemProcessors/shareAuthorizationRequest/ShareAuthorizationRequestRequestItemProcessor.d.ts +0 -12
  81. package/dist/modules/requests/itemProcessors/shareAuthorizationRequest/ShareAuthorizationRequestRequestItemProcessor.d.ts.map +0 -1
  82. package/dist/modules/requests/itemProcessors/shareAuthorizationRequest/ShareAuthorizationRequestRequestItemProcessor.js +0 -55
  83. package/dist/modules/requests/itemProcessors/shareAuthorizationRequest/ShareAuthorizationRequestRequestItemProcessor.js.map +0 -1
  84. package/dist/modules/requests/itemProcessors/shareCredentialOffer/ShareCredentialOfferRequestItemProcessor.d.ts +0 -14
  85. package/dist/modules/requests/itemProcessors/shareCredentialOffer/ShareCredentialOfferRequestItemProcessor.d.ts.map +0 -1
  86. package/dist/modules/requests/itemProcessors/shareCredentialOffer/ShareCredentialOfferRequestItemProcessor.js +0 -45
  87. package/dist/modules/requests/itemProcessors/shareCredentialOffer/ShareCredentialOfferRequestItemProcessor.js.map +0 -1
@@ -1,8 +0,0 @@
1
- export * from "./local/BaseAgent";
2
- export * from "./local/EnmeshedHolderFileSystem";
3
- export * from "./local/EnmeshedHolderKeyManagmentService";
4
- export * from "./local/EnmeshedStorageService";
5
- export * from "./local/Holder";
6
- export * from "./local/OpenId4VciCredentialResponseJSON";
7
- export * from "./OpenId4VcController";
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/openid4vc/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kCAAkC,CAAC;AACjD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0CAA0C,CAAC;AACzD,cAAc,uBAAuB,CAAC"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./local/BaseAgent"), exports);
18
- __exportStar(require("./local/EnmeshedHolderFileSystem"), exports);
19
- __exportStar(require("./local/EnmeshedHolderKeyManagmentService"), exports);
20
- __exportStar(require("./local/EnmeshedStorageService"), exports);
21
- __exportStar(require("./local/Holder"), exports);
22
- __exportStar(require("./local/OpenId4VciCredentialResponseJSON"), exports);
23
- __exportStar(require("./OpenId4VcController"), exports);
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/openid4vc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mEAAiD;AACjD,4EAA0D;AAC1D,iEAA+C;AAC/C,iDAA+B;AAC/B,2EAAyD;AACzD,wDAAsC"}
@@ -1,17 +0,0 @@
1
- import { Agent, DidKey, type InitConfig, type ModulesMap, type VerificationMethod } from "@credo-ts/core";
2
- import { AccountController } from "@nmshd/transport";
3
- import { AttributesController } from "../../attributes";
4
- import { KeyStorage } from "./KeyStorage";
5
- export declare class BaseAgent<AgentModules extends ModulesMap> {
6
- private readonly keyStorage;
7
- config: InitConfig;
8
- agent: Agent<AgentModules>;
9
- did: string;
10
- didKey: DidKey;
11
- kid: string;
12
- verificationMethod: VerificationMethod;
13
- constructor(keyStorage: KeyStorage, modules: AgentModules, accountController: AccountController, attributeController: AttributesController, fetchInstance: typeof fetch);
14
- initializeAgent(privateKey: string): Promise<void>;
15
- shutdown(): Promise<void>;
16
- }
17
- //# sourceMappingURL=BaseAgent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseAgent.d.ts","sourceRoot":"","sources":["../../../../src/modules/openid4vc/local/BaseAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAGL,MAAM,EAKN,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,KAAK,kBAAkB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAIxD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,SAAS,CAAC,YAAY,SAAS,UAAU;IAS9C,OAAO,CAAC,QAAQ,CAAC,UAAU;IARxB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAC3B,GAAG,EAAG,MAAM,CAAC;IACb,MAAM,EAAG,MAAM,CAAC;IAChB,GAAG,EAAG,MAAM,CAAC;IACb,kBAAkB,EAAG,kBAAkB,CAAC;gBAG1B,UAAU,EAAE,UAAU,EACvC,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,oBAAoB,EACzC,aAAa,EAAE,OAAO,KAAK;IA6BlB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmClD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGzC"}
@@ -1,72 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BaseAgent = void 0;
7
- const core_1 = require("@credo-ts/core");
8
- const events_1 = require("events");
9
- const ws_1 = __importDefault(require("ws"));
10
- const EnmeshedHolderFileSystem_1 = require("./EnmeshedHolderFileSystem");
11
- const EnmeshedHolderKeyManagmentService_1 = require("./EnmeshedHolderKeyManagmentService");
12
- const EnmeshedStorageService_1 = require("./EnmeshedStorageService");
13
- class BaseAgent {
14
- constructor(keyStorage, modules, accountController, attributeController, fetchInstance) {
15
- this.keyStorage = keyStorage;
16
- const config = {
17
- allowInsecureHttpUrls: true,
18
- logger: new core_1.ConsoleLogger(core_1.LogLevel.off)
19
- };
20
- this.config = config;
21
- const dependencyManager = new core_1.DependencyManager();
22
- dependencyManager.registerInstance(core_1.InjectionSymbols.StorageService, new EnmeshedStorageService_1.EnmeshedStorageService(accountController, attributeController, this.keyStorage));
23
- this.agent = new core_1.Agent({
24
- config,
25
- dependencies: {
26
- // eslint-disable-next-line @typescript-eslint/naming-convention
27
- FileSystem: EnmeshedHolderFileSystem_1.EnmeshedHolderFileSystem,
28
- // eslint-disable-next-line @typescript-eslint/naming-convention
29
- EventEmitterClass: events_1.EventEmitter,
30
- fetch: fetchInstance,
31
- // eslint-disable-next-line @typescript-eslint/naming-convention
32
- WebSocketClass: ws_1.default
33
- },
34
- modules
35
- }, dependencyManager);
36
- }
37
- async initializeAgent(privateKey) {
38
- // as we are not using askar we need to set the storage version
39
- const storage = this.agent.dependencyManager.resolve(core_1.InjectionSymbols.StorageService);
40
- await storage.save(this.agent.context, new core_1.StorageVersionRecord({ storageVersion: "0.5.0" }));
41
- const kmsConfig = this.agent.dependencyManager.resolve(core_1.Kms.KeyManagementModuleConfig);
42
- kmsConfig.registerBackend(new EnmeshedHolderKeyManagmentService_1.EnmshedHolderKeyManagmentService(this.keyStorage));
43
- if (kmsConfig.backends.length === 0)
44
- throw new Error("No KMS backend registered");
45
- await this.agent.initialize();
46
- const keyId = privateKey;
47
- const didCreateResult = await this.agent.dids.create({
48
- method: "key",
49
- options: {
50
- createKey: {
51
- type: {
52
- crv: "Ed25519",
53
- kty: "OKP"
54
- },
55
- keyId: keyId
56
- }
57
- }
58
- });
59
- this.did = didCreateResult.didState.did;
60
- this.didKey = core_1.DidKey.fromDid(this.did);
61
- this.kid = `${this.did}#${this.didKey.publicJwk.fingerprint}`;
62
- const verificationMethod = didCreateResult.didState.didDocument?.dereferenceKey(this.kid, ["authentication"]);
63
- if (!verificationMethod)
64
- throw new Error("No verification method found");
65
- this.verificationMethod = verificationMethod;
66
- }
67
- async shutdown() {
68
- await this.agent.shutdown();
69
- }
70
- }
71
- exports.BaseAgent = BaseAgent;
72
- //# sourceMappingURL=BaseAgent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseAgent.js","sourceRoot":"","sources":["../../../../src/modules/openid4vc/local/BaseAgent.ts"],"names":[],"mappings":";;;;;;AAAA,yCAawB;AAExB,mCAAsC;AACtC,4CAA2B;AAE3B,yEAAsE;AACtE,2FAAuF;AACvF,qEAAkE;AAGlE,MAAa,SAAS;IAQlB,YACqB,UAAsB,EACvC,OAAqB,EACrB,iBAAoC,EACpC,mBAAyC,EACzC,aAA2B;QAJV,eAAU,GAAV,UAAU,CAAY;QAMvC,MAAM,MAAM,GAAG;YACX,qBAAqB,EAAE,IAAI;YAC3B,MAAM,EAAE,IAAI,oBAAa,CAAC,eAAQ,CAAC,GAAG,CAAC;SACrB,CAAC;QAEvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,MAAM,iBAAiB,GAAG,IAAI,wBAAiB,EAAE,CAAC;QAClD,iBAAiB,CAAC,gBAAgB,CAAC,uBAAgB,CAAC,cAAc,EAAE,IAAI,+CAAsB,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QACzJ,IAAI,CAAC,KAAK,GAAG,IAAI,YAAK,CAClB;YACI,MAAM;YACN,YAAY,EAAE;gBACV,gEAAgE;gBAChE,UAAU,EAAE,mDAAwB;gBACpC,gEAAgE;gBAChE,iBAAiB,EAAE,qBAAY;gBAC/B,KAAK,EAAE,aAAa;gBACpB,gEAAgE;gBAChE,cAAc,EAAE,YAAS;aAC5B;YACD,OA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AM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QAE9D,MAAM,kBAAkB,GAAG,eAAe,CAAC,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,kBAAkB;YAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACzE,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,QAAQ;QACjB,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC;CACJ;AAhFD,8BAgFC"}
@@ -1,14 +0,0 @@
1
- import { DownloadToFileOptions, FileSystem } from "@credo-ts/core";
2
- export declare class EnmeshedHolderFileSystem implements FileSystem {
3
- exists(_path: string): Promise<boolean>;
4
- createDirectory(_path: string): Promise<void>;
5
- copyFile(_sourcePath: string, _destinationPath: string): Promise<void>;
6
- write(_path: string, _data: string): Promise<void>;
7
- read(_path: string): Promise<string>;
8
- delete(_path: string): Promise<void>;
9
- downloadToFile(_url: string, _path: string, _options?: DownloadToFileOptions): Promise<void>;
10
- readonly dataPath: string;
11
- readonly cachePath: string;
12
- readonly tempPath: string;
13
- }
14
- //# sourceMappingURL=EnmeshedHolderFileSystem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnmeshedHolderFileSystem.d.ts","sourceRoot":"","sources":["../../../../src/modules/openid4vc/local/EnmeshedHolderFileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGnE,qBAAa,wBAAyB,YAAW,UAAU;IAChD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAGvC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAG7C,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGtE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGlD,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAGpC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGpC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAGnG,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,QAAQ,EAAE,MAAM,CAAC;CACpC"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnmeshedHolderFileSystem = void 0;
4
- // File system is not used since we don't use Askar or AnonCreds.
5
- class EnmeshedHolderFileSystem {
6
- exists(_path) {
7
- throw new Error("File system not implemented because previously not needed.");
8
- }
9
- createDirectory(_path) {
10
- throw new Error("File system not implemented because previously not needed.");
11
- }
12
- copyFile(_sourcePath, _destinationPath) {
13
- throw new Error("File system not implemented because previously not needed.");
14
- }
15
- write(_path, _data) {
16
- throw new Error("File system not implemented because previously not needed.");
17
- }
18
- read(_path) {
19
- throw new Error("File system not implemented because previously not needed.");
20
- }
21
- delete(_path) {
22
- throw new Error("File system not implemented because previously not needed.");
23
- }
24
- downloadToFile(_url, _path, _options) {
25
- throw new Error("File system not implemented because previously not needed.");
26
- }
27
- }
28
- exports.EnmeshedHolderFileSystem = EnmeshedHolderFileSystem;
29
- //# sourceMappingURL=EnmeshedHolderFileSystem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnmeshedHolderFileSystem.js","sourceRoot":"","sources":["../../../../src/modules/openid4vc/local/EnmeshedHolderFileSystem.ts"],"names":[],"mappings":";;;AAEA,iEAAiE;AACjE,MAAa,wBAAwB;IAC1B,MAAM,CAAC,KAAa;QACvB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IACM,eAAe,CAAC,KAAa;QAChC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IACM,QAAQ,CAAC,WAAmB,EAAE,gBAAwB;QACzD,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IACM,KAAK,CAAC,KAAa,EAAE,KAAa;QACrC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IACM,IAAI,CAAC,KAAa;QACrB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IACM,MAAM,CAAC,KAAa;QACvB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IACM,cAAc,CAAC,IAAY,EAAE,KAAa,EAAE,QAAgC;QAC/E,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;CAIJ;AAzBD,4DAyBC"}
@@ -1,33 +0,0 @@
1
- import { AgentContext, Kms } from "@credo-ts/core";
2
- import { KeyStorage } from "./KeyStorage";
3
- export interface JwkKeyPair {
4
- publicKey: JsonWebKey;
5
- privateKey: JsonWebKey;
6
- keyType?: string;
7
- }
8
- export declare class EnmshedHolderKeyManagmentService implements Kms.KeyManagementService {
9
- private readonly keyStorage;
10
- static readonly backend = "enmeshed";
11
- readonly backend = "enmeshed";
12
- private readonly b64url;
13
- private readonly b64urlDecode;
14
- private readonly buf2hex;
15
- private readonly hex2buf;
16
- constructor(keyStorage: KeyStorage);
17
- isOperationSupported(agentContext: AgentContext, operation: Kms.KmsOperation): boolean;
18
- getPublicKey(agentContext: AgentContext, keyId: string): Promise<Kms.KmsJwkPublic>;
19
- createKey<Type extends Kms.KmsCreateKeyType>(agentContext: AgentContext, options: Kms.KmsCreateKeyOptions<Type>): Promise<Kms.KmsCreateKeyReturn<Type>>;
20
- importKey<Jwk extends Kms.KmsJwkPrivate>(agentContext: AgentContext, options: Kms.KmsImportKeyOptions<Jwk>): Promise<Kms.KmsImportKeyReturn<Jwk>>;
21
- deleteKey(agentContext: AgentContext, options: Kms.KmsDeleteKeyOptions): Promise<boolean>;
22
- sign(agentContext: AgentContext, options: Kms.KmsSignOptions): Promise<Kms.KmsSignReturn>;
23
- verify(agentContext: AgentContext, options: Kms.KmsVerifyOptions): Promise<Kms.KmsVerifyReturn>;
24
- private ecdhEs;
25
- private utf8;
26
- private concat;
27
- private lenPrefix;
28
- private concatKdf;
29
- encrypt(agentContext: AgentContext, options: Kms.KmsEncryptOptions): Promise<Kms.KmsEncryptReturn>;
30
- decrypt(agentContext: AgentContext, options: Kms.KmsDecryptOptions): Promise<Kms.KmsDecryptReturn>;
31
- randomBytes(agentContext: AgentContext, options: Kms.KmsRandomBytesOptions): Kms.KmsRandomBytesReturn;
32
- }
33
- //# sourceMappingURL=EnmeshedHolderKeyManagmentService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnmeshedHolderKeyManagmentService.d.ts","sourceRoot":"","sources":["../../../../src/modules/openid4vc/local/EnmeshedHolderKeyManagmentService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAKnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,UAAU,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,gCAAiC,YAAW,GAAG,CAAC,oBAAoB;IAuB1D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAtB9C,gBAAuB,OAAO,cAAc;IAE5C,SAAgB,OAAO,cAA4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AAC,SAAS;IA8BJ,OAAO,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAqDxG,OAAO,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAIlG,WAAW,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC,qBAAqB,GAAG,GAAG,CAAC,oBAAoB;CAI/G"}
@@ -1,345 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.EnmshedHolderKeyManagmentService = void 0;
7
- const core_1 = require("@credo-ts/core");
8
- const elliptic_1 = require("elliptic");
9
- const crypto_1 = require("@nmshd/crypto");
10
- const sjcl_1 = __importDefault(require("sjcl"));
11
- class EnmshedHolderKeyManagmentService {
12
- static { this.backend = "enmeshed"; }
13
- constructor(keyStorage) {
14
- this.keyStorage = keyStorage;
15
- this.backend = EnmshedHolderKeyManagmentService.backend;
16
- this.b64url = (bytes) => crypto_1.SodiumWrapper.sodium.to_base64(bytes, crypto_1.SodiumWrapper.sodium.base64_variants.URLSAFE_NO_PADDING);
17
- this.b64urlDecode = (b64url) => crypto_1.SodiumWrapper.sodium.from_base64(b64url, crypto_1.SodiumWrapper.sodium.base64_variants.URLSAFE_NO_PADDING);
18
- // please note: we cannot use buffer here - because it is not available in the browser
19
- // and yes it could be pollyfilled but that extends the bundle size for no good reason
20
- this.buf2hex = (bytes) => {
21
- return Array.from(bytes)
22
- .map((b) => b.toString(16).padStart(2, "0"))
23
- .join("");
24
- };
25
- this.hex2buf = (hex) => {
26
- const bytes = new Uint8Array(hex.length / 2);
27
- for (let i = 0; i < bytes.length; i++) {
28
- bytes[i] = parseInt(hex.substring(i * 2, i * 2 + 2), 16);
29
- }
30
- return bytes;
31
- };
32
- }
33
- isOperationSupported(agentContext, operation) {
34
- agentContext.config.logger.debug(`EKM: Checking if operation is supported: ${JSON.stringify(operation)}`);
35
- if (operation.operation === "createKey") {
36
- if (operation.type.kty === "OKP") {
37
- return true;
38
- }
39
- if (operation.type.kty === "EC" && operation.type.crv === "P-256") {
40
- return true;
41
- }
42
- return false;
43
- }
44
- if (operation.operation === "verify" && operation.algorithm === "ES256") {
45
- return true;
46
- }
47
- if (operation.operation === "sign" && (operation.algorithm === "EdDSA" || operation.algorithm === "ES256")) {
48
- return true;
49
- }
50
- if (operation.operation === "randomBytes") {
51
- return true;
52
- }
53
- if (operation.operation === "deleteKey") {
54
- return true;
55
- }
56
- if (operation.operation === "encrypt" && ["A128GCM", "A256GCM"].includes(operation.encryption.algorithm)) {
57
- return true;
58
- }
59
- return false;
60
- }
61
- async getPublicKey(agentContext, keyId) {
62
- const keyPair = await this.keyStorage.getKey(keyId);
63
- if (!keyPair) {
64
- agentContext.config.logger.error(`EKM: Key with id ${keyId} not found`);
65
- throw new Error(`Key with id ${keyId} not found`);
66
- }
67
- return JSON.parse(keyPair).publicKey;
68
- }
69
- async createKey(agentContext, options) {
70
- options.keyId ??= "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
71
- // Use libsodium's randombytes_uniform for secure random number generation
72
- const r = crypto_1.SodiumWrapper.sodium.randombytes_uniform(16);
73
- const v = c === "x" ? r : (r & 0x3) | 0x8;
74
- return v.toString(16);
75
- });
76
- agentContext.config.logger.debug(`EKM: Creating key with id ${options.keyId} and type ${JSON.stringify(options.type)}`);
77
- if (options.type.kty === "EC" && options.type.crv === "P-256") {
78
- // Use P-256 (aka secp256r1)
79
- const ec = new elliptic_1.ec("p256");
80
- const key = ec.genKeyPair();
81
- // Public JWK
82
- const publicJwk = {
83
- kty: "EC", // Elliptic Curve
84
- crv: "P-256",
85
- x: this.b64url(new Uint8Array(key.getPublic().getX().toArray())),
86
- y: this.b64url(new Uint8Array(key.getPublic().getY().toArray()))
87
- };
88
- // Private JWK
89
- const privateJwk = {
90
- ...publicJwk,
91
- d: this.b64url(new Uint8Array(key.getPrivate().toArray()))
92
- };
93
- const jwkKeyPair = {
94
- publicKey: publicJwk,
95
- privateKey: privateJwk,
96
- keyType: "EC"
97
- };
98
- agentContext.config.logger.debug(`EKM: Created EC key pair with id ${options.keyId}`);
99
- // store the key pair in the keystore
100
- await this.keyStorage.storeKey(options.keyId, JSON.stringify(jwkKeyPair));
101
- // Credo doesn't trust the key id provided in the key binding jwk anymore, so there are two options: Storing the key id with the credential and making sure that key id is properly fetched - this turned out to be difficult - or the easy way out by storing this alternative key id computed from the public key.
102
- const credoLegacyKeyId = core_1.Kms.PublicJwk.fromPublicJwk(publicJwk).legacyKeyId;
103
- await this.keyStorage.storeKey(credoLegacyKeyId, JSON.stringify(jwkKeyPair));
104
- return { keyId: options.keyId, publicJwk: publicJwk };
105
- }
106
- const { keyType, publicKey, privateKey } = crypto_1.SodiumWrapper.sodium.crypto_sign_keypair();
107
- agentContext.config.logger.debug(`EKM: Created OKP key pair with id ${options.keyId} and keyType ${keyType}`);
108
- const seed = privateKey.slice(0, crypto_1.SodiumWrapper.sodium.crypto_sign_SEEDBYTES);
109
- // Public JWK
110
- const publicJwk = {
111
- kty: "OKP", // Octet Key Pair
112
- crv: "Ed25519",
113
- x: this.b64url(publicKey)
114
- };
115
- // Private JWK
116
- const privateJwk = {
117
- ...publicJwk,
118
- d: this.b64url(seed)
119
- };
120
- const jwkKeyPair = {
121
- publicKey: publicJwk,
122
- privateKey: privateJwk,
123
- keyType: "OKP"
124
- };
125
- await this.keyStorage.storeKey(options.keyId, JSON.stringify(jwkKeyPair));
126
- return { keyId: options.keyId, publicJwk: publicJwk };
127
- }
128
- importKey(agentContext, options) {
129
- agentContext.config.logger.debug(`EKM: Importing key with ${JSON.stringify(options)}`);
130
- throw new Error("Method not implemented.");
131
- }
132
- async deleteKey(agentContext, options) {
133
- const hasKey = await this.keyStorage.hasKey(options.keyId);
134
- if (!hasKey)
135
- throw new Error(`key with id ${options.keyId} not found. and cannot be deleted`);
136
- agentContext.config.logger.debug(`EKM: Deleting key with id ${options.keyId}`);
137
- await this.keyStorage.deleteKey(options.keyId);
138
- return true;
139
- }
140
- async sign(agentContext, options) {
141
- agentContext.config.logger.debug(`EKM: Signing data with key id ${options.keyId} using algorithm ${options.algorithm}`);
142
- const stringifiedKeyPair = await this.keyStorage.getKey(options.keyId);
143
- if (!stringifiedKeyPair) {
144
- throw new Error(`Key with id ${options.keyId} not found`);
145
- }
146
- const { privateKey, publicKey } = JSON.parse(stringifiedKeyPair);
147
- if (options.algorithm === "ES256") {
148
- // Use P-256 (aka secp256r1)
149
- const ec = new elliptic_1.ec("p256");
150
- if (!privateKey.d) {
151
- throw new Error("Private JWK does not contain 'd' parameter");
152
- }
153
- const priv = this.buf2hex(this.b64urlDecode(privateKey.d));
154
- const key = ec.keyFromPrivate(priv, "hex");
155
- // we need to hash the data using SHA-256
156
- const dataHash = ec.hash().update(options.data).digest();
157
- const signature = key.sign(dataHash);
158
- const r = new Uint8Array(signature.r.toArray());
159
- const s = new Uint8Array(signature.s.toArray());
160
- const signatureBytes = new Uint8Array(r.length + s.length);
161
- signatureBytes.set(r);
162
- signatureBytes.set(s, r.length);
163
- return await Promise.resolve({
164
- signature: signatureBytes
165
- });
166
- }
167
- const decode = (bytes) => crypto_1.SodiumWrapper.sodium.from_base64(bytes, crypto_1.SodiumWrapper.sodium.base64_variants.URLSAFE_NO_PADDING);
168
- // get the private key bytes
169
- if (privateKey.d === undefined) {
170
- throw new Error("Private key does not contain 'd' parameter");
171
- }
172
- const privateKeyBytes = decode(privateKey.d);
173
- // get the public key bytes
174
- if (publicKey.x === undefined) {
175
- throw new Error("Public key does not contain 'x' parameter");
176
- }
177
- const publicKeyBytes = decode(publicKey.x);
178
- // combine the key bytes to a full private key
179
- const fullPrivateKeyBytes = new Uint8Array(privateKeyBytes.length + publicKeyBytes.length);
180
- fullPrivateKeyBytes.set(privateKeyBytes);
181
- fullPrivateKeyBytes.set(publicKeyBytes, privateKeyBytes.length);
182
- // and use it to sign the data
183
- const signature = crypto_1.SodiumWrapper.sodium.crypto_sign_detached(options.data, fullPrivateKeyBytes);
184
- return {
185
- signature: signature // I hope this cast doesn't paper over something
186
- };
187
- }
188
- verify(agentContext, options) {
189
- agentContext.config.logger.debug(`EKM: Verifying signature with key id ${options.key.keyId} using algorithm ${options.algorithm}`);
190
- // Use P-256 (aka secp256r1)
191
- const ec = new elliptic_1.ec("p256");
192
- if (!options.key.publicJwk) {
193
- throw new Error("Public JWK is undefined");
194
- }
195
- if (options.key.publicJwk.kty !== "EC") {
196
- throw new Error("Public JWK does not contain 'x' or 'y' parameter");
197
- }
198
- const x = options.key.publicJwk.x;
199
- const y = options.key.publicJwk.y;
200
- const pub = { x: this.buf2hex(this.b64urlDecode(x)), y: this.buf2hex(this.b64urlDecode(y)) };
201
- const key = ec.keyFromPublic(pub, "hex");
202
- const signatureBytes = options.signature;
203
- const r = signatureBytes.subarray(0, 32);
204
- const s = signatureBytes.subarray(32, 64);
205
- const signature = { r: this.buf2hex(r), s: this.buf2hex(s) };
206
- // we need to hash the data using SHA-256
207
- const dataHash = ec.hash().update(options.data).digest();
208
- try {
209
- const verified = key.verify(dataHash, signature);
210
- return Promise.resolve({ verified: verified });
211
- }
212
- catch (e) {
213
- agentContext.config.logger.error(`EKM: Error during signature verification: ${e}`);
214
- throw e;
215
- }
216
- }
217
- async ecdhEs(localKeyId, remotePublicJWK) {
218
- const keyPairString = await this.keyStorage.getKey(localKeyId);
219
- if (!keyPairString) {
220
- throw new Error(`Key with id ${localKeyId} not found`);
221
- }
222
- const localKeyPair = JSON.parse(keyPairString);
223
- if (localKeyPair.keyType !== "EC") {
224
- throw new Error("Key type is not EC");
225
- }
226
- const ec = new elliptic_1.ec("p256");
227
- if (localKeyPair.privateKey.d === undefined) {
228
- throw new Error("Local private key does not contain 'd' parameter");
229
- }
230
- const localPriv = ec.keyFromPrivate(this.buf2hex(this.b64urlDecode(localKeyPair.privateKey.d)), "hex");
231
- // the remote jwk is base64url encoded - we again decode and transform to hex to receive a fitting public key
232
- const remoteBasePoint = ec.keyFromPublic({
233
- x: this.buf2hex(this.b64urlDecode(remotePublicJWK.x)),
234
- y: this.buf2hex(this.b64urlDecode(remotePublicJWK.y))
235
- }, "hex");
236
- const sharedSecret = localPriv.derive(remoteBasePoint.getPublic());
237
- const sharedBytes = new Uint8Array(sharedSecret.toArray("be"));
238
- return sharedBytes;
239
- }
240
- // UTF-8 encode helper
241
- utf8(str) {
242
- return new TextEncoder().encode(str);
243
- }
244
- // Concat Uint8Arrays
245
- concat(...arrays) {
246
- const total = arrays.reduce((sum, a) => sum + a.length, 0);
247
- const out = new Uint8Array(total);
248
- let offset = 0;
249
- for (const a of arrays) {
250
- out.set(a, offset);
251
- offset += a.length;
252
- }
253
- return out;
254
- }
255
- // Encode a 32-bit big-endian length prefix
256
- lenPrefix(data) {
257
- const buf = new Uint8Array(4 + data.length);
258
- const view = new DataView(buf.buffer);
259
- view.setUint32(0, data.length, false); // big-endian
260
- buf.set(data, 4);
261
- return buf;
262
- }
263
- concatKdf(sharedSecret, keyLength, algorithmDescriptor, keyAgreement) {
264
- if (keyAgreement.apu === undefined) {
265
- throw new Error("Key agreement apu is undefined");
266
- }
267
- if (keyAgreement.apv === undefined) {
268
- throw new Error("Key agreement apv is undefined");
269
- }
270
- const algId = this.lenPrefix(this.utf8(algorithmDescriptor));
271
- const partyU = this.lenPrefix(keyAgreement.apu);
272
- const partyV = this.lenPrefix(keyAgreement.apv);
273
- const suppPubInfo = new Uint8Array(4);
274
- new DataView(suppPubInfo.buffer).setUint32(0, keyLength, false);
275
- const suppPrivInfo = new Uint8Array(0);
276
- const otherInfo = this.concat(algId, partyU, partyV, suppPubInfo, suppPrivInfo);
277
- const counter = new Uint8Array([0, 0, 0, 1]);
278
- const input = this.concat(counter, sharedSecret, otherInfo);
279
- // Hash with SHA-256 (SJCL)
280
- const inputHex = this.buf2hex(input);
281
- const inputBits = sjcl_1.default.codec.hex.toBits(inputHex);
282
- const hashBits = sjcl_1.default.hash.sha256.hash(inputBits);
283
- const hashHex = sjcl_1.default.codec.hex.fromBits(hashBits);
284
- const hashBuf = this.hex2buf(hashHex);
285
- // Truncate to desired key length
286
- return hashBuf.subarray(0, keyLength / 8);
287
- }
288
- async encrypt(agentContext, options) {
289
- try {
290
- // encryption via A-128-GCM/A-256-GCM
291
- // we will call the services side bob and the incoming side alice
292
- if (options.key.keyAgreement === undefined) {
293
- throw new Error("Key agreement is undefined");
294
- }
295
- if (options.key.keyAgreement.keyId === undefined) {
296
- throw new Error("Key agreement keyId is undefined");
297
- }
298
- const algorithm = options.encryption.algorithm;
299
- const keyLength = options.encryption.algorithm === "A128GCM" ? 128 : 256;
300
- // 1. derive the shared secret via ECDH-ES
301
- const sharedSecret = await this.ecdhEs(options.key.keyAgreement.keyId, options.key.keyAgreement.externalPublicJwk);
302
- agentContext.config.logger.debug(`EKM: Derived shared secret for encryption using ECDH-ES`);
303
- // 2. Concat KDF to form the final key
304
- const derivedKey = this.concatKdf(sharedSecret, keyLength, algorithm, options.key.keyAgreement);
305
- // 3. Encrypt the data via AES-256-GCM using libsodium
306
- // create nonce
307
- const iv = crypto.getRandomValues(new Uint8Array(12));
308
- // transform to bit arrays for sjcl
309
- const keyBits = sjcl_1.default.codec.hex.toBits(this.buf2hex(derivedKey));
310
- const dataBits = sjcl_1.default.codec.hex.toBits(this.buf2hex(options.data));
311
- const ivBits = sjcl_1.default.codec.hex.toBits(this.buf2hex(iv));
312
- // do not forget to add the additional authenticated data
313
- const aadBits = "aad" in options.encryption && options.encryption.aad ? sjcl_1.default.codec.hex.toBits(this.buf2hex(options.encryption.aad)) : [];
314
- // setup aes
315
- const aes = new sjcl_1.default.cipher.aes(keyBits);
316
- // encrypt
317
- const cyphertextBits = sjcl_1.default.mode.gcm.encrypt(aes, dataBits, ivBits, aadBits, 128);
318
- // transform back to byte array
319
- const cyphertextBuf = this.hex2buf(sjcl_1.default.codec.hex.fromBits(cyphertextBits));
320
- // In SJCL, GCM output = ciphertext || tag
321
- const cyphertext = cyphertextBuf.subarray(0, cyphertextBuf.length - 16);
322
- const tag = cyphertextBuf.subarray(cyphertextBuf.length - 16);
323
- const returnValue = {
324
- encrypted: cyphertext,
325
- iv: iv,
326
- tag: tag
327
- };
328
- return returnValue;
329
- }
330
- catch (e) {
331
- agentContext.config.logger.error(`EKM: Error during encryption: ${e}`);
332
- throw e;
333
- }
334
- }
335
- decrypt(agentContext, options) {
336
- agentContext.config.logger.debug(`EKM: Decrypting data with key id ${options.key.keyId} using options ${options}`);
337
- throw new Error("Method not implemented.");
338
- }
339
- randomBytes(agentContext, options) {
340
- agentContext.config.logger.debug(`EKM: Generating ${options.length} random bytes`);
341
- return crypto_1.SodiumWrapper.sodium.randombytes_buf(options.length); // Uint8Array
342
- }
343
- }
344
- exports.EnmshedHolderKeyManagmentService = EnmshedHolderKeyManagmentService;
345
- //# sourceMappingURL=EnmeshedHolderKeyManagmentService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnmeshedHolderKeyManagmentService.js","sourceRoot":"","sources":["../../../../src/modules/openid4vc/local/EnmeshedHolderKeyManagmentService.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAmD;AACnD,uCAAoC;AAEpC,0CAA8C;AAC9C,gDAAwB;AASxB,MAAa,gCAAgC;aAClB,YAAO,GAAG,UAAU,AAAb,CAAc;IAsB5C,YAAoC,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QApB1C,YAAO,GAAG,gCAAgC,CAAC,OAAO,CAAC;QAElD,WAAM,GAAG,CAAC,KAAiB,EAAE,EAAE,CAAC,sBAAa,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAG,sBAAa,CAAC,MAAc,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;QACxI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GAAG,CAAC,KAAK,kBAAkB,OAAO,EAAE,CAAC,CAAC;QACnH,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IACM,WAAW,CAAC,YAA0B,EAAE,OAAkC;QAC7E,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,OAAO,CAAC,MAAM,eAAe,CAAC,CAAC;QACnF,OAAO,sBAAa,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa;IAC9E,CAAC;;AArYL,4EAsYC"}
@@ -1,24 +0,0 @@
1
- import { AgentContext, BaseRecord, BaseRecordConstructor, Query, QueryOptions, StorageService } from "@credo-ts/core";
2
- import { AccountController } from "@nmshd/transport";
3
- import { OwnIdentityAttribute } from "../../attributes";
4
- import { AttributesController } from "../../attributes/AttributesController";
5
- import { KeyStorage } from "./KeyStorage";
6
- export declare class EnmeshedStorageService<T extends BaseRecord> implements StorageService<T> {
7
- private readonly accountController;
8
- private readonly attributeController;
9
- private readonly keyStorage;
10
- storage: Map<string, T>;
11
- constructor(accountController: AccountController, attributeController: AttributesController, keyStorage: KeyStorage);
12
- save(_agentContext: AgentContext, record: T): Promise<void>;
13
- saveWithDisplay(agentContext: AgentContext, value: string | Record<string, any>, type: string, displayInformation?: Record<string, any>[]): Promise<OwnIdentityAttribute>;
14
- update(_agentContext: AgentContext, _record: T): Promise<void>;
15
- delete(_agentContext: AgentContext, _record: T): Promise<void>;
16
- deleteById(_agentContext: AgentContext, _recordClass: BaseRecordConstructor<T>, _id: string): Promise<void>;
17
- getById(_agentContext: AgentContext, _recordClass: BaseRecordConstructor<T>, id: string): Promise<T>;
18
- getAll(_agentContext: AgentContext, recordClass: BaseRecordConstructor<T>): Promise<T[]>;
19
- private recordTypeToCredentialType;
20
- findByQuery(agentContext: AgentContext, recordClass: BaseRecordConstructor<T>, query: Query<T>, queryOptions?: QueryOptions): Promise<T[]>;
21
- private matchesQuery;
22
- }
23
- export declare function decodeRecord(type: string, encoded: string | Record<string, any>): BaseRecord<any, any>;
24
- //# sourceMappingURL=EnmeshedStorageService.d.ts.map