@me2em/core 0.4.4-alpha.1 → 0.6.0-alpha.1

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 (92) hide show
  1. package/README.md +299 -766
  2. package/dist/attestation.d.ts +151 -0
  3. package/dist/attestation.d.ts.map +1 -0
  4. package/dist/attestation.js +279 -0
  5. package/dist/attestation.js.map +1 -0
  6. package/dist/canonical-name.d.ts +3 -0
  7. package/dist/canonical-name.d.ts.map +1 -0
  8. package/dist/canonical-name.js +12 -0
  9. package/dist/canonical-name.js.map +1 -0
  10. package/dist/crypto/derivation-paths.d.ts +41 -0
  11. package/dist/crypto/derivation-paths.d.ts.map +1 -0
  12. package/dist/crypto/derivation-paths.js +50 -0
  13. package/dist/crypto/derivation-paths.js.map +1 -0
  14. package/dist/crypto/ed25519.d.ts +52 -0
  15. package/dist/crypto/ed25519.d.ts.map +1 -0
  16. package/dist/crypto/ed25519.js +67 -0
  17. package/dist/crypto/ed25519.js.map +1 -0
  18. package/dist/crypto/hkdf.d.ts +13 -0
  19. package/dist/crypto/hkdf.d.ts.map +1 -0
  20. package/dist/crypto/hkdf.js +17 -0
  21. package/dist/crypto/hkdf.js.map +1 -0
  22. package/dist/crypto/index.d.ts +4 -0
  23. package/dist/crypto/index.d.ts.map +1 -0
  24. package/dist/crypto/index.js +5 -0
  25. package/dist/crypto/index.js.map +1 -0
  26. package/dist/crypto/init.d.ts +9 -0
  27. package/dist/crypto/init.d.ts.map +1 -0
  28. package/dist/crypto/init.js +17 -0
  29. package/dist/crypto/init.js.map +1 -0
  30. package/dist/handle.d.ts +206 -0
  31. package/dist/handle.d.ts.map +1 -0
  32. package/dist/handle.js +258 -0
  33. package/dist/handle.js.map +1 -0
  34. package/dist/identity.d.ts +123 -0
  35. package/dist/identity.d.ts.map +1 -0
  36. package/dist/identity.js +167 -0
  37. package/dist/identity.js.map +1 -0
  38. package/dist/index.d.ts +33 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +33 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/seed.d.ts +83 -0
  43. package/dist/seed.d.ts.map +1 -0
  44. package/dist/seed.js +117 -0
  45. package/dist/seed.js.map +1 -0
  46. package/dist/session.d.ts +231 -0
  47. package/dist/session.d.ts.map +1 -0
  48. package/dist/session.js +454 -0
  49. package/dist/session.js.map +1 -0
  50. package/dist/subhandle.d.ts +126 -0
  51. package/dist/subhandle.d.ts.map +1 -0
  52. package/dist/subhandle.js +158 -0
  53. package/dist/subhandle.js.map +1 -0
  54. package/dist/util.d.ts +9 -0
  55. package/dist/util.d.ts.map +1 -0
  56. package/dist/util.js +34 -0
  57. package/dist/util.js.map +1 -0
  58. package/package.json +36 -12
  59. package/src/attestation.ts +364 -0
  60. package/src/canonical-name.ts +12 -0
  61. package/src/crypto/derivation-paths.ts +56 -0
  62. package/src/crypto/ed25519.ts +86 -0
  63. package/{packages/core/src → src}/crypto/hkdf.ts +2 -0
  64. package/src/crypto/index.ts +4 -0
  65. package/{packages/core/src → src}/crypto/init.ts +1 -0
  66. package/src/handle.ts +320 -0
  67. package/src/identity.ts +218 -0
  68. package/{packages/core/src → src}/index.ts +5 -1
  69. package/{packages/core/src → src}/seed.ts +41 -54
  70. package/src/session.ts +660 -0
  71. package/src/subhandle.ts +230 -0
  72. package/src/util.ts +35 -0
  73. package/.github/workflows/ci.yml +0 -0
  74. package/CODE_OF_CONDUCT.md +0 -73
  75. package/CONTRIBUTING.md +0 -145
  76. package/GOVERNANCE.md +0 -132
  77. package/SECURITY.md +0 -70
  78. package/packages/core/README.md +0 -656
  79. package/packages/core/package.json +0 -44
  80. package/packages/core/src/crypto/ed25519.ts +0 -12
  81. package/packages/core/src/crypto/index.ts +0 -2
  82. package/packages/core/src/handle.ts +0 -130
  83. package/packages/core/src/identity.ts +0 -89
  84. package/packages/core/src/session.ts +0 -47
  85. package/packages/core/test/derivation.spec.ts +0 -117
  86. package/packages/core/tsconfig.json +0 -9
  87. package/pnpm-workspace.yaml +0 -2
  88. package/specs/core.md +0 -44
  89. package/specs/openapi/server-ref.yaml +0 -10
  90. package/specs/test-vectors.json +0 -13
  91. package/tsconfig.base.json +0 -20
  92. package/typedoc.json +0 -18
