@docknetwork/wallet-sdk-wasm 1.5.11 → 1.5.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docknetwork/wallet-sdk-wasm",
3
- "version": "1.5.11",
3
+ "version": "1.5.14",
4
4
  "license": "https://github.com/docknetwork/react-native-sdk/LICENSE",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,13 +19,13 @@
19
19
  "p-limit": "2.3.0",
20
20
  "@astronautlabs/jsonpath": "^1.1.2",
21
21
  "@docknetwork/universal-wallet": "^2.0.1",
22
- "@docknetwork/wallet-sdk-dids": "^1.5.11",
22
+ "@docknetwork/wallet-sdk-dids": "^1.5.14",
23
23
  "@cosmjs/proto-signing": "^0.32.4",
24
- "@docknetwork/cheqd-blockchain-api": "0.36.1",
25
- "@docknetwork/cheqd-blockchain-modules": "0.33.0",
24
+ "@docknetwork/cheqd-blockchain-api": "4.0.3",
25
+ "@docknetwork/cheqd-blockchain-modules": "4.0.3",
26
26
  "@scure/bip39": "^1.6.0",
27
27
  "@noble/hashes": "1.8.0",
28
- "@docknetwork/credential-sdk": "0.50.0",
28
+ "@docknetwork/credential-sdk": "0.54.3",
29
29
  "@sphereon/oid4vci-client": "^0.16.0",
30
30
  "@sphereon/oid4vci-common": "^0.16.0",
31
31
  "axios": "^0.25.0",
@@ -40,4 +40,8 @@ export class BlockchainServiceRpc extends RpcService {
40
40
  getAddress(): Promise<string> {
41
41
  return this.call('getAddress');
42
42
  }
43
+
44
+ resolveDID(did: string): Promise<any> {
45
+ return this.call('resolveDID', did);
46
+ }
43
47
  }
@@ -75,7 +75,7 @@ export class BlockchainService {
75
75
  * @returns
76
76
  */
77
77
  async ensureBlockchainReady() {
78
- if (this.isBlockchainReady) {
78
+ if (await this.isApiConnected()) {
79
79
  return;
80
80
  }
81
81
 
@@ -176,6 +176,9 @@ export class BlockchainService {
176
176
  });
177
177
  }
178
178
 
179
+ async resolveDID(did: string) {
180
+ return this.resolver.resolve(did);
181
+ }
179
182
  /**
180
183
  *
181
184
  * @returns
@@ -60,6 +60,17 @@ function getAttributeName({field, selectedCredentials, index}) {
60
60
  return attributeName;
61
61
  }
62
62
 
63
+ /**
64
+ * Convert PEX request to bounds for each descriptor
65
+ * @param {*} pexRequest - The PEX request object containing input descriptors and constraints
66
+ * @param {*} selectedCredentials - Array of selected credentials corresponding to the input descriptors
67
+ * @param {*} removeFromRequest - if true, removes range proofs fields from the request. it might be dangerous if you will be using the proof request later
68
+ * because it will not have the range proofs fields anymore.
69
+ * @returns {Array} - Array of bounds for each descriptor, where each bound is an object with attributeName, min, and max
70
+ * @throws {Error} - If a field path is missing or empty
71
+ * @throws {Error} - If an unsupported format or type is encountered
72
+ * @throws {Error} - If a selected credential is expected but not found at the given index
73
+ */
63
74
  export function pexToBounds(
64
75
  pexRequest,
65
76
  selectedCredentials = [],
@@ -162,6 +173,9 @@ export function pexToBounds(
162
173
  : formatMinimum
163
174
  : minimum;
164
175
 
176
+ const proofRequestMax = max;
177
+ const proofRequestMin = min;
178
+
165
179
  if (max === undefined && min === undefined) {
166
180
  return;
167
181
  }
@@ -236,6 +250,10 @@ export function pexToBounds(
236
250
  attributeName,
237
251
  min,
238
252
  max,
253
+ proofRequestMax,
254
+ proofRequestMin,
255
+ format,
256
+ type,
239
257
  });
240
258
  });
241
259
 
@@ -258,9 +276,10 @@ const attributesToSkip = [
258
276
  /^@context/,
259
277
  /^proof/,
260
278
  /^credentialSchema/,
279
+ /^issuanceDate/,
261
280
  ];
262
281
 
263
- const shouldSkipAttribute = attributeName =>
282
+ export const shouldSkipAttribute = attributeName =>
264
283
  attributesToSkip.some(regex => regex.test(attributeName));
265
284
 
266
285
  export function getPexRequiredAttributes(pexRequest, selectedCredentials = []) {
@@ -230,6 +230,31 @@ describe('pex helpers', () => {
230
230
 
231
231
  expect(result).toEqual(['credentialSubject.id']);
232
232
  });
233
+
234
+ it('should skip issuanceDate', () => {
235
+ const result = getPexRequiredAttributes(
236
+ {
237
+ id: 'test-issuanceDate',
238
+ input_descriptors: [
239
+ {
240
+ constraints: {
241
+ fields: [
242
+ {
243
+ path: ['$.issuanceDate'],
244
+ },
245
+ ],
246
+ },
247
+ },
248
+ ],
249
+ },
250
+ [
251
+ {
252
+ issuanceDate: '2021-01-01',
253
+ },
254
+ ],
255
+ );
256
+ expect(result).toEqual([]);
257
+ });
233
258
  });
234
259
 
