@sphereon/ssi-sdk.ms-request-api 0.33.0 → 0.33.1-feature.vcdm2.tsup.18
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 +362 -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 +332 -24
- package/dist/index.js.map +1 -1
- package/package.json +24 -17
- 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.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 };
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,335 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
5
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// plugin.schema.json
|
|
9
|
+
var require_plugin_schema = __commonJS({
|
|
10
|
+
"plugin.schema.json"(exports, module) {
|
|
11
|
+
module.exports = {
|
|
12
|
+
IMsRequestApi: {
|
|
13
|
+
components: {
|
|
14
|
+
schemas: {
|
|
15
|
+
IClientIssueRequest: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
authenticationInfo: {
|
|
19
|
+
$ref: "#/components/schemas/IMsAuthenticationClientCredentialArgs"
|
|
20
|
+
},
|
|
21
|
+
clientIssuanceConfig: {
|
|
22
|
+
$ref: "#/components/schemas/IClientIssuanceConfig"
|
|
23
|
+
},
|
|
24
|
+
claims: {
|
|
25
|
+
$ref: "#/components/schemas/CredentialSubject"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
required: [
|
|
29
|
+
"authenticationInfo",
|
|
30
|
+
"clientIssuanceConfig",
|
|
31
|
+
"claims"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
IMsAuthenticationClientCredentialArgs: {
|
|
35
|
+
type: "object",
|
|
36
|
+
properties: {
|
|
37
|
+
azClientId: {
|
|
38
|
+
type: "string"
|
|
39
|
+
},
|
|
40
|
+
azTenantId: {
|
|
41
|
+
type: "string"
|
|
42
|
+
},
|
|
43
|
+
azClientSecret: {
|
|
44
|
+
type: "string"
|
|
45
|
+
},
|
|
46
|
+
credentialManifestUrl: {
|
|
47
|
+
type: "string"
|
|
48
|
+
},
|
|
49
|
+
authority: {
|
|
50
|
+
type: "string"
|
|
51
|
+
},
|
|
52
|
+
region: {
|
|
53
|
+
type: "string"
|
|
54
|
+
},
|
|
55
|
+
scopes: {
|
|
56
|
+
type: "array",
|
|
57
|
+
items: {
|
|
58
|
+
type: "string"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
skipCache: {
|
|
62
|
+
type: "boolean"
|
|
63
|
+
},
|
|
64
|
+
piiLoggingEnabled: {
|
|
65
|
+
type: "boolean"
|
|
66
|
+
},
|
|
67
|
+
logLevel: {
|
|
68
|
+
$ref: "#/components/schemas/LogLevel"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
required: [
|
|
72
|
+
"azClientId",
|
|
73
|
+
"azTenantId",
|
|
74
|
+
"azClientSecret"
|
|
75
|
+
],
|
|
76
|
+
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"
|
|
77
|
+
},
|
|
78
|
+
LogLevel: {
|
|
79
|
+
type: "number",
|
|
80
|
+
enum: [
|
|
81
|
+
0,
|
|
82
|
+
1,
|
|
83
|
+
2,
|
|
84
|
+
3,
|
|
85
|
+
4
|
|
86
|
+
],
|
|
87
|
+
description: "Log message level."
|
|
88
|
+
},
|
|
89
|
+
IClientIssuanceConfig: {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {
|
|
92
|
+
authority: {
|
|
93
|
+
type: "string"
|
|
94
|
+
},
|
|
95
|
+
includeQRCode: {
|
|
96
|
+
type: "boolean"
|
|
97
|
+
},
|
|
98
|
+
registration: {
|
|
99
|
+
$ref: "#/components/schemas/Registration"
|
|
100
|
+
},
|
|
101
|
+
callback: {
|
|
102
|
+
$ref: "#/components/schemas/Callback"
|
|
103
|
+
},
|
|
104
|
+
issuance: {
|
|
105
|
+
$ref: "#/components/schemas/IClientIssuance"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
required: [
|
|
109
|
+
"authority",
|
|
110
|
+
"includeQRCode",
|
|
111
|
+
"registration",
|
|
112
|
+
"callback",
|
|
113
|
+
"issuance"
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
Registration: {
|
|
117
|
+
type: "object",
|
|
118
|
+
properties: {
|
|
119
|
+
clientName: {
|
|
120
|
+
type: "string"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
required: [
|
|
124
|
+
"clientName"
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
Callback: {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: {
|
|
130
|
+
url: {
|
|
131
|
+
type: "string"
|
|
132
|
+
},
|
|
133
|
+
state: {
|
|
134
|
+
type: "string"
|
|
135
|
+
},
|
|
136
|
+
headers: {
|
|
137
|
+
$ref: "#/components/schemas/Headers"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
required: [
|
|
141
|
+
"url",
|
|
142
|
+
"state",
|
|
143
|
+
"headers"
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
Headers: {
|
|
147
|
+
type: "object",
|
|
148
|
+
properties: {
|
|
149
|
+
apiKey: {
|
|
150
|
+
type: "string"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
required: [
|
|
154
|
+
"apiKey"
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
IClientIssuance: {
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
type: {
|
|
161
|
+
type: "string"
|
|
162
|
+
},
|
|
163
|
+
manifest: {
|
|
164
|
+
type: "string"
|
|
165
|
+
},
|
|
166
|
+
pin: {
|
|
167
|
+
$ref: "#/components/schemas/Pin"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
required: [
|
|
171
|
+
"type",
|
|
172
|
+
"manifest",
|
|
173
|
+
"pin"
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
Pin: {
|
|
177
|
+
type: "object",
|
|
178
|
+
properties: {
|
|
179
|
+
value: {
|
|
180
|
+
type: "string"
|
|
181
|
+
},
|
|
182
|
+
length: {
|
|
183
|
+
type: "number"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
required: [
|
|
187
|
+
"value",
|
|
188
|
+
"length"
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
CredentialSubject: {
|
|
192
|
+
type: "object"
|
|
193
|
+
},
|
|
194
|
+
IIssueRequestResponse: {
|
|
195
|
+
type: "object",
|
|
196
|
+
properties: {
|
|
197
|
+
id: {
|
|
198
|
+
type: "string"
|
|
199
|
+
},
|
|
200
|
+
requestId: {
|
|
201
|
+
type: "string"
|
|
202
|
+
},
|
|
203
|
+
url: {
|
|
204
|
+
type: "string"
|
|
205
|
+
},
|
|
206
|
+
expiry: {
|
|
207
|
+
type: "string",
|
|
208
|
+
format: "date-time"
|
|
209
|
+
},
|
|
210
|
+
pin: {
|
|
211
|
+
type: "string"
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
required: [
|
|
215
|
+
"id",
|
|
216
|
+
"requestId",
|
|
217
|
+
"url",
|
|
218
|
+
"expiry",
|
|
219
|
+
"pin"
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
methods: {
|
|
224
|
+
issuanceRequestMsVc: {
|
|
225
|
+
description: "",
|
|
226
|
+
arguments: {
|
|
227
|
+
$ref: "#/components/schemas/IClientIssueRequest"
|
|
228
|
+
},
|
|
229
|
+
returnType: {
|
|
230
|
+
$ref: "#/components/schemas/IIssueRequestResponse"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// src/agent/MsRequestApi.ts
|
|
241
|
+
import { assertEntraCredentialManifestUrlInCorrectRegion, determineMSAuthId, getMSClientCredentialAccessToken, newMSClientCredentialAuthenticator } from "@sphereon/ssi-sdk.ms-authenticator";
|
|
242
|
+
|
|
243
|
+
// src/IssuerUtil.ts
|
|
244
|
+
import { fetch } from "cross-fetch";
|
|
245
|
+
async function fetchIssuanceRequestMs(issuanceInfo, accessToken, msIdentityHostName) {
|
|
246
|
+
const requestEndpoint = `${msIdentityHostName}${issuanceInfo.authenticationInfo.azTenantId}/verifiablecredentials/request`;
|
|
247
|
+
const payload = JSON.stringify(issuanceInfo.issuanceConfig);
|
|
248
|
+
const fetchOptions = {
|
|
249
|
+
method: "POST",
|
|
250
|
+
body: payload,
|
|
251
|
+
headers: {
|
|
252
|
+
"Content-Type": "application/json",
|
|
253
|
+
"Content-Length": payload.length.toString(),
|
|
254
|
+
Authorization: `Bearer ${accessToken}`
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const response = await fetch(requestEndpoint, fetchOptions);
|
|
258
|
+
return await response.json();
|
|
259
|
+
}
|
|
260
|
+
__name(fetchIssuanceRequestMs, "fetchIssuanceRequestMs");
|
|
261
|
+
function generatePin(digits) {
|
|
262
|
+
const add = 1;
|
|
263
|
+
let max = 12 - add;
|
|
264
|
+
max = Math.pow(10, digits + add);
|
|
265
|
+
const min = max / 10;
|
|
266
|
+
const number = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
267
|
+
return ("" + number).substring(add);
|
|
268
|
+
}
|
|
269
|
+
__name(generatePin, "generatePin");
|
|
270
|
+
|
|
271
|
+
// src/agent/MsRequestApi.ts
|
|
272
|
+
var MsRequestApi = class {
|
|
273
|
+
static {
|
|
274
|
+
__name(this, "MsRequestApi");
|
|
275
|
+
}
|
|
276
|
+
clients = /* @__PURE__ */ new Map();
|
|
277
|
+
methods = {
|
|
278
|
+
issuanceRequestMsVc: this.issuanceRequestMsVc.bind(this)
|
|
279
|
+
};
|
|
280
|
+
/** {@inheritDoc IMsRequestApi.issuanceRequestMsVc} */
|
|
281
|
+
async issuanceRequestMsVc(clientIssueRequest, context) {
|
|
282
|
+
const id = determineMSAuthId(clientIssueRequest.authenticationInfo);
|
|
283
|
+
if (!this.clients.has(id)) {
|
|
284
|
+
this.clients.set(id, await newMSClientCredentialAuthenticator(clientIssueRequest.authenticationInfo));
|
|
285
|
+
}
|
|
286
|
+
const clientInfo = this.clients.get(id);
|
|
287
|
+
if (!clientInfo) {
|
|
288
|
+
throw Error(`Could not get client from arguments for id: ${id}`);
|
|
289
|
+
}
|
|
290
|
+
const authResult = await getMSClientCredentialAccessToken(clientIssueRequest.authenticationInfo, {
|
|
291
|
+
confidentialClient: clientInfo.confidentialClient
|
|
292
|
+
});
|
|
293
|
+
const accessToken = authResult.accessToken;
|
|
294
|
+
const msIdentityHostName = await assertEntraCredentialManifestUrlInCorrectRegion(clientIssueRequest.authenticationInfo);
|
|
295
|
+
if (!clientIssueRequest.authenticationInfo.azTenantId) {
|
|
296
|
+
throw new Error("azTenantId is missing.");
|
|
7
297
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
298
|
+
if (clientIssueRequest.clientIssuanceConfig.issuance.pin) {
|
|
299
|
+
clientIssueRequest.clientIssuanceConfig.issuance.pin.value = generatePin(clientIssueRequest.clientIssuanceConfig.issuance.pin.length);
|
|
300
|
+
}
|
|
301
|
+
const issuance = {
|
|
302
|
+
type: clientIssueRequest.clientIssuanceConfig.issuance.type,
|
|
303
|
+
manifest: clientIssueRequest.clientIssuanceConfig.issuance.manifest,
|
|
304
|
+
pin: clientIssueRequest.clientIssuanceConfig.issuance.pin,
|
|
305
|
+
claims: clientIssueRequest.claims
|
|
306
|
+
};
|
|
307
|
+
const issuanceConfig = {
|
|
308
|
+
authority: clientIssueRequest.clientIssuanceConfig.authority,
|
|
309
|
+
includeQRCode: clientIssueRequest.clientIssuanceConfig.includeQRCode,
|
|
310
|
+
registration: clientIssueRequest.clientIssuanceConfig.registration,
|
|
311
|
+
callback: clientIssueRequest.clientIssuanceConfig.callback,
|
|
312
|
+
issuance
|
|
313
|
+
};
|
|
314
|
+
const issueRequest = {
|
|
315
|
+
authenticationInfo: clientIssueRequest.authenticationInfo,
|
|
316
|
+
issuanceConfig
|
|
317
|
+
};
|
|
318
|
+
const resp = await fetchIssuanceRequestMs(issueRequest, accessToken, msIdentityHostName);
|
|
319
|
+
resp.id = issueRequest.issuanceConfig.callback.state;
|
|
320
|
+
if (issueRequest.issuanceConfig.issuance.pin) {
|
|
321
|
+
resp.pin = issueRequest.issuanceConfig.issuance.pin.value;
|
|
322
|
+
}
|
|
323
|
+
return resp;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// src/index.ts
|
|
328
|
+
var schema = require_plugin_schema();
|
|
329
|
+
export {
|
|
330
|
+
MsRequestApi,
|
|
331
|
+
fetchIssuanceRequestMs,
|
|
332
|
+
generatePin,
|
|
333
|
+
schema
|
|
15
334
|
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.MsRequestApi = exports.schema = void 0;
|
|
18
|
-
/**
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
const schema = require('../plugin.schema.json');
|
|
22
|
-
exports.schema = schema;
|
|
23
|
-
var MsRequestApi_1 = require("./agent/MsRequestApi");
|
|
24
|
-
Object.defineProperty(exports, "MsRequestApi", { enumerable: true, get: function () { return MsRequestApi_1.MsRequestApi; } });
|
|
25
|
-
__exportStar(require("./types/IMsRequestApi"), exports);
|
|
26
|
-
__exportStar(require("./IssuerUtil"), exports);
|
|
27
335
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AACtC,wBAAM;AACf,qDAAmD;AAA1C,4GAAA,YAAY,OAAA;AACrB,wDAAqC;AACrC,+CAA4B"}
|
|
1
|
+
{"version":3,"sources":["../plugin.schema.json","../src/agent/MsRequestApi.ts","../src/IssuerUtil.ts","../src/index.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\": [\n \"authenticationInfo\",\n \"clientIssuanceConfig\",\n \"claims\"\n ]\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\": [\n \"azClientId\",\n \"azTenantId\",\n \"azClientSecret\"\n ],\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\": [\n 0,\n 1,\n 2,\n 3,\n 4\n ],\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\": [\n \"authority\",\n \"includeQRCode\",\n \"registration\",\n \"callback\",\n \"issuance\"\n ]\n },\n \"Registration\": {\n \"type\": \"object\",\n \"properties\": {\n \"clientName\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"clientName\"\n ]\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\": [\n \"url\",\n \"state\",\n \"headers\"\n ]\n },\n \"Headers\": {\n \"type\": \"object\",\n \"properties\": {\n \"apiKey\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"apiKey\"\n ]\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\": [\n \"type\",\n \"manifest\",\n \"pin\"\n ]\n },\n \"Pin\": {\n \"type\": \"object\",\n \"properties\": {\n \"value\": {\n \"type\": \"string\"\n },\n \"length\": {\n \"type\": \"number\"\n }\n },\n \"required\": [\n \"value\",\n \"length\"\n ]\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\": [\n \"id\",\n \"requestId\",\n \"url\",\n \"expiry\",\n \"pin\"\n ]\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}","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","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { MsRequestApi } from './agent/MsRequestApi'\nexport * from './types/IMsRequestApi'\nexport * from './IssuerUtil'\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;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;AAAA,gBACV;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA,YACF;AAAA,YACA,uCAAyC;AAAA,cACvC,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,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C,WAAW5B,mBAAmBkB,qBAAqBU;MACnDC,eAAe7B,mBAAmBkB,qBAAqBW;MACvDC,cAAc9B,mBAAmBkB,qBAAqBY;MACtDC,UAAU/B,mBAAmBkB,qBAAqBa;MAClDZ;IACF;AACA,UAAMa,eAA8B;MAClC5B,oBAAoBJ,mBAAmBI;MACvCuB;IACF;AAEA,UAAMM,OAAO,MAAMC,uBAAuBF,cAAclB,aAAaC,kBAAAA;AAKrEkB,SAAK/B,KAAK8B,aAAaL,eAAeI,SAASI;AAC/C,QAAIH,aAAaL,eAAeR,SAASC,KAAK;AAC5Ca,WAAKb,MAAMY,aAAaL,eAAeR,SAASC,IAAIC;IACtD;AACA,WAAOY;EACT;AACF;;;AEpFA,IAAMG,SAASC;","names":["assertEntraCredentialManifestUrlInCorrectRegion","determineMSAuthId","getMSClientCredentialAccessToken","newMSClientCredentialAuthenticator","fetch","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"]}
|
package/package.json
CHANGED
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.ms-request-api",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
7
19
|
"veramo": {
|
|
8
20
|
"pluginInterfaces": {
|
|
9
21
|
"IMsRequestApi": "./src/types/IMsRequestApi.ts"
|
|
10
22
|
}
|
|
11
23
|
},
|
|
12
24
|
"scripts": {
|
|
13
|
-
"build": "
|
|
14
|
-
"build:clean": "tsc --build --clean && tsc --build",
|
|
25
|
+
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json",
|
|
15
26
|
"generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
|
|
16
27
|
},
|
|
17
28
|
"dependencies": {
|
|
18
|
-
"@sphereon/ssi-sdk.ms-authenticator": "0.33.
|
|
29
|
+
"@sphereon/ssi-sdk.ms-authenticator": "^0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
|
|
19
30
|
"@veramo/core": "4.2.0",
|
|
20
31
|
"cross-fetch": "^3.1.8"
|
|
21
32
|
},
|
|
22
33
|
"devDependencies": {
|
|
23
|
-
"@sphereon/ssi-sdk.agent-config": "0.33.
|
|
24
|
-
"@sphereon/ssi-sdk.credential-store": "0.33.
|
|
34
|
+
"@sphereon/ssi-sdk.agent-config": "^0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
|
|
35
|
+
"@sphereon/ssi-sdk.credential-store": "^0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
|
|
25
36
|
"@types/express": "^4.17.21",
|
|
26
37
|
"@types/express-session": "^1.18.0",
|
|
27
|
-
"@types/jest": "^27.5.2",
|
|
28
38
|
"@types/node": "^20.17.1",
|
|
29
39
|
"@types/uuid": "^9.0.8",
|
|
30
40
|
"@veramo/data-store": "4.2.0",
|
|
@@ -32,17 +42,15 @@
|
|
|
32
42
|
"@veramo/remote-server": "4.2.0",
|
|
33
43
|
"express": "^4.19.2",
|
|
34
44
|
"express-session": "^1.18.0",
|
|
35
|
-
"jest": "^27.5.1",
|
|
36
45
|
"prettier": "^2.8.8",
|
|
37
46
|
"sqlite3": "^5.1.7",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"typescript": "5.4.2",
|
|
47
|
+
"typeorm": "^0.3.22",
|
|
48
|
+
"typescript": "5.8.3",
|
|
41
49
|
"uuid": "^9.0.1"
|
|
42
50
|
},
|
|
43
51
|
"files": [
|
|
44
|
-
"dist
|
|
45
|
-
"src
|
|
52
|
+
"dist",
|
|
53
|
+
"src",
|
|
46
54
|
"README.md",
|
|
47
55
|
"plugin.schema.json",
|
|
48
56
|
"LICENSE"
|
|
@@ -65,6 +73,5 @@
|
|
|
65
73
|
"API",
|
|
66
74
|
"Issuer"
|
|
67
75
|
],
|
|
68
|
-
"
|
|
69
|
-
"gitHead": "c575bdd6642bda761881f0152e0a70ddc82d7f61"
|
|
76
|
+
"gitHead": "1fbb8be0256ec8dbc1b52d860b7bfd09d12f0d00"
|
|
70
77
|
}
|
package/dist/IssuerUtil.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { IIssueRequest, IIssueRequestResponse } from './types/IMsRequestApi';
|
|
2
|
-
export declare function fetchIssuanceRequestMs(issuanceInfo: IIssueRequest, accessToken: string, msIdentityHostName: string): Promise<IIssueRequestResponse>;
|
|
3
|
-
export declare function generatePin(digits: number): string;
|
|
4
|
-
//# sourceMappingURL=IssuerUtil.d.ts.map
|
package/dist/IssuerUtil.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IssuerUtil.d.ts","sourceRoot":"","sources":["../src/IssuerUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAG5E,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,qBAAqB,CAAC,CAehC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,UAOzC"}
|
package/dist/IssuerUtil.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.fetchIssuanceRequestMs = fetchIssuanceRequestMs;
|
|
13
|
-
exports.generatePin = generatePin;
|
|
14
|
-
const cross_fetch_1 = require("cross-fetch");
|
|
15
|
-
function fetchIssuanceRequestMs(issuanceInfo, accessToken, msIdentityHostName) {
|
|
16
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const requestEndpoint = `${msIdentityHostName}${issuanceInfo.authenticationInfo.azTenantId}/verifiablecredentials/request`;
|
|
18
|
-
const payload = JSON.stringify(issuanceInfo.issuanceConfig);
|
|
19
|
-
const fetchOptions = {
|
|
20
|
-
method: 'POST',
|
|
21
|
-
body: payload,
|
|
22
|
-
headers: {
|
|
23
|
-
'Content-Type': 'application/json',
|
|
24
|
-
'Content-Length': payload.length.toString(),
|
|
25
|
-
Authorization: `Bearer ${accessToken}`,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
const response = yield (0, cross_fetch_1.fetch)(requestEndpoint, fetchOptions);
|
|
29
|
-
return yield response.json();
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
function generatePin(digits) {
|
|
33
|
-
const add = 1;
|
|
34
|
-
let max = 12 - add;
|
|
35
|
-
max = Math.pow(10, digits + add);
|
|
36
|
-
const min = max / 10; // Math.pow(10, n) basically
|
|
37
|
-
const number = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
38
|
-
return ('' + number).substring(add);
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=IssuerUtil.js.map
|
package/dist/IssuerUtil.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IssuerUtil.js","sourceRoot":"","sources":["../src/IssuerUtil.ts"],"names":[],"mappings":";;;;;;;;;;;AAGA,wDAmBC;AAED,kCAOC;AA7BD,6CAAmC;AACnC,SAAsB,sBAAsB,CAC1C,YAA2B,EAC3B,WAAmB,EACnB,kBAA0B;;QAE1B,MAAM,eAAe,GAAG,GAAG,kBAAkB,GAAG,YAAY,CAAC,kBAAkB,CAAC,UAAU,gCAAgC,CAAA;QAE1H,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;QAC3D,MAAM,YAAY,GAAG;YACnB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,OAAO;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE;gBAC3C,aAAa,EAAE,UAAU,WAAW,EAAE;aACvC;SACF,CAAA;QACD,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAK,EAAC,eAAe,EAAE,YAAY,CAAC,CAAA;QAC3D,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAC9B,CAAC;CAAA;AAED,SAAgB,WAAW,CAAC,MAAc;IACxC,MAAM,GAAG,GAAG,CAAC,CAAA;IACb,IAAI,GAAG,GAAG,EAAE,GAAG,GAAG,CAAA;IAClB,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC,CAAA;IAChC,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAAA,CAAC,4BAA4B;IACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;IAChE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;AACrC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IAgentPlugin } from '@veramo/core';
|
|
2
|
-
import { IMsRequestApi } from '../types/IMsRequestApi';
|
|
3
|
-
/**
|
|
4
|
-
* {@inheritDoc IMsRequestApi}
|
|
5
|
-
*/
|
|
6
|
-
export declare class MsRequestApi implements IAgentPlugin {
|
|
7
|
-
private clients;
|
|
8
|
-
readonly methods: IMsRequestApi;
|
|
9
|
-
/** {@inheritDoc IMsRequestApi.issuanceRequestMsVc} */
|
|
10
|
-
private issuanceRequestMsVc;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=MsRequestApi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MsRequestApi.d.ts","sourceRoot":"","sources":["../../src/agent/MsRequestApi.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAIL,aAAa,EAId,MAAM,wBAAwB,CAAA;AAE/B;;GAEG;AACH,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,OAAO,CAA2F;IAE1G,QAAQ,CAAC,OAAO,EAAE,aAAa,CAE9B;IAED,sDAAsD;YACxC,mBAAmB;CAyDlC"}
|