@cef-ebsi/cli 0.0.0-alpha.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +22 -0
  2. package/dist/abi/pilot/DidRegistry.js +1082 -0
  3. package/dist/abi/pilot/DidRegistry.js.map +1 -0
  4. package/dist/abi/pilot/SchemaSCRegistry.js +973 -0
  5. package/dist/abi/pilot/SchemaSCRegistry.js.map +1 -0
  6. package/dist/abi/pilot/Tar.js +1395 -0
  7. package/dist/abi/pilot/Tar.js.map +1 -0
  8. package/dist/abi/pilot/Timestamp.js +1092 -0
  9. package/dist/abi/pilot/Timestamp.js.map +1 -0
  10. package/dist/abi/pilot/Tir.js +897 -0
  11. package/dist/abi/pilot/Tir.js.map +1 -0
  12. package/dist/abi/pilot/Tpr.js +1268 -0
  13. package/dist/abi/pilot/Tpr.js.map +1 -0
  14. package/dist/abi/test/DidRegistry.js +1082 -0
  15. package/dist/abi/test/DidRegistry.js.map +1 -0
  16. package/dist/abi/test/SchemaSCRegistry.js +973 -0
  17. package/dist/abi/test/SchemaSCRegistry.js.map +1 -0
  18. package/dist/abi/test/Tar.js +1395 -0
  19. package/dist/abi/test/Tar.js.map +1 -0
  20. package/dist/abi/test/Timestamp.js +1092 -0
  21. package/dist/abi/test/Timestamp.js.map +1 -0
  22. package/dist/abi/test/Tir.js +897 -0
  23. package/dist/abi/test/Tir.js.map +1 -0
  24. package/dist/abi/test/Tpr.js +1268 -0
  25. package/dist/abi/test/Tpr.js.map +1 -0
  26. package/dist/app.js +34 -714
  27. package/dist/app.js.map +1 -1
  28. package/dist/buildParam/did.js.map +1 -1
  29. package/dist/buildParam/index.js +0 -23
  30. package/dist/buildParam/index.js.map +1 -1
  31. package/dist/buildParam/tar.js.map +1 -1
  32. package/dist/buildParam/timestamp.js.map +1 -1
  33. package/dist/buildParam/tir.js.map +1 -1
  34. package/dist/buildParam/tpr.js.map +1 -1
  35. package/dist/buildParam/tsr.js +3 -3
  36. package/dist/buildParam/tsr.js.map +1 -1
  37. package/dist/commands/{authorisation-v4.js → authorisation-v2.js} +11 -91
  38. package/dist/commands/authorisation-v2.js.map +1 -0
  39. package/dist/commands/authorisation-v3.js.map +1 -1
  40. package/dist/commands/compute.js +13 -49
  41. package/dist/commands/compute.js.map +1 -1
  42. package/dist/commands/conformance-v3.js +3 -1
  43. package/dist/commands/conformance-v3.js.map +1 -1
  44. package/dist/commands/index.js +1 -3
  45. package/dist/commands/index.js.map +1 -1
  46. package/dist/commands/ledger-v3.js +1 -16
  47. package/dist/commands/ledger-v3.js.map +1 -1
  48. package/dist/commands/view.js +1 -1
  49. package/dist/commands/view.js.map +1 -1
  50. package/dist/config.js +14 -425
  51. package/dist/config.js.map +1 -1
  52. package/dist/interfaces/index.js +4 -9
  53. package/dist/interfaces/index.js.map +1 -1
  54. package/dist/interfaces/jsonrpc.interface.js.map +1 -0
  55. package/dist/interfaces/paginated-list.interface.js.map +1 -0
  56. package/dist/interfaces/unsigned-transaction.interface.js.map +1 -0
  57. package/dist/interfaces/utils.interface.js.map +1 -0
  58. package/dist/programs/appRegistration.js +4 -4
  59. package/dist/programs/appRegistration.js.map +1 -1
  60. package/dist/scripts/accreditAndAuthorize/conformance/step1 +35 -0
  61. package/dist/scripts/accreditAndAuthorize/conformance/step2 +18 -0
  62. package/dist/scripts/accreditAndAuthorize/conformance/step3 +9 -0
  63. package/dist/scripts/accreditAndAuthorize/conformance/step4 +27 -0
  64. package/dist/scripts/accreditAndAuthorize/conformance/step5 +13 -0
  65. package/dist/scripts/accreditAndAuthorize/conformance/step6 +14 -0
  66. package/dist/scripts/accreditAndAuthorize/conformance/step7 +7 -0
  67. package/dist/scripts/accreditAndAuthorize/test/step1 +35 -0
  68. package/dist/scripts/accreditAndAuthorize/test/step2 +18 -0
  69. package/dist/scripts/accreditAndAuthorize/test/step3 +9 -0
  70. package/dist/scripts/accreditAndAuthorize/test/step4 +27 -0
  71. package/dist/scripts/accreditAndAuthorize/test/step5 +13 -0
  72. package/dist/scripts/accreditAndAuthorize/test/step6 +14 -0
  73. package/dist/scripts/accreditAndAuthorize/test/step7 +7 -0
  74. package/dist/scripts/accreditTI +21 -0
  75. package/dist/scripts/assets/CTRevocableCredential.json +30 -0
  76. package/dist/scripts/assets/CredentialToAttestVerifiableAuthorisationForTrustChain.json +29 -0
  77. package/dist/scripts/assets/VerifiableAccreditationToAccredit.json +35 -0
  78. package/dist/scripts/assets/VerifiableAccreditationToAttest.json +33 -0
  79. package/dist/scripts/assets/VerifiableAuthorisationForTrustChain.json +22 -0
  80. package/dist/scripts/assets/VerifiableAuthorisationToOnboard.json +24 -0
  81. package/dist/scripts/bootstrap/0a-loadTPROperator +5 -0
  82. package/dist/scripts/bootstrap/0b-loadAdmin +6 -0
  83. package/dist/scripts/bootstrap/1-populateTPR +115 -0
  84. package/dist/scripts/bootstrap/2-populateDID +21 -0
  85. package/dist/scripts/bootstrap/3-populateTAR +72 -0
  86. package/dist/scripts/bootstrap/4-populateTimestamp +10 -0
  87. package/dist/scripts/bootstrap/5-populateTIR +9 -0
  88. package/dist/scripts/bootstrap/6-populateTSR +22 -0
  89. package/dist/scripts/bootstrap/7-setupConformanceIssuer +35 -0
  90. package/dist/scripts/initializeContracts +5 -0
  91. package/dist/scripts/issue_CTRevocableCredential +13 -0
  92. package/dist/scripts/issue_SelfAttestationSupportOffice +11 -0
  93. package/dist/scripts/issue_VerifiableAccreditationToAccredit +12 -0
  94. package/dist/scripts/issue_VerifiableAccreditationToAttest +12 -0
  95. package/dist/scripts/issue_VerifiableAuthorisationForTrustChain +11 -0
  96. package/dist/scripts/issue_VerifiableAuthorisationToOnboard +10 -0
  97. package/dist/scripts/registerDidDocument_ES256K_ES256 +13 -0
  98. package/dist/scripts/wctv3/accreditAndAuthorize +106 -0
  99. package/dist/scripts/wctv3/holderWallet +29 -0
  100. package/dist/scripts/wctv3/issueToHolder +27 -0
  101. package/dist/scripts/wctv3/pda1 +2 -0
  102. package/dist/scripts/wctv3/verifier +7 -0
  103. package/dist/tsconfig.tsbuildinfo +1 -1
  104. package/dist/utils/Client.js.map +1 -1
  105. package/dist/utils/http.js.map +1 -1
  106. package/dist/utils/index.js +0 -3
  107. package/dist/utils/index.js.map +1 -1
  108. package/dist/utils/print.js.map +1 -1
  109. package/dist/utils/utils.js +3 -7
  110. package/dist/utils/utils.js.map +1 -1
  111. package/dist/utils/verifiablePresentation.js.map +1 -1
  112. package/package.json +34 -49
  113. package/dist/abi/pilot/DidRegistry-old.json +0 -2192
  114. package/dist/abi/pilot/DidRegistry.json +0 -1081
  115. package/dist/abi/pilot/DidRegistryV3.json +0 -1081
  116. package/dist/abi/pilot/SchemaSCRegistry.json +0 -972
  117. package/dist/abi/pilot/SchemaSCRegistryV2.json +0 -473
  118. package/dist/abi/pilot/Tar.json +0 -1394
  119. package/dist/abi/pilot/TarV3.json +0 -1107
  120. package/dist/abi/pilot/Timestamp.json +0 -1091
  121. package/dist/abi/pilot/TimestampV2.json +0 -1127
  122. package/dist/abi/pilot/Tir.json +0 -896
  123. package/dist/abi/pilot/TirV3.json +0 -495
  124. package/dist/abi/pilot/Tpr.json +0 -1267
  125. package/dist/abi/pilot/TprV2.json +0 -888
  126. package/dist/abi/test/DidRegistry-old.json +0 -2192
  127. package/dist/abi/test/DidRegistry.json +0 -1081
  128. package/dist/abi/test/DidRegistryV3.json +0 -1088
  129. package/dist/abi/test/SchemaSCRegistry.json +0 -972
  130. package/dist/abi/test/SchemaSCRegistryV2.json +0 -473
  131. package/dist/abi/test/Tar.json +0 -1394
  132. package/dist/abi/test/TarV3.json +0 -1107
  133. package/dist/abi/test/Timestamp.json +0 -1091
  134. package/dist/abi/test/TimestampV2.json +0 -1127
  135. package/dist/abi/test/Tir.json +0 -896
  136. package/dist/abi/test/TirV3.json +0 -495
  137. package/dist/abi/test/Tpr.json +0 -1267
  138. package/dist/abi/test/TprV2.json +0 -888
  139. package/dist/buildParam/didOld.js +0 -275
  140. package/dist/buildParam/didOld.js.map +0 -1
  141. package/dist/buildParam/didV3.js +0 -353
  142. package/dist/buildParam/didV3.js.map +0 -1
  143. package/dist/buildParam/tarV3.js +0 -193
  144. package/dist/buildParam/tarV3.js.map +0 -1
  145. package/dist/buildParam/timestampV2.js +0 -317
  146. package/dist/buildParam/timestampV2.js.map +0 -1
  147. package/dist/buildParam/tirV3.js +0 -104
  148. package/dist/buildParam/tirV3.js.map +0 -1
  149. package/dist/buildParam/tprV2.js +0 -82
  150. package/dist/buildParam/tprV2.js.map +0 -1
  151. package/dist/buildParam/tsrV2.js +0 -110
  152. package/dist/buildParam/tsrV2.js.map +0 -1
  153. package/dist/commands/authorisation-v4.js.map +0 -1
  154. package/dist/commands/conformance-v4.js +0 -767
  155. package/dist/commands/conformance-v4.js.map +0 -1
  156. package/dist/commands/ledger-v4.js +0 -188
  157. package/dist/commands/ledger-v4.js.map +0 -1
  158. package/dist/interfaces/authorisation/authorisation.interface.js +0 -2
  159. package/dist/interfaces/authorisation/authorisation.interface.js.map +0 -1
  160. package/dist/interfaces/authorisation/index.js +0 -2
  161. package/dist/interfaces/authorisation/index.js.map +0 -1
  162. package/dist/interfaces/ledger/besu.interface.js +0 -2
  163. package/dist/interfaces/ledger/besu.interface.js.map +0 -1
  164. package/dist/interfaces/ledger/index.js +0 -2
  165. package/dist/interfaces/ledger/index.js.map +0 -1
  166. package/dist/interfaces/notifications/index.js +0 -2
  167. package/dist/interfaces/notifications/index.js.map +0 -1
  168. package/dist/interfaces/notifications/notifications.interface.js +0 -2
  169. package/dist/interfaces/notifications/notifications.interface.js.map +0 -1
  170. package/dist/interfaces/proxy-data-hub/attributes.interface.js +0 -2
  171. package/dist/interfaces/proxy-data-hub/attributes.interface.js.map +0 -1
  172. package/dist/interfaces/proxy-data-hub/index.js +0 -2
  173. package/dist/interfaces/proxy-data-hub/index.js.map +0 -1
  174. package/dist/interfaces/shared/index.js +0 -5
  175. package/dist/interfaces/shared/index.js.map +0 -1
  176. package/dist/interfaces/shared/jsonrpc.interface.js.map +0 -1
  177. package/dist/interfaces/shared/paginated-list.interface.js.map +0 -1
  178. package/dist/interfaces/shared/unsigned-transaction.interface.js.map +0 -1
  179. package/dist/interfaces/shared/utils.interface.js.map +0 -1
  180. package/dist/interfaces/timestamp/hash-algorithms.interface.js +0 -2
  181. package/dist/interfaces/timestamp/hash-algorithms.interface.js.map +0 -1
  182. package/dist/interfaces/timestamp/index.js +0 -4
  183. package/dist/interfaces/timestamp/index.js.map +0 -1
  184. package/dist/interfaces/timestamp/records.interface.js +0 -2
  185. package/dist/interfaces/timestamp/records.interface.js.map +0 -1
  186. package/dist/interfaces/timestamp/timestamps.interface.js +0 -2
  187. package/dist/interfaces/timestamp/timestamps.interface.js.map +0 -1
  188. package/dist/interfaces/trusted-apps-registry/apps.interface.js +0 -2
  189. package/dist/interfaces/trusted-apps-registry/apps.interface.js.map +0 -1
  190. package/dist/interfaces/trusted-apps-registry/index.js +0 -3
  191. package/dist/interfaces/trusted-apps-registry/index.js.map +0 -1
  192. package/dist/interfaces/trusted-apps-registry/policies.interface.js +0 -2
  193. package/dist/interfaces/trusted-apps-registry/policies.interface.js.map +0 -1
  194. package/dist/interfaces/trusted-issuers-registry/index.js +0 -2
  195. package/dist/interfaces/trusted-issuers-registry/index.js.map +0 -1
  196. package/dist/interfaces/trusted-issuers-registry/issuers.interface.js +0 -2
  197. package/dist/interfaces/trusted-issuers-registry/issuers.interface.js.map +0 -1
  198. package/dist/interfaces/users-onboarding/authentication.js +0 -2
  199. package/dist/interfaces/users-onboarding/authentication.js.map +0 -1
  200. package/dist/interfaces/users-onboarding/index.js +0 -2
  201. package/dist/interfaces/users-onboarding/index.js.map +0 -1
  202. package/dist/utils/authorisation.js +0 -118
  203. package/dist/utils/authorisation.js.map +0 -1
  204. package/dist/utils/notification.js +0 -51
  205. package/dist/utils/notification.js.map +0 -1
  206. package/dist/utils/storage.js +0 -97
  207. package/dist/utils/storage.js.map +0 -1
  208. /package/dist/interfaces/{shared/jsonrpc.interface.js → jsonrpc.interface.js} +0 -0
  209. /package/dist/interfaces/{shared/paginated-list.interface.js → paginated-list.interface.js} +0 -0
  210. /package/dist/interfaces/{shared/unsigned-transaction.interface.js → unsigned-transaction.interface.js} +0 -0
  211. /package/dist/interfaces/{shared/utils.interface.js → utils.interface.js} +0 -0