235
260
  describe('pexToBounds', () => {
@@ -278,11 +303,19 @@ describe('pex helpers', () => {
278
303
  attributeName: 'credentialSubject.age',
279
304
  min: 0,
280
305
  max: 10000000000,
306
+ proofRequestMax: undefined,
307
+ proofRequestMin: 0,
308
+ format: undefined,
309
+ type: 'number',
281
310
  },
282
311
  {
283
312
  attributeName: 'credentialSubject.dateOfBirth',
284
313
  min: new Date('2021-01-01'),
285
314
  max: new Date(884541351600000),
315
+ proofRequestMax: undefined,
316
+ proofRequestMin: '2021-01-01',
317
+ format: 'date',
318
+ type: undefined,
286
319
  },
287
320
  ],
288
321
  ]);
@@ -325,6 +358,10 @@ describe('pex helpers', () => {
325
358
  attributeName: 'credentialSubject.age',
326
359
  min: 0,
327
360
  max: 10000000000,
361
+ proofRequestMax: undefined,
362
+ proofRequestMin: 0,
363
+ format: undefined,
364
+ type: 'number',
328
365
  },
329
366
  ],
330
367
  ]);
@@ -361,6 +398,10 @@ describe('pex helpers', () => {
361
398
  attributeName: 'expirationDate',
362
399
  min: new Date('2021-01-01T00:00:00Z'),
363
400
  max: new Date('2022-01-01T00:00:00Z'),
401
+ proofRequestMax: '2022-01-01T00:00:00Z',
402
+ proofRequestMin: '2021-01-01T00:00:00Z',
403
+ format: 'date-time',
404
+ type: undefined,
364
405
  },
365
406
  ],
366
407
  ]);
@@ -398,6 +439,10 @@ describe('pex helpers', () => {
398
439
  attributeName: 'amount',
399
440
  min: 0,
400
441
  max: 100,
442
+ proofRequestMax: 100,
443
+ proofRequestMin: 0,
444
+ format: undefined,
445
+ type: 'number',
401
446
  },
402
447
  ],
403
448
  ]);
@@ -444,11 +489,19 @@ describe('pex helpers', () => {
444
489
  attributeName: 'startDate',
445
490
  min: new Date('2021-01-01'),
446
491
  max: new Date('2022-01-01'),
492
+ proofRequestMax: '2022-01-01',
493
+ proofRequestMin: '2021-01-01',
494
+ format: 'date',
495
+ type: undefined,
447
496
  },
448
497
  {
449
498
  attributeName: 'amount',
450
499
  min: 0,
451
500
  max: 100,
501
+ proofRequestMax: 100,
502
+ proofRequestMin: 0,
503
+ format: undefined,
504
+ type: 'number',
452
505
  },
453
506
  ],
454
507
  ]);
@@ -464,6 +517,67 @@ describe('pex helpers', () => {
464
517
  expect(bounds).toEqual([]);
465
518
  });
466
519
 
520
+ it('should preserve original proof request values in new metadata fields', () => {
521
+ const pexRequest = {
522
+ input_descriptors: [
523
+ {
524
+ constraints: {
525
+ fields: [
526
+ {
527
+ filter: {
528
+ type: 'number',
529
+ minimum: 18,
530
+ maximum: 65,
531
+ },
532
+ path: ['$.credentialSubject.age'],
533
+ },
534
+ {
535
+ filter: {
536
+ format: 'date',
537
+ formatMinimum: '2020-01-01',
538
+ formatMaximum: '2025-12-31',
539
+ },
540
+ path: ['$.credentialSubject.graduationDate'],
541
+ },
542
+ ],
543
+ },
544
+ },
545
+ ],
546
+ };
547
+
548
+ const bounds = pexToBounds(pexRequest, [
549
+ {
550
+ credentialSubject: {
551
+ age: 25,
552
+ graduationDate: '2023-06-15',
553
+ },
554
+ },
555
+ ]);
556
+
557
+ expect(bounds).toEqual([
558
+ [
559
+ {
560
+ attributeName: 'credentialSubject.age',
561
+ min: 18,
562
+ max: 65,
563
+ proofRequestMax: 65,
564
+ proofRequestMin: 18,
565
+ format: undefined,
566
+ type: 'number',
567
+ },
568
+ {
569
+ attributeName: 'credentialSubject.graduationDate',
570
+ min: new Date('2020-01-01'),
571
+ max: new Date('2025-12-31'),
572
+ proofRequestMax: '2025-12-31',
573
+ proofRequestMin: '2020-01-01',
574
+ format: 'date',
575
+ type: undefined,
576
+ },
577
+ ],
578
+ ]);
579
+ });
580
+
467
581
  it('should not have undefined attributeNames, exclude not found bounds', () => {
468
582
  const pexRequest = {
469
583
  id: '3cb2c1db-54d7-427a-a6a2-4b8f73a33700',
@@ -29,7 +29,7 @@ import {
29
29
  import assert from 'assert';
30
30
  import axios from 'axios';
31
31
  import {getIsRevoked, getWitnessDetails} from './bbs-revocation';
32
- import {getPexRequiredAttributes} from './pex-helpers';
32
+ import {getPexRequiredAttributes, shouldSkipAttribute} from './pex-helpers';
33
33
  import {didService} from '../dids/service';
34
34
 
35
35
  const pex: PEX = new PEX();
@@ -397,7 +397,7 @@ class CredentialService {
397
397
  ? descriptorBounds[idx].map(bound => bound.attributeName)
398
398
  : [];
399
399
  const filteredAttributes = attributesToReveal.filter(
400
- attribute => !attributesToSkip.includes(attribute),
400
+ attribute => !attributesToSkip.includes(attribute) && !shouldSkipAttribute(attribute),
401
401
  );
402
402
  const _pexRequiredAttributes = pexRequiredAttributes[idx] || [];
403
403