@proof.com/proof-vc-common 0.1.0

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.
Files changed (63) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +305 -0
  3. package/dist/certificates/chain_validator.d.ts +3 -0
  4. package/dist/certificates/chain_validator.d.ts.map +1 -0
  5. package/dist/certificates/chain_validator.js +29 -0
  6. package/dist/certificates/chain_validator.js.map +1 -0
  7. package/dist/certificates/trust_store/index.d.ts +4 -0
  8. package/dist/certificates/trust_store/index.d.ts.map +1 -0
  9. package/dist/certificates/trust_store/index.js +17 -0
  10. package/dist/certificates/trust_store/index.js.map +1 -0
  11. package/dist/certificates/trust_store/proof_root_ca_r1.d.ts +2 -0
  12. package/dist/certificates/trust_store/proof_root_ca_r1.d.ts.map +1 -0
  13. package/dist/certificates/trust_store/proof_root_ca_r1.js +16 -0
  14. package/dist/certificates/trust_store/proof_root_ca_r1.js.map +1 -0
  15. package/dist/certificates/trust_store/proof_root_ca_r1_development.d.ts +2 -0
  16. package/dist/certificates/trust_store/proof_root_ca_r1_development.d.ts.map +1 -0
  17. package/dist/certificates/trust_store/proof_root_ca_r1_development.js +17 -0
  18. package/dist/certificates/trust_store/proof_root_ca_r1_development.js.map +1 -0
  19. package/dist/index.browser.d.ts +5 -0
  20. package/dist/index.browser.d.ts.map +1 -0
  21. package/dist/index.browser.js +3 -0
  22. package/dist/index.browser.js.map +1 -0
  23. package/dist/index.node.d.ts +5 -0
  24. package/dist/index.node.d.ts.map +1 -0
  25. package/dist/index.node.js +3 -0
  26. package/dist/index.node.js.map +1 -0
  27. package/dist/presentation/base_client.d.ts +33 -0
  28. package/dist/presentation/base_client.d.ts.map +1 -0
  29. package/dist/presentation/base_client.js +92 -0
  30. package/dist/presentation/base_client.js.map +1 -0
  31. package/dist/presentation/node_client.d.ts +15 -0
  32. package/dist/presentation/node_client.d.ts.map +1 -0
  33. package/dist/presentation/node_client.js +59 -0
  34. package/dist/presentation/node_client.js.map +1 -0
  35. package/dist/proof_credential_factory.d.ts +4 -0
  36. package/dist/proof_credential_factory.d.ts.map +1 -0
  37. package/dist/proof_credential_factory.js +37 -0
  38. package/dist/proof_credential_factory.js.map +1 -0
  39. package/dist/proof_credentials.d.ts +42 -0
  40. package/dist/proof_credentials.d.ts.map +1 -0
  41. package/dist/proof_credentials.js +61 -0
  42. package/dist/proof_credentials.js.map +1 -0
  43. package/dist/transaction_data.d.ts +73 -0
  44. package/dist/transaction_data.d.ts.map +1 -0
  45. package/dist/transaction_data.js +51 -0
  46. package/dist/transaction_data.js.map +1 -0
  47. package/dist/types.d.ts +16 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +2 -0
  50. package/dist/types.js.map +1 -0
  51. package/dist/utils.d.ts +3 -0
  52. package/dist/utils.d.ts.map +1 -0
  53. package/dist/utils.js +10 -0
  54. package/dist/utils.js.map +1 -0
  55. package/dist/vc_presentation.browser.d.ts +4 -0
  56. package/dist/vc_presentation.browser.d.ts.map +1 -0
  57. package/dist/vc_presentation.browser.js +13 -0
  58. package/dist/vc_presentation.browser.js.map +1 -0
  59. package/dist/vc_presentation.node.d.ts +8 -0
  60. package/dist/vc_presentation.node.d.ts.map +1 -0
  61. package/dist/vc_presentation.node.js +23 -0
  62. package/dist/vc_presentation.node.js.map +1 -0
  63. package/package.json +77 -0
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 [yyyy] [name of copyright owner]
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,305 @@
1
+ # Proof Digital Credentials
2
+
3
+ <img src="docs/proof-logo.svg" alt="drawing" width="450"/>
4
+
5
+ _A digital passport. Verified once, usable everywhere._
6
+
7
+ Read our [documentation](https://dev.proof.com/docs/digital-credentials-overview) or [try it](https://demo.next.proof.com)!
8
+
9
+ ## Table of Contents
10
+
11
+ - [Installation](#installation)
12
+ - [Getting Started](#getting-started)
13
+ - [Response Modes](#response-modes)
14
+ - [Pushed Authorization Requests](#pushed-authorization-requests)
15
+ - [Verifiable Credential Presentation](#verifiable-credential-presentation)
16
+ - [Credential Types](#credential-type)
17
+ - [Request](#request)
18
+ - [Scopes](#scopes)
19
+ - [Transaction Templates](#transaction-templates)
20
+ - [Verify](#verify)
21
+ - [Certificate Authority](#certificate-authority)
22
+ - [Documentation](#documentation)
23
+ - [Contributing](#contributing)
24
+
25
+ ## Installation
26
+
27
+ ```
28
+ npm install @proof.com/proof-vc-common
29
+ ```
30
+
31
+ The library provides 2 distinct browser and Node.js distributions, see [package.json](package.json) `exports`. The browser distribution has **0 dependencies** :white_check_mark:
32
+
33
+ ## Getting Started
34
+
35
+ Proof implements the [OpenID for Verifiable Presentations 1.0](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html) specification.
36
+ [Setup an OAuth Application](https://dev.proof.com/docs/oauth-client-credentials) in your Proof account to get your `client_id`.
37
+
38
+ Initialize the library at the start of your application:
39
+
40
+ ```javascript
41
+ import { init } from "@proof.com/proof-vc-common";
42
+
43
+ init({
44
+ environment: "sandbox",
45
+ client_id: "verifier-demo",
46
+ response_mode: "direct_post",
47
+ callback_uri: "http://localhost/verify_vp_token",
48
+ });
49
+ ```
50
+
51
+ ### Response Modes
52
+
53
+ Proof supports `fragment` and `direct_post` response modes.
54
+
55
+ #### fragment
56
+
57
+ Using `fragment` the `vp_token` is returned as a fragment of the `callback_uri` when the user is 302 redirected from Proof to your website.
58
+
59
+ ```
60
+ GET http://localhost/verify_vp_token#vp_token=eyJwcm9vZl9pZF9...
61
+ ```
62
+
63
+ #### direct_post
64
+
65
+ Using `direct_post` the `vp_token` is returned in the JSON body of a POST request to the `callback_uri` from Proof to your website. See the [OID4VP specification](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-response-mode-direct_post) for more details.
66
+
67
+ ```
68
+ POST http://localhost/verify_vp_token
69
+ { "vp_token": "eyJwcm9vZl9pZF9..." }
70
+ ```
71
+
72
+ ### Pushed Authorization Requests
73
+
74
+ Proof supports [Pushed Authorization Requests](https://datatracker.ietf.org/doc/html/rfc9126) (PAR).
75
+ You may want to use this feature when using [Transaction Templates](#transaction-templates) to avoid hitting URL size limits.
76
+
77
+ ```javascript
78
+ init({
79
+ environment: "sandbox",
80
+ client_id: "caxdw5a7d",
81
+ response_mode: "direct_post",
82
+ callback_uri: "http://localhost/verify_vp_token",
83
+ use_pushed_authorization_request: true,
84
+ });
85
+ ```
86
+
87
+ ## Verifiable Credential Presentation
88
+
89
+ ### Credential Type
90
+
91
+ Proof issues Verifiable Credentials according to the [SD-JWT-VC specification](https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-16.html) and publishes its [OID4VCI Credential Issuer Metadata](https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-credential-issuer-metadata) at https://api.proof.com/.well-known/openid-credential-issuer.
92
+
93
+ `ProofCredentialV1`
94
+
95
+ | claim | type | description |
96
+ | -------------- | ------- | ------------------------------------------------------------------ |
97
+ | given_name | string | user's given name as it appears on the verified identity document |
98
+ | family_name | string | user's family name as it appears on the verified identity document |
99
+ | birthdate | string | user's date of birth in ISO 8601 format (`YYYY-MM-DD`) |
100
+ | age_is_over.18 | boolean | boolean confirming the user is 18 or older |
101
+ | age_is_over.21 | boolean | boolean confirming the user is 21 or older |
102
+ | age_is_over.65 | boolean | boolean confirming the user is 65 or older |
103
+
104
+ All attributes are selectively disclosable and will return `undefined` if the claim wasn't disclosed.
105
+
106
+ ### Request
107
+
108
+ Request a Verifiable Credential Presentation with an [OAuth 2.0](https://datatracker.ietf.org/doc/html/rfc6749) Authorization Request:
109
+
110
+ ```javascript
111
+ import { getAuthorizationRequestURL } from "@proof.com/proof-vc-common";
112
+
113
+ const redirect = getAuthorizationRequestURL({
114
+ nonce: "3e8e4918-e9fb-453a-a538-81152be15c1b",
115
+ scope: "urn:proof:params:scope:verifiable-credentials:basic",
116
+ state: "6A2B4CD830",
117
+ login_hint: "frodo.baggins@theshire",
118
+ });
119
+
120
+ window.location.href = redirect;
121
+ ```
122
+
123
+ #### Scopes
124
+
125
+ Proof supports the `scope` parameter of the [OID4VP specification](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-using-scope-parameter-to-re). Each scope maps to a pre-defined DCQL query and returns a specific [Credential Type](#credential-type).
126
+
127
+ Supported `scope` and their associated [Credential Type](#credential-type):
128
+
129
+ | scope | Credential Type |
130
+ | ----------------------------------------------------- | ------------------- |
131
+ | `urn:proof:params:scope:verifiable-credentials:basic` | `ProofCredentialV1` |
132
+
133
+ #### Transaction Templates
134
+
135
+ _Transaction Templates_ allow you to bind specific data to a Verifiable Credential Presentation. Proof uses the [Transaction Data](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-transaction-data) parameter of the OID4VP specification.
136
+ The data is shown to the user during the Presentation flow and the user signs it with a Key Binding JWT (KB-JWT). The KB-JWT is returned as part of the [Presentation](https://dev.proof.com/docs/sd-jwt-vc-format).
137
+
138
+ The following _Transaction Templates_ are available:
139
+
140
+ **urn:proof:params:vc:transaction-data:wire-instructions:v1**
141
+
142
+ ```javascript
143
+ import {
144
+ getAuthorizationRequestURL,
145
+ transactionData,
146
+ } from "@proof.com/proof-vc-common";
147
+
148
+ const data = transactionData.wireInstructions({
149
+ recipient: {
150
+ institution_name: "Crestline Financial",
151
+ individual_name: "Acme Corp LLC",
152
+ routing_number: "055000123",
153
+ account_number: "7293",
154
+ },
155
+ source: {
156
+ institution_name: "Sterling & Union",
157
+ individual_name: "Sterling & Union",
158
+ account_number: "4821",
159
+ routing_number: "091000456",
160
+ },
161
+ amount: 5000,
162
+ currency: "USD",
163
+ memo: "Invoice #2024-089",
164
+ });
165
+ const redirect = getAuthorizationRequestURL({
166
+ nonce: "3e8e4918-e9fb-453a-a538-81152be15c1b",
167
+ scope: "urn:proof:params:scope:verifiable-credentials:basic",
168
+ state: "6A2B4CD830",
169
+ login_hint: "frodo.baggins@theshire",
170
+ transaction_data: data,
171
+ });
172
+ ```
173
+
174
+ ---
175
+
176
+ **urn:proof:params:vc:transaction-data:payment-itemized:v1**
177
+
178
+ ```javascript
179
+ import {
180
+ getAuthorizationRequestURL,
181
+ transactionData,
182
+ } from "@proof.com/proof-vc-common";
183
+
184
+ const data = transactionData.paymentItemized({
185
+ title: "Drive Shaft",
186
+ description: "The Roadhouse (18+), May 6 2026",
187
+ currency: "USD",
188
+ items: [
189
+ { quantity: 2, unit_cost: 40.0, label: "General Admission" },
190
+ { quantity: 2, unit_cost: 11.4, label: "Fees" },
191
+ ],
192
+ });
193
+ const redirect = getAuthorizationRequestURL({
194
+ nonce: "3e8e4918-e9fb-453a-a538-81152be15c1b",
195
+ scope: "urn:proof:params:scope:verifiable-credentials:basic",
196
+ state: "6A2B4CD830",
197
+ login_hint: "frodo.baggins@theshire",
198
+ transaction_data: data,
199
+ });
200
+ ```
201
+
202
+ ---
203
+
204
+ **urn:proof:params:vc:transaction-data:payment-mandate:v1**
205
+
206
+ ```javascript
207
+ import {
208
+ getAuthorizationRequestURL,
209
+ transactionData,
210
+ } from "@proof.com/proof-vc-common";
211
+
212
+ const data = transactionData.paymentMandate({
213
+ payment_instrument: {
214
+ type: "wallet",
215
+ id: "did:example:visa-token-7829",
216
+ description: "Visa ••••7829",
217
+ },
218
+ payee: {
219
+ id: "did:example:summitco",
220
+ name: "Summit Co",
221
+ website: "summitco.com",
222
+ },
223
+ prompt_summary:
224
+ "Find me a 4-season backpacking tent from Summit Co under $500",
225
+ amount: 500,
226
+ currency: "USD",
227
+ });
228
+ const redirect = getAuthorizationRequestURL({
229
+ nonce: "3e8e4918-e9fb-453a-a538-81152be15c1b",
230
+ scope: "urn:proof:params:scope:verifiable-credentials:basic",
231
+ state: "6A2B4CD830",
232
+ login_hint: "frodo.baggins@theshire",
233
+ transaction_data: data,
234
+ });
235
+ ```
236
+
237
+ ### Verify
238
+
239
+ Decode and verify a Verifiable Presentation's `vp_token` server-side:
240
+
241
+ ```javascript
242
+ import { init, verifyVPToken } from "@proof.com/proof-vc-common";
243
+
244
+ init({
245
+ environment: "sandbox",
246
+ client_id: "verifier-demo",
247
+ callback_uri: "https://demo.next.proof.com/",
248
+ });
249
+
250
+ const vpToken = "eyJwcm9vZl9pZ...";
251
+ const presentation = verifyVPToken({
252
+ encodedVPToken: vpToken,
253
+ nonce: "3e8e4918-e9fb-453a-a538-81152be15c1b",
254
+ });
255
+ const verifiableCredential = presentation["proof_id_default"][0];
256
+
257
+ if (verifiableCredential.isOver18()) {
258
+ purchaseItem();
259
+ } else {
260
+ userNotOver18();
261
+ }
262
+ ```
263
+
264
+ Verify a single SD-JWT-VC:
265
+
266
+ ```javascript
267
+ import { init, verify } from "@proof.com/proof-vc-common";
268
+
269
+ init({
270
+ environment: "sandbox",
271
+ client_id: "verifier-demo",
272
+ callback_uri: "https://demo.next.proof.com/",
273
+ });
274
+
275
+ const encodedSDJWT = "eyJraWQiOiI3...";
276
+ const verifiableCredential = verify({
277
+ encodedSDJWT,
278
+ nonce: "3e8e4918-e9fb-453a-a538-81152be15c1b",
279
+ });
280
+
281
+ if (verifiableCredential.isOver18()) {
282
+ purchaseItem();
283
+ } else {
284
+ userNotOver18();
285
+ }
286
+ ```
287
+
288
+ ### Certificate Authority
289
+
290
+ Proof's Verifiable Credentials are issued by our [Certificate Authority](https://www.proof.com/legal/certificate-policy)
291
+ following the CA/B Forum Baseline Requirements for the Issuance and Management of Publicly-Trusted TLS Server Certificates published at https://www.cabforum.org.
292
+
293
+ The Proof Root CA R1 Certificate is published at http://cert.proof.com/proof-root-ca-r1.crt and
294
+ is also committed in this repository [proof-root-ca-r1.crt](src/certificates/trust_store/proof_root_ca_r1.ts).
295
+
296
+ The sandbox Root CA R1 Development certificate is also committed in this repository [proof-root-ca-r1-development.crt](src/certificates/trust_store/proof_root_ca_r1_development.ts) and used when `environment: "sandbox"`.
297
+
298
+ ### Documentation
299
+
300
+ _Digital Credentials_ guides https://dev.proof.com/docs/digital-credentials-overview \
301
+ _API Documentation_ https://dev.proof.com/reference/authorizeverifiablecredentialpresentation
302
+
303
+ ### Contributing
304
+
305
+ [Contribution guidelines for this project](CONTRIBUTING.md)
@@ -0,0 +1,3 @@
1
+ import type { X509Certificate } from "node:crypto";
2
+ export declare function verifyChain(chain: X509Certificate[], root: X509Certificate): void;
3
+ //# sourceMappingURL=chain_validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain_validator.d.ts","sourceRoot":"","sources":["../../src/certificates/chain_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,EAAE,EACxB,IAAI,EAAE,eAAe,GACpB,IAAI,CA+BN"}
@@ -0,0 +1,29 @@
1
+ export function verifyChain(chain, root) {
2
+ if (chain.length === 0) {
3
+ throw new Error("verifyChain: empty chain");
4
+ }
5
+ const full = [...chain, root];
6
+ const now = new Date();
7
+ for (let i = 0; i < full.length - 1; i++) {
8
+ const cert = full[i];
9
+ const issuer = full[i + 1];
10
+ const validFrom = new Date(cert.validFromDate);
11
+ const validTo = new Date(cert.validToDate);
12
+ if (now < validFrom || now > validTo) {
13
+ throw new Error(`Certificate at index ${i} is expired or not yet valid`);
14
+ }
15
+ if (!cert.checkIssued(issuer)) {
16
+ throw new Error(`Certificate at index ${i} not issued by next in chain`);
17
+ }
18
+ if (!cert.verify(issuer.publicKey)) {
19
+ throw new Error(`Certificate at index ${i} has invalid signature`);
20
+ }
21
+ }
22
+ if (now > new Date(root.validToDate)) {
23
+ throw new Error("Root certificate expired");
24
+ }
25
+ if (!root.verify(root.publicKey)) {
26
+ throw new Error("Root is not self-signed");
27
+ }
28
+ }
29
+ //# sourceMappingURL=chain_validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain_validator.js","sourceRoot":"","sources":["../../src/certificates/chain_validator.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CACzB,KAAwB,EACxB,IAAqB;IAErB,IAAI,KAA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AC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { X509Certificate } from "node:crypto";
2
+ import type { Environment } from "../../types.ts";
3
+ export declare function getTrustRoot(env: Environment): X509Certificate;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/certificates/trust_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAOlD,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,eAAe,CAU9D"}
@@ -0,0 +1,17 @@
1
+ import { X509Certificate } from "node:crypto";
2
+ import { PROOF_ROOT_CA_R1_PEM } from "./proof_root_ca_r1.js";
3
+ import { PROOF_ROOT_CA_R1_DEVELOPMENT_PEM } from "./proof_root_ca_r1_development.js";
4
+ const PRODUCTION_ROOT = new X509Certificate(PROOF_ROOT_CA_R1_PEM);
5
+ const DEVELOPMENT_ROOT = new X509Certificate(PROOF_ROOT_CA_R1_DEVELOPMENT_PEM);
6
+ export function getTrustRoot(env) {
7
+ switch (env) {
8
+ case "production":
9
+ return PRODUCTION_ROOT;
10
+ case "localhost":
11
+ case "next":
12
+ case "staging":
13
+ case "sandbox":
14
+ return DEVELOPMENT_ROOT;
15
+ }
16
+ }
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/certificates/trust_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,mC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49BAMEA4GM\nADCBiAJCALbYDcwIET9C43d4+CXHGSEiurEFLQOn1wpukSyCiIQC/HRyJ8yW6ok5\nS6yDXqiS07q1yimBzoJXIHTO9w4iYruUAkIAx77dgeh8XXmR785O7hTtWpJj2IDt\nP/CSJ1VERYWD12mh2xvxNbI1HxansQuqLHN2b8ijqnZmK2vdYa2U7mSkfJY=\n-----END CERTIFICATE-----";
2
+ //# sourceMappingURL=proof_root_ca_r1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof_root_ca_r1.d.ts","sourceRoot":"","sources":["../../../src/certificates/trust_store/proof_root_ca_r1.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,i5BAcP,CAAC"}
@@ -0,0 +1,16 @@
1
+ export const PROOF_ROOT_CA_R1_PEM = `-----BEGIN CERTIFICATE-----
2
+ MIICaDCCAcmgAwIBAgIUZQN0R5EVDjRy5wVPCzhsV/fTC0swCgYIKoZIzj0EAwQw
3
+ PDELMAkGA1UEBhMCVVMxEjAQBgNVBAoMCVByb29mLmNvbTEZMBcGA1UEAwwQUHJv
4
+ b2YgUm9vdCBDQSBSMTAeFw0yNTA3MTYwMDAwMDBaFw00NTA3MTYwMDAwMDBaMDwx
5
+ CzAJBgNVBAYTAlVTMRIwEAYDVQQKDAlQcm9vZi5jb20xGTAXBgNVBAMMEFByb29m
6
+ IFJvb3QgQ0EgUjEwgZswEAYHKoZIzj0CAQYFK4EEACMDgYYABAC58cq5SFUdb3sU
7
+ pD/26o6VwWPPbBhWembs+Ynyx7lJzynoI/JLbdj/m4aLf8OFPAqK6M5xGV/NKlj1
8
+ VG0MeyQ/JgAnzkX8FZMJlILNi6z8jm7Dw6wBOnt2fOeSx4CdYWfVvJzSYTtcqzqD
9
+ TDqDUHyW+NpA4ulSPE1md/hOq0jzZz4+ZaNmMGQwDgYDVR0PAQH/BAQDAgEGMBIG
10
+ A1UdEwEB/wQIMAYBAf8CAQIwHQYDVR0OBBYEFBwMLyXY2aMAAOHzNtrbIkfi/b7K
11
+ MB8GA1UdIwQYMBaAFBwMLyXY2aMAAOHzNtrbIkfi/b7KMAoGCCqGSM49BAMEA4GM
12
+ ADCBiAJCALbYDcwIET9C43d4+CXHGSEiurEFLQOn1wpukSyCiIQC/HRyJ8yW6ok5
13
+ S6yDXqiS07q1yimBzoJXIHTO9w4iYruUAkIAx77dgeh8XXmR785O7hTtWpJj2IDt
14
+ P/CSJ1VERYWD12mh2xvxNbI1HxansQuqLHN2b8ijqnZmK2vdYa2U7mSkfJY=
15
+ -----END CERTIFICATE-----`;
16
+ //# sourceMappingURL=proof_root_ca_r1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof_root_ca_r1.js","sourceRoot":"","sources":["../../../src/certificates/trust_store/proof_root_ca_r1.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;0BAcV,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const PROOF_ROOT_CA_R1_DEVELOPMENT_PEM = "-----BEGIN CERTIFICATE-----\nMIICgDCCAeGgAwIBAgIUY25Mz7nqI55wZDd09Jv3qPORyIEwCgYIKoZIzj0EAwQw\nSDELMAkGA1UEBhMCVVMxEjAQBgNVBAoMCVByb29mLmNvbTElMCMGA1UEAwwcUHJv\nb2YgUm9vdCBDQSBSMSBEZXZlbG9wbWVudDAeFw0yNTA2MjYwMDAwMDBaFw00NTA2\nMjYwMDAwMDBaMEgxCzAJBgNVBAYTAlVTMRIwEAYDVQQKDAlQcm9vZi5jb20xJTAj\nBgNVBAMMHFByb29mIFJvb3QgQ0EgUjEgRGV2ZWxvcG1lbnQwgZswEAYHKoZIzj0C\nAQYFK4EEACMDgYYABAAWdWHGBOxrvDXqu3sgYBBGNnH31kB1DgHaKE4YMxu2YE3p\nqHjLZQxBUlXAWoapthkujZEEbqj3wH1nfPOmafl6rgDdtB6vjEeJRbwnIq26gy27\nrxLxtgCiJgS8/tcQARlENogzXHR6pxNxJp8e26qIgx2L/mokmiwgS4YRdJTXEzel\n0aNmMGQwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQIwHQYDVR0O\nBBYEFB8o85b43sVVc3m6PGyD67JEVvToMB8GA1UdIwQYMBaAFB8o85b43sVVc3m6\nPGyD67JEVvToMAoGCCqGSM49BAMEA4GMADCBiAJCAS0QLpYdjzShTuOPqex0R9Dx\nGrMeHkvtDmG2LsIZnly5yyUMDyV3HcW/Ex190nnCwLAV4I55EytZxBfi0B4a/M6n\nAkIBOTl1ataSokAQZ40lFxZeEIFvUWOOKW7ORuS2zb/hIrXLVVctw+Lp/CuzBHhq\nWcJQb7JVud5os3ZzD6zNDgMevdo=\n-----END CERTIFICATE-----";
2
+ //# sourceMappingURL=proof_root_ca_r1_development.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof_root_ca_r1_development.d.ts","sourceRoot":"","sources":["../../../src/certificates/trust_store/proof_root_ca_r1_development.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,m7BAenB,CAAC"}
@@ -0,0 +1,17 @@
1
+ export const PROOF_ROOT_CA_R1_DEVELOPMENT_PEM = `-----BEGIN CERTIFICATE-----
2
+ MIICgDCCAeGgAwIBAgIUY25Mz7nqI55wZDd09Jv3qPORyIEwCgYIKoZIzj0EAwQw
3
+ SDELMAkGA1UEBhMCVVMxEjAQBgNVBAoMCVByb29mLmNvbTElMCMGA1UEAwwcUHJv
4
+ b2YgUm9vdCBDQSBSMSBEZXZlbG9wbWVudDAeFw0yNTA2MjYwMDAwMDBaFw00NTA2
5
+ MjYwMDAwMDBaMEgxCzAJBgNVBAYTAlVTMRIwEAYDVQQKDAlQcm9vZi5jb20xJTAj
6
+ BgNVBAMMHFByb29mIFJvb3QgQ0EgUjEgRGV2ZWxvcG1lbnQwgZswEAYHKoZIzj0C
7
+ AQYFK4EEACMDgYYABAAWdWHGBOxrvDXqu3sgYBBGNnH31kB1DgHaKE4YMxu2YE3p
8
+ qHjLZQxBUlXAWoapthkujZEEbqj3wH1nfPOmafl6rgDdtB6vjEeJRbwnIq26gy27
9
+ rxLxtgCiJgS8/tcQARlENogzXHR6pxNxJp8e26qIgx2L/mokmiwgS4YRdJTXEzel
10
+ 0aNmMGQwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQIwHQYDVR0O
11
+ BBYEFB8o85b43sVVc3m6PGyD67JEVvToMB8GA1UdIwQYMBaAFB8o85b43sVVc3m6
12
+ PGyD67JEVvToMAoGCCqGSM49BAMEA4GMADCBiAJCAS0QLpYdjzShTuOPqex0R9Dx
13
+ GrMeHkvtDmG2LsIZnly5yyUMDyV3HcW/Ex190nnCwLAV4I55EytZxBfi0B4a/M6n
14
+ AkIBOTl1ataSokAQZ40lFxZeEIFvUWOOKW7ORuS2zb/hIrXLVVctw+Lp/CuzBHhq
15
+ WcJQb7JVud5os3ZzD6zNDgMevdo=
16
+ -----END CERTIFICATE-----`;
17
+ //# sourceMappingURL=proof_root_ca_r1_development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof_root_ca_r1_development.js","sourceRoot":"","sources":["../../../src/certificates/trust_store/proof_root_ca_r1_development.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gCAAgC,GAAG;;;;;;;;;;;;;;;0BAetB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type * from "./types.ts";
2
+ export type { TransactionData, WireInstructionsTransactionData, PaymentMandateTransactionData, PaymentItemizedTransactionData, SessionDataTransactionData, WireInstructionsPayload, PaymentMandatePayload, PaymentItemizedPayload, PaymentItemizedItem, SessionDataPayload, } from "./transaction_data.ts";
3
+ export { TX_DATA_TYPE, transactionData } from "./transaction_data.ts";
4
+ export { init, getAuthorizationRequestURL } from "./vc_presentation.browser.ts";
5
+ //# sourceMappingURL=index.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC;AAChC,YAAY,EACV,eAAe,EACf,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,IAAI,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { TX_DATA_TYPE, transactionData } from "./transaction_data.js";
2
+ export { init, getAuthorizationRequestURL } from "./vc_presentation.browser.js";
3
+ //# sourceMappingURL=index.browser.js.map