@originals/sdk 1.4.5 → 1.6.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/dist/adapters/FeeOracleMock.js +2 -2
- package/dist/bitcoin/OrdinalsClient.d.ts +1 -1
- package/dist/bitcoin/OrdinalsClient.js +10 -8
- package/dist/bitcoin/PSBTBuilder.js +1 -1
- package/dist/bitcoin/utxo-selection.js +2 -2
- package/dist/cel/ExternalReferenceManager.d.ts +57 -0
- package/dist/cel/ExternalReferenceManager.js +73 -0
- package/dist/cel/OriginalsCel.d.ts +245 -0
- package/dist/cel/OriginalsCel.js +349 -0
- package/dist/cel/algorithms/createEventLog.d.ts +32 -0
- package/dist/cel/algorithms/createEventLog.js +56 -0
- package/dist/cel/algorithms/deactivateEventLog.d.ts +35 -0
- package/dist/cel/algorithms/deactivateEventLog.js +91 -0
- package/dist/cel/algorithms/index.d.ts +10 -0
- package/dist/cel/algorithms/index.js +10 -0
- package/dist/cel/algorithms/updateEventLog.d.ts +34 -0
- package/dist/cel/algorithms/updateEventLog.js +82 -0
- package/dist/cel/algorithms/verifyEventLog.d.ts +45 -0
- package/dist/cel/algorithms/verifyEventLog.js +255 -0
- package/dist/cel/algorithms/witnessEvent.d.ts +29 -0
- package/dist/cel/algorithms/witnessEvent.js +75 -0
- package/dist/cel/cli/create.d.ts +36 -0
- package/dist/cel/cli/create.js +282 -0
- package/dist/cel/cli/index.d.ts +11 -0
- package/dist/cel/cli/index.js +351 -0
- package/dist/cel/cli/inspect.d.ts +30 -0
- package/dist/cel/cli/inspect.js +475 -0
- package/dist/cel/cli/migrate.d.ts +41 -0
- package/dist/cel/cli/migrate.js +405 -0
- package/dist/cel/cli/verify.d.ts +31 -0
- package/dist/cel/cli/verify.js +205 -0
- package/dist/cel/hash.d.ts +46 -0
- package/dist/cel/hash.js +66 -0
- package/dist/cel/index.d.ts +15 -0
- package/dist/cel/index.js +15 -0
- package/dist/cel/layers/BtcoCelManager.d.ts +121 -0
- package/dist/cel/layers/BtcoCelManager.js +329 -0
- package/dist/cel/layers/PeerCelManager.d.ts +151 -0
- package/dist/cel/layers/PeerCelManager.js +299 -0
- package/dist/cel/layers/WebVHCelManager.d.ts +122 -0
- package/dist/cel/layers/WebVHCelManager.js +291 -0
- package/dist/cel/layers/index.d.ts +13 -0
- package/dist/cel/layers/index.js +16 -0
- package/dist/cel/serialization/cbor.d.ts +42 -0
- package/dist/cel/serialization/cbor.js +163 -0
- package/dist/cel/serialization/index.d.ts +9 -0
- package/dist/cel/serialization/index.js +9 -0
- package/dist/cel/serialization/json.d.ts +41 -0
- package/dist/cel/serialization/json.js +180 -0
- package/dist/cel/types.d.ts +149 -0
- package/dist/cel/types.js +7 -0
- package/dist/cel/witnesses/BitcoinWitness.d.ts +83 -0
- package/dist/cel/witnesses/BitcoinWitness.js +116 -0
- package/dist/cel/witnesses/HttpWitness.d.ts +79 -0
- package/dist/cel/witnesses/HttpWitness.js +163 -0
- package/dist/cel/witnesses/WitnessService.d.ts +49 -0
- package/dist/cel/witnesses/WitnessService.js +10 -0
- package/dist/cel/witnesses/index.d.ts +10 -0
- package/dist/cel/witnesses/index.js +7 -0
- package/dist/core/OriginalsSDK.js +5 -1
- package/dist/crypto/Signer.js +14 -6
- package/dist/crypto/noble-init.js +20 -1
- package/dist/did/BtcoDidResolver.d.ts +2 -2
- package/dist/did/BtcoDidResolver.js +12 -8
- package/dist/did/DIDManager.js +6 -4
- package/dist/did/KeyManager.d.ts +1 -1
- package/dist/did/KeyManager.js +7 -4
- package/dist/did/WebVHManager.js +1 -1
- package/dist/did/createBtcoDidDocument.js +2 -1
- package/dist/events/types.d.ts +4 -1
- package/dist/examples/create-module-original.js +1 -1
- package/dist/examples/full-lifecycle-flow.js +2 -2
- package/dist/index.d.ts +13 -0
- package/dist/index.js +12 -0
- package/dist/kinds/KindRegistry.js +59 -29
- package/dist/lifecycle/BatchOperations.d.ts +5 -3
- package/dist/lifecycle/BatchOperations.js +11 -5
- package/dist/lifecycle/LifecycleManager.d.ts +1 -1
- package/dist/lifecycle/LifecycleManager.js +42 -33
- package/dist/lifecycle/OriginalsAsset.js +2 -2
- package/dist/migration/MigrationManager.js +67 -3
- package/dist/storage/LocalStorageAdapter.js +4 -1
- package/dist/storage/MemoryStorageAdapter.js +7 -7
- package/dist/types/network.js +6 -3
- package/dist/utils/Logger.d.ts +6 -6
- package/dist/utils/Logger.js +5 -3
- package/dist/utils/MetricsCollector.js +1 -1
- package/dist/utils/bitcoin-address.js +4 -2
- package/dist/utils/cbor.js +16 -3
- package/dist/utils/encoding.d.ts +4 -4
- package/dist/utils/encoding.js +7 -6
- package/dist/utils/hash.js +6 -1
- package/dist/utils/serialization.d.ts +2 -2
- package/dist/utils/serialization.js +7 -5
- package/dist/utils/telemetry.js +6 -2
- package/dist/utils/validation.js +8 -4
- package/dist/vc/CredentialManager.d.ts +8 -8
- package/dist/vc/CredentialManager.js +46 -33
- package/dist/vc/Issuer.d.ts +2 -2
- package/dist/vc/Issuer.js +5 -1
- package/dist/vc/Verifier.d.ts +2 -2
- package/dist/vc/Verifier.js +12 -6
- package/dist/vc/documentLoader.d.ts +5 -3
- package/dist/vc/documentLoader.js +5 -4
- package/package.json +4 -1
|
@@ -38,7 +38,9 @@ export class MigrationManager {
|
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
40
|
// Create stub implementations that throw errors
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
41
42
|
this.webvhToBtco = null;
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
42
44
|
this.peerToBtco = null;
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -65,14 +67,20 @@ export class MigrationManager {
|
|
|
65
67
|
*/
|
|
66
68
|
async migrate(options) {
|
|
67
69
|
const startTime = Date.now();
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
71
|
let migrationState;
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
73
|
let checkpoint;
|
|
70
74
|
try {
|
|
71
75
|
// Step 1: Create migration state
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
72
77
|
migrationState = await this.stateTracker.createMigration(options);
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
73
79
|
const migrationId = migrationState.migrationId;
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
74
81
|
await this.emitEvent('migration:started', { migrationId, options });
|
|
75
82
|
// Step 2: Validate migration
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
76
84
|
await this.stateTracker.updateState(migrationId, {
|
|
77
85
|
state: MigrationStateEnum.VALIDATING,
|
|
78
86
|
currentOperation: 'Validating migration',
|
|
@@ -80,46 +88,62 @@ export class MigrationManager {
|
|
|
80
88
|
});
|
|
81
89
|
const validationResult = await this.validationPipeline.validate(options);
|
|
82
90
|
if (!validationResult.valid) {
|
|
83
|
-
throw this.createMigrationError(MigrationErrorType.VALIDATION_ERROR, 'VALIDATION_FAILED', `Migration validation failed: ${validationResult.errors.map(e => e.message).join(', ')}`,
|
|
91
|
+
throw this.createMigrationError(MigrationErrorType.VALIDATION_ERROR, 'VALIDATION_FAILED', `Migration validation failed: ${validationResult.errors.map(e => e.message).join(', ')}`,
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
93
|
+
migrationId, { errors: validationResult.errors });
|
|
84
94
|
}
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
85
96
|
await this.emitEvent('migration:validated', { migrationId, validationResult });
|
|
86
97
|
// Step 3: Create checkpoint
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
87
99
|
await this.stateTracker.updateState(migrationId, {
|
|
88
100
|
state: MigrationStateEnum.CHECKPOINTED,
|
|
89
101
|
currentOperation: 'Creating checkpoint',
|
|
90
102
|
progress: 20
|
|
91
103
|
});
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment
|
|
92
105
|
checkpoint = await this.checkpointManager.createCheckpoint(migrationId, options);
|
|
93
106
|
// Persist checkpointId immediately so rollback can locate it
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
94
108
|
await this.stateTracker.updateState(migrationId, {
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
95
110
|
checkpointId: checkpoint.checkpointId
|
|
96
111
|
});
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
97
113
|
await this.emitEvent('migration:checkpointed', { migrationId, checkpointId: checkpoint.checkpointId });
|
|
98
114
|
// Step 4: Execute migration
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
99
116
|
const migration = this.getMigrationOperation(options);
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-argument
|
|
100
118
|
const result = await migration.executeMigration(options, migrationId);
|
|
101
119
|
// Step 5: Complete migration
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
102
121
|
await this.stateTracker.updateState(migrationId, {
|
|
103
122
|
state: MigrationStateEnum.COMPLETED,
|
|
104
123
|
currentOperation: 'Completed',
|
|
105
124
|
progress: 100,
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
106
126
|
targetDid: result.targetDid
|
|
107
127
|
});
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
108
129
|
await this.emitEvent('migration:completed', { migrationId, targetDid: result.targetDid });
|
|
109
130
|
// Step 6: Create audit record
|
|
110
131
|
const duration = Date.now() - startTime;
|
|
111
132
|
const auditRecord = {
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
112
134
|
migrationId,
|
|
113
135
|
timestamp: startTime,
|
|
114
136
|
initiator: 'system',
|
|
115
137
|
sourceDid: options.sourceDid,
|
|
116
138
|
sourceLayer: this.extractLayer(options.sourceDid),
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
117
140
|
targetDid: result.targetDid,
|
|
118
141
|
targetLayer: options.targetLayer,
|
|
119
142
|
finalState: MigrationStateEnum.COMPLETED,
|
|
120
143
|
validationResults: validationResult,
|
|
121
144
|
costActual: validationResult.estimatedCost,
|
|
122
145
|
duration,
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
123
147
|
checkpointId: checkpoint.checkpointId,
|
|
124
148
|
errors: [],
|
|
125
149
|
metadata: options.metadata || {}
|
|
@@ -129,12 +153,15 @@ export class MigrationManager {
|
|
|
129
153
|
this.storeAuditRecordInMemory(auditRecord);
|
|
130
154
|
// Clean up checkpoint after successful migration
|
|
131
155
|
setTimeout(() => {
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-floating-promises
|
|
132
157
|
this.checkpointManager.deleteCheckpoint(checkpoint.checkpointId);
|
|
133
158
|
}, 24 * 60 * 60 * 1000); // Delete after 24 hours
|
|
134
159
|
return {
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
135
161
|
migrationId,
|
|
136
162
|
success: true,
|
|
137
163
|
sourceDid: options.sourceDid,
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
138
165
|
targetDid: result.targetDid,
|
|
139
166
|
sourceLayer: this.extractLayer(options.sourceDid),
|
|
140
167
|
targetLayer: options.targetLayer,
|
|
@@ -155,6 +182,7 @@ export class MigrationManager {
|
|
|
155
182
|
async estimateMigrationCost(sourceDid, targetLayer, feeRate) {
|
|
156
183
|
const options = {
|
|
157
184
|
sourceDid,
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
158
186
|
targetLayer: targetLayer,
|
|
159
187
|
feeRate,
|
|
160
188
|
estimateCostOnly: true
|
|
@@ -165,12 +193,14 @@ export class MigrationManager {
|
|
|
165
193
|
/**
|
|
166
194
|
* Get migration status
|
|
167
195
|
*/
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
197
|
async getMigrationStatus(migrationId) {
|
|
169
198
|
return await this.stateTracker.getState(migrationId);
|
|
170
199
|
}
|
|
171
200
|
/**
|
|
172
201
|
* Rollback a migration
|
|
173
202
|
*/
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
204
|
async rollback(migrationId) {
|
|
175
205
|
const state = await this.stateTracker.getState(migrationId);
|
|
176
206
|
if (!state || !state.checkpointId) {
|
|
@@ -185,7 +215,9 @@ export class MigrationManager {
|
|
|
185
215
|
* TODO: AuditLogger temporarily disabled for v1.0 release
|
|
186
216
|
* Returns in-memory audit records (unsigned) - will use proper AuditLogger in v1.1
|
|
187
217
|
*/
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-explicit-any
|
|
188
219
|
async getMigrationHistory(did) {
|
|
220
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
189
221
|
return this.inMemoryAuditRecords.get(did) || [];
|
|
190
222
|
}
|
|
191
223
|
/**
|
|
@@ -244,13 +276,25 @@ export class MigrationManager {
|
|
|
244
276
|
/**
|
|
245
277
|
* Handle migration failure with automatic rollback
|
|
246
278
|
*/
|
|
247
|
-
async handleMigrationFailure(
|
|
279
|
+
async handleMigrationFailure(
|
|
280
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
281
|
+
error, options,
|
|
282
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
283
|
+
migrationState,
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
285
|
+
checkpoint, startTime) {
|
|
286
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
248
287
|
const migrationId = migrationState?.migrationId || `mig_failed_${Date.now()}`;
|
|
249
288
|
const migrationError = {
|
|
289
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
250
290
|
type: error.type || MigrationErrorType.UNKNOWN_ERROR,
|
|
291
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
251
292
|
code: error.code || 'MIGRATION_FAILED',
|
|
293
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
252
294
|
message: error.message || String(error),
|
|
295
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
253
296
|
technicalDetails: error.stack,
|
|
297
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
254
298
|
migrationId,
|
|
255
299
|
sourceDid: options.sourceDid,
|
|
256
300
|
timestamp: Date.now()
|
|
@@ -258,6 +302,7 @@ export class MigrationManager {
|
|
|
258
302
|
// Update state to failed
|
|
259
303
|
if (migrationState) {
|
|
260
304
|
try {
|
|
305
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
261
306
|
await this.stateTracker.updateState(migrationId, {
|
|
262
307
|
state: MigrationStateEnum.FAILED,
|
|
263
308
|
error: migrationError
|
|
@@ -272,11 +317,15 @@ export class MigrationManager {
|
|
|
272
317
|
let rollbackSuccess = false;
|
|
273
318
|
if (checkpoint) {
|
|
274
319
|
try {
|
|
320
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
275
321
|
const rollbackResult = await this.rollbackManager.rollback(migrationId, checkpoint.checkpointId);
|
|
322
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
276
323
|
rollbackSuccess = rollbackResult.success;
|
|
277
324
|
if (!rollbackSuccess) {
|
|
325
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
278
326
|
await this.emitEvent('migration:quarantine', {
|
|
279
327
|
migrationId,
|
|
328
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
280
329
|
checkpointId: checkpoint.checkpointId,
|
|
281
330
|
reason: 'Rollback failed'
|
|
282
331
|
});
|
|
@@ -284,8 +333,10 @@ export class MigrationManager {
|
|
|
284
333
|
}
|
|
285
334
|
catch (rollbackError) {
|
|
286
335
|
console.error('Rollback failed:', rollbackError);
|
|
336
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
287
337
|
await this.emitEvent('migration:quarantine', {
|
|
288
338
|
migrationId,
|
|
339
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
289
340
|
checkpointId: checkpoint.checkpointId,
|
|
290
341
|
reason: rollbackError instanceof Error ? rollbackError.message : String(rollbackError)
|
|
291
342
|
});
|
|
@@ -294,6 +345,7 @@ export class MigrationManager {
|
|
|
294
345
|
// Create audit record
|
|
295
346
|
const duration = Date.now() - startTime;
|
|
296
347
|
const auditRecord = {
|
|
348
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
297
349
|
migrationId,
|
|
298
350
|
timestamp: startTime,
|
|
299
351
|
initiator: 'system',
|
|
@@ -311,6 +363,7 @@ export class MigrationManager {
|
|
|
311
363
|
},
|
|
312
364
|
costActual: { storageCost: 0, networkFees: 0, totalCost: 0, estimatedDuration: duration, currency: 'sats' },
|
|
313
365
|
duration,
|
|
366
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
314
367
|
checkpointId: checkpoint?.checkpointId || '',
|
|
315
368
|
errors: [migrationError],
|
|
316
369
|
metadata: options.metadata || {}
|
|
@@ -334,6 +387,7 @@ export class MigrationManager {
|
|
|
334
387
|
/**
|
|
335
388
|
* Get appropriate migration operation handler
|
|
336
389
|
*/
|
|
390
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
337
391
|
getMigrationOperation(options) {
|
|
338
392
|
const sourceLayer = this.extractLayer(options.sourceDid);
|
|
339
393
|
if (sourceLayer === 'peer' && options.targetLayer === 'webvh') {
|
|
@@ -358,15 +412,21 @@ export class MigrationManager {
|
|
|
358
412
|
* Stores by both source and target DID for easy lookup
|
|
359
413
|
* TODO: Remove in v1.1 when AuditLogger is re-enabled with signatures
|
|
360
414
|
*/
|
|
415
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
361
416
|
storeAuditRecordInMemory(record) {
|
|
362
417
|
// Store by source DID
|
|
418
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
363
419
|
const sourceRecords = this.inMemoryAuditRecords.get(record.sourceDid) || [];
|
|
364
420
|
sourceRecords.push(record);
|
|
421
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
365
422
|
this.inMemoryAuditRecords.set(record.sourceDid, sourceRecords);
|
|
366
423
|
// Also store by target DID if available
|
|
424
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
367
425
|
if (record.targetDid) {
|
|
426
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
368
427
|
const targetRecords = this.inMemoryAuditRecords.get(record.targetDid) || [];
|
|
369
428
|
targetRecords.push(record);
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
370
430
|
this.inMemoryAuditRecords.set(record.targetDid, targetRecords);
|
|
371
431
|
}
|
|
372
432
|
}
|
|
@@ -385,7 +445,9 @@ export class MigrationManager {
|
|
|
385
445
|
/**
|
|
386
446
|
* Create migration error
|
|
387
447
|
*/
|
|
388
|
-
createMigrationError(type, code, message, migrationId,
|
|
448
|
+
createMigrationError(type, code, message, migrationId,
|
|
449
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
450
|
+
details) {
|
|
389
451
|
const error = new Error(message);
|
|
390
452
|
error.type = type;
|
|
391
453
|
error.code = code;
|
|
@@ -396,8 +458,10 @@ export class MigrationManager {
|
|
|
396
458
|
/**
|
|
397
459
|
* Emit event
|
|
398
460
|
*/
|
|
461
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
399
462
|
async emitEvent(type, data) {
|
|
400
463
|
try {
|
|
464
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
401
465
|
await this.eventEmitter.emit({
|
|
402
466
|
type,
|
|
403
467
|
timestamp: new Date().toISOString(),
|
|
@@ -35,7 +35,10 @@ export class LocalStorageAdapter {
|
|
|
35
35
|
return { content: new Uint8Array(content) };
|
|
36
36
|
}
|
|
37
37
|
catch (e) {
|
|
38
|
-
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
|
|
39
|
+
const error = e;
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
41
|
+
if (error && error.code === 'ENOENT')
|
|
39
42
|
return null;
|
|
40
43
|
throw e;
|
|
41
44
|
}
|
|
@@ -4,18 +4,18 @@ function key(domain, objectPath) {
|
|
|
4
4
|
return `${domain}::${cleanPath}`;
|
|
5
5
|
}
|
|
6
6
|
export class MemoryStorageAdapter {
|
|
7
|
-
|
|
7
|
+
putObject(domain, objectPath, content) {
|
|
8
8
|
const data = typeof content === 'string' ? new TextEncoder().encode(content) : content;
|
|
9
9
|
globalStore.set(key(domain, objectPath), data);
|
|
10
|
-
return `mem://${domain}/${objectPath.replace(/^\/+/, '')}
|
|
10
|
+
return Promise.resolve(`mem://${domain}/${objectPath.replace(/^\/+/, '')}`);
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
getObject(domain, objectPath) {
|
|
13
13
|
const stored = globalStore.get(key(domain, objectPath));
|
|
14
14
|
if (!stored)
|
|
15
|
-
return null;
|
|
16
|
-
return { content: stored };
|
|
15
|
+
return Promise.resolve(null);
|
|
16
|
+
return Promise.resolve({ content: stored });
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
return globalStore.has(key(domain, objectPath));
|
|
18
|
+
exists(domain, objectPath) {
|
|
19
|
+
return Promise.resolve(globalStore.has(key(domain, objectPath)));
|
|
20
20
|
}
|
|
21
21
|
}
|
package/dist/types/network.js
CHANGED
|
@@ -80,7 +80,7 @@ export function validateVersionForNetwork(version, network) {
|
|
|
80
80
|
if (!match) {
|
|
81
81
|
throw new Error(`Invalid version format: ${version}. Expected semver format (e.g., 1.2.3)`);
|
|
82
82
|
}
|
|
83
|
-
const [,
|
|
83
|
+
const [, , minor, patch] = match;
|
|
84
84
|
switch (config.stability) {
|
|
85
85
|
case 'major':
|
|
86
86
|
// Pichu: Only allow major releases (X.0.0)
|
|
@@ -91,8 +91,11 @@ export function validateVersionForNetwork(version, network) {
|
|
|
91
91
|
case 'patch':
|
|
92
92
|
// Magby: Allow all versions including patches
|
|
93
93
|
return true;
|
|
94
|
-
default:
|
|
95
|
-
|
|
94
|
+
default: {
|
|
95
|
+
// TypeScript exhaustiveness check
|
|
96
|
+
const _exhaustive = config.stability;
|
|
97
|
+
throw new Error(`Unknown stability level: ${String(_exhaustive)}`);
|
|
98
|
+
}
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
/**
|
package/dist/utils/Logger.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface LogEntry {
|
|
|
22
22
|
level: LogLevel;
|
|
23
23
|
context: string;
|
|
24
24
|
message: string;
|
|
25
|
-
data?:
|
|
25
|
+
data?: unknown;
|
|
26
26
|
duration?: number;
|
|
27
27
|
traceId?: string;
|
|
28
28
|
}
|
|
@@ -47,7 +47,7 @@ export declare class FileLogOutput implements LogOutput {
|
|
|
47
47
|
private flushTimeout;
|
|
48
48
|
private readonly flushInterval;
|
|
49
49
|
constructor(filePath: string);
|
|
50
|
-
write(entry: LogEntry):
|
|
50
|
+
write(entry: LogEntry): void;
|
|
51
51
|
private flush;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -65,19 +65,19 @@ export declare class Logger {
|
|
|
65
65
|
/**
|
|
66
66
|
* Log a debug message
|
|
67
67
|
*/
|
|
68
|
-
debug(message: string, data?:
|
|
68
|
+
debug(message: string, data?: unknown): void;
|
|
69
69
|
/**
|
|
70
70
|
* Log an info message
|
|
71
71
|
*/
|
|
72
|
-
info(message: string, data?:
|
|
72
|
+
info(message: string, data?: unknown): void;
|
|
73
73
|
/**
|
|
74
74
|
* Log a warning message
|
|
75
75
|
*/
|
|
76
|
-
warn(message: string, data?:
|
|
76
|
+
warn(message: string, data?: unknown): void;
|
|
77
77
|
/**
|
|
78
78
|
* Log an error message
|
|
79
79
|
*/
|
|
80
|
-
error(message: string, error?: Error, data?:
|
|
80
|
+
error(message: string, error?: Error, data?: unknown): void;
|
|
81
81
|
/**
|
|
82
82
|
* Start a timer for performance tracking
|
|
83
83
|
* Returns a function that stops the timer and logs the duration
|
package/dist/utils/Logger.js
CHANGED
|
@@ -47,13 +47,15 @@ export class FileLogOutput {
|
|
|
47
47
|
this.flushTimeout = null;
|
|
48
48
|
this.flushInterval = 1000; // Flush every 1 second
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
write(entry) {
|
|
51
51
|
// Format as JSON line
|
|
52
52
|
const line = JSON.stringify(entry) + '\n';
|
|
53
53
|
this.buffer.push(line);
|
|
54
54
|
// Schedule flush
|
|
55
55
|
if (!this.flushTimeout) {
|
|
56
|
-
this.flushTimeout = setTimeout(() =>
|
|
56
|
+
this.flushTimeout = setTimeout(() => {
|
|
57
|
+
void this.flush();
|
|
58
|
+
}, this.flushInterval);
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
async flush() {
|
|
@@ -126,7 +128,7 @@ export class Logger {
|
|
|
126
128
|
*/
|
|
127
129
|
error(message, error, data) {
|
|
128
130
|
const errorData = error ? {
|
|
129
|
-
...data,
|
|
131
|
+
...(data && typeof data === 'object' ? data : {}),
|
|
130
132
|
error: {
|
|
131
133
|
name: error.name,
|
|
132
134
|
message: error.message,
|
|
@@ -181,7 +181,7 @@ export class MetricsCollector {
|
|
|
181
181
|
else if (format === 'prometheus') {
|
|
182
182
|
return this.exportPrometheus();
|
|
183
183
|
}
|
|
184
|
-
throw new Error(`Unsupported export format: ${format}`);
|
|
184
|
+
throw new Error(`Unsupported export format: ${String(format)}`);
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
187
|
* Export metrics as JSON
|
|
@@ -14,8 +14,10 @@ const getNetwork = (network) => {
|
|
|
14
14
|
case 'signet':
|
|
15
15
|
// Signet uses the same bech32 prefix as testnet (tb1)
|
|
16
16
|
return bitcoin.networks.testnet;
|
|
17
|
-
default:
|
|
18
|
-
|
|
17
|
+
default: {
|
|
18
|
+
const exhaustiveCheck = network;
|
|
19
|
+
throw new Error(`Unsupported network: ${String(exhaustiveCheck)}`);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
23
|
/**
|
package/dist/utils/cbor.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import * as cbor from 'cbor-js';
|
|
2
2
|
export function encode(input) {
|
|
3
|
-
const
|
|
3
|
+
const cborTyped = cbor;
|
|
4
|
+
const encoded = cborTyped.encode(input);
|
|
4
5
|
return new Uint8Array(encoded);
|
|
5
6
|
}
|
|
6
7
|
export function decode(bytes) {
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const cborTyped = cbor;
|
|
9
|
+
let arrayBuffer;
|
|
10
|
+
if (bytes instanceof ArrayBuffer) {
|
|
11
|
+
arrayBuffer = bytes;
|
|
12
|
+
}
|
|
13
|
+
else if (bytes instanceof Uint8Array) {
|
|
14
|
+
arrayBuffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
// Buffer - explicitly handle Buffer type
|
|
18
|
+
const bufferInstance = bytes;
|
|
19
|
+
arrayBuffer = bufferInstance.buffer.slice(bufferInstance.byteOffset, bufferInstance.byteOffset + bufferInstance.byteLength);
|
|
20
|
+
}
|
|
21
|
+
return cborTyped.decode(arrayBuffer);
|
|
9
22
|
}
|
package/dist/utils/encoding.d.ts
CHANGED
|
@@ -12,16 +12,16 @@ export declare const MULTICODEC_SECP256K1_PRIV_HEADER: Uint8Array<ArrayBuffer>;
|
|
|
12
12
|
export declare const MULTICODEC_BLS12381_G2_PUB_HEADER: Uint8Array<ArrayBuffer>;
|
|
13
13
|
export declare const MULTICODEC_BLS12381_G2_PRIV_HEADER: Uint8Array<ArrayBuffer>;
|
|
14
14
|
export declare const base64: {
|
|
15
|
-
encode: (unencoded:
|
|
16
|
-
decode: (encoded:
|
|
15
|
+
encode: (unencoded: string | Uint8Array) => string;
|
|
16
|
+
decode: (encoded: string) => Uint8Array;
|
|
17
17
|
};
|
|
18
18
|
export declare const utf8: {
|
|
19
19
|
encode: (unencoded: string) => Uint8Array;
|
|
20
20
|
decode: (encoded: Uint8Array) => string;
|
|
21
21
|
};
|
|
22
22
|
export declare const base64url: {
|
|
23
|
-
encode: (unencoded:
|
|
24
|
-
decode: (encoded:
|
|
23
|
+
encode: (unencoded: string | Uint8Array) => string;
|
|
24
|
+
decode: (encoded: string) => Uint8Array;
|
|
25
25
|
};
|
|
26
26
|
export declare const base58: {
|
|
27
27
|
encode: (unencoded: Uint8Array) => string;
|
package/dist/utils/encoding.js
CHANGED
|
@@ -66,18 +66,19 @@ export const base64url = {
|
|
|
66
66
|
return encoded.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
|
|
67
67
|
},
|
|
68
68
|
decode: (encoded) => {
|
|
69
|
-
|
|
70
|
-
while (
|
|
71
|
-
|
|
72
|
-
return base64.decode(
|
|
69
|
+
let padded = encoded.replace(/-/g, '+').replace(/_/g, '/');
|
|
70
|
+
while (padded.length % 4)
|
|
71
|
+
padded += '=';
|
|
72
|
+
return base64.decode(padded);
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
+
const b58Typed = b58;
|
|
75
76
|
export const base58 = {
|
|
76
77
|
encode: (unencoded) => {
|
|
77
|
-
return
|
|
78
|
+
return b58Typed.encode(unencoded);
|
|
78
79
|
},
|
|
79
80
|
decode: (encoded) => {
|
|
80
|
-
return
|
|
81
|
+
return b58Typed.decode(encoded);
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
84
|
export const multibase = {
|
package/dist/utils/hash.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export async function sha256Bytes(input) {
|
|
2
2
|
const data = typeof input === 'string' ? new TextEncoder().encode(input) : input;
|
|
3
|
-
|
|
3
|
+
// Type assertion for subtle crypto which exists in modern environments
|
|
4
|
+
const subtle = globalThis.crypto?.subtle;
|
|
5
|
+
if (!subtle) {
|
|
6
|
+
throw new Error('SubtleCrypto not available in this environment');
|
|
7
|
+
}
|
|
8
|
+
const digest = await subtle.digest('SHA-256', data);
|
|
4
9
|
return new Uint8Array(digest);
|
|
5
10
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { DIDDocument, VerifiableCredential } from '../types';
|
|
2
2
|
type DocumentLoader = (url: string) => Promise<{
|
|
3
3
|
documentUrl: string;
|
|
4
|
-
document:
|
|
4
|
+
document: unknown;
|
|
5
5
|
contextUrl: string | null;
|
|
6
6
|
}>;
|
|
7
7
|
export declare function serializeDIDDocument(didDoc: DIDDocument): string;
|
|
8
8
|
export declare function deserializeDIDDocument(data: string): DIDDocument;
|
|
9
9
|
export declare function serializeCredential(vc: VerifiableCredential): string;
|
|
10
10
|
export declare function deserializeCredential(data: string): VerifiableCredential;
|
|
11
|
-
export declare function canonicalizeDocument(doc:
|
|
11
|
+
export declare function canonicalizeDocument(doc: unknown, options?: {
|
|
12
12
|
documentLoader?: DocumentLoader;
|
|
13
13
|
}): Promise<string>;
|
|
14
14
|
export {};
|
|
@@ -23,12 +23,12 @@ const PRELOADED_CONTEXTS = {
|
|
|
23
23
|
'https://cleffa.originals.build/context': originalsContext, // Staging
|
|
24
24
|
'https://magby.originals.build/context': originalsContext, // Development
|
|
25
25
|
};
|
|
26
|
-
const defaultDocumentLoader =
|
|
26
|
+
const defaultDocumentLoader = (url) => {
|
|
27
27
|
const preloaded = PRELOADED_CONTEXTS[url];
|
|
28
28
|
if (preloaded) {
|
|
29
|
-
return { documentUrl: url, document: preloaded, contextUrl: null };
|
|
29
|
+
return Promise.resolve({ documentUrl: url, document: preloaded, contextUrl: null });
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
return Promise.reject(new Error(`Document not found in PRELOADED_CONTEXTS: ${url}`));
|
|
32
32
|
};
|
|
33
33
|
export function serializeDIDDocument(didDoc) {
|
|
34
34
|
// Serialize to JSON-LD with proper context
|
|
@@ -60,7 +60,8 @@ export function deserializeCredential(data) {
|
|
|
60
60
|
}
|
|
61
61
|
export async function canonicalizeDocument(doc, options = {}) {
|
|
62
62
|
try {
|
|
63
|
-
|
|
63
|
+
const jsonldTyped = jsonld;
|
|
64
|
+
const result = await jsonldTyped.canonize(doc, {
|
|
64
65
|
algorithm: 'URDNA2015',
|
|
65
66
|
format: 'application/n-quads',
|
|
66
67
|
documentLoader: options.documentLoader ?? defaultDocumentLoader,
|
|
@@ -68,9 +69,10 @@ export async function canonicalizeDocument(doc, options = {}) {
|
|
|
68
69
|
rdfDirection: 'i18n-datatype',
|
|
69
70
|
safe: false // Disable safe mode to allow custom contexts
|
|
70
71
|
});
|
|
72
|
+
return result;
|
|
71
73
|
}
|
|
72
74
|
catch (error) {
|
|
73
|
-
const message = error
|
|
75
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
74
76
|
throw new Error(`Failed to canonicalize document: ${message}`);
|
|
75
77
|
}
|
|
76
78
|
}
|
package/dist/utils/telemetry.js
CHANGED
|
@@ -11,7 +11,9 @@ export function emitTelemetry(hooks, event) {
|
|
|
11
11
|
try {
|
|
12
12
|
hooks.onEvent({ level: 'info', ...event });
|
|
13
13
|
}
|
|
14
|
-
catch (
|
|
14
|
+
catch (_err) {
|
|
15
|
+
// Intentionally ignore errors in telemetry hooks
|
|
16
|
+
}
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
export function emitError(hooks, error) {
|
|
@@ -19,6 +21,8 @@ export function emitError(hooks, error) {
|
|
|
19
21
|
try {
|
|
20
22
|
hooks.onError(error);
|
|
21
23
|
}
|
|
22
|
-
catch (
|
|
24
|
+
catch (_err) {
|
|
25
|
+
// Intentionally ignore errors in telemetry hooks
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
}
|
package/dist/utils/validation.js
CHANGED
|
@@ -42,8 +42,11 @@ export function validateCredential(vc) {
|
|
|
42
42
|
const issuerIsValidDid = (iss) => {
|
|
43
43
|
if (typeof iss === 'string')
|
|
44
44
|
return validateDID(iss);
|
|
45
|
-
if (iss && typeof iss
|
|
46
|
-
|
|
45
|
+
if (iss && typeof iss === 'object' && 'id' in iss) {
|
|
46
|
+
const issObj = iss;
|
|
47
|
+
if (typeof issObj.id === 'string')
|
|
48
|
+
return validateDID(issObj.id);
|
|
49
|
+
}
|
|
47
50
|
return false;
|
|
48
51
|
};
|
|
49
52
|
if (!issuerIsValidDid(vc.issuer)) {
|
|
@@ -83,8 +86,9 @@ export function validateDIDDocument(didDoc) {
|
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
// If controller array present on the DID Document, validate entries are DIDs
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
const didDocWithController = didDoc;
|
|
90
|
+
if (Array.isArray(didDocWithController.controller)) {
|
|
91
|
+
const ctrls = didDocWithController.controller;
|
|
88
92
|
if (!ctrls.every((c) => typeof c === 'string' && validateDID(c))) {
|
|
89
93
|
return false;
|
|
90
94
|
}
|