package/dist/app.js CHANGED
@@ -1,26 +1,18 @@
1
1
  /* eslint-disable no-use-before-define, @typescript-eslint/no-use-before-define */
2
- import { randomBytes, randomUUID } from "node:crypto";
3
- import { URL, URLSearchParams } from "node:url";
4
2
  import { ethers } from "ethers";
5
- import chalk from "chalk";
6
- import qs from "qs";
7
3
  import { EbsiWallet } from "@cef-ebsi/wallet-lib";
8
4
  import lodashSet from "lodash.set";
9
- import { calculateJwkThumbprint, importJWK, SignJWT, base64url, } from "jose";
10
- import fs, { createWriteStream } from "fs";
5
+ import { calculateJwkThumbprint } from "jose";
6
+ import fs from "fs";
11
7
  import Joi from "joi";
12
- import { Agent as SiopAgent } from "@cef-ebsi/siop-auth";
13
8
  import readline from "readline";
14
9
  import { loadConfig } from "./config.js";
15
10
  import * as utils from "./utils/index.js";
16
11
  import { buildParam } from "./buildParam/index.js";
17
- import { isResponseFile, jsonrpcBody, paramSignedTransaction, parseLine, prefixWith0x, getPrivateKeyHex, } from "./utils/index.js";
12
+ import { jsonrpcBody, paramSignedTransaction, parseLine, prefixWith0x, getPrivateKeyHex, } from "./utils/index.js";
18
13
  import { Client, getPrivateKeyJwk } from "./utils/Client.js";
