@bedrock/vc-delivery 3.0.0 → 3.0.2

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/lib/issue.js CHANGED
@@ -14,8 +14,8 @@ export async function issue({exchanger, exchange} = {}) {
14
14
  const {variables = {}} = exchange;
15
15
  // run jsonata compiler; only `jsonata` template type is supported and this
16
16
  // was validated when the exchanger was created
17
- const credentials = credentialTemplates.map(
18
- ({template: t}) => jsonata(t).evaluate(variables));
17
+ const credentials = await Promise.all(credentialTemplates.map(
18
+ ({template: t}) => jsonata(t).evaluate(variables)));
19
19
 
20
20
  // issue all VCs
21
21
  const vcs = await _issue({exchanger, credentials});
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@bedrock/vc-delivery",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "type": "module",
5
5
  "description": "Bedrock Verifiable Credential Delivery",
6
6
  "main": "./lib/index.js",
7
7
  "files": [
8
- "lib/**/*.js"
8
+ "lib/**/*.js",
9
+ "schemas/**/*.js"
9
10
  ],
10
11
  "scripts": {
11
12
  "lint": "eslint ."
@@ -15,7 +16,14 @@
15
16
  "url": "https://github.com/digitalbazaar/bedrock-vc-delivery"
16
17
  },
17
18
  "keywords": [
18
- "bedrock"
19
+ "bedrock",
20
+ "exchange",
21
+ "oid4vci",
22
+ "oid4vc",
23
+ "VC API",
24
+ "vc-api",
25
+ "verifiable credential",
26
+ "verifiable presentation"
19
27
  ],
20
28
  "author": {
21
29
  "name": "Digital Bazaar, Inc.",
@@ -27,14 +35,16 @@
27
35
  },
28
36
  "homepage": "https://github.com/digitalbazaar/bedrock-vc-delivery",
29
37
  "dependencies": {
30
- "@digitalbazaar/ed25519-signature-2020": "^4.0.1",
38
+ "@digitalbazaar/ed25519-signature-2020": "^5.2.0",
31
39
  "@digitalbazaar/ed25519-verification-key-2020": "^4.1.0",
32
- "@digitalbazaar/ezcap": "^3.0.1",
40
+ "@digitalbazaar/ezcap": "^4.0.0",
41
+ "@digitalbazaar/vc": "^6.0.1",
42
+ "assert-plus": "^1.0.0",
33
43
  "bnid": "^3.0.0",
34
44
  "body-parser": "^1.20.1",
35
45
  "cors": "^2.8.5",
36
46
  "jose": "^4.10.4",
37
- "jsonata": "^1.8.6",
47
+ "jsonata": "^2.0.3",
38
48
  "klona": "^2.0.5"
39
49
  },
40
50
  "peerDependencies": {
@@ -55,12 +65,12 @@
55
65
  "devDependencies": {
56
66
  "eslint": "^8.41.0",
57
67
  "eslint-config-digitalbazaar": "^5.0.1",
58
- "eslint-plugin-jsdoc": "^45.0.0",
68
+ "eslint-plugin-jsdoc": "^46.3.0",
59
69
  "eslint-plugin-unicorn": "^47.0.0",
60
70
  "jsdoc": "^4.0.2",
61
71
  "jsdoc-to-markdown": "^8.0.0"
62
72
  },
63
73
  "engines": {
64
- "node": ">=16"
74
+ "node": ">=18"
65
75
  }
66
76
  }
@@ -0,0 +1,286 @@
1
+ /*!
2
+ * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ import {schemas} from '@bedrock/validation';
5
+
6
+ const credentialDefinition = {
7
+ title: 'OID4VCI Verifiable Credential Definition',
8
+ type: 'object',
9
+ additionalProperties: false,
10
+ required: ['@context', 'type'],
11
+ properties: {
12
+ '@context': {
13
+ type: 'array',
14
+ minItems: 1,
15
+ item: {
16
+ type: 'string'
17
+ }
18
+ },
19
+ type: {
20
+ type: 'array',
21
+ minItems: 2,
22
+ item: {
23
+ type: 'string'
24
+ }
25
+ }
26
+ }
27
+ };
28
+
29
+ const openIdExchangeOptions = {
30
+ title: 'OpenID Exchange options',
31
+ type: 'object',
32
+ additionalProperties: false,
33
+ required: ['expectedCredentialRequests', 'preAuthorizedCode', 'oauth2'],
34
+ properties: {
35
+ expectedCredentialRequests: {
36
+ title: 'OpenID Expected Credential Requests',
37
+ type: 'array',
38
+ minItems: 1,
39
+ items: {
40
+ type: 'object',
41
+ additionalProperties: false,
42
+ required: ['credential_definition', 'format'],
43
+ properties: {
44
+ credential_definition: credentialDefinition,
45
+ format: {
46
+ type: 'string',
47
+ enum: ['ldp_vc']
48
+ }
49
+ }
50
+ }
51
+ },
52
+ preAuthorizedCode: {
53
+ type: 'string'
54
+ },
55
+ oauth2: {
56
+ title: 'OpenID Exchange OAuth2 Options',
57
+ type: 'object',
58
+ additionalProperties: false,
59
+ oneOf: [{
60
+ required: ['keyPair']
61
+ }, {
62
+ required: ['generateKeyPair']
63
+ }],
64
+ properties: {
65
+ generateKeyPair: {
66
+ type: 'object',
67
+ additionalProperties: false,
68
+ required: ['algorithm'],
69
+ properties: {
70
+ algorithm: {
71
+ enum: ['EdDSA', 'ES256', 'ES256K', 'ES384']
72
+ }
73
+ }
74
+ },
75
+ keyPair: {
76
+ type: 'object',
77
+ additionalProperties: false,
78
+ required: ['privateKeyJwk', 'publicKeyJwk'],
79
+ properties: {
80
+ privateKeyJwk: {
81
+ type: 'object'
82
+ },
83
+ publicKeyJwk: {
84
+ type: 'object'
85
+ }
86
+ }
87
+ },
88
+ maxClockSkew: {
89
+ type: 'number'
90
+ }
91
+ }
92
+ }
93
+ }
94
+ };
95
+
96
+ export const createExchangeBody = {
97
+ title: 'Create Exchange',
98
+ type: 'object',
99
+ additionalProperties: false,
100
+ properties: {
101
+ ttl: {
102
+ type: 'number'
103
+ },
104
+ variables: {
105
+ type: 'object',
106
+ additionalProperties: true
107
+ },
108
+ openId: openIdExchangeOptions
109
+ }
110
+ };
111
+
112
+ const credentialTemplate = {
113
+ title: 'Credential Template',
114
+ type: 'object',
115
+ required: ['type', 'template'],
116
+ additionalProperties: false,
117
+ properties: {
118
+ type: {
119
+ type: 'string',
120
+ enum: ['jsonata']
121
+ },
122
+ template: {
123
+ type: 'string'
124
+ }
125
+ }
126
+ };
127
+
128
+ export const credentialTemplates = {
129
+ title: 'Credential Templates',
130
+ type: 'array',
131
+ minItems: 1,
132
+ items: credentialTemplate
133
+ };
134
+
135
+ const step = {
136
+ title: 'Exchange Step',
137
+ type: 'object',
138
+ additionalProperties: false,
139
+ properties: {
140
+ createChallenge: {
141
+ type: 'boolean'
142
+ },
143
+ verifiablePresentationRequest: {
144
+ type: 'object'
145
+ },
146
+ jwtDidProofRequest: {
147
+ type: 'object',
148
+ additionalProperties: false,
149
+ properties: {
150
+ acceptedMethods: {
151
+ title: 'Accepted DID Methods',
152
+ type: 'array',
153
+ minItems: 1,
154
+ items: {
155
+ title: 'Accepted DID Method',
156
+ type: 'object',
157
+ additionalProperties: false,
158
+ properties: {
159
+ method: {
160
+ type: 'string'
161
+ }
162
+ }
163
+ }
164
+ },
165
+ allowedAlgorithms: {
166
+ title: 'Allowed JWT Algorithms',
167
+ type: 'array',
168
+ minItems: 1,
169
+ items: {
170
+ type: 'string'
171
+ }
172
+ }
173
+ }
174
+ },
175
+ // FIXME: add jsonata template to convert VPR or
176
+ // `jwtDidProofRequest` to more variables to be
177
+ // used when issuing VCs
178
+ // FIXME: `nextStep` feature not yet implemented
179
+ // nextStep: {
180
+ // type: 'string'
181
+ // }
182
+ }
183
+ };
184
+
185
+ export const steps = {
186
+ title: 'Exchange Steps',
187
+ type: 'object',
188
+ additionalProperties: false,
189
+ patternProperties: {
190
+ '^.*$': step
191
+ }
192
+ };
193
+
194
+ export const initialStep = {
195
+ title: 'Initial Exchange Step',
196
+ type: 'string'
197
+ };
198
+
199
+ export function useExchangeBody() {
200
+ return {
201
+ title: 'Use Exchange',
202
+ type: 'object',
203
+ additionalProperties: false,
204
+ properties: {
205
+ verifiablePresentation: schemas.verifiablePresentation()
206
+ }
207
+ };
208
+ }
209
+
210
+ const openIdCredentialRequest = {
211
+ title: 'OpenID Credential Request',
212
+ type: 'object',
213
+ additionalProperties: false,
214
+ required: ['credential_definition', 'format'],
215
+ properties: {
216
+ credential_definition: credentialDefinition,
217
+ format: {
218
+ type: 'string',
219
+ enum: ['ldp_vc']
220
+ },
221
+ did: {
222
+ type: 'string'
223
+ },
224
+ proof: {
225
+ title: 'DID Authn Proof JWT',
226
+ type: 'object',
227
+ additionalProperties: false,
228
+ required: ['proof_type', 'jwt'],
229
+ properties: {
230
+ proof_type: {
231
+ type: 'string',
232
+ enum: ['jwt']
233
+ },
234
+ jwt: {
235
+ type: 'string'
236
+ }
237
+ }
238
+ }
239
+ }
240
+ };
241
+
242
+ export const openIdCredentialBody = openIdCredentialRequest;
243
+
244
+ export const openIdBatchCredentialBody = {
245
+ title: 'OpenID Batch Credential Request',
246
+ type: 'object',
247
+ additionalProperties: false,
248
+ required: ['credential_requests'],
249
+ properties: {
250
+ credential_requests: {
251
+ title: 'OpenID Credential Requests',
252
+ type: 'array',
253
+ minItems: 1,
254
+ items: openIdCredentialRequest
255
+ }
256
+ }
257
+ };
258
+
259
+ export const openIdTokenBody = {
260
+ title: 'OpenID Token Request',
261
+ type: 'object',
262
+ additionalProperties: false,
263
+ required: ['grant_type'],
264
+ properties: {
265
+ grant_type: {
266
+ type: 'string'
267
+ },
268
+ 'pre-authorized_code': {
269
+ type: 'string'
270
+ },
271
+ // FIXME: there is no implementation for using these fields yet:
272
+ // user_pin: {
273
+ // type: 'string'
274
+ // },
275
+ // // params for `authorization_code` grant type
276
+ // code: {
277
+ // type: 'string'
278
+ // },
279
+ // verifier: {
280
+ // type: 'string'
281
+ // },
282
+ // redirect_uri: {
283
+ // type: 'string'
284
+ // }
285
+ }
286
+ };