@sphereon/oid4vci-client 0.10.4-unstable.2 → 0.10.4-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/README.md +20 -0
- package/dist/CredentialOfferClient.d.ts.map +1 -1
- package/dist/CredentialOfferClient.js +3 -5
- package/dist/CredentialOfferClient.js.map +1 -1
- package/lib/CredentialOfferClient.ts +3 -5
- package/lib/__tests__/IT.spec.ts +40 -3
- package/lib/__tests__/IssuanceInitiation.spec.ts +6 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -51,6 +51,8 @@ client you can use to finish the pre-authorized code flows.
|
|
|
51
51
|
This initiates the client using a URI obtained from the Issuer using a link (URL) or QR code typically. We are also
|
|
52
52
|
already fetching the Server Metadata
|
|
53
53
|
|
|
54
|
+
|
|
55
|
+
Using openid-initiate-issuance scheme
|
|
54
56
|
```typescript
|
|
55
57
|
import { OpenID4VCIClient } from '@sphereon/oid4vci-client';
|
|
56
58
|
|
|
@@ -68,6 +70,24 @@ console.log(client.getCredentialEndpoint()); // https://issuer.research.identipr
|
|
|
68
70
|
console.log(client.getAccessTokenEndpoint()); // https://auth.research.identiproof.io/oauth2/token
|
|
69
71
|
```
|
|
70
72
|
|
|
73
|
+
Using https scheme
|
|
74
|
+
```typescript
|
|
75
|
+
import { OpenID4VCIClient } from '@sphereon/oid4vci-client';
|
|
76
|
+
|
|
77
|
+
// The client is initiated from a URI. This URI is provided by the Issuer, typically as a URL or QR code.
|
|
78
|
+
const client = await OpenID4VCIClient.fromURI({
|
|
79
|
+
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',
|
|
80
|
+
kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21#key-1', // Our DID. You can defer this also to when the acquireCredential method is called
|
|
81
|
+
alg: Alg.ES256, // The signing Algorithm we will use. You can defer this also to when the acquireCredential method is called
|
|
82
|
+
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
|
|
83
|
+
retrieveServerMetadata: true, // Already retrieve the server metadata. Can also be done afterwards by invoking a method yourself.
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
console.log(client.getIssuer()); // https://launchpad.vii.electron.mattrlabs.io
|
|
87
|
+
console.log(client.getCredentialEndpoint()); // https://launchpad.vii.electron.mattrlabs.io/credential
|
|
88
|
+
console.log(client.getAccessTokenEndpoint()); // https://launchpad.vii.electron.mattrlabs.io/oauth2/token
|
|
89
|
+
```
|
|
90
|
+
|
|
71
91
|
## Server metadata
|
|
72
92
|
|
|
73
93
|
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,EAIL,iCAAiC,EAIjC,iBAAiB,EAElB,MAAM,0BAA0B,CAAC;AAOlC,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,EAIL,iCAAiC,EAIjC,iBAAiB,EAElB,MAAM,0BAA0B,CAAC;AAOlC,qBAAa,qBAAqB;WACZ,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,iCAAiC,CAAC;WA+CpG,KAAK,CACjB,kBAAkB,EAAE,iCAAiC,EACrD,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,iBAAiB,CAAC;KAC7B,GACA,MAAM;CAsCV"}
|
|
@@ -31,10 +31,11 @@ class CredentialOfferClient {
|
|
|
31
31
|
const version = (0, oid4vci_common_1.determineSpecVersionFromURI)(uri);
|
|
32
32
|
let credentialOffer;
|
|
33
33
|
let credentialOfferPayload;
|
|
34
|
+
// credential offer was introduced in draft 9 and credential_offer_uri in draft 11
|
|
34
35
|
if (version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
|
|
35
36
|
credentialOfferPayload = (0, functions_1.convertURIToJsonObject)(uri, {
|
|
36
37
|
arrayTypeProperties: ['credential_type'],
|
|
37
|
-
requiredProperties: uri.includes('
|
|
38
|
+
requiredProperties: uri.includes('credential_offer=') ? ['credential_offer'] : ['issuer', 'credential_type'],
|
|
38
39
|
});
|
|
39
40
|
credentialOffer = {
|
|
40
41
|
credential_offer: credentialOfferPayload,
|
|
@@ -42,12 +43,9 @@ class CredentialOfferClient {
|
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
45
|
credentialOffer = (0, functions_1.convertURIToJsonObject)(uri, {
|
|
45
|
-
arrayTypeProperties: ['
|
|
46
|
+
arrayTypeProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri'] : ['credential_offer'],
|
|
46
47
|
requiredProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri'] : ['credential_offer'],
|
|
47
48
|
});
|
|
48
|
-
if ((credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.credential_offer_uri) === undefined && !(credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.credential_offer)) {
|
|
49
|
-
throw Error('Either a credential_offer or credential_offer_uri should be present in ' + uri);
|
|
50
|
-
}
|
|
51
49
|
}
|
|
52
50
|
const request = yield (0, oid4vci_common_1.toUniformCredentialOfferRequest)(credentialOffer, Object.assign(Object.assign({}, opts), { version }));
|
|
53
51
|
const clientId = (0, oid4vci_common_1.getClientIdFromCredentialOfferPayload)(request.credential_offer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialOfferClient.js","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAUkC;AAClC,kDAA0B;AAE1B,2CAAuE;AAEvE,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,wBAAwB,CAAC,CAAC;AAE9C,MAAa,qBAAqB;IACzB,MAAM,CAAO,OAAO,CAAC,GAAW,EAAE,IAA4B;;;YACnE,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;YACtC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/C,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;gBAC9C,MAAM,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAClD,CAAC;YACD,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACnC,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,OAAO,GAAG,IAAA,4CAA2B,EAAC,GAAG,CAAC,CAAC;YACjD,IAAI,eAAgC,CAAC;YACrC,IAAI,sBAA8C,CAAC;YACnD,IAAI,OAAO,GAAG,kCAAiB,CAAC,UAAU,EAAE,CAAC;gBAC3C,sBAAsB,GAAG,IAAA,kCAAsB,EAAC,GAAG,EAAE;oBACnD,mBAAmB,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AAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;wBAClC,OAAO,IAAI,GAAG,CAAC;wBACf,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,kBAAkB,CAAC;oBAC9D,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAA,4BAAgB,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;AA3FD,sDA2FC"}
|
|
@@ -27,22 +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
|
-
arrayTypeProperties: ['
|
|
41
|
+
arrayTypeProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri'] : ['credential_offer'],
|
|
41
42
|
requiredProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri'] : ['credential_offer'],
|
|
42
43
|
}) as CredentialOfferV1_0_11;
|
|
43
|
-
if (credentialOffer?.credential_offer_uri === undefined && !credentialOffer?.credential_offer) {
|
|
44
|
-
throw Error('Either a credential_offer or credential_offer_uri should be present in ' + uri);
|
|
45
|
-
}
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
const request = await toUniformCredentialOfferRequest(credentialOffer, {
|
package/lib/__tests__/IT.spec.ts
CHANGED
|
@@ -50,7 +50,11 @@ 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%3D%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 = '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'
|
|
55
|
+
const HTTPS_OFFER_QR_AUTHORIZATION_CODE =
|
|
56
|
+
'https://issuer.research.identiproof.io?credential_offer%3D%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';
|
|
57
|
+
const HTTPS_OFFER_QR_PRE_AUTHORIZED = 'https://issuer.research.identiproof.io?credential_offer%3D%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
58
|
|
|
55
59
|
function succeedWithAFullFlowWithClientSetup() {
|
|
56
60
|
nock(IDENTIPROOF_ISSUER_URL).get('/.well-known/openid-credential-issuer').reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
|
|
@@ -78,7 +82,7 @@ describe('OID4VCI-Client should', () => {
|
|
|
78
82
|
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
79
83
|
});
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
it('succeed with a full flow with the client using OpenID4VCI version 11 and deeplink', async () => {
|
|
82
86
|
succeedWithAFullFlowWithClientSetup();
|
|
83
87
|
const client = await OpenID4VCIClient.fromURI({
|
|
84
88
|
uri: OFFER_QR,
|
|
@@ -89,6 +93,39 @@ describe('OID4VCI-Client should', () => {
|
|
|
89
93
|
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
90
94
|
});
|
|
91
95
|
|
|
96
|
+
it('succeed with a full flow with the client using OpenID4VCI draft < 9 and https', async () => {
|
|
97
|
+
succeedWithAFullFlowWithClientSetup()
|
|
98
|
+
const client = await OpenID4VCIClient.fromURI({
|
|
99
|
+
uri: HTTPS_INITIATE_QR,
|
|
100
|
+
kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1',
|
|
101
|
+
alg: Alg.ES256,
|
|
102
|
+
clientId: 'test-clientId'
|
|
103
|
+
})
|
|
104
|
+
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('should succeed with a full flow with the client using OpenID4VCI draft > 11, https and authorization_code flow', async () => {
|
|
108
|
+
succeedWithAFullFlowWithClientSetup()
|
|
109
|
+
const client = await OpenID4VCIClient.fromURI({
|
|
110
|
+
uri: HTTPS_OFFER_QR_AUTHORIZATION_CODE,
|
|
111
|
+
kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1',
|
|
112
|
+
alg: Alg.ES256,
|
|
113
|
+
clientId: 'test-clientId'
|
|
114
|
+
})
|
|
115
|
+
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('should succeed with a full flow with the client using OpenID4VCI draft > 11, https and preauthorized_code flow', async () => {
|
|
119
|
+
succeedWithAFullFlowWithClientSetup()
|
|
120
|
+
const client = await OpenID4VCIClient.fromURI({
|
|
121
|
+
uri: HTTPS_OFFER_QR_PRE_AUTHORIZED,
|
|
122
|
+
kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1',
|
|
123
|
+
alg: Alg.ES256,
|
|
124
|
+
clientId: 'test-clientId'
|
|
125
|
+
})
|
|
126
|
+
await assertionOfsucceedWithAFullFlowWithClient(client);
|
|
127
|
+
})
|
|
128
|
+
|
|
92
129
|
async function assertionOfsucceedWithAFullFlowWithClient(client: OpenID4VCIClient) {
|
|
93
130
|
expect(client.credentialOffer).toBeDefined();
|
|
94
131
|
expect(client.endpointMetadata).toBeDefined();
|
|
@@ -96,7 +133,7 @@ describe('OID4VCI-Client should', () => {
|
|
|
96
133
|
expect(client.getCredentialEndpoint()).toEqual('https://issuer.research.identiproof.io/credential');
|
|
97
134
|
expect(client.getAccessTokenEndpoint()).toEqual('https://auth.research.identiproof.io/oauth2/token');
|
|
98
135
|
|
|
99
|
-
const accessToken = await client.acquireAccessToken({ pin: '1234' });
|
|
136
|
+
const accessToken = await client.acquireAccessToken({ pin: '1234', code: 'ABCD' });
|
|
100
137
|
expect(accessToken).toEqual(mockedAccessTokenResponse);
|
|
101
138
|
|
|
102
139
|
const credentialResponse = await client.acquireCredentials({
|
|
@@ -61,23 +61,23 @@ describe('Issuance Initiation', () => {
|
|
|
61
61
|
|
|
62
62
|
it('Should take an https url as input and return a Credential Offer', async () => {
|
|
63
63
|
const client = await CredentialOfferClient.fromURI(
|
|
64
|
-
'https
|
|
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
65
|
);
|
|
66
66
|
expect(client.version).toEqual(OpenId4VCIVersion.VER_1_0_11);
|
|
67
|
-
expect(client.baseUrl).toEqual('https://');
|
|
67
|
+
expect(client.baseUrl).toEqual('https://launchpad.vii.electron.mattrlabs.io');
|
|
68
68
|
expect(client.scheme).toEqual('https');
|
|
69
69
|
expect(client.credential_offer.credential_issuer).toEqual('https://launchpad.vii.electron.mattrlabs.io');
|
|
70
70
|
expect(client.preAuthorizedCode).toEqual('UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X');
|
|
71
71
|
})
|
|
72
72
|
|
|
73
|
-
it('Should take an
|
|
73
|
+
it('Should take an http url as input and return a Credential Offer', async () => {
|
|
74
74
|
const client = await CredentialOfferClient.fromURI(
|
|
75
|
-
'http
|
|
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
76
|
);
|
|
77
77
|
expect(client.version).toEqual(OpenId4VCIVersion.VER_1_0_11);
|
|
78
|
-
expect(client.baseUrl).toEqual('http://');
|
|
78
|
+
expect(client.baseUrl).toEqual('http://launchpad.vii.electron.mattrlabs.io');
|
|
79
79
|
expect(client.scheme).toEqual('http');
|
|
80
|
-
expect(client.credential_offer.credential_issuer).toEqual('
|
|
80
|
+
expect(client.credential_offer.credential_issuer).toEqual('http://launchpad.vii.electron.mattrlabs.io');
|
|
81
81
|
expect(client.preAuthorizedCode).toEqual('UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X');
|
|
82
82
|
})
|
|
83
83
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/oid4vci-client",
|
|
3
|
-
"version": "0.10.4-unstable.
|
|
3
|
+
"version": "0.10.4-unstable.6+f6c4d31",
|
|
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-unstable.
|
|
18
|
+
"@sphereon/oid4vci-common": "0.10.4-unstable.6+f6c4d31",
|
|
19
19
|
"@sphereon/ssi-types": "^0.23.0",
|
|
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": "f6c4d319a04cc9bcdf513c34f2141abdb76e281a"
|
|
73
73
|
}
|