@sphereon/oid4vci-client 0.12.1-next.2 → 0.12.1-next.22

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.
Files changed (60) hide show
  1. package/dist/AccessTokenClient.d.ts.map +1 -1
  2. package/dist/AccessTokenClient.js +7 -5
  3. package/dist/AccessTokenClient.js.map +1 -1
  4. package/dist/AccessTokenClientV1_0_11.d.ts.map +1 -1
  5. package/dist/AccessTokenClientV1_0_11.js +7 -5
  6. package/dist/AccessTokenClientV1_0_11.js.map +1 -1
  7. package/dist/CredentialRequestClient.d.ts +3 -2
  8. package/dist/CredentialRequestClient.d.ts.map +1 -1
  9. package/dist/CredentialRequestClient.js.map +1 -1
  10. package/dist/CredentialRequestClientBuilder.d.ts +7 -15
  11. package/dist/CredentialRequestClientBuilder.d.ts.map +1 -1
  12. package/dist/CredentialRequestClientBuilder.js +79 -55
  13. package/dist/CredentialRequestClientBuilder.js.map +1 -1
  14. package/dist/CredentialRequestClientBuilderV1_0_13.d.ts +51 -0
  15. package/dist/CredentialRequestClientBuilderV1_0_13.d.ts.map +1 -0
  16. package/dist/CredentialRequestClientBuilderV1_0_13.js +130 -0
  17. package/dist/CredentialRequestClientBuilderV1_0_13.js.map +1 -0
  18. package/dist/OpenID4VCIClient.d.ts +3 -1
  19. package/dist/OpenID4VCIClient.d.ts.map +1 -1
  20. package/dist/OpenID4VCIClient.js +31 -16
  21. package/dist/OpenID4VCIClient.js.map +1 -1
  22. package/dist/OpenID4VCIClientV1_0_11.d.ts +3 -2
  23. package/dist/OpenID4VCIClientV1_0_11.d.ts.map +1 -1
  24. package/dist/OpenID4VCIClientV1_0_11.js +26 -10
  25. package/dist/OpenID4VCIClientV1_0_11.js.map +1 -1
  26. package/dist/OpenID4VCIClientV1_0_13.d.ts +2 -1
  27. package/dist/OpenID4VCIClientV1_0_13.d.ts.map +1 -1
  28. package/dist/OpenID4VCIClientV1_0_13.js +26 -12
  29. package/dist/OpenID4VCIClientV1_0_13.js.map +1 -1
  30. package/dist/functions/AccessTokenUtil.d.ts +5 -0
  31. package/dist/functions/AccessTokenUtil.d.ts.map +1 -0
  32. package/dist/functions/AccessTokenUtil.js +55 -0
  33. package/dist/functions/AccessTokenUtil.js.map +1 -0
  34. package/dist/functions/index.d.ts +2 -0
  35. package/dist/functions/index.d.ts.map +1 -1
  36. package/dist/functions/index.js +2 -0
  37. package/dist/functions/index.js.map +1 -1
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +1 -0
  41. package/dist/index.js.map +1 -1
  42. package/lib/AccessTokenClient.ts +5 -4
  43. package/lib/AccessTokenClientV1_0_11.ts +6 -3
  44. package/lib/CredentialRequestClient.ts +3 -2
  45. package/lib/CredentialRequestClientBuilder.ts +98 -67
  46. package/lib/CredentialRequestClientBuilderV1_0_13.ts +173 -0
  47. package/lib/OpenID4VCIClient.ts +33 -6
  48. package/lib/OpenID4VCIClientV1_0_11.ts +32 -5
  49. package/lib/OpenID4VCIClientV1_0_13.ts +30 -5
  50. package/lib/__tests__/CredentialRequestClient.spec.ts +8 -13
  51. package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +40 -2
  52. package/lib/__tests__/CredentialRequestClientV1_0_11.spec.ts +96 -0
  53. package/lib/__tests__/IT.spec.ts +148 -111
  54. package/lib/__tests__/MetadataMocks.ts +35 -0
  55. package/lib/__tests__/ProofOfPossessionBuilder.spec.ts +85 -0
  56. package/lib/__tests__/SdJwt.spec.ts +103 -0
  57. package/lib/functions/AccessTokenUtil.ts +45 -0
  58. package/lib/functions/index.ts +2 -0
  59. package/lib/index.ts +1 -0
  60. package/package.json +3 -3
