@me2em/core 0.4.4-alpha.1 → 0.4.4-alpha.2
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 +159 -373
- package/dist/crypto/ed25519.d.ts +12 -0
- package/dist/crypto/ed25519.d.ts.map +1 -0
- package/dist/crypto/ed25519.js +12 -0
- package/dist/crypto/ed25519.js.map +1 -0
- package/dist/crypto/hkdf.d.ts +13 -0
- package/dist/crypto/hkdf.d.ts.map +1 -0
- package/dist/crypto/hkdf.js +16 -0
- package/dist/crypto/hkdf.js.map +1 -0
- package/dist/crypto/index.d.ts +3 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +3 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/crypto/init.d.ts +9 -0
- package/dist/crypto/init.d.ts.map +1 -0
- package/dist/crypto/init.js +16 -0
- package/dist/crypto/init.js.map +1 -0
- package/dist/handle.d.ts +87 -0
- package/dist/handle.d.ts.map +1 -0
- package/dist/handle.js +113 -0
- package/dist/handle.js.map +1 -0
- package/dist/identity.d.ts +43 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +71 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/seed.d.ts +96 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +127 -0
- package/dist/seed.js.map +1 -0
- package/dist/session.d.ts +41 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +37 -0
- package/dist/session.js.map +1 -0
- package/package.json +36 -12
- package/.github/workflows/ci.yml +0 -0
- package/CODE_OF_CONDUCT.md +0 -73
- package/CONTRIBUTING.md +0 -145
- package/GOVERNANCE.md +0 -132
- package/SECURITY.md +0 -70
- package/packages/core/README.md +0 -656
- package/packages/core/package.json +0 -44
- package/packages/core/test/derivation.spec.ts +0 -117
- package/packages/core/tsconfig.json +0 -9
- package/pnpm-workspace.yaml +0 -2
- package/specs/core.md +0 -44
- package/specs/openapi/server-ref.yaml +0 -10
- package/specs/test-vectors.json +0 -13
- package/tsconfig.base.json +0 -20
- package/typedoc.json +0 -18
- /package/{packages/core/src → src}/crypto/ed25519.ts +0 -0
- /package/{packages/core/src → src}/crypto/hkdf.ts +0 -0
- /package/{packages/core/src → src}/crypto/index.ts +0 -0
- /package/{packages/core/src → src}/crypto/init.ts +0 -0
- /package/{packages/core/src → src}/handle.ts +0 -0
- /package/{packages/core/src → src}/identity.ts +0 -0
- /package/{packages/core/src → src}/index.ts +0 -0
- /package/{packages/core/src → src}/seed.ts +0 -0
- /package/{packages/core/src → src}/session.ts +0 -0
package/dist/seed.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { generateMnemonic, mnemonicToSeed, validateMnemonic } from '@scure/bip39';
|
|
2
|
+
import { wordlist } from '@scure/bip39/wordlists/english';
|
|
3
|
+
import { sha256 } from './crypto/hkdf.js';
|
|
4
|
+
/**
|
|
5
|
+
* Utilities for BIP39 mnemonic seed phrase generation and validation.
|
|
6
|
+
*
|
|
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
|
+
*
|
|
23
|
+
* @returns A Promise resolving to a space-separated mnemonic string.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const mnemonic12 = await generateSeedPhrase(128);
|
|
28
|
+
* // "abandon abandon abandon ... art"
|
|
29
|
+
*
|
|
30
|
+
* const mnemonic24 = await generateSeedPhrase(256);
|
|
31
|
+
* // "abandon abandon abandon ... zoo" (24 words)
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function generateSeedPhrase(strength = 128) {
|
|
35
|
+
if (strength !== 128 && strength !== 256) {
|
|
36
|
+
throw new Error('Seed strength must be 128 (12 words) or 256 (24 words)');
|
|
37
|
+
}
|
|
38
|
+
const mnemonic = generateMnemonic(wordlist, strength);
|
|
39
|
+
return mnemonic.split(' ');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Normalizes a mnemonic seed phrase by trimming whitespace and converting to lowercase.
|
|
43
|
+
*
|
|
44
|
+
* @param phrase - The mnemonic phrase to normalize (string or array of words).
|
|
45
|
+
* @returns A normalized string of lowercase words separated by single spaces.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const normalized = normalizeSeedPhrase(' ABANDON abandon ART ');
|
|
50
|
+
* // "abandon abandon art"
|
|
51
|
+
*
|
|
52
|
+
* const normalized2 = normalizeSeedPhrase(['abandon', ' ART ', 'zoo']);
|
|
53
|
+
* // "abandon art zoo"
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export function normalizeSeedPhrase(seedPhrase) {
|
|
57
|
+
const words = Array.isArray(seedPhrase) ? seedPhrase : seedPhrase.trim().split(/\s+/);
|
|
58
|
+
return words.map(word => word.toLowerCase().trim()).filter(word => word.length > 0);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validates a mnemonic seed phrase against the BIP39 standard.
|
|
62
|
+
*
|
|
63
|
+
* Checks:
|
|
64
|
+
* - Correct word count (12, 15, 18, 21, or 24 words)
|
|
65
|
+
* - All words exist in the BIP39 wordlist
|
|
66
|
+
* - Valid checksum
|
|
67
|
+
*
|
|
68
|
+
* @param phrase - The mnemonic phrase to validate.
|
|
69
|
+
* @returns `true` if the phrase is valid, `false` otherwise.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const isValid = await validateSeedPhrase('abandon abandon ... art');
|
|
74
|
+
* // true
|
|
75
|
+
*
|
|
76
|
+
* const isInvalid = await validateSeedPhrase('invalid word list ...');
|
|
77
|
+
* // false
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export function validateSeedPhrase(words) {
|
|
81
|
+
const wordCount = words.length;
|
|
82
|
+
if (wordCount !== 12 && wordCount !== 24) {
|
|
83
|
+
return { isValid: false, error: `Seed phrase must be 12 or 24 words, got ${wordCount}` };
|
|
84
|
+
}
|
|
85
|
+
const normalized = normalizeSeedPhrase(words);
|
|
86
|
+
for (const word of normalized) {
|
|
87
|
+
if (!wordlist.includes(word)) {
|
|
88
|
+
return { isValid: false, error: `Invalid word: ${word}` };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const isValid = validateMnemonic(normalized.join(' '), wordlist);
|
|
92
|
+
return { isValid, error: isValid ? undefined : 'Invalid seed phrase checksum' };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Derives a 32-byte cryptographic seed from a BIP39 mnemonic phrase using PBKDF2.
|
|
96
|
+
*
|
|
97
|
+
* This is the standard BIP39 derivation function that converts a human-readable
|
|
98
|
+
* mnemonic into a binary seed suitable for key generation.
|
|
99
|
+
*
|
|
100
|
+
* @param phrase - The BIP39 mnemonic phrase (will be normalized automatically).
|
|
101
|
+
* @param passphrase - Optional passphrase for additional security (BIP39 "25th word").
|
|
102
|
+
* @returns A Promise resolving to a 32-byte Uint8Array seed.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const seed = await get32ByteSeedFromMnemonic('abandon abandon ... art');
|
|
107
|
+
* // Uint8Array(32) [123, 45, 67, ...]
|
|
108
|
+
*
|
|
109
|
+
* const seedWithPassphrase = await get32ByteSeedFromMnemonic(
|
|
110
|
+
* 'abandon abandon ... art',
|
|
111
|
+
* 'mySecretPassphrase'
|
|
112
|
+
* );
|
|
113
|
+
* // Different seed even with same mnemonic
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export async function get32ByteSeedFromMnemonic(seedPhrase) {
|
|
117
|
+
const words = normalizeSeedPhrase(seedPhrase);
|
|
118
|
+
const validation = validateSeedPhrase(words);
|
|
119
|
+
if (!validation.isValid) {
|
|
120
|
+
throw new Error(`Invalid seed phrase: ${validation.error}`);
|
|
121
|
+
}
|
|
122
|
+
const mnemonic = words.join(' ');
|
|
123
|
+
const seed64 = await mnemonicToSeed(mnemonic);
|
|
124
|
+
// Hash the 64-byte seed to get a deterministic 32-byte seed for Ed25519
|
|
125
|
+
return sha256(seed64);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=seed.js.map
|
package/dist/seed.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seed.js","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AAAA,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;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;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;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAA6B;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtF,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAe;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;IAC/B,IAAI,SAAS,KAAK,EAAE,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC;QACzC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,2CAA2C,SAAS,EAAE,EAAE,CAAC;IAC3F,CAAC;IAED,MAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,IAAI,EAAE,EAAE,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IACjE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,8BAA8B,EAAE,CAAC;AAClF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,UAA6B;IAC3E,MAAM,KAAK,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAE7C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,wBAAwB,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IAE9C,wEAAwE;IACxE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface SessionOptions {
|
|
2
|
+
audience: string;
|
|
3
|
+
scopes: string[];
|
|
4
|
+
ttl?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface SessionToken {
|
|
7
|
+
handleId: string;
|
|
8
|
+
scopes: string[];
|
|
9
|
+
expiresAt: number;
|
|
10
|
+
token: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents a stateless, cryptographically verifiable session token.
|
|
14
|
+
*
|
|
15
|
+
* Instead of storing session state on the server, the Session object
|
|
16
|
+
* encapsulates all necessary authorization data (handle ID, scopes, expiration)
|
|
17
|
+
* into a self-contained structure that can be verified using the Handle's public key.
|
|
18
|
+
*
|
|
19
|
+
* @category Core Primitives
|
|
20
|
+
*/
|
|
21
|
+
export declare class Session {
|
|
22
|
+
readonly handleId: string;
|
|
23
|
+
readonly scopes: string[];
|
|
24
|
+
readonly expiresAt: number;
|
|
25
|
+
readonly token: string;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new Session instance.
|
|
28
|
+
*
|
|
29
|
+
* @param handleId - The ID of the Handle that authorized this session.
|
|
30
|
+
* @param scopes - An array of permission scopes granted in this session (e.g., ['read', 'write']).
|
|
31
|
+
* @param expiresAt - Unix timestamp (in milliseconds) when this session expires.
|
|
32
|
+
* @param token - The cryptographic token string (e.g., JWT or custom signature format).
|
|
33
|
+
*/
|
|
34
|
+
constructor(handleId: string, scopes: string[], expiresAt: number, token: string);
|
|
35
|
+
/**
|
|
36
|
+
* Checks if the session has expired based on the current time.
|
|
37
|
+
* @returns `true` if the current time is past the `expiresAt` timestamp, `false` otherwise.
|
|
38
|
+
*/
|
|
39
|
+
isExpired(): boolean;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,qBAAa,OAAO;aAWA,QAAQ,EAAE,MAAM;aAChB,MAAM,EAAE,MAAM,EAAE;aAChB,SAAS,EAAE,MAAM;aACjB,KAAK,EAAE,MAAM;IAZ7B;;;;;;;KAOC;gBAEe,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM;IAG/B;;;OAGG;IACH,SAAS,IAAI,OAAO;CAGrB"}
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a stateless, cryptographically verifiable session token.
|
|
3
|
+
*
|
|
4
|
+
* Instead of storing session state on the server, the Session object
|
|
5
|
+
* encapsulates all necessary authorization data (handle ID, scopes, expiration)
|
|
6
|
+
* into a self-contained structure that can be verified using the Handle's public key.
|
|
7
|
+
*
|
|
8
|
+
* @category Core Primitives
|
|
9
|
+
*/
|
|
10
|
+
export class Session {
|
|
11
|
+
handleId;
|
|
12
|
+
scopes;
|
|
13
|
+
expiresAt;
|
|
14
|
+
token;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new Session instance.
|
|
17
|
+
*
|
|
18
|
+
* @param handleId - The ID of the Handle that authorized this session.
|
|
19
|
+
* @param scopes - An array of permission scopes granted in this session (e.g., ['read', 'write']).
|
|
20
|
+
* @param expiresAt - Unix timestamp (in milliseconds) when this session expires.
|
|
21
|
+
* @param token - The cryptographic token string (e.g., JWT or custom signature format).
|
|
22
|
+
*/
|
|
23
|
+
constructor(handleId, scopes, expiresAt, token) {
|
|
24
|
+
this.handleId = handleId;
|
|
25
|
+
this.scopes = scopes;
|
|
26
|
+
this.expiresAt = expiresAt;
|
|
27
|
+
this.token = token;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the session has expired based on the current time.
|
|
31
|
+
* @returns `true` if the current time is past the `expiresAt` timestamp, `false` otherwise.
|
|
32
|
+
*/
|
|
33
|
+
isExpired() {
|
|
34
|
+
return Date.now() >= this.expiresAt * 1000;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AACH,MAAM,OAAO,OAAO;IAWA;IACA;IACA;IACA;IAZhB;;;;;;;KAOC;IACH,YACkB,QAAgB,EAChB,MAAgB,EAChB,SAAiB,EACjB,KAAa;QAHb,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAU;QAChB,cAAS,GAAT,SAAS,CAAQ;QACjB,UAAK,GAAL,KAAK,CAAQ;IAC5B,CAAC;IAEJ;;;OAGG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC7C,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@me2em/core",
|
|
3
|
-
"version": "0.4.4-alpha.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"version": "0.4.4-alpha.2",
|
|
4
|
+
"description": "Core primitives for the Me2em authorization protocol: Identity, Handle, and Session",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@noble/ed25519": "^3.1.0",
|
|
27
|
+
"@noble/hashes": "^2.2.0",
|
|
28
|
+
"@scure/bip39": "^1.3.0"
|
|
8
29
|
},
|
|
9
30
|
"devDependencies": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
31
|
+
"@types/node": "^25.9.1",
|
|
32
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
33
|
+
"eslint": "^10.4.1",
|
|
34
|
+
"typescript": "^6.0.3",
|
|
35
|
+
"vitest": "^4.1.7"
|
|
12
36
|
},
|
|
13
37
|
"scripts": {
|
|
14
|
-
"build": "
|
|
15
|
-
"test": "
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
38
|
+
"build": "tsc -p tsconfig.json",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:coverage": "vitest run --coverage",
|
|
41
|
+
"lint": "eslint src",
|
|
42
|
+
"typecheck": "tsc --noEmit"
|
|
19
43
|
}
|
|
20
44
|
}
|
package/.github/workflows/ci.yml
DELETED
|
File without changes
|
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in the Me2em community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
|
6
|
-
|
|
7
|
-
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
-
|
|
9
|
-
## Our Standards
|
|
10
|
-
|
|
11
|
-
Examples of behavior that contributes to a positive environment:
|
|
12
|
-
|
|
13
|
-
✅ Using welcoming and inclusive language
|
|
14
|
-
✅ Being respectful of differing viewpoints and experiences
|
|
15
|
-
✅ Gracefully accepting constructive criticism
|
|
16
|
-
✅ Focusing on what is best for the community
|
|
17
|
-
✅ Showing empathy towards other community members
|
|
18
|
-
|
|
19
|
-
Examples of unacceptable behavior:
|
|
20
|
-
|
|
21
|
-
❌ The use of sexualized language or imagery, and sexual attention or advances
|
|
22
|
-
❌ Trolling, insulting or derogatory comments, and personal or political attacks
|
|
23
|
-
❌ Public or private harassment
|
|
24
|
-
❌ Publishing others' private information without explicit permission
|
|
25
|
-
❌ Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
26
|
-
|
|
27
|
-
## Enforcement Responsibilities
|
|
28
|
-
|
|
29
|
-
Community leaders (maintainers) are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
-
|
|
31
|
-
## Scope
|
|
32
|
-
|
|
33
|
-
This Code of Conduct applies within all community spaces (GitHub, discussions, chat), and also applies when an individual is officially representing the community in public spaces (conferences, social media).
|
|
34
|
-
|
|
35
|
-
## Enforcement
|
|
36
|
-
|
|
37
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at `hello@me2em.com`. All complaints will be reviewed and investigated promptly and fairly.
|
|
38
|
-
|
|
39
|
-
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
40
|
-
|
|
41
|
-
## Enforcement Guidelines
|
|
42
|
-
|
|
43
|
-
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
44
|
-
|
|
45
|
-
### 1. Correction
|
|
46
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional.
|
|
47
|
-
**Consequence**: Private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
48
|
-
|
|
49
|
-
### 2. Warning
|
|
50
|
-
**Community Impact**: A violation through a single incident or series of actions.
|
|
51
|
-
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. Violating these terms may lead to a temporary or permanent ban.
|
|
52
|
-
|
|
53
|
-
### 3. Temporary Ban
|
|
54
|
-
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
55
|
-
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period.
|
|
56
|
-
|
|
57
|
-
### 4. Permanent Ban
|
|
58
|
-
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
59
|
-
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
60
|
-
|
|
61
|
-
## Attribution
|
|
62
|
-
|
|
63
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
64
|
-
|
|
65
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
66
|
-
|
|
67
|
-
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
|
|
68
|
-
|
|
69
|
-
[homepage]: https://www.contributor-covenant.org
|
|
70
|
-
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
71
|
-
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
72
|
-
[FAQ]: https://www.contributor-covenant.org/faq
|
|
73
|
-
[translations]: https://www.contributor-covenant.org/translations
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
# Contributing to me2em-protocol
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing to Me2em! This document outlines how to contribute to the protocol reference implementation, our architecture, and release processes.
|
|
4
|
-
|
|
5
|
-
## 🗂️ Project Structure & Architecture
|
|
6
|
-
|
|
7
|
-
This repository is a `pnpm` workspace monorepo containing the core cryptographic primitives of the Me2em protocol.
|
|
8
|
-
|
|
9
|
-
> **Note:** The main marketing website, blog, and high-level guides are hosted in a **separate repository**: [`me2em-org/me2em-website`](https://github.com/me2em-org/me2em-website) (built with Astro). This repository is strictly for the protocol implementation and its API reference.
|
|
10
|
-
|
|
11
|
-
```text
|
|
12
|
-
me2em-protocol/
|
|
13
|
-
├── packages/
|
|
14
|
-
│ └── core/ # Core primitives: Identity, Handle, Session (@me2em/core)
|
|
15
|
-
├── docs/ # Generated TypeDoc output (auto-deployed, do not edit manually)
|
|
16
|
-
├── package.json # Root workspace configuration
|
|
17
|
-
├── typedoc.json # TypeDoc configuration for API reference generation
|
|
18
|
-
└── CONTRIBUTING.md # This file
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## 🚀 Getting Started
|
|
22
|
-
|
|
23
|
-
### Prerequisites
|
|
24
|
-
- Node.js 18+
|
|
25
|
-
- pnpm 9+ (We strictly use `pnpm`, not `npm` or `yarn`)
|
|
26
|
-
|
|
27
|
-
### Local Development Setup
|
|
28
|
-
```bash
|
|
29
|
-
# 1. Clone the repository
|
|
30
|
-
git clone https://github.com/me2em-org/me2em-protocol.git
|
|
31
|
-
cd me2em-protocol
|
|
32
|
-
|
|
33
|
-
# 2. Install dependencies for all workspace packages
|
|
34
|
-
pnpm install
|
|
35
|
-
|
|
36
|
-
# 3. Build the core package
|
|
37
|
-
pnpm run build
|
|
38
|
-
|
|
39
|
-
# 4. Run tests
|
|
40
|
-
pnpm run test
|
|
41
|
-
|
|
42
|
-
# 5. Generate documentation locally (optional, for preview)
|
|
43
|
-
pnpm run build-docs
|
|
44
|
-
# You can then view it by opening `docs/index.html` or running `npx serve docs`
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## 📦 Publishing to npm
|
|
48
|
-
|
|
49
|
-
Publishing is done manually to ensure strict version control. **Always use `pnpm`, never `npm`**, to maintain lockfile consistency.
|
|
50
|
-
|
|
51
|
-
1. **Authenticate with pnpm registry:**
|
|
52
|
-
Ensure you are logged in. If not, run:
|
|
53
|
-
```bash
|
|
54
|
-
pnpm login
|
|
55
|
-
```
|
|
56
|
-
2. **Update versions manually:** You must update the `"version"` field in **two** places to keep the workspace in sync:
|
|
57
|
-
- `package.json` (root)
|
|
58
|
-
- `packages/core/package.json`
|
|
59
|
-
3. **Commit the version bump:**
|
|
60
|
-
```bash
|
|
61
|
-
git add package.json packages/core/package.json
|
|
62
|
-
git commit -m "chore: bump version to X.Y.Z"
|
|
63
|
-
git push origin main
|
|
64
|
-
```
|
|
65
|
-
4. **Publish the package:**
|
|
66
|
-
Run the publish command specifically for the core package:
|
|
67
|
-
```bash
|
|
68
|
-
pnpm publish --filter @me2em/core --access public
|
|
69
|
-
```
|
|
70
|
-
*(Alternatively, from within the `packages/core` directory, you can run `pnpm publish --access public`)*
|
|
71
|
-
|
|
72
|
-
## 📝 Documentation Pipeline
|
|
73
|
-
|
|
74
|
-
We do not maintain a separate documentation repository or use heavy frameworks like Docusaurus for the API reference.
|
|
75
|
-
|
|
76
|
-
- **Source of Truth:** All API documentation is written as [JSDoc/TSDoc](https://tsdoc.org/) comments directly in the TypeScript source files (`packages/core/src/**/*.ts`).
|
|
77
|
-
- **Automation:** The root `package.json` contains a `"build-docs": "typedoc"` script.
|
|
78
|
-
- **Deployment:** This repository is connected to **Cloudflare Pages**. On every `git push` to the `main` branch, Cloudflare automatically runs `pnpm install && pnpm run build-docs` and deploys the resulting `./docs` folder to **[docs.me2em.com](https://docs.me2em.com)**.
|
|
79
|
-
|
|
80
|
-
**Rule for contributors:** If you add or modify public methods, classes, or interfaces, you **must** add or update the corresponding JSDoc comments.
|
|
81
|
-
|
|
82
|
-
## 🐛 Reporting Issues
|
|
83
|
-
|
|
84
|
-
Before creating a new issue:
|
|
85
|
-
1. Search [existing issues](https://github.com/me2em-org/me2em-protocol/issues).
|
|
86
|
-
2. Check if it's already fixed in the `main` branch.
|
|
87
|
-
3. Use the appropriate [issue template](.github/ISSUE_TEMPLATE/).
|
|
88
|
-
|
|
89
|
-
⚠️ **For security vulnerabilities:** See [SECURITY.md](SECURITY.md). Do not disclose publicly.
|
|
90
|
-
|
|
91
|
-
## 💡 Proposing Changes
|
|
92
|
-
|
|
93
|
-
**Small fixes (typos, docs, minor bug fixes):**
|
|
94
|
-
1. Fork the repository.
|
|
95
|
-
2. Create a branch: `fix/short-description`.
|
|
96
|
-
3. Make your changes and run `pnpm test`.
|
|
97
|
-
4. Submit a Pull Request.
|
|
98
|
-
|
|
99
|
-
**New features or breaking changes:**
|
|
100
|
-
1. Open a [Discussion](https://github.com/me2em-org/me2em-protocol/discussions) first.
|
|
101
|
-
2. Describe the problem, proposed solution, and alternatives.
|
|
102
|
-
3. Wait for feedback from maintainers. If approved, implement and submit a PR.
|
|
103
|
-
|
|
104
|
-
## 📐 Coding Standards
|
|
105
|
-
|
|
106
|
-
### TypeScript/JavaScript
|
|
107
|
-
- Follow the project's ESLint configuration.
|
|
108
|
-
- Use strict mode. Avoid `any` types.
|
|
109
|
-
- Write comprehensive JSDoc for all public APIs.
|
|
110
|
-
- Aim for 100% type coverage for new code.
|
|
111
|
-
|
|
112
|
-
### Commits
|
|
113
|
-
- Use [Conventional Commits](https://www.conventionalcommits.org/).
|
|
114
|
-
- Example: `feat(core): add handle derivation with metadata` or `fix(crypto): resolve edge case in hkdf`.
|
|
115
|
-
|
|
116
|
-
## 🔐 Cryptography Guidelines
|
|
117
|
-
|
|
118
|
-
Me2em is a security-critical project. When working with crypto:
|
|
119
|
-
|
|
120
|
-
✅ **Do:**
|
|
121
|
-
- Use established, audited libraries (e.g., `@noble/ed25519`, `@noble/hashes`, Web Crypto API).
|
|
122
|
-
- Add property-based tests for cryptographic functions.
|
|
123
|
-
- Document security assumptions and threat models in code comments.
|
|
124
|
-
|
|
125
|
-
❌ **Don't:**
|
|
126
|
-
- Implement your own cryptographic primitives.
|
|
127
|
-
- Hardcode secrets, private keys, or test seeds in the source code.
|
|
128
|
-
- Change key derivation parameters (like HKDF info/salt) without consensus and thorough review.
|
|
129
|
-
|
|
130
|
-
## 🧪 Testing
|
|
131
|
-
|
|
132
|
-
- New features require new tests.
|
|
133
|
-
- Bug fixes should include a regression test.
|
|
134
|
-
- Aim for >90% coverage in `packages/core`.
|
|
135
|
-
- Run coverage locally: `pnpm run test:coverage`
|
|
136
|
-
|
|
137
|
-
## 🤝 Review Process
|
|
138
|
-
|
|
139
|
-
1. PR created → GitHub Actions CI runs automatically (lint, typecheck, test).
|
|
140
|
-
2. Maintainer reviews within 3-5 business days.
|
|
141
|
-
3. Address feedback by pushing updates to the same branch.
|
|
142
|
-
4. Once approved, the PR is merged by a maintainer.
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
🙏 **Thank You!** Your contributions make Me2em better, more secure, and more accessible for everyone. Welcome to the community! 🎉
|
package/GOVERNANCE.md
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
# Governance Model: Me2em Ecosystem
|
|
2
|
-
|
|
3
|
-
> This document describes how decisions are made in the Me2em open-source project.
|
|
4
|
-
|
|
5
|
-
**Version**: 1.0
|
|
6
|
-
**Last Updated**: May 2026
|
|
7
|
-
**Scope**: All repositories under `github.com/me2em-org`
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## 🎯 Philosophy
|
|
12
|
-
|
|
13
|
-
Me2em is built on three principles:
|
|
14
|
-
|
|
15
|
-
1. **Privacy by Design**: Technical decisions must prioritize user privacy and cryptographic security.
|
|
16
|
-
2. **Open Collaboration**: Anyone can contribute; merit is earned through quality work, not affiliation.
|
|
17
|
-
3. **Decentralized Trust**: The protocol should enable trustless interactions; governance should reflect that.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 👥 Roles
|
|
22
|
-
|
|
23
|
-
### 👤 Contributor
|
|
24
|
-
Anyone who submits code, docs, issues, or feedback.
|
|
25
|
-
|
|
26
|
-
**Rights**:
|
|
27
|
-
- Comment on issues and PRs
|
|
28
|
-
- Propose features via Discussions
|
|
29
|
-
- Submit pull requests
|
|
30
|
-
|
|
31
|
-
**Path to next role**: 3+ merged PRs with positive reviews.
|
|
32
|
-
|
|
33
|
-
### 🔧 Maintainer
|
|
34
|
-
Trusted contributors with write access to specific repositories.
|
|
35
|
-
|
|
36
|
-
**Responsibilities**:
|
|
37
|
-
- Review and merge PRs in their area
|
|
38
|
-
- Triage issues and label appropriately
|
|
39
|
-
- Help onboard new contributors
|
|
40
|
-
- Uphold code quality and security standards
|
|
41
|
-
|
|
42
|
-
**How to become**:
|
|
43
|
-
1. Be an active Contributor (3+ merged PRs)
|
|
44
|
-
2. Receive nomination from an existing Maintainer
|
|
45
|
-
3. Approval by ≥2 Core Team members
|
|
46
|
-
4. 2-week no-objection period
|
|
47
|
-
|
|
48
|
-
**Current Maintainers**: [List in `MAINTAINERS.md`]
|
|
49
|
-
|
|
50
|
-
### 🧭 Core Team
|
|
51
|
-
Strategic decision-makers for the protocol and ecosystem.
|
|
52
|
-
|
|
53
|
-
**Responsibilities**:
|
|
54
|
-
- Approve breaking changes to the protocol spec
|
|
55
|
-
- Resolve maintainer disputes
|
|
56
|
-
- Manage security disclosures and releases
|
|
57
|
-
- Represent Me2em in external partnerships
|
|
58
|
-
|
|
59
|
-
**How to become**:
|
|
60
|
-
1. Be a Maintainer for ≥6 months
|
|
61
|
-
2. Demonstrate deep protocol understanding
|
|
62
|
-
3. Nomination by ≥2 Core Team members
|
|
63
|
-
4. Supermajority vote (≥75%) of existing Core Team
|
|
64
|
-
|
|
65
|
-
**Current Core Team**: [List in `CORE_TEAM.md`]
|
|
66
|
-
|
|
67
|
-
### 🗳️ Community Advisory Council (Planned)
|
|
68
|
-
Representative body for broader community input (post-v1.0).
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## 🗳️ Decision-Making
|
|
73
|
-
|
|
74
|
-
### Technical Decisions (within a repo)
|
|
75
|
-
- **Process**: RFC via GitHub Discussion → Implementation PR → Maintainer review → Merge
|
|
76
|
-
- **Consensus**: Lazy consensus (no objections after 5 business days)
|
|
77
|
-
- **Tie-breaker**: Repo Maintainer(s)
|
|
78
|
-
|
|
79
|
-
### Protocol Specification Changes
|
|
80
|
-
- **Process**: Me2em Improvement Proposal (MIP) → Core Team review → Community comment period (14 days) → Core Team vote
|
|
81
|
-
- **Threshold**: ≥2/3 Core Team approval
|
|
82
|
-
- **Documentation**: All MIPs archived in `specs/MIPs/`
|
|
83
|
-
|
|
84
|
-
### Governance Changes
|
|
85
|
-
- **Process**: Proposal in Discussions → Core Team draft → Community comment (30 days) → Core Team supermajority (≥75%)
|
|
86
|
-
- **Ratification**: Published as `GOVERNANCE-vX.md`
|
|
87
|
-
|
|
88
|
-
### Security Decisions
|
|
89
|
-
- **Process**: Private discussion among Core Team + security reporter → Fix → Coordinated disclosure
|
|
90
|
-
- **Emergency**: Core Team may act unilaterally for critical vulnerabilities, with post-mortem
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
## 🔄 Conflict Resolution
|
|
95
|
-
|
|
96
|
-
1. **Direct discussion**: Parties attempt to resolve informally
|
|
97
|
-
2. **Maintainer mediation**: Neutral Maintainer facilitates
|
|
98
|
-
3. **Core Team escalation**: Final decision by Core Team vote
|
|
99
|
-
4. **Community fork**: As last resort, community may fork (per Apache 2.0 license)
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## 📊 Transparency
|
|
104
|
-
|
|
105
|
-
- All non-sensitive discussions happen in public (GitHub Issues/Discussions)
|
|
106
|
-
- Meeting notes (Core Team) published within 7 days
|
|
107
|
-
- Financial decisions (if any) documented in `TRANSPARENCY.md`
|
|
108
|
-
- Security incidents: post-mortem published after resolution
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## 🚀 Roadmap Input
|
|
113
|
-
|
|
114
|
-
Anyone can propose roadmap items via:
|
|
115
|
-
- GitHub Discussions: `category:roadmap`
|
|
116
|
-
- Annual community survey (planned)
|
|
117
|
-
|
|
118
|
-
Core Team prioritizes based on:
|
|
119
|
-
1. Security & stability
|
|
120
|
-
2. Community demand (👍 reactions, use-case validation)
|
|
121
|
-
3. Technical feasibility
|
|
122
|
-
4. Alignment with Me2em philosophy
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## 📜 Amendments
|
|
127
|
-
|
|
128
|
-
This document may be amended following the "Governance Changes" process above.
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
*Part of the Me2em ecosystem: [github.com/me2em-org](https://github.com/me2em-org) | Contact: hello@me2em.com*
|