@smartledger/keys 1.0.1 → 1.2.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/dist/cjs/browser.d.ts +20 -0
- package/dist/cjs/browser.d.ts.map +1 -0
- package/dist/cjs/browser.js.map +1 -0
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/sdk.d.ts +69 -0
- package/dist/cjs/sdk.d.ts.map +1 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/cjs/types.d.ts +117 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/browser.d.ts +20 -0
- package/dist/esm/browser.d.ts.map +1 -0
- package/dist/esm/browser.js +41 -0
- package/dist/esm/browser.js.map +1 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/sdk.d.ts +69 -0
- package/dist/esm/sdk.d.ts.map +1 -0
- package/dist/esm/sdk.js +186 -0
- package/dist/esm/sdk.js.map +1 -0
- package/dist/esm/types.d.ts +117 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +8 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/lumen-keys.js +1566 -2685
- package/dist/lumen-keys.js.map +4 -4
- package/dist/lumen-keys.min.js +2 -2
- package/dist/lumen-keys.min.js.map +4 -4
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +23 -7
- package/dist/browser.d.ts.map +0 -1
- package/dist/browser.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/sdk.d.ts.map +0 -1
- package/dist/sdk.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- /package/dist/{browser.js → cjs/browser.js} +0 -0
- /package/dist/{index.js → cjs/index.js} +0 -0
- /package/dist/{sdk.js → cjs/sdk.js} +0 -0
- /package/dist/{types.js → cjs/types.js} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @smartledger/keys - Key Management SDK
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for cryptographic key operations.
|
|
5
|
+
* Provides a clean API that hides complexity and ensures consistency.
|
|
6
|
+
*/
|
|
7
|
+
import { KeyMeta, CryptoProfile } from '@smartledger/crypto';
|
|
8
|
+
/**
|
|
9
|
+
* Public key record (safe to expose, no private key).
|
|
10
|
+
*/
|
|
11
|
+
export interface KeyRecord {
|
|
12
|
+
meta: KeyMeta;
|
|
13
|
+
publicKey: Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Key creation options.
|
|
17
|
+
*/
|
|
18
|
+
export interface CreateKeyOptions {
|
|
19
|
+
/** Optional expiration date (ISO 8601) */
|
|
20
|
+
expiresAt?: string;
|
|
21
|
+
/** Key usage (default: ['signing']) */
|
|
22
|
+
usage?: Array<'signing' | 'encryption' | 'both'>;
|
|
23
|
+
/** Crypto profile version (default: '1.0.0') */
|
|
24
|
+
cryptoProfileVersion?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Key SDK - Single interface for all key operations.
|
|
28
|
+
*
|
|
29
|
+
* Design principles:
|
|
30
|
+
* - Hide private keys from most callers
|
|
31
|
+
* - Single source of truth for suite selection
|
|
32
|
+
* - Crypto-agnostic API (suite is config, not code)
|
|
33
|
+
* - Easy to audit (all key operations go through this)
|
|
34
|
+
*/
|
|
35
|
+
export interface KeySDK {
|
|
36
|
+
/**
|
|
37
|
+
* Create a new key for an agent/module.
|
|
38
|
+
*
|
|
39
|
+
* @param agentId Agent identifier (e.g. 'agent-resonance')
|
|
40
|
+
* @param profile Crypto configuration (which suites to use)
|
|
41
|
+
* @param options Optional expiration, usage, etc.
|
|
42
|
+
* @returns KeyRecord with metadata and public key
|
|
43
|
+
*/
|
|
44
|
+
createKey(agentId: string, profile: CryptoProfile, options?: CreateKeyOptions): Promise<KeyRecord>;
|
|
45
|
+
/**
|
|
46
|
+
* Get an existing key by ID.
|
|
47
|
+
*
|
|
48
|
+
* @param keyId Key identifier
|
|
49
|
+
* @returns KeyRecord or null if not found
|
|
50
|
+
*/
|
|
51
|
+
getKey(keyId: string): Promise<KeyRecord | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Sign a message with a key.
|
|
54
|
+
*
|
|
55
|
+
* Private key never leaves the SDK.
|
|
56
|
+
*
|
|
57
|
+
* @param keyId Which key to sign with
|
|
58
|
+
* @param message Message to sign (will be hashed internally)
|
|
59
|
+
* @returns Signature bytes
|
|
60
|
+
*/
|
|
61
|
+
signWithKey(keyId: string, message: Uint8Array): Promise<Uint8Array>;
|
|
62
|
+
/**
|
|
63
|
+
* Verify a signature against a public key.
|
|
64
|
+
*
|
|
65
|
+
* @param keyId Which key to verify with
|
|
66
|
+
* @param message Original message
|
|
67
|
+
* @param signature Signature to verify
|
|
68
|
+
* @returns true if valid
|
|
69
|
+
*/
|
|
70
|
+
verifySignature(keyId: string, message: Uint8Array, signature: Uint8Array): Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* List all keys for an agent.
|
|
73
|
+
*
|
|
74
|
+
* @param agentId Agent identifier
|
|
75
|
+
* @param activeOnly If true, only return active keys (default: true)
|
|
76
|
+
* @returns Array of KeyRecords
|
|
77
|
+
*/
|
|
78
|
+
listKeysForAgent(agentId: string, activeOnly?: boolean): Promise<KeyRecord[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Get the active crypto profile for an agent.
|
|
81
|
+
*
|
|
82
|
+
* Looks up the most recent active keys and infers the profile.
|
|
83
|
+
*
|
|
84
|
+
* @param agentId Agent identifier
|
|
85
|
+
* @returns CryptoProfile or null if no keys found
|
|
86
|
+
*/
|
|
87
|
+
getActiveCryptoProfile(agentId: string): Promise<CryptoProfile | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Rotate an agent's keys.
|
|
90
|
+
*
|
|
91
|
+
* Generates new keypairs for all active keys, marks old ones as rotated.
|
|
92
|
+
*
|
|
93
|
+
* @param agentId Agent identifier
|
|
94
|
+
* @returns Array of new KeyRecords
|
|
95
|
+
*/
|
|
96
|
+
rotateAgentKeys(agentId: string): Promise<KeyRecord[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Create key if it doesn't exist, otherwise return existing.
|
|
99
|
+
*
|
|
100
|
+
* Idempotent key creation for agent setup.
|
|
101
|
+
*
|
|
102
|
+
* @param agentId Agent identifier
|
|
103
|
+
* @param profile Crypto configuration
|
|
104
|
+
* @param options Creation options
|
|
105
|
+
* @returns KeyRecord (new or existing)
|
|
106
|
+
*/
|
|
107
|
+
getOrCreateKey(agentId: string, profile: CryptoProfile, options?: CreateKeyOptions): Promise<KeyRecord>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Agent metadata with crypto configuration.
|
|
111
|
+
*/
|
|
112
|
+
export interface AgentKeyConfig {
|
|
113
|
+
agentId: string;
|
|
114
|
+
version: string;
|
|
115
|
+
cryptoProfile: CryptoProfile;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,UAAU,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,uCAAuC;IACvC,KAAK,CAAC,EAAE,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