19
- import { authorisationV3, authorisationV4, compute, view, conformanceV3, conformanceV4, ledgerV4, ledgerV3, waitToBeMined, } from "./commands/index.js";
14
+ import { authorisationV2, authorisationV3, compute, view, conformanceV3, ledgerV3, waitToBeMined, } from "./commands/index.js";
20
15
  let config = loadConfig();
21
- if (!fs.existsSync("./downloads")) {
22
- fs.mkdirSync("./downloads");
23
- }
24
16
  let client = new Client();
25
17
  let transactionInfo;
26
18
  let trustedApp;
@@ -29,9 +21,6 @@ let oauth2token;
29
21
  let httpOpts = {
30
22
  headers: {},
31
23
  };
32
- let httpOptsUrlencoded = {
33
- headers: {},
34
- };
35
24
  const rtVars = {}; // runtime variables
36
25
  const algSchema = Joi.string()
37
26
  .valid("ES256K", "ES256", "RS256", "EdDSA")
@@ -57,15 +46,6 @@ function updateHttpOpts() {
57
46
  ...(conformanceId && { conformance: conformanceId }),
58
47
  },
59
48
  };
60
- httpOptsUrlencoded = {
61
- headers: {
62
- ...((token || oauth2token) && {
63
- authorization: `Bearer ${token || oauth2token}`,
64
- }),
65
- ...(conformanceId && { conformance: conformanceId }),
66
- "content-type": "application/x-www-form-urlencoded",
67
- },
68
- };
69
49
  }
