@docknetwork/wallet-sdk-wasm 1.5.10 → 1.5.11

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.10",
3
+ "version": "1.5.11",
4
4
  "license": "https://github.com/docknetwork/react-native-sdk/LICENSE",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
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.10",
22
+ "@docknetwork/wallet-sdk-dids": "^1.5.11",
23
23
  "@cosmjs/proto-signing": "^0.32.4",
24
24
  "@docknetwork/cheqd-blockchain-api": "0.36.1",
25
25
  "@docknetwork/cheqd-blockchain-modules": "0.33.0",
@@ -132,9 +132,7 @@ export class BlockchainService {
132
132
  });
133
133
  Logger.info(`Cheqd initialized at: ${checkdApiUrl}`);
134
134
  } catch (err) {
135
- console.error(err);
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
 
@@ -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 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';
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 ed25519VerificationKey2018.Ed25519VerificationKey2018(keypairOptions),
65
+ new Ed25519VerificationKey2018(keypairOptions),
66
66
  Ed25519VerificationKey2020: keypairOptions =>
67
- new ed25519VerificationKey2020.Ed25519VerificationKey2020(keypairOptions),
67
+ new Ed25519VerificationKey2020(keypairOptions),
68
68
  X25519KeyAgreementKey2019: keypairOptions =>
69
- new x25519KeyAgreementKey2019.X25519KeyAgreementKey2019(keypairOptions),
69
+ new X25519KeyAgreementKey2019(keypairOptions),
70
70
  X25519KeyAgreementKey2020: keypairOptions =>
71
- new x25519KeyAgreementKey2020.X25519KeyAgreementKey2020(keypairOptions),
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, blockchainService.dock);
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
- getAddressPrefix(params: any): Promise<number | null> {
31
- return this.call('getAddressPrefix', params);
25
+ hexToString(hex: string): Promise<string> {
26
+ return this.call('hexToString', hex);
32
27
  }
33
28
  }