@originals/sdk 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -124,7 +124,7 @@ export declare class CredentialManager {
|
|
|
124
124
|
private config;
|
|
125
125
|
private didManager?;
|
|
126
126
|
constructor(config: OriginalsConfig, didManager?: DIDManager | undefined);
|
|
127
|
-
createResourceCredential(type: 'ResourceCreated' | 'ResourceUpdated' | 'ResourceMigrated', subject: CredentialSubject, issuer: string):
|
|
127
|
+
createResourceCredential(type: 'ResourceCreated' | 'ResourceUpdated' | 'ResourceMigrated', subject: CredentialSubject, issuer: string): VerifiableCredential;
|
|
128
128
|
signCredential(credential: VerifiableCredential, privateKeyMultibase: string, verificationMethod: string): Promise<VerifiableCredential>;
|
|
129
129
|
/**
|
|
130
130
|
* Sign a credential using an external signer (e.g., hardware wallet, Turnkey)
|
|
@@ -134,7 +134,7 @@ export declare class CredentialManager {
|
|
|
134
134
|
*/
|
|
135
135
|
signCredentialWithExternalSigner(credential: VerifiableCredential, signer: ExternalSigner): Promise<VerifiableCredential>;
|
|
136
136
|
verifyCredential(credential: VerifiableCredential): Promise<boolean>;
|
|
137
|
-
createPresentation(credentials: VerifiableCredential[], holder: string):
|
|
137
|
+
createPresentation(credentials: VerifiableCredential[], holder: string): VerifiablePresentation;
|
|
138
138
|
private generateProofValue;
|
|
139
139
|
private getSigner;
|
|
140
140
|
private resolveVerificationMethodMultibase;
|
|
@@ -159,7 +159,7 @@ export declare class CredentialManager {
|
|
|
159
159
|
* const signed = await credentialManager.signCredential(credential, privateKey, vmId);
|
|
160
160
|
* ```
|
|
161
161
|
*/
|
|
162
|
-
issueResourceCredential(resource: AssetResource, assetDid: string, creatorDid: string, chainOptions?: CredentialChainOptions):
|
|
162
|
+
issueResourceCredential(resource: AssetResource, assetDid: string, creatorDid: string, chainOptions?: CredentialChainOptions): VerifiableCredential;
|
|
163
163
|
/**
|
|
164
164
|
* Issue a ResourceUpdated credential for a resource version update
|
|
165
165
|
*
|
|
@@ -188,7 +188,7 @@ export declare class CredentialManager {
|
|
|
188
188
|
* );
|
|
189
189
|
* ```
|
|
190
190
|
*/
|
|
191
|
-
issueResourceUpdateCredential(resourceId: string, assetDid: string, previousHash: string, newHash: string, fromVersion: number, toVersion: number, updaterDid: string, updateReason?: string, chainOptions?: CredentialChainOptions):
|
|
191
|
+
issueResourceUpdateCredential(resourceId: string, assetDid: string, previousHash: string, newHash: string, fromVersion: number, toVersion: number, updaterDid: string, updateReason?: string, chainOptions?: CredentialChainOptions): VerifiableCredential;
|
|
192
192
|
/**
|
|
193
193
|
* Issue a MigrationCompleted credential for layer migrations
|
|
194
194
|
*
|
|
@@ -219,7 +219,7 @@ export declare class CredentialManager {
|
|
|
219
219
|
inscriptionId?: string;
|
|
220
220
|
satoshi?: string;
|
|
221
221
|
migrationReason?: string;
|
|
222
|
-
}, chainOptions?: CredentialChainOptions):
|
|
222
|
+
}, chainOptions?: CredentialChainOptions): VerifiableCredential;
|
|
223
223
|
/**
|
|
224
224
|
* Issue an OwnershipTransferred credential for Bitcoin-anchored asset transfers
|
|
225
225
|
*
|
|
@@ -248,7 +248,7 @@ export declare class CredentialManager {
|
|
|
248
248
|
issueOwnershipCredential(assetDid: string, previousOwner: string, newOwner: string, transactionId: string, issuerDid: string, details?: {
|
|
249
249
|
satoshi?: string;
|
|
250
250
|
transferReason?: string;
|
|
251
|
-
}, chainOptions?: CredentialChainOptions):
|
|
251
|
+
}, chainOptions?: CredentialChainOptions): VerifiableCredential;
|
|
252
252
|
/**
|
|
253
253
|
* Create a credential with optional chaining to a previous credential
|
|
254
254
|
*
|
|
@@ -313,7 +313,7 @@ export declare class CredentialManager {
|
|
|
313
313
|
* @param presentationHeader - Optional presentation-specific data
|
|
314
314
|
* @returns The credential with derived proof
|
|
315
315
|
*/
|
|
316
|
-
deriveSelectiveProof(credential: VerifiableCredential, fieldsToDisclose: string[],
|
|
316
|
+
deriveSelectiveProof(credential: VerifiableCredential, fieldsToDisclose: string[], _presentationHeader?: Uint8Array): Promise<DerivedProofResult>;
|
|
317
317
|
/**
|
|
318
318
|
* Extract all field paths from a credential as JSON Pointers
|
|
319
319
|
*/
|
|
@@ -325,5 +325,5 @@ export declare class CredentialManager {
|
|
|
325
325
|
* @param pointer - JSON Pointer path (e.g., /credentialSubject/name)
|
|
326
326
|
* @returns The value at the pointer path, or undefined if not found
|
|
327
327
|
*/
|
|
328
|
-
getFieldByPointer(credential: VerifiableCredential, pointer: string):
|
|
328
|
+
getFieldByPointer(credential: VerifiableCredential, pointer: string): unknown;
|
|
329
329
|
}
|
|
@@ -11,7 +11,7 @@ export class CredentialManager {
|
|
|
11
11
|
this.config = config;
|
|
12
12
|
this.didManager = didManager;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
createResourceCredential(type, subject, issuer) {
|
|
15
15
|
return {
|
|
16
16
|
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
17
17
|
type: ['VerifiableCredential', type],
|
|
@@ -25,13 +25,14 @@ export class CredentialManager {
|
|
|
25
25
|
try {
|
|
26
26
|
const loader = createDocumentLoader(this.didManager);
|
|
27
27
|
const { document } = await loader(verificationMethod);
|
|
28
|
-
|
|
28
|
+
const docWithKey = document;
|
|
29
|
+
if (docWithKey && docWithKey.publicKeyMultibase) {
|
|
29
30
|
const vm = {
|
|
30
31
|
id: verificationMethod,
|
|
31
|
-
controller: typeof credential.issuer === 'string' ? credential.issuer : credential.issuer?.id,
|
|
32
|
-
publicKeyMultibase:
|
|
32
|
+
controller: typeof credential.issuer === 'string' ? credential.issuer : credential.issuer?.id ?? '',
|
|
33
|
+
publicKeyMultibase: docWithKey.publicKeyMultibase,
|
|
33
34
|
secretKeyMultibase: privateKeyMultibase,
|
|
34
|
-
type:
|
|
35
|
+
type: docWithKey.type || 'Multikey'
|
|
35
36
|
};
|
|
36
37
|
const issuer = new Issuer(this.didManager, vm);
|
|
37
38
|
const unsigned = { ...credential };
|
|
@@ -63,7 +64,7 @@ export class CredentialManager {
|
|
|
63
64
|
* @returns Signed verifiable credential
|
|
64
65
|
*/
|
|
65
66
|
async signCredentialWithExternalSigner(credential, signer) {
|
|
66
|
-
const verificationMethodId =
|
|
67
|
+
const verificationMethodId = signer.getVerificationMethodId();
|
|
67
68
|
// Create proof structure
|
|
68
69
|
const proofBase = {
|
|
69
70
|
type: 'DataIntegrityProof',
|
|
@@ -91,11 +92,17 @@ export class CredentialManager {
|
|
|
91
92
|
}
|
|
92
93
|
async verifyCredential(credential) {
|
|
93
94
|
if (this.didManager) {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
95
|
+
const proofValue = credential.proof;
|
|
96
|
+
const proofWithSuite = proofValue;
|
|
97
|
+
if (proofWithSuite) {
|
|
98
|
+
const hasCryptosuite = Array.isArray(proofWithSuite)
|
|
99
|
+
? proofWithSuite[0]?.cryptosuite
|
|
100
|
+
: proofWithSuite.cryptosuite;
|
|
101
|
+
if (hasCryptosuite) {
|
|
102
|
+
const verifier = new Verifier(this.didManager);
|
|
103
|
+
const res = await verifier.verifyCredential(credential);
|
|
104
|
+
return res.verified;
|
|
105
|
+
}
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
108
|
const proof = credential.proof;
|
|
@@ -124,7 +131,8 @@ export class CredentialManager {
|
|
|
124
131
|
const digest = Buffer.concat([hProof, hCred]);
|
|
125
132
|
const signer = this.getSigner();
|
|
126
133
|
try {
|
|
127
|
-
const
|
|
134
|
+
const proofWithKey = proof;
|
|
135
|
+
const resolvedKey = proofWithKey.publicKeyMultibase
|
|
128
136
|
|| await this.resolveVerificationMethodMultibase(verificationMethod);
|
|
129
137
|
if (!resolvedKey) {
|
|
130
138
|
return false;
|
|
@@ -135,7 +143,7 @@ export class CredentialManager {
|
|
|
135
143
|
return false;
|
|
136
144
|
}
|
|
137
145
|
}
|
|
138
|
-
|
|
146
|
+
createPresentation(credentials, holder) {
|
|
139
147
|
return {
|
|
140
148
|
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
141
149
|
type: ['VerifiablePresentation'],
|
|
@@ -185,8 +193,9 @@ export class CredentialManager {
|
|
|
185
193
|
const loader = createDocumentLoader(this.didManager);
|
|
186
194
|
try {
|
|
187
195
|
const { document } = await loader(verificationMethod);
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
const docWithKey = document;
|
|
197
|
+
if (docWithKey && typeof docWithKey.publicKeyMultibase === 'string') {
|
|
198
|
+
return docWithKey.publicKeyMultibase;
|
|
190
199
|
}
|
|
191
200
|
}
|
|
192
201
|
catch (err) {
|
|
@@ -201,7 +210,8 @@ export class CredentialManager {
|
|
|
201
210
|
return null;
|
|
202
211
|
}
|
|
203
212
|
const didDoc = await this.didManager.resolveDID(did);
|
|
204
|
-
const
|
|
213
|
+
const docWithVMs = didDoc;
|
|
214
|
+
const vms = docWithVMs?.verificationMethod;
|
|
205
215
|
if (Array.isArray(vms)) {
|
|
206
216
|
const vm = vms.find((m) => m?.id === verificationMethod);
|
|
207
217
|
if (vm && typeof vm.publicKeyMultibase === 'string') {
|
|
@@ -246,7 +256,7 @@ export class CredentialManager {
|
|
|
246
256
|
* const signed = await credentialManager.signCredential(credential, privateKey, vmId);
|
|
247
257
|
* ```
|
|
248
258
|
*/
|
|
249
|
-
|
|
259
|
+
issueResourceCredential(resource, assetDid, creatorDid, chainOptions) {
|
|
250
260
|
const subject = {
|
|
251
261
|
id: assetDid,
|
|
252
262
|
resourceId: resource.id,
|
|
@@ -256,7 +266,7 @@ export class CredentialManager {
|
|
|
256
266
|
creator: creatorDid,
|
|
257
267
|
createdAt: resource.createdAt || new Date().toISOString()
|
|
258
268
|
};
|
|
259
|
-
const credential =
|
|
269
|
+
const credential = this.createCredentialWithChain('ResourceCreated', subject, creatorDid, chainOptions);
|
|
260
270
|
return credential;
|
|
261
271
|
}
|
|
262
272
|
/**
|
|
@@ -287,7 +297,7 @@ export class CredentialManager {
|
|
|
287
297
|
* );
|
|
288
298
|
* ```
|
|
289
299
|
*/
|
|
290
|
-
|
|
300
|
+
issueResourceUpdateCredential(resourceId, assetDid, previousHash, newHash, fromVersion, toVersion, updaterDid, updateReason, chainOptions) {
|
|
291
301
|
const subject = {
|
|
292
302
|
id: assetDid,
|
|
293
303
|
resourceId,
|
|
@@ -298,7 +308,7 @@ export class CredentialManager {
|
|
|
298
308
|
updatedAt: new Date().toISOString(),
|
|
299
309
|
...(updateReason && { updateReason })
|
|
300
310
|
};
|
|
301
|
-
const credential =
|
|
311
|
+
const credential = this.createCredentialWithChain('ResourceUpdated', subject, updaterDid, chainOptions);
|
|
302
312
|
return credential;
|
|
303
313
|
}
|
|
304
314
|
/**
|
|
@@ -326,7 +336,7 @@ export class CredentialManager {
|
|
|
326
336
|
* );
|
|
327
337
|
* ```
|
|
328
338
|
*/
|
|
329
|
-
|
|
339
|
+
issueMigrationCredential(sourceDid, targetDid, fromLayer, toLayer, issuerDid, details, chainOptions) {
|
|
330
340
|
const subject = {
|
|
331
341
|
id: targetDid || sourceDid,
|
|
332
342
|
sourceDid,
|
|
@@ -339,7 +349,7 @@ export class CredentialManager {
|
|
|
339
349
|
...(details?.satoshi && { satoshi: details.satoshi }),
|
|
340
350
|
...(details?.migrationReason && { migrationReason: details.migrationReason })
|
|
341
351
|
};
|
|
342
|
-
const credential =
|
|
352
|
+
const credential = this.createCredentialWithChain('MigrationCompleted', subject, issuerDid, chainOptions);
|
|
343
353
|
return credential;
|
|
344
354
|
}
|
|
345
355
|
/**
|
|
@@ -367,7 +377,7 @@ export class CredentialManager {
|
|
|
367
377
|
* );
|
|
368
378
|
* ```
|
|
369
379
|
*/
|
|
370
|
-
|
|
380
|
+
issueOwnershipCredential(assetDid, previousOwner, newOwner, transactionId, issuerDid, details, chainOptions) {
|
|
371
381
|
const subject = {
|
|
372
382
|
id: assetDid,
|
|
373
383
|
previousOwner,
|
|
@@ -377,7 +387,7 @@ export class CredentialManager {
|
|
|
377
387
|
...(details?.satoshi && { satoshi: details.satoshi }),
|
|
378
388
|
...(details?.transferReason && { transferReason: details.transferReason })
|
|
379
389
|
};
|
|
380
|
-
const credential =
|
|
390
|
+
const credential = this.createCredentialWithChain('OwnershipTransferred', subject, issuerDid, chainOptions);
|
|
381
391
|
return credential;
|
|
382
392
|
}
|
|
383
393
|
/**
|
|
@@ -392,7 +402,7 @@ export class CredentialManager {
|
|
|
392
402
|
* @param chainOptions - Optional chaining options
|
|
393
403
|
* @returns Unsigned verifiable credential with chain metadata
|
|
394
404
|
*/
|
|
395
|
-
|
|
405
|
+
createCredentialWithChain(type, subject, issuer, chainOptions) {
|
|
396
406
|
const credential = {
|
|
397
407
|
'@context': [
|
|
398
408
|
'https://www.w3.org/2018/credentials/v1',
|
|
@@ -414,7 +424,8 @@ export class CredentialManager {
|
|
|
414
424
|
}
|
|
415
425
|
// Add chaining metadata if provided
|
|
416
426
|
if (chainOptions?.previousCredentialId || chainOptions?.previousCredentialHash) {
|
|
417
|
-
credential.credentialSubject
|
|
427
|
+
const subjectWithPrev = credential.credentialSubject;
|
|
428
|
+
subjectWithPrev.previousCredential = {
|
|
418
429
|
...(chainOptions.previousCredentialId && { id: chainOptions.previousCredentialId }),
|
|
419
430
|
...(chainOptions.previousCredentialHash && { hash: chainOptions.previousCredentialHash })
|
|
420
431
|
};
|
|
@@ -472,7 +483,8 @@ export class CredentialManager {
|
|
|
472
483
|
for (let i = 1; i < credentials.length; i++) {
|
|
473
484
|
const current = credentials[i];
|
|
474
485
|
const previous = credentials[i - 1];
|
|
475
|
-
const
|
|
486
|
+
const currentSubject = current.credentialSubject;
|
|
487
|
+
const previousCredRef = currentSubject?.previousCredential;
|
|
476
488
|
if (previousCredRef) {
|
|
477
489
|
// Verify ID link
|
|
478
490
|
if (previousCredRef.id && previousCredRef.id !== previous.id) {
|
|
@@ -530,11 +542,11 @@ export class CredentialManager {
|
|
|
530
542
|
// Store pointers in credential for later derivation
|
|
531
543
|
// In a full implementation, this would involve creating a BBS+ base proof
|
|
532
544
|
};
|
|
533
|
-
return {
|
|
545
|
+
return await Promise.resolve({
|
|
534
546
|
credential: enhancedCredential,
|
|
535
547
|
mandatoryPointers: options.mandatoryPointers,
|
|
536
548
|
selectivePointers
|
|
537
|
-
};
|
|
549
|
+
});
|
|
538
550
|
}
|
|
539
551
|
/**
|
|
540
552
|
* Create a derived proof with selective disclosure
|
|
@@ -547,7 +559,7 @@ export class CredentialManager {
|
|
|
547
559
|
* @param presentationHeader - Optional presentation-specific data
|
|
548
560
|
* @returns The credential with derived proof
|
|
549
561
|
*/
|
|
550
|
-
async deriveSelectiveProof(credential, fieldsToDisclose,
|
|
562
|
+
async deriveSelectiveProof(credential, fieldsToDisclose, _presentationHeader) {
|
|
551
563
|
// Validate that all disclosed fields are valid JSON pointers
|
|
552
564
|
for (const field of fieldsToDisclose) {
|
|
553
565
|
if (!field.startsWith('/')) {
|
|
@@ -563,14 +575,14 @@ export class CredentialManager {
|
|
|
563
575
|
// 2. Create selective indexes from fieldsToDisclose
|
|
564
576
|
// 3. Generate the derived BBS+ proof
|
|
565
577
|
// For now, we return a structure showing what would be disclosed
|
|
566
|
-
return {
|
|
578
|
+
return await Promise.resolve({
|
|
567
579
|
credential: {
|
|
568
580
|
...credential,
|
|
569
581
|
// A real implementation would have a derived proof here
|
|
570
582
|
},
|
|
571
583
|
disclosedFields: fieldsToDisclose,
|
|
572
584
|
hiddenFields
|
|
573
|
-
};
|
|
585
|
+
});
|
|
574
586
|
}
|
|
575
587
|
/**
|
|
576
588
|
* Extract all field paths from a credential as JSON Pointers
|
|
@@ -608,7 +620,8 @@ export class CredentialManager {
|
|
|
608
620
|
}
|
|
609
621
|
// Handle escaped characters in JSON Pointer
|
|
610
622
|
const unescaped = part.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
611
|
-
|
|
623
|
+
const currentObj = current;
|
|
624
|
+
current = currentObj[unescaped];
|
|
612
625
|
}
|
|
613
626
|
return current;
|
|
614
627
|
}
|
package/dist/vc/Issuer.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DIDManager } from '../did/DIDManager';
|
|
|
3
3
|
export interface IssueOptions {
|
|
4
4
|
proofPurpose: 'assertionMethod' | 'authentication';
|
|
5
5
|
documentLoader?: (iri: string) => Promise<{
|
|
6
|
-
document:
|
|
6
|
+
document: unknown;
|
|
7
7
|
documentUrl: string;
|
|
8
8
|
contextUrl: string | null;
|
|
9
9
|
}>;
|
|
@@ -15,7 +15,7 @@ export type VerificationMethodLike = {
|
|
|
15
15
|
controller: string;
|
|
16
16
|
publicKeyMultibase: string;
|
|
17
17
|
secretKeyMultibase?: string;
|
|
18
|
-
type?:
|
|
18
|
+
type?: string;
|
|
19
19
|
};
|
|
20
20
|
export declare class Issuer {
|
|
21
21
|
private didManager;
|
package/dist/vc/Issuer.js
CHANGED
|
@@ -51,7 +51,11 @@ export class Issuer {
|
|
|
51
51
|
if (keyType !== 'Ed25519') {
|
|
52
52
|
throw new Error('Only Ed25519 supported for eddsa-rdfc-2022');
|
|
53
53
|
}
|
|
54
|
-
const
|
|
54
|
+
const presentationWithContext = {
|
|
55
|
+
...presentation,
|
|
56
|
+
'@context': ['https://www.w3.org/ns/credentials/v2']
|
|
57
|
+
};
|
|
58
|
+
const proof = await DataIntegrityProofManager.createProof(presentationWithContext, {
|
|
55
59
|
verificationMethod: this.verificationMethod.id,
|
|
56
60
|
proofPurpose: options.proofPurpose,
|
|
57
61
|
cryptosuite: 'eddsa-rdfc-2022',
|
package/dist/vc/Verifier.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export declare class Verifier {
|
|
|
8
8
|
private didManager;
|
|
9
9
|
constructor(didManager: DIDManager);
|
|
10
10
|
verifyCredential(vc: VerifiableCredential, options?: {
|
|
11
|
-
documentLoader?: (iri: string) => Promise<
|
|
11
|
+
documentLoader?: (iri: string) => Promise<unknown>;
|
|
12
12
|
}): Promise<VerificationResult>;
|
|
13
13
|
verifyPresentation(vp: VerifiablePresentation, options?: {
|
|
14
|
-
documentLoader?: (iri: string) => Promise<
|
|
14
|
+
documentLoader?: (iri: string) => Promise<unknown>;
|
|
15
15
|
}): Promise<VerificationResult>;
|
|
16
16
|
}
|
package/dist/vc/Verifier.js
CHANGED
|
@@ -11,15 +11,18 @@ export class Verifier {
|
|
|
11
11
|
if (!vc.proof)
|
|
12
12
|
throw new Error('Credential has no proof');
|
|
13
13
|
const loader = options.documentLoader || createDocumentLoader(this.didManager);
|
|
14
|
-
const
|
|
14
|
+
const vcContext = vc['@context'];
|
|
15
|
+
const ctxs = Array.isArray(vcContext) ? vcContext.filter((c) => typeof c === 'string') : [String(vcContext)];
|
|
15
16
|
for (const c of ctxs)
|
|
16
17
|
await loader(c);
|
|
17
|
-
const
|
|
18
|
+
const proofValue = vc.proof;
|
|
19
|
+
const proof = Array.isArray(proofValue) ? proofValue[0] : proofValue;
|
|
18
20
|
const result = await DataIntegrityProofManager.verifyProof(vc, proof, { documentLoader: loader });
|
|
19
21
|
return result.verified ? { verified: true, errors: [] } : { verified: false, errors: result.errors ?? ['Verification failed'] };
|
|
20
22
|
}
|
|
21
23
|
catch (e) {
|
|
22
|
-
|
|
24
|
+
const error = e;
|
|
25
|
+
return { verified: false, errors: [error?.message ?? 'Unknown error in verifyCredential'] };
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
async verifyPresentation(vp, options = {}) {
|
|
@@ -29,7 +32,8 @@ export class Verifier {
|
|
|
29
32
|
if (!vp.proof)
|
|
30
33
|
throw new Error('Presentation has no proof');
|
|
31
34
|
const loader = options.documentLoader || createDocumentLoader(this.didManager);
|
|
32
|
-
const
|
|
35
|
+
const vpContext = vp['@context'];
|
|
36
|
+
const ctxs = Array.isArray(vpContext) ? vpContext.filter((c) => typeof c === 'string') : [String(vpContext)];
|
|
33
37
|
for (const c of ctxs)
|
|
34
38
|
await loader(c);
|
|
35
39
|
if (vp.verifiableCredential) {
|
|
@@ -39,12 +43,14 @@ export class Verifier {
|
|
|
39
43
|
return res;
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
|
-
const
|
|
46
|
+
const proofValue = vp.proof;
|
|
47
|
+
const proof = Array.isArray(proofValue) ? proofValue[0] : proofValue;
|
|
43
48
|
const result = await DataIntegrityProofManager.verifyProof(vp, proof, { documentLoader: loader });
|
|
44
49
|
return result.verified ? { verified: true, errors: [] } : { verified: false, errors: result.errors ?? ['Verification failed'] };
|
|
45
50
|
}
|
|
46
51
|
catch (e) {
|
|
47
|
-
|
|
52
|
+
const error = e;
|
|
53
|
+
return { verified: false, errors: [error?.message ?? 'Unknown error in verifyPresentation'] };
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DIDManager } from '../did/DIDManager';
|
|
2
2
|
type LoadedDocument = {
|
|
3
|
-
document:
|
|
3
|
+
document: unknown;
|
|
4
4
|
documentUrl: string;
|
|
5
5
|
contextUrl: string | null;
|
|
6
6
|
};
|
|
@@ -11,6 +11,8 @@ export declare class DocumentLoader {
|
|
|
11
11
|
private resolveDID;
|
|
12
12
|
}
|
|
13
13
|
export declare const createDocumentLoader: (didManager: DIDManager) => (iri: string) => Promise<LoadedDocument>;
|
|
14
|
-
export declare const verificationMethodRegistry: Map<string,
|
|
15
|
-
export declare function registerVerificationMethod(vm:
|
|
14
|
+
export declare const verificationMethodRegistry: Map<string, Record<string, unknown>>;
|
|
15
|
+
export declare function registerVerificationMethod(vm: Record<string, unknown> & {
|
|
16
|
+
id?: string;
|
|
17
|
+
}): void;
|
|
16
18
|
export {};
|
|
@@ -23,27 +23,28 @@ export class DocumentLoader {
|
|
|
23
23
|
if (!didDoc) {
|
|
24
24
|
throw new Error(`DID not resolved: ${did}`);
|
|
25
25
|
}
|
|
26
|
+
const didDocTyped = didDoc;
|
|
26
27
|
if (fragment) {
|
|
27
28
|
// If a VM was registered explicitly, prefer it
|
|
28
29
|
const cached = verificationMethodRegistry.get(didUrl);
|
|
29
30
|
if (cached) {
|
|
30
31
|
return {
|
|
31
|
-
document: { '@context':
|
|
32
|
+
document: { '@context': didDocTyped['@context'], ...cached },
|
|
32
33
|
documentUrl: didUrl,
|
|
33
34
|
contextUrl: null
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
|
-
const vms =
|
|
37
|
+
const vms = didDocTyped.verificationMethod;
|
|
37
38
|
const vm = vms?.find((m) => m.id === didUrl);
|
|
38
39
|
if (vm) {
|
|
39
40
|
return {
|
|
40
|
-
document: { '@context':
|
|
41
|
+
document: { '@context': didDocTyped['@context'], ...vm },
|
|
41
42
|
documentUrl: didUrl,
|
|
42
43
|
contextUrl: null
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
return {
|
|
46
|
-
document: { '@context':
|
|
47
|
+
document: { '@context': didDocTyped['@context'], id: didUrl },
|
|
47
48
|
documentUrl: didUrl,
|
|
48
49
|
contextUrl: null
|
|
49
50
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@originals/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "TypeScript SDK for the Originals Protocol - creating, discovering, and transferring digital assets with cryptographically verifiable provenance",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"originals-cel": "./dist/cel/cli/index.js"
|
|
13
|
+
},
|
|
11
14
|
"exports": {
|
|
12
15
|
".": {
|
|
13
16
|
"types": "./dist/index.d.ts",
|