@docknetwork/wallet-sdk-wasm 1.5.10 → 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/lib/services/blockchain/service-rpc.js +4 -0
- package/lib/services/blockchain/service-rpc.mjs +4 -0
- package/lib/services/blockchain/service.js +5 -4
- package/lib/services/blockchain/service.mjs +5 -4
- package/lib/services/credential/pex-helpers.js +20 -0
- package/lib/services/credential/pex-helpers.mjs +20 -1
- package/lib/services/credential/service.js +1 -1
- package/lib/services/credential/service.mjs +2 -2
- package/lib/services/credential/utils.js +4 -10
- package/lib/services/credential/utils.mjs +8 -8
- package/lib/services/dids/index.js +1 -16
- package/lib/services/dids/index.mjs +1 -16
- package/lib/services/dids/service-rpc.js +0 -3
- package/lib/services/dids/service-rpc.mjs +0 -3
- package/lib/services/dids/service.js +3 -26
- package/lib/services/dids/service.mjs +3 -25
- package/lib/services/edv/index.js +1 -16
- package/lib/services/edv/index.mjs +1 -16
- package/lib/services/edv/service.js +1 -16
- package/lib/services/edv/service.mjs +1 -16
- package/lib/services/util-crypto/service-rpc.js +2 -7
- package/lib/services/util-crypto/service-rpc.mjs +2 -7
- package/lib/src/services/blockchain/service.d.ts +1 -0
- package/lib/src/services/blockchain/service.d.ts.map +1 -1
- package/lib/src/services/credential/pex-helpers.d.ts +13 -1
- package/lib/src/services/credential/pex-helpers.d.ts.map +1 -1
- package/lib/src/services/dids/service-rpc.d.ts +0 -1
- package/lib/src/services/dids/service-rpc.d.ts.map +1 -1
- package/lib/src/services/dids/service.d.ts +5 -2
- package/lib/src/services/dids/service.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/services/blockchain/service-rpc.js +4 -0
- package/src/services/blockchain/service.ts +5 -4
- package/src/services/credential/pex-helpers.js +20 -1
- package/src/services/credential/pex-helpers.test.js +114 -0
- package/src/services/credential/service.ts +2 -2
- package/src/services/credential/utils.js +8 -8
- package/src/services/dids/index.test.js +37 -14
- package/src/services/dids/service-rpc.ts +0 -3
- package/src/services/dids/service.ts +1 -9
- package/src/services/util-crypto/service-rpc.js +2 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docknetwork/wallet-sdk-wasm",
|
|
3
|
-
"version": "1.5.
|
|
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.
|
|
22
|
+
"@docknetwork/wallet-sdk-dids": "^1.5.14",
|
|
23
23
|
"@cosmjs/proto-signing": "^0.32.4",
|
|
24
|
-
"@docknetwork/cheqd-blockchain-api": "0.
|
|
25
|
-
"@docknetwork/cheqd-blockchain-modules": "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.
|
|
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",
|
|
@@ -75,7 +75,7 @@ export class BlockchainService {
|
|
|
75
75
|
* @returns
|
|
76
76
|
*/
|
|
77
77
|
async ensureBlockchainReady() {
|
|
78
|
-
if (this.
|
|
78
|
+
if (await this.isApiConnected()) {
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -132,9 +132,7 @@ export class BlockchainService {
|
|
|
132
132
|
});
|
|
133
133
|
Logger.info(`Cheqd initialized at: ${checkdApiUrl}`);
|
|
134
134
|
} catch (err) {
|
|
135
|
-
|
|
136
|
-
debugger;
|
|
137
|
-
Logger.error(`Failed to initialize cheqd at: ${checkdApiUrl}`);
|
|
135
|
+
Logger.error(`Failed to initialize cheqd at: ${checkdApiUrl}`, err);
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
|
|
@@ -178,6 +176,9 @@ export class BlockchainService {
|
|
|
178
176
|
});
|
|
179
177
|
}
|
|
180
178
|
|
|
179
|
+
async resolveDID(did: string) {
|
|
180
|
+
return this.resolver.resolve(did);
|
|
181
|
+
}
|
|
181
182
|
/**
|
|
182
183
|
*
|
|
183
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
|
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
Bls12381BBDT16KeyPairDock2024,
|
|
6
6
|
} from '@docknetwork/credential-sdk/vc/crypto';
|
|
7
7
|
import {randomAsHex} from '@docknetwork/credential-sdk/utils';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
8
|
+
import {X25519KeyAgreementKey2020} from '@digitalbazaar/x25519-key-agreement-key-2020';
|
|
9
|
+
import {X25519KeyAgreementKey2019} from '@digitalbazaar/x25519-key-agreement-key-2019';
|
|
10
|
+
import {Ed25519VerificationKey2018} from '@digitalbazaar/ed25519-verification-key-2018';
|
|
11
|
+
import {Ed25519VerificationKey2020} from '@digitalbazaar/ed25519-verification-key-2020';
|
|
12
12
|
|
|
13
13
|
import {Ed25519Keypair} from '@docknetwork/credential-sdk/keypairs';
|
|
14
14
|
|
|
@@ -62,13 +62,13 @@ export async function keyDocToKeypair(keyDoc) {
|
|
|
62
62
|
|
|
63
63
|
const keyConstructors = {
|
|
64
64
|
Ed25519VerificationKey2018: keypairOptions =>
|
|
65
|
-
new
|
|
65
|
+
new Ed25519VerificationKey2018(keypairOptions),
|
|
66
66
|
Ed25519VerificationKey2020: keypairOptions =>
|
|
67
|
-
new
|
|
67
|
+
new Ed25519VerificationKey2020(keypairOptions),
|
|
68
68
|
X25519KeyAgreementKey2019: keypairOptions =>
|
|
69
|
-
new
|
|
69
|
+
new X25519KeyAgreementKey2019(keypairOptions),
|
|
70
70
|
X25519KeyAgreementKey2020: keypairOptions =>
|
|
71
|
-
new
|
|
71
|
+
new X25519KeyAgreementKey2020(keypairOptions),
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
export function getKeypairFromDoc(keypairOptions) {
|
|
@@ -3,7 +3,6 @@ import {DIDServiceRPC} from './service-rpc';
|
|
|
3
3
|
import {didService as service} from './service';
|
|
4
4
|
import {validation} from './config';
|
|
5
5
|
import {DIDKeyManager} from '@docknetwork/wallet-sdk-dids/src';
|
|
6
|
-
import {blockchainService} from '../blockchain/service';
|
|
7
6
|
import {Ed25519Keypair} from '@docknetwork/credential-sdk/keypairs';
|
|
8
7
|
|
|
9
8
|
describe('DID Service', () => {
|
|
@@ -93,19 +92,6 @@ describe('DID Service', () => {
|
|
|
93
92
|
spy.mockReset();
|
|
94
93
|
});
|
|
95
94
|
|
|
96
|
-
it('expect to get did document', async () => {
|
|
97
|
-
const document = 'document';
|
|
98
|
-
jest
|
|
99
|
-
.spyOn(blockchainService.modules.did, 'getDocument')
|
|
100
|
-
.mockResolvedValue(document);
|
|
101
|
-
|
|
102
|
-
const result = await service.getDidDockDocument(
|
|
103
|
-
'did:dock:5HL5XB7CHcHT2ZUKjY2SCJvDAK11qoa1exgfVnVTHRbmjJQi',
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
expect(result).toStrictEqual(document);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
95
|
it('expect to generateKeyDoc without keyPair', async () => {
|
|
110
96
|
const controller =
|
|
111
97
|
'did:dock:5HL5XB7CHcHT2ZUKjY2SCJvDAK11qoa1exgfVnVTHRbmjJQ';
|
|
@@ -131,4 +117,41 @@ describe('DID Service', () => {
|
|
|
131
117
|
expect(derivedKeyDoc.controller).toEqual(controller);
|
|
132
118
|
expect(derivedKeyDoc.privateKeyMultibase).toBeDefined();
|
|
133
119
|
});
|
|
120
|
+
|
|
121
|
+
it('expect to createSignedJWT', async () => {
|
|
122
|
+
const headerInput = {
|
|
123
|
+
typ: 'openid4vci-proof+jwt',
|
|
124
|
+
alg: 'EdDSA',
|
|
125
|
+
kid: 'did:key:z6MkjW3DVk4mXjnK8GUuK2SydyFg8oMJbUnHiVzzSz3N9iGM#z6MkjW3DVk4mXjnK8GUuK2SydyFg8oMJbUnHiVzzSz3N9iGM',
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const payload = {
|
|
129
|
+
aud: 'https://api.truvera.io/openid/issuers/d044f3d3-0934-4f62-9b6f-6f06ae8f383e',
|
|
130
|
+
iat: 1750356930,
|
|
131
|
+
exp: 1750357590,
|
|
132
|
+
iss: 'dock.wallet',
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const privateKeyDoc = {
|
|
136
|
+
controller: 'did:key:z6MkjW3DVk4mXjnK8GUuK2SydyFg8oMJbUnHiVzzSz3N9iGM',
|
|
137
|
+
type: 'Ed25519VerificationKey2018',
|
|
138
|
+
id: 'did:key:z6MkjW3DVk4mXjnK8GUuK2SydyFg8oMJbUnHiVzzSz3N9iGM#z6MkjW3DVk4mXjnK8GUuK2SydyFg8oMJbUnHiVzzSz3N9iGM',
|
|
139
|
+
publicKeyMultibase: 'z6MkjW3DVk4mXjnK8GUuK2SydyFg8oMJbUnHiVzzSz3N9iGM',
|
|
140
|
+
privateKeyMultibase:
|
|
141
|
+
'zruzuEmC9VrJ3JUcufskfX4qNKwqqrNDztqJsDp1dXXQFS8CkfEDqK1ZBgNXeWF9xGhAPeVVfV1vL5pVaHpXLU2JwXK',
|
|
142
|
+
privateKeyBase58:
|
|
143
|
+
'GLkPGM4hz3AhQkQA1y63PtxdA3GL4vJiWgYpnB4N1sFi2wzr2tDbc482igkKaDcAwbrhe92LKJygEHd5xmBJtvR',
|
|
144
|
+
publicKeyBase58: '63nAuVpLCCHr1meCdTV8nshgKE5TBbXw2V64ci5MEVUy',
|
|
145
|
+
'@context': ['https://w3id.org/wallet/v1'],
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const signedJWT = await service.createSignedJWT({
|
|
149
|
+
payload,
|
|
150
|
+
privateKeyDoc,
|
|
151
|
+
headerInput,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
expect(signedJWT).toBeDefined();
|
|
155
|
+
expect(signedJWT).toContain('.');
|
|
156
|
+
});
|
|
134
157
|
});
|
|
@@ -21,9 +21,6 @@ export class DIDServiceRPC extends RpcService {
|
|
|
21
21
|
deriveKeyDoc(params) {
|
|
22
22
|
return this.call('deriveKeyDoc', params);
|
|
23
23
|
}
|
|
24
|
-
getDidDockDocument(did) {
|
|
25
|
-
return this.call('getDidDockDocument', did);
|
|
26
|
-
}
|
|
27
24
|
createSignedJWT(params) {
|
|
28
25
|
return this.call('createSignedJWT', params);
|
|
29
26
|
}
|
|
@@ -29,7 +29,7 @@ import { keypairToKeydoc } from './keypair-utils';
|
|
|
29
29
|
|
|
30
30
|
async function getSignerKeypair(privateKeyDoc) {
|
|
31
31
|
const privateKey =
|
|
32
|
-
privateKeyDoc.keypair || keyDocToKeypair(privateKeyDoc
|
|
32
|
+
privateKeyDoc.keypair || await keyDocToKeypair(privateKeyDoc);
|
|
33
33
|
|
|
34
34
|
if (!privateKey.signer && privateKey.sign) {
|
|
35
35
|
privateKey.signer = () => ({sign: ({data}) => privateKey.sign(data)});
|
|
@@ -66,7 +66,6 @@ class DIDService {
|
|
|
66
66
|
DIDService.prototype.getDIDResolution,
|
|
67
67
|
DIDService.prototype.generateKeyDoc,
|
|
68
68
|
DIDService.prototype.deriveKeyDoc,
|
|
69
|
-
DIDService.prototype.getDidDockDocument,
|
|
70
69
|
DIDService.prototype.createSignedJWT,
|
|
71
70
|
];
|
|
72
71
|
keypairToDIDKeyDocument(params: KeypairToDIDKeyDocumentParams) {
|
|
@@ -114,13 +113,6 @@ class DIDService {
|
|
|
114
113
|
const signature = await sign({data: signPayload});
|
|
115
114
|
return `${headerAndPayloadBase64URL}.${base64url.encode(signature)}`;
|
|
116
115
|
}
|
|
117
|
-
|
|
118
|
-
async getDidDockDocument(did) {
|
|
119
|
-
assert(!!did, 'DID is required');
|
|
120
|
-
const dock = blockchainService.dock;
|
|
121
|
-
const result = await blockchainService.modules.did.getDocument(did);
|
|
122
|
-
return result;
|
|
123
|
-
}
|
|
124
116
|
}
|
|
125
117
|
|
|
126
118
|
export const didService = new DIDService();
|
|
@@ -18,16 +18,11 @@ export class UtilCryptoServiceRpc extends RpcService {
|
|
|
18
18
|
return this.call('mnemonicToMiniSecret', phrase);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
deriveValidate(uri: string): Promise<any> {
|
|
22
|
-
validation.deriveValidate(uri);
|
|
23
|
-
return this.call('deriveValidate', uri);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
21
|
isBase64(value: string): Promise<boolean> {
|
|
27
22
|
return this.call('isBase64', value);
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
return this.call('
|
|
25
|
+
hexToString(hex: string): Promise<string> {
|
|
26
|
+
return this.call('hexToString', hex);
|
|
32
27
|
}
|
|
33
28
|
}
|