70
50
  function readValue(input, required = false) {
71
51
  if (!input || typeof input !== "string")
@@ -209,8 +189,7 @@ async function using(method, ...params) {
209
189
  await execCommand(`using user ES256K ${params.join(" ")}`, true);
210
190
  return client;
211
191
  }
212
- case "app":
213
- case "app-new": {
192
+ case "app": {
214
193
  const name = params[0];
215
194
  const privateKey = params[1];
216
195
  const publicKeyPem = new EbsiWallet(privateKey).getPublicKey({
@@ -222,7 +201,7 @@ async function using(method, ...params) {
222
201
  privateKey,
223
202
  publicKeyPem,
224
203
  publicKeyPemBase64,
225
- kid: `${method === "app" ? config.api.tar.url : config.api["tar-new"].url}/apps/${name}`,
204
+ kid: `${config.api.tar.url}/apps/${name}`,
226
205
  };
227
206
  utils.yellow(trustedApp);
228
207
  return trustedApp;
@@ -232,522 +211,6 @@ async function using(method, ...params) {
232
211
  return 0;
233
212
  }
234
213
  }
235
- async function authorisationV2(method, inputs) {
236
- const apiUrl = config.api.authorisationV2.url;
237
- switch (method) {
238
- case "get": {
239
- const response = await utils.httpCall.get(`${apiUrl}${urlPath(inputs)}`, httpOpts);
240
- return response.data;
241
- }
242
- case "siopRequest": {
243
- return utils.siopRequestV2(config, httpOpts);
244
- }
245
- case "siopSession": {
246
- const callbackUrl = readValue(inputs[0]);
247
- const alg = readValue(inputs[1]) || "ES256K";
248
- const verifiedClaims = readValue(inputs[2]);
249
- Joi.assert(callbackUrl, Joi.string());
250
- Joi.assert(alg, algSchema);
251
- Joi.assert(verifiedClaims, Joi.string().optional());
252
- return utils.siopSessionV2(client, callbackUrl, alg, httpOpts, verifiedClaims);
253
- }
254
- case "siop": {
255
- const alg = readValue(inputs[0]) || "ES256K";
256
- const vcJwtEOS = readValue(inputs[1]);
257
- let vpJwt = "";
258
- if (vcJwtEOS) {
259
- vpJwt = await execCommand(`compute createPresentationJwt ${vcJwtEOS} ${alg} authorisation-api`, true);
260
- }
261
- const request = await execCommand("authorisation-old siopRequest", true);
262
- const callbackUrl = await execCommand(`compute verifyAuthenticationRequest ${JSON.stringify(request)}`, true);
263
- const sessionResponse = await execCommand(`authorisation-old siopSession ${callbackUrl} ${alg} ${vpJwt}`, true);
264
- const accessToken = await execCommand(`compute verifySessionResponse ${JSON.stringify(sessionResponse)}`, true);
265
- return accessToken;
266
- }
267
- case "oauth2":
268
- case "oauth2Session": {
269
- return utils.oauth2SessionV2(trustedApp, inputs[0], config);
270
- }
271
- default:
272
- utils.red(`Invalid method '${method}'`);
273
- break;
274
- }
275
- return 0;
276
- }
277
- async function proxydatahub(method, inputs) {
278
- const apiUrl = config.api.datahub.url;
279
- const storageApiUrl = config.api.storage.url;
280
- switch (method) {
281
- case "get": {
282
- Joi.assert(inputs[0], Joi.string());
283
- const response = await utils.httpCall.get(`${apiUrl}${urlPath(inputs)}`, httpOpts);
284
- return response.data;
285
- }
286
- case "insert": {
287
- Joi.assert(inputs[0], Joi.object().optional());
288
- Joi.assert(inputs[1], Joi.string().optional());
289
- Joi.assert(inputs[2], Joi.string().optional());
290
- const data = typeof inputs[0] === "object"
291
- ? base64url.encode(Buffer.from(JSON.stringify(inputs[0])))
292
- : base64url.encode(randomBytes(20));
293
- const visibility = inputs[1] || "private";
294
- const did = inputs[2] || "";
295
- const url = `${apiUrl}/attributes`;
296
- const body = {
297
- storageUri: `${storageApiUrl}/stores/distributed`,
298
- visibility,
299
- ...(did && { sharedWith: did }),
300
- did: client.did,
301
- contentType: "application/ld+json",
302
- dataLabel: "document",
303
- data,
304
- proof: {},
305
- };
306
- return utils.httpCall.post(url, body, httpOpts);
307
- }
308
- case "patch": {
309
- Joi.assert(inputs[0], Joi.string());
310
- Joi.assert(inputs[1], Joi.array().optional());
311
- const attributeId = inputs[0];
312
- const patchOps = Array.isArray(inputs[1])
313
- ? inputs[1]
314
- : [
315
- {
316
- op: "replace",
317
- path: "/contentType",
318
- value: "application/ld+json",
319
- },
320
- ];
321
- const url = `${apiUrl}/attributes/${attributeId}`;
322
- return utils.httpCall.patch(url, patchOps, httpOpts);
323
- }
324
- case "delete": {
325
- Joi.assert(inputs[0], Joi.string());
326
- const attributeId = inputs[0];
327
- const url = `${apiUrl}/attributes/${attributeId}`;
328
- return utils.httpCall.delete(url, httpOpts);
329
- }
330
- default:
331
- utils.red(`Invalid method '${method}'`);
332
- break;
333
- }
334
- return 0;
335
- }
336
- async function notifications(method, ...inputs) {
337
- const apiUrl = config.api.notifications.url;
338
- switch (method) {
339
- case "get": {
340
- Joi.assert(inputs[0], Joi.string());
341
- const response = await utils.httpCall.get(`${apiUrl}${urlPath(inputs)}`, httpOpts);
342
- return response.data;
343
- }
344
- case "insert": {
345
- Joi.assert(inputs[0], Joi.string());
346
- Joi.assert(inputs[1], Joi.object().optional());
347
- Joi.assert(inputs[2], Joi.string().optional());
348
- const to = inputs[0];
349
- const payload = typeof inputs[1] === "object"
350
- ? inputs[1]
351
- : {
352
- "@context": "ebsi.eu",
353
- data: randomBytes(32).toString("hex"),
354
- };
355
- const type = inputs[2] || "StoreVerifiableCredential";
356
- const url = `${apiUrl}/notifications`;
357
- const data = await utils.createNotification(client, to, payload, type);
358
- const response = await utils.httpCall.post(url, data, httpOpts);
359
- const { location } = response.headers;
360
- const notificationId = location.substring(location.lastIndexOf("/") + 1);
361
- utils.yellow("Notification Id:");
362
- utils.yellow(notificationId);
363
- return response.data;
364
- }
365
- case "delete": {
366
- Joi.assert(inputs[0], Joi.string());
367
- Joi.assert(inputs[1], Joi.object().optional());
368
- if (inputs[0] === "all") {
369
- const response = await utils.httpCall.get(`${apiUrl}/notifications?page[size]=50`, httpOpts);
370
- const { items } = response.data;
371
- for (let i = 0; i < items.length; i += 1) {
372
- // eslint-disable-next-line no-underscore-dangle
373
- const { href } = items[i]._links.self;
374
- const notificationId = href.substring(href.lastIndexOf("/") + 1);
375
- const url = `${apiUrl}/notifications/${notificationId}`;
376
- await utils.httpCall.delete(url, httpOpts);
377
- }
378
- return 0;
379
- }
380
- const notificationId = inputs[0];
381
- const url = `${apiUrl}/notifications/${notificationId}`;
382
- return utils.httpCall.delete(url, httpOpts);
383
- }
384
- default:
385
- utils.red(`Invalid method '${method}'`);
386
- break;
387
- }
388
- return 0;
389
- }
390
- async function storage(method, inputs) {
391
- const apiUrl = config.api.storage.url;
392
- switch (method) {
393
- case "get": {
394
- Joi.assert(inputs[0], Joi.string());
395
- const storageUrlPath = urlPath(inputs);
396
- const isDownloadingFile = /stores\/distributed\/files\/0x([a-zA-Z0-9]){64}$/.exec(storageUrlPath);
397
- if (!isDownloadingFile) {
398
- const response = await utils.httpCall.get(`${apiUrl}${storageUrlPath}`, httpOpts);
399
- return response.data;
400
- }
401
- const response = await utils.httpCall.get(`${apiUrl}${storageUrlPath}`, {
402
- ...httpOpts,
403
- responseType: "stream",
404
- });
405
- let filename;
406
- if (isResponseFile(response)) {
407
- filename = response.headers["content-disposition"].replace("attachment; filename=", "");
408
- }
409
- else {
410
- filename = `error-${randomBytes(12).toString("hex")}.txt`;
411
- }
412
- const filepath = `./downloads/${filename}`;
413
- const writer = createWriteStream(filepath);
414
- await new Promise((resolve, reject) => {
415
- response.data.pipe(writer);
416
- let error = null;
417
- writer.on("error", (err) => {
418
- error = err;
419
- writer.close();
420
- reject(err);
421
- });
422
- writer.on("close", () => {
423
- if (!error) {
424
- resolve(true);
425
- }
426
- });
427
- });
428
- if (!isResponseFile(response)) {
429
- // there is an error
430
- const dataString = fs.readFileSync(filepath, "utf8");
431
- fs.unlinkSync(filepath);
432
- try {
433
- const jsonData = JSON.parse(dataString);
434
- utils.red(jsonData);
435
- }
436
- catch (e) {
437
- utils.red(dataString);
438
- }
439
- throw new Error(`Requests failed with status code ${response.status}: ${dataString}`);
440
- }
441
- utils.green(`Binary data: ${filename}`);
442
- return 0;
443
- }
444
- case "file": {
445
- Joi.assert(inputs[0], Joi.string());
446
- const methodFile = inputs[0];
447
- return utils.fileController(httpOpts, apiUrl, methodFile, inputs.slice(1));
448
- }
449
- case "keyvalue": {
450
- Joi.assert(inputs[0], Joi.string());
451
- const methodKeyValue = inputs[0];
452
- return utils.keyValueController(httpOpts, apiUrl, methodKeyValue, inputs.slice(1));
453
- }
454
- case "jsonrpc": {
455
- Joi.assert(inputs[0], Joi.array());
456
- return utils.jsonrpcStorage(httpOpts, apiUrl, inputs[0]);
457
- }
458
- default:
459
- utils.red(`Invalid method '${method}'`);
460
- break;
461
- }
462
- return 0;
463
- }
464
- async function cassandra(method, inputs) {
465
- switch (method) {
466
- case "query": {
467
- Joi.assert(inputs[0], Joi.array().items(Joi.string()));
468
- const [query, ...params] = inputs[0];
469
- const options = {
470
- consistency: query.trim().startsWith("select")
471
- ? config.cassandra.consistency.read
472
- : config.cassandra.consistency.write,
473
- prepare: true,
474
- };
475
- if (params.length > 0 && typeof params[params.length - 1] === "object") {
476
- Object.assign(options, params.pop());
477
- }
478
- const { rows, pageState } = await config.cassandra.client.execute(query, params, options);
479
- return {
480
- rows,
481
- pageState,
482
- };
483
- }
484
- default:
485
- utils.red(`Invalid method '${method}'`);
486
- break;
487
- }
488
- return 0;
489
- }
490
- async function onboarding(method, ...params) {
491
- const apiUrl = config.api.onboarding.url;
492
- switch (method) {
493
- case "get": {
494
- const response = await utils.httpCall.get(`${apiUrl}${urlPath(params)}`, httpOpts);
495
- return response.data;
496
- }
497
- case "session": {
498
- return utils.httpCall.post(`${apiUrl}/sessions`, {
499
- onboarding: "eu-login",
500
- info: {
501
- "eul-ticket": readValue(params[0]),
502
- },
503
- }, httpOpts);
504
- }
505
- case "authenticationRequests": {
506
- const response = await utils.httpCall.post(`${apiUrl}/authentication-requests`, {
507
- scope: "ebsi users onboarding",
508
- }, httpOpts);
509
- return response.data;
510
- }
511
- case "sendAuthResponse": {
512
- const alg = readValue(params[0]) || "ES256K";
513
- Joi.assert(alg, algSchema);
514
- const nonce = randomUUID();
515
- const key = client.keys[alg];
516
- if (!key)
517
- throw new Error(`There is no key defined for alg ${alg}`);
518
- const callbackUrl = `${apiUrl}/authentication-responses`;
519
- const agent = new SiopAgent({
520
- privateKey: await importJWK(key.privateKeyJwk, alg),
521
- alg,
522
- kid: key.kid,
523
- siopV2: true,
524
- });
525
- const { idToken } = await agent.createResponse({
526
- nonce,
527
- redirectUri: callbackUrl,
528
- claims: {
529
- encryption_key: key.publicKeyEncryptionJwk,
530
- },
531
- responseMode: "form_post",
532
- }, {
533
- syntaxType: client.didVersion === 1 ? "jwk_thumbprint_subject" : "did_subject",
534
- });
535
- const data = `id_token=${idToken}`;
536
- const response = await utils.httpCall.post(callbackUrl, data, {
537
- headers: {
538
- ...httpOpts.headers,
539
- "content-type": "application/x-www-form-urlencoded",
540
- },
541
- });
542
- return response.data.verifiableCredential;
543
- }
544
- case "authentication": {
545
- const alg = params[0] || "ES256K";
546
- const vc = await execCommand(`onboarding sendAuthResponse ${alg}`, true);
547
- const vp = await execCommand(`compute createPresentationJwt ${vc} ${alg} authorisation-api`, true);
548
- const request = await execCommand(`authorisation-old siopRequest`, true);
549
- const callbackUrl = await execCommand(`compute verifyAuthenticationRequest ${JSON.stringify(request)}`, true);
550
- const sessionResponse = await execCommand(`authorisation-old siopSession ${callbackUrl} ${alg} ${vp}`, true);
551
- const accessToken = await execCommand(`compute verifySessionResponse ${JSON.stringify(sessionResponse)}`, true);
552
- return accessToken;
553
- }
554
- default:
555
- utils.red(`Invalid method '${method}'`);
556
- break;
557
- }
558
- return 0;
559
- }
560
- async function conformanceOld(method, inputs) {
561
- const apiUrl = config.api.conformanceV2.url;
562
- switch (method) {
563
- case "get": {
564
- const response = await utils.httpCall.get(`${apiUrl}${urlPath(inputs)}`, httpOpts);
565
- return response.data;
566
- }
567
- case "setId": {
568
- const id = readValue(inputs[0]);
569
- let conformanceId;
570
- if (id === "null")
571
- conformanceId = undefined;
572
- else if (!id)
573
- conformanceId = randomUUID();
574
- else
575
- conformanceId = id;
576
- await setVar("conformanceId", conformanceId);
577
- updateHttpOpts();
578
- return execCommand("view conformanceId", false);
579
- }
580
- case "issuerInitiate": {
581
- const flowType = readValue(inputs[0]) || "same-device";
582
- const redirect = readValue(inputs[1]) || "false";
583
- const urlParams = { redirect, flow_type: flowType };
584
- const response = await utils.httpCall.get(`${apiUrl}/issuer-mock/initiate?${qs.stringify(urlParams)}`, httpOpts);
585
- const openid = response.data;
586
- return qs.parse(openid.split("?")[1]);
587
- }
588
- case "issuerAuthorize": {
589
- const redirectUri = readValue(inputs[0]) || "http://localhost:3000";
590
- const credentialType = readValue(inputs[1]);
591
- Joi.assert(redirectUri, Joi.string());
592
- Joi.assert(credentialType, Joi.string().optional());
593
- const urlparams = {
594
- scope: "openid conformance_testing",
595
- response_type: "code",
596
- redirect_uri: redirectUri,
597
- client_id: client.did,
598
- response_mode: "post",
599
- state: randomBytes(6).toString("hex"),
600
- authorization_details: JSON.stringify([
601
- {
602
- type: "openid_credential",
603
- credential_type: credentialType,
604
- format: "jwt_vc",
605
- },
606
- ]),
607
- };
608
- const urlParamsString = qs.stringify(urlparams);
609
- const response = await utils.httpCall.get(`${apiUrl}/issuer-mock/authorize?${urlParamsString}`, httpOpts);
610
- const urlResponse = response.headers
611
- .location;
612
- const location = new URL(urlResponse).searchParams;
613
- if (location.get("error"))
614
- throw new Error(location.toString());
615
- return {
616
- code: location.get("code"),
617
- state: location.get("state"),
618
- };
619
- }
620
- case "issuerToken": {
621
- const code = readValue(inputs[0]);
622
- const redirectUri = readValue(inputs[1]) || "http://localhost:3000";
623
- Joi.assert(code, Joi.string());
624
- Joi.assert(redirectUri, Joi.string());
625
- const body = {
626
- code,
627
- grant_type: "authorization_code",
628
- redirect_uri: redirectUri,
629
- };
630
- const response = await utils.httpCall.post(`${apiUrl}/issuer-mock/token`, new URLSearchParams(body).toString(), httpOptsUrlencoded);
631
- return response.data;
632
- }
633
- case "issuerCredential": {
634
- const cNonce = readValue(inputs[0]);
635
- const accessToken = readValue(inputs[1]) || token;
636
- const alg = readValue(inputs[2]) || "ES256K";
637
- const credentialType = readValue(inputs[3]);
638
- const issuerUrl = readValue(inputs[4]);
639
- Joi.assert(cNonce, Joi.string());
640
- if (!client.keys[alg])
641
- throw new Error(`There is no key defined for alg ${alg}`);
642
- const privateKey = await importJWK(client.keys[alg].privateKeyJwk, alg);
643
- const jwt = await new SignJWT({
644
- nonce: cNonce,
645
- aud: issuerUrl,
646
- })
647
- .setProtectedHeader({
648
- alg,
649
- typ: "JWT",
650
- kid: client.keys[alg].kid,
651
- ...(client.didVersion === 2 && {
652
- jwk: client.keys[alg].publicKeyJwk,
653
- }),
654
- })
655
- .setIssuedAt()
656
- .setIssuer(client.did)
657
- .sign(privateKey);
658
- const endpoint = "/issuer-mock/credential";
659
- const headers = {
660
- authorization: `Bearer ${accessToken}`,
661
- };
662
- const body = {
663
- type: credentialType,
664
- proof: {
665
- proof_type: "jwt",
666
- jwt,
667
- },
668
- };
669
- const response = await utils.httpCall.post(`${apiUrl}${endpoint}`, qs.stringify(body), {
670
- headers: { ...httpOpts.headers, ...headers },
671
- });
672
- return response.data;
673
- }
674
- case "verifierAuthRequest": {
675
- const flowType = readValue(inputs[0]) || "same-device";
676
- const redirect = readValue(inputs[1]) || "false";
677
- const urlparams = { redirect, flow_type: flowType };
678
- let dataResponse;
679
- {
680
- const response = await utils.httpCall.get(`${apiUrl}/verifier-mock/authentication-requests?${qs.stringify(urlparams)}`, httpOpts);
681
- dataResponse = response.data;
682
- }
683
- const uriDecoded = qs.parse(dataResponse.replace("openid://?", ""));
684
- return uriDecoded;
685
- }
686
- case "verifierAuthResponse": {
687
- const jwtVp = readValue(inputs[0]);
688
- const alg = readValue(inputs[1]) || "ES256K";
689
- Joi.assert(jwtVp, Joi.string());
690
- if (!client.keys[alg])
691
- throw new Error(`There is no key defined for alg ${alg}`);
692
- const privateKey = await importJWK(client.keys[alg].privateKeyJwk, alg);
693
- const idToken = await new SignJWT({
694
- _vp_token: {
695
- presentation_submission: {
696
- id: randomUUID(),
697
- definition_id: "conformance_mock_vp_request",
698
- descriptor_map: [
699
- {
700
- id: "conformance_mock_vp",
701
- format: "jwt_vp",
702
- path: "$",
703
- },
704
- ],
705
- },
706
- },
707
- })
708
- .setProtectedHeader({
709
- alg,
710
- typ: "JWT",
711
- kid: client.keys[alg].kid,
712
- ...(client.didVersion === 2 && {
713
- jwk: client.keys[alg].publicKeyJwk,
714
- }),
715
- })
716
- .setIssuedAt()
717
- .setIssuer("https://self-issued.me/v2")
718
- .sign(privateKey);
719
- const body = {
720
- id_token: idToken,
721
- vp_token: jwtVp,
722
- };
723
- const response = await utils.httpCall.post(`${apiUrl}/verifier-mock/authentication-responses`, qs.stringify(body), httpOptsUrlencoded);
724
- return response.data;
725
- }
726
- case "issuer": {
727
- let response = await execCommand("conformance-old issuerInitiate", true);
728
- const { credential_type: credentialType, issuer: issuerUrl } = response;
729
- response = await execCommand(`conformance-old issuerAuthorize http://localhost:3000 ${credentialType}`, true);
730
- const { code } = response;
731
- response = await execCommand(`conformance-old issuerToken ${code}`, true);
732
- const { access_token: accessToken, c_nonce: cNonce } = response;
733
- response = await execCommand(`conformance-old issuerCredential ${cNonce} ${accessToken} ES256K ${credentialType} ${issuerUrl}`, true);
734
- return response;
735
- }
736
- case "verifier": {
737
- const { credential: jwtVc } = await execCommand(`conformance-old issuer`, true);
738
- await execCommand(`conformance-old verifierAuthRequest`, true);
739
- const vcDecoded = await execCommand(`compute decodeJWT ${jwtVc}`, true);
740
- const audience = vcDecoded.payload.iss;
741
- const jwtVp = await execCommand(`compute createPresentationJwt ${jwtVc} ES256K ${audience}`, true);
742
- const response = await execCommand(`conformance-old verifierAuthResponse ${jwtVp}`, true);
743
- return response;
744
- }
745
- default:
746
- utils.red(`Invalid method '${method}'`);
747
- break;
748
- }
749
- return 0;
750
- }
751
214
  async function smartContractApi(contract, method, ...inputs) {
752
215
  const apiUrl = config.api[contract].url;
753
216
  if (method === "get") {
@@ -834,74 +297,6 @@ function setDomain(dom) {
834
297
  }
835
298
  utils.yellow(`Current domain: ${config.domain}`);
836
299
  }
837
- function wctOld(method, inputs) {
838
- switch (method) {
839
- case "loadReport": {
840
- const filename = readValue(inputs[0]);
841
- Joi.assert(filename, Joi.string());
842
- const data = fs.readFileSync(filename, "utf8");
843
- const book = JSON.parse(data);
844
- utils.yellow(`Report loaded: ${filename}`);
845
- return book;
846
- }
847
- case "check": {
848
- const logs = readValue(inputs[0]);
849
- if (!logs || logs.length === 0)
850
- throw new Error("No logs found");
851
- const iniTime = new Date(logs[0].created).toISOString();
852
- const endTime = new Date(logs[logs.length - 1].created).toISOString();
853
- const conformanceId = logs[0].data.request.headers.conformance;
854
- console.log([
855
- "",
856
- chalk.yellow("----------------------------------------------------"),
857
- chalk.yellow("Wallet Conformance Testing Report"),
858
- chalk.yellow("----------------------------------------------------"),
859
- "",
860
- `conformance id: ${chalk.magenta(conformanceId)}`,
861
- "",
862
- "timestamp:",
863
- ` from: ${chalk.magenta(iniTime)}`,
864
- ` to: ${chalk.magenta(endTime)}`,
865
- "",
866
- ].join("\n"));
867
- const missingUrls = [
868
- "/conformance/v2/issuer-mock/initiate",
869
- "/conformance/v2/issuer-mock/authorize",
870
- "/conformance/v2/issuer-mock/token",
871
- "/conformance/v2/issuer-mock/credential",
872
- "/conformance/v2/verifier-mock/authentication-requests",
873
- "/conformance/v2/verifier-mock/authentication-responses",
874
- ];
875
- let numberErrors = 0;
876
- logs.forEach((log) => {
877
- const testOk = log.data.response.statusCode < 400;
878
- const url = log.data.request.url.split("?")[0];
879
- const result = testOk ? chalk.green("OK") : chalk.red("FAIL");
880
- console.log(url + ".".repeat(70 - url.length) + result);
881
- if (!testOk)
882
- numberErrors += 1;
883
- const id = missingUrls.findIndex((u) => u === url);
884
- if (id >= 0)
885
- missingUrls.splice(id, 1);
886
- });
887
- missingUrls.forEach((url) => {
888
- console.log(url + ".".repeat(70 - url.length) + chalk.red("NO LOGS"));
889
- });
890
- numberErrors += missingUrls.length;
891
- console.log("");
892
- const numberSuccess = logs.length + missingUrls.length - numberErrors;
893
- if (numberSuccess)
894
- console.log(chalk.green.bold(numberSuccess) + chalk.green(" test passed"));
895
- if (numberErrors)
896
- console.log(chalk.red.bold(numberErrors) + chalk.red(" test failed"));
897
- return 0;
898
- }
899
- default:
900
- utils.red(`Invalid method '${method}'`);
901
- break;
902
- }
903
- return 0;
904
- }
905
300
  function fileSystem(method, ...params) {
906
301
  switch (method) {
907
302
  case "readBinaryFile": {
@@ -921,8 +316,24 @@ function fileSystem(method, ...params) {
921
316
  return 0;
922
317
  }
923
318
  }
319
+ function readFile(filename) {
320
+ try {
321
+ // get the file from the working directory
322
+ return fs.readFileSync(filename, "utf-8");
323
+ }
324
+ catch {
325
+ // otherwise get the file from the internal scripts of the CLI tool
326
+ try {
327
+ return fs.readFileSync(new URL(`scripts/${filename}`, import.meta.url), "utf8");
328
+ }
329
+ catch {
330
+ throw new Error(`Can't open script ${filename}`);
331
+ }
332
+ }
333
+ }
924
334
  async function run(filename, inputs = []) {
925
- const lines = fs.readFileSync(`scripts/${filename}`, "utf8").split(/\r?\n/);
335
+ const filedata = readFile(filename);
336
+ const lines = filedata.split(/\r?\n/);
926
337
  let response;
927
338
  for (let i = 0; i < lines.length; i += 1) {
928
339
  let line = lines[i].trim();
@@ -959,22 +370,7 @@ export async function execCommand(command, printCommand = false) {
959
370
  const word1 = part1;
960
371
  Joi.assert(method, Joi.string());
961
372
  // APIs linked to smart contracts
962
- if ([
963
- "timestamp",
964
- "timestamp-new",
965
- "did",
966
- "did-old",
967
- "did-new",
968
- "tar",
969
- "tar-new",
970
- "tir",
971
- "tir-old",
972
- "tir-new",
973
- "tsr",
974
- "tsr-new",
975
- "tpr",
976
- "tpr-new",
977
- ].includes(method)) {
373
+ if (["timestamp", "did", "tar", "tir", "tsr", "tpr"].includes(method)) {
978
374
  Joi.assert(word1, Joi.string());
979
375
  const response = await smartContractApi(method, word1, ...parts2);
980
376
  if (varName)
@@ -1037,52 +433,14 @@ export async function execCommand(command, printCommand = false) {
1037
433
  Joi.assert(word1, Joi.string());
1038
434
  Joi.assert(parts2, schemaStrings);
1039
435
  const inputs = parts2.map((p) => readValue(p));
1040
- const response = await authorisationV3(word1, inputs, context);
1041
- if (varName)
1042
- await setVar(varName, response);
1043
- return response;
1044
- }
1045
- case "authorisation-new": {
1046
- Joi.assert(word1, Joi.string());
1047
- Joi.assert(parts2, schemaStrings);
1048
- const inputs = parts2.map((p) => readValue(p));
1049
- const response = await authorisationV4(word1, inputs, context);
1050
- if (varName)
1051
- await setVar(varName, response);
1052
- return response;
1053
- }
1054
- case "authorisation-old": {
1055
- Joi.assert(word1, Joi.string());
1056
- Joi.assert(parts2, schemaStrings);
1057
- const response = await authorisationV2(word1, parts2);
1058
- if (varName)
1059
- await setVar(varName, response);
1060
- return response;
1061
- }
1062
- case "notifications": {
1063
- Joi.assert(word1, Joi.string());
1064
- const response = await notifications(word1, ...parts2);
1065
- if (varName)
1066
- await setVar(varName, response);
1067
- return response;
1068
- }
1069
- case "datahub": {
1070
- Joi.assert(word1, Joi.string());
1071
- const response = await proxydatahub(word1, parts2);
1072
- if (varName)
1073
- await setVar(varName, response);
1074
- return response;
1075
- }
1076
- case "storage": {
1077
- Joi.assert(word1, Joi.string());
1078
- const response = await storage(word1, parts2);
1079
- if (varName)
1080
- await setVar(varName, response);
1081
- return response;
1082
- }
1083
- case "cassandra": {
1084
- Joi.assert(word1, Joi.string());
1085
- const response = await cassandra(word1, parts2);
436
+ const legacyCommands = ["siopRequest", "siopSession", "siop", "oauth2"];
437
+ let response;
438
+ if (legacyCommands.includes(word1)) {
439
+ response = await authorisationV2(word1, inputs, context);
440
+ }
441
+ else {
442
+ response = await authorisationV3(word1, inputs, context);
443
+ }
1086
444
  if (varName)
1087
445
  await setVar(varName, response);
1088
446
  return response;
@@ -1090,7 +448,7 @@ export async function execCommand(command, printCommand = false) {
1090
448
  case "proxyledger": {
1091
449
  Joi.assert(word1, Joi.string());
1092
450
  const inputs = parts2.map((p) => readValue(p));
1093
- const response = await ledgerV4(word1, inputs, true, context);
451
+ const response = await ledgerV3(word1, inputs, true, context);
1094
452
  if (varName)
1095
453
  await setVar(varName, response);
1096
454
  return response;
@@ -1103,22 +461,6 @@ export async function execCommand(command, printCommand = false) {
1103
461
  await setVar(varName, response);
1104
462
  return response;
1105
463
  }
1106
- case "ledger-new": {
1107
- Joi.assert(word1, Joi.string());
1108
- const inputs = parts2.map((p) => readValue(p));
1109
- const response = await ledgerV4(word1, inputs, false, context);
1110
- if (varName)
1111
- await setVar(varName, response);
1112
- return response;
1113
- }
1114
- case "onboarding": {
1115
- Joi.assert(word1, Joi.string());
1116
- Joi.assert(parts2, schemaStrings);
1117
- const response = await onboarding(word1, ...parts2);
1118
- if (varName)
1119
- await setVar(varName, response);
1120
- return response;
1121
- }
1122
464
  case "conformance": {
1123
465
  Joi.assert(word1, Joi.string());
1124
466
  const inputs = parts2.map((p) => readValue(p));
@@ -1127,21 +469,6 @@ export async function execCommand(command, printCommand = false) {
1127
469
  await setVar(varName, response);
1128
470
  return response;
1129
471
  }
1130
- case "conformance-new": {
1131
- Joi.assert(word1, Joi.string());
1132
- const inputs = parts2.map((p) => readValue(p));
1133
- const response = await conformanceV4(word1, inputs, context);
1134
- if (varName)
1135
- await setVar(varName, response);
1136
- return response;
1137
- }
1138
- case "conformance-old": {
1139
- Joi.assert(word1, Joi.string());
1140
- const response = await conformanceOld(word1, parts2);
1141
- if (varName)
1142
- await setVar(varName, response);
1143
- return response;
1144
- }
1145
472
  case "compute": {
1146
473
  Joi.assert(word1, Joi.string());
1147
474
  const inputs = parts2.map((p) => readValue(p));
@@ -1152,19 +479,12 @@ export async function execCommand(command, printCommand = false) {
1152
479
  }
1153
480
  case "load": {
1154
481
  const filename = readValue(word1);
1155
- const data = fs.readFileSync(filename, "utf8");
482
+ const data = readFile(filename);
1156
483
  const response = JSON.parse(data);
1157
484
  if (varName)
1158
485
  await setVar(varName, response);
1159
486
  return response;
1160
487
  }
1161
- case "wct-old": {
1162
- Joi.assert(word1, Joi.string());
1163
- const response = wctOld(word1, parts2);
1164
- if (varName)
1165
- await setVar(varName, response, false);
1166
- return response;
1167
- }
1168
488
  case "run": {
1169
489
  Joi.assert(word1, Joi.string());
1170
490
  const inputs = parts2.map((p) => readValue(p));