@smartledger/keys 3.0.0 → 3.1.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.
- package/README.md +168 -515
- package/dist/cjs/browser.d.ts +16 -6
- package/dist/cjs/browser.d.ts.map +1 -1
- package/dist/cjs/browser.js +15 -10
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +19 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sdk.d.ts +83 -9
- package/dist/cjs/sdk.d.ts.map +1 -1
- package/dist/cjs/sdk.js +322 -87
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/cjs/types.d.ts +78 -3
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/browser.d.ts +16 -6
- package/dist/esm/browser.d.ts.map +1 -1
- package/dist/esm/browser.js +14 -10
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sdk.d.ts +83 -9
- package/dist/esm/sdk.d.ts.map +1 -1
- package/dist/esm/sdk.js +322 -87
- package/dist/esm/sdk.js.map +1 -1
- package/dist/esm/types.d.ts +78 -3
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/lumen-keys.js +1728 -1738
- package/dist/lumen-keys.min.js +4 -7
- package/dist/lumen-keys.min.js.map +4 -4
- package/package.json +11 -11
- package/dist/lumen-keys.js.map +0 -7
- package/dist/tsconfig.esm.tsbuildinfo +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/cjs/browser.d.ts
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Entry point of the browser <script> bundle (dist/lumen-keys(.min).js),
|
|
3
|
+
* which exposes `window.LumenKeys`.
|
|
4
|
+
*
|
|
5
|
+
* Bundlers and Node should import '@smartledger/keys' itself: the ESM build
|
|
6
|
+
* runs unchanged in browsers. This file exists for the script-tag build only.
|
|
4
7
|
*/
|
|
8
|
+
import { KeyRegistry } from '@smartledger/crypto';
|
|
5
9
|
import type { KeySDK } from './types.js';
|
|
6
10
|
export * from './types.js';
|
|
7
|
-
export { InMemoryKeyStorage } from '@smartledger/crypto';
|
|
11
|
+
export { InMemoryKeyStorage, KeyRegistry } from '@smartledger/crypto';
|
|
8
12
|
/**
|
|
9
|
-
* Creates a new KeySDK instance for browser usage
|
|
10
|
-
*
|
|
13
|
+
* Creates a new KeySDK instance for browser usage.
|
|
14
|
+
*
|
|
15
|
+
* Async for backward compatibility with earlier bundles; nothing is awaited
|
|
16
|
+
* (the cryptography is pure JavaScript, there is no WASM to initialise).
|
|
11
17
|
*
|
|
12
18
|
* All signature suites (ECDSA, ML-DSA-44, ML-DSA-65, ML-DSA-87) are
|
|
13
19
|
* auto-registered in globalRegistry when @smartledger/crypto loads.
|
|
20
|
+
*
|
|
21
|
+
* Keys live in memory only and are gone when the page unloads.
|
|
14
22
|
*/
|
|
15
|
-
export declare function createKeySDK(
|
|
23
|
+
export declare function createKeySDK(config?: {
|
|
24
|
+
keyRegistry?: KeyRegistry;
|
|
25
|
+
}): Promise<KeySDK>;
|
|
16
26
|
/**
|
|
17
27
|
* Browser-ready default export
|
|
18
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAEL,WAAW,EAEZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGzC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,MAAM,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAY1F;AAED;;GAEG;;;;AACH,wBAEE"}
|
package/dist/cjs/browser.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Entry point of the browser <script> bundle (dist/lumen-keys(.min).js),
|
|
4
|
+
* which exposes `window.LumenKeys`.
|
|
5
|
+
*
|
|
6
|
+
* Bundlers and Node should import '@smartledger/keys' itself: the ESM build
|
|
7
|
+
* runs unchanged in browsers. This file exists for the script-tag build only.
|
|
5
8
|
*/
|
|
6
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
10
|
if (k2 === undefined) k2 = k;
|
|
@@ -18,7 +21,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
22
|
};
|
|
20
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.InMemoryKeyStorage = void 0;
|
|
24
|
+
exports.KeyRegistry = exports.InMemoryKeyStorage = void 0;
|
|
22
25
|
exports.createKeySDK = createKeySDK;
|
|
23
26
|
const sdk_js_1 = require("./sdk.js");
|
|
24
27
|
const crypto_1 = require("@smartledger/crypto");
|
|
@@ -26,24 +29,26 @@ const crypto_1 = require("@smartledger/crypto");
|
|
|
26
29
|
__exportStar(require("./types.js"), exports);
|
|
27
30
|
var crypto_2 = require("@smartledger/crypto");
|
|
28
31
|
Object.defineProperty(exports, "InMemoryKeyStorage", { enumerable: true, get: function () { return crypto_2.InMemoryKeyStorage; } });
|
|
32
|
+
Object.defineProperty(exports, "KeyRegistry", { enumerable: true, get: function () { return crypto_2.KeyRegistry; } });
|
|
29
33
|
/**
|
|
30
|
-
* Creates a new KeySDK instance for browser usage
|
|
31
|
-
*
|
|
34
|
+
* Creates a new KeySDK instance for browser usage.
|
|
35
|
+
*
|
|
36
|
+
* Async for backward compatibility with earlier bundles; nothing is awaited
|
|
37
|
+
* (the cryptography is pure JavaScript, there is no WASM to initialise).
|
|
32
38
|
*
|
|
33
39
|
* All signature suites (ECDSA, ML-DSA-44, ML-DSA-65, ML-DSA-87) are
|
|
34
40
|
* auto-registered in globalRegistry when @smartledger/crypto loads.
|
|
41
|
+
*
|
|
42
|
+
* Keys live in memory only and are gone when the page unloads.
|
|
35
43
|
*/
|
|
36
|
-
async function createKeySDK() {
|
|
37
|
-
const
|
|
38
|
-
const keyRegistry = new crypto_1.KeyRegistry(storage);
|
|
44
|
+
async function createKeySDK(config) {
|
|
45
|
+
const keyRegistry = config?.keyRegistry ?? new crypto_1.KeyRegistry(new crypto_1.InMemoryKeyStorage());
|
|
39
46
|
// Use the global registry with auto-registered suites
|
|
40
47
|
// (BsvEcdsaSuite, MlDsa44Suite, MlDsa65Suite, MlDsa87Suite)
|
|
41
48
|
const sdk = new sdk_js_1.DefaultKeySDK({
|
|
42
49
|
keyRegistry,
|
|
43
50
|
suiteRegistry: crypto_1.globalRegistry,
|
|
44
51
|
});
|
|
45
|
-
// Pre-initialize WASM for ML-DSA if needed
|
|
46
|
-
// The dilithium-crystals library will lazy-load WASM on first use
|
|
47
52
|
return sdk;
|
|
48
53
|
}
|
|
49
54
|
/**
|
package/dist/cjs/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;AAyBH,oCAYC;AAnCD,qCAAyC;AACzC,gDAI6B;AAG7B,wCAAwC;AACxC,6CAA2B;AAC3B,8CAAsE;AAA7D,4GAAA,kBAAkB,OAAA;AAAE,qGAAA,WAAW,OAAA;AAExC;;;;;;;;;;GAUG;AACI,KAAK,UAAU,YAAY,CAAC,MAAsC;IACvE,MAAM,WAAW,GAAG,MAAM,EAAE,WAAW,IAAI,IAAI,oBAAW,CAAC,IAAI,2BAAkB,EAAE,CAAC,CAAC;IAErF,sDAAsD;IACtD,4DAA4D;IAC5D,MAAM,GAAG,GAAG,IAAI,sBAAa,CAAC;QAC5B,WAAW;QACX,aAAa,EAAE,uBAAc;KAC9B,CAAC,CAAC;IAGH,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,kBAAe;IACb,YAAY;CACb,CAAC;AAEF,8BAA8B;AAC9B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IACjC,MAAc,CAAC,SAAS,GAAG;QAC1B,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Entry point of the browser <script> bundle (dist/lumen-keys(.min).js),\n * which exposes `window.LumenKeys`.\n *\n * Bundlers and Node should import '@smartledger/keys' itself: the ESM build\n * runs unchanged in browsers. This file exists for the script-tag build only.\n */\n\nimport { DefaultKeySDK } from './sdk.js';\nimport { \n InMemoryKeyStorage, \n KeyRegistry,\n globalRegistry,\n} from '@smartledger/crypto';\nimport type { KeySDK } from './types.js';\n\n// Re-export all types for browser usage\nexport * from './types.js';\nexport { InMemoryKeyStorage, KeyRegistry } from '@smartledger/crypto';\n\n/**\n * Creates a new KeySDK instance for browser usage.\n *\n * Async for backward compatibility with earlier bundles; nothing is awaited\n * (the cryptography is pure JavaScript, there is no WASM to initialise).\n * \n * All signature suites (ECDSA, ML-DSA-44, ML-DSA-65, ML-DSA-87) are\n * auto-registered in globalRegistry when @smartledger/crypto loads.\n *\n * Keys live in memory only and are gone when the page unloads.\n */\nexport async function createKeySDK(config?: { keyRegistry?: KeyRegistry }): Promise<KeySDK> {\n const keyRegistry = config?.keyRegistry ?? new KeyRegistry(new InMemoryKeyStorage());\n \n // Use the global registry with auto-registered suites\n // (BsvEcdsaSuite, MlDsa44Suite, MlDsa65Suite, MlDsa87Suite)\n const sdk = new DefaultKeySDK({\n keyRegistry,\n suiteRegistry: globalRegistry,\n });\n \n \n return sdk;\n}\n\n/**\n * Browser-ready default export\n */\nexport default {\n createKeySDK,\n};\n\n// Global export for CDN usage\nif (typeof window !== 'undefined') {\n (window as any).LumenKeys = {\n createKeySDK,\n };\n}\n"]}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -7,4 +7,7 @@ export * from './types.js';
|
|
|
7
7
|
export * from './sdk.js';
|
|
8
8
|
export type { KeyMeta, CryptoProfile } from '@smartledger/crypto';
|
|
9
9
|
export { BIP32Derivation } from '@smartledger/crypto';
|
|
10
|
+
export { SignatureSuiteRegistry, BsvEcdsaSuite, MlDsa44Suite, MlDsa65Suite, MlDsa87Suite, } from '@smartledger/crypto';
|
|
11
|
+
export { KeyRegistry, InMemoryKeyStorage, isKeyUsable, assertKeyUsable, KeyAlreadyExistsError, KeyExpiredError, KeyInvalidStateError, } from '@smartledger/crypto';
|
|
12
|
+
export type { KeyStorage } from '@smartledger/crypto';
|
|
10
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AAGzB,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AAGzB,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKtD,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -19,9 +19,27 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
19
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.BIP32Derivation = void 0;
|
|
22
|
+
exports.KeyInvalidStateError = exports.KeyExpiredError = exports.KeyAlreadyExistsError = exports.assertKeyUsable = exports.isKeyUsable = exports.InMemoryKeyStorage = exports.KeyRegistry = exports.MlDsa87Suite = exports.MlDsa65Suite = exports.MlDsa44Suite = exports.BsvEcdsaSuite = exports.SignatureSuiteRegistry = exports.BIP32Derivation = void 0;
|
|
23
23
|
__exportStar(require("./types.js"), exports);
|
|
24
24
|
__exportStar(require("./sdk.js"), exports);
|
|
25
25
|
var crypto_1 = require("@smartledger/crypto");
|
|
26
26
|
Object.defineProperty(exports, "BIP32Derivation", { enumerable: true, get: function () { return crypto_1.BIP32Derivation; } });
|
|
27
|
+
// Re-exported so callers can build or extend a suite registry without taking
|
|
28
|
+
// a direct dependency on @smartledger/crypto -- doing so pulls in a second
|
|
29
|
+
// copy of the library and splits the registry.
|
|
30
|
+
var crypto_2 = require("@smartledger/crypto");
|
|
31
|
+
Object.defineProperty(exports, "SignatureSuiteRegistry", { enumerable: true, get: function () { return crypto_2.SignatureSuiteRegistry; } });
|
|
32
|
+
Object.defineProperty(exports, "BsvEcdsaSuite", { enumerable: true, get: function () { return crypto_2.BsvEcdsaSuite; } });
|
|
33
|
+
Object.defineProperty(exports, "MlDsa44Suite", { enumerable: true, get: function () { return crypto_2.MlDsa44Suite; } });
|
|
34
|
+
Object.defineProperty(exports, "MlDsa65Suite", { enumerable: true, get: function () { return crypto_2.MlDsa65Suite; } });
|
|
35
|
+
Object.defineProperty(exports, "MlDsa87Suite", { enumerable: true, get: function () { return crypto_2.MlDsa87Suite; } });
|
|
36
|
+
// Key-state helpers and the errors callers are expected to catch.
|
|
37
|
+
var crypto_3 = require("@smartledger/crypto");
|
|
38
|
+
Object.defineProperty(exports, "KeyRegistry", { enumerable: true, get: function () { return crypto_3.KeyRegistry; } });
|
|
39
|
+
Object.defineProperty(exports, "InMemoryKeyStorage", { enumerable: true, get: function () { return crypto_3.InMemoryKeyStorage; } });
|
|
40
|
+
Object.defineProperty(exports, "isKeyUsable", { enumerable: true, get: function () { return crypto_3.isKeyUsable; } });
|
|
41
|
+
Object.defineProperty(exports, "assertKeyUsable", { enumerable: true, get: function () { return crypto_3.assertKeyUsable; } });
|
|
42
|
+
Object.defineProperty(exports, "KeyAlreadyExistsError", { enumerable: true, get: function () { return crypto_3.KeyAlreadyExistsError; } });
|
|
43
|
+
Object.defineProperty(exports, "KeyExpiredError", { enumerable: true, get: function () { return crypto_3.KeyExpiredError; } });
|
|
44
|
+
Object.defineProperty(exports, "KeyInvalidStateError", { enumerable: true, get: function () { return crypto_3.KeyInvalidStateError; } });
|
|
27
45
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,2CAAyB;AAIzB,8CAAsD;AAA7C,yGAAA,eAAe,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,2CAAyB;AAIzB,8CAAsD;AAA7C,yGAAA,eAAe,OAAA;AAExB,6EAA6E;AAC7E,2EAA2E;AAC3E,+CAA+C;AAC/C,8CAM6B;AAL3B,gHAAA,sBAAsB,OAAA;AACtB,uGAAA,aAAa,OAAA;AACb,sGAAA,YAAY,OAAA;AACZ,sGAAA,YAAY,OAAA;AACZ,sGAAA,YAAY,OAAA;AAGd,kEAAkE;AAClE,8CAQ6B;AAP3B,qGAAA,WAAW,OAAA;AACX,4GAAA,kBAAkB,OAAA;AAClB,qGAAA,WAAW,OAAA;AACX,yGAAA,eAAe,OAAA;AACf,+GAAA,qBAAqB,OAAA;AACrB,yGAAA,eAAe,OAAA;AACf,8GAAA,oBAAoB,OAAA","sourcesContent":["/**\n * @smartledger/keys - Key Management SDK\n * \n * Single source of truth for cryptographic key operations.\n */\n\nexport * from './types.js';\nexport * from './sdk.js';\n\n// Re-export commonly used types and utilities from @smartledger/crypto\nexport type { KeyMeta, CryptoProfile } from '@smartledger/crypto';\nexport { BIP32Derivation } from '@smartledger/crypto';\n\n// Re-exported so callers can build or extend a suite registry without taking\n// a direct dependency on @smartledger/crypto -- doing so pulls in a second\n// copy of the library and splits the registry.\nexport {\n SignatureSuiteRegistry,\n BsvEcdsaSuite,\n MlDsa44Suite,\n MlDsa65Suite,\n MlDsa87Suite,\n} from '@smartledger/crypto';\n\n// Key-state helpers and the errors callers are expected to catch.\nexport {\n KeyRegistry,\n InMemoryKeyStorage,\n isKeyUsable,\n assertKeyUsable,\n KeyAlreadyExistsError,\n KeyExpiredError,\n KeyInvalidStateError,\n} from '@smartledger/crypto';\nexport type { KeyStorage } from '@smartledger/crypto';\n"]}
|
package/dist/cjs/sdk.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Integrates KeyRegistry and SignatureSuiteRegistry to provide
|
|
5
5
|
* a clean, high-level API for key operations.
|
|
6
6
|
*/
|
|
7
|
-
import { KeyRegistry, SignatureSuiteRegistry, CryptoProfile } from '@smartledger/crypto';
|
|
8
|
-
import { KeySDK, KeyRecord, CreateKeyOptions, MultiSignatureResult, MultiVerificationResult, SuiteSignature } from './types.js';
|
|
7
|
+
import { KeyRegistry, SignatureSuiteRegistry, CryptoProfile, agentIdOfKey } from '@smartledger/crypto';
|
|
8
|
+
import { KeySDK, KeyRecord, CreateKeyOptions, MultiSignatureResult, MultiVerificationResult, SuiteSignature, VerifySignatureOptions, VerifyWithSuitesOptions, RotateAgentKeysOptions, WalletKeyPath } from './types.js';
|
|
9
9
|
/**
|
|
10
10
|
* Configuration for DefaultKeySDK.
|
|
11
11
|
*/
|
|
@@ -15,6 +15,7 @@ export interface KeySDKConfig {
|
|
|
15
15
|
/** Signature suite registry instance */
|
|
16
16
|
suiteRegistry: SignatureSuiteRegistry;
|
|
17
17
|
}
|
|
18
|
+
export { agentIdOfKey };
|
|
18
19
|
/**
|
|
19
20
|
* Default KeySDK implementation.
|
|
20
21
|
*
|
|
@@ -26,6 +27,7 @@ export declare class DefaultKeySDK implements KeySDK {
|
|
|
26
27
|
private keyCounter;
|
|
27
28
|
private counterInitialized;
|
|
28
29
|
private counterInitPromises;
|
|
30
|
+
private getOrCreateInFlight;
|
|
29
31
|
constructor(config: KeySDKConfig);
|
|
30
32
|
/**
|
|
31
33
|
* Create a new key for an agent.
|
|
@@ -37,12 +39,22 @@ export declare class DefaultKeySDK implements KeySDK {
|
|
|
37
39
|
getKey(keyId: string): Promise<KeyRecord | null>;
|
|
38
40
|
/**
|
|
39
41
|
* Sign with a key (private key never exposed).
|
|
42
|
+
*
|
|
43
|
+
* @throws if the key is unknown, not active, past its `expiresAt`, or not
|
|
44
|
+
* registered for signing
|
|
40
45
|
*/
|
|
41
46
|
signWithKey(keyId: string, message: Uint8Array): Promise<Uint8Array>;
|
|
42
47
|
/**
|
|
43
48
|
* Verify a signature.
|
|
49
|
+
*
|
|
50
|
+
* By default this is the cryptographic check only: a signature made by a
|
|
51
|
+
* key that has since been rotated, expired or revoked still verifies, which
|
|
52
|
+
* is what verifying a historical signature needs. Pass `keyStatus` to also
|
|
53
|
+
* require something of the key's state now.
|
|
44
54
|
*/
|
|
45
|
-
verifySignature(keyId: string, message: Uint8Array, signature: Uint8Array): Promise<boolean>;
|
|
55
|
+
verifySignature(keyId: string, message: Uint8Array, signature: Uint8Array, options?: VerifySignatureOptions): Promise<boolean>;
|
|
56
|
+
/** The cryptographic check alone. Anything but a strict `true` is a failure. */
|
|
57
|
+
private verifyAgainst;
|
|
46
58
|
/**
|
|
47
59
|
* List keys for an agent.
|
|
48
60
|
*/
|
|
@@ -53,10 +65,22 @@ export declare class DefaultKeySDK implements KeySDK {
|
|
|
53
65
|
getActiveCryptoProfile(agentId: string): Promise<CryptoProfile | null>;
|
|
54
66
|
/**
|
|
55
67
|
* Rotate all keys for an agent.
|
|
68
|
+
*
|
|
69
|
+
* Each replacement gets its predecessor's lifetime again, counted from now
|
|
70
|
+
* (or `options.expiresAt`); it does not inherit the old expiry instant.
|
|
71
|
+
*
|
|
72
|
+
* A key derived from a seed cannot be re-derived here, because the SDK does
|
|
73
|
+
* not keep seeds. By default the call refuses, before changing anything,
|
|
74
|
+
* rather than silently swapping a recoverable key for a random one. See
|
|
75
|
+
* {@link RotateAgentKeysOptions.derivedKeys}.
|
|
56
76
|
*/
|
|
57
|
-
rotateAgentKeys(agentId: string): Promise<KeyRecord[]>;
|
|
77
|
+
rotateAgentKeys(agentId: string, options?: RotateAgentKeysOptions): Promise<KeyRecord[]>;
|
|
58
78
|
/**
|
|
59
79
|
* Get or create key (idempotent).
|
|
80
|
+
*
|
|
81
|
+
* Concurrent calls on this SDK instance for the same agent and suite share
|
|
82
|
+
* one creation. Two SDK instances (or processes) on one storage backend can
|
|
83
|
+
* still each create a key; that needs a lock in the backend.
|
|
60
84
|
*/
|
|
61
85
|
getOrCreateKey(agentId: string, profile: CryptoProfile, options?: CreateKeyOptions): Promise<KeyRecord>;
|
|
62
86
|
/**
|
|
@@ -73,14 +97,33 @@ export declare class DefaultKeySDK implements KeySDK {
|
|
|
73
97
|
primaryKey: KeyRecord;
|
|
74
98
|
secondaryKey: KeyRecord;
|
|
75
99
|
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Fail before creating either key if the pair could not be a hybrid pair:
|
|
102
|
+
* an unknown suite, or the same suite twice (two ECDSA keys are not a
|
|
103
|
+
* classical + post-quantum pair, whatever the profile calls them).
|
|
104
|
+
*/
|
|
105
|
+
private assertDualProfile;
|
|
76
106
|
/**
|
|
77
107
|
* Sign with one or more suites for an agent.
|
|
78
108
|
*/
|
|
79
109
|
signWithSuites(agentId: string, message: Uint8Array, suites?: string[]): Promise<MultiSignatureResult>;
|
|
80
110
|
/**
|
|
81
|
-
* Verify
|
|
111
|
+
* Verify a set of signatures as a hybrid (multi-suite) signature by `agentId`.
|
|
112
|
+
*
|
|
113
|
+
* `allValid` is true only when ALL of these hold:
|
|
114
|
+
* - at least one signature was supplied;
|
|
115
|
+
* - every supplied signature is by a key that belongs to `agentId`, names
|
|
116
|
+
* that key's real suite, passes the key-status policy, and verifies;
|
|
117
|
+
* - every REQUIRED suite has such a signature.
|
|
118
|
+
*
|
|
119
|
+
* The required suites come from the verifier: `options.requiredSuites`, or
|
|
120
|
+
* by default the suites of the agent's currently usable keys in this SDK's
|
|
121
|
+
* registry. They are never read from `signatures`. The check walks the
|
|
122
|
+
* required suites and looks each one up among the valid signatures, so an
|
|
123
|
+
* empty list, or one that merely omits the post-quantum signature, is
|
|
124
|
+
* refused instead of passing because everything in it happens to be valid.
|
|
82
125
|
*/
|
|
83
|
-
verifyWithSuites(agentId: string, message: Uint8Array, signatures: SuiteSignature[]): Promise<MultiVerificationResult>;
|
|
126
|
+
verifyWithSuites(agentId: string, message: Uint8Array, signatures: SuiteSignature[], options?: VerifyWithSuitesOptions): Promise<MultiVerificationResult>;
|
|
84
127
|
/**
|
|
85
128
|
* Generate a new BIP39 mnemonic phrase.
|
|
86
129
|
*
|
|
@@ -95,11 +138,12 @@ export declare class DefaultKeySDK implements KeySDK {
|
|
|
95
138
|
*
|
|
96
139
|
* @param agentId Agent identifier
|
|
97
140
|
* @param profile Crypto profile (must use derivation-capable suite)
|
|
98
|
-
* @param mnemonic BIP39 mnemonic phrase
|
|
141
|
+
* @param mnemonic BIP39 mnemonic phrase (words and checksum are validated)
|
|
99
142
|
* @param path BIP32 derivation path (default: "m/44'/0'/0'/0/0")
|
|
100
143
|
* @param passphrase Optional BIP39 passphrase
|
|
101
144
|
* @param options Additional key creation options
|
|
102
145
|
* @returns KeyRecord with derived key
|
|
146
|
+
* @throws if the mnemonic has an unknown word, a wrong word count or a bad checksum
|
|
103
147
|
*/
|
|
104
148
|
createKeyFromMnemonic(agentId: string, profile: CryptoProfile, mnemonic: string, path?: string, passphrase?: string, options?: CreateKeyOptions): Promise<KeyRecord>;
|
|
105
149
|
/**
|
|
@@ -117,11 +161,31 @@ export declare class DefaultKeySDK implements KeySDK {
|
|
|
117
161
|
*/
|
|
118
162
|
getSuitesWithCapability(capability: 'derivation' | 'encryption' | 'threshold'): string[];
|
|
119
163
|
/**
|
|
120
|
-
* Create a
|
|
164
|
+
* Create a wallet key from a mnemonic at an explicit BIP44 coin type:
|
|
165
|
+
* `m/44'/coinType'/account'/change/index`.
|
|
121
166
|
*
|
|
122
|
-
*
|
|
167
|
+
* The coin type is required and has no default. It decides which wallets
|
|
168
|
+
* will find the key again: Bitcoin (BTC) is 0, Bitcoin SV is 236.
|
|
123
169
|
*
|
|
124
170
|
* @param agentId Agent identifier
|
|
171
|
+
* @param mnemonic BIP39 mnemonic phrase (words and checksum are validated)
|
|
172
|
+
* @param path Coin type and position in the BIP44 tree
|
|
173
|
+
* @param options Additional key creation options
|
|
174
|
+
* @returns KeyRecord with the derived secp256k1 key
|
|
175
|
+
*/
|
|
176
|
+
createWalletKey(agentId: string, mnemonic: string, path: WalletKeyPath, options?: CreateKeyOptions): Promise<KeyRecord>;
|
|
177
|
+
/**
|
|
178
|
+
* Create a wallet key from mnemonic at the Bitcoin (BTC) BIP44 path:
|
|
179
|
+
* m/44'/0'/account'/change/addressIndex
|
|
180
|
+
*
|
|
181
|
+
* NOTE: coin type 0 is BTC. A Bitcoin SV wallet restoring the same mnemonic
|
|
182
|
+
* looks under coin type 236 and will not find this key. The path is left
|
|
183
|
+
* as it is because changing it would move every key already created with
|
|
184
|
+
* this method. For new code use {@link createWalletKey}, which makes the
|
|
185
|
+
* coin type explicit.
|
|
186
|
+
*
|
|
187
|
+
* @deprecated Use createWalletKey(agentId, mnemonic, { coinType, ... }).
|
|
188
|
+
* @param agentId Agent identifier
|
|
125
189
|
* @param mnemonic BIP39 mnemonic phrase
|
|
126
190
|
* @param accountIndex Account index (default: 0)
|
|
127
191
|
* @param addressIndex Address index (default: 0)
|
|
@@ -134,6 +198,16 @@ export declare class DefaultKeySDK implements KeySDK {
|
|
|
134
198
|
* Helper: Get hash algorithm for a suite.
|
|
135
199
|
*/
|
|
136
200
|
private getHashAlgorithm;
|
|
201
|
+
/**
|
|
202
|
+
* Helper: register a key under the agent's next free key ID.
|
|
203
|
+
*
|
|
204
|
+
* The counter is cached per SDK instance, so another instance (or process)
|
|
205
|
+
* on the same storage can have taken the ID already. The registry refuses
|
|
206
|
+
* to overwrite; on that refusal the counter is re-read from storage and the
|
|
207
|
+
* next ID is tried. Before, the second writer silently replaced the first
|
|
208
|
+
* writer's private key.
|
|
209
|
+
*/
|
|
210
|
+
private registerUnderFreshId;
|
|
137
211
|
/**
|
|
138
212
|
* Helper: Get next counter for an agent.
|
|
139
213
|
*/
|
package/dist/cjs/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,WAAW,EACX,sBAAsB,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,WAAW,EACX,sBAAsB,EAGtB,aAAa,EAKb,YAAY,EAQb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,MAAM,EACN,SAAS,EACT,gBAAgB,EAEhB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EAGd,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,WAAW,EAAE,WAAW,CAAC;IAEzB,wCAAwC;IACxC,aAAa,EAAE,sBAAsB,CAAC;CACvC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC;AAuBxB;;;;GAIG;AACH,qBAAa,aAAc,YAAW,MAAM;IAC1C,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,aAAa,CAAyB;IAC9C,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,mBAAmB,CAAoC;IAC/D,OAAO,CAAC,mBAAmB,CAAyC;gBAExD,MAAM,EAAE,YAAY;IAKhC;;OAEG;IACG,SAAS,CACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,EACtB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,SAAS,CAAC;IA4CrB;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAUtD;;;;;OAKG;IACG,WAAW,CACf,KAAK,EAAE,MAAM,EACb,OA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