@sphereon/oid4vci-client 0.10.4-unstable.2 → 0.10.4-unstable.3

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 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
@@ -50,7 +50,8 @@ 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://credential_offer=%7B%22credential_issuer%22:%22https://credential-issuer.example.com%22,%22credentials%22:%5B%7B%22format%22:%22jwt_vc_json%22,%22types%22:%5B%22VerifiableCredential%22,%22UniversityDegreeCredential%22%5D%7D%5D,%22issuer_state%22:%22eyJhbGciOiJSU0Et...FYUaBy%22%7D';
53
+ 'openid-credential-offer://credential_offer=%7B%22credential_issuer%22:%22https://issuer.research.identiproof.io%22,%22credentials%22:%5B%7B%22format%22:%22jwt_vc_json%22,%22types%22:%5B%22VerifiableCredential%22,%22UniversityDegreeCredential%22%5D%7D%5D,%22issuer_state%22:%22eyJhbGciOiJSU0Et...FYUaBy%22%7D';
54
+ const HTTPS = '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'
54
55
 
55
56
  function succeedWithAFullFlowWithClientSetup() {
56
57
  nock(IDENTIPROOF_ISSUER_URL).get('/.well-known/openid-credential-issuer').reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
@@ -78,7 +79,7 @@ describe('OID4VCI-Client should', () => {
78
79
  await assertionOfsucceedWithAFullFlowWithClient(client);
79
80
  });
80
81
 
81
- test.skip('succeed with a full flow wit the client using OpenID4VCI version 11', async () => {
82
+ test.skip('succeed with a full flow with the client using OpenID4VCI version 11 and deeplink', async () => {
82
83
  succeedWithAFullFlowWithClientSetup();
83
84
  const client = await OpenID4VCIClient.fromURI({
84
85
  uri: OFFER_QR,
@@ -89,6 +90,28 @@ describe('OID4VCI-Client should', () => {
89
90
  await assertionOfsucceedWithAFullFlowWithClient(client);
90
91
  });
91
92
 
93
+ /*
94
+ openid-initiate-issuance://?issuer=https://issuer.research.identiproof.io&credential_type=OpenBadgeCredentialUrl&pre-authorized_code=4jLs9xZHEfqcoow0kHE7d1a8hUk6Sy-5bVSV2MqBUGUgiFFQi-ImL62T-FmLIo8hKA1UdMPH0lM1xAgcFkJfxIw9L-lI3mVs0hRT8YVwsEM1ma6N3wzuCdwtMU4bcwKp&user_pin_required=true
95
+
96
+ ####################################################################################################################################
97
+
98
+ openid-credential-offer://credential_offer={"credential_issuer":"https://issuer.research.identiproof.io","credentials":[{"format":"jwt_vc_json","types":["VerifiableCredential","UniversityDegreeCredential"]}],"issuer_state":"eyJhbGciOiJSU0Et...FYUaBy"}
99
+
100
+ ####################################################################################################################################
101
+
102
+ https://issuer.research.identiproof.io?issuer=https://issuer.research.identiproof.io&credential_type=OpenBadgeCredentialUrl&pre-authorized_code=4jLs9xZHEfqcoow0kHE7d1a8hUk6Sy-5bVSV2MqBUGUgiFFQi-ImL62T-FmLIo8hKA1UdMPH0lM1xAgcFkJfxIw9L-lI3mVs0hRT8YVwsEM1ma6N3wzuCdwtMU4bcwKp&user_pin_required=true
103
+ */
104
+ it('succeed with a full flow with the client using OpenID4VCI version 11 and https', async () => {
105
+ succeedWithAFullFlowWithClientSetup()
106
+ const client = await OpenID4VCIClient.fromURI({
107
+ uri: HTTPS,
108
+ kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1',
109
+ alg: Alg.ES256,
110
+ clientId: 'test-clientId'
111
+ })
112
+ await assertionOfsucceedWithAFullFlowWithClient(client);
113
+ })
114
+
92
115
  async function assertionOfsucceedWithAFullFlowWithClient(client: OpenID4VCIClient) {
93
116
  expect(client.credentialOffer).toBeDefined();
94
117
  expect(client.endpointMetadata).toBeDefined();
@@ -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://?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',
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 https url as input and return a Credential Offer', async () => {
73
+ it('Should take an http url as input and return a Credential Offer', async () => {
74
74
  const client = await CredentialOfferClient.fromURI(
75
- 'http://?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',
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('https://launchpad.vii.electron.mattrlabs.io');
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.2+968cc5f",
3
+ "version": "0.10.4-unstable.3+4eaa40a",
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.2+968cc5f",
18
+ "@sphereon/oid4vci-common": "0.10.4-unstable.3+4eaa40a",
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": "968cc5ff4f829f528cc6b0941f69470a97c206ec"
72
+ "gitHead": "4eaa40a765b91ee1237fd2ecc309d51821c9340c"
73
73
  }