@affectively/aeon 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/compression/index.cjs +580 -0
- package/dist/compression/index.cjs.map +1 -0
- package/dist/compression/index.d.cts +189 -0
- package/dist/compression/index.d.ts +189 -0
- package/dist/compression/index.js +573 -0
- package/dist/compression/index.js.map +1 -0
- package/dist/core/index.d.cts +70 -5
- package/dist/core/index.d.ts +70 -5
- package/dist/crypto/index.cjs +100 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +407 -0
- package/dist/crypto/index.d.ts +407 -0
- package/dist/crypto/index.js +96 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/distributed/index.cjs +420 -23
- package/dist/distributed/index.cjs.map +1 -1
- package/dist/distributed/index.d.cts +901 -2
- package/dist/distributed/index.d.ts +901 -2
- package/dist/distributed/index.js +420 -23
- package/dist/distributed/index.js.map +1 -1
- package/dist/index.cjs +1222 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -811
- package/dist/index.d.ts +11 -811
- package/dist/index.js +1221 -56
- package/dist/index.js.map +1 -1
- package/dist/offline/index.cjs +419 -0
- package/dist/offline/index.cjs.map +1 -0
- package/dist/offline/index.d.cts +148 -0
- package/dist/offline/index.d.ts +148 -0
- package/dist/offline/index.js +415 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/optimization/index.cjs +797 -0
- package/dist/optimization/index.cjs.map +1 -0
- package/dist/optimization/index.d.cts +347 -0
- package/dist/optimization/index.d.ts +347 -0
- package/dist/optimization/index.js +787 -0
- package/dist/optimization/index.js.map +1 -0
- package/dist/persistence/index.cjs +145 -0
- package/dist/persistence/index.cjs.map +1 -0
- package/dist/persistence/index.d.cts +63 -0
- package/dist/persistence/index.d.ts +63 -0
- package/dist/persistence/index.js +142 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/presence/index.cjs +489 -0
- package/dist/presence/index.cjs.map +1 -0
- package/dist/presence/index.d.cts +283 -0
- package/dist/presence/index.d.ts +283 -0
- package/dist/presence/index.js +485 -0
- package/dist/presence/index.js.map +1 -0
- package/dist/types-CMxO7QF0.d.cts +33 -0
- package/dist/types-CMxO7QF0.d.ts +33 -0
- package/dist/versioning/index.cjs +296 -14
- package/dist/versioning/index.cjs.map +1 -1
- package/dist/versioning/index.d.cts +66 -1
- package/dist/versioning/index.d.ts +66 -1
- package/dist/versioning/index.js +296 -14
- package/dist/versioning/index.js.map +1 -1
- package/package.json +51 -1
- package/dist/index-C_4CMV5c.d.cts +0 -1207
- package/dist/index-C_4CMV5c.d.ts +0 -1207
package/dist/core/index.d.cts
CHANGED
|
@@ -112,6 +112,68 @@ interface CRDTOperation {
|
|
|
112
112
|
nodeId: string;
|
|
113
113
|
vectorClock: VectorClock;
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Presence selection range
|
|
117
|
+
*/
|
|
118
|
+
interface PresenceSelection {
|
|
119
|
+
start: number;
|
|
120
|
+
end: number;
|
|
121
|
+
direction?: 'forward' | 'backward' | 'none';
|
|
122
|
+
path?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Presence typing signal
|
|
126
|
+
*/
|
|
127
|
+
interface PresenceTyping {
|
|
128
|
+
isTyping: boolean;
|
|
129
|
+
field?: string;
|
|
130
|
+
isComposing?: boolean;
|
|
131
|
+
startedAt?: number;
|
|
132
|
+
stoppedAt?: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Presence scroll signal
|
|
136
|
+
*/
|
|
137
|
+
interface PresenceScroll {
|
|
138
|
+
depth: number;
|
|
139
|
+
y?: number;
|
|
140
|
+
viewportHeight?: number;
|
|
141
|
+
documentHeight?: number;
|
|
142
|
+
path?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Presence viewport signal
|
|
146
|
+
*/
|
|
147
|
+
interface PresenceViewport {
|
|
148
|
+
width: number;
|
|
149
|
+
height: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Presence input signal
|
|
153
|
+
*/
|
|
154
|
+
interface PresenceInputState {
|
|
155
|
+
field: string;
|
|
156
|
+
hasFocus: boolean;
|
|
157
|
+
valueLength?: number;
|
|
158
|
+
selectionStart?: number;
|
|
159
|
+
selectionEnd?: number;
|
|
160
|
+
isComposing?: boolean;
|
|
161
|
+
inputMode?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Presence emotional state signal
|
|
165
|
+
*/
|
|
166
|
+
interface PresenceEmotion {
|
|
167
|
+
primary?: string;
|
|
168
|
+
secondary?: string;
|
|
169
|
+
confidence?: number;
|
|
170
|
+
intensity?: number;
|
|
171
|
+
valence?: number;
|
|
172
|
+
arousal?: number;
|
|
173
|
+
dominance?: number;
|
|
174
|
+
source?: 'self-report' | 'inferred' | 'sensor' | 'hybrid';
|
|
175
|
+
updatedAt?: number;
|
|
176
|
+
}
|
|
115
177
|
/**
|
|
116
178
|
* Presence information for real-time collaboration
|
|
117
179
|
*/
|
|
@@ -122,10 +184,13 @@ interface PresenceInfo {
|
|
|
122
184
|
x: number;
|
|
123
185
|
y: number;
|
|
124
186
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
187
|
+
focusNode?: string;
|
|
188
|
+
selection?: PresenceSelection;
|
|
189
|
+
typing?: PresenceTyping;
|
|
190
|
+
scroll?: PresenceScroll;
|
|
191
|
+
viewport?: PresenceViewport;
|
|
192
|
+
inputState?: PresenceInputState;
|
|
193
|
+
emotion?: PresenceEmotion;
|
|
129
194
|
metadata?: Record<string, unknown>;
|
|
130
195
|
lastActivity: number;
|
|
131
196
|
}
|
|
@@ -143,4 +208,4 @@ interface IEventEmitter {
|
|
|
143
208
|
emit<T = unknown>(event: string, data?: T): void;
|
|
144
209
|
}
|
|
145
210
|
|
|
146
|
-
export type { BandwidthProfile, CRDTOperation, ConflictDetectionResult, EventCallback, EventUnsubscribe, IEventEmitter, NetworkState, Operation, OperationPriority, OperationStatus, OperationType, PresenceInfo, ResolutionStrategy, SyncBatch, SyncCoordinatorConfig, SyncResult, VectorClock };
|
|
211
|
+
export type { BandwidthProfile, CRDTOperation, ConflictDetectionResult, EventCallback, EventUnsubscribe, IEventEmitter, NetworkState, Operation, OperationPriority, OperationStatus, OperationType, PresenceEmotion, PresenceInfo, PresenceInputState, PresenceScroll, PresenceSelection, PresenceTyping, PresenceViewport, ResolutionStrategy, SyncBatch, SyncCoordinatorConfig, SyncResult, VectorClock };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -112,6 +112,68 @@ interface CRDTOperation {
|
|
|
112
112
|
nodeId: string;
|
|
113
113
|
vectorClock: VectorClock;
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Presence selection range
|
|
117
|
+
*/
|
|
118
|
+
interface PresenceSelection {
|
|
119
|
+
start: number;
|
|
120
|
+
end: number;
|
|
121
|
+
direction?: 'forward' | 'backward' | 'none';
|
|
122
|
+
path?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Presence typing signal
|
|
126
|
+
*/
|
|
127
|
+
interface PresenceTyping {
|
|
128
|
+
isTyping: boolean;
|
|
129
|
+
field?: string;
|
|
130
|
+
isComposing?: boolean;
|
|
131
|
+
startedAt?: number;
|
|
132
|
+
stoppedAt?: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Presence scroll signal
|
|
136
|
+
*/
|
|
137
|
+
interface PresenceScroll {
|
|
138
|
+
depth: number;
|
|
139
|
+
y?: number;
|
|
140
|
+
viewportHeight?: number;
|
|
141
|
+
documentHeight?: number;
|
|
142
|
+
path?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Presence viewport signal
|
|
146
|
+
*/
|
|
147
|
+
interface PresenceViewport {
|
|
148
|
+
width: number;
|
|
149
|
+
height: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Presence input signal
|
|
153
|
+
*/
|
|
154
|
+
interface PresenceInputState {
|
|
155
|
+
field: string;
|
|
156
|
+
hasFocus: boolean;
|
|
157
|
+
valueLength?: number;
|
|
158
|
+
selectionStart?: number;
|
|
159
|
+
selectionEnd?: number;
|
|
160
|
+
isComposing?: boolean;
|
|
161
|
+
inputMode?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Presence emotional state signal
|
|
165
|
+
*/
|
|
166
|
+
interface PresenceEmotion {
|
|
167
|
+
primary?: string;
|
|
168
|
+
secondary?: string;
|
|
169
|
+
confidence?: number;
|
|
170
|
+
intensity?: number;
|
|
171
|
+
valence?: number;
|
|
172
|
+
arousal?: number;
|
|
173
|
+
dominance?: number;
|
|
174
|
+
source?: 'self-report' | 'inferred' | 'sensor' | 'hybrid';
|
|
175
|
+
updatedAt?: number;
|
|
176
|
+
}
|
|
115
177
|
/**
|
|
116
178
|
* Presence information for real-time collaboration
|
|
117
179
|
*/
|
|
@@ -122,10 +184,13 @@ interface PresenceInfo {
|
|
|
122
184
|
x: number;
|
|
123
185
|
y: number;
|
|
124
186
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
187
|
+
focusNode?: string;
|
|
188
|
+
selection?: PresenceSelection;
|
|
189
|
+
typing?: PresenceTyping;
|
|
190
|
+
scroll?: PresenceScroll;
|
|
191
|
+
viewport?: PresenceViewport;
|
|
192
|
+
inputState?: PresenceInputState;
|
|
193
|
+
emotion?: PresenceEmotion;
|
|
129
194
|
metadata?: Record<string, unknown>;
|
|
130
195
|
lastActivity: number;
|
|
131
196
|
}
|
|
@@ -143,4 +208,4 @@ interface IEventEmitter {
|
|
|
143
208
|
emit<T = unknown>(event: string, data?: T): void;
|
|
144
209
|
}
|
|
145
210
|
|
|
146
|
-
export type { BandwidthProfile, CRDTOperation, ConflictDetectionResult, EventCallback, EventUnsubscribe, IEventEmitter, NetworkState, Operation, OperationPriority, OperationStatus, OperationType, PresenceInfo, ResolutionStrategy, SyncBatch, SyncCoordinatorConfig, SyncResult, VectorClock };
|
|
211
|
+
export type { BandwidthProfile, CRDTOperation, ConflictDetectionResult, EventCallback, EventUnsubscribe, IEventEmitter, NetworkState, Operation, OperationPriority, OperationStatus, OperationType, PresenceEmotion, PresenceInfo, PresenceInputState, PresenceScroll, PresenceSelection, PresenceTyping, PresenceViewport, ResolutionStrategy, SyncBatch, SyncCoordinatorConfig, SyncResult, VectorClock };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/crypto/types.ts
|
|
4
|
+
var AEON_CAPABILITIES = {
|
|
5
|
+
// Basic sync operations
|
|
6
|
+
SYNC_READ: "aeon:sync:read",
|
|
7
|
+
SYNC_WRITE: "aeon:sync:write",
|
|
8
|
+
SYNC_ADMIN: "aeon:sync:admin",
|
|
9
|
+
// Node operations
|
|
10
|
+
NODE_REGISTER: "aeon:node:register",
|
|
11
|
+
NODE_HEARTBEAT: "aeon:node:heartbeat",
|
|
12
|
+
// Replication operations
|
|
13
|
+
REPLICATE_READ: "aeon:replicate:read",
|
|
14
|
+
REPLICATE_WRITE: "aeon:replicate:write",
|
|
15
|
+
// State operations
|
|
16
|
+
STATE_READ: "aeon:state:read",
|
|
17
|
+
STATE_WRITE: "aeon:state:write",
|
|
18
|
+
STATE_RECONCILE: "aeon:state:reconcile"
|
|
19
|
+
};
|
|
20
|
+
var DEFAULT_CRYPTO_CONFIG = {
|
|
21
|
+
defaultEncryptionMode: "none",
|
|
22
|
+
requireSignatures: false,
|
|
23
|
+
requireCapabilities: false,
|
|
24
|
+
allowedSignatureAlgorithms: ["ES256", "Ed25519"],
|
|
25
|
+
allowedEncryptionAlgorithms: ["ECIES-P256", "AES-256-GCM"],
|
|
26
|
+
sessionKeyExpiration: 24 * 60 * 60 * 1e3
|
|
27
|
+
// 24 hours
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/crypto/CryptoProvider.ts
|
|
31
|
+
var NullCryptoProvider = class {
|
|
32
|
+
notConfiguredError() {
|
|
33
|
+
return new Error("Crypto provider not configured");
|
|
34
|
+
}
|
|
35
|
+
async generateIdentity() {
|
|
36
|
+
throw this.notConfiguredError();
|
|
37
|
+
}
|
|
38
|
+
getLocalDID() {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
async exportPublicIdentity() {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
async registerRemoteNode() {
|
|
45
|
+
}
|
|
46
|
+
async getRemotePublicKey() {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
async sign() {
|
|
50
|
+
throw this.notConfiguredError();
|
|
51
|
+
}
|
|
52
|
+
async signData(_data) {
|
|
53
|
+
throw this.notConfiguredError();
|
|
54
|
+
}
|
|
55
|
+
async verify() {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
async verifySignedData() {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
async encrypt() {
|
|
62
|
+
throw this.notConfiguredError();
|
|
63
|
+
}
|
|
64
|
+
async decrypt() {
|
|
65
|
+
throw this.notConfiguredError();
|
|
66
|
+
}
|
|
67
|
+
async getSessionKey() {
|
|
68
|
+
throw this.notConfiguredError();
|
|
69
|
+
}
|
|
70
|
+
async encryptWithSessionKey() {
|
|
71
|
+
throw this.notConfiguredError();
|
|
72
|
+
}
|
|
73
|
+
async decryptWithSessionKey() {
|
|
74
|
+
throw this.notConfiguredError();
|
|
75
|
+
}
|
|
76
|
+
async createUCAN() {
|
|
77
|
+
throw this.notConfiguredError();
|
|
78
|
+
}
|
|
79
|
+
async verifyUCAN() {
|
|
80
|
+
return { authorized: true };
|
|
81
|
+
}
|
|
82
|
+
async delegateCapabilities() {
|
|
83
|
+
throw this.notConfiguredError();
|
|
84
|
+
}
|
|
85
|
+
async hash() {
|
|
86
|
+
throw this.notConfiguredError();
|
|
87
|
+
}
|
|
88
|
+
randomBytes(length) {
|
|
89
|
+
return crypto.getRandomValues(new Uint8Array(length));
|
|
90
|
+
}
|
|
91
|
+
isInitialized() {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
exports.AEON_CAPABILITIES = AEON_CAPABILITIES;
|
|
97
|
+
exports.DEFAULT_CRYPTO_CONFIG = DEFAULT_CRYPTO_CONFIG;
|
|
98
|
+
exports.NullCryptoProvider = NullCryptoProvider;
|
|
99
|
+
//# sourceMappingURL=index.cjs.map
|
|
100
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/crypto/types.ts","../../src/crypto/CryptoProvider.ts"],"names":[],"mappings":"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","file":"index.cjs","sourcesContent":["/**\n * Aeon Crypto Types\n *\n * Type definitions for cryptographic operations in Aeon.\n * These are compatible with @affectively/ucan and @affectively/zk-encryption.\n */\n\n// =============================================================================\n// IDENTITY TYPES (compatible with @affectively/ucan)\n// =============================================================================\n\n/**\n * Decentralized Identifier (DID)\n * Format: did:method:identifier\n */\nexport type DID = `did:${string}:${string}`;\n\n/**\n * Supported signing algorithms\n */\nexport type SigningAlgorithm = 'ES256' | 'Ed25519' | 'ES384' | 'ES512';\n\n/**\n * Key pair for signing and verification\n */\nexport interface KeyPair {\n algorithm: SigningAlgorithm;\n publicKey: JsonWebKey;\n privateKey?: JsonWebKey;\n fingerprint: string;\n}\n\n/**\n * Identity representing a user or node\n */\nexport interface Identity {\n did: DID;\n signingKey: KeyPair;\n encryptionKey?: KeyPair;\n createdAt: number;\n displayName?: string;\n}\n\n/**\n * UCAN Capability structure\n */\nexport interface Capability {\n can: string;\n with: string;\n constraints?: Record<string, unknown>;\n}\n\n/**\n * UCAN Token payload\n */\nexport interface UCANPayload {\n iss: DID;\n aud: DID;\n exp: number;\n nbf?: number;\n iat?: number;\n nonce?: string;\n jti?: string;\n att: Capability[];\n prf?: string[];\n fct?: Record<string, unknown>;\n}\n\n/**\n * Parsed UCAN Token\n */\nexport interface UCANToken {\n payload: UCANPayload;\n raw: string;\n signature: Uint8Array;\n algorithm: string;\n}\n\n/**\n * UCAN verification result\n */\nexport interface VerificationResult {\n valid: boolean;\n payload?: UCANPayload;\n error?: string;\n expired?: boolean;\n shouldRotate?: boolean;\n expiresIn?: number;\n}\n\n// =============================================================================\n// ENCRYPTION TYPES (compatible with @affectively/zk-encryption)\n// =============================================================================\n\n/**\n * Encryption algorithms supported\n */\nexport type EncryptionAlgorithm = 'ECIES-P256' | 'AES-256-GCM';\n\n/**\n * HKDF domain separator categories\n */\nexport type DomainCategory =\n | 'default'\n | 'sync'\n | 'message'\n | 'api-key'\n | 'personal-data'\n | string;\n\n/**\n * EC Key pair for ECDH operations\n */\nexport interface ECKeyPair {\n publicKey: JsonWebKey;\n privateKey: JsonWebKey;\n keyId: string;\n createdAt: string;\n}\n\n/**\n * Encrypted data envelope\n */\nexport interface EncryptedPayload {\n alg: EncryptionAlgorithm;\n ct: string;\n iv: string;\n tag: string;\n epk?: JsonWebKey;\n category?: DomainCategory;\n nonce?: string;\n encryptedAt: number;\n}\n\n/**\n * Decryption result\n */\nexport interface DecryptionResult {\n plaintext: Uint8Array;\n category?: DomainCategory;\n encryptedAt: number;\n}\n\n// =============================================================================\n// AEON-SPECIFIC TYPES\n// =============================================================================\n\n/**\n * Aeon encryption mode\n */\nexport type AeonEncryptionMode =\n | 'none' // No encryption (development/testing)\n | 'transport' // Encrypt in transit only (session keys)\n | 'at-rest' // Encrypt for storage\n | 'end-to-end'; // Full E2E encryption between nodes\n\n/**\n * Aeon sync capability namespace\n */\nexport const AEON_CAPABILITIES = {\n // Basic sync operations\n SYNC_READ: 'aeon:sync:read',\n SYNC_WRITE: 'aeon:sync:write',\n SYNC_ADMIN: 'aeon:sync:admin',\n\n // Node operations\n NODE_REGISTER: 'aeon:node:register',\n NODE_HEARTBEAT: 'aeon:node:heartbeat',\n\n // Replication operations\n REPLICATE_READ: 'aeon:replicate:read',\n REPLICATE_WRITE: 'aeon:replicate:write',\n\n // State operations\n STATE_READ: 'aeon:state:read',\n STATE_WRITE: 'aeon:state:write',\n STATE_RECONCILE: 'aeon:state:reconcile',\n} as const;\n\nexport type AeonCapability =\n (typeof AEON_CAPABILITIES)[keyof typeof AEON_CAPABILITIES];\n\n/**\n * Crypto configuration for Aeon\n */\nexport interface AeonCryptoConfig {\n /** Default encryption mode for sync messages */\n defaultEncryptionMode: AeonEncryptionMode;\n /** Require all messages to be signed */\n requireSignatures: boolean;\n /** Require UCAN capability verification */\n requireCapabilities: boolean;\n /** Allowed signature algorithms */\n allowedSignatureAlgorithms: string[];\n /** Allowed encryption algorithms */\n allowedEncryptionAlgorithms: string[];\n /** UCAN audience DID for verification */\n ucanAudience?: string;\n /** Session key expiration (ms) */\n sessionKeyExpiration?: number;\n}\n\n/**\n * Default crypto configuration\n */\nexport const DEFAULT_CRYPTO_CONFIG: AeonCryptoConfig = {\n defaultEncryptionMode: 'none',\n requireSignatures: false,\n requireCapabilities: false,\n allowedSignatureAlgorithms: ['ES256', 'Ed25519'],\n allowedEncryptionAlgorithms: ['ECIES-P256', 'AES-256-GCM'],\n sessionKeyExpiration: 24 * 60 * 60 * 1000, // 24 hours\n};\n\n/**\n * Authenticated sync message fields\n */\nexport interface AuthenticatedMessageFields {\n /** Sender DID */\n senderDID?: string;\n /** Receiver DID */\n receiverDID?: string;\n /** UCAN token for capability verification */\n ucan?: string;\n /** Message signature (base64url) */\n signature?: string;\n /** Whether payload is encrypted */\n encrypted?: boolean;\n}\n\n/**\n * Secure sync session\n */\nexport interface SecureSyncSession {\n id: string;\n initiator: string;\n participants: string[];\n sessionKey?: Uint8Array;\n encryptionMode: AeonEncryptionMode;\n requiredCapabilities: string[];\n status: 'pending' | 'active' | 'completed' | 'failed';\n startTime: string;\n endTime?: string;\n}\n\n/**\n * Node with identity information\n */\nexport interface SecureNodeInfo {\n id: string;\n did?: string;\n publicSigningKey?: JsonWebKey;\n publicEncryptionKey?: JsonWebKey;\n capabilities?: string[];\n lastSeen?: number;\n}\n\n/**\n * Capability verification result\n */\nexport interface AeonCapabilityResult {\n authorized: boolean;\n error?: string;\n issuer?: string;\n grantedCapabilities?: Array<{ can: string; with: string }>;\n}\n\n/**\n * Signed data envelope for sync operations\n */\nexport interface SignedSyncData<T = unknown> {\n payload: T;\n signature: string;\n signer: string;\n algorithm: string;\n signedAt: number;\n}\n","/**\n * Aeon Crypto Provider Interface\n *\n * Abstract interface for cryptographic operations.\n * Aeon core remains zero-dependency - crypto is injected through this interface.\n */\n\nimport type {\n AeonCapabilityResult,\n SignedSyncData,\n SecureNodeInfo,\n} from './types';\n\n/**\n * Abstract crypto provider interface\n *\n * Implementations use @affectively/ucan and @affectively/zk-encryption\n * or other compatible libraries.\n */\nexport interface ICryptoProvider {\n // ===========================================================================\n // IDENTITY OPERATIONS\n // ===========================================================================\n\n /**\n * Generate a new identity with DID and key pairs\n */\n generateIdentity(displayName?: string): Promise<{\n did: string;\n publicSigningKey: JsonWebKey;\n publicEncryptionKey?: JsonWebKey;\n }>;\n\n /**\n * Get the local identity's DID\n */\n getLocalDID(): string | null;\n\n /**\n * Export local identity's public info for sharing\n */\n exportPublicIdentity(): Promise<SecureNodeInfo | null>;\n\n /**\n * Register a known remote node's public keys\n */\n registerRemoteNode(node: SecureNodeInfo): Promise<void>;\n\n /**\n * Get a remote node's public key\n */\n getRemotePublicKey(did: string): Promise<JsonWebKey | null>;\n\n // ===========================================================================\n // SIGNING OPERATIONS\n // ===========================================================================\n\n /**\n * Sign data with local identity's private key\n */\n sign(data: Uint8Array): Promise<Uint8Array>;\n\n /**\n * Sign structured data and wrap in SignedSyncData envelope\n */\n signData<T>(data: T): Promise<SignedSyncData<T>>;\n\n /**\n * Verify a signature from a remote node\n */\n verify(\n did: string,\n signature: Uint8Array,\n data: Uint8Array,\n ): Promise<boolean>;\n\n /**\n * Verify a SignedSyncData envelope\n */\n verifySignedData<T>(signedData: SignedSyncData<T>): Promise<boolean>;\n\n // ===========================================================================\n // ENCRYPTION OPERATIONS\n // ===========================================================================\n\n /**\n * Encrypt data for a recipient\n */\n encrypt(\n plaintext: Uint8Array,\n recipientDID: string,\n ): Promise<{\n alg: string;\n ct: string;\n iv: string;\n tag: string;\n epk?: JsonWebKey;\n encryptedAt: number;\n }>;\n\n /**\n * Decrypt data\n */\n decrypt(\n encrypted: {\n alg: string;\n ct: string;\n iv: string;\n tag: string;\n epk?: JsonWebKey;\n },\n senderDID?: string,\n ): Promise<Uint8Array>;\n\n /**\n * Derive or get a session key for communication with a peer\n */\n getSessionKey(peerDID: string): Promise<Uint8Array>;\n\n /**\n * Encrypt with a session key\n */\n encryptWithSessionKey(\n plaintext: Uint8Array,\n sessionKey: Uint8Array,\n ): Promise<{\n alg: string;\n ct: string;\n iv: string;\n tag: string;\n encryptedAt: number;\n }>;\n\n /**\n * Decrypt with a session key\n */\n decryptWithSessionKey(\n encrypted: {\n ct: string;\n iv: string;\n tag: string;\n },\n sessionKey: Uint8Array,\n ): Promise<Uint8Array>;\n\n // ===========================================================================\n // UCAN OPERATIONS\n // ===========================================================================\n\n /**\n * Create a UCAN token\n */\n createUCAN(\n audience: string,\n capabilities: Array<{ can: string; with: string }>,\n options?: {\n expirationSeconds?: number;\n proofs?: string[];\n },\n ): Promise<string>;\n\n /**\n * Verify a UCAN token\n */\n verifyUCAN(\n token: string,\n options?: {\n expectedAudience?: string;\n requiredCapabilities?: Array<{ can: string; with: string }>;\n },\n ): Promise<AeonCapabilityResult>;\n\n /**\n * Delegate capabilities\n */\n delegateCapabilities(\n parentToken: string,\n audience: string,\n capabilities: Array<{ can: string; with: string }>,\n options?: {\n expirationSeconds?: number;\n },\n ): Promise<string>;\n\n // ===========================================================================\n // UTILITY OPERATIONS\n // ===========================================================================\n\n /**\n * Compute hash of data\n */\n hash(data: Uint8Array): Promise<Uint8Array>;\n\n /**\n * Generate random bytes\n */\n randomBytes(length: number): Uint8Array;\n\n /**\n * Check if crypto is properly initialized\n */\n isInitialized(): boolean;\n}\n\n/**\n * Null crypto provider for when crypto is disabled\n *\n * All operations either throw or return permissive defaults.\n */\nexport class NullCryptoProvider implements ICryptoProvider {\n private notConfiguredError(): Error {\n return new Error('Crypto provider not configured');\n }\n\n async generateIdentity(): Promise<{\n did: string;\n publicSigningKey: JsonWebKey;\n publicEncryptionKey?: JsonWebKey;\n }> {\n throw this.notConfiguredError();\n }\n\n getLocalDID(): string | null {\n return null;\n }\n\n async exportPublicIdentity(): Promise<SecureNodeInfo | null> {\n return null;\n }\n\n async registerRemoteNode(): Promise<void> {\n // No-op when crypto disabled\n }\n\n async getRemotePublicKey(): Promise<JsonWebKey | null> {\n return null;\n }\n\n async sign(): Promise<Uint8Array> {\n throw this.notConfiguredError();\n }\n\n async signData<T>(_data: T): Promise<SignedSyncData<T>> {\n throw this.notConfiguredError();\n }\n\n async verify(): Promise<boolean> {\n // Permissive when crypto disabled\n return true;\n }\n\n async verifySignedData(): Promise<boolean> {\n // Permissive when crypto disabled\n return true;\n }\n\n async encrypt(): Promise<{\n alg: string;\n ct: string;\n iv: string;\n tag: string;\n epk?: JsonWebKey;\n encryptedAt: number;\n }> {\n throw this.notConfiguredError();\n }\n\n async decrypt(): Promise<Uint8Array> {\n throw this.notConfiguredError();\n }\n\n async getSessionKey(): Promise<Uint8Array> {\n throw this.notConfiguredError();\n }\n\n async encryptWithSessionKey(): Promise<{\n alg: string;\n ct: string;\n iv: string;\n tag: string;\n encryptedAt: number;\n }> {\n throw this.notConfiguredError();\n }\n\n async decryptWithSessionKey(): Promise<Uint8Array> {\n throw this.notConfiguredError();\n }\n\n async createUCAN(): Promise<string> {\n throw this.notConfiguredError();\n }\n\n async verifyUCAN(): Promise<AeonCapabilityResult> {\n // Permissive when crypto disabled\n return { authorized: true };\n }\n\n async delegateCapabilities(): Promise<string> {\n throw this.notConfiguredError();\n }\n\n async hash(): Promise<Uint8Array> {\n throw this.notConfiguredError();\n }\n\n randomBytes(length: number): Uint8Array {\n // Use crypto.getRandomValues even without full crypto setup\n return crypto.getRandomValues(new Uint8Array(length));\n }\n\n isInitialized(): boolean {\n return false;\n }\n}\n"]}
|