@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,230 @@
1
+ // subhandle.ts
2
+ //
3
+ // SubHandle is a leaf node in the Me2em derivation tree.
4
+ // With MAX_DEPTH = 2, a SubHandle CANNOT derive children.
5
+ // It inherits from Handle for polymorphism in Session handling.
6
+
7
+ import { Handle, type HandleMetadata } from './handle.js';
8
+ import { normalizeName } from './canonical-name.js';
9
+
10
+ /**
11
+ * Metadata for a {@link SubHandle}, extending {@link HandleMetadata} with
12
+ * constraints that govern session creation.
13
+ *
14
+ * All constraint fields are optional. When present, they are enforced by
15
+ * {@link SubHandle.validateSessionOptions} at session creation time.
16
+ *
17
+ * @category Types
18
+ */
19
+ export interface SubHandleMetadata extends HandleMetadata {
20
+ /**
21
+ * Restricts the set of audiences this SubHandle may create sessions for.
22
+ * `undefined` = unrestricted; `[]` = deny all.
23
+ */
24
+ allowedAudiences?: string[];
25
+
26
+ /**
27
+ * Restricts the set of scopes this SubHandle may request in sessions.
28
+ * `undefined` = unrestricted; `[]` = deny all.
29
+ */
30
+ allowedScopes?: string[];
31
+
32
+ /**
33
+ * Maximum allowed TTL (in seconds) for sessions created by this SubHandle.
34
+ * Attempts to create a session with a larger TTL will be rejected.
35
+ */
36
+ maxSessionTtl?: number;
37
+
38
+ /**
39
+ * Unix timestamp (in seconds) at which this SubHandle itself expires.
40
+ * After this time, any attempt to create a session will fail.
41
+ * Useful for temporary access grants (e.g., contractor access for 2 weeks).
42
+ */
43
+ expiresAt?: number;
44
+ }
45
+
46
+ /**
47
+ * Represents a context-isolated child Handle in the Me2em hierarchy.
48
+ *
49
+ * A SubHandle is always derived from a parent {@link Handle} and represents
50
+ * a leaf node in the derivation tree (MAX_DEPTH = 2). It inherits all
51
+ * cryptographic capabilities of Handle (signing, key derivation, etc.) but
52
+ * adds:
53
+ *
54
+ * - A **derivation path** (`[handleName, subName]`) carried in session tokens.
55
+ * - **Constraint enforcement** on audience, scopes, and TTL at session creation.
56
+ * - An optional **expiration timestamp** for temporary access grants.
57
+ *
58
+ * SubHandle is used for polymorphism in {@link Session}: both Handle and
59
+ * SubHandle can create and verify sessions, but SubHandle sessions carry
60
+ * the additional `hPath` field for hierarchical auditing.
61
+ *
62
+ * @category Core Primitives
63
+ */
64
+ export class SubHandle extends Handle {
65
+ private readonly _path: string[];
66
+ private readonly _subMetadata: SubHandleMetadata;
67
+
68
+ /**
69
+ * Creates a new SubHandle instance.
70
+ *
71
+ * @internal Typically created via {@link Handle.deriveSubHandle} or
72
+ * {@link Identity.deriveSubHandle}. Direct construction is discouraged.
73
+ *
74
+ * @param privateKey - The 32-byte Ed25519 private key for this SubHandle.
75
+ * @param name - The SubHandle name.
76
+ * @param path - The derivation path, must have exactly 2 elements: `[handleName, subName]`.
77
+ * @param subMetadata - Optional constraints and metadata.
78
+ * @throws {Error} If the path does not have exactly 2 elements.
79
+ */
80
+ constructor(
81
+ privateKey: Uint8Array,
82
+ name: string,
83
+ path: string[],
84
+ subMetadata?: SubHandleMetadata
85
+ ) {
86
+ super(privateKey, name, subMetadata);
87
+
88
+ if (path.length !== 2) {
89
+ throw new Error(
90
+ `SubHandle path must have exactly 2 elements: [handleName, subName]. Got ${path.length}.`
91
+ );
92
+ }
93
+
94
+ const normalizedName = normalizeName(name);
95
+ if (path[1] !== normalizedName) {
96
+ throw new Error(`path[1] must equal normalized name: path[1]=${JSON.stringify(path[1])}, name=${JSON.stringify(normalizedName)}`);
97
+ }
98
+
99
+ this._path = path;
100
+ this._subMetadata = subMetadata ?? {};
101
+ }
102
+
103
+ /**
104
+ * Returns the full derivation path of this SubHandle.
105
+ *
106
+ * @returns A copy of the path array, e.g. `["station-001", "connector-1"]`.
107
+ */
108
+ getPath(): string[] {
109
+ return [...this._path];
110
+ }
111
+
112
+ /**
113
+ * Returns the derivation path as a slash-separated string.
114
+ *
115
+ * @returns The path string, e.g. `"station-001/connector-1"`.
116
+ */
117
+ getPathString(): string {
118
+ return this._path.join('/');
119
+ }
120
+
121
+ /**
122
+ * Returns the depth of this SubHandle in the derivation hierarchy.
123
+ *
124
+ * With MAX_DEPTH = 2, this is always `2` (Identity = 0, Handle = 1, SubHandle = 2).
125
+ *
126
+ * @returns The depth, always `2`.
127
+ */
128
+ getDepth(): number {
129
+ return 2;
130
+ }
131
+
132
+ /**
133
+ * Returns whether this SubHandle is a leaf node.
134
+ *
135
+ * With MAX_DEPTH = 2, a SubHandle is **always** a leaf and cannot derive children.
136
+ *
137
+ * @returns Always `true`.
138
+ */
139
+ isLeaf(): boolean {
140
+ return true;
141
+ }
142
+
143
+ /**
144
+ * SubHandle is a leaf node (depth = 2) and cannot derive children.
145
+ * Overrides the inherited `Handle.deriveSubHandle` to throw an error.
146
+ */
147
+ override async deriveSubHandle(): Promise<never> {
148
+ throw new Error('Cannot derive child: maximum depth (2) reached or this SubHandle is marked as leaf');
149
+ }
150
+
151
+ /**
152
+ * Returns the SubHandle-specific metadata (constraints).
153
+ *
154
+ * @returns The SubHandleMetadata object.
155
+ */
156
+ getSubMetadata(): SubHandleMetadata {
157
+ return {
158
+ ...this._subMetadata,
159
+ allowedAudiences: this._subMetadata.allowedAudiences
160
+ ? [...this._subMetadata.allowedAudiences]
161
+ : undefined,
162
+ allowedScopes: this._subMetadata.allowedScopes
163
+ ? [...this._subMetadata.allowedScopes]
164
+ : undefined,
165
+ };
166
+ }
167
+
168
+ /**
169
+ * Validates session options against this SubHandle's constraints.
170
+ *
171
+ * Called internally by {@link Session.create} before signing. Throws if
172
+ * any constraint is violated:
173
+ * - `audience` not in `allowedAudiences`
174
+ * - any `scope` not in `allowedScopes`
175
+ * - `ttl` exceeds `maxSessionTtl`
176
+ * - current time is past `expiresAt`
177
+ *
178
+ * @param options - The session options to validate.
179
+ * @throws {Error} If any constraint is violated.
180
+ */
181
+ validateSessionOptions(options: {
182
+ audience: string;
183
+ scopes: string[];
184
+ ttl: number;
185
+ }): void {
186
+ // Audience check: undefined = unrestricted, [] = deny all
187
+ if (this._subMetadata.allowedAudiences !== undefined) {
188
+ if (!this._subMetadata.allowedAudiences.includes(options.audience)) {
189
+ throw new Error(
190
+ `Audience "${options.audience}" not allowed for this SubHandle. ` +
191
+ `Allowed: ${this._subMetadata.allowedAudiences.length === 0
192
+ ? '(none — empty list denies all)'
193
+ : this._subMetadata.allowedAudiences.join(', ')}`
194
+ );
195
+ }
196
+ }
197
+
198
+ // Scopes check: undefined = unrestricted, [] = deny all
199
+ if (this._subMetadata.allowedScopes !== undefined) {
200
+ const forbidden = options.scopes.filter(
201
+ s => !this._subMetadata.allowedScopes!.includes(s)
202
+ );
203
+ // An empty allow-list denies every requested scope.
204
+ if (forbidden.length > 0) {
205
+ throw new Error(
206
+ `Scopes not allowed for this SubHandle: ${forbidden.join(', ')}`
207
+ );
208
+ }
209
+ }
210
+
211
+ // TTL check
212
+ if (
213
+ this._subMetadata.maxSessionTtl !== undefined &&
214
+ options.ttl > this._subMetadata.maxSessionTtl
215
+ ) {
216
+ throw new Error(
217
+ `TTL ${options.ttl}s exceeds max allowed ` +
218
+ `${this._subMetadata.maxSessionTtl}s for this SubHandle`
219
+ );
220
+ }
221
+
222
+ // SubHandle expiration check
223
+ if (this._subMetadata.expiresAt !== undefined) {
224
+ const now = Math.floor(Date.now() / 1000);
225
+ if (now >= this._subMetadata.expiresAt) {
226
+ throw new Error('SubHandle has expired');
227
+ }
228
+ }
229
+ }
230
+ }
package/src/util.ts ADDED
@@ -0,0 +1,35 @@
1
+ // util.ts
2
+ //
3
+ // Shared utility functions for the Me2em protocol.
4
+
5
+ /**
6
+ * Encodes a Uint8Array to a URL-safe Base64 string (no padding).
7
+ */
8
+ export function base64urlEncode(bytes: Uint8Array): string {
9
+ let binary = '';
10
+ for (const byte of bytes) {
11
+ binary += String.fromCharCode(byte);
12
+ }
13
+ return btoa(binary)
14
+ .replace(/\+/g, '-')
15
+ .replace(/\//g, '_')
16
+ .replace(/=+$/, '');
17
+ }
18
+
19
+ /**
20
+ * Decodes a URL-safe Base64 string to a Uint8Array.
21
+ */
22
+ export function base64urlDecode(input: string): Uint8Array {
23
+ let base64 = input
24
+ .replace(/-/g, '+')
25
+ .replace(/_/g, '/');
26
+ while (base64.length % 4 !== 0) {
27
+ base64 += '=';
28
+ }
29
+ const binary = atob(base64);
30
+ const bytes = new Uint8Array(binary.length);
31
+ for (let i = 0; i < binary.length; i++) {
32
+ bytes[i] = binary.charCodeAt(i);
33
+ }
34
+ return bytes;
35
+ }
File without changes
@@ -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*
package/SECURITY.md DELETED
@@ -1,70 +0,0 @@
1
- # Security Policy
2
-
3
- ## 🔐 Supported Versions
4
-
5
- | Version | Supported |
6
- |---------|-----------|
7
- | 0.1.x | ✅ Yes |
8
- | < 0.1 | ❌ No |
9
-
10
- > Me2em is in active development. Always use the latest version for security fixes.
11
-
12
- ## 🚨 Reporting a Vulnerability
13
-
14
- Me2em handles cryptographic identities and authentication. We take security seriously.
15
-
16
- **If you discover a security vulnerability:**
17
-
18
- 1. **Do NOT** open a public issue or discuss it publicly
19
- 2. Email `security@me2em.com` with:
20
- - Description of the vulnerability
21
- - Steps to reproduce (if applicable)
22
- - Potential impact assessment
23
- - Suggested fix (optional but appreciated)
24
- 3. Use PGP if possible: [PGP Key](https://me2em.com/security/pgp-key.asc) (coming soon)
25
-
26
- ## 📬 What to Expect
27
-
28
- - **Acknowledgment**: Within 72 hours
29
- - **Assessment**: Within 7 business days
30
- - **Fix timeline**: Depends on severity (critical: ≤14 days)
31
- - **Disclosure**: Coordinated with reporter, after fix is released
32
-
33
- ## 🛡️ Security Best Practices for Users
34
-
35
- When implementing Me2em in your application:
36
-
37
- ✅ **Do**:
38
- - Store seed phrases in secure, user-controlled storage (never in plaintext)
39
- - Use short-lived sessions and rotate tokens frequently
40
- - Validate Handle metadata server-side, not just client-side
41
- - Keep dependencies updated (`@me2em/*` packages)
42
-
43
- ❌ **Don't**:
44
- - Expose private keys or seed phrases in client-side code
45
- - Reuse sessions across different contexts/applications
46
- - Trust Handle metadata without verification
47
- - Disable cryptographic signature verification
48
-
49
- ## 🔍 Audit Status
50
-
51
- | Component | Audit Date | Auditor | Report |
52
- |-----------|------------|---------|--------|
53
- | protocol-core | Planned Q2 2026 | TBD | — |
54
-
55
- > We plan independent security audits before v1.0 release. Follow [Discussions](https://github.com/me2em-org/me2em-protocol/discussions) for updates.
56
-
57
- ## 📜 Responsible Disclosure Policy
58
-
59
- We follow responsible disclosure principles:
60
- - No legal action against good-faith researchers
61
- - Public acknowledgment (with consent) after fix
62
- - Bug bounty program: Planned for post-v1.0
63
-
64
- ## 🔄 Updates
65
-
66
- This policy is reviewed quarterly. Last updated: May 2026.
67
-
68
- ---
69
-
70
- *Part of the Me2em ecosystem: [github.com/me2em-org](https://github.com/me2em-org) | Contact: security@me2em.com*