@credo-ts/node 0.6.0-alpha-20250807200316 → 0.6.0-alpha-20250808215909

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 (39) hide show
  1. package/build/NodeFileSystem.js +18 -8
  2. package/build/NodeFileSystem.js.map +1 -1
  3. package/build/index.d.ts +3 -0
  4. package/build/index.js +5 -1
  5. package/build/index.js.map +1 -1
  6. package/build/kms/NodeInMemoryKeyManagementStorage.d.ts +75 -0
  7. package/build/kms/NodeInMemoryKeyManagementStorage.js +37 -0
  8. package/build/kms/NodeInMemoryKeyManagementStorage.js.map +1 -0
  9. package/build/kms/NodeKeyManagementService.d.ts +20 -0
  10. package/build/kms/NodeKeyManagementService.js +381 -0
  11. package/build/kms/NodeKeyManagementService.js.map +1 -0
  12. package/build/kms/NodeKeyManagementStorage.d.ts +10 -0
  13. package/build/kms/NodeKeyManagementStorage.js +3 -0
  14. package/build/kms/NodeKeyManagementStorage.js.map +1 -0
  15. package/build/kms/crypto/createKey.d.ts +39 -0
  16. package/build/kms/crypto/createKey.js +87 -0
  17. package/build/kms/crypto/createKey.js.map +1 -0
  18. package/build/kms/crypto/decrypt.d.ts +4 -0
  19. package/build/kms/crypto/decrypt.js +84 -0
  20. package/build/kms/crypto/decrypt.js.map +1 -0
  21. package/build/kms/crypto/deriveKey.d.ts +41 -0
  22. package/build/kms/crypto/deriveKey.js +235 -0
  23. package/build/kms/crypto/deriveKey.js.map +1 -0
  24. package/build/kms/crypto/encrypt.d.ts +7 -0
  25. package/build/kms/crypto/encrypt.js +114 -0
  26. package/build/kms/crypto/encrypt.js.map +1 -0
  27. package/build/kms/crypto/sign.d.ts +5 -0
  28. package/build/kms/crypto/sign.js +81 -0
  29. package/build/kms/crypto/sign.js.map +1 -0
  30. package/build/kms/crypto/verify.d.ts +2 -0
  31. package/build/kms/crypto/verify.js +43 -0
  32. package/build/kms/crypto/verify.js.map +1 -0
  33. package/build/transport/HttpInboundTransport.d.ts +4 -3
  34. package/build/transport/HttpInboundTransport.js +31 -18
  35. package/build/transport/HttpInboundTransport.js.map +1 -1
  36. package/build/transport/WsInboundTransport.d.ts +4 -3
  37. package/build/transport/WsInboundTransport.js +33 -22
  38. package/build/transport/WsInboundTransport.js.map +1 -1
  39. package/package.json +12 -11
@@ -15,25 +15,35 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.NodeFileSystem = void 0;
30
- const core_1 = require("@credo-ts/core");
31
40
  const crypto_1 = require("crypto");
32
41
  const fs_1 = __importStar(require("fs"));
33
42
  const http_1 = __importDefault(require("http"));
34
43
  const https_1 = __importDefault(require("https"));
35
44
  const os_1 = require("os");
36
45
  const path_1 = require("path");
46
+ const core_1 = require("@credo-ts/core");
37
47
  const { access, readFile, writeFile, mkdir, rm, unlink, copyFile } = fs_1.promises;
