@sphereon/oid4vci-client 0.0.1-unstable.1

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/.eslintrc.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "root": true,
3
+ "parser": "@typescript-eslint/parser",
4
+ "parserOptions": {
5
+ "project": "./tsconfig.json"
6
+ },
7
+ "env": {
8
+ "es6": true
9
+ },
10
+ "ignorePatterns": [
11
+ "build",
12
+ "coverage",
13
+ "dist",
14
+ "jest.config.js",
15
+ "node_modules"
16
+ ],
17
+ "plugins": [
18
+ "import",
19
+ "eslint-comments"
20
+ ],
21
+ "extends": [
22
+ "eslint:recommended",
23
+ "plugin:eslint-comments/recommended",
24
+ "plugin:@typescript-eslint/recommended",
25
+ "plugin:import/typescript",
26
+ "prettier"
27
+ ],
28
+ "globals": {
29
+ "BigInt": true,
30
+ "console": true,
31
+ "WebAssembly": true
32
+ },
33
+ "rules": {
34
+ "@typescript-eslint/explicit-module-boundary-types": "off",
35
+ "@typescript-eslint/typedef": [
36
+ "error",
37
+ {
38
+ "call-signature": true,
39
+ "arrow-call-signature": true,
40
+ "parameter": true,
41
+ "arrow-parameter": true,
42
+ "property-declaration": true,
43
+ "variable-declaration": true,
44
+ "member-variable-declaration": true
45
+ }
46
+ ],
47
+ "@typescript-eslint/explicit-function-return-type": [
48
+ "error",
49
+ {
50
+ "allowExpressions": true
51
+ }
52
+ ],
53
+ "eslint-comments/disable-enable-pair": [
54
+ "error",
55
+ {
56
+ "allowWholeFile": true
57
+ }
58
+ ],
59
+ "eslint-comments/no-unused-disable": "error",
60
+ "import/order": [
61
+ "error",
62
+ {
63
+ "newlines-between": "always",
64
+ "alphabetize": {
65
+ "order": "asc"
66
+ }
67
+ }
68
+ ],
69
+ "sort-imports": [
70
+ "error",
71
+ {
72
+ "ignoreDeclarationSort": true,
73
+ "ignoreCase": true
74
+ }
75
+ ]
76
+ }
77
+ }
@@ -0,0 +1,34 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ # Allows you to run this workflow manually from the Actions tab
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ build:
12
+ name: build
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v1
16
+ - name: install node v14
17
+ uses: actions/setup-node@v1
18
+ with:
19
+ node-version: 14
20
+ - name: yarn install
21
+ run: yarn install
22
+ - name: tsc
23
+ uses: icrawl/action-tsc@v1
24
+ - name: yarn build
25
+ run: yarn build
26
+ - name: yarn test
27
+ run: yarn test
28
+ - name: codecov
29
+ uses: codecov/codecov-action@v2
30
+ with:
31
+ # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
32
+ name: codecove # optional
33
+ flags: unittest
34
+ verbose: true # optional (default = false)
@@ -0,0 +1,3 @@
1
+ dist
2
+ coverage
3
+ node_modules
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Release Notes
2
+
3
+ ## v0.0.1 - 2022-10-21
4
+
5
+ Initial Structure
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2022] [Sphereon B.V.]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,206 @@
1
+ <h1 align="center">
2
+ <br>
3
+ <a href="https://www.sphereon.com"><img src="https://sphereon.com/content/themes/sphereon/assets/img/logo.svg" alt="Sphereon" width="400"></a>
4
+ <br>OpenID for Verifiable Credential Issuance - Client
5
+ <br>
6
+ </h1>
7
+
8
+ _IMPORTANT this package is in an early development stage and does not support all functionality from the OID4VCI spec
9
+ yet!_
10
+
11
+ ### Background
12
+
13
+ A client to request and receive Verifiable Credentials using
14
+ the [OpenID for Verifiable Credential Issuance](https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html) (
15
+ OID4VCI) specification for receiving Verifiable Credentials as a Holder.
16
+
17
+ ### Flows
18
+
19
+ #### Authorized Code Flow
20
+
21
+ This flow isn't supported yet!
22
+
23
+ #### Pre-authorized Code Flow
24
+
25
+ The pre-authorized code flow assumes the user is using an out of bound mechanism outside the issuance flow to
26
+ authenticate first.
27
+
28
+ The below diagram shows the steps involved in the pre-authorized code flow. Note that wallet inner functionalities (like
29
+ saving VCs) are out of scope for this library. Also This library doesn't involve any functionalities of a VC Issuer
30
+ ![Flow diagram](https://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/Sphereon-Opensource/OID4VCI-client/develop/docs/preauthorized-code-flow.puml)
31
+
32
+ #### Issuance Initiation
33
+
34
+ Issuance is started from a so-called Issuance Initiation Request by the Issuer. This typically is URI, exposed
35
+ as a link or a QR code. You can call the `IssuanceInitiation.fromURI(uri)` method to parse the URI into a Json object
36
+ containing the baseUrl and the `IssuanceInitiationRequest` payload object
37
+
38
+ ```typescript
39
+ import IssuanceInitiation from './IssuanceInitiation';
40
+
41
+ const initiationURI =
42
+ 'https://issuer.example.com?issuer=https%3A%2F%2Fserver%2Eexample%2Ecom&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FhealthCard&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FdriverLicense&op_state=eyJhbGciOiJSU0Et...FYUaBy';
43
+
44
+ const initiationRequestWithUrl = IssuanceInitiation.fromURI(initiationURI);
45
+ console.log(initiationRequestWithUrl);
46
+
47
+ /**
48
+ * {
49
+ * "baseUrl": "https://server.example.com",
50
+ * "issuanceInitiationRequest": {
51
+ * "credential_type": [
52
+ * "https://did.example.org/healthCard",
53
+ * "https://did.example.org/driverLicense"
54
+ * ],
55
+ * "issuer": "https://server.example.com",
56
+ * "op_state": "eyJhbGciOiJSU0Et...FYUaBy"
57
+ * }
58
+ * }
59
+ */
60
+ ```
61
+
62
+ #### Acquiring the Access Token
63
+ Now you will need to get an access token from the oAuth2 Authorization Server (AS), using some values from the `IssuanceInitiationRequest` payload.
64
+ For now you can use the issuer hostname for the AS, as there is no way to know the AS from the Issuance Initiation for known until the following [OpenID Ticket](https://bitbucket.org/openid/connect/issues/1632/issuer-metadata-clarification-needed) is resolved. So the token endpoint would become https://<issuer-hostname>/token.
65
+ The library allows to pass in a different value for the AS token endpoint as well, so you already can use a different AS if you know the AS upfront.
66
+
67
+
68
+
69
+
70
+ ### Interfaces
71
+
72
+ ```typescript
73
+ export interface IssuanceInitiationRequestPayload {
74
+ issuer: string; //REQUIRED The issuer URL of the Credential issuer, the Wallet is requested to obtain one or more Credentials from.
75
+ credential_type: string[] | string; //REQUIRED A JSON string denoting the type of the Credential the Wallet shall request
76
+ pre_authorized_code?: string; //CONDITIONAL The code representing the issuer's authorization for the Wallet to obtain Credentials of a certain type. This code MUST be short lived and single-use. MUST be present in a pre-authorized code flow.
77
+ user_pin_required?: boolean; //OPTIONAL Boolean value specifying whether the issuer expects presentation of a user PIN along with the Token Request in a pre-authorized code flow. Default is false.
78
+ op_state?: string; //OPTIONAL String value created by the Credential Issuer and opaque to the Wallet that is used to bind the sub-sequent authentication request with the Credential Issuer to a context set up during previous steps
79
+ }
80
+
81
+ export interface CredentialRequest {
82
+ type: string | string[];
83
+ format: CredentialFormat | CredentialFormat[];
84
+ proof: ProofOfPossession;
85
+ }
86
+
87
+ export interface CredentialResponse {
88
+ credential: W3CVerifiableCredential;
89
+ format: CredentialFormat;
90
+ }
91
+
92
+ export interface CredentialResponseError {
93
+ error: CredentialResponseErrorCode;
94
+ error_description?: string;
95
+ error_uri?: string;
96
+ }
97
+ ```
98
+
99
+ ### Functions
100
+
101
+ Several utility functions are available
102
+
103
+ #### convertJsonToURI:
104
+
105
+ Converts a Json object or string into an URI:
106
+
107
+ ```typescript
108
+ import { convertJsonToURI } from './Encoding';
109
+
110
+ const encodedURI = convertJsonToURI(
111
+ {
112
+ issuer: 'https://server.example.com',
113
+ credential_type: ['https://did.example.org/healthCard', 'https://did.example1.org/driverLicense'],
114
+ op_state: 'eyJhbGciOiJSU0Et...FYUaBy',
115
+ },
116
+ {
117
+ arrayTypeProperties: ['credential_type'],
118
+ urlTypeProperties: ['issuer', 'credential_type'],
119
+ }
120
+ );
121
+ console.log(encodedURI);
122
+ // issuer=https%3A%2F%2Fserver%2Eexample%2Ecom&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FhealthCard&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FdriverLicense&op_state=eyJhbGciOiJSU0Et...FYUaBy
123
+ ```
124
+
125
+ #### convertURIToJsonObject:
126
+
127
+ Converts a URI into a Json object with URL decoded properties. Allows to provide which potential duplicate keys need to
128
+ be converted into an array.
129
+
130
+ ```typescript
131
+ import { convertURIToJsonObject } from './Encoding';
132
+
133
+ const decodedJson = convertURIToJsonObject(
134
+ 'issuer=https%3A%2F%2Fserver%2Eexample%2Ecom&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FhealthCard&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FdriverLicense&op_state=eyJhbGciOiJSU0Et...FYUaBy',
135
+ {
136
+ arrayTypeProperties: ['credential_type'],
137
+ requiredProperties: ['issuer', 'credential_type'],
138
+ }
139
+ );
140
+ console.log(decodedJson);
141
+ // {
142
+ // issuer: 'https://server.example.com',
143
+ // credential_type: ['https://did.example.org/healthCard', 'https://did.example1.org/driverLicense'],
144
+ // op_state: 'eyJhbGciOiJSU0Et...FYUaBy'
145
+ // }
146
+ ```
147
+
148
+ #### createProofOfPossession
149
+
150
+ Creates the ProofOfPossession object and JWT signature
151
+
152
+ The callback function created using `jose`
153
+
154
+ ```typescript
155
+ // Must be JWS
156
+ const signJWT = async (args: JWTSignerArgs): Promise<string> => {
157
+ const { header, payload, keyPair } = args;
158
+ return await new jose.CompactSign(u8a.fromString(JSON.stringify({ ...payload })))
159
+ // Only ES256 and EdDSA are supported
160
+ .setProtectedHeader({ ...header, alg: args.header.alg })
161
+ .sign(keyPair.privateKey);
162
+ };
163
+ ```
164
+
165
+ ```typescript
166
+ const verifyJWT = async (args: { jws: string | Uint8Array; key: KeyLike | Uint8Array; options?: VerifyOptions }): Promise<void> => {
167
+ // Throws an exception if JWT is not valid
168
+ await jose.compactVerify(args.jws, args.key, args.options);
169
+ };
170
+ ```
171
+
172
+ The arguments requested by `jose` and `oidc4vci`
173
+
174
+ ```typescript
175
+ const keyPair = await jose.generateKeyPair('ES256');
176
+
177
+ const jwtArgs: JWTSignerArgs = {
178
+ header: {
179
+ alg: 'ES256',
180
+ kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1',
181
+ },
182
+ payload: {
183
+ iss: 's6BhdRkqt3',
184
+ aud: 'https://server.example.com',
185
+ iat: 1659145924,
186
+ nonce: 'tZignsnFbp',
187
+ },
188
+ privateKey: keyPair.privateKey,
189
+ publicKey: keyPair.publicKey,
190
+ };
191
+ ```
192
+
193
+ The actual method call
194
+
195
+ ```typescript
196
+ const proof: ProofOfPossession = await vcIssuanceClient.createProofOfPossession({
197
+ jwtSignerArgs: jwtArgs,
198
+ jwtSignerCallback: (args) => signJWT(args),
199
+ jwtVerifyCallback: (args) => verifyJWT(args),
200
+ });
201
+ console.log(proof);
202
+ // {
203
+ // "proof_type": "jwt",
204
+ // "jwt": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImRpZDpleGFtcGxlOmViZmViMWY3MTJlYmM2ZjFjMjc2ZTEyZWMyMS9rZXlzLzEifQ.eyJpc3MiOiJzNkJoZFJrcXQzIiwiYXVkIjoiaHR0cHM6Ly9zZXJ2ZXIuZXhhbXBsZS5jb20iLCJpYXQiOjE2NTkxNDU5MjQsIm5vbmNlIjoidFppZ25zbkZicCJ9.btetOcsJ_VOePkwlFf2kyxm6hEUvPRimf3M-Dn3Lmzcmt5QiPToXNWxe_0fEJlRf4Ith55YGB43ScBe6ScZmD1gfLELYQF7LLg97yYlx_Iu8RLA2dS_7EWzLD3ZIzyUGf_uMq3HwXGJKL-ihroRpRBvxRLdZCy-j62nAzoTsBnlr6n79VjkGtlxIjN_CLGIQBhc3du3enghY6N4s3oXFrxWMl7UzGKdjCYN6vSagDb0MURjdiDCsK_yX4NyNd0nGpxqGhVgMpuhqEcqyU0qWPyHF-swtGG5JVAOJGd_YkJS5vbia8UdyOJXnAAdEE1E62a2yUPahNDxMh1iIpS0WO7y6QexWXdb5fmnWDst89T3ELS8Hj2Vzsw1XPyk9XR9JmiDzmEZdH05Wf4M9pXUG4-8_7StB6Lxc7_xDJdk6JPbzFgAIhJa4F_3rfPuwMseSEQvD6bDFowkIiUpt1vXGGVjVm3N4I4Th4_A2QpW4mDzcTKoZq9MKlDGXeLQBtiKXmqs10Jvzpp3O7kBwH7Qm6VUdBxk_-wsWplUZC4IvCfv23hy2SyFnh5zC6Wtw3UcbrSH6LcD7g-RNTKe4fRekyDxqLRdEm60BOozgBoTNhnetCrQ3e7HrApj9EP0vqNyXdtGGWCA011HVDnz6lVzf5yijJB8hOPpkgYGRmHdRQwI"
205
+ // }
206
+ ```
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -0,0 +1,38 @@
1
+ @startuml
2
+
3
+ header Pre-authorized Code Flow
4
+
5
+ title
6
+ Pre-authorized Code Flow
7
+ Pre-authorized Code Flow between a holder and an issuer
8
+ end title
9
+
10
+
11
+ autonumber
12
+
13
+ participant "Holder" as H order 1 #PINK
14
+ participant "Wallet" as W order 2 #YELLOW
15
+ participant "Issuer" as I order 3 #ORANGE
16
+
17
+ H -> I: Holder applies for one or more credentials online.
18
+ I -> I: The Issuer generates a pre-authorization code \nthe Issuer puts the OIDC4VCI Initiate Issuance Request\n into a QR Code.
19
+ I -> H: The Issuer either shows the QR Code to the holder\n or prints a document with the QR Code on it.
20
+ H -> W: Holder uses the Wallet to scan the QR Code\n displayed on the Issuer website.
21
+ W -> W: Since the QR Code contains an Issuance Initiation Request, \nthe Wallet then starts the issuance flow.
22
+ W -> I: (OPTIONAL) The wallet uses the URL in the QR Code to\n obtain the issuer’s metadata.
23
+ W -> W: (OPTIONAL) Wallet generates a new DID / keypair\n or selects an existing DID / keypair.
24
+ W -> W: The Wallet generates the OIDC4VCI Token Request.
25
+ W -> I: The Wallet sends the OIDCVCI Token Request via HTTPS\n to the OIDC4VCI token endpoint of the Issuer\n including the pre-authorized code.
26
+ I -> I: The Issuer verifies the OIDC4VCI Token Request\n and checks whether the request was pre-authorized.
27
+ I -> W: The Issuer returns the OIDC4VCI token (access_token).
28
+ W -> W: The Wallet generates a JWT that contains a nonce and\n short validity time and is \nsigned by the private key of the DID.\n This will provide the issuer with PoP of the private key.
29
+ W -> W: The Wallet creates the CredentialRequest
30
+ W -> I: The Wallet sends the CredentialRequest via \nVcIssuanceClient.sendCredentialRequest function
31
+ I -> I: The Issuer verifies the CredentialRequest\n (based on the access_token) and the PoP (JWT).
32
+ I -> I: The Issuer extracts the DID from the PoP.
33
+ I -> I: The Issuer creates the credential, adds the subject’s DID\n and signs the credential with the private key of their Issuer’ URI.
34
+ I -> I: The Issuer generates the CredentialResponse.
35
+ I -> W: The Wallet receives the CredentialResponse\n and extracts the credential(s) to store in the Wallet.
36
+ W -> H: Wallet shows the credential(s) to the holder.
37
+
38
+ @enduml
package/index.ts ADDED
File without changes
@@ -0,0 +1,26 @@
1
+ module.exports = {
2
+ preset: "ts-jest",
3
+ testEnvironment: "node",
4
+ moduleNameMapper: {
5
+ "^jose/(.*)$": "<rootDir>/node_modules/jose/dist/node/cjs/$1",
6
+ },
7
+ rootDir: ".",
8
+ roots: ["<rootDir>/lib/", "<rootDir>/tests/"],
9
+ testMatch: ["**/?(*.)+(spec|test).+(ts|tsx|js)"],
10
+ transform: {
11
+ "^.+\\.(ts|tsx)?$": "ts-jest",
12
+ },
13
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"],
14
+ coverageDirectory: "./coverage/",
15
+ collectCoverageFrom: [
16
+ "lib/**/*.{ts,tsx}",
17
+ "!lib/schemas/**",
18
+ "!lib/**/*.d.ts",
19
+ "!**/node_modules/**",
20
+ "!jest.config.cjs",
21
+ "!generator/**",
22
+ "!index.ts"
23
+ ],
24
+ collectCoverage: true,
25
+ reporters: ["default", ["jest-junit", { outputDirectory: "./coverage" }]],
26
+ };