@@ -0,0 +1,123 @@
1
+ import { Handle, type HandleMetadata } from './handle.js';
2
+ import { SubHandle, type SubHandleMetadata } from './subhandle.js';
3
+ import { Attestation, type AttestationGrant } from './attestation.js';
4
+ /**
5
+ * Represents the root cryptographic identity derived from a seed phrase.
6
+ *
7
+ * An Identity is the foundation of the Me2em protocol. It allows for the
8
+ * hierarchical derivation of isolated {@link Handle}s and {@link SubHandle}s
9
+ * for different contexts (e.g., email, social, specific devices) from a
10
+ * single master seed, ensuring zero cross-contamination of cryptographic material.
11
+ *
12
+ * The Identity provides two derivation entry points:
13
+ * - {@link Identity.deriveHandle} — derives a top-level Handle.
14
+ * - {@link Identity.deriveSubHandle} — atomically derives a SubHandle by its
15
+ * full path (Handle name + SubHandle name). Used primarily for stateless
16
+ * session verification on the server side.
17
+ *
18
+ * @category Core Primitives
19
+ */
20
+ export declare class Identity {
21
+ private readonly privateKey;
22
+ private readonly publicKey;
23
+ private constructor();
24
+ /**
25
+ * Initializes a new Identity from a BIP39 mnemonic seed phrase or raw seed bytes.
26
+ *
27
+ * @param seed - A 32-byte raw Uint8Array seed, or a hex-encoded string of 32 bytes.
28
+ * @returns A Promise resolving to a new Identity instance.
29
+ * @throws {Error} If the provided seed is not exactly 32 bytes.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const seed = await get32ByteSeedFromMnemonic('abandon abandon ... art');
34
+ * const identity = await Identity.fromSeed(seed);
35
+ * ```
36
+ */
37
+ static fromSeed(seed: Uint8Array | string): Promise<Identity>;
38
+ /**
39
+ * Derives a new, cryptographically isolated {@link Handle} for a specific context.
40
+ *
41
+ * Each Handle is derived deterministically. The same name will always produce
42
+ * the same Handle from the same Identity, but different names produce
43
+ * completely unrelated keys.
44
+ *
45
+ * @param name - The context identifier (e.g., `'alice@example.com'`, `'station-001'`).
46
+ * @param metadata - Optional metadata to associate with this Handle.
47
+ * @returns A Promise resolving to the derived Handle.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const handle = await identity.deriveHandle('station-001', {
52
+ * displayName: 'Berlin Station #001'
53
+ * });
54
+ * ```
55
+ */
56
+ deriveHandle(name: string, metadata?: HandleMetadata): Promise<Handle>;
57
+ /**
58
+ * Atomically derives a {@link SubHandle} from this Identity by its full path.
59
+ *
60
+ * This method performs the equivalent of:
61
+ * ```ts
62
+ * const handle = await identity.deriveHandle(handleName);
63
+ * const sub = await handle.deriveSubHandle(subName);
64
+ * ```
65
+ * but in a single call, without exposing the intermediate Handle.
66
+ *
67
+ * It is the **recommended entry point for stateless session verification**,
68
+ * because the server only needs the Identity and the path from the token.
69
+ *
70
+ * The resulting SubHandle is cryptographically identical to the one produced
71
+ * by `Handle.deriveSubHandle(subName)` on the same Identity.
72
+ *
73
+ * @param handleName - The parent Handle name.
74
+ * @param subName - The SubHandle name.
75
+ * @param metadata - Optional SubHandle metadata with constraints.
76
+ * @returns A Promise resolving to the derived SubHandle with path `[handleName, subName]`.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * // Server-side stateless verification
81
+ * const sub = await identity.deriveSubHandle('station-001', 'connector-1');
82
+ * const publicKey = sub.getPublicKey();
83
+ * ```
84
+ */
85
+ deriveSubHandle(handleName: string, subName: string, metadata?: SubHandleMetadata): Promise<SubHandle>;
86
+ /**
87
+ * Issues an attestation binding a derived Handle key to its name
88
+ * and grant. The subject public key is always derived internally —
89
+ * it is impossible to attest a foreign key, and the resulting
90
+ * `subjectId` always matches the handle reconstructed via
91
+ * {@link Identity.deriveSubHandle}.
92
+ *
93
+ * @param grant - Constraints verifiers will enforce for this handle
94
+ * and (via `subNamePatterns`) for the SubHandles it may attest.
95
+ * @returns An attestation signed by the Identity root key. Store it
96
+ * with the Handle — it is a public artifact, not a secret.
97
+ * @throws {Error} If the name is not canonicalizable.
98
+ * @throws {AttestationError} If the grant is invalid.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const A = await identity.attestHandle('station-001', {
103
+ * audiences: ['ev-app.com'],
104
+ * scopes: ['charge:start', 'charge:stop', 'charge:status'],
105
+ * maxSessionTtl: 7200,
106
+ * subNamePatterns: ['connector-*', 'meter-*'],
107
+ * });
108
+ * ```
109
+ */
110
+ attestHandle(name: string, grant: AttestationGrant, opts?: {
111
+ ttlSeconds?: number;
112
+ expiresAt?: number;
113
+ jti?: string;
114
+ now?: number;
115
+ }): Promise<Attestation>;
116
+ /**
117
+ * Retrieves the public key of the root Identity.
118
+ *
119
+ * @returns A Uint8Array containing the 32-byte Ed25519 public key.
120
+ */
121
+ getPublicKey(): Uint8Array;
122
+ }
123
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAWtE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IAEvC,OAAO;IAKP;;;;;;;;;;;;OAYG;WACU,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAmBnE;;;;;;;;;;;;;;;;;OAiBG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAa5E;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,eAAe,CACnB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,SAAS,CAAC;IA8BrB;;;;;;;;;;;;;;;;;;;;;;;QAuBI;IACG,YAAY,CACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,gBAAgB,EACvB,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7E,OAAO,CAAC,WAAW,CAAC;IAYvB;;;;OAIG;IACH,YAAY,IAAI,UAAU;CAG3B"}
@@ -0,0 +1,167 @@
1
+ // identity.ts
2
+ import { ed } from './crypto/init.js';
3
+ import { hkdf } from '@noble/hashes/hkdf.js';
4
+ import { sha256 } from '@noble/hashes/sha2.js';
5
+ import { Handle } from './handle.js';
6
+ import { SubHandle } from './subhandle.js';
7
+ import { DERIVATION_PATHS } from './crypto/derivation-paths.js';
8
+ import { normalizeName } from './canonical-name.js';
9
+ import { Attestation } from './attestation.js';
10
+ function parseHexSeed(hex) {
11
+ if (!/^[0-9a-fA-F]{64}$/.test(hex)) {
12
+ throw new Error('Seed string must be 64 hex characters');
13
+ }
14
+ const out = new Uint8Array(32);
15
+ for (let i = 0; i < 32; i++)
16
+ out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
17
+ return out;
18
+ }
19
+ /**
20
+ * Represents the root cryptographic identity derived from a seed phrase.
21
+ *
22
+ * An Identity is the foundation of the Me2em protocol. It allows for the
23
+ * hierarchical derivation of isolated {@link Handle}s and {@link SubHandle}s
24
+ * for different contexts (e.g., email, social, specific devices) from a
25
+ * single master seed, ensuring zero cross-contamination of cryptographic material.
26
+ *
27
+ * The Identity provides two derivation entry points:
28
+ * - {@link Identity.deriveHandle} — derives a top-level Handle.
29
+ * - {@link Identity.deriveSubHandle} — atomically derives a SubHandle by its
30
+ * full path (Handle name + SubHandle name). Used primarily for stateless
31
+ * session verification on the server side.
32
+ *
33
+ * @category Core Primitives
34
+ */
35
+ export class Identity {
36
+ privateKey;
37
+ publicKey;
38
+ constructor(privateKey) {
39
+ this.privateKey = privateKey;
40
+ this.publicKey = ed.getPublicKey(privateKey);
41
+ }
42
+ /**
43
+ * Initializes a new Identity from a BIP39 mnemonic seed phrase or raw seed bytes.
44
+ *
45
+ * @param seed - A 32-byte raw Uint8Array seed, or a hex-encoded string of 32 bytes.
46
+ * @returns A Promise resolving to a new Identity instance.
47
+ * @throws {Error} If the provided seed is not exactly 32 bytes.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const seed = await get32ByteSeedFromMnemonic('abandon abandon ... art');
52
+ * const identity = await Identity.fromSeed(seed);
53
+ * ```
54
+ */
55
+ static async fromSeed(seed) {
56
+ const seedBytes = typeof seed === 'string'
57
+ ? parseHexSeed(seed)
58
+ : seed;
59
+ if (seedBytes.length !== 32) {
60
+ throw new Error('Invalid seed: must be 32 bytes');
61
+ }
62
+ const key = hkdf(sha256, seedBytes, new Uint8Array(0), new TextEncoder().encode(DERIVATION_PATHS.identity), 32);
63
+ return new Identity(key);
64
+ }
65
+ /**
66
+ * Derives a new, cryptographically isolated {@link Handle} for a specific context.
67
+ *
68
+ * Each Handle is derived deterministically. The same name will always produce
69
+ * the same Handle from the same Identity, but different names produce
70
+ * completely unrelated keys.
71
+ *
72
+ * @param name - The context identifier (e.g., `'alice@example.com'`, `'station-001'`).
73
+ * @param metadata - Optional metadata to associate with this Handle.
74
+ * @returns A Promise resolving to the derived Handle.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const handle = await identity.deriveHandle('station-001', {
79
+ * displayName: 'Berlin Station #001'
80
+ * });
81
+ * ```
82
+ */
83
+ async deriveHandle(name, metadata) {
84
+ name = normalizeName(name);
85
+ const info = new TextEncoder().encode(DERIVATION_PATHS.handle(name));
86
+ const handleKey = hkdf(sha256, this.privateKey, new Uint8Array(0), info, 32);
87
+ return new Handle(handleKey, name, metadata);
88
+ }
89
+ /**
90
+ * Atomically derives a {@link SubHandle} from this Identity by its full path.
91
+ *
92
+ * This method performs the equivalent of:
93
+ * ```ts
94
+ * const handle = await identity.deriveHandle(handleName);
95
+ * const sub = await handle.deriveSubHandle(subName);
96
+ * ```
97
+ * but in a single call, without exposing the intermediate Handle.
98
+ *
99
+ * It is the **recommended entry point for stateless session verification**,
100
+ * because the server only needs the Identity and the path from the token.
101
+ *
102
+ * The resulting SubHandle is cryptographically identical to the one produced
103
+ * by `Handle.deriveSubHandle(subName)` on the same Identity.
104
+ *
105
+ * @param handleName - The parent Handle name.
106
+ * @param subName - The SubHandle name.
107
+ * @param metadata - Optional SubHandle metadata with constraints.
108
+ * @returns A Promise resolving to the derived SubHandle with path `[handleName, subName]`.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * // Server-side stateless verification
113
+ * const sub = await identity.deriveSubHandle('station-001', 'connector-1');
114
+ * const publicKey = sub.getPublicKey();
115
+ * ```
116
+ */
117
+ async deriveSubHandle(handleName, subName, metadata) {
118
+ handleName = normalizeName(handleName);
119
+ const subNameNorm = normalizeName(subName);
120
+ // Step 1: derive the intermediate Handle key (never exposed)
121
+ const handleInfo = new TextEncoder().encode(DERIVATION_PATHS.handle(handleName));
122
+ const handleKey = hkdf(sha256, this.privateKey, new Uint8Array(0), handleInfo, 32);
123
+ // Step 2: derive the SubHandle key from the Handle key
124
+ const subInfo = new TextEncoder().encode(DERIVATION_PATHS.subhandle(handleName, subNameNorm));
125
+ const subKey = hkdf(sha256, handleKey, new Uint8Array(0), subInfo, 32);
126
+ const path = [handleName, subNameNorm];
127
+ return new SubHandle(subKey, subNameNorm, path, metadata);
128
+ }
129
+ /**
130
+ * Issues an attestation binding a derived Handle key to its name
131
+ * and grant. The subject public key is always derived internally —
132
+ * it is impossible to attest a foreign key, and the resulting
133
+ * `subjectId` always matches the handle reconstructed via
134
+ * {@link Identity.deriveSubHandle}.
135
+ *
136
+ * @param grant - Constraints verifiers will enforce for this handle
137
+ * and (via `subNamePatterns`) for the SubHandles it may attest.
138
+ * @returns An attestation signed by the Identity root key. Store it
139
+ * with the Handle — it is a public artifact, not a secret.
140
+ * @throws {Error} If the name is not canonicalizable.
141
+ * @throws {AttestationError} If the grant is invalid.
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * const A = await identity.attestHandle('station-001', {
146
+ * audiences: ['ev-app.com'],
147
+ * scopes: ['charge:start', 'charge:stop', 'charge:status'],
148
+ * maxSessionTtl: 7200,
149
+ * subNamePatterns: ['connector-*', 'meter-*'],
150
+ * });
151
+ * ```
152
+ */
153
+ async attestHandle(name, grant, opts) {
154
+ const normalized = normalizeName(name);
155
+ const handle = await this.deriveHandle(normalized);
156
+ return Attestation.issue(this.privateKey, handle.getPublicKey(), normalized, grant, opts ?? {});
157
+ }
158
+ /**
159
+ * Retrieves the public key of the root Identity.
160
+ *
161
+ * @returns A Uint8Array containing the 32-byte Ed25519 public key.
162
+ */
163
+ getPublicKey() {
164
+ return this.publicKey;
165
+ }
166
+ }
167
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAuB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,SAAS,EAA0B,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAkB,CAAC;AAEtE,SA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F,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QACvC,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;QAuBI;IACH,KAAK,CAAC,YAAY,CACjB,IAAY,EACZ,KAAuB,EACvB,IAA8E;QAE9E,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QACnD,OAAO,WAAW,CAAC,KAAK,CACtB,IAAI,CAAC,UAAU,EACf,MAAM,CAAC,YAAY,EAAE,EACrB,UAAU,EACV,KAAK,EACL,IAAI,IAAI,EAAE,CACX,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ export { Identity } from './identity.js';
2
+ export { Handle, type HandleMetadata } from './handle.js';
3
+ export { SubHandle, type SubHandleMetadata } from './subhandle.js';
4
+ export { Session, type SessionOptions, type SessionPayload, type RevocationChecker } from './session.js';
5
+ export { Attestation, AttestationError, ATTESTATION_TYPE, ATTESTATION_MAX_PAYLOAD, type AttestationGrant, type AttestationPayload, type AttestationErrorCode, type AttestationLevel } from './attestation.js';
6
+ export * as crypto from './crypto/index.js';
7
+ /**
8
+ * @module @me2em/core
9
+ * @packageDocumentation
10
+ *
11
+ * Core cryptographic primitives for the Me2em authorization protocol.
12
+ *
13
+ * This package provides the foundation for decentralized, multi-context
14
+ * identity management and secure, stateless authentication.
15
+ *
16
+ * ## Key Features
17
+ * - **Hierarchical Identities**: Derive multiple isolated {@link Handle}s from a single seed.
18
+ * - **SubHandle Leaf Nodes**: Hierarchical access control with MAX_DEPTH = 2.
19
+ * - **Stateless Auth**: Cryptographic proof without server-side session storage via {@link Session}.
20
+ * - **Zero-Knowledge Secrets**: Deterministic password derivation without storage.
21
+ * - **Revocation Support**: Optional {@link RevocationChecker} interface for session invalidation.
22
+ *
23
+ * @example Basic usage
24
+ * ```typescript
25
+ * import { Identity } from '@me2em/core';
26
+ *
27
+ * const identity = await Identity.fromSeed('your twelve word mnemonic phrase here...');
28
+ * const handle = await identity.deriveHandle('user@example.com');
29
+ * const signature = await handle.sign(new TextEncoder().encode('data'));
30
+ * ```
31
+ */
32
+ export { generateSeedPhrase, normalizeSeedPhrase, validateSeedPhrase, get32ByteSeedFromMnemonic, type SeedStrength } from './seed.js';
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC9M,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ export { Identity } from './identity.js';
2
+ export { Handle } from './handle.js';
3
+ export { SubHandle } from './subhandle.js';
4
+ export { Session } from './session.js';
5
+ export { Attestation, AttestationError, ATTESTATION_TYPE, ATTESTATION_MAX_PAYLOAD } from './attestation.js';
6
+ export * as crypto from './crypto/index.js';
7
+ /**
8
+ * @module @me2em/core
9
+ * @packageDocumentation
10
+ *
11
+ * Core cryptographic primitives for the Me2em authorization protocol.
12
+ *
13
+ * This package provides the foundation for decentralized, multi-context
14
+ * identity management and secure, stateless authentication.
15
+ *
16
+ * ## Key Features
17
+ * - **Hierarchical Identities**: Derive multiple isolated {@link Handle}s from a single seed.
18
+ * - **SubHandle Leaf Nodes**: Hierarchical access control with MAX_DEPTH = 2.
19
+ * - **Stateless Auth**: Cryptographic proof without server-side session storage via {@link Session}.
20
+ * - **Zero-Knowledge Secrets**: Deterministic password derivation without storage.
21
+ * - **Revocation Support**: Optional {@link RevocationChecker} interface for session invalidation.
22
+ *
23
+ * @example Basic usage
24
+ * ```typescript
25
+ * import { Identity } from '@me2em/core';
26
+ *
27
+ * const identity = await Identity.fromSeed('your twelve word mnemonic phrase here...');
28
+ * const handle = await identity.deriveHandle('user@example.com');
29
+ * const signature = await handle.sign(new TextEncoder().encode('data'));
30
+ * ```
31
+ */
32
+ export { generateSeedPhrase, normalizeSeedPhrase, validateSeedPhrase, get32ByteSeedFromMnemonic } from './seed.js';
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAuB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,SAAS,EAA0B,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAoE,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,uBAAuB,EAAoG,MAAM,kBAAkB,CAAC;AAC9M,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EAE1B,MAAM,WAAW,CAAC"}
package/dist/seed.d.ts ADDED
@@ -0,0 +1,83 @@
1
+ export type SeedStrength = 128 | 256;
2
+ /**
3
+ * Utilities for BIP39 mnemonic seed phrase generation and validation.
4
+ * These functions provide secure, deterministic seed phrase handling
5
+ * compatible with the BIP39 standard.
6
+ *
7
+ * @category Seed Utilities
8
+ * @packageDocumentation
9
+ */
10
+ /**
11
+ * Generates a cryptographically secure random mnemonic seed phrase.
12
+ *
13
+ * @param strength - The entropy strength in bits.
14
+ * - 128 bits = 12 words (standard security)
15
+ * - 160 bits = 15 words
16
+ * - 192 bits = 18 words
17
+ * - 224 bits = 21 words
18
+ * - 256 bits = 24 words (maximum security)
19
+ * @returns A space-separated mnemonic string split into an array of words.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const mnemonic12 = generateSeedPhrase(128);
24
+ * // ["abandon", "abandon", ..., "art"]
25
+ *
26
+ * const mnemonic24 = generateSeedPhrase(256);
27
+ * // ["abandon", "abandon", ..., "zoo"] (24 words)
28
+ * ```
29
+ */
30
+ export declare function generateSeedPhrase(strength?: SeedStrength): string[];
31
+ /**
32
+ * Normalizes a mnemonic seed phrase by trimming whitespace and converting to lowercase.
33
+ *
34
+ * @param seedPhrase - The mnemonic phrase to normalize (string or array of words).
35
+ * @returns A normalized array of lowercase words.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const normalized = normalizeSeedPhrase(' ABANDON abandon ART ');
40
+ * // ["abandon", "abandon", "art"]
41
+ * ```
42
+ */
43
+ export declare function normalizeSeedPhrase(seedPhrase: string | string[]): string[];
44
+ /**
45
+ * Validates a mnemonic seed phrase against the BIP39 standard.
46
+ *
47
+ * Checks:
48
+ * - Correct word count (12 or 24 words)
49
+ * - All words exist in the BIP39 wordlist
50
+ * - Valid checksum
51
+ *
52
+ * @param words - The mnemonic phrase to validate.
53
+ * @returns An object with `isValid` flag and optional `error` message.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const result = validateSeedPhrase(['abandon', 'abandon', ..., 'art']);
58
+ * if (!result.isValid) console.error(result.error);
59
+ * ```
60
+ */
61
+ export declare function validateSeedPhrase(words: string[]): {
62
+ isValid: boolean;
63
+ error?: string;
64
+ };
65
+ /**
66
+ * Derives a 32-byte cryptographic seed from a BIP39 mnemonic phrase using PBKDF2.
67
+ * This is the standard BIP39 derivation function that converts a human-readable
68
+ * mnemonic into a binary seed suitable for Ed25519 key generation.
69
+ *
70
+ * The resulting 64-byte BIP39 seed is hashed with SHA-256 to produce a
71
+ * deterministic 32-byte seed, as required by Ed25519.
72
+ *
73
+ * @param seedPhrase - The BIP39 mnemonic phrase (string or array of words).
74
+ * @returns A Promise resolving to a 32-byte Uint8Array seed.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const seed = await get32ByteSeedFromMnemonic('abandon abandon ... art');
79
+ * // Uint8Array(32) [123, 45, 67, ...]
80
+ * ```
81
+ */
82
+ export declare function get32ByteSeedFromMnemonic(seedPhrase: string | string[]): Promise<Uint8Array>;
83
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,CAAC;AAErC;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,GAAE,YAAkB,GAAG,MAAM,EAAE,CAMzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAK3E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAaxF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAC5B,OAAO,CAAC,UAAU,CAAC,CAUrB"}
package/dist/seed.js ADDED
@@ -0,0 +1,117 @@
1
+ // seed.ts
2
+ import { generateMnemonic, mnemonicToSeed, validateMnemonic } from '@scure/bip39';
3
+ import { wordlist } from '@scure/bip39/wordlists/english';
4
+ import { sha256 } from './crypto/hkdf.js';
5
+ /**
6
+ * Utilities for BIP39 mnemonic seed phrase generation and validation.
7
+ * These functions provide secure, deterministic seed phrase handling
8
+ * compatible with the BIP39 standard.
9
+ *
10
+ * @category Seed Utilities
11
+ * @packageDocumentation
12
+ */
13
+ /**
14
+ * Generates a cryptographically secure random mnemonic seed phrase.
15
+ *
16
+ * @param strength - The entropy strength in bits.
17
+ * - 128 bits = 12 words (standard security)
18
+ * - 160 bits = 15 words
19
+ * - 192 bits = 18 words
20
+ * - 224 bits = 21 words
21
+ * - 256 bits = 24 words (maximum security)
22
+ * @returns A space-separated mnemonic string split into an array of words.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const mnemonic12 = generateSeedPhrase(128);
27
+ * // ["abandon", "abandon", ..., "art"]
28
+ *
29
+ * const mnemonic24 = generateSeedPhrase(256);
30
+ * // ["abandon", "abandon", ..., "zoo"] (24 words)
31
+ * ```
32
+ */
33
+ export function generateSeedPhrase(strength = 128) {
34
+ if (strength !== 128 && strength !== 256) {
35
+ throw new Error('Seed strength must be 128 (12 words) or 256 (24 words)');
36
+ }
37
+ const mnemonic = generateMnemonic(wordlist, strength);
38
+ return mnemonic.split(' ');
39
+ }
40
+ /**
41
+ * Normalizes a mnemonic seed phrase by trimming whitespace and converting to lowercase.
42
+ *
43
+ * @param seedPhrase - The mnemonic phrase to normalize (string or array of words).
44
+ * @returns A normalized array of lowercase words.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const normalized = normalizeSeedPhrase(' ABANDON abandon ART ');
49
+ * // ["abandon", "abandon", "art"]
50
+ * ```
51
+ */
52
+ export function normalizeSeedPhrase(seedPhrase) {
53
+ const words = Array.isArray(seedPhrase)
54
+ ? seedPhrase
55
+ : seedPhrase.trim().split(/\s+/);
56
+ return words.map(word => word.toLowerCase().trim()).filter(word => word.length > 0);
57
+ }
58
+ /**
59
+ * Validates a mnemonic seed phrase against the BIP39 standard.
60
+ *
61
+ * Checks:
62
+ * - Correct word count (12 or 24 words)
63
+ * - All words exist in the BIP39 wordlist
64
+ * - Valid checksum
65
+ *
66
+ * @param words - The mnemonic phrase to validate.
67
+ * @returns An object with `isValid` flag and optional `error` message.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const result = validateSeedPhrase(['abandon', 'abandon', ..., 'art']);
72
+ * if (!result.isValid) console.error(result.error);
73
+ * ```
74
+ */
75
+ export function validateSeedPhrase(words) {
76
+ const wordCount = words.length;
77
+ if (wordCount !== 12 && wordCount !== 24) {
78
+ return { isValid: false, error: `Seed phrase must be 12 or 24 words, got ${wordCount}` };
79
+ }
80
+ const normalized = normalizeSeedPhrase(words);
81
+ for (const word of normalized) {
82
+ if (!wordlist.includes(word)) {
83
+ return { isValid: false, error: `Invalid word: ${word}` };
84
+ }
85
+ }
86
+ const isValid = validateMnemonic(normalized.join(' '), wordlist);
87
+ return { isValid, error: isValid ? undefined : 'Invalid seed phrase checksum' };
88
+ }
89
+ /**
90
+ * Derives a 32-byte cryptographic seed from a BIP39 mnemonic phrase using PBKDF2.
91
+ * This is the standard BIP39 derivation function that converts a human-readable
92
+ * mnemonic into a binary seed suitable for Ed25519 key generation.
93
+ *
94
+ * The resulting 64-byte BIP39 seed is hashed with SHA-256 to produce a
95
+ * deterministic 32-byte seed, as required by Ed25519.
96
+ *
97
+ * @param seedPhrase - The BIP39 mnemonic phrase (string or array of words).
98
+ * @returns A Promise resolving to a 32-byte Uint8Array seed.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const seed = await get32ByteSeedFromMnemonic('abandon abandon ... art');
103
+ * // Uint8Array(32) [123, 45, 67, ...]
104
+ * ```
105
+ */
106
+ export async function get32ByteSeedFromMnemonic(seedPhrase) {
107
+ const words = normalizeSeedPhrase(seedPhrase);
108
+ const validation = validateSeedPhrase(words);
109
+ if (!validation.isValid) {
110
+ throw new Error(`Invalid seed phrase: ${validation.error}`);
111
+ }
112
+ const mnemonic = words.join(' ');
113
+ const seed64 = await mnemonicToSeed(mnemonic);
114
+ // Hash the 64-byte seed to get a deterministic 32-byte seed for Ed25519
115
+ return sha256(seed64);
116
+ }
117
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.js","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAyB,GAAG;IAC7D,IAAI,QAAQ,KAAK,GAAG,IAAI,QAAQ,KAAK,GAAG,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACtD,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAA6B;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC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