@sphereon/oid4vci-client 0.10.4-next.3 → 0.10.4-unstable.13
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/README.md +18 -0
- package/dist/CredentialOfferClient.d.ts.map +1 -1
- package/dist/CredentialOfferClient.js +5 -3
- package/dist/CredentialOfferClient.js.map +1 -1
- package/lib/CredentialOfferClient.ts +5 -3
- package/lib/__tests__/IT.spec.ts +42 -3
- package/lib/__tests__/IssuanceInitiation.spec.ts +22 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -68,6 +68,24 @@ console.log(client.getCredentialEndpoint()); // https://issuer.research.identipr
|
|
|
68
68
|
console.log(client.getAccessTokenEndpoint()); // https://auth.research.identiproof.io/oauth2/token
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
Using https scheme
|
|
72
|
+
```typescript
|
|
73
|
+
import { OpenID4VCIClient } from '@sphereon/oid4vci-client';
|
|
74
|
+
|
|
75
|
+
// The client is initiated from a URI. This URI is provided by the Issuer, typically as a URL or QR code.
|
|
76
|
+
const client = await OpenID4VCIClient.fromURI({
|
|
77
|
+
uri: 'https://launchpad.vii.electron.mattrlabs.io?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Flaunchpad.vii.electron.mattrlabs.io%22%2C%22credentials%22%3A%5B%7B%22format%22%3A%22ldp_vc%22%2C%22types%22%3A%5B%22OpenBadgeCredential%22%5D%7D%5D%2C%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X%22%7D%7D%7D',
|
|
78
|
+
kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21#key-1', // Our DID. You can defer this also to when the acquireCredential method is called
|
|
79
|
+
alg: Alg.ES256, // The signing Algorithm we will use. You can defer this also to when the acquireCredential method is called
|
|
80
|
+
clientId: 'test-clientId', // The clientId if the Authrozation Service requires it. If a clientId is needed you can defer this also to when the acquireAccessToken method is called
|
|
81
|
+
retrieveServerMetadata: true, // Already retrieve the server metadata. Can also be done afterwards by invoking a method yourself.
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
console.log(client.getIssuer()); // https://launchpad.vii.electron.mattrlabs.io
|
|
85
|
+
console.log(client.getCredentialEndpoint()); // https://launchpad.vii.electron.mattrlabs.io/credential
|
|
86
|
+
console.log(client.getAccessTokenEndpoint()); // https://launchpad.vii.electron.mattrlabs.io/oauth2/token
|
|
87
|
+
```
|
|
88
|
+
|
|
71
89
|
## Server metadata
|
|
72
90
|
|
|
73
91
|
The OID4VCI Server metadata contains information about token endpoints, credential endpoints, as well as additional
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialOfferClient.d.ts","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iCAAiC,EAIjC,iBAAiB,EAElB,MAAM,0BAA0B,CAAC;AAKlC,qBAAa,qBAAqB;WACZ,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"CredentialOfferClient.d.ts","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iCAAiC,EAIjC,iBAAiB,EAElB,MAAM,0BAA0B,CAAC;AAKlC,qBAAa,qBAAqB;WACZ,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,iCAAiC,CAAC;WAmDpG,KAAK,CACjB,kBAAkB,EAAE,iCAAiC,EACrD,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,iBAAiB,CAAC;KAC7B,GACA,MAAM;CAsCV"}
|
|
@@ -30,10 +30,11 @@ class CredentialOfferClient {
|
|
|
30
30
|
const version = (0, oid4vci_common_1.determineSpecVersionFromURI)(uri);
|
|
31
31
|
let credentialOffer;
|
|
32
32
|
let credentialOfferPayload;
|
|
33
|
+
// credential offer was introduced in draft 9 and credential_offer_uri in draft 11
|
|
33
34
|
if (version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
|
|
34
35
|
credentialOfferPayload = (0, oid4vci_common_1.convertURIToJsonObject)(uri, {
|
|
35
36
|
arrayTypeProperties: ['credential_type'],
|
|
36
|
-
requiredProperties: uri.includes('
|
|
37
|
+
requiredProperties: uri.includes('credential_offer=') ? ['credential_offer'] : ['issuer', 'credential_type'],
|
|
37
38
|
});
|
|
38
39
|
credentialOffer = {
|
|
39
40
|
credential_offer: credentialOfferPayload,
|
|
@@ -41,8 +42,9 @@ class CredentialOfferClient {
|
|
|
41
42
|
}
|
|
42
43
|
else {
|
|
43
44
|
credentialOffer = (0, oid4vci_common_1.convertURIToJsonObject)(uri, {
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
// It must have the '=' sign after credential_offer otherwise the uri will get split at openid_credential_offer
|
|
46
|
+
arrayTypeProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri='] : ['credential_offer='],
|
|
47
|
+
requiredProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri='] : ['credential_offer='],
|
|
46
48
|
});
|
|
47
49
|
if ((credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.credential_offer_uri) === undefined && !(credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.credential_offer)) {
|
|
48
50
|
throw Error('Either a credential_offer or credential_offer_uri should be present in ' + uri);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialOfferClient.js","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAYkC;AAClC,kDAA0B;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oBAC9D,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAA,iCAAgB,EAAC,MAAA,kBAAkB,CAAC,oBAAoB,mCAAI,kBAAkB,CAAC,yBAAyB,EAAE;YAC/G,OAAO;YACP,mBAAmB,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;YACrD,iBAAiB,EAAE,KAAK;gBACtB,CAAC,CAAC,CAAC,sBAAsB,CAAC;gBAC1B,CAAC,CAAC,OAAO,IAAI,kCAAiB,CAAC,UAAU;oBACvC,CAAC,CAAC,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;oBAC1C,CAAC,CAAC,CAAC,QAAQ,EAAE,iBAAiB,CAAC;YACnC,KAAK;YACL,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF;AA/FD,sDA+FC"}
|
|
@@ -27,18 +27,20 @@ export class CredentialOfferClient {
|
|
|
27
27
|
const version = determineSpecVersionFromURI(uri);
|
|
28
28
|
let credentialOffer: CredentialOffer;
|
|
29
29
|
let credentialOfferPayload: CredentialOfferPayload;
|
|
30
|
+
// credential offer was introduced in draft 9 and credential_offer_uri in draft 11
|
|
30
31
|
if (version < OpenId4VCIVersion.VER_1_0_11) {
|
|
31
32
|
credentialOfferPayload = convertURIToJsonObject(uri, {
|
|
32
33
|
arrayTypeProperties: ['credential_type'],
|
|
33
|
-
requiredProperties: uri.includes('
|
|
34
|
+
requiredProperties: uri.includes('credential_offer=') ? ['credential_offer'] : ['issuer', 'credential_type'],
|
|
34
35
|
}) as CredentialOfferPayloadV1_0_09;
|
|
35
36
|
credentialOffer = {
|
|
36
37
|
credential_offer: credentialOfferPayload,
|
|
37
38
|
};
|
|
38
39
|
} else {
|
|
39
40
|
credentialOffer = convertURIToJsonObject(uri, {
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
// It must have the '=' sign after credential_offer otherwise the uri will get split at openid_credential_offer
|
|
42
|
+
arrayTypeProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri='] : ['credential_offer='],
|
|
43
|
+
requiredProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri='] : ['credential_offer='],
|
|
42
44
|
}) as CredentialOfferV1_0_11;
|
|
43
45
|
if (credentialOffer?.credential_offer_uri === undefined && !credentialOffer?.credential_offer) {
|
|
44
46
|
throw Error('Either a credential_offer or credential_offer_uri should be present in ' + uri);
|
package/lib/__tests__/IT.spec.ts
CHANGED
|
@@ -50,7 +50,13 @@ describe('OID4VCI-Client should', () => {
|
|
|
50
50
|
const INITIATE_QR =
|
|
51
51
|
'openid-initiate-issuance://?issuer=https%3A%2F%2Fissuer.research.identiproof.io&credential_type=OpenBadgeCredentialUrl&pre-authorized_code=4jLs9xZHEfqcoow0kHE7d1a8hUk6Sy-5bVSV2MqBUGUgiFFQi-ImL62T-FmLIo8hKA1UdMPH0lM1xAgcFkJfxIw9L-lI3mVs0hRT8YVwsEM1ma6N3wzuCdwtMU4bcwKp&user_pin_required=true';
|
|
52
52
|
const OFFER_QR =
|
|
53
|
-
'openid-credential-offer
|
|
53
|
+
'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fissuer.research.identiproof.io%22%2C%22credentials%22%3A%5B%7B%22format%22%3A%22jwt_vc_json%22%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%5D%2C%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22adhjhdjajkdkhjhdj%22%2C%22user_pin_required%22%3Atrue%7D%7D%7D';
|
|
54
|
+
const HTTPS_INITIATE_QR =
|
|
55
|
+
'https://issuer.research.identiproof.io?issuer=https%3A%2F%2Fissuer.research.identiproof.io&credential_type=OpenBadgeCredentialUrl&pre-authorized_code=4jLs9xZHEfqcoow0kHE7d1a8hUk6Sy-5bVSV2MqBUGUgiFFQi-ImL62T-FmLIo8hKA1UdMPH0lM1xAgcFkJfxIw9L-lI3mVs0hRT8YVwsEM1ma6N3wzuCdwtMU4bcwKp&user_pin_required=true';
|
|
56
|
+
const HTTPS_OFFER_QR_AUTHORIZATION_CODE =
|
|
57
|
+
'https://issuer.research.identiproof.io?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fissuer.research.identiproof.io%22%2C%22credentials%22%3A%5B%7B%22format%22%3A%22jwt_vc_json%22%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%5D%2C%22grants%22%3A%7B%22authorization_code%22%3A%7B%22issuer_state%22%3A%22eyJhbGciOiJSU0Et...FYUaBy%22%7D%7D%7D';
|
|
58
|
+
const HTTPS_OFFER_QR_PRE_AUTHORIZED =
|
|
59
|
+
'https://issuer.research.identiproof.io?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fissuer.research.identiproof.io%22%2C%22credentials%22%3A%5B%7B%22format%22%3A%22jwt_vc_json%22%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%5D%2C%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22adhjhdjajkdkhjhdj%22%2C%22user_pin_required%22%3Atrue%7D%7D%7D';
|
|
54
60
|
|
|
55
61
|
function succeedWithAFullFlowWithClientSetup() {
|
|
56
62
|
nock(IDENTIPROOF_ISSUER_URL).get('/.well-known/openid-credential-issuer').reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
|
|
@@ -78,7 +84,7 @@ describe('OID4VCI-Client should', () => {
|
|
|
78
84
|
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
79
85
|
});
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
it('succeed with a full flow with the client using OpenID4VCI version 11 and deeplink', async () => {
|
|
82
88
|
succeedWithAFullFlowWithClientSetup();
|
|
83
89
|
const client = await OpenID4VCIClient.fromURI({
|
|
84
90
|
uri: OFFER_QR,
|
|
@@ -89,6 +95,39 @@ describe('OID4VCI-Client should', () => {
|
|
|
89
95
|
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
90
96
|
});
|
|
91
97
|
|
|
98
|
+
it('succeed with a full flow with the client using OpenID4VCI draft < 9 and https', async () => {
|
|
99
|
+
succeedWithAFullFlowWithClientSetup();
|
|
100
|
+
const client = await OpenID4VCIClient.fromURI({
|
|
101
|
+
uri: HTTPS_INITIATE_QR,
|
|
102
|
+
kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1',
|
|
103
|
+
alg: Alg.ES256,
|
|
104
|
+
clientId: 'test-clientId',
|
|
105
|
+
});
|
|
106
|
+
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should succeed with a full flow with the client using OpenID4VCI draft > 11, https and authorization_code flow', async () => {
|
|
110
|
+
succeedWithAFullFlowWithClientSetup();
|
|
111
|
+
const client = await OpenID4VCIClient.fromURI({
|
|
112
|
+
uri: HTTPS_OFFER_QR_AUTHORIZATION_CODE,
|
|
113
|
+
kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1',
|
|
114
|
+
alg: Alg.ES256,
|
|
115
|
+
clientId: 'test-clientId',
|
|
116
|
+
});
|
|
117
|
+
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should succeed with a full flow with the client using OpenID4VCI draft > 11, https and preauthorized_code flow', async () => {
|
|
121
|
+
succeedWithAFullFlowWithClientSetup();
|
|
122
|
+
const client = await OpenID4VCIClient.fromURI({
|
|
123
|
+
uri: HTTPS_OFFER_QR_PRE_AUTHORIZED,
|
|
124
|
+
kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1',
|
|
125
|
+
alg: Alg.ES256,
|
|
126
|
+
clientId: 'test-clientId',
|
|
127
|
+
});
|
|
128
|
+
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
129
|
+
});
|
|
130
|
+
|
|
92
131
|
async function assertionOfsucceedWithAFullFlowWithClient(client: OpenID4VCIClient) {
|
|
93
132
|
expect(client.credentialOffer).toBeDefined();
|
|
94
133
|
expect(client.endpointMetadata).toBeDefined();
|
|
@@ -96,7 +135,7 @@ describe('OID4VCI-Client should', () => {
|
|
|
96
135
|
expect(client.getCredentialEndpoint()).toEqual('https://issuer.research.identiproof.io/credential');
|
|
97
136
|
expect(client.getAccessTokenEndpoint()).toEqual('https://auth.research.identiproof.io/oauth2/token');
|
|
98
137
|
|
|
99
|
-
const accessToken = await client.acquireAccessToken({ pin: '1234' });
|
|
138
|
+
const accessToken = await client.acquireAccessToken({ pin: '1234', code: 'ABCD' });
|
|
100
139
|
expect(accessToken).toEqual(mockedAccessTokenResponse);
|
|
101
140
|
|
|
102
141
|
const credentialResponse = await client.acquireCredentials({
|
|
@@ -58,4 +58,26 @@ describe('Issuance Initiation', () => {
|
|
|
58
58
|
expect(client.credential_offer.credential_issuer).toEqual('https://launchpad.vii.electron.mattrlabs.io');
|
|
59
59
|
expect(client.preAuthorizedCode).toEqual('UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X');
|
|
60
60
|
});
|
|
61
|
+
|
|
62
|
+
it('Should take an https url as input and return a Credential Offer', async () => {
|
|
63
|
+
const client = await CredentialOfferClient.fromURI(
|
|
64
|
+
'https://launchpad.vii.electron.mattrlabs.io?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Flaunchpad.vii.electron.mattrlabs.io%22%2C%22credentials%22%3A%5B%7B%22format%22%3A%22ldp_vc%22%2C%22types%22%3A%5B%22OpenBadgeCredential%22%5D%7D%5D%2C%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X%22%7D%7D%7D',
|
|
65
|
+
);
|
|
66
|
+
expect(client.version).toEqual(OpenId4VCIVersion.VER_1_0_11);
|
|
67
|
+
expect(client.baseUrl).toEqual('https://launchpad.vii.electron.mattrlabs.io');
|
|
68
|
+
expect(client.scheme).toEqual('https');
|
|
69
|
+
expect(client.credential_offer.credential_issuer).toEqual('https://launchpad.vii.electron.mattrlabs.io');
|
|
70
|
+
expect(client.preAuthorizedCode).toEqual('UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X');
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('Should take an http url as input and return a Credential Offer', async () => {
|
|
74
|
+
const client = await CredentialOfferClient.fromURI(
|
|
75
|
+
'http://launchpad.vii.electron.mattrlabs.io?credential_offer=%7B%22credential_issuer%22%3A%22http%3A%2F%2Flaunchpad.vii.electron.mattrlabs.io%22%2C%22credentials%22%3A%5B%7B%22format%22%3A%22ldp_vc%22%2C%22types%22%3A%5B%22OpenBadgeCredential%22%5D%7D%5D%2C%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X%22%7D%7D%7D',
|
|
76
|
+
);
|
|
77
|
+
expect(client.version).toEqual(OpenId4VCIVersion.VER_1_0_11);
|
|
78
|
+
expect(client.baseUrl).toEqual('http://launchpad.vii.electron.mattrlabs.io');
|
|
79
|
+
expect(client.scheme).toEqual('http');
|
|
80
|
+
expect(client.credential_offer.credential_issuer).toEqual('http://launchpad.vii.electron.mattrlabs.io');
|
|
81
|
+
expect(client.preAuthorizedCode).toEqual('UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X');
|
|
82
|
+
})
|
|
61
83
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/oid4vci-client",
|
|
3
|
-
"version": "0.10.4-
|
|
3
|
+
"version": "0.10.4-unstable.13+fb14206",
|
|
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.10.4-
|
|
18
|
+
"@sphereon/oid4vci-common": "0.10.4-unstable.13+fb14206",
|
|
19
19
|
"@sphereon/ssi-types": "0.24.1-unstable.112",
|
|
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": "fb14206f7e1aea62720ffa7308d4c65b8d19c3c0"
|
|
73
73
|
}
|