@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-feat.SSISDK.35.64 → 0.34.1-feat.SSISDK.55.244
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/dist/index.cjs +461 -429
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +739 -69
- package/dist/index.d.ts +739 -69
- package/dist/index.js +455 -424
- package/dist/index.js.map +1 -1
- package/package.json +18 -18
- package/src/RPInstance.ts +11 -28
- package/src/agent/SIOPv2RP.ts +131 -72
- package/src/functions.ts +50 -52
- package/src/index.ts +1 -1
- package/src/types/ISIOPv2RP.ts +32 -62
package/dist/index.cjs
CHANGED
|
@@ -4,9 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
7
|
var __export = (target, all) => {
|
|
11
8
|
for (var name in all)
|
|
12
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -21,354 +18,352 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
21
18
|
};
|
|
22
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
20
|
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
SIOPv2RP: () => SIOPv2RP,
|
|
25
|
+
schema: () => plugin_schema_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
24
29
|
// plugin.schema.json
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
sessionId: {
|
|
35
|
-
type: "string"
|
|
36
|
-
},
|
|
37
|
-
additionalProperties: false
|
|
38
|
-
},
|
|
39
|
-
required: ["sessionId"],
|
|
40
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSessionForSiop } "
|
|
30
|
+
var plugin_schema_default = {
|
|
31
|
+
IDidAuthSiopOpAuthenticator: {
|
|
32
|
+
components: {
|
|
33
|
+
schemas: {
|
|
34
|
+
IGetSiopSessionArgs: {
|
|
35
|
+
type: "object",
|
|
36
|
+
properties: {
|
|
37
|
+
sessionId: {
|
|
38
|
+
type: "string"
|
|
41
39
|
},
|
|
42
|
-
|
|
40
|
+
additionalProperties: false
|
|
41
|
+
},
|
|
42
|
+
required: ["sessionId"],
|
|
43
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSessionForSiop } "
|
|
44
|
+
},
|
|
45
|
+
IRegisterSiopSessionArgs: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
identifier: {
|
|
43
49
|
type: "object",
|
|
44
50
|
properties: {
|
|
45
|
-
|
|
46
|
-
type: "object",
|
|
47
|
-
properties: {
|
|
48
|
-
did: {
|
|
49
|
-
type: "string"
|
|
50
|
-
},
|
|
51
|
-
alias: {
|
|
52
|
-
type: "string"
|
|
53
|
-
},
|
|
54
|
-
provider: {
|
|
55
|
-
type: "string"
|
|
56
|
-
},
|
|
57
|
-
controllerKeyId: {
|
|
58
|
-
type: "string"
|
|
59
|
-
},
|
|
60
|
-
keys: {
|
|
61
|
-
type: "array",
|
|
62
|
-
items: {
|
|
63
|
-
type: "object",
|
|
64
|
-
properties: {
|
|
65
|
-
additionalProperties: true
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
services: {
|
|
70
|
-
type: "array",
|
|
71
|
-
items: {
|
|
72
|
-
type: "object",
|
|
73
|
-
properties: {
|
|
74
|
-
additionalProperties: true
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
additionalProperties: false,
|
|
80
|
-
required: ["did", "provider", "keys", "services"]
|
|
81
|
-
},
|
|
82
|
-
sessionId: {
|
|
51
|
+
did: {
|
|
83
52
|
type: "string"
|
|
84
53
|
},
|
|
85
|
-
|
|
86
|
-
type: "number"
|
|
87
|
-
},
|
|
88
|
-
additionalProperties: false
|
|
89
|
-
},
|
|
90
|
-
required: ["identifier"],
|
|
91
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.registerSessionForSiop } "
|
|
92
|
-
},
|
|
93
|
-
IRemoveSiopSessionArgs: {
|
|
94
|
-
type: "object",
|
|
95
|
-
properties: {
|
|
96
|
-
sessionId: {
|
|
54
|
+
alias: {
|
|
97
55
|
type: "string"
|
|
98
56
|
},
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
required: ["sessionId"],
|
|
102
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.removeSessionForSiop } "
|
|
103
|
-
},
|
|
104
|
-
IAuthenticateWithSiopArgs: {
|
|
105
|
-
type: "object",
|
|
106
|
-
properties: {
|
|
107
|
-
sessionId: {
|
|
57
|
+
provider: {
|
|
108
58
|
type: "string"
|
|
109
59
|
},
|
|
110
|
-
|
|
60
|
+
controllerKeyId: {
|
|
111
61
|
type: "string"
|
|
112
62
|
},
|
|
113
|
-
|
|
114
|
-
type: "
|
|
63
|
+
keys: {
|
|
64
|
+
type: "array",
|
|
65
|
+
items: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
additionalProperties: true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
115
71
|
},
|
|
116
|
-
|
|
72
|
+
services: {
|
|
73
|
+
type: "array",
|
|
74
|
+
items: {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: {
|
|
77
|
+
additionalProperties: true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
117
81
|
},
|
|
118
|
-
|
|
119
|
-
|
|
82
|
+
additionalProperties: false,
|
|
83
|
+
required: ["did", "provider", "keys", "services"]
|
|
84
|
+
},
|
|
85
|
+
sessionId: {
|
|
86
|
+
type: "string"
|
|
87
|
+
},
|
|
88
|
+
expiresIn: {
|
|
89
|
+
type: "number"
|
|
90
|
+
},
|
|
91
|
+
additionalProperties: false
|
|
92
|
+
},
|
|
93
|
+
required: ["identifier"],
|
|
94
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.registerSessionForSiop } "
|
|
95
|
+
},
|
|
96
|
+
IRemoveSiopSessionArgs: {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: {
|
|
99
|
+
sessionId: {
|
|
100
|
+
type: "string"
|
|
101
|
+
},
|
|
102
|
+
additionalProperties: false
|
|
103
|
+
},
|
|
104
|
+
required: ["sessionId"],
|
|
105
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.removeSessionForSiop } "
|
|
106
|
+
},
|
|
107
|
+
IAuthenticateWithSiopArgs: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
sessionId: {
|
|
111
|
+
type: "string"
|
|
120
112
|
},
|
|
121
|
-
|
|
113
|
+
stateId: {
|
|
114
|
+
type: "string"
|
|
115
|
+
},
|
|
116
|
+
redirectUrl: {
|
|
117
|
+
type: "string"
|
|
118
|
+
},
|
|
119
|
+
additionalProperties: false
|
|
120
|
+
},
|
|
121
|
+
required: ["sessionId", "stateId", "redirectUrl"],
|
|
122
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.authenticateWithSiop } "
|
|
123
|
+
},
|
|
124
|
+
IResponse: {
|
|
125
|
+
type: "object",
|
|
126
|
+
properties: {
|
|
127
|
+
status: {
|
|
128
|
+
type: "number"
|
|
129
|
+
},
|
|
130
|
+
additionalProperties: true
|
|
131
|
+
},
|
|
132
|
+
required: ["status"],
|
|
133
|
+
description: "Result of {@link DidAuthSiopOpAuthenticator.authenticateWithSiop & DidAuthSiopOpAuthenticator.sendSiopAuthenticationResponse } "
|
|
134
|
+
},
|
|
135
|
+
IGetSiopAuthenticationRequestFromRpArgs: {
|
|
136
|
+
type: "object",
|
|
137
|
+
properties: {
|
|
138
|
+
sessionId: {
|
|
139
|
+
type: "string"
|
|
140
|
+
},
|
|
141
|
+
stateId: {
|
|
142
|
+
type: "string"
|
|
143
|
+
},
|
|
144
|
+
redirectUrl: {
|
|
145
|
+
type: "string"
|
|
146
|
+
},
|
|
147
|
+
additionalProperties: false
|
|
148
|
+
},
|
|
149
|
+
required: ["sessionId", "stateId", "redirectUrl"],
|
|
150
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestFromRP } "
|
|
151
|
+
},
|
|
152
|
+
ParsedAuthenticationRequestURI: {
|
|
153
|
+
type: "object",
|
|
154
|
+
properties: {
|
|
155
|
+
jwt: {
|
|
156
|
+
type: "string"
|
|
157
|
+
},
|
|
158
|
+
requestPayload: {
|
|
122
159
|
type: "object",
|
|
123
160
|
properties: {
|
|
124
|
-
status: {
|
|
125
|
-
type: "number"
|
|
126
|
-
},
|
|
127
161
|
additionalProperties: true
|
|
128
|
-
}
|
|
129
|
-
required: ["status"],
|
|
130
|
-
description: "Result of {@link DidAuthSiopOpAuthenticator.authenticateWithSiop & DidAuthSiopOpAuthenticator.sendSiopAuthenticationResponse } "
|
|
162
|
+
}
|
|
131
163
|
},
|
|
132
|
-
|
|
164
|
+
registration: {
|
|
133
165
|
type: "object",
|
|
134
166
|
properties: {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
stateId: {
|
|
139
|
-
type: "string"
|
|
140
|
-
},
|
|
141
|
-
redirectUrl: {
|
|
142
|
-
type: "string"
|
|
143
|
-
},
|
|
144
|
-
additionalProperties: false
|
|
145
|
-
},
|
|
146
|
-
required: ["sessionId", "stateId", "redirectUrl"],
|
|
147
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestFromRP } "
|
|
167
|
+
additionalProperties: true
|
|
168
|
+
}
|
|
148
169
|
},
|
|
149
|
-
|
|
170
|
+
additionalProperties: false
|
|
171
|
+
},
|
|
172
|
+
required: ["jwt", "requestPayload", "registration"],
|
|
173
|
+
description: "Result of {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestFromRP } "
|
|
174
|
+
},
|
|
175
|
+
IGetSiopAuthenticationRequestDetailsArgs: {
|
|
176
|
+
type: "object",
|
|
177
|
+
properties: {
|
|
178
|
+
sessionId: {
|
|
179
|
+
type: "string"
|
|
180
|
+
},
|
|
181
|
+
verifiedAuthenticationRequest: {
|
|
150
182
|
type: "object",
|
|
151
183
|
properties: {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
},
|
|
155
|
-
requestPayload: {
|
|
156
|
-
type: "object",
|
|
157
|
-
properties: {
|
|
158
|
-
additionalProperties: true
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
registration: {
|
|
162
|
-
type: "object",
|
|
163
|
-
properties: {
|
|
164
|
-
additionalProperties: true
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
additionalProperties: false
|
|
168
|
-
},
|
|
169
|
-
required: ["jwt", "requestPayload", "registration"],
|
|
170
|
-
description: "Result of {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestFromRP } "
|
|
184
|
+
additionalProperties: true
|
|
185
|
+
}
|
|
171
186
|
},
|
|
172
|
-
|
|
187
|
+
credentialFilter: {
|
|
173
188
|
type: "object",
|
|
174
189
|
properties: {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
additionalProperties: false
|
|
191
|
-
},
|
|
192
|
-
required: ["sessionId", "verifiedAuthenticationRequest"],
|
|
193
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestDetails } "
|
|
190
|
+
additionalProperties: true
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
additionalProperties: false
|
|
194
|
+
},
|
|
195
|
+
required: ["sessionId", "verifiedAuthenticationRequest"],
|
|
196
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestDetails } "
|
|
197
|
+
},
|
|
198
|
+
IAuthRequestDetails: {
|
|
199
|
+
type: "object",
|
|
200
|
+
properties: {
|
|
201
|
+
id: {
|
|
202
|
+
type: "string"
|
|
194
203
|
},
|
|
195
|
-
|
|
204
|
+
alsoKnownAs: {
|
|
205
|
+
type: "array",
|
|
206
|
+
items: {
|
|
207
|
+
type: "string"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
vpResponseOpts: {
|
|
196
211
|
type: "object",
|
|
197
212
|
properties: {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
additionalProperties: false
|
|
214
|
-
},
|
|
215
|
-
required: ["id", "vpResponseOpts"],
|
|
216
|
-
description: "Result of {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestDetails } "
|
|
213
|
+
additionalProperties: true
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
additionalProperties: false
|
|
217
|
+
},
|
|
218
|
+
required: ["id", "vpResponseOpts"],
|
|
219
|
+
description: "Result of {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestDetails } "
|
|
220
|
+
},
|
|
221
|
+
IVerifySiopAuthenticationRequestUriArgs: {
|
|
222
|
+
type: "object",
|
|
223
|
+
properties: {
|
|
224
|
+
sessionId: {
|
|
225
|
+
type: "string"
|
|
217
226
|
},
|
|
218
|
-
|
|
227
|
+
ParsedAuthenticationRequestURI: {
|
|
219
228
|
type: "object",
|
|
220
229
|
properties: {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
},
|
|
224
|
-
ParsedAuthenticationRequestURI: {
|
|
225
|
-
type: "object",
|
|
226
|
-
properties: {
|
|
227
|
-
additionalProperties: true
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
additionalProperties: false
|
|
231
|
-
},
|
|
232
|
-
required: ["sessionId", "ParsedAuthenticationRequestURI"],
|
|
233
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.verifySiopAuthenticationRequestURI } "
|
|
230
|
+
additionalProperties: true
|
|
231
|
+
}
|
|
234
232
|
},
|
|
235
|
-
|
|
233
|
+
additionalProperties: false
|
|
234
|
+
},
|
|
235
|
+
required: ["sessionId", "ParsedAuthenticationRequestURI"],
|
|
236
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.verifySiopAuthenticationRequestURI } "
|
|
237
|
+
},
|
|
238
|
+
VerifiedAuthorizationRequest: {
|
|
239
|
+
type: "object",
|
|
240
|
+
properties: {
|
|
241
|
+
payload: {
|
|
236
242
|
type: "object",
|
|
237
243
|
properties: {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
properties: {
|
|
241
|
-
additionalProperties: true
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
presentationDefinitions: {
|
|
245
|
-
type: "object",
|
|
246
|
-
properties: {
|
|
247
|
-
additionalProperties: true
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
verifyOpts: {
|
|
251
|
-
type: "object",
|
|
252
|
-
properties: {
|
|
253
|
-
additionalProperties: true
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
additionalProperties: false
|
|
257
|
-
},
|
|
258
|
-
required: ["payload", "verifyOpts"],
|
|
259
|
-
description: "Result of {@link DidAuthSiopOpAuthenticator.verifySiopAuthenticationRequestURI } "
|
|
244
|
+
additionalProperties: true
|
|
245
|
+
}
|
|
260
246
|
},
|
|
261
|
-
|
|
247
|
+
presentationDefinitions: {
|
|
262
248
|
type: "object",
|
|
263
249
|
properties: {
|
|
264
|
-
|
|
265
|
-
type: "string"
|
|
266
|
-
},
|
|
267
|
-
verifiedAuthenticationRequest: {
|
|
268
|
-
type: "object",
|
|
269
|
-
properties: {
|
|
270
|
-
additionalProperties: true
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
verifiablePresentationResponse: {
|
|
274
|
-
type: "object",
|
|
275
|
-
properties: {
|
|
276
|
-
additionalProperties: true
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
additionalProperties: false
|
|
280
|
-
},
|
|
281
|
-
required: ["sessionId", "verifiedAuthenticationRequest"],
|
|
282
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.sendSiopAuthenticationResponse } "
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
methods: {
|
|
286
|
-
getSessionForSiop: {
|
|
287
|
-
description: "Get SIOP session",
|
|
288
|
-
arguments: {
|
|
289
|
-
$ref: "#/components/schemas/IGetSiopSessionArgs"
|
|
290
|
-
},
|
|
291
|
-
returnType: "object"
|
|
292
|
-
},
|
|
293
|
-
registerSessionForSiop: {
|
|
294
|
-
description: "Register SIOP session",
|
|
295
|
-
arguments: {
|
|
296
|
-
$ref: "#/components/schemas/IRegisterSiopSessionArgs"
|
|
297
|
-
},
|
|
298
|
-
returnType: "object"
|
|
299
|
-
},
|
|
300
|
-
removeSessionForSiop: {
|
|
301
|
-
description: "Remove SIOP session",
|
|
302
|
-
arguments: {
|
|
303
|
-
$ref: "#/components/schemas/IRemoveSiopSessionArgs"
|
|
304
|
-
},
|
|
305
|
-
returnType: "boolean"
|
|
306
|
-
},
|
|
307
|
-
authenticateWithSiop: {
|
|
308
|
-
description: "Authenticate using DID Auth SIOP",
|
|
309
|
-
arguments: {
|
|
310
|
-
$ref: "#/components/schemas/IAuthenticateWithSiopArgs"
|
|
311
|
-
},
|
|
312
|
-
returnType: {
|
|
313
|
-
$ref: "#/components/schemas/Response"
|
|
250
|
+
additionalProperties: true
|
|
314
251
|
}
|
|
315
252
|
},
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
},
|
|
321
|
-
returnType: {
|
|
322
|
-
$ref: "#/components/schemas/ParsedAuthenticationRequestURI"
|
|
253
|
+
verifyOpts: {
|
|
254
|
+
type: "object",
|
|
255
|
+
properties: {
|
|
256
|
+
additionalProperties: true
|
|
323
257
|
}
|
|
324
258
|
},
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
259
|
+
additionalProperties: false
|
|
260
|
+
},
|
|
261
|
+
required: ["payload", "verifyOpts"],
|
|
262
|
+
description: "Result of {@link DidAuthSiopOpAuthenticator.verifySiopAuthenticationRequestURI } "
|
|
263
|
+
},
|
|
264
|
+
ISendSiopAuthenticationResponseArgs: {
|
|
265
|
+
type: "object",
|
|
266
|
+
properties: {
|
|
267
|
+
sessionId: {
|
|
268
|
+
type: "string"
|
|
333
269
|
},
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
},
|
|
339
|
-
returnType: {
|
|
340
|
-
$ref: "#/components/schemas/VerifiedAuthorizationRequest"
|
|
270
|
+
verifiedAuthenticationRequest: {
|
|
271
|
+
type: "object",
|
|
272
|
+
properties: {
|
|
273
|
+
additionalProperties: true
|
|
341
274
|
}
|
|
342
275
|
},
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
},
|
|
348
|
-
returnType: {
|
|
349
|
-
$ref: "#/components/schemas/IRequiredContext"
|
|
276
|
+
verifiablePresentationResponse: {
|
|
277
|
+
type: "object",
|
|
278
|
+
properties: {
|
|
279
|
+
additionalProperties: true
|
|
350
280
|
}
|
|
351
|
-
}
|
|
281
|
+
},
|
|
282
|
+
additionalProperties: false
|
|
283
|
+
},
|
|
284
|
+
required: ["sessionId", "verifiedAuthenticationRequest"],
|
|
285
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.sendSiopAuthenticationResponse } "
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
methods: {
|
|
289
|
+
getSessionForSiop: {
|
|
290
|
+
description: "Get SIOP session",
|
|
291
|
+
arguments: {
|
|
292
|
+
$ref: "#/components/schemas/IGetSiopSessionArgs"
|
|
293
|
+
},
|
|
294
|
+
returnType: "object"
|
|
295
|
+
},
|
|
296
|
+
registerSessionForSiop: {
|
|
297
|
+
description: "Register SIOP session",
|
|
298
|
+
arguments: {
|
|
299
|
+
$ref: "#/components/schemas/IRegisterSiopSessionArgs"
|
|
300
|
+
},
|
|
301
|
+
returnType: "object"
|
|
302
|
+
},
|
|
303
|
+
removeSessionForSiop: {
|
|
304
|
+
description: "Remove SIOP session",
|
|
305
|
+
arguments: {
|
|
306
|
+
$ref: "#/components/schemas/IRemoveSiopSessionArgs"
|
|
307
|
+
},
|
|
308
|
+
returnType: "boolean"
|
|
309
|
+
},
|
|
310
|
+
authenticateWithSiop: {
|
|
311
|
+
description: "Authenticate using DID Auth SIOP",
|
|
312
|
+
arguments: {
|
|
313
|
+
$ref: "#/components/schemas/IAuthenticateWithSiopArgs"
|
|
314
|
+
},
|
|
315
|
+
returnType: {
|
|
316
|
+
$ref: "#/components/schemas/Response"
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
getSiopAuthenticationRequestFromRP: {
|
|
320
|
+
description: "Get authentication request from RP",
|
|
321
|
+
arguments: {
|
|
322
|
+
$ref: "#/components/schemas/IGetSiopAuthenticationRequestFromRpArgs"
|
|
323
|
+
},
|
|
324
|
+
returnType: {
|
|
325
|
+
$ref: "#/components/schemas/ParsedAuthenticationRequestURI"
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
getSiopAuthenticationRequestDetails: {
|
|
329
|
+
description: "Get authentication request details",
|
|
330
|
+
arguments: {
|
|
331
|
+
$ref: "#/components/schemas/IGetSiopAuthenticationRequestDetailsArgs"
|
|
332
|
+
},
|
|
333
|
+
returnType: {
|
|
334
|
+
$ref: "#/components/schemas/IAuthRequestDetails"
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
verifySiopAuthenticationRequestURI: {
|
|
338
|
+
description: "Verify authentication request URI",
|
|
339
|
+
arguments: {
|
|
340
|
+
$ref: "#/components/schemas/IVerifySiopAuthenticationRequestUriArgs"
|
|
341
|
+
},
|
|
342
|
+
returnType: {
|
|
343
|
+
$ref: "#/components/schemas/VerifiedAuthorizationRequest"
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
sendSiopAuthenticationResponse: {
|
|
347
|
+
description: "Send authentication response",
|
|
348
|
+
arguments: {
|
|
349
|
+
$ref: "#/components/schemas/ISendSiopAuthenticationResponseArgs"
|
|
350
|
+
},
|
|
351
|
+
returnType: {
|
|
352
|
+
$ref: "#/components/schemas/IRequiredContext"
|
|
352
353
|
}
|
|
353
354
|
}
|
|
354
355
|
}
|
|
355
|
-
}
|
|
356
|
+
}
|
|
356
357
|
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// src/index.ts
|
|
360
|
-
var index_exports = {};
|
|
361
|
-
__export(index_exports, {
|
|
362
|
-
SIOPv2RP: () => SIOPv2RP,
|
|
363
|
-
VerifiedDataMode: () => VerifiedDataMode,
|
|
364
|
-
schema: () => schema
|
|
365
|
-
});
|
|
366
|
-
module.exports = __toCommonJS(index_exports);
|
|
358
|
+
};
|
|
367
359
|
|
|
368
360
|
// src/agent/SIOPv2RP.ts
|
|
369
361
|
var import_did_auth_siop2 = require("@sphereon/did-auth-siop");
|
|
370
362
|
var import_ssi_sdk_ext4 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
363
|
+
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.core");
|
|
364
|
+
var import_uuid2 = require("uuid");
|
|
371
365
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
366
|
+
var import_dcql = require("dcql");
|
|
372
367
|
|
|
373
368
|
// src/functions.ts
|
|
374
369
|
var import_did_auth_siop = require("@sphereon/did-auth-siop");
|
|
@@ -382,7 +377,7 @@ function getRequestVersion(rpOptions) {
|
|
|
382
377
|
if (Array.isArray(rpOptions.supportedVersions) && rpOptions.supportedVersions.length > 0) {
|
|
383
378
|
return rpOptions.supportedVersions[0];
|
|
384
379
|
}
|
|
385
|
-
return import_did_auth_siop.SupportedVersion.
|
|
380
|
+
return import_did_auth_siop.SupportedVersion.OID4VP_v1;
|
|
386
381
|
}
|
|
387
382
|
__name(getRequestVersion, "getRequestVersion");
|
|
388
383
|
function getWellKnownDIDVerifyCallback(siopIdentifierOpts, context) {
|
|
@@ -397,12 +392,38 @@ function getWellKnownDIDVerifyCallback(siopIdentifierOpts, context) {
|
|
|
397
392
|
};
|
|
398
393
|
}
|
|
399
394
|
__name(getWellKnownDIDVerifyCallback, "getWellKnownDIDVerifyCallback");
|
|
395
|
+
function getDcqlQueryLookupCallback(context) {
|
|
396
|
+
async function dcqlQueryLookup(queryId, version, tenantId) {
|
|
397
|
+
const result = await context.agent.pdmGetDefinitions({
|
|
398
|
+
filter: [
|
|
399
|
+
{
|
|
400
|
+
queryId,
|
|
401
|
+
...tenantId && {
|
|
402
|
+
tenantId
|
|
403
|
+
},
|
|
404
|
+
...version && {
|
|
405
|
+
version
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
id: queryId
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
});
|
|
413
|
+
if (result && result.length > 0) {
|
|
414
|
+
return result[0].query;
|
|
415
|
+
}
|
|
416
|
+
return Promise.reject(Error(`No dcql query found for queryId ${queryId}`));
|
|
417
|
+
}
|
|
418
|
+
__name(dcqlQueryLookup, "dcqlQueryLookup");
|
|
419
|
+
return dcqlQueryLookup;
|
|
420
|
+
}
|
|
421
|
+
__name(getDcqlQueryLookupCallback, "getDcqlQueryLookupCallback");
|
|
400
422
|
function getPresentationVerificationCallback(idOpts, context) {
|
|
401
423
|
async function presentationVerificationCallback(args, presentationSubmission) {
|
|
402
424
|
if (import_ssi_types.CredentialMapper.isSdJwtEncoded(args)) {
|
|
403
425
|
const result2 = await context.agent.verifySdJwtPresentation({
|
|
404
|
-
presentation: args
|
|
405
|
-
kb: true
|
|
426
|
+
presentation: args
|
|
406
427
|
});
|
|
407
428
|
return {
|
|
408
429
|
verified: !!result2.payload
|
|
@@ -437,28 +458,8 @@ function getPresentationVerificationCallback(idOpts, context) {
|
|
|
437
458
|
}
|
|
438
459
|
__name(getPresentationVerificationCallback, "getPresentationVerificationCallback");
|
|
439
460
|
async function createRPBuilder(args) {
|
|
440
|
-
const { rpOpts,
|
|
461
|
+
const { rpOpts, context } = args;
|
|
441
462
|
const { identifierOpts } = rpOpts;
|
|
442
|
-
let definition = args.definition;
|
|
443
|
-
let dcqlQuery = args.dcql;
|
|
444
|
-
if (!definition && pexOpts && pexOpts.definitionId) {
|
|
445
|
-
const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
|
|
446
|
-
filter: [
|
|
447
|
-
{
|
|
448
|
-
definitionId: pexOpts.definitionId,
|
|
449
|
-
version: pexOpts.version,
|
|
450
|
-
tenantId: pexOpts.tenantId
|
|
451
|
-
}
|
|
452
|
-
]
|
|
453
|
-
});
|
|
454
|
-
if (presentationDefinitionItems.length > 0) {
|
|
455
|
-
const presentationDefinitionItem = presentationDefinitionItems[0];
|
|
456
|
-
definition = presentationDefinitionItem.definitionPayload;
|
|
457
|
-
if (!dcqlQuery && presentationDefinitionItem.dcqlPayload) {
|
|
458
|
-
dcqlQuery = presentationDefinitionItem.dcqlPayload;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
463
|
const didMethods = identifierOpts.supportedDIDMethods ?? await (0, import_ssi_sdk_ext.getAgentDIDMethods)(context);
|
|
463
464
|
const eventEmitter = rpOpts.eventEmitter ?? new import_events.EventEmitter();
|
|
464
465
|
const defaultClientMetadata = {
|
|
@@ -513,34 +514,27 @@ async function createRPBuilder(args) {
|
|
|
513
514
|
const builder = import_did_auth_siop.RP.builder({
|
|
514
515
|
requestVersion: getRequestVersion(rpOpts)
|
|
515
516
|
}).withScope("openid", import_did_auth_siop.PropertyTarget.REQUEST_OBJECT).withResponseMode(rpOpts.responseMode ?? import_did_auth_siop.ResponseMode.POST).withResponseType(import_did_auth_siop.ResponseType.VP_TOKEN, import_did_auth_siop.PropertyTarget.REQUEST_OBJECT).withSupportedVersions(rpOpts.supportedVersions ?? [
|
|
516
|
-
import_did_auth_siop.SupportedVersion.
|
|
517
|
-
import_did_auth_siop.SupportedVersion.
|
|
518
|
-
import_did_auth_siop.SupportedVersion.SIOPv2_D11
|
|
517
|
+
import_did_auth_siop.SupportedVersion.OID4VP_v1,
|
|
518
|
+
import_did_auth_siop.SupportedVersion.SIOPv2_OID4VP_D28
|
|
519
519
|
]).withEventEmitter(eventEmitter).withSessionManager(rpOpts.sessionManager ?? new import_did_auth_siop.InMemoryRPSessionManager(eventEmitter)).withClientMetadata(rpOpts.clientMetadataOpts ?? defaultClientMetadata, import_did_auth_siop.PropertyTarget.REQUEST_OBJECT).withVerifyJwtCallback(rpOpts.verifyJwtCallback ? rpOpts.verifyJwtCallback : getVerifyJwtCallback({
|
|
520
520
|
resolver,
|
|
521
521
|
verifyOpts: {
|
|
522
522
|
wellknownDIDVerifyCallback: getWellKnownDIDVerifyCallback(rpOpts.identifierOpts, context),
|
|
523
523
|
checkLinkedDomain: "if_present"
|
|
524
524
|
}
|
|
525
|
-
}, context)).withRevocationVerification(import_did_auth_siop.RevocationVerification.NEVER).withPresentationVerification(getPresentationVerificationCallback(identifierOpts.idOpts, context));
|
|
525
|
+
}, context)).withDcqlQueryLookup(getDcqlQueryLookupCallback(context)).withRevocationVerification(import_did_auth_siop.RevocationVerification.NEVER).withPresentationVerification(getPresentationVerificationCallback(identifierOpts.idOpts, context));
|
|
526
526
|
const oidfOpts = identifierOpts.oidfOpts;
|
|
527
527
|
if (oidfOpts && (0, import_ssi_sdk_ext2.isExternalIdentifierOIDFEntityIdOpts)(oidfOpts)) {
|
|
528
|
-
builder.withEntityId(oidfOpts.identifier, import_did_auth_siop.PropertyTarget.REQUEST_OBJECT)
|
|
528
|
+
builder.withEntityId(oidfOpts.identifier, import_did_auth_siop.PropertyTarget.REQUEST_OBJECT);
|
|
529
529
|
} else {
|
|
530
530
|
const resolution = await context.agent.identifierManagedGet(identifierOpts.idOpts);
|
|
531
|
-
|
|
531
|
+
const clientId = rpOpts.clientMetadataOpts?.client_id ?? resolution.issuer ?? ((0, import_ssi_sdk_ext2.isManagedIdentifierDidResult)(resolution) ? resolution.did : resolution.jwkThumbprint);
|
|
532
|
+
const clientIdPrefixed = prefixClientId(clientId);
|
|
533
|
+
builder.withClientId(clientIdPrefixed, import_did_auth_siop.PropertyTarget.REQUEST_OBJECT);
|
|
532
534
|
}
|
|
533
535
|
if (hasher) {
|
|
534
536
|
builder.withHasher(hasher);
|
|
535
537
|
}
|
|
536
|
-
if (definition) {
|
|
537
|
-
builder.withPresentationDefinition({
|
|
538
|
-
definition
|
|
539
|
-
}, import_did_auth_siop.PropertyTarget.REQUEST_OBJECT);
|
|
540
|
-
}
|
|
541
|
-
if (dcqlQuery) {
|
|
542
|
-
builder.withDcqlQuery(dcqlQuery);
|
|
543
|
-
}
|
|
544
538
|
if (rpOpts.responseRedirectUri) {
|
|
545
539
|
builder.withResponseRedirectUri(rpOpts.responseRedirectUri);
|
|
546
540
|
}
|
|
@@ -597,6 +591,13 @@ function getSigningAlgo(type) {
|
|
|
597
591
|
}
|
|
598
592
|
}
|
|
599
593
|
__name(getSigningAlgo, "getSigningAlgo");
|
|
594
|
+
function prefixClientId(clientId) {
|
|
595
|
+
if (clientId.startsWith("did:")) {
|
|
596
|
+
return `${import_did_auth_siop.ClientIdentifierPrefix.DECENTRALIZED_IDENTIFIER}:${clientId}`;
|
|
597
|
+
}
|
|
598
|
+
return clientId;
|
|
599
|
+
}
|
|
600
|
+
__name(prefixClientId, "prefixClientId");
|
|
600
601
|
|
|
601
602
|
// src/RPInstance.ts
|
|
602
603
|
var import_uuid = require("uuid");
|
|
@@ -606,17 +607,16 @@ var RPInstance = class {
|
|
|
606
607
|
__name(this, "RPInstance");
|
|
607
608
|
}
|
|
608
609
|
_rp;
|
|
609
|
-
|
|
610
|
+
_presentationOptions;
|
|
610
611
|
_rpOptions;
|
|
611
612
|
constructor({ rpOpts, pexOpts }) {
|
|
612
613
|
this._rpOptions = rpOpts;
|
|
613
|
-
this.
|
|
614
|
+
this._presentationOptions = pexOpts;
|
|
614
615
|
}
|
|
615
616
|
async get(context) {
|
|
616
617
|
if (!this._rp) {
|
|
617
618
|
const builder = await createRPBuilder({
|
|
618
619
|
rpOpts: this._rpOptions,
|
|
619
|
-
pexOpts: this._pexOptions,
|
|
620
620
|
context
|
|
621
621
|
});
|
|
622
622
|
this._rp = builder.build();
|
|
@@ -626,23 +626,11 @@ var RPInstance = class {
|
|
|
626
626
|
get rpOptions() {
|
|
627
627
|
return this._rpOptions;
|
|
628
628
|
}
|
|
629
|
-
get
|
|
630
|
-
return this.
|
|
631
|
-
}
|
|
632
|
-
hasDefinition() {
|
|
633
|
-
return this.definitionId !== void 0;
|
|
634
|
-
}
|
|
635
|
-
get definitionId() {
|
|
636
|
-
return this.pexOptions?.definitionId;
|
|
637
|
-
}
|
|
638
|
-
async getPresentationDefinition(context) {
|
|
639
|
-
return this.definitionId ? await context.agent.pexStoreGetDefinition({
|
|
640
|
-
definitionId: this.definitionId,
|
|
641
|
-
tenantId: this.pexOptions?.tenantId
|
|
642
|
-
}) : void 0;
|
|
629
|
+
get presentationOptions() {
|
|
630
|
+
return this._presentationOptions;
|
|
643
631
|
}
|
|
644
632
|
async createAuthorizationRequestURI(createArgs, context) {
|
|
645
|
-
const { correlationId, claims, requestByReferenceURI, responseURI, responseURIType } = createArgs;
|
|
633
|
+
const { correlationId, queryId, claims, requestByReferenceURI, responseURI, responseURIType, callback } = createArgs;
|
|
646
634
|
const nonce = createArgs.nonce ?? (0, import_uuid.v4)();
|
|
647
635
|
const state = createArgs.state ?? correlationId;
|
|
648
636
|
let jwtIssuer;
|
|
@@ -670,13 +658,15 @@ var RPInstance = class {
|
|
|
670
658
|
return await this.get(context).then((rp) => rp.createAuthorizationRequestURI({
|
|
671
659
|
version: getRequestVersion(this.rpOptions),
|
|
672
660
|
correlationId,
|
|
661
|
+
queryId,
|
|
673
662
|
nonce,
|
|
674
663
|
state,
|
|
675
664
|
claims,
|
|
676
665
|
requestByReferenceURI,
|
|
677
666
|
responseURI,
|
|
678
667
|
responseURIType,
|
|
679
|
-
jwtIssuer
|
|
668
|
+
jwtIssuer,
|
|
669
|
+
callback
|
|
680
670
|
}));
|
|
681
671
|
}
|
|
682
672
|
async createAuthorizationRequest(createArgs, context) {
|
|
@@ -717,7 +707,6 @@ var RPInstance = class {
|
|
|
717
707
|
};
|
|
718
708
|
|
|
719
709
|
// src/agent/SIOPv2RP.ts
|
|
720
|
-
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.core");
|
|
721
710
|
var SIOPv2RP = class _SIOPv2RP {
|
|
722
711
|
static {
|
|
723
712
|
__name(this, "SIOPv2RP");
|
|
@@ -725,7 +714,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
725
714
|
opts;
|
|
726
715
|
static _DEFAULT_OPTS_KEY = "_default";
|
|
727
716
|
instances = /* @__PURE__ */ new Map();
|
|
728
|
-
schema =
|
|
717
|
+
schema = plugin_schema_default.IDidAuthSiopOpAuthenticator;
|
|
729
718
|
methods = {
|
|
730
719
|
siopCreateAuthRequestURI: this.createAuthorizationRequestURI.bind(this),
|
|
731
720
|
siopCreateAuthRequestPayloads: this.createAuthorizationRequestPayloads.bind(this),
|
|
@@ -755,53 +744,60 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
755
744
|
}
|
|
756
745
|
async createAuthorizationRequestURI(createArgs, context) {
|
|
757
746
|
return await this.getRPInstance({
|
|
758
|
-
|
|
759
|
-
responseRedirectURI: createArgs.responseRedirectURI
|
|
747
|
+
createWhenNotPresent: true,
|
|
748
|
+
responseRedirectURI: createArgs.responseRedirectURI,
|
|
749
|
+
...createArgs.useQueryIdInstance === true && {
|
|
750
|
+
queryId: createArgs.queryId
|
|
751
|
+
}
|
|
760
752
|
}, context).then((rp) => rp.createAuthorizationRequestURI(createArgs, context)).then((URI) => URI.encodedUri);
|
|
761
753
|
}
|
|
762
754
|
async createAuthorizationRequestPayloads(createArgs, context) {
|
|
763
755
|
return await this.getRPInstance({
|
|
764
|
-
|
|
756
|
+
createWhenNotPresent: true,
|
|
757
|
+
queryId: createArgs.queryId
|
|
765
758
|
}, context).then((rp) => rp.createAuthorizationRequest(createArgs, context)).then(async (request) => {
|
|
766
759
|
const authRequest = {
|
|
767
760
|
authorizationRequest: request.payload,
|
|
768
761
|
requestObject: await request.requestObjectJwt(),
|
|
769
|
-
requestObjectDecoded:
|
|
762
|
+
requestObjectDecoded: request.requestObject?.getPayload()
|
|
770
763
|
};
|
|
771
764
|
return authRequest;
|
|
772
765
|
});
|
|
773
766
|
}
|
|
774
767
|
async siopGetRequestState(args, context) {
|
|
775
768
|
return await this.getRPInstance({
|
|
776
|
-
|
|
769
|
+
createWhenNotPresent: false,
|
|
770
|
+
queryId: args.queryId
|
|
777
771
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.getRequestStateByCorrelationId(args.correlationId, args.errorOnNotFound)));
|
|
778
772
|
}
|
|
779
773
|
async siopGetResponseState(args, context) {
|
|
780
774
|
const rpInstance = await this.getRPInstance({
|
|
781
|
-
|
|
775
|
+
createWhenNotPresent: false,
|
|
776
|
+
queryId: args.queryId
|
|
782
777
|
}, context);
|
|
783
778
|
const authorizationResponseState = await rpInstance.get(context).then((rp) => rp.sessionManager.getResponseStateByCorrelationId(args.correlationId, args.errorOnNotFound));
|
|
784
779
|
if (authorizationResponseState === void 0) {
|
|
785
780
|
return void 0;
|
|
786
781
|
}
|
|
787
782
|
const responseState = authorizationResponseState;
|
|
788
|
-
if (responseState.status === import_did_auth_siop2.AuthorizationResponseStateStatus.VERIFIED
|
|
783
|
+
if (responseState.status === import_did_auth_siop2.AuthorizationResponseStateStatus.VERIFIED) {
|
|
789
784
|
let hasher;
|
|
790
785
|
if (import_ssi_types2.CredentialMapper.isSdJwtEncoded(responseState.response.payload.vp_token) && (!rpInstance.rpOptions.credentialOpts?.hasher || typeof rpInstance.rpOptions.credentialOpts?.hasher !== "function")) {
|
|
791
786
|
hasher = import_ssi_sdk2.shaHasher;
|
|
792
787
|
}
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
788
|
+
const vpToken = responseState.response.payload.vp_token && JSON.parse(responseState.response.payload.vp_token);
|
|
789
|
+
const claims = [];
|
|
790
|
+
for (const [key, value] of Object.entries(vpToken)) {
|
|
791
|
+
const presentationDecoded = import_ssi_types2.CredentialMapper.decodeVerifiablePresentation(
|
|
792
|
+
value,
|
|
793
|
+
//todo: later we want to conditionally pass in options for mdl-mdoc here
|
|
794
|
+
hasher
|
|
795
|
+
);
|
|
796
|
+
console.log(`presentationDecoded: ${JSON.stringify(presentationDecoded)}`);
|
|
797
|
+
const allClaims = {};
|
|
798
|
+
const presentationOrClaims = this.presentationOrClaimsFrom(presentationDecoded);
|
|
799
|
+
if ("verifiableCredential" in presentationOrClaims) {
|
|
800
|
+
for (const credential of presentationOrClaims.verifiableCredential) {
|
|
805
801
|
const vc = credential;
|
|
806
802
|
const schemaValidationResult = await context.agent.cvVerifySchema({
|
|
807
803
|
credential,
|
|
@@ -817,25 +813,48 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
817
813
|
if (!("id" in allClaims)) {
|
|
818
814
|
allClaims["id"] = credentialSubject.id;
|
|
819
815
|
}
|
|
820
|
-
Object.entries(credentialSubject).forEach(([
|
|
821
|
-
if (!(
|
|
822
|
-
allClaims[
|
|
816
|
+
Object.entries(credentialSubject).forEach(([key2, value2]) => {
|
|
817
|
+
if (!(key2 in allClaims)) {
|
|
818
|
+
allClaims[key2] = value2;
|
|
823
819
|
}
|
|
824
820
|
});
|
|
821
|
+
claims.push({
|
|
822
|
+
id: key,
|
|
823
|
+
type: vc.type[0],
|
|
824
|
+
claims: allClaims
|
|
825
|
+
});
|
|
825
826
|
}
|
|
826
|
-
|
|
827
|
-
|
|
827
|
+
} else {
|
|
828
|
+
claims.push({
|
|
829
|
+
id: key,
|
|
830
|
+
type: presentationDecoded.decodedPayload.vct,
|
|
831
|
+
claims: presentationOrClaims
|
|
832
|
+
});
|
|
833
|
+
}
|
|
828
834
|
}
|
|
835
|
+
responseState.verifiedData = {
|
|
836
|
+
...responseState.response.payload.vp_token && {
|
|
837
|
+
authorization_response: {
|
|
838
|
+
vp_token: typeof responseState.response.payload.vp_token === "string" ? JSON.parse(responseState.response.payload.vp_token) : responseState.response.payload.vp_token
|
|
839
|
+
}
|
|
840
|
+
},
|
|
841
|
+
...claims.length > 0 && {
|
|
842
|
+
credential_claims: claims
|
|
843
|
+
}
|
|
844
|
+
};
|
|
829
845
|
}
|
|
830
846
|
return responseState;
|
|
831
847
|
}
|
|
832
|
-
presentationOrClaimsFrom = /* @__PURE__ */ __name((presentationDecoded) =>
|
|
848
|
+
presentationOrClaimsFrom = /* @__PURE__ */ __name((presentationDecoded) => {
|
|
849
|
+
return import_ssi_types2.CredentialMapper.isSdJwtDecodedCredential(presentationDecoded) ? presentationDecoded.decodedPayload : import_ssi_types2.CredentialMapper.toUniformPresentation(presentationDecoded);
|
|
850
|
+
}, "presentationOrClaimsFrom");
|
|
833
851
|
async siopUpdateRequestState(args, context) {
|
|
834
|
-
if (args.state !== "
|
|
835
|
-
throw Error(`Only '
|
|
852
|
+
if (args.state !== "authorization_request_created") {
|
|
853
|
+
throw Error(`Only 'authorization_request_created' status is supported for this method at this point`);
|
|
836
854
|
}
|
|
837
855
|
return await this.getRPInstance({
|
|
838
|
-
|
|
856
|
+
createWhenNotPresent: false,
|
|
857
|
+
queryId: args.queryId
|
|
839
858
|
}, context).then((rp) => rp.get(context).then(async (rp2) => {
|
|
840
859
|
await rp2.signalAuthRequestRetrieved({
|
|
841
860
|
correlationId: args.correlationId,
|
|
@@ -846,7 +865,8 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
846
865
|
}
|
|
847
866
|
async siopDeleteState(args, context) {
|
|
848
867
|
return await this.getRPInstance({
|
|
849
|
-
|
|
868
|
+
createWhenNotPresent: false,
|
|
869
|
+
queryId: args.queryId
|
|
850
870
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.deleteStateForCorrelationId(args.correlationId))).then(() => true);
|
|
851
871
|
}
|
|
852
872
|
async siopVerifyAuthResponse(args, context) {
|
|
@@ -855,32 +875,27 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
855
875
|
}
|
|
856
876
|
const authResponse = typeof args.authorizationResponse === "string" ? (0, import_did_auth_siop2.decodeUriAsJson)(args.authorizationResponse) : args.authorizationResponse;
|
|
857
877
|
return await this.getRPInstance({
|
|
858
|
-
|
|
878
|
+
createWhenNotPresent: false,
|
|
879
|
+
queryId: args.queryId
|
|
859
880
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.verifyAuthorizationResponse(authResponse, {
|
|
860
881
|
correlationId: args.correlationId,
|
|
861
|
-
...args.
|
|
862
|
-
presentationDefinitions: args.presentationDefinitions
|
|
863
|
-
} : {},
|
|
864
|
-
...args.dcqlQuery ? {
|
|
882
|
+
...args.dcqlQuery && {
|
|
865
883
|
dcqlQuery: args.dcqlQuery
|
|
866
|
-
}
|
|
884
|
+
},
|
|
867
885
|
audience: args.audience
|
|
868
886
|
})));
|
|
869
887
|
}
|
|
870
888
|
async siopImportDefinitions(args, context) {
|
|
871
|
-
const {
|
|
872
|
-
await Promise.all(
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
definition: definitionPayload
|
|
876
|
-
});
|
|
877
|
-
console.log(`persisting definition ${definitionPayload.id} / ${definitionPayload.name} with versionControlMode ${versionControlMode}`);
|
|
889
|
+
const { importItems, tenantId, version, versionControlMode } = args;
|
|
890
|
+
await Promise.all(importItems.map(async (importItem) => {
|
|
891
|
+
import_dcql.DcqlQuery.validate(importItem.query);
|
|
892
|
+
console.log(`persisting DCQL definition ${importItem.queryId} with versionControlMode ${versionControlMode}`);
|
|
878
893
|
return context.agent.pdmPersistDefinition({
|
|
879
894
|
definitionItem: {
|
|
895
|
+
queryId: importItem.queryId,
|
|
880
896
|
tenantId,
|
|
881
897
|
version,
|
|
882
|
-
|
|
883
|
-
dcqlPayload: definitionPair.dcqlPayload
|
|
898
|
+
query: importItem.query
|
|
884
899
|
},
|
|
885
900
|
opts: {
|
|
886
901
|
versionControlMode
|
|
@@ -889,7 +904,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
889
904
|
}));
|
|
890
905
|
}
|
|
891
906
|
async siopGetRedirectURI(args, context) {
|
|
892
|
-
const instanceId = args.
|
|
907
|
+
const instanceId = args.queryId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
|
|
893
908
|
if (this.instances.has(instanceId)) {
|
|
894
909
|
const rpInstance = this.instances.get(instanceId);
|
|
895
910
|
if (rpInstance !== void 0) {
|
|
@@ -905,12 +920,40 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
905
920
|
}
|
|
906
921
|
return void 0;
|
|
907
922
|
}
|
|
908
|
-
async getRPInstance({
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
923
|
+
async getRPInstance({ createWhenNotPresent, queryId, responseRedirectURI }, context) {
|
|
924
|
+
let rpInstanceId = _SIOPv2RP._DEFAULT_OPTS_KEY;
|
|
925
|
+
let rpInstance;
|
|
926
|
+
if (queryId) {
|
|
927
|
+
if (this.instances.has(queryId)) {
|
|
928
|
+
rpInstanceId = queryId;
|
|
929
|
+
rpInstance = this.instances.get(rpInstanceId);
|
|
930
|
+
} else if ((0, import_uuid2.validate)(queryId)) {
|
|
931
|
+
try {
|
|
932
|
+
const pd = await context.agent.pdmGetDefinition({
|
|
933
|
+
itemId: queryId
|
|
934
|
+
});
|
|
935
|
+
if (this.instances.has(pd.queryId)) {
|
|
936
|
+
rpInstanceId = pd.queryId;
|
|
937
|
+
rpInstance = this.instances.get(rpInstanceId);
|
|
938
|
+
}
|
|
939
|
+
} catch (ignore) {
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
if (createWhenNotPresent) {
|
|
943
|
+
rpInstanceId = queryId;
|
|
944
|
+
} else {
|
|
945
|
+
rpInstance = this.instances.get(rpInstanceId);
|
|
946
|
+
}
|
|
947
|
+
} else {
|
|
948
|
+
rpInstance = this.instances.get(rpInstanceId);
|
|
949
|
+
}
|
|
950
|
+
if (!rpInstance) {
|
|
951
|
+
if (!createWhenNotPresent) {
|
|
952
|
+
return Promise.reject(`No RP instance found for key ${rpInstanceId}`);
|
|
953
|
+
}
|
|
954
|
+
const instanceOpts = this.getInstanceOpts(queryId);
|
|
912
955
|
const rpOpts = await this.getRPOptions(context, {
|
|
913
|
-
|
|
956
|
+
queryId,
|
|
914
957
|
responseRedirectURI
|
|
915
958
|
});
|
|
916
959
|
if (!rpOpts.identifierOpts.resolveOpts?.resolver || typeof rpOpts.identifierOpts.resolveOpts.resolver.resolve !== "function") {
|
|
@@ -922,29 +965,29 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
922
965
|
...rpOpts.identifierOpts.resolveOpts
|
|
923
966
|
};
|
|
924
967
|
}
|
|
925
|
-
console.log("Using agent DID resolver for RP instance with definition id " +
|
|
968
|
+
console.log("Using agent DID resolver for RP instance with definition id " + queryId);
|
|
926
969
|
rpOpts.identifierOpts.resolveOpts.resolver = (0, import_ssi_sdk_ext4.getAgentResolver)(context, {
|
|
927
970
|
uniresolverResolution: true,
|
|
928
971
|
localResolution: true,
|
|
929
972
|
resolverResolution: true
|
|
930
973
|
});
|
|
931
974
|
}
|
|
932
|
-
|
|
975
|
+
rpInstance = new RPInstance({
|
|
933
976
|
rpOpts,
|
|
934
977
|
pexOpts: instanceOpts
|
|
935
|
-
})
|
|
978
|
+
});
|
|
979
|
+
this.instances.set(rpInstanceId, rpInstance);
|
|
936
980
|
}
|
|
937
|
-
const rpInstance = this.instances.get(instanceId);
|
|
938
981
|
if (responseRedirectURI) {
|
|
939
982
|
rpInstance.rpOptions.responseRedirectUri = responseRedirectURI;
|
|
940
983
|
}
|
|
941
984
|
return rpInstance;
|
|
942
985
|
}
|
|
943
986
|
async getRPOptions(context, opts) {
|
|
944
|
-
const {
|
|
945
|
-
const options = this.getInstanceOpts(
|
|
987
|
+
const { queryId, responseRedirectURI } = opts;
|
|
988
|
+
const options = this.getInstanceOpts(queryId)?.rpOpts ?? this.opts.defaultOpts;
|
|
946
989
|
if (!options) {
|
|
947
|
-
throw Error(`Could not get specific nor default options for definition ${
|
|
990
|
+
throw Error(`Could not get specific nor default options for definition ${queryId}`);
|
|
948
991
|
}
|
|
949
992
|
if (this.opts.defaultOpts) {
|
|
950
993
|
if (!options.identifierOpts) {
|
|
@@ -976,35 +1019,24 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
976
1019
|
}
|
|
977
1020
|
return options;
|
|
978
1021
|
}
|
|
979
|
-
getInstanceOpts(
|
|
1022
|
+
getInstanceOpts(queryId) {
|
|
980
1023
|
if (!this.opts.instanceOpts) return void 0;
|
|
981
|
-
const instanceOpt =
|
|
982
|
-
return instanceOpt ?? this.getDefaultOptions(
|
|
1024
|
+
const instanceOpt = queryId ? this.opts.instanceOpts.find((i) => i.queryId === queryId) : void 0;
|
|
1025
|
+
return instanceOpt ?? this.getDefaultOptions(queryId);
|
|
983
1026
|
}
|
|
984
|
-
getDefaultOptions(
|
|
1027
|
+
getDefaultOptions(queryId) {
|
|
985
1028
|
if (!this.opts.instanceOpts) return void 0;
|
|
986
|
-
const defaultOptions = this.opts.instanceOpts.find((i) => i.
|
|
1029
|
+
const defaultOptions = this.opts.instanceOpts.find((i) => i.queryId === "default");
|
|
987
1030
|
if (defaultOptions) {
|
|
988
1031
|
const clonedOptions = {
|
|
989
1032
|
...defaultOptions
|
|
990
1033
|
};
|
|
991
|
-
if (
|
|
992
|
-
clonedOptions.
|
|
1034
|
+
if (queryId !== void 0) {
|
|
1035
|
+
clonedOptions.queryId = queryId;
|
|
993
1036
|
}
|
|
994
1037
|
return clonedOptions;
|
|
995
1038
|
}
|
|
996
1039
|
return void 0;
|
|
997
1040
|
}
|
|
998
1041
|
};
|
|
999
|
-
|
|
1000
|
-
// src/types/ISIOPv2RP.ts
|
|
1001
|
-
var VerifiedDataMode = /* @__PURE__ */ (function(VerifiedDataMode2) {
|
|
1002
|
-
VerifiedDataMode2["NONE"] = "none";
|
|
1003
|
-
VerifiedDataMode2["VERIFIED_PRESENTATION"] = "vp";
|
|
1004
|
-
VerifiedDataMode2["CREDENTIAL_SUBJECT_FLATTENED"] = "cs-flat";
|
|
1005
|
-
return VerifiedDataMode2;
|
|
1006
|
-
})({});
|
|
1007
|
-
|
|
1008
|
-
// src/index.ts
|
|
1009
|
-
var schema = require_plugin_schema();
|
|
1010
1042
|
//# sourceMappingURL=index.cjs.map
|