@sphereon/ssi-sdk.ms-request-api 0.33.1-next.3 → 0.33.1-next.73
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 +323 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{ssi-sdk.ms-request-api.d.ts → index.d.cts} +86 -103
- package/dist/index.d.ts +82 -5
- package/dist/index.js +300 -24
- package/dist/index.js.map +1 -1
- package/package.json +25 -17
- package/plugin.schema.json +20 -52
- package/dist/IssuerUtil.d.ts +0 -4
- package/dist/IssuerUtil.d.ts.map +0 -1
- package/dist/IssuerUtil.js +0 -40
- package/dist/IssuerUtil.js.map +0 -1
- package/dist/agent/MsRequestApi.d.ts +0 -12
- package/dist/agent/MsRequestApi.d.ts.map +0 -1
- package/dist/agent/MsRequestApi.js +0 -80
- package/dist/agent/MsRequestApi.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/tsdoc-metadata.json +0 -11
- package/dist/types/IMsRequestApi.d.ts +0 -66
- package/dist/types/IMsRequestApi.d.ts.map +0 -1
- package/dist/types/IMsRequestApi.js +0 -3
- package/dist/types/IMsRequestApi.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
|
|
24
|
+
// plugin.schema.json
|
|
25
|
+
var require_plugin_schema = __commonJS({
|
|
26
|
+
"plugin.schema.json"(exports, module2) {
|
|
27
|
+
module2.exports = {
|
|
28
|
+
IMsRequestApi: {
|
|
29
|
+
components: {
|
|
30
|
+
schemas: {
|
|
31
|
+
IClientIssueRequest: {
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
authenticationInfo: {
|
|
35
|
+
$ref: "#/components/schemas/IMsAuthenticationClientCredentialArgs"
|
|
36
|
+
},
|
|
37
|
+
clientIssuanceConfig: {
|
|
38
|
+
$ref: "#/components/schemas/IClientIssuanceConfig"
|
|
39
|
+
},
|
|
40
|
+
claims: {
|
|
41
|
+
$ref: "#/components/schemas/CredentialSubject"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
required: ["authenticationInfo", "clientIssuanceConfig", "claims"],
|
|
45
|
+
additionalProperties: false
|
|
46
|
+
},
|
|
47
|
+
IMsAuthenticationClientCredentialArgs: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
azClientId: {
|
|
51
|
+
type: "string"
|
|
52
|
+
},
|
|
53
|
+
azTenantId: {
|
|
54
|
+
type: "string"
|
|
55
|
+
},
|
|
56
|
+
azClientSecret: {
|
|
57
|
+
type: "string"
|
|
58
|
+
},
|
|
59
|
+
credentialManifestUrl: {
|
|
60
|
+
type: "string"
|
|
61
|
+
},
|
|
62
|
+
authority: {
|
|
63
|
+
type: "string"
|
|
64
|
+
},
|
|
65
|
+
region: {
|
|
66
|
+
type: "string"
|
|
67
|
+
},
|
|
68
|
+
scopes: {
|
|
69
|
+
type: "array",
|
|
70
|
+
items: {
|
|
71
|
+
type: "string"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
skipCache: {
|
|
75
|
+
type: "boolean"
|
|
76
|
+
},
|
|
77
|
+
piiLoggingEnabled: {
|
|
78
|
+
type: "boolean"
|
|
79
|
+
},
|
|
80
|
+
logLevel: {
|
|
81
|
+
$ref: "#/components/schemas/LogLevel"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
required: ["azClientId", "azTenantId", "azClientSecret"],
|
|
85
|
+
additionalProperties: false,
|
|
86
|
+
description: "azClientId: clientId of the application you're trying to login azClientSecret: secret of the application you're trying to login azTenantId: your MS Azure tenantId credentialManifestUrl: url of your credential manifest. usually in following format: https://beta.eu.did.msidentity.com/v1.0/<tenant_id>/verifiableCredential/contracts/<verifiable_credential_schema> authority: optional. if not provided, we'll use the azClientId to create the Tenanted format if provided should be one of these two formats: - Tenanted: https://login.microsoftonline.com/{tenant}/, where {tenant} is either the GUID representing the tenant ID or a domain name associated with the tenant. - Work and school accounts: https://login.microsoftonline.com/organizations/. region?: if present will use the provided, if not will make a request to determine the region scopes?: scopes that you want to access via this authentication skipCache?: whether to skip cache piiLoggingEnabled?: if not provided defaults to false logLevel?: can be one of these values: Error = 0, Warning = 1, Info = 2, Verbose = 3, Trace = 4 if not provided defaults to LogLevel.Verbose"
|
|
87
|
+
},
|
|
88
|
+
LogLevel: {
|
|
89
|
+
type: "number",
|
|
90
|
+
enum: [0, 1, 2, 3, 4],
|
|
91
|
+
description: "Log message level."
|
|
92
|
+
},
|
|
93
|
+
IClientIssuanceConfig: {
|
|
94
|
+
type: "object",
|
|
95
|
+
properties: {
|
|
96
|
+
authority: {
|
|
97
|
+
type: "string"
|
|
98
|
+
},
|
|
99
|
+
includeQRCode: {
|
|
100
|
+
type: "boolean"
|
|
101
|
+
},
|
|
102
|
+
registration: {
|
|
103
|
+
$ref: "#/components/schemas/Registration"
|
|
104
|
+
},
|
|
105
|
+
callback: {
|
|
106
|
+
$ref: "#/components/schemas/Callback"
|
|
107
|
+
},
|
|
108
|
+
issuance: {
|
|
109
|
+
$ref: "#/components/schemas/IClientIssuance"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
required: ["authority", "includeQRCode", "registration", "callback", "issuance"],
|
|
113
|
+
additionalProperties: false
|
|
114
|
+
},
|
|
115
|
+
Registration: {
|
|
116
|
+
type: "object",
|
|
117
|
+
properties: {
|
|
118
|
+
clientName: {
|
|
119
|
+
type: "string"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
required: ["clientName"],
|
|
123
|
+
additionalProperties: false
|
|
124
|
+
},
|
|
125
|
+
Callback: {
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: {
|
|
128
|
+
url: {
|
|
129
|
+
type: "string"
|
|
130
|
+
},
|
|
131
|
+
state: {
|
|
132
|
+
type: "string"
|
|
133
|
+
},
|
|
134
|
+
headers: {
|
|
135
|
+
$ref: "#/components/schemas/Headers"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
required: ["url", "state", "headers"],
|
|
139
|
+
additionalProperties: false
|
|
140
|
+
},
|
|
141
|
+
Headers: {
|
|
142
|
+
type: "object",
|
|
143
|
+
properties: {
|
|
144
|
+
apiKey: {
|
|
145
|
+
type: "string"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
required: ["apiKey"],
|
|
149
|
+
additionalProperties: false
|
|
150
|
+
},
|
|
151
|
+
IClientIssuance: {
|
|
152
|
+
type: "object",
|
|
153
|
+
properties: {
|
|
154
|
+
type: {
|
|
155
|
+
type: "string"
|
|
156
|
+
},
|
|
157
|
+
manifest: {
|
|
158
|
+
type: "string"
|
|
159
|
+
},
|
|
160
|
+
pin: {
|
|
161
|
+
$ref: "#/components/schemas/Pin"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
required: ["type", "manifest", "pin"],
|
|
165
|
+
additionalProperties: false
|
|
166
|
+
},
|
|
167
|
+
Pin: {
|
|
168
|
+
type: "object",
|
|
169
|
+
properties: {
|
|
170
|
+
value: {
|
|
171
|
+
type: "string"
|
|
172
|
+
},
|
|
173
|
+
length: {
|
|
174
|
+
type: "number"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
required: ["value", "length"],
|
|
178
|
+
additionalProperties: false
|
|
179
|
+
},
|
|
180
|
+
CredentialSubject: {
|
|
181
|
+
type: "object"
|
|
182
|
+
},
|
|
183
|
+
IIssueRequestResponse: {
|
|
184
|
+
type: "object",
|
|
185
|
+
properties: {
|
|
186
|
+
id: {
|
|
187
|
+
type: "string"
|
|
188
|
+
},
|
|
189
|
+
requestId: {
|
|
190
|
+
type: "string"
|
|
191
|
+
},
|
|
192
|
+
url: {
|
|
193
|
+
type: "string"
|
|
194
|
+
},
|
|
195
|
+
expiry: {
|
|
196
|
+
type: "string",
|
|
197
|
+
format: "date-time"
|
|
198
|
+
},
|
|
199
|
+
pin: {
|
|
200
|
+
type: "string"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
required: ["id", "requestId", "url", "expiry", "pin"],
|
|
204
|
+
additionalProperties: false
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
methods: {
|
|
208
|
+
issuanceRequestMsVc: {
|
|
209
|
+
description: "",
|
|
210
|
+
arguments: {
|
|
211
|
+
$ref: "#/components/schemas/IClientIssueRequest"
|
|
212
|
+
},
|
|
213
|
+
returnType: {
|
|
214
|
+
$ref: "#/components/schemas/IIssueRequestResponse"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// src/index.ts
|
|
225
|
+
var index_exports = {};
|
|
226
|
+
__export(index_exports, {
|
|
227
|
+
MsRequestApi: () => MsRequestApi,
|
|
228
|
+
fetchIssuanceRequestMs: () => fetchIssuanceRequestMs,
|
|
229
|
+
generatePin: () => generatePin,
|
|
230
|
+
schema: () => schema
|
|
231
|
+
});
|
|
232
|
+
module.exports = __toCommonJS(index_exports);
|
|
233
|
+
|
|
234
|
+
// src/agent/MsRequestApi.ts
|
|
235
|
+
var import_ssi_sdk = require("@sphereon/ssi-sdk.ms-authenticator");
|
|
236
|
+
|
|
237
|
+
// src/IssuerUtil.ts
|
|
238
|
+
var import_cross_fetch = require("cross-fetch");
|
|
239
|
+
async function fetchIssuanceRequestMs(issuanceInfo, accessToken, msIdentityHostName) {
|
|
240
|
+
const requestEndpoint = `${msIdentityHostName}${issuanceInfo.authenticationInfo.azTenantId}/verifiablecredentials/request`;
|
|
241
|
+
const payload = JSON.stringify(issuanceInfo.issuanceConfig);
|
|
242
|
+
const fetchOptions = {
|
|
243
|
+
method: "POST",
|
|
244
|
+
body: payload,
|
|
245
|
+
headers: {
|
|
246
|
+
"Content-Type": "application/json",
|
|
247
|
+
"Content-Length": payload.length.toString(),
|
|
248
|
+
Authorization: `Bearer ${accessToken}`
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const response = await (0, import_cross_fetch.fetch)(requestEndpoint, fetchOptions);
|
|
252
|
+
return await response.json();
|
|
253
|
+
}
|
|
254
|
+
__name(fetchIssuanceRequestMs, "fetchIssuanceRequestMs");
|
|
255
|
+
function generatePin(digits) {
|
|
256
|
+
const add = 1;
|
|
257
|
+
let max = 12 - add;
|
|
258
|
+
max = Math.pow(10, digits + add);
|
|
259
|
+
const min = max / 10;
|
|
260
|
+
const number = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
261
|
+
return ("" + number).substring(add);
|
|
262
|
+
}
|
|
263
|
+
__name(generatePin, "generatePin");
|
|
264
|
+
|
|
265
|
+
// src/agent/MsRequestApi.ts
|
|
266
|
+
var MsRequestApi = class {
|
|
267
|
+
static {
|
|
268
|
+
__name(this, "MsRequestApi");
|
|
269
|
+
}
|
|
270
|
+
clients = /* @__PURE__ */ new Map();
|
|
271
|
+
methods = {
|
|
272
|
+
issuanceRequestMsVc: this.issuanceRequestMsVc.bind(this)
|
|
273
|
+
};
|
|
274
|
+
/** {@inheritDoc IMsRequestApi.issuanceRequestMsVc} */
|
|
275
|
+
async issuanceRequestMsVc(clientIssueRequest, context) {
|
|
276
|
+
const id = (0, import_ssi_sdk.determineMSAuthId)(clientIssueRequest.authenticationInfo);
|
|
277
|
+
if (!this.clients.has(id)) {
|
|
278
|
+
this.clients.set(id, await (0, import_ssi_sdk.newMSClientCredentialAuthenticator)(clientIssueRequest.authenticationInfo));
|
|
279
|
+
}
|
|
280
|
+
const clientInfo = this.clients.get(id);
|
|
281
|
+
if (!clientInfo) {
|
|
282
|
+
throw Error(`Could not get client from arguments for id: ${id}`);
|
|
283
|
+
}
|
|
284
|
+
const authResult = await (0, import_ssi_sdk.getMSClientCredentialAccessToken)(clientIssueRequest.authenticationInfo, {
|
|
285
|
+
confidentialClient: clientInfo.confidentialClient
|
|
286
|
+
});
|
|
287
|
+
const accessToken = authResult.accessToken;
|
|
288
|
+
const msIdentityHostName = await (0, import_ssi_sdk.assertEntraCredentialManifestUrlInCorrectRegion)(clientIssueRequest.authenticationInfo);
|
|
289
|
+
if (!clientIssueRequest.authenticationInfo.azTenantId) {
|
|
290
|
+
throw new Error("azTenantId is missing.");
|
|
291
|
+
}
|
|
292
|
+
if (clientIssueRequest.clientIssuanceConfig.issuance.pin) {
|
|
293
|
+
clientIssueRequest.clientIssuanceConfig.issuance.pin.value = generatePin(clientIssueRequest.clientIssuanceConfig.issuance.pin.length);
|
|
294
|
+
}
|
|
295
|
+
const issuance = {
|
|
296
|
+
type: clientIssueRequest.clientIssuanceConfig.issuance.type,
|
|
297
|
+
manifest: clientIssueRequest.clientIssuanceConfig.issuance.manifest,
|
|
298
|
+
pin: clientIssueRequest.clientIssuanceConfig.issuance.pin,
|
|
299
|
+
claims: clientIssueRequest.claims
|
|
300
|
+
};
|
|
301
|
+
const issuanceConfig = {
|
|
302
|
+
authority: clientIssueRequest.clientIssuanceConfig.authority,
|
|
303
|
+
includeQRCode: clientIssueRequest.clientIssuanceConfig.includeQRCode,
|
|
304
|
+
registration: clientIssueRequest.clientIssuanceConfig.registration,
|
|
305
|
+
callback: clientIssueRequest.clientIssuanceConfig.callback,
|
|
306
|
+
issuance
|
|
307
|
+
};
|
|
308
|
+
const issueRequest = {
|
|
309
|
+
authenticationInfo: clientIssueRequest.authenticationInfo,
|
|
310
|
+
issuanceConfig
|
|
311
|
+
};
|
|
312
|
+
const resp = await fetchIssuanceRequestMs(issueRequest, accessToken, msIdentityHostName);
|
|
313
|
+
resp.id = issueRequest.issuanceConfig.callback.state;
|
|
314
|
+
if (issueRequest.issuanceConfig.issuance.pin) {
|
|
315
|
+
resp.pin = issueRequest.issuanceConfig.issuance.pin.value;
|
|
316
|
+
}
|
|
317
|
+
return resp;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// src/index.ts
|
|
322
|
+
var schema = require_plugin_schema();
|
|
323
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../plugin.schema.json","../src/index.ts","../src/agent/MsRequestApi.ts","../src/IssuerUtil.ts"],"sourcesContent":["{\n \"IMsRequestApi\": {\n \"components\": {\n \"schemas\": {\n \"IClientIssueRequest\": {\n \"type\": \"object\",\n \"properties\": {\n \"authenticationInfo\": {\n \"$ref\": \"#/components/schemas/IMsAuthenticationClientCredentialArgs\"\n },\n \"clientIssuanceConfig\": {\n \"$ref\": \"#/components/schemas/IClientIssuanceConfig\"\n },\n \"claims\": {\n \"$ref\": \"#/components/schemas/CredentialSubject\"\n }\n },\n \"required\": [\"authenticationInfo\", \"clientIssuanceConfig\", \"claims\"],\n \"additionalProperties\": false\n },\n \"IMsAuthenticationClientCredentialArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"azClientId\": {\n \"type\": \"string\"\n },\n \"azTenantId\": {\n \"type\": \"string\"\n },\n \"azClientSecret\": {\n \"type\": \"string\"\n },\n \"credentialManifestUrl\": {\n \"type\": \"string\"\n },\n \"authority\": {\n \"type\": \"string\"\n },\n \"region\": {\n \"type\": \"string\"\n },\n \"scopes\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"skipCache\": {\n \"type\": \"boolean\"\n },\n \"piiLoggingEnabled\": {\n \"type\": \"boolean\"\n },\n \"logLevel\": {\n \"$ref\": \"#/components/schemas/LogLevel\"\n }\n },\n \"required\": [\"azClientId\", \"azTenantId\", \"azClientSecret\"],\n \"additionalProperties\": false,\n \"description\": \"azClientId: clientId of the application you're trying to login azClientSecret: secret of the application you're trying to login azTenantId: your MS Azure tenantId credentialManifestUrl: url of your credential manifest. usually in following format: https://beta.eu.did.msidentity.com/v1.0/<tenant_id>/verifiableCredential/contracts/<verifiable_credential_schema> authority: optional. if not provided, we'll use the azClientId to create the Tenanted format if provided should be one of these two formats: - Tenanted: https://login.microsoftonline.com/{tenant}/, where {tenant} is either the GUID representing the tenant ID or a domain name associated with the tenant. - Work and school accounts: https://login.microsoftonline.com/organizations/. region?: if present will use the provided, if not will make a request to determine the region scopes?: scopes that you want to access via this authentication skipCache?: whether to skip cache piiLoggingEnabled?: if not provided defaults to false logLevel?: can be one of these values: Error = 0, Warning = 1, Info = 2, Verbose = 3, Trace = 4 if not provided defaults to LogLevel.Verbose\"\n },\n \"LogLevel\": {\n \"type\": \"number\",\n \"enum\": [0, 1, 2, 3, 4],\n \"description\": \"Log message level.\"\n },\n \"IClientIssuanceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"authority\": {\n \"type\": \"string\"\n },\n \"includeQRCode\": {\n \"type\": \"boolean\"\n },\n \"registration\": {\n \"$ref\": \"#/components/schemas/Registration\"\n },\n \"callback\": {\n \"$ref\": \"#/components/schemas/Callback\"\n },\n \"issuance\": {\n \"$ref\": \"#/components/schemas/IClientIssuance\"\n }\n },\n \"required\": [\"authority\", \"includeQRCode\", \"registration\", \"callback\", \"issuance\"],\n \"additionalProperties\": false\n },\n \"Registration\": {\n \"type\": \"object\",\n \"properties\": {\n \"clientName\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"clientName\"],\n \"additionalProperties\": false\n },\n \"Callback\": {\n \"type\": \"object\",\n \"properties\": {\n \"url\": {\n \"type\": \"string\"\n },\n \"state\": {\n \"type\": \"string\"\n },\n \"headers\": {\n \"$ref\": \"#/components/schemas/Headers\"\n }\n },\n \"required\": [\"url\", \"state\", \"headers\"],\n \"additionalProperties\": false\n },\n \"Headers\": {\n \"type\": \"object\",\n \"properties\": {\n \"apiKey\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"apiKey\"],\n \"additionalProperties\": false\n },\n \"IClientIssuance\": {\n \"type\": \"object\",\n \"properties\": {\n \"type\": {\n \"type\": \"string\"\n },\n \"manifest\": {\n \"type\": \"string\"\n },\n \"pin\": {\n \"$ref\": \"#/components/schemas/Pin\"\n }\n },\n \"required\": [\"type\", \"manifest\", \"pin\"],\n \"additionalProperties\": false\n },\n \"Pin\": {\n \"type\": \"object\",\n \"properties\": {\n \"value\": {\n \"type\": \"string\"\n },\n \"length\": {\n \"type\": \"number\"\n }\n },\n \"required\": [\"value\", \"length\"],\n \"additionalProperties\": false\n },\n \"CredentialSubject\": {\n \"type\": \"object\"\n },\n \"IIssueRequestResponse\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"requestId\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"expiry\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"pin\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"id\", \"requestId\", \"url\", \"expiry\", \"pin\"],\n \"additionalProperties\": false\n }\n },\n \"methods\": {\n \"issuanceRequestMsVc\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IClientIssueRequest\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IIssueRequestResponse\"\n }\n }\n }\n }\n }\n}\n","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { MsRequestApi } from './agent/MsRequestApi'\nexport * from './types/IMsRequestApi'\nexport * from './IssuerUtil'\n","import {\n assertEntraCredentialManifestUrlInCorrectRegion,\n IMSClientCredentialAuthInfo,\n determineMSAuthId,\n getMSClientCredentialAccessToken,\n newMSClientCredentialAuthenticator,\n} from '@sphereon/ssi-sdk.ms-authenticator'\nimport { IAgentPlugin } from '@veramo/core'\nimport { fetchIssuanceRequestMs, generatePin } from '../IssuerUtil'\nimport {\n IClientIssueRequest,\n IIssueRequest,\n IIssueRequestResponse,\n IMsRequestApi,\n IRequiredContext,\n Issuance,\n IssuanceConfig,\n} from '../types/IMsRequestApi'\n\n/**\n * {@inheritDoc IMsRequestApi}\n */\nexport class MsRequestApi implements IAgentPlugin {\n private clients: Map<string, IMSClientCredentialAuthInfo> = new Map<string, IMSClientCredentialAuthInfo>()\n\n readonly methods: IMsRequestApi = {\n issuanceRequestMsVc: this.issuanceRequestMsVc.bind(this),\n }\n\n /** {@inheritDoc IMsRequestApi.issuanceRequestMsVc} */\n private async issuanceRequestMsVc(clientIssueRequest: IClientIssueRequest, context: IRequiredContext): Promise<IIssueRequestResponse> {\n const id = determineMSAuthId(clientIssueRequest.authenticationInfo)\n if (!this.clients.has(id)) {\n this.clients.set(id, await newMSClientCredentialAuthenticator(clientIssueRequest.authenticationInfo))\n }\n const clientInfo = this.clients.get(id)\n if (!clientInfo) {\n throw Error(`Could not get client from arguments for id: ${id}`)\n }\n const authResult = await getMSClientCredentialAccessToken(clientIssueRequest.authenticationInfo, {\n confidentialClient: clientInfo.confidentialClient,\n })\n const accessToken = authResult.accessToken\n\n const msIdentityHostName = await assertEntraCredentialManifestUrlInCorrectRegion(clientIssueRequest.authenticationInfo)\n\n // Config Request and App Config File should be a parameter to this function\n if (!clientIssueRequest.authenticationInfo.azTenantId) {\n throw new Error('azTenantId is missing.')\n }\n\n // check if pin is required, if found make sure we set a new random pin\n // pincode is only used when the payload contains claim value pairs which results in an IDTokenhint\n if (clientIssueRequest.clientIssuanceConfig.issuance.pin) {\n clientIssueRequest.clientIssuanceConfig.issuance.pin.value = generatePin(clientIssueRequest.clientIssuanceConfig.issuance.pin.length)\n }\n\n const issuance: Issuance = {\n type: clientIssueRequest.clientIssuanceConfig.issuance.type,\n manifest: clientIssueRequest.clientIssuanceConfig.issuance.manifest,\n pin: clientIssueRequest.clientIssuanceConfig.issuance.pin,\n claims: clientIssueRequest.claims,\n }\n\n const issuanceConfig: IssuanceConfig = {\n authority: clientIssueRequest.clientIssuanceConfig.authority,\n includeQRCode: clientIssueRequest.clientIssuanceConfig.includeQRCode,\n registration: clientIssueRequest.clientIssuanceConfig.registration,\n callback: clientIssueRequest.clientIssuanceConfig.callback,\n issuance: issuance,\n }\n const issueRequest: IIssueRequest = {\n authenticationInfo: clientIssueRequest.authenticationInfo,\n issuanceConfig: issuanceConfig,\n }\n\n const resp = await fetchIssuanceRequestMs(issueRequest, accessToken, msIdentityHostName)\n\n // the response from the VC Request API call is returned to the caller (the UI). It contains the URI to the request which Authenticator can download after\n // it has scanned the QR code. If the payload requested the VC Request service to create the QR code that is returned as well\n // the javascript in the UI will use that QR code to display it on the screen to the user.\n resp.id = issueRequest.issuanceConfig.callback.state // add session id so browser can pull status\n if (issueRequest.issuanceConfig.issuance.pin) {\n resp.pin = issueRequest.issuanceConfig.issuance.pin.value // add pin code so browser can display it\n }\n return resp\n }\n}\n","import { IIssueRequest, IIssueRequestResponse } from './types/IMsRequestApi'\n\nimport { fetch } from 'cross-fetch'\nexport async function fetchIssuanceRequestMs(\n issuanceInfo: IIssueRequest,\n accessToken: string,\n msIdentityHostName: string,\n): Promise<IIssueRequestResponse> {\n const requestEndpoint = `${msIdentityHostName}${issuanceInfo.authenticationInfo.azTenantId}/verifiablecredentials/request`\n\n const payload = JSON.stringify(issuanceInfo.issuanceConfig)\n const fetchOptions = {\n method: 'POST',\n body: payload,\n headers: {\n 'Content-Type': 'application/json',\n 'Content-Length': payload.length.toString(),\n Authorization: `Bearer ${accessToken}`,\n },\n }\n const response = await fetch(requestEndpoint, fetchOptions)\n return await response.json()\n}\n\nexport function generatePin(digits: number) {\n const add = 1\n let max = 12 - add\n max = Math.pow(10, digits + add)\n const min = max / 10 // Math.pow(10, n) basically\n const number = Math.floor(Math.random() * (max - min + 1)) + min\n return ('' + number).substring(add)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,gCAAAA,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,eAAiB;AAAA,QACf,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,qBAAuB;AAAA,cACrB,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,oBAAsB;AAAA,kBACpB,MAAQ;AAAA,gBACV;AAAA,gBACA,sBAAwB;AAAA,kBACtB,MAAQ;AAAA,gBACV;AAAA,gBACA,QAAU;AAAA,kBACR,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,UAAY,CAAC,sBAAsB,wBAAwB,QAAQ;AAAA,cACnE,sBAAwB;AAAA,YAC1B;AAAA,YACA,uCAAyC;AAAA,cACvC,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,YAAc;AAAA,kBACZ,MAAQ;AAAA,gBACV;AAAA,gBACA,YAAc;AAAA,kBACZ,MAAQ;AAAA,gBACV;AAAA,gBACA,gBAAkB;AAAA,kBAChB,MAAQ;AAAA,gBACV;AAAA,gBACA,uBAAyB;AAAA,kBACvB,MAAQ;AAAA,gBACV;AAAA,gBACA,WAAa;AAAA,kBACX,MAAQ;AAAA,gBACV;AAAA,gBACA,QAAU;AAAA,kBACR,MAAQ;AAAA,gBACV;AAAA,gBACA,QAAU;AAAA,kBACR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C,KAAK;AAC5Ca,WAAKb,MAAMY,aAAaL,eAAeR,SAASC,IAAIC;IACtD;AACA,WAAOY;EACT;AACF;;;ADpFA,IAAMG,SAASC;","names":["module","fetchIssuanceRequestMs","issuanceInfo","accessToken","msIdentityHostName","requestEndpoint","authenticationInfo","azTenantId","payload","JSON","stringify","issuanceConfig","fetchOptions","method","body","headers","length","toString","Authorization","response","fetch","json","generatePin","digits","add","max","Math","pow","min","number","floor","random","substring","MsRequestApi","clients","Map","methods","issuanceRequestMsVc","bind","clientIssueRequest","context","id","determineMSAuthId","authenticationInfo","has","set","newMSClientCredentialAuthenticator","clientInfo","get","Error","authResult","getMSClientCredentialAccessToken","confidentialClient","accessToken","msIdentityHostName","assertEntraCredentialManifestUrlInCorrectRegion","azTenantId","clientIssuanceConfig","issuance","pin","value","generatePin","length","type","manifest","claims","issuanceConfig","authority","includeQRCode","registration","callback","issueRequest","resp","fetchIssuanceRequestMs","state","schema","require"]}
|
|
@@ -1,103 +1,86 @@
|
|
|
1
|
-
import { IAgentContext } from '@veramo/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export declare interface Pin {
|
|
90
|
-
value: string;
|
|
91
|
-
length: number;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export declare interface Registration {
|
|
95
|
-
clientName: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @public
|
|
100
|
-
*/
|
|
101
|
-
export declare const schema: any;
|
|
102
|
-
|
|
103
|
-
export { }
|
|
1
|
+
import { IPluginMethodMap, IAgentContext, IAgentPlugin } from '@veramo/core';
|
|
2
|
+
import { IMsAuthenticationClientCredentialArgs } from '@sphereon/ssi-sdk.ms-authenticator';
|
|
3
|
+
|
|
4
|
+
interface IMsRequestApi extends IPluginMethodMap {
|
|
5
|
+
issuanceRequestMsVc(clientIssueRequest: IClientIssueRequest, context: IRequiredContext): Promise<IIssueRequestResponse>;
|
|
6
|
+
}
|
|
7
|
+
interface IClientIssueRequest {
|
|
8
|
+
authenticationInfo: IMsAuthenticationClientCredentialArgs;
|
|
9
|
+
clientIssuanceConfig: IClientIssuanceConfig;
|
|
10
|
+
claims: CredentialSubject;
|
|
11
|
+
}
|
|
12
|
+
interface IClientIssuanceConfig {
|
|
13
|
+
authority: string;
|
|
14
|
+
includeQRCode: boolean;
|
|
15
|
+
registration: Registration;
|
|
16
|
+
callback: Callback;
|
|
17
|
+
issuance: IClientIssuance;
|
|
18
|
+
}
|
|
19
|
+
interface IClientIssuance {
|
|
20
|
+
type: string;
|
|
21
|
+
manifest: string;
|
|
22
|
+
pin: Pin;
|
|
23
|
+
}
|
|
24
|
+
interface IIssueRequest {
|
|
25
|
+
authenticationInfo: IMsAuthenticationClientCredentialArgs;
|
|
26
|
+
issuanceConfig: IssuanceConfig;
|
|
27
|
+
}
|
|
28
|
+
interface IIssueRequestResponse {
|
|
29
|
+
id: string;
|
|
30
|
+
requestId: string;
|
|
31
|
+
url: string;
|
|
32
|
+
expiry: Date;
|
|
33
|
+
pin: string;
|
|
34
|
+
}
|
|
35
|
+
interface Registration {
|
|
36
|
+
clientName: string;
|
|
37
|
+
}
|
|
38
|
+
interface Headers {
|
|
39
|
+
apiKey: string;
|
|
40
|
+
}
|
|
41
|
+
interface Callback {
|
|
42
|
+
url: string;
|
|
43
|
+
state: string;
|
|
44
|
+
headers: Headers;
|
|
45
|
+
}
|
|
46
|
+
interface Pin {
|
|
47
|
+
value: string;
|
|
48
|
+
length: number;
|
|
49
|
+
}
|
|
50
|
+
type CredentialSubject = {
|
|
51
|
+
[x: string]: any;
|
|
52
|
+
};
|
|
53
|
+
interface Issuance {
|
|
54
|
+
type: string;
|
|
55
|
+
manifest: string;
|
|
56
|
+
pin: Pin;
|
|
57
|
+
claims: CredentialSubject;
|
|
58
|
+
}
|
|
59
|
+
interface IssuanceConfig {
|
|
60
|
+
authority: string;
|
|
61
|
+
includeQRCode: boolean;
|
|
62
|
+
registration: Registration;
|
|
63
|
+
callback: Callback;
|
|
64
|
+
issuance: Issuance;
|
|
65
|
+
}
|
|
66
|
+
type IRequiredContext = IAgentContext<Record<string, never>>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* {@inheritDoc IMsRequestApi}
|
|
70
|
+
*/
|
|
71
|
+
declare class MsRequestApi implements IAgentPlugin {
|
|
72
|
+
private clients;
|
|
73
|
+
readonly methods: IMsRequestApi;
|
|
74
|
+
/** {@inheritDoc IMsRequestApi.issuanceRequestMsVc} */
|
|
75
|
+
private issuanceRequestMsVc;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare function fetchIssuanceRequestMs(issuanceInfo: IIssueRequest, accessToken: string, msIdentityHostName: string): Promise<IIssueRequestResponse>;
|
|
79
|
+
declare function generatePin(digits: number): string;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
declare const schema: any;
|
|
85
|
+
|
|
86
|
+
export { type Callback, type CredentialSubject, type Headers, type IClientIssuance, type IClientIssuanceConfig, type IClientIssueRequest, type IIssueRequest, type IIssueRequestResponse, type IMsRequestApi, type IRequiredContext, type Issuance, type IssuanceConfig, MsRequestApi, type Pin, type Registration, fetchIssuanceRequestMs, generatePin, schema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,86 @@
|
|
|
1
|
+
import { IPluginMethodMap, IAgentContext, IAgentPlugin } from '@veramo/core';
|
|
2
|
+
import { IMsAuthenticationClientCredentialArgs } from '@sphereon/ssi-sdk.ms-authenticator';
|
|
3
|
+
|
|
4
|
+
interface IMsRequestApi extends IPluginMethodMap {
|
|
5
|
+
issuanceRequestMsVc(clientIssueRequest: IClientIssueRequest, context: IRequiredContext): Promise<IIssueRequestResponse>;
|
|
6
|
+
}
|
|
7
|
+
interface IClientIssueRequest {
|
|
8
|
+
authenticationInfo: IMsAuthenticationClientCredentialArgs;
|
|
9
|
+
clientIssuanceConfig: IClientIssuanceConfig;
|
|
10
|
+
claims: CredentialSubject;
|
|
11
|
+
}
|
|
12
|
+
interface IClientIssuanceConfig {
|
|
13
|
+
authority: string;
|
|
14
|
+
includeQRCode: boolean;
|
|
15
|
+
registration: Registration;
|
|
16
|
+
callback: Callback;
|
|
17
|
+
issuance: IClientIssuance;
|
|
18
|
+
}
|
|
19
|
+
interface IClientIssuance {
|
|
20
|
+
type: string;
|
|
21
|
+
manifest: string;
|
|
22
|
+
pin: Pin;
|
|
23
|
+
}
|
|
24
|
+
interface IIssueRequest {
|
|
25
|
+
authenticationInfo: IMsAuthenticationClientCredentialArgs;
|
|
26
|
+
issuanceConfig: IssuanceConfig;
|
|
27
|
+
}
|
|
28
|
+
interface IIssueRequestResponse {
|
|
29
|
+
id: string;
|
|
30
|
+
requestId: string;
|
|
31
|
+
url: string;
|
|
32
|
+
expiry: Date;
|
|
33
|
+
pin: string;
|
|
34
|
+
}
|
|
35
|
+
interface Registration {
|
|
36
|
+
clientName: string;
|
|
37
|
+
}
|
|
38
|
+
interface Headers {
|
|
39
|
+
apiKey: string;
|
|
40
|
+
}
|
|
41
|
+
interface Callback {
|
|
42
|
+
url: string;
|
|
43
|
+
state: string;
|
|
44
|
+
headers: Headers;
|
|
45
|
+
}
|
|
46
|
+
interface Pin {
|
|
47
|
+
value: string;
|
|
48
|
+
length: number;
|
|
49
|
+
}
|
|
50
|
+
type CredentialSubject = {
|
|
51
|
+
[x: string]: any;
|
|
52
|
+
};
|
|
53
|
+
interface Issuance {
|
|
54
|
+
type: string;
|
|
55
|
+
manifest: string;
|
|
56
|
+
pin: Pin;
|
|
57
|
+
claims: CredentialSubject;
|
|
58
|
+
}
|
|
59
|
+
interface IssuanceConfig {
|
|
60
|
+
authority: string;
|
|
61
|
+
includeQRCode: boolean;
|
|
62
|
+
registration: Registration;
|
|
63
|
+
callback: Callback;
|
|
64
|
+
issuance: Issuance;
|
|
65
|
+
}
|
|
66
|
+
type IRequiredContext = IAgentContext<Record<string, never>>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* {@inheritDoc IMsRequestApi}
|
|
70
|
+
*/
|
|
71
|
+
declare class MsRequestApi implements IAgentPlugin {
|
|
72
|
+
private clients;
|
|
73
|
+
readonly methods: IMsRequestApi;
|
|
74
|
+
/** {@inheritDoc IMsRequestApi.issuanceRequestMsVc} */
|
|
75
|
+
private issuanceRequestMsVc;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare function fetchIssuanceRequestMs(issuanceInfo: IIssueRequest, accessToken: string, msIdentityHostName: string): Promise<IIssueRequestResponse>;
|
|
79
|
+
declare function generatePin(digits: number): string;
|
|
80
|
+
|
|
1
81
|
/**
|
|
2
82
|
* @public
|
|
3
83
|
*/
|
|
4
84
|
declare const schema: any;
|
|
5
|
-
|
|
6
|
-
export { MsRequestApi
|
|
7
|
-
export * from './types/IMsRequestApi';
|
|
8
|
-
export * from './IssuerUtil';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
85
|
+
|
|
86
|
+
export { type Callback, type CredentialSubject, type Headers, type IClientIssuance, type IClientIssuanceConfig, type IClientIssueRequest, type IIssueRequest, type IIssueRequestResponse, type IMsRequestApi, type IRequiredContext, type Issuance, type IssuanceConfig, MsRequestApi, type Pin, type Registration, fetchIssuanceRequestMs, generatePin, schema };
|