@@ -20,13 +20,8 @@ import * as jose from 'jose';
20
20
  // @ts-ignore
21
21
  import nock from 'nock';
22
22
 
23
- import {
24
- CredentialOfferClientV1_0_11,
25
- CredentialRequestClientBuilder,
26
- CredentialRequestClientBuilderV1_0_11,
27
- MetadataClientV1_0_11,
28
- ProofOfPossessionBuilder,
29
- } from '..';
23
+ import { CredentialOfferClient, MetadataClient, ProofOfPossessionBuilder } from '..';
24
+ import { CredentialRequestClientBuilder } from '../CredentialRequestClientBuilder';
30
25
 
31
26
  import { IDENTIPROOF_ISSUER_URL, IDENTIPROOF_OID4VCI_METADATA, INITIATION_TEST, WALT_OID4VCI_METADATA } from './MetadataMocks';
32
27
  import { getMockData } from './data/VciDataFixtures';
@@ -154,14 +149,14 @@ describe('Credential Request Client with Walt.id ', () => {
154
149
  nock.cleanAll();
155
150
  const WALT_IRR_URI =
156
151
  'openid-initiate-issuance://?issuer=https%3A%2F%2Fjff.walt.id%2Fissuer-api%2Foidc%2F&credential_type=OpenBadgeCredential&pre-authorized_code=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhOTUyZjUxNi1jYWVmLTQ4YjMtODIxYy00OTRkYzgyNjljZjAiLCJwcmUtYXV0aG9yaXplZCI6dHJ1ZX0.YE5DlalcLC2ChGEg47CQDaN1gTxbaQqSclIVqsSAUHE&user_pin_required=false';
157
- const credentialOffer = await CredentialOfferClientV1_0_11.fromURI(WALT_IRR_URI);
152
+ const credentialOffer = await CredentialOfferClient.fromURI(WALT_IRR_URI);
158
153
 
159
154
  const request = credentialOffer.credential_offer;
160
- const metadata = await MetadataClientV1_0_11.retrieveAllMetadata(getIssuerFromCredentialOfferPayload(request) as string);
155
+ const metadata = await MetadataClient.retrieveAllMetadata(getIssuerFromCredentialOfferPayload(request) as string);
161
156
  expect(metadata.credential_endpoint).toEqual(WALT_OID4VCI_METADATA.credential_endpoint);
162
157
  expect(metadata.token_endpoint).toEqual(WALT_OID4VCI_METADATA.token_endpoint);
163
158
 
164
- const credReqClient = CredentialRequestClientBuilderV1_0_11.fromCredentialOffer({
159
+ const credReqClient = CredentialRequestClientBuilder.fromCredentialOffer({
165
160
  credentialOffer,
166
161
  metadata,
167
162
  }).build();
@@ -205,7 +200,7 @@ describe('Credential Request Client with different issuers ', () => {
205
200
  const IRR_URI =
206
201
  'openid-initiate-issuance://?issuer=https%3A%2F%2Fjff.walt.id%2Fissuer-api%2Fdefault%2Foidc%2F&credential_type=OpenBadgeCredential&pre-authorized_code=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIwMTc4OTNjYy04ZTY3LTQxNzItYWZlOS1lODcyYmYxNDBlNWMiLCJwcmUtYXV0aG9yaXplZCI6dHJ1ZX0.ODfq2AIhOcB61dAb3zMrXBJjPJaf53zkeHh_AssYyYA&user_pin_required=false';
207
202
  const credentialOffer = await (
208
- await CredentialRequestClientBuilderV1_0_11.fromURI({
203
+ await CredentialRequestClientBuilder.fromURI({
209
204
  uri: IRR_URI,
210
205
  metadata: getMockData('walt')?.metadata as unknown as EndpointMetadata,
211
206
  })
@@ -250,7 +245,7 @@ describe('Credential Request Client with different issuers ', () => {
250
245
  const IRR_URI =
251
246
  'openid-initiate-issuance://?issuer=https://launchpad.mattrlabs.com&credential_type=OpenBadgeCredential&pre-authorized_code=g0UCOj6RAN5AwHU6gczm_GzB4_lH6GW39Z0Dl2DOOiO';
252
247
  const credentialOffer = await (
253
- await CredentialRequestClientBuilderV1_0_11.fromURI({
248
+ await CredentialRequestClientBuilder.fromURI({
254
249
  uri: IRR_URI,
255
250
  metadata: getMockData('mattr')?.metadata as unknown as EndpointMetadata,
256
251
  })
@@ -273,7 +268,7 @@ describe('Credential Request Client with different issuers ', () => {
273
268
  const IRR_URI =
274
269
  'openid-initiate-issuance://?issuer=https://oidc4vc.diwala.io&credential_type=OpenBadgeCredential&pre-authorized_code=eyJhbGciOiJIUzI1NiJ9.eyJjcmVkZW50aWFsX3R5cGUiOiJPcGVuQmFkZ2VDcmVkZW50aWFsIiwiZXhwIjoxNjgxOTg0NDY3fQ.fEAHKz2nuWfiYHw406iNxr-81pWkNkbi31bWsYSf6Ng';
275
270
  const credentialOffer = await (
276
- await CredentialRequestClientBuilderV1_0_11.fromURI({
271
+ await CredentialRequestClientBuilder.fromURI({
277
272
  uri: IRR_URI,
278
273
  metadata: getMockData('diwala')?.metadata as unknown as EndpointMetadata,
279
274
  })
@@ -11,11 +11,13 @@ import {
11
11
  } from '@sphereon/oid4vci-common';
12
12
  import * as jose from 'jose';
13
13
 
14
- import { CredentialRequestClientBuilder, ProofOfPossessionBuilder } from '..';
14
+ import { CredentialRequestOpts, ProofOfPossessionBuilder } from '..';
15
+ import { CredentialRequestClientBuilder } from '../CredentialRequestClientBuilder';
15
16
 
16
17
  import { IDENTIPROOF_ISSUER_URL, IDENTIPROOF_OID4VCI_METADATA, INITIATION_TEST_URI, WALT_ISSUER_URL, WALT_OID4VCI_METADATA } from './MetadataMocks';
17
18
 
18
19
  const partialJWT = 'eyJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJkaWQ6ZXhhbXBsZTplYmZlYjFmN';
20
+ const partialJWT_withoutDid = 'eyJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJlYmZlYjFmNzEyZWJjNmYxYzI3N';
19
21
 
20
22
  /*const jwtv1_0_08: Jwt = {
21
23
  header: { alg: Alg.ES256, kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1', typ: 'jwt' },
@@ -27,8 +29,15 @@ const jwtv1_0_11: Jwt = {
27
29
  payload: { iss: 'sphereon:wallet', nonce: 'tZignsnFbp', jti: 'tZignsnFbp223', aud: IDENTIPROOF_ISSUER_URL },
28
30
  };
29
31
 
32
+ const jwtv1_0_13_withoutDid: Jwt = {
33
+ header: { alg: Alg.ES256, kid: 'ebfeb1f712ebc6f1c276e12ec21/keys/1', typ: 'openid4vci-proof+jwt' },
34
+ payload: { iss: 'sphereon:wallet', nonce: 'tZignsnFbp', jti: 'tZignsnFbp223', aud: IDENTIPROOF_ISSUER_URL },
35
+ };
36
+
30
37
  const kid = 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1';
31
38
 
39
+ const kid_withoutDid = 'ebfeb1f712ebc6f1c276e12ec21/keys/1';
40
+
32
41
  let keypair: KeyPair;
33
42
 
34
43
  beforeAll(async () => {
@@ -81,7 +90,7 @@ describe('Credential Request Client Builder', () => {
81
90
  .build();
82
91
  expect(credReqClient.credentialRequestOpts.credentialEndpoint).toBe('https://oidc4vci.demo.spruceid.com/credential');
83
92
  expect(credReqClient.credentialRequestOpts.format).toBe('jwt_vc');
84
- expect(credReqClient.credentialRequestOpts.credentialIdentifier).toStrictEqual('credentialType');
93
+ expect((credReqClient.credentialRequestOpts as CredentialRequestOpts).credentialIdentifier).toStrictEqual('credentialType');
85
94
  expect(credReqClient.credentialRequestOpts.token).toBe('token');
86
95
  });
87
96
 
@@ -115,6 +124,35 @@ describe('Credential Request Client Builder', () => {
115
124
  }
116
125
  });
117
126
 
127
+ it('should build credential request correctly without did', async () => {
128
+ const credReqClient = (await CredentialRequestClientBuilder.fromURI({ uri: INITIATION_TEST_URI }))
129
+ .withCredentialEndpoint('https://oidc4vci.demo.spruceid.com/credential')
130
+ .withFormat('jwt_vc')
131
+ .withCredentialType('OpenBadgeCredential')
132
+ .build();
133
+ const proof: ProofOfPossession = await ProofOfPossessionBuilder.fromJwt({
134
+ jwt: jwtv1_0_13_withoutDid,
135
+ callbacks: {
136
+ signCallback: proofOfPossessionCallbackFunction,
137
+ verifyCallback: proofOfPossessionVerifierCallbackFunction,
138
+ },
139
+ version: OpenId4VCIVersion.VER_1_0_13,
140
+ })
141
+ .withClientId('sphereon:wallet')
142
+ .withKid(kid_withoutDid)
143
+ .build();
144
+ await proofOfPossessionVerifierCallbackFunction({ ...proof, kid: kid_withoutDid });
145
+ const credentialRequest: CredentialRequestV1_0_13 = await credReqClient.createCredentialRequest({
146
+ proofInput: proof,
147
+ credentialTypes: 'OpenBadgeCredential',
148
+ version: OpenId4VCIVersion.VER_1_0_13,
149
+ });
150
+ expect(credentialRequest.proof?.jwt).toContain(partialJWT_withoutDid);
151
+ if ('types' in credentialRequest) {
152
+ expect(credentialRequest.types).toStrictEqual(['OpenBadgeCredential']);
153
+ }
154
+ });
155
+
118
156
  it('should build correctly from metadata', async () => {
119
157
  const credReqClient = (
120
158
  await CredentialRequestClientBuilder.fromURI({
@@ -28,14 +28,22 @@ import {
28
28
  import { getMockData } from './data/VciDataFixtures';
29
29
 
30
30
  const partialJWT = 'eyJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJkaWQ6ZXhhbXBsZTplYmZlYjFmN';
31
+ const partialJWT_withoutDid = 'eyJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJlYmZlYjFmNzEyZWJjNmYxYzI3N';
31
32
 
32
33
  const jwt: Jwt = {
33
34
  header: { alg: Alg.ES256, kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1', typ: 'jwt' },
34
35
  payload: { iss: 'sphereon:wallet', nonce: 'tZignsnFbp', jti: 'tZignsnFbp223', aud: IDENTIPROOF_ISSUER_URL },
35
36
  };
36
37
 
38
+ const jwt_withoutDid: Jwt = {
39
+ header: { alg: Alg.ES256, kid: 'ebfeb1f712ebc6f1c276e12ec21/keys/1', typ: 'jwt' },
40
+ payload: { iss: 'sphereon:wallet', nonce: 'tZignsnFbp', jti: 'tZignsnFbp223', aud: IDENTIPROOF_ISSUER_URL },
41
+ };
42
+
37
43
  const kid = 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1';
38
44
 
45
+ const kid_withoutDid = 'ebfeb1f712ebc6f1c276e12ec21/keys/1';
46
+
39
47
  let keypair: KeyPair;
40
48
 
41
49
  async function proofOfPossessionCallbackFunction(args: Jwt, kid?: string): Promise<string> {
@@ -102,6 +110,36 @@ describe('Credential Request Client ', () => {
102
110
  expect(result?.errorBody?.error).toBe('unsupported_format');
103
111
  });
104
112
 
113
+ it('should get a failed credential response with an unsupported format and without did', async function () {
114
+ const basePath = 'https://sphereonjunit2022101301.com/';
115
+ nock(basePath).post(/.*/).reply(500, {
116
+ error: 'unsupported_format',
117
+ error_description: 'This is a mock error message',
118
+ });
119
+
120
+ const credReqClient = CredentialRequestClientBuilderV1_0_11.fromCredentialOffer({ credentialOffer: INITIATION_TEST_V1_0_08 })
121
+ .withCredentialEndpoint(basePath + '/credential')
122
+ .withFormat('ldp_vc')
123
+ .withCredentialType('https://imsglobal.github.io/openbadges-specification/ob_v3p0.html#OpenBadgeCredential')
124
+ .build();
125
+ const proof: ProofOfPossession = await ProofOfPossessionBuilder.fromJwt({
126
+ jwt: jwt_withoutDid,
127
+ callbacks: {
128
+ signCallback: proofOfPossessionCallbackFunction,
129
+ },
130
+ version: OpenId4VCIVersion.VER_1_0_08,
131
+ })
132
+ // .withEndpointMetadata(metadata)
133
+ .withClientId('sphereon:wallet')
134
+ .withKid(kid_withoutDid)
135
+ .build();
136
+ expect(credReqClient.getCredentialEndpoint()).toEqual(basePath + '/credential');
137
+ const credentialRequest = await credReqClient.createCredentialRequest({ proofInput: proof, version: OpenId4VCIVersion.VER_1_0_08 });
138
+ expect(credentialRequest.proof?.jwt?.includes(partialJWT_withoutDid)).toBeTruthy();
139
+ const result = await credReqClient.acquireCredentialsUsingRequest(credentialRequest);
140
+ expect(result?.errorBody?.error).toBe('unsupported_format');
141
+ });
142
+
105
143
  it('should get success credential response', async function () {
106
144
  const mockedVC =
107
145
  'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL2V4YW1wbGVzL3YxIl0sImlkIjoiaHR0cDovL2V4YW1wbGUuZWR1L2NyZWRlbnRpYWxzLzM3MzIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVW5pdmVyc2l0eURlZ3JlZUNyZWRlbnRpYWwiXSwiaXNzdWVyIjoiaHR0cHM6Ly9leGFtcGxlLmVkdS9pc3N1ZXJzLzU2NTA0OSIsImlzc3VhbmNlRGF0ZSI6IjIwMTAtMDEtMDFUMDA6MDA6MDBaIiwiY3JlZGVudGlhbFN1YmplY3QiOnsiaWQiOiJkaWQ6ZXhhbXBsZTplYmZlYjFmNzEyZWJjNmYxYzI3NmUxMmVjMjEiLCJkZWdyZWUiOnsidHlwZSI6IkJhY2hlbG9yRGVncmVlIiwibmFtZSI6IkJhY2hlbG9yIG9mIFNjaWVuY2UgYW5kIEFydHMifX19LCJpc3MiOiJodHRwczovL2V4YW1wbGUuZWR1L2lzc3VlcnMvNTY1MDQ5IiwibmJmIjoxMjYyMzA0MDAwLCJqdGkiOiJodHRwOi8vZXhhbXBsZS5lZHUvY3JlZGVudGlhbHMvMzczMiIsInN1YiI6ImRpZDpleGFtcGxlOmViZmViMWY3MTJlYmM2ZjFjMjc2ZTEyZWMyMSJ9.z5vgMTK1nfizNCg5N-niCOL3WUIAL7nXy-nGhDZYO_-PNGeE-0djCpWAMH8fD8eWSID5PfkPBYkx_dfLJnQ7NA';
@@ -138,6 +176,42 @@ describe('Credential Request Client ', () => {
138
176
  expect(result?.successBody?.credential).toEqual(mockedVC);
139
177
  });
140
178
 
179
+ it('should get success credential response without did', async function () {
180
+ const mockedVC =
181
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL2V4YW1wbGVzL3YxIl0sImlkIjoiaHR0cDovL2V4YW1wbGUuZWR1L2NyZWRlbnRpYWxzLzM3MzIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVW5pdmVyc2l0eURlZ3JlZUNyZWRlbnRpYWwiXSwiaXNzdWVyIjoiaHR0cHM6Ly9leGFtcGxlLmVkdS9pc3N1ZXJzLzU2NTA0OSIsImlzc3VhbmNlRGF0ZSI6IjIwMTAtMDEtMDFUMDA6MDA6MDBaIiwiY3JlZGVudGlhbFN1YmplY3QiOnsiaWQiOiJlYmZlYjFmNzEyZWJjNmYxYzI3NmUxMmVjMjEiLCJkZWdyZWUiOnsidHlwZSI6IkJhY2hlbG9yRGVncmVlIiwibmFtZSI6IkJhY2hlbG9yIG9mIFNjaWVuY2UgYW5kIEFydHMifX19LCJpc3MiOiJodHRwczovL2V4YW1wbGUuZWR1L2lzc3VlcnMvNTY1MDQ5IiwibmJmIjoxMjYyMzA0MDAwLCJqdGkiOiJodHRwOi8vZXhhbXBsZS5lZHUvY3JlZGVudGlhbHMvMzczMiIsInN1YiI6ImViZmViMWY3MTJlYmM2ZjFjMjc2ZTEyZWMyMSIsImlhdCI6MTcxODM1NzcxOH0.7iiOTuIjQRyrIincYyDW6m0nBYmDoYfXcTYFrywsKEY';
182
+ nock('https://oidc4vci.demo.spruceid.com')
183
+ .post(/credential/)
184
+ .reply(200, {
185
+ format: 'jwt-vc',
186
+ credential: mockedVC,
187
+ });
188
+ const credReqClient = CredentialRequestClientBuilderV1_0_11.fromCredentialOfferRequest({ request: INITIATION_TEST })
189
+ .withCredentialEndpoint('https://oidc4vci.demo.spruceid.com/credential')
190
+ .withFormat('jwt_vc')
191
+ .withCredentialType('https://imsglobal.github.io/openbadges-specification/ob_v3p0.html#OpenBadgeCredential')
192
+ .build();
193
+ const proof: ProofOfPossession = await ProofOfPossessionBuilder.fromJwt({
194
+ jwt: jwt_withoutDid,
195
+ callbacks: {
196
+ signCallback: proofOfPossessionCallbackFunction,
197
+ },
198
+ version: OpenId4VCIVersion.VER_1_0_08,
199
+ })
200
+ // .withEndpointMetadata(metadata)
201
+ .withKid(kid_withoutDid)
202
+ .withClientId('sphereon:wallet')
203
+ .build();
204
+ const credentialRequest = await credReqClient.createCredentialRequest({
205
+ proofInput: proof,
206
+ format: 'jwt',
207
+ version: OpenId4VCIVersion.VER_1_0_08,
208
+ });
209
+ expect(credentialRequest.proof?.jwt?.includes(partialJWT_withoutDid)).toBeTruthy();
210
+ expect(credentialRequest.format).toEqual('jwt_vc');
211
+ const result = await credReqClient.acquireCredentialsUsingRequest(credentialRequest);
212
+ expect(result?.successBody?.credential).toEqual(mockedVC);
213
+ });
214
+
141
215
  it('should fail with invalid url', async () => {
142
216
  const credReqClient = CredentialRequestClientBuilderV1_0_11.fromCredentialOfferRequest({ request: INITIATION_TEST })
143
217
  .withCredentialEndpoint('httpsf://oidc4vci.demo.spruceid.com/credential')
@@ -159,6 +233,28 @@ describe('Credential Request Client ', () => {
159
233
  Error(URL_NOT_VALID),
160
234
  );
161
235
  });
236
+
237
+ it('should fail with invalid url without did', async () => {
238
+ const credReqClient = CredentialRequestClientBuilderV1_0_11.fromCredentialOfferRequest({ request: INITIATION_TEST })
239
+ .withCredentialEndpoint('httpsf://oidc4vci.demo.spruceid.com/credential')
240
+ .withFormat('jwt_vc')
241
+ .withCredentialType('https://imsglobal.github.io/openbadges-specification/ob_v3p0.html#OpenBadgeCredential')
242
+ .build();
243
+ const proof: ProofOfPossession = await ProofOfPossessionBuilder.fromJwt({
244
+ jwt: jwt_withoutDid,
245
+ callbacks: {
246
+ signCallback: proofOfPossessionCallbackFunction,
247
+ },
248
+ version: OpenId4VCIVersion.VER_1_0_08,
249
+ })
250
+ // .withEndpointMetadata(metadata)
251
+ .withKid(kid_withoutDid)
252
+ .withClientId('sphereon:wallet')
253
+ .build();
254
+ await expect(credReqClient.acquireCredentialsUsingRequest({ format: 'jwt_vc_json', types: ['random'], proof })).rejects.toThrow(
255
+ Error(URL_NOT_VALID),
256
+ );
257
+ });
162
258
  });
163
259
 
164
260
  describe('Credential Request Client with Walt.id ', () => {