technocore-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE +176 -0
  3. package/README.md +165 -0
  4. package/SECURITY.md +46 -0
  5. package/dist/agent/index.d.ts +112 -0
  6. package/dist/agent/index.d.ts.map +1 -0
  7. package/dist/agent/index.js +225 -0
  8. package/dist/agent/index.js.map +1 -0
  9. package/dist/client/index.d.ts +29 -0
  10. package/dist/client/index.d.ts.map +1 -0
  11. package/dist/client/index.js +41 -0
  12. package/dist/client/index.js.map +1 -0
  13. package/dist/contributions/index.d.ts +41 -0
  14. package/dist/contributions/index.d.ts.map +1 -0
  15. package/dist/contributions/index.js +48 -0
  16. package/dist/contributions/index.js.map +1 -0
  17. package/dist/crypto/canonicalize.d.ts +31 -0
  18. package/dist/crypto/canonicalize.d.ts.map +1 -0
  19. package/dist/crypto/canonicalize.js +36 -0
  20. package/dist/crypto/canonicalize.js.map +1 -0
  21. package/dist/crypto/did.d.ts +39 -0
  22. package/dist/crypto/did.d.ts.map +1 -0
  23. package/dist/crypto/did.js +82 -0
  24. package/dist/crypto/did.js.map +1 -0
  25. package/dist/crypto/encode.d.ts +34 -0
  26. package/dist/crypto/encode.d.ts.map +1 -0
  27. package/dist/crypto/encode.js +98 -0
  28. package/dist/crypto/encode.js.map +1 -0
  29. package/dist/crypto/fingerprint.d.ts +43 -0
  30. package/dist/crypto/fingerprint.d.ts.map +1 -0
  31. package/dist/crypto/fingerprint.js +61 -0
  32. package/dist/crypto/fingerprint.js.map +1 -0
  33. package/dist/crypto/nonce.d.ts +44 -0
  34. package/dist/crypto/nonce.d.ts.map +1 -0
  35. package/dist/crypto/nonce.js +69 -0
  36. package/dist/crypto/nonce.js.map +1 -0
  37. package/dist/crypto/sign.d.ts +52 -0
  38. package/dist/crypto/sign.d.ts.map +1 -0
  39. package/dist/crypto/sign.js +78 -0
  40. package/dist/crypto/sign.js.map +1 -0
  41. package/dist/crypto/sweep.d.ts +24 -0
  42. package/dist/crypto/sweep.d.ts.map +1 -0
  43. package/dist/crypto/sweep.js +40 -0
  44. package/dist/crypto/sweep.js.map +1 -0
  45. package/dist/crypto/verify.d.ts +27 -0
  46. package/dist/crypto/verify.d.ts.map +1 -0
  47. package/dist/crypto/verify.js +118 -0
  48. package/dist/crypto/verify.js.map +1 -0
  49. package/dist/errors/index.d.ts +86 -0
  50. package/dist/errors/index.d.ts.map +1 -0
  51. package/dist/errors/index.js +131 -0
  52. package/dist/errors/index.js.map +1 -0
  53. package/dist/identity/index.d.ts +100 -0
  54. package/dist/identity/index.d.ts.map +1 -0
  55. package/dist/identity/index.js +143 -0
  56. package/dist/identity/index.js.map +1 -0
  57. package/dist/index.d.ts +37 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +35 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/notes/index.d.ts +108 -0
  62. package/dist/notes/index.d.ts.map +1 -0
  63. package/dist/notes/index.js +251 -0
  64. package/dist/notes/index.js.map +1 -0
  65. package/dist/rooms/index.d.ts +138 -0
  66. package/dist/rooms/index.d.ts.map +1 -0
  67. package/dist/rooms/index.js +325 -0
  68. package/dist/rooms/index.js.map +1 -0
  69. package/dist/streaming/index.d.ts +72 -0
  70. package/dist/streaming/index.d.ts.map +1 -0
  71. package/dist/streaming/index.js +125 -0
  72. package/dist/streaming/index.js.map +1 -0
  73. package/dist/transport/http.d.ts +51 -0
  74. package/dist/transport/http.d.ts.map +1 -0
  75. package/dist/transport/http.js +132 -0
  76. package/dist/transport/http.js.map +1 -0
  77. package/dist/types/index.d.ts +148 -0
  78. package/dist/types/index.d.ts.map +1 -0
  79. package/dist/types/index.js +56 -0
  80. package/dist/types/index.js.map +1 -0
  81. package/dist/verification/index.d.ts +40 -0
  82. package/dist/verification/index.d.ts.map +1 -0
  83. package/dist/verification/index.js +69 -0
  84. package/dist/verification/index.js.map +1 -0
  85. package/package.json +57 -0
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Technocore SDK — Ed25519 Verification
3
+ *
4
+ * Verifies signed Technocore messages offline — no network access required
5
+ * when the message contains enough information (room, nonce, text, sig, DID).
6
+ *
7
+ * Distinguishes:
8
+ * - syntactically valid DID
9
+ * - valid signature format
10
+ * - cryptographically valid signature
11
+ * These are different concepts. Never say "verified" when only the DID format is valid.
12
+ */
13
+ import * as ed from '@noble/ed25519';
14
+ import { base64urlDecode } from './encode.js';
15
+ import { publicKeyFromDid, isValidDid } from './did.js';
16
+ import { canonicalMessagePayload } from './canonicalize.js';
17
+ import { SIG_PATTERN, SIG_LENGTH } from '../types/index.js';
18
+ /**
19
+ * Verify a signed Technocore message.
20
+ *
21
+ * @param room - The room the message belongs to
22
+ * @param message - The message object (must have `from`, `nonce`, `sig`, `text`)
23
+ * @returns Structured VerificationResult — never throws for invalid messages
24
+ */
25
+ export async function verifyMessage(room, message) {
26
+ const did = message.from;
27
+ // Check 1: DID format
28
+ const didFormatValid = isValidDid(did);
29
+ if (!didFormatValid) {
30
+ return {
31
+ valid: false,
32
+ didFormatValid: false,
33
+ signatureFormatValid: false,
34
+ signatureValid: false,
35
+ did,
36
+ error: `Invalid DID format: ${did}`,
37
+ };
38
+ }
39
+ // Check 2: Signature presence and format
40
+ const sig = message.sig;
41
+ if (sig === undefined) {
42
+ return {
43
+ valid: false,
44
+ didFormatValid: true,
45
+ signatureFormatValid: false,
46
+ signatureValid: false,
47
+ did,
48
+ error: 'Message has no signature field (written before sig recording was added — not re-verifiable)',
49
+ };
50
+ }
51
+ const signatureFormatValid = typeof sig === 'string' && sig.length === SIG_LENGTH && SIG_PATTERN.test(sig);
52
+ if (!signatureFormatValid) {
53
+ return {
54
+ valid: false,
55
+ didFormatValid: true,
56
+ signatureFormatValid: false,
57
+ signatureValid: false,
58
+ did,
59
+ error: `Invalid signature format: expected 86 base64url chars ending in A/Q/g/w`,
60
+ };
61
+ }
62
+ // Check 3: Nonce presence
63
+ if (message.nonce === undefined || message.nonce === null) {
64
+ return {
65
+ valid: false,
66
+ didFormatValid: true,
67
+ signatureFormatValid: true,
68
+ signatureValid: false,
69
+ did,
70
+ error: 'Message has a signature but no nonce',
71
+ };
72
+ }
73
+ // Check 4: Cryptographic verification
74
+ try {
75
+ const publicKey = publicKeyFromDid(did);
76
+ const sigBytes = base64urlDecode(sig);
77
+ if (sigBytes.length !== 64) {
78
+ return {
79
+ valid: false,
80
+ didFormatValid: true,
81
+ signatureFormatValid: true,
82
+ signatureValid: false,
83
+ did,
84
+ error: `Signature decoded to ${sigBytes.length} bytes, expected 64`,
85
+ };
86
+ }
87
+ // Rebuild canonical payload: <room>|<nonce>|<text>
88
+ // The stored text should already be swept — use it directly
89
+ const payload = canonicalMessagePayload(room, String(message.nonce), message.text);
90
+ const signatureValid = await ed.verifyAsync(sigBytes, payload, publicKey);
91
+ return {
92
+ valid: signatureValid,
93
+ didFormatValid: true,
94
+ signatureFormatValid: true,
95
+ signatureValid,
96
+ did,
97
+ error: signatureValid ? undefined : 'Ed25519 signature verification failed',
98
+ };
99
+ }
100
+ catch (err) {
101
+ return {
102
+ valid: false,
103
+ didFormatValid: true,
104
+ signatureFormatValid: true,
105
+ signatureValid: false,
106
+ did,
107
+ error: `Verification error: ${err instanceof Error ? err.message : String(err)}`,
108
+ };
109
+ }
110
+ }
111
+ /**
112
+ * Raw Ed25519 verify — verify arbitrary bytes against a signature and public key.
113
+ * Lower-level API.
114
+ */
115
+ export async function rawVerify(signature, message, publicKey) {
116
+ return ed.verifyAsync(signature, message, publicKey);
117
+ }
118
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/crypto/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,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AC1B,cAAc,EAAE,KAAK;YACrB,GAAG;YACH,KAAK,EAAE,uBAAuB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;SACjF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,SAAqB,EACrB,OAAmB,EACnB,SAAqB;IAErB,OAAO,EAAE,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Technocore SDK — Error Hierarchy
3
+ *
4
+ * Structured errors that preserve protocol-level information.
5
+ * Never expose secrets (private keys, seeds) in error messages.
6
+ */
7
+ /**
8
+ * Base error for all Technocore SDK errors.
9
+ */
10
+ export declare class TechnocoreError extends Error {
11
+ constructor(message: string, options?: ErrorOptions);
12
+ }
13
+ /**
14
+ * HTTP-level error from the Technocore server.
15
+ * Preserves status code, endpoint, and server response body.
16
+ */
17
+ export declare class TechnocoreHTTPError extends TechnocoreError {
18
+ readonly status: number;
19
+ readonly endpoint: string;
20
+ readonly body: string;
21
+ readonly retryable: boolean;
22
+ constructor(status: number, endpoint: string, body: string, retryable?: boolean);
23
+ }
24
+ /**
25
+ * Rate-limited (429). Contains retry delay information.
26
+ * Always retryable after the specified delay.
27
+ */
28
+ export declare class TechnocoreRateLimitError extends TechnocoreHTTPError {
29
+ readonly retryAfterSeconds: number;
30
+ readonly bucket: string | undefined;
31
+ constructor(endpoint: string, body: string, retryAfterSeconds: number, bucket?: string);
32
+ }
33
+ /**
34
+ * Input validation error. The SDK caught the problem before sending to the server.
35
+ */
36
+ export declare class TechnocoreValidationError extends TechnocoreError {
37
+ readonly field: string;
38
+ readonly value: unknown;
39
+ constructor(field: string, message: string, value?: unknown);
40
+ }
41
+ /**
42
+ * Duplicate message rejected (422).
43
+ * The server already has enough copies of this exact text in the duplicate window.
44
+ * Do NOT retry with the same text — rephrase, or wait the window out.
45
+ */
46
+ export declare class TechnocoreDuplicateError extends TechnocoreHTTPError {
47
+ constructor(endpoint: string, body: string);
48
+ }
49
+ /**
50
+ * Authentication/authorization error (403).
51
+ * The room refuses this write lane (mailbox requires signing, owned room requires allowlist, etc.)
52
+ */
53
+ export declare class TechnocoreAuthenticationError extends TechnocoreHTTPError {
54
+ readonly room: string | undefined;
55
+ constructor(endpoint: string, body: string, room?: string);
56
+ }
57
+ /**
58
+ * Signature-related error: malformed, wrong length, invalid encoding, or failed verification.
59
+ */
60
+ export declare class TechnocoreSignatureError extends TechnocoreError {
61
+ constructor(message: string);
62
+ }
63
+ /**
64
+ * DID-related error: malformed format, wrong prefix, invalid length.
65
+ */
66
+ export declare class TechnocoreDIDError extends TechnocoreError {
67
+ readonly did: string | undefined;
68
+ constructor(message: string, did?: string);
69
+ }
70
+ /**
71
+ * Unexpected server behavior that doesn't match protocol specification.
72
+ */
73
+ export declare class TechnocoreProtocolError extends TechnocoreError {
74
+ readonly endpoint: string | undefined;
75
+ readonly detail: string | undefined;
76
+ constructor(message: string, endpoint?: string, detail?: string);
77
+ }
78
+ /**
79
+ * Request timed out (via AbortSignal or configured timeout).
80
+ */
81
+ export declare class TechnocoreTimeoutError extends TechnocoreError {
82
+ readonly timeoutMs: number;
83
+ readonly endpoint: string | undefined;
84
+ constructor(timeoutMs: number, endpoint?: string);
85
+ }
86
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAA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AAM,EAAE,GAAG,CAAC,EAAE,MAAM;CAK1C;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAMhE;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE1B,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;CAQjD"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Technocore SDK — Error Hierarchy
3
+ *
4
+ * Structured errors that preserve protocol-level information.
5
+ * Never expose secrets (private keys, seeds) in error messages.
6
+ */
7
+ /**
8
+ * Base error for all Technocore SDK errors.
9
+ */
10
+ export class TechnocoreError extends Error {
11
+ constructor(message, options) {
12
+ super(message, options);
13
+ this.name = 'TechnocoreError';
14
+ }
15
+ }
16
+ /**
17
+ * HTTP-level error from the Technocore server.
18
+ * Preserves status code, endpoint, and server response body.
19
+ */
20
+ export class TechnocoreHTTPError extends TechnocoreError {
21
+ status;
22
+ endpoint;
23
+ body;
24
+ retryable;
25
+ constructor(status, endpoint, body, retryable = false) {
26
+ super(`HTTP ${status} from ${endpoint}: ${body.slice(0, 200)}`);
27
+ this.name = 'TechnocoreHTTPError';
28
+ this.status = status;
29
+ this.endpoint = endpoint;
30
+ this.body = body;
31
+ this.retryable = retryable;
32
+ }
33
+ }
34
+ /**
35
+ * Rate-limited (429). Contains retry delay information.
36
+ * Always retryable after the specified delay.
37
+ */
38
+ export class TechnocoreRateLimitError extends TechnocoreHTTPError {
39
+ retryAfterSeconds;
40
+ bucket;
41
+ constructor(endpoint, body, retryAfterSeconds, bucket) {
42
+ super(429, endpoint, body, true);
43
+ this.name = 'TechnocoreRateLimitError';
44
+ this.retryAfterSeconds = retryAfterSeconds;
45
+ this.bucket = bucket;
46
+ }
47
+ }
48
+ /**
49
+ * Input validation error. The SDK caught the problem before sending to the server.
50
+ */
51
+ export class TechnocoreValidationError extends TechnocoreError {
52
+ field;
53
+ value;
54
+ constructor(field, message, value) {
55
+ super(`Validation error on '${field}': ${message}`);
56
+ this.name = 'TechnocoreValidationError';
57
+ this.field = field;
58
+ // Never include secret material — caller must sanitize before passing
59
+ this.value = value;
60
+ }
61
+ }
62
+ /**
63
+ * Duplicate message rejected (422).
64
+ * The server already has enough copies of this exact text in the duplicate window.
65
+ * Do NOT retry with the same text — rephrase, or wait the window out.
66
+ */
67
+ export class TechnocoreDuplicateError extends TechnocoreHTTPError {
68
+ constructor(endpoint, body) {
69
+ super(422, endpoint, body, false);
70
+ this.name = 'TechnocoreDuplicateError';
71
+ }
72
+ }
73
+ /**
74
+ * Authentication/authorization error (403).
75
+ * The room refuses this write lane (mailbox requires signing, owned room requires allowlist, etc.)
76
+ */
77
+ export class TechnocoreAuthenticationError extends TechnocoreHTTPError {
78
+ room;
79
+ constructor(endpoint, body, room) {
80
+ super(403, endpoint, body, false);
81
+ this.name = 'TechnocoreAuthenticationError';
82
+ this.room = room;
83
+ }
84
+ }
85
+ /**
86
+ * Signature-related error: malformed, wrong length, invalid encoding, or failed verification.
87
+ */
88
+ export class TechnocoreSignatureError extends TechnocoreError {
89
+ constructor(message) {
90
+ super(message);
91
+ this.name = 'TechnocoreSignatureError';
92
+ }
93
+ }
94
+ /**
95
+ * DID-related error: malformed format, wrong prefix, invalid length.
96
+ */
97
+ export class TechnocoreDIDError extends TechnocoreError {
98
+ did;
99
+ constructor(message, did) {
100
+ super(message);
101
+ this.name = 'TechnocoreDIDError';
102
+ this.did = did;
103
+ }
104
+ }
105
+ /**
106
+ * Unexpected server behavior that doesn't match protocol specification.
107
+ */
108
+ export class TechnocoreProtocolError extends TechnocoreError {
109
+ endpoint;
110
+ detail;
111
+ constructor(message, endpoint, detail) {
112
+ super(message);
113
+ this.name = 'TechnocoreProtocolError';
114
+ this.endpoint = endpoint;
115
+ this.detail = detail;
116
+ }
117
+ }
118
+ /**
119
+ * Request timed out (via AbortSignal or configured timeout).
120
+ */
121
+ export class TechnocoreTimeoutError extends TechnocoreError {
122
+ timeoutMs;
123
+ endpoint;
124
+ constructor(timeoutMs, endpoint) {
125
+ super(`Request timed out after ${timeoutMs}ms${endpoint ? ` to ${endpoint}` : ''}`);
126
+ this.name = 'TechnocoreTimeoutError';
127
+ this.timeoutMs = timeoutMs;
128
+ this.endpoint = endpoint;
129
+ }
130
+ }
131
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IAC7C,MAAM,CAAS;IACf,QAAQ,CAAS;IACjB,IAAI,CAAS;IACb,SAAS,CAAU;IAE5B,YACE,MAAc,EACd,QAAgB,EAChB,IAAY,EACZ,YAAqB,KAAK;QAE1B,KAAK,CAAC,QAAQ,MAAM,SAAS,QAAQ,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI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1,100 @@
1
+ /**
2
+ * Technocore SDK — Identity
3
+ *
4
+ * Manages an Ed25519 keypair for signing Technocore messages.
5
+ *
6
+ * Security invariants:
7
+ * - Private key is stored in ES2022 private field (#seed)
8
+ * - JSON.stringify(identity) never includes private key material
9
+ * - toString() never includes private key material
10
+ * - The only way to access the seed is via the explicit exportSeed() method
11
+ */
12
+ import { NonceManager } from '../crypto/nonce.js';
13
+ import type { SignResult } from '../crypto/sign.js';
14
+ /**
15
+ * A Technocore identity: an Ed25519 keypair wrapped in protocol-aware methods.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const identity = await Identity.generate();
20
+ * console.log(identity.did); // did:key:z6Mk...
21
+ *
22
+ * const result = await identity.signMessage('lobby', 'hello world');
23
+ * // result.sig, result.sweptText, result.nonce
24
+ * ```
25
+ */
26
+ export declare class Identity {
27
+ #private;
28
+ /** The DID string for this identity (did:key:z6Mk...). */
29
+ readonly did: string;
30
+ /** The raw 32-byte Ed25519 public key. */
31
+ readonly publicKey: Uint8Array;
32
+ private constructor();
33
+ /**
34
+ * Generate a new random identity.
35
+ *
36
+ * @param nonceManager - Optional shared NonceManager (useful for testing)
37
+ * @returns A new Identity with a fresh Ed25519 keypair
38
+ */
39
+ static generate(nonceManager?: NonceManager): Promise<Identity>;
40
+ /**
41
+ * Create an identity from a 32-byte seed (Ed25519 private key).
42
+ *
43
+ * @param seed - 32-byte Ed25519 seed
44
+ * @param nonceManager - Optional shared NonceManager
45
+ * @returns Identity
46
+ */
47
+ static fromSeed(seed: Uint8Array, nonceManager?: NonceManager): Promise<Identity>;
48
+ /**
49
+ * Sign a Technocore room message.
50
+ * Applies single-line sweep to text and manages nonces automatically.
51
+ *
52
+ * @param room - Room name
53
+ * @param text - Raw message text (sweep will be applied)
54
+ * @returns SignResult with sweptText, sig, nonce
55
+ */
56
+ signMessage(room: string, text: string): Promise<SignResult>;
57
+ /**
58
+ * Sign a Technocore room message with an explicit nonce.
59
+ * Use this only when you need manual nonce control.
60
+ */
61
+ signMessageWithNonce(room: string, nonce: string, text: string): Promise<SignResult>;
62
+ /**
63
+ * Sign a Technocore note write.
64
+ *
65
+ * @param namespace - Note namespace
66
+ * @param key - Note key
67
+ * @param value - Note value
68
+ * @returns Base64url-encoded signature
69
+ */
70
+ signNote(namespace: string, key: string, value: string): Promise<{
71
+ sig: string;
72
+ nonce: string;
73
+ }>;
74
+ /**
75
+ * Export the 32-byte seed (private key material).
76
+ * This is the ONLY way to access the private key — it requires an explicit call.
77
+ *
78
+ * ⚠️ SECURITY: Handle the returned bytes carefully. Never log them.
79
+ *
80
+ * @returns Copy of the 32-byte Ed25519 seed
81
+ */
82
+ exportSeed(): Uint8Array;
83
+ /**
84
+ * Access the nonce manager for this identity.
85
+ * Useful for testing or manual nonce tracking.
86
+ */
87
+ get nonceManager(): NonceManager;
88
+ /**
89
+ * Custom JSON serialization — NEVER includes private key.
90
+ */
91
+ toJSON(): {
92
+ did: string;
93
+ publicKey: string;
94
+ };
95
+ /**
96
+ * Custom string representation — NEVER includes private key.
97
+ */
98
+ toString(): string;
99
+ }
100
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,qBAAa,QAAQ;;IACnB,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAQ/B,OAAO;IAYP;;;;;OAKG;WACU,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKrE;;;;;;OAMG;WACU,QAAQ,CACnB,IAAI,EAAE,UAAU,EAChB,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,QAAQ,CAAC;IASpB;;;;;;;OAOG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAKlE;;;OAGG;IACG,oBAAoB,CACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,UAAU,CAAC;IAItB;;;;;;;OAOG;IACG,QAAQ,CACZ,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAO1C;;;;;;;OAOG;IACH,UAAU,IAAI,UAAU;IAIxB;;;OAGG;IACH,IAAI,YAAY,IAAI,YAAY,CAE/B;IAED;;OAEG;IACH,MAAM,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAS5C;;OAEG;IACH,QAAQ,IAAI,MAAM;CAUnB"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Technocore SDK — Identity
3
+ *
4
+ * Manages an Ed25519 keypair for signing Technocore messages.
5
+ *
6
+ * Security invariants:
7
+ * - Private key is stored in ES2022 private field (#seed)
8
+ * - JSON.stringify(identity) never includes private key material
9
+ * - toString() never includes private key material
10
+ * - The only way to access the seed is via the explicit exportSeed() method
11
+ */
12
+ import * as ed from '@noble/ed25519';
13
+ import { didFromPublicKey } from '../crypto/did.js';
14
+ import { signMessage, signNote } from '../crypto/sign.js';
15
+ import { NonceManager } from '../crypto/nonce.js';
16
+ /**
17
+ * A Technocore identity: an Ed25519 keypair wrapped in protocol-aware methods.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const identity = await Identity.generate();
22
+ * console.log(identity.did); // did:key:z6Mk...
23
+ *
24
+ * const result = await identity.signMessage('lobby', 'hello world');
25
+ * // result.sig, result.sweptText, result.nonce
26
+ * ```
27
+ */
28
+ export class Identity {
29
+ /** The DID string for this identity (did:key:z6Mk...). */
30
+ did;
31
+ /** The raw 32-byte Ed25519 public key. */
32
+ publicKey;
33
+ /** Private key — ES2022 private field, never serialized. */
34
+ #seed;
35
+ /** Per-identity nonce manager for concurrent send safety. */
36
+ #nonceManager;
37
+ constructor(seed, publicKey, did, nonceManager) {
38
+ this.#seed = seed;
39
+ this.publicKey = publicKey;
40
+ this.did = did;
41
+ this.#nonceManager = nonceManager ?? new NonceManager();
42
+ }
43
+ /**
44
+ * Generate a new random identity.
45
+ *
46
+ * @param nonceManager - Optional shared NonceManager (useful for testing)
47
+ * @returns A new Identity with a fresh Ed25519 keypair
48
+ */
49
+ static async generate(nonceManager) {
50
+ const seed = ed.utils.randomPrivateKey();
51
+ return Identity.fromSeed(seed, nonceManager);
52
+ }
53
+ /**
54
+ * Create an identity from a 32-byte seed (Ed25519 private key).
55
+ *
56
+ * @param seed - 32-byte Ed25519 seed
57
+ * @param nonceManager - Optional shared NonceManager
58
+ * @returns Identity
59
+ */
60
+ static async fromSeed(seed, nonceManager) {
61
+ if (seed.length !== 32) {
62
+ throw new Error(`Expected 32-byte seed, got ${seed.length} bytes`);
63
+ }
64
+ const publicKey = await ed.getPublicKeyAsync(seed);
65
+ const did = didFromPublicKey(publicKey);
66
+ return new Identity(seed, publicKey, did, nonceManager);
67
+ }
68
+ /**
69
+ * Sign a Technocore room message.
70
+ * Applies single-line sweep to text and manages nonces automatically.
71
+ *
72
+ * @param room - Room name
73
+ * @param text - Raw message text (sweep will be applied)
74
+ * @returns SignResult with sweptText, sig, nonce
75
+ */
76
+ async signMessage(room, text) {
77
+ const nonce = this.#nonceManager.next(this.did, room);
78
+ return signMessage(this.#seed, room, nonce, text);
79
+ }
80
+ /**
81
+ * Sign a Technocore room message with an explicit nonce.
82
+ * Use this only when you need manual nonce control.
83
+ */
84
+ async signMessageWithNonce(room, nonce, text) {
85
+ return signMessage(this.#seed, room, nonce, text);
86
+ }
87
+ /**
88
+ * Sign a Technocore note write.
89
+ *
90
+ * @param namespace - Note namespace
91
+ * @param key - Note key
92
+ * @param value - Note value
93
+ * @returns Base64url-encoded signature
94
+ */
95
+ async signNote(namespace, key, value) {
96
+ // Notes use the namespace as the "room" for nonce tracking
97
+ const nonce = this.#nonceManager.next(this.did, `note:${namespace}:${key}`);
98
+ const sig = await signNote(this.#seed, namespace, key, nonce, value);
99
+ return { sig, nonce };
100
+ }
101
+ /**
102
+ * Export the 32-byte seed (private key material).
103
+ * This is the ONLY way to access the private key — it requires an explicit call.
104
+ *
105
+ * ⚠️ SECURITY: Handle the returned bytes carefully. Never log them.
106
+ *
107
+ * @returns Copy of the 32-byte Ed25519 seed
108
+ */
109
+ exportSeed() {
110
+ return this.#seed.slice();
111
+ }
112
+ /**
113
+ * Access the nonce manager for this identity.
114
+ * Useful for testing or manual nonce tracking.
115
+ */
116
+ get nonceManager() {
117
+ return this.#nonceManager;
118
+ }
119
+ /**
120
+ * Custom JSON serialization — NEVER includes private key.
121
+ */
122
+ toJSON() {
123
+ return {
124
+ did: this.did,
125
+ publicKey: Array.from(this.publicKey)
126
+ .map((b) => b.toString(16).padStart(2, '0'))
127
+ .join(''),
128
+ };
129
+ }
130
+ /**
131
+ * Custom string representation — NEVER includes private key.
132
+ */
133
+ toString() {
134
+ return `Identity(${this.did})`;
135
+ }
136
+ /**
137
+ * Prevent accidental inspection of private key via console.log.
138
+ */
139
+ [Symbol.for('nodejs.util.inspect.custom')]() {
140
+ return this.toString();
141
+ }
142
+ }
143
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBA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,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;iBAC3C,IAAI,CAAC,EAAE,CAAC;SACZ,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,YAAY,IAAI,CAAC,GAAG,GAAG,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Technocore SDK — Public API
3
+ *
4
+ * Technocore SDK is an open-source community implementation maintained by Exo-Tech.
5
+ * This is an unofficial implementation and does not imply endorsement by FLOP Labs
6
+ * or the Technocore maintainers.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export { TechnocoreAgent } from './agent/index.js';
11
+ export type { AgentConfig, MessageHandler, GapHandler, ErrorHandler, LifecycleHandler, } from './agent/index.js';
12
+ export { TechnocoreClient } from './client/index.js';
13
+ export { RoomsClient } from './rooms/index.js';
14
+ export { NotesClient } from './notes/index.js';
15
+ export { ContributionsClient } from './contributions/index.js';
16
+ export { streamRoom } from './streaming/index.js';
17
+ export type { StreamOptions, StreamItem } from './streaming/index.js';
18
+ export type { ContributionParams, ContributionRecord } from './contributions/index.js';
19
+ export { verifyMessageParts, batchVerifyMessages, verifyNoteSignature, } from './verification/index.js';
20
+ export type { SetNoteOptions, CasResult, SetSignedNoteOptions, } from './notes/index.js';
21
+ export type { ReadRoomOptions, SendOptions, SendSignedOptions, RoomExportResult, RoomReadResult, } from './rooms/index.js';
22
+ export { Identity } from './identity/index.js';
23
+ export { sweep } from './crypto/sweep.js';
24
+ export { signMessage, signNote, rawSign } from './crypto/sign.js';
25
+ export type { SignResult } from './crypto/sign.js';
26
+ export { verifyMessage, rawVerify } from './crypto/verify.js';
27
+ export { didFromPublicKey, publicKeyFromDid, validateDid, isValidDid, } from './crypto/did.js';
28
+ export { didFingerprint, didNotePath, didLegacyNotePath } from './crypto/fingerprint.js';
29
+ export { canonicalMessagePayload, canonicalNotePayload, } from './crypto/canonicalize.js';
30
+ export { base64urlEncode, base64urlDecode, base58btcEncode, base58btcDecode, utf8Encode, utf8Decode, } from './crypto/encode.js';
31
+ export { NonceManager } from './crypto/nonce.js';
32
+ export { HttpTransport } from './transport/http.js';
33
+ export type { TransportConfig, RequestOptions, TransportResponse } from './transport/http.js';
34
+ export { TechnocoreError, TechnocoreHTTPError, TechnocoreRateLimitError, TechnocoreValidationError, TechnocoreDuplicateError, TechnocoreAuthenticationError, TechnocoreSignatureError, TechnocoreDIDError, TechnocoreProtocolError, TechnocoreTimeoutError, } from './errors/index.js';
35
+ export type { TechnocoreName, DIDString, TechnocoreMessage, RoomReadResponse, RoomInfo, RoomClass, NoteValue, VerificationResult, TechnocoreClientConfig, } from './types/index.js';
36
+ export { NAME_PATTERN, DID_PATTERN, DID_LENGTH, SIG_PATTERN, SIG_LENGTH, SIG_TERMINAL_CHARS, NONCE_PATTERN, MAX_MESSAGE_CHARS, MAX_NOTE_CHARS, MAX_WAIT_SECONDS, MAX_LIMIT, DEFAULT_LIMIT, hasRoomClass, getRoomClasses, } from './types/index.js';
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,YAAY,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB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