@docknetwork/wallet-sdk-core 1.5.6 → 1.5.9

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.
@@ -3,18 +3,16 @@ import {
3
3
  getAuthURL,
4
4
  decodeRequestJWT,
5
5
  getPresentationSubmision,
6
- } from './oidvc'; // replace with your actual file path
6
+ } from './oidvc';
7
7
  import {credentialServiceRPC} from '@docknetwork/wallet-sdk-wasm/src/services/credential';
8
8
  import {MetadataClient} from '@sphereon/oid4vci-client';
9
9
  import jwtDecode from 'jwt-decode';
10
10
  import axios from 'axios';
11
- import {pexService} from '@docknetwork/wallet-sdk-wasm/src/services/pex';
12
11
 
13
12
  jest.mock('@docknetwork/wallet-sdk-wasm/src/services/credential');
14
13
  jest.mock('@sphereon/oid4vci-client');
15
14
  jest.mock('jwt-decode');
16
15
  jest.mock('axios');
17
- jest.mock('@docknetwork/wallet-sdk-wasm/src/services/pex');
18
16
 
19
17
  describe('acquireOpenIDCredentialFromURI', () => {
20
18
  const didProvider: any = {
@@ -99,14 +97,71 @@ describe('decodeRequestJWT', () => {
99
97
 
100
98
  describe('getPresentationSubmision', () => {
101
99
  it('should get presentation submission', async () => {
102
- const credentials = [{id: 'credential-1'}];
103
- const presentationDefinition = {id: 'presentation-definition-1'};
104
- const holderDID = 'did:example:123';
105
- const presentationSubmission = {definition_id: 'presentation-submission-1'};
100
+ const credentials = [
101
+ {
102
+ '@context': [
103
+ 'https://www.w3.org/2018/credentials/v1',
104
+ 'https://ld.truvera.io/credentials/extensions-v1',
105
+ {
106
+ BasicCredential: 'dk:BasicCredential',
107
+ dk: 'https://ld.truvera.io/credentials#',
108
+ },
109
+ ],
110
+ id: 'https://creds-testnet.truvera.io/8afcb0925ad0d31c6afcc7fdec040f3b6c8260c20cdc6da5042307a9fa0dd7a6',
111
+ type: ['VerifiableCredential', 'BasicCredential'],
112
+ credentialSubject: {
113
+ id: 'did:key:z6MkkS7LbdxSqP8WM5GfsXiNwZC6Ve33aj83eEyzsFGphepp',
114
+ name: 'Test Credential',
115
+ },
116
+ issuanceDate: '2025-02-22T19:14:04.108Z',
117
+ issuer: {
118
+ name: 'Quotient Credit Union',
119
+ description: 'Quotient Credit Union is the credit union.',
120
+ logo: 'https://img.dock.io/06d78272268c606a172d5fd1cd559b46',
121
+ id: 'did:cheqd:testnet:5ad9c962-74e7-4857-891e-95e4a3b035d0',
122
+ },
123
+ name: 'Test Credential',
124
+ proof: {
125
+ type: 'Ed25519Signature2018',
126
+ created: '2025-05-29T18:48:19Z',
127
+ verificationMethod:
128
+ 'did:cheqd:testnet:5ad9c962-74e7-4857-891e-95e4a3b035d0#keys-1',
129
+ proofPurpose: 'assertionMethod',
130
+ jws: 'eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..c5vxz6GKOuWykNKuNVqZ4giOplR3V8YVsJ5Ej4i5Dk3urVFd2ODsAkcu5Th7qWJrD5L3zEJzGEvlUbtRFCS1BQ',
131
+ },
132
+ },
133
+ ];
134
+ const presentationDefinition = {
135
+ id: '94d240d2-b70f-412e-8331-1b610407cce6',
136
+ name: 'Verificação de maioridade',
137
+ purpose: 'Verificação de maioridade',
138
+ input_descriptors: [
139
+ {
140
+ id: 'OpenFinanceCredentialV2',
141
+ name: 'Verificação de maioridade',
142
+ purpose: 'Verificação de maioridade',
143
+ constraints: {
144
+ fields: [
145
+ {
146
+ path: ['$.credentialSubject.name'],
147
+ },
148
+ {
149
+ path: ['$.type', '$.vc.type'],
150
+ filter: {
151
+ type: 'array',
152
+ contains: {
153
+ const: 'BasicCredential',
154
+ },
155
+ },
156
+ },
157
+ ],
158
+ },
159
+ },
160
+ ],
161
+ };
106
162
 
107
- (pexService.presentationFrom as jest.Mock).mockResolvedValue({
108
- presentation_submission: presentationSubmission,
109
- });
163
+ const holderDID =
164
+ 'did:key:z6MkkS7LbdxSqP8WM5GfsXiNwZC6Ve33aj83eEyzsFGphepp';
110
165
 
111
166
  const result = await getPresentationSubmision({
112
167
  credentials,
@@ -114,11 +169,16 @@ describe('getPresentationSubmision', () => {
114
169
  holderDID,
115
170
  });
116
171
 
117
- expect(pexService.presentationFrom).toHaveBeenCalledWith({
118
- presentationDefinition,
119
- credentials,
120
- holderDID,
172
+ expect(result).toStrictEqual({
173
+ id: expect.any(String),
174
+ definition_id: '94d240d2-b70f-412e-8331-1b610407cce6',
175
+ descriptor_map: [
176
+ {
177
+ id: 'OpenFinanceCredentialV2',
178
+ format: 'ldp_vc',
179
+ path: '$.verifiableCredential[0]',
180
+ },
181
+ ],
121
182
  });
122
- expect(result).toEqual(presentationSubmission);
123
183
  });
124
184
  });
@@ -113,7 +113,7 @@ export async function getPresentationSubmision({
113
113
  holderDID,
114
114
  });
115
115
 
116
- return presentation.presentation_submission;
116
+ return presentation?.presentation_submission;
117
117
  }
118
118
 
119
119
  pexService.evaluatePresentation;