@sphereon/oid4vci-client 0.12.1-unstable.4 → 0.12.1-unstable.6
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/CredentialRequestClientBuilder.d.ts +23 -8
- package/dist/CredentialRequestClientBuilder.d.ts.map +1 -1
- package/dist/CredentialRequestClientBuilder.js +99 -11
- package/dist/CredentialRequestClientBuilder.js.map +1 -1
- package/lib/CredentialRequestClientBuilder.ts +147 -32
- package/lib/__tests__/CredentialRequestClient.spec.ts +2 -4
- package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +4 -4
- package/lib/__tests__/IT.spec.ts +71 -4
- package/package.json +3 -3
|
@@ -1,28 +1,43 @@
|
|
|
1
|
-
import { CredentialOfferRequestWithBaseUrl, EndpointMetadata, OpenId4VCIVersion, UniformCredentialOfferRequest } from '@sphereon/oid4vci-common';
|
|
2
|
-
import {
|
|
3
|
-
import { CredentialRequestClientBuilderV1_0_13 } from './CredentialRequestClientBuilderV1_0_13';
|
|
1
|
+
import { AccessTokenResponse, CredentialIssuerMetadata, CredentialIssuerMetadataV1_0_13, CredentialOfferRequestWithBaseUrl, EndpointMetadata, ExperimentalSubjectIssuance, OID4VCICredentialFormat, OpenId4VCIVersion, UniformCredentialOfferRequest } from '@sphereon/oid4vci-common';
|
|
2
|
+
import { CredentialFormat } from '@sphereon/ssi-types';
|
|
4
3
|
export declare class CredentialRequestClientBuilder {
|
|
4
|
+
private _builder;
|
|
5
|
+
private constructor();
|
|
5
6
|
static fromCredentialIssuer({ credentialIssuer, metadata, version, credentialIdentifier, credentialTypes, }: {
|
|
6
7
|
credentialIssuer: string;
|
|
7
8
|
metadata?: EndpointMetadata;
|
|
8
9
|
version?: OpenId4VCIVersion;
|
|
9
10
|
credentialIdentifier?: string;
|
|
10
11
|
credentialTypes?: string | string[];
|
|
11
|
-
}):
|
|
12
|
-
static fromURI({ uri, metadata
|
|
12
|
+
}): CredentialRequestClientBuilder;
|
|
13
|
+
static fromURI({ uri, metadata }: {
|
|
13
14
|
uri: string;
|
|
14
15
|
metadata?: EndpointMetadata;
|
|
15
|
-
}): Promise<
|
|
16
|
+
}): Promise<CredentialRequestClientBuilder>;
|
|
16
17
|
static fromCredentialOfferRequest(opts: {
|
|
17
18
|
request: UniformCredentialOfferRequest;
|
|
18
19
|
scheme?: string;
|
|
19
20
|
baseUrl?: string;
|
|
20
21
|
version?: OpenId4VCIVersion;
|
|
21
22
|
metadata?: EndpointMetadata;
|
|
22
|
-
}):
|
|
23
|
+
}): CredentialRequestClientBuilder;
|
|
23
24
|
static fromCredentialOffer({ credentialOffer, metadata, }: {
|
|
24
25
|
credentialOffer: CredentialOfferRequestWithBaseUrl;
|
|
25
26
|
metadata?: EndpointMetadata;
|
|
26
|
-
}):
|
|
27
|
+
}): CredentialRequestClientBuilder;
|
|
28
|
+
getVersion(): OpenId4VCIVersion | undefined;
|
|
29
|
+
withCredentialEndpointFromMetadata(metadata: CredentialIssuerMetadata | CredentialIssuerMetadataV1_0_13): this;
|
|
30
|
+
withCredentialEndpoint(credentialEndpoint: string): this;
|
|
31
|
+
withDeferredCredentialEndpointFromMetadata(metadata: CredentialIssuerMetadata | CredentialIssuerMetadataV1_0_13): this;
|
|
32
|
+
withDeferredCredentialEndpoint(deferredCredentialEndpoint: string): this;
|
|
33
|
+
withDeferredCredentialAwait(deferredCredentialAwait: boolean, deferredCredentialIntervalInMS?: number): this;
|
|
34
|
+
withCredentialIdentifier(credentialIdentifier: string): this;
|
|
35
|
+
withCredentialType(credentialTypes: string | string[]): this;
|
|
36
|
+
withFormat(format: CredentialFormat | OID4VCICredentialFormat): this;
|
|
37
|
+
withSubjectIssuance(subjectIssuance: ExperimentalSubjectIssuance): this;
|
|
38
|
+
withToken(accessToken: string): this;
|
|
39
|
+
withTokenFromResponse(response: AccessTokenResponse): this;
|
|
40
|
+
withVersion(version: OpenId4VCIVersion): this;
|
|
41
|
+
build(): import("./CredentialRequestClientV1_0_11").CredentialRequestClientV1_0_11 | import("./CredentialRequestClient").CredentialRequestClient;
|
|
27
42
|
}
|
|
28
43
|
//# sourceMappingURL=CredentialRequestClientBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialRequestClientBuilder.d.ts","sourceRoot":"","sources":["../lib/CredentialRequestClientBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAEjC,gBAAgB,EAChB,iBAAiB,EACjB,6BAA6B,EAC9B,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"CredentialRequestClientBuilder.d.ts","sourceRoot":"","sources":["../lib/CredentialRequestClientBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,+BAA+B,EAC/B,iCAAiC,EAEjC,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,6BAA6B,EAC9B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAYtD,qBAAa,8BAA8B;IACzC,OAAO,CAAC,QAAQ,CAAgD;IAEhE,OAAO;WAIO,oBAAoB,CAAC,EACE,gBAAgB,EAChB,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,eAAe,GAChB,EAAE;QACpC,gBAAgB,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;QAC5B,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KACrC,GAAG,8BAA8B;WA2Bd,OAAO,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAA;KAAE,GAAG,OAAO,CAAC,8BAA8B,CAAC;WAUvH,0BAA0B,CAAC,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14
14
|
const CredentialOfferClient_1 = require("./CredentialOfferClient");
|
|
15
15
|
const CredentialRequestClientBuilderV1_0_11_1 = require("./CredentialRequestClientBuilderV1_0_11");
|
|
16
16
|
const CredentialRequestClientBuilderV1_0_13_1 = require("./CredentialRequestClientBuilderV1_0_13");
|
|
17
|
+
function isV1_0_13(builder) {
|
|
18
|
+
return builder.withCredentialIdentifier !== undefined;
|
|
19
|
+
}
|
|
17
20
|
class CredentialRequestClientBuilder {
|
|
21
|
+
constructor(builder) {
|
|
22
|
+
this._builder = builder;
|
|
23
|
+
}
|
|
18
24
|
static fromCredentialIssuer({ credentialIssuer, metadata, version, credentialIdentifier, credentialTypes, }) {
|
|
19
|
-
const specVersion = version ? version : oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13;
|
|
25
|
+
const specVersion = version !== null && version !== void 0 ? version : oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13;
|
|
26
|
+
let builder;
|
|
20
27
|
if (specVersion >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13) {
|
|
21
|
-
|
|
28
|
+
builder = CredentialRequestClientBuilderV1_0_13_1.CredentialRequestClientBuilderV1_0_13.fromCredentialIssuer({
|
|
22
29
|
credentialIssuer,
|
|
23
30
|
metadata,
|
|
24
31
|
version,
|
|
@@ -30,10 +37,16 @@ class CredentialRequestClientBuilder {
|
|
|
30
37
|
if (!credentialTypes || credentialTypes.length === 0) {
|
|
31
38
|
throw new Error('CredentialTypes must be provided for v1_0_11');
|
|
32
39
|
}
|
|
33
|
-
|
|
40
|
+
builder = CredentialRequestClientBuilderV1_0_11_1.CredentialRequestClientBuilderV1_0_11.fromCredentialIssuer({
|
|
41
|
+
credentialIssuer,
|
|
42
|
+
metadata,
|
|
43
|
+
version,
|
|
44
|
+
credentialTypes,
|
|
45
|
+
});
|
|
34
46
|
}
|
|
47
|
+
return new CredentialRequestClientBuilder(builder);
|
|
35
48
|
}
|
|
36
|
-
static fromURI({ uri, metadata
|
|
49
|
+
static fromURI({ uri, metadata }) {
|
|
37
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
51
|
const offer = yield CredentialOfferClient_1.CredentialOfferClient.fromURI(uri);
|
|
39
52
|
return CredentialRequestClientBuilder.fromCredentialOfferRequest(Object.assign(Object.assign({ request: offer }, offer), { metadata, version: offer.version }));
|
|
@@ -43,23 +56,98 @@ class CredentialRequestClientBuilder {
|
|
|
43
56
|
var _a, _b;
|
|
44
57
|
const { request } = opts;
|
|
45
58
|
const version = (_b = (_a = opts.version) !== null && _a !== void 0 ? _a : request.version) !== null && _b !== void 0 ? _b : (0, oid4vci_common_1.determineSpecVersionFromOffer)(request.original_credential_offer);
|
|
59
|
+
let builder;
|
|
46
60
|
if (version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13) {
|
|
47
|
-
|
|
61
|
+
builder = CredentialRequestClientBuilderV1_0_11_1.CredentialRequestClientBuilderV1_0_11.fromCredentialOfferRequest(opts);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
builder = CredentialRequestClientBuilderV1_0_13_1.CredentialRequestClientBuilderV1_0_13.fromCredentialOfferRequest(opts);
|
|
48
65
|
}
|
|
49
|
-
return
|
|
66
|
+
return new CredentialRequestClientBuilder(builder);
|
|
50
67
|
}
|
|
51
68
|
static fromCredentialOffer({ credentialOffer, metadata, }) {
|
|
52
69
|
const version = (0, oid4vci_common_1.determineSpecVersionFromOffer)(credentialOffer.credential_offer);
|
|
70
|
+
let builder;
|
|
53
71
|
if (version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13) {
|
|
54
|
-
|
|
72
|
+
builder = CredentialRequestClientBuilderV1_0_11_1.CredentialRequestClientBuilderV1_0_11.fromCredentialOffer({
|
|
55
73
|
credentialOffer,
|
|
56
74
|
metadata,
|
|
57
75
|
});
|
|
58
76
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
else {
|
|
78
|
+
builder = CredentialRequestClientBuilderV1_0_13_1.CredentialRequestClientBuilderV1_0_13.fromCredentialOffer({
|
|
79
|
+
credentialOffer,
|
|
80
|
+
metadata,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return new CredentialRequestClientBuilder(builder);
|
|
84
|
+
}
|
|
85
|
+
getVersion() {
|
|
86
|
+
return this._builder.version;
|
|
87
|
+
}
|
|
88
|
+
withCredentialEndpointFromMetadata(metadata) {
|
|
89
|
+
if (isV1_0_13(this._builder)) {
|
|
90
|
+
this._builder.withCredentialEndpointFromMetadata(metadata);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this._builder.withCredentialEndpointFromMetadata(metadata);
|
|
94
|
+
}
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
withCredentialEndpoint(credentialEndpoint) {
|
|
98
|
+
this._builder.withCredentialEndpoint(credentialEndpoint);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
withDeferredCredentialEndpointFromMetadata(metadata) {
|
|
102
|
+
if (isV1_0_13(this._builder)) {
|
|
103
|
+
this._builder.withDeferredCredentialEndpointFromMetadata(metadata);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
this._builder.withDeferredCredentialEndpointFromMetadata(metadata);
|
|
107
|
+
}
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
withDeferredCredentialEndpoint(deferredCredentialEndpoint) {
|
|
111
|
+
this._builder.withDeferredCredentialEndpoint(deferredCredentialEndpoint);
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
withDeferredCredentialAwait(deferredCredentialAwait, deferredCredentialIntervalInMS) {
|
|
115
|
+
this._builder.withDeferredCredentialAwait(deferredCredentialAwait, deferredCredentialIntervalInMS);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
withCredentialIdentifier(credentialIdentifier) {
|
|
119
|
+
if (this._builder.version === undefined || this._builder.version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13) {
|
|
120
|
+
throw new Error('Version of spec should be equal or higher than v1_0_13');
|
|
121
|
+
}
|
|
122
|
+
this._builder.withCredentialIdentifier(credentialIdentifier);
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
withCredentialType(credentialTypes) {
|
|
126
|
+
this._builder.withCredentialType(credentialTypes);
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
withFormat(format) {
|
|
130
|
+
this._builder.withFormat(format);
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
withSubjectIssuance(subjectIssuance) {
|
|
134
|
+
this._builder.withSubjectIssuance(subjectIssuance);
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
withToken(accessToken) {
|
|
138
|
+
this._builder.withToken(accessToken);
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
withTokenFromResponse(response) {
|
|
142
|
+
this._builder.withTokenFromResponse(response);
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
withVersion(version) {
|
|
146
|
+
this._builder.withVersion(version);
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
build() {
|
|
150
|
+
return this._builder.build();
|
|
63
151
|
}
|
|
64
152
|
}
|
|
65
153
|
exports.CredentialRequestClientBuilder = CredentialRequestClientBuilder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialRequestClientBuilder.js","sourceRoot":"","sources":["../lib/CredentialRequestClientBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CredentialRequestClientBuilder.js","sourceRoot":"","sources":["../lib/CredentialRequestClientBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAWiC;AAGjC,mEAAgE;AAChE,mGAAgG;AAChG,mGAAgG;AAIhG,SAAS,SAAS,CAAC,OAAsD;IACvE,OAAQ,OAAiD,CAAC,wBAAwB,KAAK,SAAS,CAAC;AACnG,CAAC;AAED,MAAa,8BAA8B;IAGzC,YAAoB,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I,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,mBAAmB,CAAC,eAA4C;QACrE,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,SAAS,CAAC,WAAmB;QAClC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,qBAAqB,CAAC,QAA6B;QACxD,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,WAAW,CAAC,OAA0B;QAC3C,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CACF;AAnLD,wEAmLC"}
|
|
@@ -1,32 +1,52 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AccessTokenResponse,
|
|
3
|
+
CredentialIssuerMetadata,
|
|
4
|
+
CredentialIssuerMetadataV1_0_13,
|
|
2
5
|
CredentialOfferRequestWithBaseUrl,
|
|
3
6
|
determineSpecVersionFromOffer,
|
|
4
7
|
EndpointMetadata,
|
|
8
|
+
ExperimentalSubjectIssuance,
|
|
9
|
+
OID4VCICredentialFormat,
|
|
5
10
|
OpenId4VCIVersion,
|
|
6
|
-
UniformCredentialOfferRequest
|
|
7
|
-
} from '@sphereon/oid4vci-common'
|
|
11
|
+
UniformCredentialOfferRequest
|
|
12
|
+
} from '@sphereon/oid4vci-common'
|
|
13
|
+
import { CredentialFormat } from '@sphereon/ssi-types'
|
|
8
14
|
|
|
9
15
|
import { CredentialOfferClient } from './CredentialOfferClient';
|
|
10
16
|
import { CredentialRequestClientBuilderV1_0_11 } from './CredentialRequestClientBuilderV1_0_11';
|
|
11
17
|
import { CredentialRequestClientBuilderV1_0_13 } from './CredentialRequestClientBuilderV1_0_13';
|
|
12
18
|
|
|
19
|
+
type CredentialRequestClientBuilderVersionSpecific = CredentialRequestClientBuilderV1_0_11 | CredentialRequestClientBuilderV1_0_13;
|
|
20
|
+
|
|
21
|
+
function isV1_0_13(builder: CredentialRequestClientBuilderVersionSpecific): builder is CredentialRequestClientBuilderV1_0_13 {
|
|
22
|
+
return (builder as CredentialRequestClientBuilderV1_0_13).withCredentialIdentifier !== undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
export class CredentialRequestClientBuilder {
|
|
26
|
+
private _builder: CredentialRequestClientBuilderVersionSpecific;
|
|
27
|
+
|
|
28
|
+
private constructor(builder: CredentialRequestClientBuilderVersionSpecific) {
|
|
29
|
+
this._builder = builder;
|
|
30
|
+
}
|
|
31
|
+
|
|
14
32
|
public static fromCredentialIssuer({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
credentialIssuer,
|
|
34
|
+
metadata,
|
|
35
|
+
version,
|
|
36
|
+
credentialIdentifier,
|
|
37
|
+
credentialTypes,
|
|
38
|
+
}: {
|
|
21
39
|
credentialIssuer: string;
|
|
22
40
|
metadata?: EndpointMetadata;
|
|
23
41
|
version?: OpenId4VCIVersion;
|
|
24
42
|
credentialIdentifier?: string;
|
|
25
43
|
credentialTypes?: string | string[];
|
|
26
|
-
}):
|
|
27
|
-
const specVersion = version
|
|
44
|
+
}): CredentialRequestClientBuilder {
|
|
45
|
+
const specVersion = version ?? OpenId4VCIVersion.VER_1_0_13;
|
|
46
|
+
let builder;
|
|
47
|
+
|
|
28
48
|
if (specVersion >= OpenId4VCIVersion.VER_1_0_13) {
|
|
29
|
-
|
|
49
|
+
builder = CredentialRequestClientBuilderV1_0_13.fromCredentialIssuer({
|
|
30
50
|
credentialIssuer,
|
|
31
51
|
metadata,
|
|
32
52
|
version,
|
|
@@ -37,19 +57,25 @@ export class CredentialRequestClientBuilder {
|
|
|
37
57
|
if (!credentialTypes || credentialTypes.length === 0) {
|
|
38
58
|
throw new Error('CredentialTypes must be provided for v1_0_11');
|
|
39
59
|
}
|
|
40
|
-
|
|
60
|
+
builder = CredentialRequestClientBuilderV1_0_11.fromCredentialIssuer({
|
|
61
|
+
credentialIssuer,
|
|
62
|
+
metadata,
|
|
63
|
+
version,
|
|
64
|
+
credentialTypes,
|
|
65
|
+
});
|
|
41
66
|
}
|
|
67
|
+
|
|
68
|
+
return new CredentialRequestClientBuilder(builder);
|
|
42
69
|
}
|
|
43
70
|
|
|
44
|
-
public static async fromURI({
|
|
45
|
-
uri,
|
|
46
|
-
metadata,
|
|
47
|
-
}: {
|
|
48
|
-
uri: string;
|
|
49
|
-
metadata?: EndpointMetadata;
|
|
50
|
-
}): Promise<CredentialRequestClientBuilderV1_0_11 | CredentialRequestClientBuilderV1_0_13> {
|
|
71
|
+
public static async fromURI({ uri, metadata }: { uri: string; metadata?: EndpointMetadata }): Promise<CredentialRequestClientBuilder> {
|
|
51
72
|
const offer = await CredentialOfferClient.fromURI(uri);
|
|
52
|
-
return CredentialRequestClientBuilder.fromCredentialOfferRequest({
|
|
73
|
+
return CredentialRequestClientBuilder.fromCredentialOfferRequest({
|
|
74
|
+
request: offer,
|
|
75
|
+
...offer,
|
|
76
|
+
metadata,
|
|
77
|
+
version: offer.version,
|
|
78
|
+
});
|
|
53
79
|
}
|
|
54
80
|
|
|
55
81
|
public static fromCredentialOfferRequest(opts: {
|
|
@@ -58,32 +84,121 @@ export class CredentialRequestClientBuilder {
|
|
|
58
84
|
baseUrl?: string;
|
|
59
85
|
version?: OpenId4VCIVersion;
|
|
60
86
|
metadata?: EndpointMetadata;
|
|
61
|
-
}):
|
|
87
|
+
}): CredentialRequestClientBuilder {
|
|
62
88
|
const { request } = opts;
|
|
63
89
|
const version = opts.version ?? request.version ?? determineSpecVersionFromOffer(request.original_credential_offer);
|
|
90
|
+
let builder;
|
|
91
|
+
|
|
64
92
|
if (version < OpenId4VCIVersion.VER_1_0_13) {
|
|
65
|
-
|
|
93
|
+
builder = CredentialRequestClientBuilderV1_0_11.fromCredentialOfferRequest(opts);
|
|
94
|
+
} else {
|
|
95
|
+
builder = CredentialRequestClientBuilderV1_0_13.fromCredentialOfferRequest(opts);
|
|
66
96
|
}
|
|
67
|
-
|
|
97
|
+
|
|
98
|
+
return new CredentialRequestClientBuilder(builder);
|
|
68
99
|
}
|
|
69
100
|
|
|
70
101
|
public static fromCredentialOffer({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
102
|
+
credentialOffer,
|
|
103
|
+
metadata,
|
|
104
|
+
}: {
|
|
74
105
|
credentialOffer: CredentialOfferRequestWithBaseUrl;
|
|
75
106
|
metadata?: EndpointMetadata;
|
|
76
|
-
}):
|
|
107
|
+
}): CredentialRequestClientBuilder {
|
|
77
108
|
const version = determineSpecVersionFromOffer(credentialOffer.credential_offer);
|
|
109
|
+
let builder;
|
|
110
|
+
|
|
78
111
|
if (version < OpenId4VCIVersion.VER_1_0_13) {
|
|
79
|
-
|
|
112
|
+
builder = CredentialRequestClientBuilderV1_0_11.fromCredentialOffer({
|
|
113
|
+
credentialOffer,
|
|
114
|
+
metadata,
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
builder = CredentialRequestClientBuilderV1_0_13.fromCredentialOffer({
|
|
80
118
|
credentialOffer,
|
|
81
119
|
metadata,
|
|
82
120
|
});
|
|
83
121
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
122
|
+
|
|
123
|
+
return new CredentialRequestClientBuilder(builder);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public getVersion(): OpenId4VCIVersion | undefined {
|
|
127
|
+
return this._builder.version;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public withCredentialEndpointFromMetadata(metadata: CredentialIssuerMetadata | CredentialIssuerMetadataV1_0_13): this {
|
|
131
|
+
if (isV1_0_13(this._builder)) {
|
|
132
|
+
this._builder.withCredentialEndpointFromMetadata(metadata as CredentialIssuerMetadataV1_0_13)
|
|
133
|
+
} else {
|
|
134
|
+
this._builder.withCredentialEndpointFromMetadata(metadata as CredentialIssuerMetadata)
|
|
135
|
+
}
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public withCredentialEndpoint(credentialEndpoint: string): this {
|
|
140
|
+
this._builder.withCredentialEndpoint(credentialEndpoint);
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public withDeferredCredentialEndpointFromMetadata(metadata: CredentialIssuerMetadata | CredentialIssuerMetadataV1_0_13): this {
|
|
145
|
+
if (isV1_0_13(this._builder)) {
|
|
146
|
+
this._builder.withDeferredCredentialEndpointFromMetadata(metadata as CredentialIssuerMetadataV1_0_13);
|
|
147
|
+
} else {
|
|
148
|
+
this._builder.withDeferredCredentialEndpointFromMetadata(metadata as CredentialIssuerMetadata);
|
|
149
|
+
}
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public withDeferredCredentialEndpoint(deferredCredentialEndpoint: string): this {
|
|
154
|
+
this._builder.withDeferredCredentialEndpoint(deferredCredentialEndpoint);
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public withDeferredCredentialAwait(deferredCredentialAwait: boolean, deferredCredentialIntervalInMS?: number): this {
|
|
159
|
+
this._builder.withDeferredCredentialAwait(deferredCredentialAwait, deferredCredentialIntervalInMS);
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public withCredentialIdentifier(credentialIdentifier: string): this {
|
|
164
|
+
if (this._builder.version === undefined || this._builder.version < OpenId4VCIVersion.VER_1_0_13) {
|
|
165
|
+
throw new Error('Version of spec should be equal or higher than v1_0_13');
|
|
166
|
+
}
|
|
167
|
+
(this._builder as CredentialRequestClientBuilderV1_0_13).withCredentialIdentifier(credentialIdentifier);
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public withCredentialType(credentialTypes: string | string[]): this {
|
|
172
|
+
this._builder.withCredentialType(credentialTypes);
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public withFormat(format: CredentialFormat | OID4VCICredentialFormat): this {
|
|
177
|
+
this._builder.withFormat(format);
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
public withSubjectIssuance(subjectIssuance: ExperimentalSubjectIssuance): this {
|
|
182
|
+
this._builder.withSubjectIssuance(subjectIssuance);
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public withToken(accessToken: string): this {
|
|
187
|
+
this._builder.withToken(accessToken);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
public withTokenFromResponse(response: AccessTokenResponse): this {
|
|
192
|
+
this._builder.withTokenFromResponse(response);
|
|
193
|
+
return this;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public withVersion(version: OpenId4VCIVersion): this {
|
|
197
|
+
this._builder.withVersion(version);
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public build() {
|
|
202
|
+
return this._builder.build();
|
|
88
203
|
}
|
|
89
204
|
}
|
|
@@ -20,7 +20,7 @@ import * as jose from 'jose';
|
|
|
20
20
|
// @ts-ignore
|
|
21
21
|
import nock from 'nock';
|
|
22
22
|
|
|
23
|
-
import { CredentialOfferClient,
|
|
23
|
+
import { CredentialOfferClient, MetadataClient, ProofOfPossessionBuilder } from '..';
|
|
24
24
|
import { CredentialRequestClientBuilder } from '../CredentialRequestClientBuilder';
|
|
25
25
|
|
|
26
26
|
import { IDENTIPROOF_ISSUER_URL, IDENTIPROOF_OID4VCI_METADATA, INITIATION_TEST, WALT_OID4VCI_METADATA } from './MetadataMocks';
|
|
@@ -114,9 +114,7 @@ describe('Credential Request Client ', () => {
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
it('should fail with invalid url', async () => {
|
|
117
|
-
const credReqClient = (
|
|
118
|
-
CredentialRequestClientBuilder.fromCredentialOfferRequest({ request: INITIATION_TEST }) as CredentialRequestClientBuilderV1_0_13
|
|
119
|
-
)
|
|
117
|
+
const credReqClient = CredentialRequestClientBuilder.fromCredentialOfferRequest({ request: INITIATION_TEST })
|
|
120
118
|
.withCredentialEndpoint('httpsf://oidc4vci.demo.spruceid.com/credential')
|
|
121
119
|
.withFormat('jwt_vc')
|
|
122
120
|
.withCredentialIdentifier('https://imsglobal.github.io/openbadges-specification/ob_v3p0.html#OpenBadgeCredential')
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@sphereon/oid4vci-common';
|
|
12
12
|
import * as jose from 'jose';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { CredentialRequestOpts, ProofOfPossessionBuilder } from '..';
|
|
15
15
|
import { CredentialRequestClientBuilder } from '../CredentialRequestClientBuilder';
|
|
16
16
|
|
|
17
17
|
import { IDENTIPROOF_ISSUER_URL, IDENTIPROOF_OID4VCI_METADATA, INITIATION_TEST_URI, WALT_ISSUER_URL, WALT_OID4VCI_METADATA } from './MetadataMocks';
|
|
@@ -82,7 +82,7 @@ async function proofOfPossessionVerifierCallbackFunction(args: { jwt: string; ki
|
|
|
82
82
|
|
|
83
83
|
describe('Credential Request Client Builder', () => {
|
|
84
84
|
it('should build correctly provided with correct params', async function () {
|
|
85
|
-
const credReqClient = (
|
|
85
|
+
const credReqClient = (await CredentialRequestClientBuilder.fromURI({ uri: INITIATION_TEST_URI }))
|
|
86
86
|
.withCredentialEndpoint('https://oidc4vci.demo.spruceid.com/credential')
|
|
87
87
|
.withFormat('jwt_vc')
|
|
88
88
|
.withCredentialIdentifier('credentialType')
|
|
@@ -90,12 +90,12 @@ describe('Credential Request Client Builder', () => {
|
|
|
90
90
|
.build();
|
|
91
91
|
expect(credReqClient.credentialRequestOpts.credentialEndpoint).toBe('https://oidc4vci.demo.spruceid.com/credential');
|
|
92
92
|
expect(credReqClient.credentialRequestOpts.format).toBe('jwt_vc');
|
|
93
|
-
expect(credReqClient.credentialRequestOpts.credentialIdentifier).toStrictEqual('credentialType');
|
|
93
|
+
expect((credReqClient.credentialRequestOpts as CredentialRequestOpts).credentialIdentifier).toStrictEqual('credentialType');
|
|
94
94
|
expect(credReqClient.credentialRequestOpts.token).toBe('token');
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
it('should build credential request correctly', async () => {
|
|
98
|
-
const credReqClient = (
|
|
98
|
+
const credReqClient = (await CredentialRequestClientBuilder.fromURI({ uri: INITIATION_TEST_URI }))
|
|
99
99
|
.withCredentialEndpoint('https://oidc4vci.demo.spruceid.com/credential')
|
|
100
100
|
.withFormat('jwt_vc')
|
|
101
101
|
.withCredentialIdentifier('OpenBadgeCredential')
|
package/lib/__tests__/IT.spec.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AccessTokenResponse,
|
|
3
|
-
Alg,
|
|
3
|
+
Alg, CredentialOfferPayloadV1_0_13,
|
|
4
4
|
CredentialOfferRequestWithBaseUrl,
|
|
5
5
|
Jwt,
|
|
6
6
|
OpenId4VCIVersion,
|
|
7
7
|
ProofOfPossession,
|
|
8
|
-
WellKnownEndpoints
|
|
9
|
-
} from '@sphereon/oid4vci-common'
|
|
8
|
+
WellKnownEndpoints
|
|
9
|
+
} from '@sphereon/oid4vci-common'
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
11
|
// @ts-ignore
|
|
12
12
|
import nock from 'nock';
|
|
@@ -225,7 +225,7 @@ describe('OID4VCI-Client should', () => {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
it(
|
|
228
|
-
'succeed with a full flow without the client',
|
|
228
|
+
'succeed with a full flow without the client v1_0_11',
|
|
229
229
|
async () => {
|
|
230
230
|
/* Convert the URI into an object */
|
|
231
231
|
const credentialOffer: CredentialOfferRequestWithBaseUrl = await CredentialOfferClient.fromURI(INITIATE_QR_V1_0_08);
|
|
@@ -284,6 +284,73 @@ describe('OID4VCI-Client should', () => {
|
|
|
284
284
|
UNIT_TEST_TIMEOUT,
|
|
285
285
|
);
|
|
286
286
|
|
|
287
|
+
it(
|
|
288
|
+
'succeed with a full flow without the client v1_0_13',
|
|
289
|
+
async () => {
|
|
290
|
+
/* Convert the URI into an object */
|
|
291
|
+
const credentialOffer: CredentialOfferRequestWithBaseUrl = await CredentialOfferClient.fromURI(INITIATE_QR_V1_0_13);
|
|
292
|
+
const preAuthorizedCode = 'oaKazRN8I0IbtZ0C7JuMn5';
|
|
293
|
+
expect(credentialOffer.baseUrl).toEqual('openid-credential-offer://');
|
|
294
|
+
expect((credentialOffer.credential_offer as CredentialOfferPayloadV1_0_13).credential_configuration_ids).toEqual(['OpenBadgeCredentialUrl']);
|
|
295
|
+
expect(credentialOffer.original_credential_offer.grants).toEqual({
|
|
296
|
+
'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
|
|
297
|
+
'pre-authorized_code': preAuthorizedCode,
|
|
298
|
+
tx_code: {
|
|
299
|
+
input_mode: 'text',
|
|
300
|
+
description: 'Please enter the serial number of your physical drivers license',
|
|
301
|
+
length: preAuthorizedCode.length,
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
nock(ISSUER_URL)
|
|
307
|
+
.post(/token.*/)
|
|
308
|
+
.reply(200, JSON.stringify(mockedAccessTokenResponse));
|
|
309
|
+
|
|
310
|
+
/* The actual access token calls */
|
|
311
|
+
const accessTokenClient: AccessTokenClient = new AccessTokenClient();
|
|
312
|
+
const accessTokenResponse = await accessTokenClient.acquireAccessToken({ credentialOffer: credentialOffer, pin: '1234' });
|
|
313
|
+
expect(accessTokenResponse.successBody).toEqual(mockedAccessTokenResponse);
|
|
314
|
+
// Get the credential
|
|
315
|
+
nock(ISSUER_URL)
|
|
316
|
+
.post(/credential/)
|
|
317
|
+
.reply(200, {
|
|
318
|
+
format: 'jwt-vc',
|
|
319
|
+
credential: mockedVC,
|
|
320
|
+
});
|
|
321
|
+
const credReqClient = CredentialRequestClientBuilder.fromCredentialOffer({ credentialOffer: credentialOffer })
|
|
322
|
+
.withFormat('jwt_vc')
|
|
323
|
+
|
|
324
|
+
.withTokenFromResponse(accessTokenResponse.successBody!)
|
|
325
|
+
.build();
|
|
326
|
+
|
|
327
|
+
//TS2322: Type '(args: ProofOfPossessionCallbackArgs) => Promise<string>'
|
|
328
|
+
// is not assignable to type 'ProofOfPossessionCallback'.
|
|
329
|
+
// Types of parameters 'args' and 'args' are incompatible.
|
|
330
|
+
// Property 'kid' is missing in type '{ header: unknown; payload: unknown; }' but required in type 'ProofOfPossessionCallbackArgs'.
|
|
331
|
+
const proof: ProofOfPossession = await ProofOfPossessionBuilder.fromJwt({
|
|
332
|
+
jwt: jwtDid,
|
|
333
|
+
callbacks: {
|
|
334
|
+
signCallback: proofOfPossessionCallbackFunction,
|
|
335
|
+
},
|
|
336
|
+
version: OpenId4VCIVersion.VER_1_0_11,
|
|
337
|
+
})
|
|
338
|
+
.withEndpointMetadata({
|
|
339
|
+
issuer: 'https://issuer.research.identiproof.io',
|
|
340
|
+
credential_endpoint: 'https://issuer.research.identiproof.io/credential',
|
|
341
|
+
token_endpoint: 'https://issuer.research.identiproof.io/token',
|
|
342
|
+
})
|
|
343
|
+
.withKid('did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1')
|
|
344
|
+
.build();
|
|
345
|
+
const credResponse = await credReqClient.acquireCredentialsUsingProof({
|
|
346
|
+
proofInput: proof,
|
|
347
|
+
credentialTypes: credentialOffer.original_credential_offer.credential_configuration_ids[0],
|
|
348
|
+
});
|
|
349
|
+
expect(credResponse.successBody?.credential).toEqual(mockedVC);
|
|
350
|
+
},
|
|
351
|
+
UNIT_TEST_TIMEOUT,
|
|
352
|
+
);
|
|
353
|
+
|
|
287
354
|
it(
|
|
288
355
|
'succeed with a full flow without the client and without did',
|
|
289
356
|
async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/oid4vci-client",
|
|
3
|
-
"version": "0.12.1-unstable.
|
|
3
|
+
"version": "0.12.1-unstable.6+19b0704",
|
|
4
4
|
"description": "OpenID for Verifiable Credential Issuance (OpenID4VCI) client",
|
|
5
5
|
"source": "lib/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"build": "tsc"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@sphereon/oid4vci-common": "0.12.1-unstable.
|
|
18
|
+
"@sphereon/oid4vci-common": "0.12.1-unstable.6+19b0704",
|
|
19
19
|
"@sphereon/ssi-types": "0.25.1-unstable.87",
|
|
20
20
|
"cross-fetch": "^3.1.8",
|
|
21
21
|
"debug": "^4.3.4"
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"OIDC4VCI",
|
|
70
70
|
"OID4VCI"
|
|
71
71
|
],
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "19b07046aaf213c3feb4f4b8c61f4eb97f8504cc"
|
|
73
73
|
}
|