@sphereon/oid4vci-client 0.16.1-next.4 → 0.16.1-next.48
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/dist/AccessTokenClient.d.ts.map +1 -1
- package/dist/AccessTokenClient.js +10 -9
- package/dist/AccessTokenClient.js.map +1 -1
- package/dist/AccessTokenClientV1_0_11.js +9 -8
- package/dist/AccessTokenClientV1_0_11.js.map +1 -1
- package/dist/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/AuthorizationCodeClient.js +3 -2
- package/dist/AuthorizationCodeClient.js.map +1 -1
- package/dist/AuthorizationCodeClientV1_0_11.js.map +1 -1
- package/dist/CredentialRequestClient.d.ts +36 -12
- package/dist/CredentialRequestClient.d.ts.map +1 -1
- package/dist/CredentialRequestClient.js +56 -14
- package/dist/CredentialRequestClient.js.map +1 -1
- package/dist/CredentialRequestClientV1_0_11.d.ts.map +1 -1
- package/dist/CredentialRequestClientV1_0_11.js +10 -0
- package/dist/CredentialRequestClientV1_0_11.js.map +1 -1
- package/dist/MetadataClient.d.ts +1 -0
- package/dist/MetadataClient.d.ts.map +1 -1
- package/dist/MetadataClient.js +5 -4
- package/dist/MetadataClient.js.map +1 -1
- package/dist/MetadataClientV1_0_13.d.ts +1 -0
- package/dist/MetadataClientV1_0_13.d.ts.map +1 -1
- package/dist/MetadataClientV1_0_13.js +5 -4
- package/dist/MetadataClientV1_0_13.js.map +1 -1
- package/dist/OpenID4VCIClient.d.ts +3 -1
- package/dist/OpenID4VCIClient.d.ts.map +1 -1
- package/dist/OpenID4VCIClientV1_0_11.d.ts +3 -1
- package/dist/OpenID4VCIClientV1_0_11.d.ts.map +1 -1
- package/dist/OpenID4VCIClientV1_0_13.d.ts +21 -2
- package/dist/OpenID4VCIClientV1_0_13.d.ts.map +1 -1
- package/dist/OpenID4VCIClientV1_0_13.js +54 -23
- package/dist/OpenID4VCIClientV1_0_13.js.map +1 -1
- package/dist/ProofOfPossessionBuilder.d.ts +1 -1
- package/dist/ProofOfPossessionBuilder.d.ts.map +1 -1
- package/lib/AccessTokenClient.ts +13 -12
- package/lib/AccessTokenClientV1_0_11.ts +11 -11
- package/lib/AuthorizationCodeClient.ts +3 -1
- package/lib/AuthorizationCodeClientV1_0_11.ts +2 -2
- package/lib/CredentialRequestClient.ts +94 -21
- package/lib/CredentialRequestClientV1_0_11.ts +10 -0
- package/lib/MetadataClient.ts +2 -1
- package/lib/MetadataClientV1_0_13.ts +2 -1
- package/lib/OpenID4VCIClient.ts +1 -1
- package/lib/OpenID4VCIClientV1_0_11.ts +1 -1
- package/lib/OpenID4VCIClientV1_0_13.ts +82 -30
- package/lib/ProofOfPossessionBuilder.ts +1 -1
- package/lib/__tests__/IT.spec.ts +1 -1
- package/package.json +5 -5
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
CodeChallengeMethod,
|
|
5
5
|
convertJsonToURI,
|
|
6
6
|
CreateRequestObjectMode,
|
|
7
|
-
|
|
7
|
+
CredentialOfferFormatV1_0_11,
|
|
8
8
|
CredentialOfferPayloadV1_0_11,
|
|
9
9
|
CredentialOfferRequestWithBaseUrl,
|
|
10
10
|
CredentialsSupportedLegacy,
|
|
@@ -47,7 +47,7 @@ export const createAuthorizationRequestUrlV1_0_11 = async ({
|
|
|
47
47
|
if (!credentialOffer) {
|
|
48
48
|
throw Error('Please provide a scope or authorization_details if no credential offer is present');
|
|
49
49
|
}
|
|
50
|
-
const creds: (
|
|
50
|
+
const creds: (CredentialOfferFormatV1_0_11 | string)[] = (credentialOffer.credential_offer as CredentialOfferPayloadV1_0_11).credentials;
|
|
51
51
|
|
|
52
52
|
// FIXME: complains about VCT for sd-jwt
|
|
53
53
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -2,6 +2,7 @@ import { createDPoP, CreateDPoPClientOpts, getCreateDPoPOptions } from '@sphereo
|
|
|
2
2
|
import {
|
|
3
3
|
acquireDeferredCredential,
|
|
4
4
|
CredentialRequestV1_0_13,
|
|
5
|
+
CredentialRequestWithoutProofV1_0_13,
|
|
5
6
|
CredentialResponse,
|
|
6
7
|
DPoPResponseParams,
|
|
7
8
|
getCredentialRequestForVersion,
|
|
@@ -16,8 +17,8 @@ import {
|
|
|
16
17
|
UniformCredentialRequest,
|
|
17
18
|
URL_NOT_VALID,
|
|
18
19
|
} from '@sphereon/oid4vci-common';
|
|
19
|
-
import { ExperimentalSubjectIssuance } from '@sphereon/oid4vci-common
|
|
20
|
-
import { CredentialFormat } from '@sphereon/ssi-types';
|
|
20
|
+
import { ExperimentalSubjectIssuance } from '@sphereon/oid4vci-common';
|
|
21
|
+
import { CredentialFormat, DIDDocument } from '@sphereon/ssi-types';
|
|
21
22
|
import Debug from 'debug';
|
|
22
23
|
|
|
23
24
|
import { CredentialRequestClientBuilderV1_0_11 } from './CredentialRequestClientBuilderV1_0_11';
|
|
@@ -42,7 +43,16 @@ export interface CredentialRequestOpts {
|
|
|
42
43
|
subjectIssuance?: ExperimentalSubjectIssuance;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export
|
|
46
|
+
export type CreateCredentialRequestOpts<DIDDoc = DIDDocument> = {
|
|
47
|
+
credentialIdentifier?: string;
|
|
48
|
+
credentialTypes?: string | string[];
|
|
49
|
+
context?: string[];
|
|
50
|
+
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
51
|
+
subjectIssuance?: ExperimentalSubjectIssuance;
|
|
52
|
+
version: OpenId4VCIVersion;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export async function buildProof<DIDDoc = DIDDocument>(
|
|
46
56
|
proofInput: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession,
|
|
47
57
|
opts: {
|
|
48
58
|
version: OpenId4VCIVersion;
|
|
@@ -85,7 +95,34 @@ export class CredentialRequestClient {
|
|
|
85
95
|
this._credentialRequestOpts = { ...builder };
|
|
86
96
|
}
|
|
87
97
|
|
|
88
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Typically you should not use this method, as it omits a proof from the request.
|
|
100
|
+
* There are certain issuers that in specific circumstances can do without this proof, because they have other means of user binding
|
|
101
|
+
* like using DPoP together with an authorization code flow. These are however rare, so you should be using the acquireCredentialsUsingProof normally
|
|
102
|
+
* @param opts
|
|
103
|
+
*/
|
|
104
|
+
public async acquireCredentialsWithoutProof<DIDDoc = DIDDocument>(opts: {
|
|
105
|
+
credentialIdentifier?: string;
|
|
106
|
+
credentialTypes?: string | string[];
|
|
107
|
+
context?: string[];
|
|
108
|
+
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
109
|
+
subjectIssuance?: ExperimentalSubjectIssuance;
|
|
110
|
+
createDPoPOpts?: CreateDPoPClientOpts;
|
|
111
|
+
}): Promise<OpenIDResponse<CredentialResponse, DPoPResponseParams> & { access_token: string }> {
|
|
112
|
+
const { credentialIdentifier, credentialTypes, format, context, subjectIssuance } = opts;
|
|
113
|
+
|
|
114
|
+
const request = await this.createCredentialRequestWithoutProof<DIDDoc>({
|
|
115
|
+
credentialTypes,
|
|
116
|
+
context,
|
|
117
|
+
format,
|
|
118
|
+
version: this.version(),
|
|
119
|
+
credentialIdentifier,
|
|
120
|
+
subjectIssuance,
|
|
121
|
+
});
|
|
122
|
+
return await this.acquireCredentialsUsingRequestWithoutProof(request, opts.createDPoPOpts);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public async acquireCredentialsUsingProof<DIDDoc = DIDDocument>(opts: {
|
|
89
126
|
proofInput: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession;
|
|
90
127
|
credentialIdentifier?: string;
|
|
91
128
|
credentialTypes?: string | string[];
|
|
@@ -96,7 +133,7 @@ export class CredentialRequestClient {
|
|
|
96
133
|
}): Promise<OpenIDResponse<CredentialResponse, DPoPResponseParams> & { access_token: string }> {
|
|
97
134
|
const { credentialIdentifier, credentialTypes, proofInput, format, context, subjectIssuance } = opts;
|
|
98
135
|
|
|
99
|
-
const request = await this.createCredentialRequest({
|
|
136
|
+
const request = await this.createCredentialRequest<DIDDoc>({
|
|
100
137
|
proofInput,
|
|
101
138
|
credentialTypes,
|
|
102
139
|
context,
|
|
@@ -108,9 +145,23 @@ export class CredentialRequestClient {
|
|
|
108
145
|
return await this.acquireCredentialsUsingRequest(request, opts.createDPoPOpts);
|
|
109
146
|
}
|
|
110
147
|
|
|
148
|
+
public async acquireCredentialsUsingRequestWithoutProof(
|
|
149
|
+
uniformRequest: UniformCredentialRequest,
|
|
150
|
+
createDPoPOpts?: CreateDPoPClientOpts,
|
|
151
|
+
): Promise<OpenIDResponse<CredentialResponse, DPoPResponseParams> & { access_token: string }> {
|
|
152
|
+
return await this.acquireCredentialsUsingRequestImpl(uniformRequest, createDPoPOpts);
|
|
153
|
+
}
|
|
154
|
+
|
|
111
155
|
public async acquireCredentialsUsingRequest(
|
|
112
156
|
uniformRequest: UniformCredentialRequest,
|
|
113
157
|
createDPoPOpts?: CreateDPoPClientOpts,
|
|
158
|
+
): Promise<OpenIDResponse<CredentialResponse, DPoPResponseParams> & { access_token: string }> {
|
|
159
|
+
return await this.acquireCredentialsUsingRequestImpl(uniformRequest, createDPoPOpts);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private async acquireCredentialsUsingRequestImpl(
|
|
163
|
+
uniformRequest: UniformCredentialRequest & { proof?: ProofOfPossession },
|
|
164
|
+
createDPoPOpts?: CreateDPoPClientOpts,
|
|
114
165
|
): Promise<OpenIDResponse<CredentialResponse, DPoPResponseParams> & { access_token: string }> {
|
|
115
166
|
if (this.version() < OpenId4VCIVersion.VER_1_0_13) {
|
|
116
167
|
throw new Error('Versions below v1.0.13 (draft 13) are not supported by the V13 credential request client.');
|
|
@@ -194,24 +245,37 @@ export class CredentialRequestClient {
|
|
|
194
245
|
});
|
|
195
246
|
}
|
|
196
247
|
|
|
197
|
-
public async
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
248
|
+
public async createCredentialRequestWithoutProof<DIDDoc = DIDDocument>(
|
|
249
|
+
opts: CreateCredentialRequestOpts<DIDDoc>,
|
|
250
|
+
): Promise<CredentialRequestWithoutProofV1_0_13> {
|
|
251
|
+
return await this.createCredentialRequestImpl(opts);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
public async createCredentialRequest<DIDDoc = DIDDocument>(
|
|
255
|
+
opts: CreateCredentialRequestOpts<DIDDoc> & {
|
|
256
|
+
proofInput: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession;
|
|
257
|
+
},
|
|
258
|
+
): Promise<CredentialRequestV1_0_13> {
|
|
259
|
+
return await this.createCredentialRequestImpl(opts);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private async createCredentialRequestImpl<DIDDoc = DIDDocument>(
|
|
263
|
+
opts: CreateCredentialRequestOpts<DIDDoc> & {
|
|
264
|
+
proofInput?: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession;
|
|
265
|
+
},
|
|
266
|
+
): Promise<CredentialRequestV1_0_13> {
|
|
206
267
|
const { proofInput, credentialIdentifier: credential_identifier } = opts;
|
|
207
|
-
|
|
268
|
+
let proof: ProofOfPossession | undefined = undefined;
|
|
269
|
+
if (proofInput) {
|
|
270
|
+
proof = await buildProof(proofInput, opts);
|
|
271
|
+
}
|
|
208
272
|
if (credential_identifier) {
|
|
209
273
|
if (opts.format || opts.credentialTypes || opts.context) {
|
|
210
274
|
throw Error(`You cannot mix credential_identifier with format, credential types and/or context`);
|
|
211
275
|
}
|
|
212
276
|
return {
|
|
213
277
|
credential_identifier,
|
|
214
|
-
proof,
|
|
278
|
+
...(proof && { proof }),
|
|
215
279
|
};
|
|
216
280
|
}
|
|
217
281
|
const formatSelection = opts.format ?? this.credentialRequestOpts.format;
|
|
@@ -239,7 +303,7 @@ export class CredentialRequestClient {
|
|
|
239
303
|
type: types,
|
|
240
304
|
},
|
|
241
305
|
format,
|
|
242
|
-
proof,
|
|
306
|
+
...(proof && { proof }),
|
|
243
307
|
...opts.subjectIssuance,
|
|
244
308
|
};
|
|
245
309
|
} else if (format === 'jwt_vc_json-ld' || format === 'ldp_vc') {
|
|
@@ -249,7 +313,7 @@ export class CredentialRequestClient {
|
|
|
249
313
|
|
|
250
314
|
return {
|
|
251
315
|
format,
|
|
252
|
-
proof,
|
|
316
|
+
...(proof && { proof }),
|
|
253
317
|
...opts.subjectIssuance,
|
|
254
318
|
|
|
255
319
|
credential_definition: {
|
|
@@ -261,16 +325,25 @@ export class CredentialRequestClient {
|
|
|
261
325
|
if (types.length > 1) {
|
|
262
326
|
throw Error(`Only a single credential type is supported for ${format}`);
|
|
263
327
|
}
|
|
264
|
-
// fixme: this isn't up to the CredentialRequest that we see in the version v1_0_13
|
|
265
328
|
return {
|
|
266
329
|
format,
|
|
267
|
-
proof,
|
|
330
|
+
...(proof && { proof }),
|
|
268
331
|
vct: types[0],
|
|
269
332
|
...opts.subjectIssuance,
|
|
270
333
|
};
|
|
334
|
+
} else if (format === 'mso_mdoc') {
|
|
335
|
+
if (types.length > 1) {
|
|
336
|
+
throw Error(`Only a single credential type is supported for ${format}`);
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
format,
|
|
340
|
+
...(proof && { proof }),
|
|
341
|
+
doctype: types[0],
|
|
342
|
+
...opts.subjectIssuance,
|
|
343
|
+
};
|
|
271
344
|
}
|
|
272
345
|
|
|
273
|
-
throw new Error(`Unsupported format: ${format}`);
|
|
346
|
+
throw new Error(`Unsupported credential format: ${format}`);
|
|
274
347
|
}
|
|
275
348
|
|
|
276
349
|
private version(): OpenId4VCIVersion {
|
|
@@ -215,6 +215,16 @@ export class CredentialRequestClientV1_0_11 {
|
|
|
215
215
|
proof,
|
|
216
216
|
vct: types[0],
|
|
217
217
|
};
|
|
218
|
+
} else if (format === 'mso_mdoc') {
|
|
219
|
+
if (types.length > 1) {
|
|
220
|
+
throw Error(`Only a single credential type is supported for ${format}`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
format,
|
|
225
|
+
proof,
|
|
226
|
+
doctype: types[0],
|
|
227
|
+
};
|
|
218
228
|
}
|
|
219
229
|
|
|
220
230
|
throw new Error(`Unsupported format: ${format}`);
|
package/lib/MetadataClient.ts
CHANGED
|
@@ -19,7 +19,7 @@ import Debug from 'debug';
|
|
|
19
19
|
|
|
20
20
|
import { MetadataClientV1_0_11 } from './MetadataClientV1_0_11';
|
|
21
21
|
import { MetadataClientV1_0_13 } from './MetadataClientV1_0_13';
|
|
22
|
-
import { retrieveWellknown } from './functions
|
|
22
|
+
import { retrieveWellknown } from './functions';
|
|
23
23
|
|
|
24
24
|
const debug = Debug('sphereon:oid4vci:metadata');
|
|
25
25
|
|
|
@@ -204,6 +204,7 @@ export class MetadataClient {
|
|
|
204
204
|
* Retrieve only the OID4VCI metadata for the issuer. So no OIDC/OAuth2 metadata
|
|
205
205
|
*
|
|
206
206
|
* @param issuerHost The issuer hostname
|
|
207
|
+
* @param opts
|
|
207
208
|
*/
|
|
208
209
|
public static async retrieveOpenID4VCIServerMetadata(
|
|
209
210
|
issuerHost: string,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from '@sphereon/oid4vci-common';
|
|
13
13
|
import Debug from 'debug';
|
|
14
14
|
|
|
15
|
-
import { retrieveWellknown } from './functions
|
|
15
|
+
import { retrieveWellknown } from './functions';
|
|
16
16
|
|
|
17
17
|
const debug = Debug('sphereon:oid4vci:metadata');
|
|
18
18
|
|
|
@@ -174,6 +174,7 @@ export class MetadataClientV1_0_13 {
|
|
|
174
174
|
* Retrieve only the OID4VCI metadata for the issuer. So no OIDC/OAuth2 metadata
|
|
175
175
|
*
|
|
176
176
|
* @param issuerHost The issuer hostname
|
|
177
|
+
* @param opts
|
|
177
178
|
*/
|
|
178
179
|
public static async retrieveOpenID4VCIServerMetadata(
|
|
179
180
|
issuerHost: string,
|
package/lib/OpenID4VCIClient.ts
CHANGED
|
@@ -276,7 +276,7 @@ export class OpenID4VCIClient {
|
|
|
276
276
|
authorizationResponse?: string | AuthorizationResponse; // Pass in an auth response, either as URI/redirect, or object
|
|
277
277
|
additionalRequestParams?: Record<string, any>;
|
|
278
278
|
},
|
|
279
|
-
): Promise<AccessTokenResponse & DPoPResponseParams> {
|
|
279
|
+
): Promise<AccessTokenResponse & { params?: DPoPResponseParams }> {
|
|
280
280
|
const { pin, clientId = this._state.clientId ?? this._state.authorizationRequestOpts?.clientId } = opts ?? {};
|
|
281
281
|
let { redirectUri } = opts ?? {};
|
|
282
282
|
if (opts?.authorizationResponse) {
|
|
@@ -262,7 +262,7 @@ export class OpenID4VCIClientV1_0_11 {
|
|
|
262
262
|
authorizationResponse?: string | AuthorizationResponse; // Pass in an auth response, either as URI/redirect, or object
|
|
263
263
|
additionalRequestParams?: Record<string, any>;
|
|
264
264
|
},
|
|
265
|
-
): Promise<AccessTokenResponse> {
|
|
265
|
+
): Promise<AccessTokenResponse & { params?: DPoPResponseParams }> {
|
|
266
266
|
const { pin, clientId = this._state.clientId ?? this._state.authorizationRequestOpts?.clientId } = opts ?? {};
|
|
267
267
|
let { redirectUri } = opts ?? {};
|
|
268
268
|
if (opts?.authorizationResponse) {
|
|
@@ -29,14 +29,14 @@ import {
|
|
|
29
29
|
ProofOfPossessionCallbacks,
|
|
30
30
|
toAuthorizationResponsePayload,
|
|
31
31
|
} from '@sphereon/oid4vci-common';
|
|
32
|
-
import { CredentialFormat } from '@sphereon/ssi-types';
|
|
32
|
+
import { CredentialFormat, DIDDocument } from '@sphereon/ssi-types';
|
|
33
33
|
import Debug from 'debug';
|
|
34
34
|
|
|
35
35
|
import { AccessTokenClient } from './AccessTokenClient';
|
|
36
36
|
import { createAuthorizationRequestUrl } from './AuthorizationCodeClient';
|
|
37
37
|
import { CredentialOfferClient } from './CredentialOfferClient';
|
|
38
38
|
import { CredentialRequestOpts } from './CredentialRequestClient';
|
|
39
|
-
import {
|
|
39
|
+
import { CredentialRequestClientBuilderV1_0_13 } from './CredentialRequestClientBuilderV1_0_13';
|
|
40
40
|
import { MetadataClientV1_0_13 } from './MetadataClientV1_0_13';
|
|
41
41
|
import { ProofOfPossessionBuilder } from './ProofOfPossessionBuilder';
|
|
42
42
|
import { generateMissingPKCEOpts, sendNotification } from './functions';
|
|
@@ -267,7 +267,7 @@ export class OpenID4VCIClientV1_0_13 {
|
|
|
267
267
|
authorizationResponse?: string | AuthorizationResponse; // Pass in an auth response, either as URI/redirect, or object
|
|
268
268
|
additionalRequestParams?: Record<string, any>;
|
|
269
269
|
},
|
|
270
|
-
): Promise<AccessTokenResponse> {
|
|
270
|
+
): Promise<AccessTokenResponse & { params?: DPoPResponseParams }> {
|
|
271
271
|
const { pin, clientId = this._state.clientId ?? this._state.authorizationRequestOpts?.clientId } = opts ?? {};
|
|
272
272
|
let { redirectUri } = opts ?? {};
|
|
273
273
|
if (opts?.authorizationResponse) {
|
|
@@ -351,7 +351,41 @@ export class OpenID4VCIClientV1_0_13 {
|
|
|
351
351
|
return { ...this.accessTokenResponse, ...(this.dpopResponseParams && { params: this.dpopResponseParams }) };
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
public async
|
|
354
|
+
public async acquireCredentialsWithoutProof(args: {
|
|
355
|
+
credentialIdentifier?: string;
|
|
356
|
+
credentialTypes?: string | string[];
|
|
357
|
+
context?: string[];
|
|
358
|
+
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
359
|
+
kid?: string;
|
|
360
|
+
jwk?: JWK;
|
|
361
|
+
alg?: Alg | string;
|
|
362
|
+
jti?: string;
|
|
363
|
+
deferredCredentialAwait?: boolean;
|
|
364
|
+
deferredCredentialIntervalInMS?: number;
|
|
365
|
+
experimentalHolderIssuanceSupported?: boolean;
|
|
366
|
+
createDPoPOpts?: CreateDPoPClientOpts;
|
|
367
|
+
}): Promise<CredentialResponse & { access_token: string }> {
|
|
368
|
+
return await this.acquireCredentialsImpl(args);
|
|
369
|
+
}
|
|
370
|
+
public async acquireCredentials(args: {
|
|
371
|
+
credentialIdentifier?: string;
|
|
372
|
+
credentialTypes?: string | string[];
|
|
373
|
+
context?: string[];
|
|
374
|
+
proofCallbacks: ProofOfPossessionCallbacks<any>;
|
|
375
|
+
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
376
|
+
kid?: string;
|
|
377
|
+
jwk?: JWK;
|
|
378
|
+
alg?: Alg | string;
|
|
379
|
+
jti?: string;
|
|
380
|
+
deferredCredentialAwait?: boolean;
|
|
381
|
+
deferredCredentialIntervalInMS?: number;
|
|
382
|
+
experimentalHolderIssuanceSupported?: boolean;
|
|
383
|
+
createDPoPOpts?: CreateDPoPClientOpts;
|
|
384
|
+
}): Promise<CredentialResponse & { access_token: string }> {
|
|
385
|
+
return await this.acquireCredentialsImpl(args);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
private async acquireCredentialsImpl({
|
|
355
389
|
credentialIdentifier,
|
|
356
390
|
credentialTypes,
|
|
357
391
|
context,
|
|
@@ -368,7 +402,7 @@ export class OpenID4VCIClientV1_0_13 {
|
|
|
368
402
|
credentialIdentifier?: string;
|
|
369
403
|
credentialTypes?: string | string[];
|
|
370
404
|
context?: string[];
|
|
371
|
-
proofCallbacks
|
|
405
|
+
proofCallbacks?: ProofOfPossessionCallbacks<any>;
|
|
372
406
|
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
373
407
|
kid?: string;
|
|
374
408
|
jwk?: JWK;
|
|
@@ -388,11 +422,11 @@ export class OpenID4VCIClientV1_0_13 {
|
|
|
388
422
|
if (kid) this._state.kid = kid;
|
|
389
423
|
|
|
390
424
|
const requestBuilder = this.credentialOffer
|
|
391
|
-
?
|
|
425
|
+
? CredentialRequestClientBuilderV1_0_13.fromCredentialOffer({
|
|
392
426
|
credentialOffer: this.credentialOffer,
|
|
393
427
|
metadata: this.endpointMetadata,
|
|
394
428
|
})
|
|
395
|
-
:
|
|
429
|
+
: CredentialRequestClientBuilderV1_0_13.fromCredentialIssuer({
|
|
396
430
|
credentialIssuer: this.getIssuer(),
|
|
397
431
|
credentialIdentifier: credentialIdentifier,
|
|
398
432
|
metadata: this.endpointMetadata,
|
|
@@ -451,32 +485,50 @@ export class OpenID4VCIClientV1_0_13 {
|
|
|
451
485
|
}
|
|
452
486
|
|
|
453
487
|
const credentialRequestClient = requestBuilder.build();
|
|
454
|
-
const proofBuilder = ProofOfPossessionBuilder.fromAccessTokenResponse({
|
|
455
|
-
accessTokenResponse: this.accessTokenResponse,
|
|
456
|
-
callbacks: proofCallbacks,
|
|
457
|
-
version: this.version(),
|
|
458
|
-
})
|
|
459
|
-
.withIssuer(this.getIssuer())
|
|
460
|
-
.withAlg(this.alg);
|
|
461
488
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
489
|
+
let proofBuilder: ProofOfPossessionBuilder<any> | undefined;
|
|
490
|
+
if (proofCallbacks) {
|
|
491
|
+
proofBuilder = ProofOfPossessionBuilder.fromAccessTokenResponse({
|
|
492
|
+
accessTokenResponse: this.accessTokenResponse,
|
|
493
|
+
callbacks: proofCallbacks,
|
|
494
|
+
version: this.version(),
|
|
495
|
+
})
|
|
496
|
+
.withIssuer(this.getIssuer())
|
|
497
|
+
.withAlg(this.alg);
|
|
468
498
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
499
|
+
if (this._state.jwk) {
|
|
500
|
+
proofBuilder.withJWK(this._state.jwk);
|
|
501
|
+
}
|
|
502
|
+
if (this._state.kid) {
|
|
503
|
+
proofBuilder.withKid(this._state.kid);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
if (this.clientId) {
|
|
507
|
+
proofBuilder.withClientId(this.clientId);
|
|
508
|
+
}
|
|
509
|
+
if (jti) {
|
|
510
|
+
proofBuilder.withJti(jti);
|
|
511
|
+
}
|
|
474
512
|
}
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
513
|
+
const request = proofBuilder
|
|
514
|
+
? await credentialRequestClient.createCredentialRequest<DIDDocument>({
|
|
515
|
+
proofInput: proofBuilder,
|
|
516
|
+
credentialTypes,
|
|
517
|
+
context,
|
|
518
|
+
format,
|
|
519
|
+
version: this.version(),
|
|
520
|
+
credentialIdentifier,
|
|
521
|
+
subjectIssuance,
|
|
522
|
+
})
|
|
523
|
+
: await credentialRequestClient.createCredentialRequestWithoutProof<DIDDocument>({
|
|
524
|
+
credentialTypes,
|
|
525
|
+
context,
|
|
526
|
+
format,
|
|
527
|
+
version: this.version(),
|
|
528
|
+
credentialIdentifier,
|
|
529
|
+
subjectIssuance,
|
|
530
|
+
});
|
|
531
|
+
const response = await credentialRequestClient.acquireCredentialsUsingRequest(request, createDPoPOpts);
|
|
480
532
|
this._state.dpopResponseParams = response.params;
|
|
481
533
|
if (response.errorBody) {
|
|
482
534
|
debug(`Credential request error:\r\n${JSON.stringify(response.errorBody)}`);
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
Typ,
|
|
15
15
|
} from '@sphereon/oid4vci-common';
|
|
16
16
|
|
|
17
|
-
export class ProofOfPossessionBuilder<DIDDoc> {
|
|
17
|
+
export class ProofOfPossessionBuilder<DIDDoc = never> {
|
|
18
18
|
private readonly proof?: ProofOfPossession;
|
|
19
19
|
private readonly callbacks?: ProofOfPossessionCallbacks<DIDDoc>;
|
|
20
20
|
private readonly version: OpenId4VCIVersion;
|
package/lib/__tests__/IT.spec.ts
CHANGED
|
@@ -198,7 +198,7 @@ describe('OID4VCI-Client should', () => {
|
|
|
198
198
|
|
|
199
199
|
const credentialResponse = await client.acquireCredentials({
|
|
200
200
|
credentialIdentifier: 'OpenBadgeCredential',
|
|
201
|
-
format: 'jwt_vc_json-ld',
|
|
201
|
+
// format: 'jwt_vc_json-ld',
|
|
202
202
|
proofCallbacks: {
|
|
203
203
|
signCallback: proofOfPossessionCallbackFunction,
|
|
204
204
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/oid4vci-client",
|
|
3
|
-
"version": "0.16.1-next.
|
|
3
|
+
"version": "0.16.1-next.48+74b00cb",
|
|
4
4
|
"description": "OpenID for Verifiable Credential Issuance (OpenID4VCI) client",
|
|
5
5
|
"source": "lib/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"build": "tsc"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@sphereon/oid4vc-common": "0.16.1-next.
|
|
19
|
-
"@sphereon/oid4vci-common": "0.16.1-next.
|
|
20
|
-
"@sphereon/ssi-types": "0.29.
|
|
18
|
+
"@sphereon/oid4vc-common": "0.16.1-next.48+74b00cb",
|
|
19
|
+
"@sphereon/oid4vci-common": "0.16.1-next.48+74b00cb",
|
|
20
|
+
"@sphereon/ssi-types": "0.29.1-unstable.208",
|
|
21
21
|
"cross-fetch": "^3.1.8",
|
|
22
22
|
"debug": "^4.3.5"
|
|
23
23
|
},
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"OIDC4VCI",
|
|
71
71
|
"OID4VCI"
|
|
72
72
|
],
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "74b00cb66d8e7d7f1fc7148c8861930e8f8dbf98"
|
|
74
74
|
}
|