38
48
  class NodeFileSystem {
39
49
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"NodeFileSystem.js","sourceRoot":"","sources":["../src/NodeFileSystem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAA8D;AAC9D,mCAAmC;AACnC,yCAAiC;AACjC,gDAAuB;AACvB,kDAAyB;AACzB,2BAAoC;AACpC,+BAA8B;AAE9B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAQ,CAAA;AAE7E,MAAa,cAAc;IAKzB;;;;;;;;;OASG;IACH,YAAmB,OAAkF;QACnG,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,YAAY,OAAO,CAAC,CAAC,CAAC,GAAG,IAAA,YAAO,GAAE,YAAY,CAAA;QAClG,IAAI,CAAC,SAAS,GAAG,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,aAAa,OAAO,CAAC,CAAC,CAAC,GAAG,IAAA,YAAO,GAAE,aAAa,CAAA;QACtG,IAAI,CAAC,QAAQ,GAAG,GAAG,OAAO,EAAE,YAAY,IAAI,IAAA,WAAM,GAAE,OAAO,CAAA;IAC7D,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,IAAY;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;YAClB,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,IAAY;QACvC,MAAM,KAAK,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACjD,CAAC;IAEM,KA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CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AApGD,wCAoGC"}
package/build/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import type { AgentDependencies } from '@credo-ts/core';
2
2
  import { HttpInboundTransport } from './transport/HttpInboundTransport';
3
3
  import { WsInboundTransport } from './transport/WsInboundTransport';
4
+ export { NodeInMemoryKeyManagementStorage } from './kms/NodeInMemoryKeyManagementStorage';
5
+ export { NodeKeyManagementService } from './kms/NodeKeyManagementService';
6
+ export { NodeKeyManagementStorage } from './kms/NodeKeyManagementStorage';
4
7
  declare const agentDependencies: AgentDependencies;
5
8
  export { agentDependencies, HttpInboundTransport, WsInboundTransport };
package/build/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WsInboundTransport = exports.HttpInboundTransport = exports.agentDependencies = void 0;
3
+ exports.WsInboundTransport = exports.HttpInboundTransport = exports.agentDependencies = exports.NodeKeyManagementService = exports.NodeInMemoryKeyManagementStorage = void 0;
4
4
  const events_1 = require("events");
5
5
  const ws_1 = require("ws");
6
6
  const NodeFileSystem_1 = require("./NodeFileSystem");
@@ -8,6 +8,10 @@ const HttpInboundTransport_1 = require("./transport/HttpInboundTransport");
8
8
  Object.defineProperty(exports, "HttpInboundTransport", { enumerable: true, get: function () { return HttpInboundTransport_1.HttpInboundTransport; } });
9
9
  const WsInboundTransport_1 = require("./transport/WsInboundTransport");
10
10
  Object.defineProperty(exports, "WsInboundTransport", { enumerable: true, get: function () { return WsInboundTransport_1.WsInboundTransport; } });
11
+ var NodeInMemoryKeyManagementStorage_1 = require("./kms/NodeInMemoryKeyManagementStorage");
12
+ Object.defineProperty(exports, "NodeInMemoryKeyManagementStorage", { enumerable: true, get: function () { return NodeInMemoryKeyManagementStorage_1.NodeInMemoryKeyManagementStorage; } });
13
+ var NodeKeyManagementService_1 = require("./kms/NodeKeyManagementService");
14
+ Object.defineProperty(exports, "NodeKeyManagementService", { enumerable: true, get: function () { return NodeKeyManagementService_1.NodeKeyManagementService; } });
11
15
  const agentDependencies = {
12
16
  FileSystem: NodeFileSystem_1.NodeFileSystem,
13
17
  fetch,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,mCAAqC;AACrC,2BAA8B;AAE9B,qDAAiD;AACjD,2EAAuE;AAU3C,qGAVnB,2CAAoB,OAUmB;AAThD,uEAAmE;AASjB,mGATzC,uCAAkB,OASyC;AAPpE,MAAM,iBAAiB,GAAsB;IAC3C,UAAU,EAAE,+BAAc;IAC1B,KAAK;IACL,iBAAiB,EAAE,qBAAY;IAC/B,cAAc,EAAE,cAAS;CAC1B,CAAA;AAEQ,8CAAiB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,mCAAqC;AACrC,2BAA8B;AAE9B,qDAAiD;AACjD,2EAAuE;AAc3C,qGAdnB,2CAAoB,OAcmB;AAbhD,uEAAmE;AAajB,mGAbzC,uCAAkB,OAayC;AAXpE,2FAAyF;AAAhF,oJAAA,gCAAgC,OAAA;AACzC,2EAAyE;AAAhE,oIAAA,wBAAwB,OAAA;AAGjC,MAAM,iBAAiB,GAAsB;IAC3C,UAAU,EAAE,+BAAc;IAC1B,KAAK;IACL,iBAAiB,EAAE,qBAAY;IAC/B,cAAc,EAAE,cAAS;CAC1B,CAAA;AAEQ,8CAAiB"}
@@ -0,0 +1,75 @@
1
+ import type { AgentContext, Kms } from '@credo-ts/core';
2
+ import type { NodeKeyManagementStorage } from './NodeKeyManagementStorage';
3
+ export declare class NodeInMemoryKeyManagementStorage implements NodeKeyManagementStorage {
4
+ #private;
5
+ get(agentContext: AgentContext, keyId: string): Promise<{
6
+ kty: "EC";
7
+ crv: "P-256" | "P-384" | "P-521" | "secp256k1";
8
+ x: string;
9
+ d: string;
10
+ y: string;
11
+ kid?: string | undefined;
12
+ alg?: string | undefined;
13
+ key_ops?: string[] | undefined;
14
+ use?: string | undefined;
15
+ ext?: boolean | undefined;
16
+ x5c?: string[] | undefined;
17
+ x5t?: string | undefined;
18
+ 'x5t#S256'?: string | undefined;
19
+ x5u?: string | undefined;
20
+ } | {
21
+ kty: "RSA";
22
+ d: string;
23
+ n: string;
24
+ e: string;
25
+ p: string;
26
+ q: string;
27
+ dp: string;
28
+ dq: string;
29
+ qi: string;
30
+ kid?: string | undefined;
31
+ alg?: string | undefined;
32
+ key_ops?: string[] | undefined;
33
+ use?: string | undefined;
34
+ ext?: boolean | undefined;
35
+ x5c?: string[] | undefined;
36
+ x5t?: string | undefined;
37
+ 'x5t#S256'?: string | undefined;
38
+ x5u?: string | undefined;
39
+ oth?: import("@credo-ts/core/src/utils/zod").objectOutputType<{
40
+ d: import("@credo-ts/core/src/utils/zod").ZodOptional<import("@credo-ts/core/src/utils/zod").ZodString>;
41
+ r: import("@credo-ts/core/src/utils/zod").ZodOptional<import("@credo-ts/core/src/utils/zod").ZodString>;
42
+ t: import("@credo-ts/core/src/utils/zod").ZodOptional<import("@credo-ts/core/src/utils/zod").ZodString>;
43
+ }, import("@credo-ts/core/src/utils/zod").ZodTypeAny, "passthrough">[] | undefined;
44
+ } | {
45
+ kty: "oct";
46
+ k: string;
47
+ kid?: string | undefined;
48
+ alg?: string | undefined;
49
+ key_ops?: string[] | undefined;
50
+ use?: string | undefined;
51
+ ext?: boolean | undefined;
52
+ x5c?: string[] | undefined;
53
+ x5t?: string | undefined;
54
+ 'x5t#S256'?: string | undefined;
55
+ x5u?: string | undefined;
56
+ } | {
57
+ kty: "OKP";
58
+ crv: "X25519" | "Ed25519";
59
+ x: string;
60
+ d: string;
61
+ kid?: string | undefined;
62
+ alg?: string | undefined;
63
+ key_ops?: string[] | undefined;
64
+ use?: string | undefined;
65
+ ext?: boolean | undefined;
66
+ x5c?: string[] | undefined;
67
+ x5t?: string | undefined;
68
+ 'x5t#S256'?: string | undefined;
69
+ x5u?: string | undefined;
70
+ } | null>;
71
+ has(agentContext: AgentContext, keyId: string): boolean;
72
+ set(agentContext: AgentContext, keyId: string, jwk: Kms.KmsJwkPrivate): void;
73
+ delete(agentContext: AgentContext, keyId: string): boolean;
74
+ private storageForContext;
75
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _NodeInMemoryKeyManagementStorage_storage;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.NodeInMemoryKeyManagementStorage = void 0;
10
+ class NodeInMemoryKeyManagementStorage {
11
+ constructor() {
12
+ _NodeInMemoryKeyManagementStorage_storage.set(this, new Map());
13
+ }
14
+ async get(agentContext, keyId) {
15
+ return this.storageForContext(agentContext).get(keyId) ?? null;
16
+ }
17
+ has(agentContext, keyId) {
18
+ return this.storageForContext(agentContext).has(keyId);
19
+ }
20
+ set(agentContext, keyId, jwk) {
21
+ this.storageForContext(agentContext).set(keyId, jwk);
22
+ }
23
+ delete(agentContext, keyId) {
24
+ return this.storageForContext(agentContext).delete(keyId);
25
+ }
26
+ storageForContext(agentContext) {
27
+ let storage = __classPrivateFieldGet(this, _NodeInMemoryKeyManagementStorage_storage, "f").get(agentContext.contextCorrelationId);
28
+ if (!storage) {
29
+ storage = new Map();
30
+ __classPrivateFieldGet(this, _NodeInMemoryKeyManagementStorage_storage, "f").set(agentContext.contextCorrelationId, storage);
31
+ }
32
+ return storage;
33
+ }
34
+ }
35
+ exports.NodeInMemoryKeyManagementStorage = NodeInMemoryKeyManagementStorage;
36
+ _NodeInMemoryKeyManagementStorage_storage = new WeakMap();
37
+ //# sourceMappingURL=NodeInMemoryKeyManagementStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeInMemoryKeyManagementStorage.js","sourceRoot":"","sources":["../../src/kms/NodeInMemoryKeyManagementStorage.ts"],"names":[],"mappings":";;;;;;;;;AAGA,MAAa,gCAAgC;IAA7C;QACE,oDAAW,IAAI,GAAG,EAA0C,EAAA;IA4B9D,CAAC;IA1BQ,KAAK,CAAC,GAAG,CAAC,YAA0B,EAAE,KAAa;QACxD,OAAO,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAA;IAChE,CAAC;IAEM,GAAG,CAAC,YAA0B,EAAE,KAAa;QAClD,OAAO,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACxD,CAAC;IAEM,GAAG,CAAC,YAA0B,EAAE,KAAa,EAAE,GAAsB;QAC1E,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACtD,CAAC;IAEM,MAAM,CAAC,YAA0B,EAAE,KAAa;QACrD,OAAO,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC3D,CAAC;IAEO,iBAAiB,CAAC,YAA0B;QAClD,IAAI,OAAO,GAAG,uBAAA,IAAI,iDAAS,CAAC,GAAG,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAA;QAElE,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,IAAI,GAAG,EAAE,CAAA;YACnB,uBAAA,IAAI,iDAAS,CAAC,GAAG,CAAC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAA;QAC/D,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AA7BD,4EA6BC"}
@@ -0,0 +1,20 @@
1
+ import type { AgentContext } from '@credo-ts/core';
2
+ import type { NodeKeyManagementStorage } from './NodeKeyManagementStorage';
3
+ import { Kms } from '@credo-ts/core';
4
+ export declare class NodeKeyManagementService implements Kms.KeyManagementService {
5
+ #private;
6
+ readonly backend = "node";
7
+ constructor(storage: NodeKeyManagementStorage);
8
+ isOperationSupported(_agentContext: AgentContext, operation: Kms.KmsOperation): boolean;
9
+ randomBytes(_agentContext: AgentContext, options: Kms.KmsRandomBytesOptions): Kms.KmsRandomBytesReturn;
10
+ getPublicKey(agentContext: AgentContext, keyId: string): Promise<Kms.KmsJwkPublic | null>;
11
+ importKey<Jwk extends Kms.KmsJwkPrivate>(agentContext: AgentContext, options: Kms.KmsImportKeyOptions<Jwk>): Promise<Kms.KmsImportKeyReturn<Jwk>>;
12
+ deleteKey(agentContext: AgentContext, options: Kms.KmsDeleteKeyOptions): Promise<boolean>;
13
+ createKey<Type extends Kms.KmsCreateKeyType>(agentContext: AgentContext, options: Kms.KmsCreateKeyOptions<Type>): Promise<Kms.KmsCreateKeyReturn<Type>>;
14
+ sign(agentContext: AgentContext, options: Kms.KmsSignOptions): Promise<Kms.KmsSignReturn>;
15
+ verify(agentContext: AgentContext, options: Kms.KmsVerifyOptions): Promise<Kms.KmsVerifyReturn>;
16
+ encrypt(agentContext: AgentContext, options: Kms.KmsEncryptOptions): Promise<Kms.KmsEncryptReturn>;
17
+ decrypt(agentContext: AgentContext, options: Kms.KmsDecryptOptions): Promise<Kms.KmsDecryptReturn>;
18
+ private getKeyAsserted;
19
+ private assertKeyNotExists;
20
+ }
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _NodeKeyManagementService_storage;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.NodeKeyManagementService = void 0;
16
+ const node_crypto_1 = require("node:crypto");
17
+ const core_1 = require("@credo-ts/core");
18
+ const createKey_1 = require("./crypto/createKey");
19
+ const decrypt_1 = require("./crypto/decrypt");
20
+ const deriveKey_1 = require("./crypto/deriveKey");
21
+ const encrypt_1 = require("./crypto/encrypt");
22
+ const sign_1 = require("./crypto/sign");
23
+ const verify_1 = require("./crypto/verify");
24
+ class NodeKeyManagementService {
25
+ constructor(storage) {
26
+ this.backend = 'node';
27
+ _NodeKeyManagementService_storage.set(this, void 0);
28
+ __classPrivateFieldSet(this, _NodeKeyManagementService_storage, storage, "f");
29
+ }
30
+ isOperationSupported(_agentContext, operation) {
31
+ if (operation.operation === 'deleteKey')
32
+ return true;
33
+ if (operation.operation === 'randomBytes')
34
+ return true;
35
+ if (operation.operation === 'createKey') {
36
+ // TODO: probably clean to split the assert methods so we don't need try/catch here
37
+ try {
38
+ if (operation.type.kty === 'RSA') {
39
+ return true;
40
+ }
41
+ if (operation.type.kty === 'EC') {
42
+ (0, createKey_1.assertNodeSupportedEcCrv)(operation.type);
43
+ return true;
44
+ }
45
+ if (operation.type.kty === 'OKP') {
46
+ (0, createKey_1.assertNodeSupportedOkpCrv)(operation.type);
47
+ return true;
48
+ }
49
+ if (operation.type.kty === 'oct') {
50
+ (0, createKey_1.assertNodeSupportedOctAlgorithm)(operation.type);
51
+ return true;
52
+ }
53
+ }
54
+ catch {
55
+ return false;
56
+ }
57
+ return false;
58
+ }
59
+ if (operation.operation === 'importKey') {
60
+ try {
61
+ if (operation.privateJwk.kty === 'RSA' || operation.privateJwk.kty === 'oct') {
62
+ return true;
63
+ }
64
+ if (operation.privateJwk.kty === 'EC') {
65
+ (0, createKey_1.assertNodeSupportedEcCrv)({ kty: operation.privateJwk.kty, crv: operation.privateJwk.crv });
66
+ return true;
67
+ }
68
+ if (operation.privateJwk.kty === 'OKP') {
69
+ (0, createKey_1.assertNodeSupportedOkpCrv)({ kty: operation.privateJwk.kty, crv: operation.privateJwk.crv });
70
+ return true;
71
+ }
72
+ }
73
+ catch {
74
+ return false;
75
+ }
76
+ }
77
+ if (operation.operation === 'sign' || operation.operation === 'verify') {
78
+ return sign_1.nodeSupportedJwaAlgorithm.includes(operation.algorithm);
79
+ }
80
+ if (operation.operation === 'encrypt') {
81
+ const isSupportedEncryptionAlgorithm = encrypt_1.nodeSupportedEncryptionAlgorithms.includes(operation.encryption.algorithm);
82
+ if (!isSupportedEncryptionAlgorithm)
83
+ return false;
84
+ if (!operation.keyAgreement)
85
+ return true;
86
+ return deriveKey_1.nodeSupportedKeyAgreementAlgorithms.includes(operation.keyAgreement.algorithm);
87
+ }
88
+ if (operation.operation === 'decrypt') {
89
+ const isSupportedEncryptionAlgorithm = encrypt_1.nodeSupportedEncryptionAlgorithms.includes(operation.decryption.algorithm);
90
+ if (!isSupportedEncryptionAlgorithm)
91
+ return false;
92
+ if (!operation.keyAgreement)
93
+ return true;
94
+ return deriveKey_1.nodeSupportedKeyAgreementAlgorithms.includes(operation.keyAgreement.algorithm);
95
+ }
96
+ return false;
97
+ }
98
+ randomBytes(_agentContext, options) {
99
+ return (0, node_crypto_1.randomBytes)(options.length);
100
+ }
101
+ async getPublicKey(agentContext, keyId) {
102
+ const privateJwk = await __classPrivateFieldGet(this, _NodeKeyManagementService_storage, "f").get(agentContext, keyId);
103
+ if (!privateJwk)
104
+ return null;
105
+ return core_1.Kms.publicJwkFromPrivateJwk(privateJwk);
106
+ }
107
+ async importKey(agentContext, options) {
108
+ const { kid } = options.privateJwk;
109
+ if (kid)
110
+ await this.assertKeyNotExists(agentContext, kid);
111
+ const privateJwk = {
112
+ ...options.privateJwk,
113
+ kid: kid ?? (0, node_crypto_1.randomUUID)(),
114
+ };
115
+ try {
116
+ if (privateJwk.kty === 'oct') {
117
+ // Just check if we can create a secret key instance
118
+ (0, node_crypto_1.createSecretKey)(core_1.TypedArrayEncoder.fromBase64(privateJwk.k)).export({ format: 'jwk' });
119
+ }
120
+ else if (privateJwk.kty === 'EC') {
121
+ (0, createKey_1.assertNodeSupportedEcCrv)({ kty: privateJwk.kty, crv: privateJwk.crv });
122
+ // This validates the JWK
123
+ (0, node_crypto_1.createPrivateKey)({
124
+ format: 'jwk',
125
+ key: privateJwk,
126
+ });
127
+ }
128
+ else if (privateJwk.kty === 'OKP') {
129
+ (0, createKey_1.assertNodeSupportedOkpCrv)({ kty: privateJwk.kty, crv: privateJwk.crv });
130
+ // This validates the JWK
131
+ (0, node_crypto_1.createPrivateKey)({
132
+ format: 'jwk',
133
+ key: privateJwk,
134
+ });
135
+ }
136
+ else if (privateJwk.kty === 'RSA') {
137
+ // This validates the JWK
138
+ (0, node_crypto_1.createPrivateKey)({
139
+ format: 'jwk',
140
+ key: privateJwk,
141
+ });
142
+ }
143
+ else {
144
+ // All kty values supported for now, but can change in the future
145
+ // @ts-expect-error
146
+ throw new core_1.Kms.KeyManagementAlgorithmNotSupportedError(`kty '${privateJwk.kty}'`, this.backend);
147
+ }
148
+ await __classPrivateFieldGet(this, _NodeKeyManagementService_storage, "f").set(agentContext, privateJwk.kid, privateJwk);
149
+ const publicJwk = core_1.Kms.publicJwkFromPrivateJwk(privateJwk);
150
+ return {
151
+ keyId: privateJwk.kid,
152
+ publicJwk: {
153
+ ...publicJwk,
154
+ kid: privateJwk.kid,
155
+ },
156
+ };
157
+ }
158
+ catch (error) {
159
+ if (error instanceof core_1.Kms.KeyManagementError)
160
+ throw error;
161
+ throw new core_1.Kms.KeyManagementError('Error importing key', { cause: error });
162
+ }
163
+ }
164
+ async deleteKey(agentContext, options) {
165
+ return await __classPrivateFieldGet(this, _NodeKeyManagementService_storage, "f").delete(agentContext, options.keyId);
166
+ }
167
+ async createKey(agentContext, options) {
168
+ const { type, keyId } = options;
169
+ if (keyId)
170
+ await this.assertKeyNotExists(agentContext, keyId);
171
+ try {
172
+ let jwks;
173
+ if (type.kty === 'EC') {
174
+ (0, createKey_1.assertNodeSupportedEcCrv)(type);
175
+ jwks = await (0, createKey_1.createEcKey)(type);
176
+ }
177
+ else if (type.kty === 'OKP') {
178
+ (0, createKey_1.assertNodeSupportedOkpCrv)(type);
179
+ jwks = await (0, createKey_1.createOkpKey)(type);
180
+ }
181
+ else if (type.kty === 'RSA') {
182
+ jwks = await (0, createKey_1.createRsaKey)(type);
183
+ }
184
+ else if (type.kty === 'oct') {
185
+ (0, createKey_1.assertNodeSupportedOctAlgorithm)(type);
186
+ jwks = await (0, createKey_1.createOctKey)(type);
187
+ }
188
+ else {
189
+ // @ts-expect-error
190
+ throw new core_1.Kms.KeyManagementAlgorithmNotSupportedError(`kty '${type.kty}'`, this.backend);
191
+ }
192
+ jwks.privateJwk.kid = keyId ?? (0, node_crypto_1.randomUUID)();
193
+ jwks.publicJwk.kid = jwks.privateJwk.kid;
194
+ await __classPrivateFieldGet(this, _NodeKeyManagementService_storage, "f").set(agentContext, jwks.privateJwk.kid, jwks.privateJwk);
195
+ return {
196
+ publicJwk: jwks.publicJwk,
197
+ keyId: jwks.publicJwk.kid,
198
+ };
199
+ }
200
+ catch (error) {
201
+ if (error instanceof core_1.Kms.KeyManagementError)
202
+ throw error;
203
+ throw new core_1.Kms.KeyManagementError('Error creating key', { cause: error });
204
+ }
205
+ }
206
+ async sign(agentContext, options) {
207
+ const { keyId, algorithm, data } = options;
208
+ // 1. Retrieve the key
209
+ const key = await this.getKeyAsserted(agentContext, keyId);
210
+ try {
211
+ // 2. Validate alg and use for key
212
+ core_1.Kms.assertAllowedSigningAlgForKey(key, algorithm);
213
+ core_1.Kms.assertKeyAllowsSign(key);
214
+ // 3. Perform the signing operation
215
+ const signature = await (0, sign_1.performSign)(key, algorithm, data);
216
+ return {
217
+ signature,
218
+ };
219
+ }
220
+ catch (error) {
221
+ if (error instanceof core_1.Kms.KeyManagementError)
222
+ throw error;
223
+ throw new core_1.Kms.KeyManagementError('Error signing with key', { cause: error });
224
+ }
225
+ }
226
+ async verify(agentContext, options) {
227
+ const { algorithm, data, signature } = options;
228
+ try {
229
+ let key;
230
+ if (options.key.keyId) {
231
+ key = await this.getKeyAsserted(agentContext, options.key.keyId);
232
+ }
233
+ else if (options.key.publicJwk?.kty === 'EC') {
234
+ (0, createKey_1.assertNodeSupportedEcCrv)(options.key.publicJwk);
235
+ key = options.key.publicJwk;
236
+ }
237
+ else if (options.key.publicJwk?.kty === 'OKP') {
238
+ (0, createKey_1.assertNodeSupportedOkpCrv)(options.key.publicJwk);
239
+ key = options.key.publicJwk;
240
+ }
241
+ else if (options.key.publicJwk?.kty === 'RSA') {
242
+ key = options.key.publicJwk;
243
+ }
244
+ else {
245
+ // @ts-expect-error
246
+ throw new core_1.Kms.KeyManagementAlgorithmNotSupportedError(`kty ${options.key.kty}`, this.backend);
247
+ }
248
+ // 2. Validate alg and use for key
249
+ core_1.Kms.assertAllowedSigningAlgForKey(key, algorithm);
250
+ core_1.Kms.assertKeyAllowsVerify(key);
251
+ // 3. Perform the verify operation
252
+ const verified = await (0, verify_1.performVerify)(key, algorithm, data, signature);
253
+ if (verified) {
254
+ return {
255
+ verified: true,
256
+ publicJwk: core_1.Kms.publicJwkFromPrivateJwk(key),
257
+ };
258
+ }
259
+ return {
260
+ verified: false,
261
+ };
262
+ }
263
+ catch (error) {
264
+ if (error instanceof core_1.Kms.KeyManagementError)
265
+ throw error;
266
+ throw new core_1.Kms.KeyManagementError('Error verifying with key', { cause: error });
267
+ }
268
+ }
269
+ async encrypt(agentContext, options) {
270
+ const { data, encryption, key } = options;
271
+ core_1.Kms.assertSupportedEncryptionAlgorithm(encryption, encrypt_1.nodeSupportedEncryptionAlgorithms, this.backend);
272
+ let encryptionKey;
273
+ let encryptedKey = undefined;
274
+ if (key.keyId) {
275
+ encryptionKey = await this.getKeyAsserted(agentContext, key.keyId);
276
+ }
277
+ else if (key.privateJwk) {
278
+ encryptionKey = key.privateJwk;
279
+ }
280
+ else if (key.keyAgreement) {
281
+ core_1.Kms.assertAllowedKeyDerivationAlgForKey(key.keyAgreement.externalPublicJwk, key.keyAgreement.algorithm);
282
+ core_1.Kms.assertKeyAllowsDerive(key.keyAgreement.externalPublicJwk);
283
+ core_1.Kms.assertSupportedKeyAgreementAlgorithm(key.keyAgreement, deriveKey_1.nodeSupportedKeyAgreementAlgorithms, this.backend);
284
+ const privateJwk = await this.getKeyAsserted(agentContext, key.keyAgreement.keyId);
285
+ core_1.Kms.assertJwkAsymmetric(privateJwk, key.keyAgreement.keyId);
286
+ core_1.Kms.assertAllowedKeyDerivationAlgForKey(privateJwk, key.keyAgreement.algorithm);
287
+ core_1.Kms.assertKeyAllowsDerive(privateJwk);
288
+ core_1.Kms.assertAsymmetricJwkKeyTypeMatches(privateJwk, key.keyAgreement.externalPublicJwk);
289
+ const { contentEncryptionKey, encryptedContentEncryptionKey } = await (0, deriveKey_1.deriveEncryptionKey)({
290
+ keyAgreement: key.keyAgreement,
291
+ encryption,
292
+ privateJwk,
293
+ });
294
+ encryptionKey = contentEncryptionKey;
295
+ encryptedKey = encryptedContentEncryptionKey;
296
+ }
297
+ else {
298
+ throw new core_1.Kms.KeyManagementError('Unexpected key parameter for encrypt');
299
+ }
300
+ if (encryptionKey.kty !== 'oct') {
301
+ throw new core_1.Kms.KeyManagementAlgorithmNotSupportedError(`kty '${encryptionKey.kty} for content encryption'`, this.backend);
302
+ }
303
+ try {
304
+ // 2. Validate alg and use for key
305
+ core_1.Kms.assertAllowedEncryptionAlgForKey(encryptionKey, encryption.algorithm);
306
+ core_1.Kms.assertKeyAllowsEncrypt(encryptionKey);
307
+ // 3. Perform the encryption operation
308
+ const encrypted = await (0, encrypt_1.performEncrypt)(encryptionKey, options.encryption, data);
309
+ return {
310
+ ...encrypted,
311
+ encryptedKey,
312
+ };
313
+ }
314
+ catch (error) {
315
+ if (error instanceof core_1.Kms.KeyManagementError)
316
+ throw error;
317
+ throw new core_1.Kms.KeyManagementError('Error encrypting', { cause: error });
318
+ }
319
+ }
320
+ async decrypt(agentContext, options) {
321
+ const { decryption, encrypted, key } = options;
322
+ core_1.Kms.assertSupportedEncryptionAlgorithm(decryption, encrypt_1.nodeSupportedEncryptionAlgorithms, this.backend);
323
+ let decryptionKey;
324
+ if (key.keyId) {
325
+ decryptionKey = await this.getKeyAsserted(agentContext, key.keyId);
326
+ }
327
+ else if (key.privateJwk) {
328
+ decryptionKey = key.privateJwk;
329
+ }
330
+ else if (key.keyAgreement) {
331
+ core_1.Kms.assertSupportedKeyAgreementAlgorithm(key.keyAgreement, deriveKey_1.nodeSupportedKeyAgreementAlgorithms, this.backend);
332
+ core_1.Kms.assertAllowedKeyDerivationAlgForKey(key.keyAgreement.externalPublicJwk, key.keyAgreement.algorithm);
333
+ core_1.Kms.assertKeyAllowsDerive(key.keyAgreement.externalPublicJwk);
334
+ const privateJwk = await this.getKeyAsserted(agentContext, key.keyAgreement.keyId);
335
+ core_1.Kms.assertJwkAsymmetric(privateJwk, key.keyAgreement.keyId);
336
+ core_1.Kms.assertAllowedKeyDerivationAlgForKey(privateJwk, key.keyAgreement.algorithm);
337
+ core_1.Kms.assertKeyAllowsDerive(privateJwk);
338
+ core_1.Kms.assertAsymmetricJwkKeyTypeMatches(privateJwk, key.keyAgreement.externalPublicJwk);
339
+ const { contentEncryptionKey } = await (0, deriveKey_1.deriveDecryptionKey)({
340
+ keyAgreement: key.keyAgreement,
341
+ decryption,
342
+ privateJwk,
343
+ });
344
+ decryptionKey = contentEncryptionKey;
345
+ }
346
+ else {
347
+ throw new core_1.Kms.KeyManagementError('Unexpected key parameter for decrypt');
348
+ }
349
+ if (decryptionKey.kty !== 'oct') {
350
+ throw new core_1.Kms.KeyManagementAlgorithmNotSupportedError(`kty '${decryptionKey.kty}' for content encryption`, this.backend);
351
+ }
352
+ try {
353
+ // 2. Validate alg and use for key
354
+ core_1.Kms.assertAllowedEncryptionAlgForKey(decryptionKey, decryption.algorithm);
355
+ core_1.Kms.assertKeyAllowsEncrypt(decryptionKey);
356
+ // 3. Perform the decryption operation
357
+ return await (0, decrypt_1.performDecrypt)(decryptionKey, decryption, encrypted);
358
+ }
359
+ catch (error) {
360
+ if (error instanceof core_1.Kms.KeyManagementError)
361
+ throw error;
362
+ throw new core_1.Kms.KeyManagementError('Error decrypting', { cause: error });
363
+ }
364
+ }
365
+ async getKeyAsserted(agentContext, keyId) {
366
+ const storageKey = await __classPrivateFieldGet(this, _NodeKeyManagementService_storage, "f").get(agentContext, keyId);
367
+ if (!storageKey) {
368
+ throw new core_1.Kms.KeyManagementKeyNotFoundError(keyId, this.backend);
369
+ }
370
+ return storageKey;
371
+ }
372
+ async assertKeyNotExists(agentContext, keyId) {
373
+ const storageKey = await __classPrivateFieldGet(this, _NodeKeyManagementService_storage, "f").get(agentContext, keyId);
374
+ if (storageKey) {
375
+ throw new core_1.Kms.KeyManagementKeyExistsError(keyId, this.backend);
376
+ }
377
+ }
378
+ }
379
+ exports.NodeKeyManagementService = NodeKeyManagementService;
380
+ _NodeKeyManagementService_storage = new WeakMap();
381
+ //# sourceMappingURL=NodeKeyManagementService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeKeyManagementService.js","sourceRoot":"","sources":["../../src/kms/NodeKeyManagementService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,6CAAwF;AACxF,yCAAuD;AAEvD,kDAQ2B;AAC3B,8CAAiD;AACjD,kDAAkH;AAClH,8CAAoF;AACpF,wCAAsE;AACtE,4CAA+C;AAE/C,MAAa,wBAAwB;IAKnC,YAAmB,OAAiC;QAJpC,YAAO,GAAG,MAAM,CAAA;QAEh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