@prosopo/cli 3.4.6 → 3.4.17

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 (123) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/coverage/base.css +224 -0
  3. package/coverage/block-navigation.js +87 -0
  4. package/coverage/clover.xml +1243 -0
  5. package/coverage/coverage-final.json +22 -0
  6. package/coverage/favicon.png +0 -0
  7. package/coverage/index.html +146 -0
  8. package/coverage/prettify.css +1 -0
  9. package/coverage/prettify.js +2 -0
  10. package/coverage/sort-arrow-sprite.png +0 -0
  11. package/coverage/sorter.js +210 -0
  12. package/coverage/src/RateLimiter.ts.html +298 -0
  13. package/coverage/src/argv.ts.html +325 -0
  14. package/coverage/src/cli.ts.html +328 -0
  15. package/coverage/src/commands/ensureExternalIndexes.ts.html +244 -0
  16. package/coverage/src/commands/ensureIndexes.ts.html +226 -0
  17. package/coverage/src/commands/index.html +236 -0
  18. package/coverage/src/commands/index.ts.html +145 -0
  19. package/coverage/src/commands/migrateIpInCaptchaRecords/getDb.ts.html +280 -0
  20. package/coverage/src/commands/migrateIpInCaptchaRecords/index.html +146 -0
  21. package/coverage/src/commands/migrateIpInCaptchaRecords/migrateIpField.ts.html +526 -0
  22. package/coverage/src/commands/migrateIpInCaptchaRecords/migrateIpInCaptchaRecords.ts.html +280 -0
  23. package/coverage/src/commands/providerSetDataset.ts.html +289 -0
  24. package/coverage/src/commands/siteKeyRegister.ts.html +445 -0
  25. package/coverage/src/commands/siteKeyRegisterApi.ts.html +478 -0
  26. package/coverage/src/commands/storeCaptchasExternally.ts.html +229 -0
  27. package/coverage/src/commands/validators.ts.html +280 -0
  28. package/coverage/src/commands/version.ts.html +193 -0
  29. package/coverage/src/files.ts.html +256 -0
  30. package/coverage/src/index.html +236 -0
  31. package/coverage/src/index.ts.html +142 -0
  32. package/coverage/src/process.env.ts.html +280 -0
  33. package/coverage/src/prosopo.config.ts.html +496 -0
  34. package/coverage/src/reloader.ts.html +394 -0
  35. package/coverage/src/start.ts.html +760 -0
  36. package/dist/RateLimiter.d.ts +59 -0
  37. package/dist/RateLimiter.d.ts.map +1 -0
  38. package/dist/RateLimiter.js +4 -0
  39. package/dist/RateLimiter.js.map +1 -0
  40. package/dist/argv.d.ts +22 -0
  41. package/dist/argv.d.ts.map +1 -0
  42. package/dist/argv.js +0 -2
  43. package/dist/argv.js.map +1 -0
  44. package/dist/bundle/i18nBackend-D6GWR1ra.js +5260 -0
  45. package/dist/bundle/provider.cli.bundle.js +101406 -0
  46. package/dist/cjs/RateLimiter.cjs +4 -0
  47. package/dist/cjs/argv.cjs +0 -2
  48. package/dist/cjs/cli.cjs +2 -10
  49. package/dist/cjs/commands/siteKeyRegister.cjs +2 -1
  50. package/dist/cjs/commands/siteKeyRegisterApi.cjs +2 -1
  51. package/dist/cjs/start.cjs +8 -10
  52. package/dist/cli.d.ts +2 -0
  53. package/dist/cli.d.ts.map +1 -0
  54. package/dist/cli.js +0 -9
  55. package/dist/cli.js.map +1 -0
  56. package/dist/commands/ensureExternalIndexes.d.ts +13 -0
  57. package/dist/commands/ensureExternalIndexes.d.ts.map +1 -0
  58. package/dist/commands/ensureExternalIndexes.js.map +1 -0
  59. package/dist/commands/ensureIndexes.d.ts +13 -0
  60. package/dist/commands/ensureIndexes.d.ts.map +1 -0
  61. package/dist/commands/ensureIndexes.js.map +1 -0
  62. package/dist/commands/index.d.ts +8 -0
  63. package/dist/commands/index.d.ts.map +1 -0
  64. package/dist/commands/index.js.map +1 -0
  65. package/dist/commands/migrateIpInCaptchaRecords/getDb.d.ts +5 -0
  66. package/dist/commands/migrateIpInCaptchaRecords/getDb.d.ts.map +1 -0
  67. package/dist/commands/migrateIpInCaptchaRecords/getDb.js +24 -25
  68. package/dist/commands/migrateIpInCaptchaRecords/getDb.js.map +1 -0
  69. package/dist/commands/migrateIpInCaptchaRecords/migrateIpField.d.ts +4 -0
  70. package/dist/commands/migrateIpInCaptchaRecords/migrateIpField.d.ts.map +1 -0
  71. package/dist/commands/migrateIpInCaptchaRecords/migrateIpField.js +90 -82
  72. package/dist/commands/migrateIpInCaptchaRecords/migrateIpField.js.map +1 -0
  73. package/dist/commands/migrateIpInCaptchaRecords/migrateIpInCaptchaRecords.d.ts +5 -0
  74. package/dist/commands/migrateIpInCaptchaRecords/migrateIpInCaptchaRecords.d.ts.map +1 -0
  75. package/dist/commands/migrateIpInCaptchaRecords/migrateIpInCaptchaRecords.js +34 -33
  76. package/dist/commands/migrateIpInCaptchaRecords/migrateIpInCaptchaRecords.js.map +1 -0
  77. package/dist/commands/providerSetDataset.d.ts +17 -0
  78. package/dist/commands/providerSetDataset.d.ts.map +1 -0
  79. package/dist/commands/providerSetDataset.js.map +1 -0
  80. package/dist/commands/siteKeyRegister.d.ts +57 -0
  81. package/dist/commands/siteKeyRegister.d.ts.map +1 -0
  82. package/dist/commands/siteKeyRegister.js +2 -1
  83. package/dist/commands/siteKeyRegister.js.map +1 -0
  84. package/dist/commands/siteKeyRegisterApi.d.ts +33 -0
  85. package/dist/commands/siteKeyRegisterApi.d.ts.map +1 -0
  86. package/dist/commands/siteKeyRegisterApi.js +2 -1
  87. package/dist/commands/siteKeyRegisterApi.js.map +1 -0
  88. package/dist/commands/storeCaptchasExternally.d.ts +13 -0
  89. package/dist/commands/storeCaptchasExternally.d.ts.map +1 -0
  90. package/dist/commands/storeCaptchasExternally.js.map +1 -0
  91. package/dist/commands/validators.d.ts +18 -0
  92. package/dist/commands/validators.d.ts.map +1 -0
  93. package/dist/commands/validators.js.map +1 -0
  94. package/dist/commands/version.d.ts +12 -0
  95. package/dist/commands/version.d.ts.map +1 -0
  96. package/dist/commands/version.js.map +1 -0
  97. package/dist/files.d.ts +4 -0
  98. package/dist/files.d.ts.map +1 -0
  99. package/dist/files.js.map +1 -0
  100. package/dist/index.d.ts +7 -0
  101. package/dist/index.d.ts.map +1 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/process.env.d.ts +8 -0
  104. package/dist/process.env.d.ts.map +1 -0
  105. package/dist/process.env.js.map +1 -0
  106. package/dist/prosopo.config.d.ts +3 -0
  107. package/dist/prosopo.config.d.ts.map +1 -0
  108. package/dist/prosopo.config.js.map +1 -0
  109. package/dist/reloader.d.ts +20 -0
  110. package/dist/reloader.d.ts.map +1 -0
  111. package/dist/reloader.js.map +1 -0
  112. package/dist/start.d.ts +4 -0
  113. package/dist/start.d.ts.map +1 -0
  114. package/dist/start.js +8 -10
  115. package/dist/start.js.map +1 -0
  116. package/dist/tests/bundle/bundle.unit.test.d.ts +2 -0
  117. package/dist/tests/bundle/bundle.unit.test.d.ts.map +1 -0
  118. package/dist/tests/bundle/bundle.unit.test.js +14 -0
  119. package/dist/tests/bundle/bundle.unit.test.js.map +1 -0
  120. package/package.json +21 -25
  121. package/dist/cjs/commands/migrateIpInCaptchaRecords/getDb.cjs +0 -32
  122. package/dist/cjs/commands/migrateIpInCaptchaRecords/migrateIpField.cjs +0 -98
  123. package/dist/cjs/commands/migrateIpInCaptchaRecords/migrateIpInCaptchaRecords.cjs +0 -56
@@ -51,6 +51,10 @@ const getRateLimitConfig = () => {
51
51
  windowMs: process.env.PROSOPO_REMOVE_DETECTOR_KEY_WINDOW,
52
52
  limit: process.env.PROSOPO_REMOVE_DETECTOR_KEY_LIMIT
53
53
  },
54
+ [types.AdminApiPaths.ToggleMaintenanceMode]: {
55
+ windowMs: process.env.PROSOPO_TOGGLE_MAINTENANCE_MODE_WINDOW,
56
+ limit: process.env.PROSOPO_TOGGLE_MAINTENANCE_MODE_LIMIT
57
+ },
54
58
  [types.ClientApiPaths.GetFrictionlessCaptchaChallenge]: {
55
59
  windowMs: process.env.PROSOPO_GET_FR_CAPTCHA_CHALLENGE_WINDOW,
56
60
  limit: process.env.PROSOPO_GET_FR_CAPTCHA_CHALLENGE_LIMIT
package/dist/cjs/argv.cjs CHANGED
@@ -4,7 +4,6 @@ const common = require("@prosopo/common");
4
4
  const yargs = require("yargs");
5
5
  const helpers = require("yargs/helpers");
6
6
  require("./commands/index.cjs");
7
- const migrateIpInCaptchaRecords = require("./commands/migrateIpInCaptchaRecords/migrateIpInCaptchaRecords.cjs");
8
7
  const ensureIndexes = require("./commands/ensureIndexes.cjs");
9
8
  const ensureExternalIndexes = require("./commands/ensureExternalIndexes.cjs");
10
9
  const providerSetDataset = require("./commands/providerSetDataset.cjs");
@@ -20,7 +19,6 @@ function getCommands(pair, config, authAccount, logger) {
20
19
  storeCaptchasExternally(pair, config, { logger }),
21
20
  siteKeyRegister.default(pair, config, { logger }),
22
21
  siteKeyRegisterApi(pair, authAccount, config, { logger }),
23
- migrateIpInCaptchaRecords.migrateIpInCaptchaRecordsCommand(pair, config, logger),
24
22
  version(pair, config, { logger })
25
23
  ];
26
24
  }
package/dist/cjs/cli.cjs CHANGED
@@ -8,19 +8,11 @@ const util = require("@prosopo/util");
8
8
  const argv = require("./argv.cjs");
9
9
  const prosopo_config = require("./prosopo.config.cjs");
10
10
  const reloader = require("./reloader.cjs");
11
+ var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
11
12
  const log = common.getLogger(common.LogLevel.enum.info, "CLI");
12
13
  async function main() {
13
14
  const envPath = dotenv.loadEnv();
14
15
  const config = prosopo_config();
15
- if (config.devOnlyWatchEvents) {
16
- log.warn(() => ({
17
- msg: `
18
- ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
19
- EVENT TRACKING ON. IF NOT DEVELOPMENT, PLEASE STOP, CHANGE THE ENVIRONMENT, AND RESTART
20
- ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
21
- `
22
- }));
23
- }
24
16
  const pair = keyring.getPair(config.account.secret, config.account.address);
25
17
  const authAccount = keyring.getPair(
26
18
  config.authAccount.secret,
@@ -42,7 +34,7 @@ async function main() {
42
34
  process.exit(0);
43
35
  }
44
36
  }
45
- if (util.isMain(module, "provider")) {
37
+ if (util.isMain(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("cli.cjs", document.baseURI).href, "provider")) {
46
38
  locale.loadI18next(true).then(() => {
47
39
  main().then(() => {
48
40
  log.info(() => ({ msg: "Running main process..." }));
@@ -68,7 +68,8 @@ const commandSiteKeyRegister = (pair, config, cmdArgs) => {
68
68
  frictionlessThreshold: frictionless_threshold,
69
69
  domains: domains || [],
70
70
  powDifficulty: pow_difficulty,
71
- imageThreshold: image_threshold
71
+ imageThreshold: image_threshold,
72
+ disallowWebView: false
72
73
  });
73
74
  logger.info(() => ({
74
75
  data: { sitekey },
@@ -74,7 +74,8 @@ const commandSiteKeyRegisterApi = (pair, authAccount, config, cmdArgs) => {
74
74
  frictionlessThreshold: frictionless_threshold,
75
75
  domains: domains || [],
76
76
  powDifficulty: pow_difficulty,
77
- imageThreshold: image_threshold
77
+ imageThreshold: image_threshold,
78
+ disallowWebView: false
78
79
  },
79
80
  timestamp,
80
81
  signature
@@ -8,7 +8,7 @@ const keyring = require("@prosopo/keyring");
8
8
  const locale = require("@prosopo/locale");
9
9
  const provider = require("@prosopo/provider");
10
10
  const types = require("@prosopo/types");
11
- const userAccessPolicy = require("@prosopo/user-access-policy");
11
+ const api = require("@prosopo/user-access-policy/api");
12
12
  const cors = require("cors");
13
13
  const express = require("express");
14
14
  const rateLimit = require("express-rate-limit");
@@ -27,8 +27,9 @@ async function startApi(env2, admin = false, port) {
27
27
  const apiEndpointAdapter = apiExpressRouter.createApiExpressDefaultEndpointAdapter(
28
28
  common.parseLogLevel(env2.config.logLevel)
29
29
  );
30
- const apiRuleRoutesProvider = userAccessPolicy.createApiRuleRoutesProvider(
31
- env2.getDb().getUserAccessRulesStorage()
30
+ const apiRuleRoutesProvider = new api.AccessRuleApiRoutes(
31
+ env2.getDb().getUserAccessRulesStorage(),
32
+ env2.logger
32
33
  );
33
34
  const apiAdminRoutesProvider = provider.createApiAdminRoutesProvider(env2);
34
35
  const clientPathsExcludingVerify = getClientApiPathsExcludingVerify();
@@ -46,8 +47,8 @@ async function startApi(env2, admin = false, port) {
46
47
  apiApp.use(apiExpressRouter.requestLoggerMiddleware(env2));
47
48
  apiApp.use(i18Middleware);
48
49
  apiApp.use(provider.ja4Middleware(env2));
49
- apiApp.use(provider.prosopoVerifyRouter(env2));
50
50
  apiApp.use(clientPathsExcludingVerify, provider.headerCheckMiddleware(env2));
51
+ apiApp.use(provider.prosopoVerifyRouter(env2));
51
52
  env2.logger.info(() => ({ msg: "Enabling admin auth middleware" }));
52
53
  apiApp.use(
53
54
  "/v1/prosopo/provider/admin",
@@ -57,11 +58,8 @@ async function startApi(env2, admin = false, port) {
57
58
  apiApp.use("/v1/prosopo/provider/client/", provider.domainMiddleware(env2));
58
59
  apiApp.use(provider.prosopoRouter(env2));
59
60
  const userAccessRuleRoutes = apiRuleRoutesProvider.getRoutes();
60
- for (const userAccessRuleRoute of userAccessRuleRoutes) {
61
- apiApp.use(
62
- userAccessRuleRoute.path,
63
- apiExpressRouter.authMiddleware(env2.pair, env2.authAccount)
64
- );
61
+ for (const userAccessRuleRoute in userAccessRuleRoutes) {
62
+ apiApp.use(userAccessRuleRoute, apiExpressRouter.authMiddleware(env2.pair, env2.authAccount));
65
63
  }
66
64
  apiApp.use(
67
65
  apiExpressRouter.apiExpressRouterFactory.createRouter(
@@ -80,7 +78,7 @@ async function startApi(env2, admin = false, port) {
80
78
  )
81
79
  );
82
80
  const configRateLimits = env2.config.rateLimits;
83
- const rateLimits = { ...configRateLimits, ...userAccessPolicy.getExpressApiRuleRateLimits() };
81
+ const rateLimits = { ...configRateLimits, ...api.getExpressApiRuleRateLimits() };
84
82
  for (const [path, limit] of Object.entries(rateLimits)) {
85
83
  const enumPath = path;
86
84
  apiApp.use(enumPath, rateLimit(limit));
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js CHANGED
@@ -11,15 +11,6 @@ const log = getLogger(LogLevel.enum.info, "CLI");
11
11
  async function main() {
12
12
  const envPath = loadEnv();
13
13
  const config = getConfig();
14
- if (config.devOnlyWatchEvents) {
15
- log.warn(() => ({
16
- msg: `
17
- ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
18
- EVENT TRACKING ON. IF NOT DEVELOPMENT, PLEASE STOP, CHANGE THE ENVIRONMENT, AND RESTART
19
- ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
20
- `
21
- }));
22
- }
23
14
  const pair = getPair(config.account.secret, config.account.address);
24
15
  const authAccount = getPair(
25
16
  config.authAccount.secret,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAaA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,MAAM,GAAG,GA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AC,GAAG,EAAE,UAAU,CAAC,EAAE,CAAC;IACzC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QAC3B,IAAI,EAAE;aACJ,IAAI,CAAC,GAAG,EAAE;YACV,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,yBAAyB,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChB,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Logger } from "@prosopo/common";
2
+ import type { KeyringPair } from "@prosopo/types";
3
+ import type { ProsopoConfigOutput } from "@prosopo/types";
4
+ declare const _default: (pair: KeyringPair, config: ProsopoConfigOutput, cmdArgs?: {
5
+ logger?: Logger;
6
+ }) => {
7
+ command: string;
8
+ describe: string;
9
+ handler: () => Promise<void>;
10
+ middlewares: never[];
11
+ };
12
+ export default _default;
13
+ //# sourceMappingURL=ensureExternalIndexes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureExternalIndexes.d.ts","sourceRoot":"","sources":["../../src/commands/ensureExternalIndexes.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,KAAK,MAAM,EAAa,MAAM,iBAAiB,CAAC;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;+BAGnD,WAAW,UACT,mBAAmB,YACjB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;AAH9B,wBAgCE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureExternalIndexes.js","sourceRoot":"","sources":["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AC;QACF,CAAC;QACD,WAAW,EAAE,EAAE;KACf,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Logger } from "@prosopo/common";
2
+ import type { KeyringPair } from "@prosopo/types";
3
+ import type { ProsopoConfigOutput } from "@prosopo/types";
4
+ declare const _default: (pair: KeyringPair, config: ProsopoConfigOutput, cmdArgs?: {
5
+ logger?: Logger;
6
+ }) => {
7
+ command: string;
8
+ describe: string;
9
+ handler: () => Promise<void>;
10
+ middlewares: never[];
11
+ };
12
+ export default _default;
13
+ //# sourceMappingURL=ensureIndexes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureIndexes.d.ts","sourceRoot":"","sources":["../../src/commands/ensureIndexes.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,KAAK,MAAM,EAAa,MAAM,iBAAiB,CAAC;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;+BAGnD,WAAW,UACT,mBAAmB,YACjB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;AAH9B,wBA0BE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureIndexes.js","sourceRoot":"","sources":["../../src/commands/ensureIndexes.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI1C,eAAe,CACd,IAAiB,EACjB,MAA2B,EAC3B,OAA6B,EAC5B,EAAE;IACH,MAAM,MAAM,GACX,OAAO,EAAE,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IAExE,OAAO;QACN,OAAO,EAAE,gBAAgB;QACzB,QAAQ,EAAE,sCAAsC;QAChD,OAAO,EAAE,KAAK,IAAI,EAAE;YACnB,IAAI,CAAC;gBACJ,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAClD,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;gBACpB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC7B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;oBACjC,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;gBACtD,CAAC;gBACD,MAAM,KAAK,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YAChC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;QACD,WAAW,EAAE,EAAE;KACf,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { default as commandProviderSetDataset } from "./providerSetDataset.js";
2
+ export { default as commandStoreCaptchasExternally } from "./storeCaptchasExternally.js";
3
+ export { default as commandVersion } from "./version.js";
4
+ export { default as commandSiteKeyRegister } from "./siteKeyRegister.js";
5
+ export { default as commandSiteKeyRegisterApi } from "./siteKeyRegisterApi.js";
6
+ export { default as commandEnsureExternalIndexes } from "./ensureExternalIndexes.js";
7
+ export { default as commandEnsureIndexes } from "./ensureIndexes.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Logger } from "@prosopo/common";
2
+ import type { KeyringPair, ProsopoConfigOutput } from "@prosopo/types";
3
+ import type { Db } from "mongodb";
4
+ export declare const getDb: (pair: KeyringPair, config: ProsopoConfigOutput, uri: string, logger: Logger) => Promise<Db>;
5
+ //# sourceMappingURL=getDb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDb.d.ts","sourceRoot":"","sources":["../../../src/commands/migrateIpInCaptchaRecords/getDb.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAGlC,eAAO,MAAM,KAAK,SACX,WAAW,UACT,mBAAmB,OACtB,MAAM,UACH,MAAM,KACZ,OAAO,CAAC,EAAE,CAsBZ,CAAC"}
@@ -1,32 +1,31 @@
1
1
  import { ProviderEnvironment } from "@prosopo/env";
2
2
  import mongoose from "mongoose";
3
- const getDb = async (pair, config, uri, logger) => {
4
- let db;
5
- if (uri) {
6
- logger.info(() => ({
7
- msg: "Using DB connection from the URI"
8
- }));
9
- db = await getByUri(uri);
10
- } else {
11
- logger.info(() => ({
12
- msg: "Using DB connection from the config"
13
- }));
14
- db = await getByConfig(pair, config);
15
- }
16
- if (db) {
17
- return db;
18
- }
19
- throw new Error("Db connection cannot be established");
3
+ export const getDb = async (pair, config, uri, logger) => {
4
+ let db;
5
+ if (uri) {
6
+ logger.info(() => ({
7
+ msg: "Using DB connection from the URI",
8
+ }));
9
+ db = await getByUri(uri);
10
+ }
11
+ else {
12
+ logger.info(() => ({
13
+ msg: "Using DB connection from the config",
14
+ }));
15
+ db = await getByConfig(pair, config);
16
+ }
17
+ if (db) {
18
+ return db;
19
+ }
20
+ throw new Error("Db connection cannot be established");
20
21
  };
21
22
  const getByUri = async (uri) => {
22
- await mongoose.connect(uri);
23
- return mongoose.connection.db;
23
+ await mongoose.connect(uri);
24
+ return mongoose.connection.db;
24
25
  };
25
26
  const getByConfig = async (pair, config) => {
26
- const env = new ProviderEnvironment(config, pair);
27
- await env.isReady();
28
- return env.db?.getConnection()?.db;
29
- };
30
- export {
31
- getDb
27
+ const env = new ProviderEnvironment(config, pair);
28
+ await env.isReady();
29
+ return env.db?.getConnection()?.db;
32
30
  };
31
+ //# sourceMappingURL=getDb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDb.js","sourceRoot":"","sources":["../../../src/commands/migrateIpInCaptchaRecords/get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0,0 +1,4 @@
1
+ import type { Logger } from "@prosopo/common";
2
+ import { type Db } from "mongodb";
3
+ export declare const migrateIpField: (db: Db, collectionsToUpgrade: string[], logger: Logger) => Promise<void>;
4
+ //# sourceMappingURL=migrateIpField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateIpField.d.ts","sourceRoot":"","sources":["../../../src/commands/migrateIpInCaptchaRecords/migrateIpField.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAI9C,OAAO,EAAE,KAAK,EAAE,EAAc,MAAM,SAAS,CAAC;AAK9C,eAAO,MAAM,cAAc,OACtB,EAAE,wBACgB,MAAM,EAAE,UACtB,MAAM,kBAMd,CAAC"}
@@ -3,96 +3,104 @@ import { IpAddressType } from "@prosopo/types-database";
3
3
  import { Address6 } from "ip-address";
4
4
  import { Decimal128 } from "mongodb";
5
5
  const MAX_IPV4_NUMERIC = 4294967295;
6
- const BATCH_SIZE = 1e5;
7
- const migrateIpField = async (db, collectionsToUpgrade, logger) => {
8
- for (const collection of collectionsToUpgrade) {
9
- await migrateV4Records(db, collection, logger);
10
- await migrateV6Records(db, collection, logger);
11
- }
6
+ const BATCH_SIZE = 100_000;
7
+ export const migrateIpField = async (db, collectionsToUpgrade, logger) => {
8
+ for (const collection of collectionsToUpgrade) {
9
+ await migrateV4Records(db, collection, logger);
10
+ await migrateV6Records(db, collection, logger);
11
+ }
12
12
  };
13
13
  const migrateV4Records = async (db, collection, logger) => {
14
- const searchArgs = {
15
- ipAddress: {
16
- $type: "number",
17
- $lte: Number(MAX_IPV4_NUMERIC)
14
+ const searchArgs = {
15
+ ipAddress: {
16
+ $type: "number",
17
+ $lte: Number(MAX_IPV4_NUMERIC),
18
+ },
19
+ };
20
+ let totalModified = 0;
21
+ let processed = 0;
22
+ const count = await db.collection(collection).countDocuments(searchArgs);
23
+ while (true) {
24
+ const docs = await db
25
+ .collection(collection)
26
+ .find(searchArgs, { projection: { ipAddress: 1 } })
27
+ .limit(BATCH_SIZE)
28
+ .toArray();
29
+ if (docs.length === 0)
30
+ break;
31
+ const operations = docs.map((doc) => ({
32
+ updateOne: {
33
+ filter: { _id: doc._id },
34
+ update: {
35
+ $set: {
36
+ ipAddress: {
37
+ lower: doc.ipAddress,
38
+ type: IpAddressType.v4,
39
+ },
40
+ },
41
+ },
42
+ },
43
+ }));
44
+ const bulkResult = await db
45
+ .collection(collection)
46
+ .bulkWrite(operations, { ordered: false });
47
+ totalModified += bulkResult?.modifiedCount || 0;
48
+ processed += docs.length;
49
+ logger.info(() => ({
50
+ msg: `Migrated v4 batch (${docs.length}) [${processed}/${count}] in "${collection}"`,
51
+ }));
18
52
  }
19
- };
20
- let totalModified = 0;
21
- let processed = 0;
22
- const count = await db.collection(collection).countDocuments(searchArgs);
23
- while (true) {
24
- const docs = await db.collection(collection).find(searchArgs, { projection: { ipAddress: 1 } }).limit(BATCH_SIZE).toArray();
25
- if (docs.length === 0) break;
26
- const operations = docs.map((doc) => ({
27
- updateOne: {
28
- filter: { _id: doc._id },
29
- update: {
30
- $set: {
31
- ipAddress: {
32
- lower: doc.ipAddress,
33
- type: IpAddressType.v4
34
- }
35
- }
36
- }
37
- }
38
- }));
39
- const bulkResult = await db.collection(collection).bulkWrite(operations, { ordered: false });
40
- totalModified += bulkResult?.modifiedCount || 0;
41
- processed += docs.length;
42
53
  logger.info(() => ({
43
- msg: `Migrated v4 batch (${docs.length}) [${processed}/${count}] in "${collection}"`
54
+ msg: `Migrated ${count} v4 records (${totalModified} modified) in "${collection}" collection`,
44
55
  }));
45
- }
46
- logger.info(() => ({
47
- msg: `Migrated ${count} v4 records (${totalModified} modified) in "${collection}" collection`
48
- }));
49
56
  };
50
57
  const migrateV6Records = async (db, collection, logger) => {
51
- const searchArgs = {
52
- ipAddress: {
53
- $type: "number",
54
- $gt: Number(MAX_IPV4_NUMERIC)
58
+ const searchArgs = {
59
+ ipAddress: {
60
+ $type: "number",
61
+ $gt: Number(MAX_IPV4_NUMERIC),
62
+ },
63
+ };
64
+ let totalModified = 0;
65
+ let processed = 0;
66
+ const count = await db.collection(collection).countDocuments(searchArgs);
67
+ while (true) {
68
+ const docs = await db
69
+ .collection(collection)
70
+ .find(searchArgs, { projection: { ipAddress: 1 } })
71
+ .limit(BATCH_SIZE)
72
+ .toArray();
73
+ if (docs.length === 0)
74
+ break;
75
+ const operations = docs.map((doc) => {
76
+ const ipAddress = Address6.fromBigInt(BigInt(doc.ipAddress));
77
+ const compositeIpAddress = getCompositeIpAddress(ipAddress);
78
+ return {
79
+ updateOne: {
80
+ filter: { _id: doc._id },
81
+ update: {
82
+ $set: {
83
+ ipAddress: {
84
+ lower: Decimal128.fromString(compositeIpAddress.lower.toString()),
85
+ upper: Decimal128.fromString((compositeIpAddress.upper || 0n).toString()),
86
+ type: IpAddressType.v6,
87
+ },
88
+ },
89
+ },
90
+ },
91
+ };
92
+ });
93
+ const bulkResult = await db
94
+ .collection(collection)
95
+ .bulkWrite(operations, { ordered: false });
96
+ totalModified += bulkResult?.modifiedCount || 0;
97
+ processed += docs.length;
98
+ logger.info(() => ({
99
+ msg: `Migrated v6 batch (${docs.length}) [${processed}/${count}] in "${collection}"`,
100
+ }));
55
101
  }
56
- };
57
- let totalModified = 0;
58
- let processed = 0;
59
- const count = await db.collection(collection).countDocuments(searchArgs);
60
- while (true) {
61
- const docs = await db.collection(collection).find(searchArgs, { projection: { ipAddress: 1 } }).limit(BATCH_SIZE).toArray();
62
- if (docs.length === 0) break;
63
- const operations = docs.map((doc) => {
64
- const ipAddress = Address6.fromBigInt(BigInt(doc.ipAddress));
65
- const compositeIpAddress = getCompositeIpAddress(ipAddress);
66
- return {
67
- updateOne: {
68
- filter: { _id: doc._id },
69
- update: {
70
- $set: {
71
- ipAddress: {
72
- lower: Decimal128.fromString(
73
- compositeIpAddress.lower.toString()
74
- ),
75
- upper: Decimal128.fromString(
76
- (compositeIpAddress.upper || 0n).toString()
77
- ),
78
- type: IpAddressType.v6
79
- }
80
- }
81
- }
82
- }
83
- };
84
- });
85
- const bulkResult = await db.collection(collection).bulkWrite(operations, { ordered: false });
86
- totalModified += bulkResult?.modifiedCount || 0;
87
- processed += docs.length;
88
102
  logger.info(() => ({
89
- msg: `Migrated v6 batch (${docs.length}) [${processed}/${count}] in "${collection}"`
103
+ msg: `Migrated ${count} v6 records (${totalModified} modified) in "${collection}"`,
90
104
  }));
91
- }
92
- logger.info(() => ({
93
- msg: `Migrated ${count} v6 records (${totalModified} modified) in "${collection}"`
94
- }));
95
- };
96
- export {
97
- migrateIpField
98
105
  };
106
+ //# sourceMappingURL=migrateIpField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateIpField.js","sourceRoot":"","sources":["../../../src/commands/migrateIpInCaptchaRecords/migrateIpField.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAW,UAAU,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,gBAAgB,GAAG,UAAU,CAAC;AACpC,MAAM,UAAU,GAAG,OAAO,CAAC;AAE3B,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAClC,EAAM,EACN,oBAA8B,EAC9B,MAAc,EACb,EAAE;IACH,KAAK,MAAM,UAAU,IAAI,oBAAoB,EAAE,CAAC;QAC/C,MAAM,gBAAgB,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QAC/C,MAAM,gBAAgB,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,KAAK,EAAE,EAAM,EAAE,UAAkB,EAAE,MAAc,EAAE,EAAE;IAC7E,MAAM,UAAU,GAAG;QAClB,SAAS,EAAE;YACV,K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E;oBACxB,MAAM,EAAE;wBACP,IAAI,EAAE;4BACL,SAAS,EAAE;gCACV,KAAK,EAAE,UAAU,CAAC,UAAU,CAC3B,kBAAkB,CAAC,KAAK,CAAC,QAAQ,EAAE,CACnC;gCACD,KAAK,EAAE,UAAU,CAAC,UAAU,CAC3B,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAC3C;gCACD,IAAI,EAAE,aAAa,CAAC,EAAE;6BACtB;yBACD;qBACD;iBACD;aACD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,MAAM,EAAE;aACzB,UAAU,CAAC,UAAU,CAAC;aACtB,SAAS,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAE5C,aAAa,IAAI,UAAU,EAAE,aAAa,IAAI,CAAC,CAAC;QAChD,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC;QAEzB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YAClB,GAAG,EAAE,sBAAsB,IAAI,CAAC,MAAM,MAAM,SAAS,IAAI,KAAK,SAAS,UAAU,GAAG;SACpF,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAClB,GAAG,EAAE,YAAY,KAAK,gBAAgB,aAAa,kBAAkB,UAAU,GAAG;KAClF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type Logger } from "@prosopo/common";
2
+ import type { KeyringPair, ProsopoConfigOutput } from "@prosopo/types";
3
+ import type { CommandModule } from "yargs";
4
+ export declare const migrateIpInCaptchaRecordsCommand: (pair: KeyringPair, config: ProsopoConfigOutput, logger: Logger | undefined) => CommandModule;
5
+ //# sourceMappingURL=migrateIpInCaptchaRecords.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateIpInCaptchaRecords.d.ts","sourceRoot":"","sources":["../../../src/commands/migrateIpInCaptchaRecords/migrateIpInCaptchaRecords.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,KAAK,MAAM,EAAa,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAA4B,aAAa,EAAE,MAAM,OAAO,CAAC;AAYrE,eAAO,MAAM,gCAAgC,SACtC,WAAW,UACT,mBAAmB,UACnB,MAAM,GAAG,SAAS,KACxB,aAgCF,CAAC"}
@@ -1,39 +1,40 @@
1
- import { getLogger, LogLevel } from "@prosopo/common";
1
+ import { LogLevel, getLogger } from "@prosopo/common";
2
2
  import * as z from "zod";
3
3
  import { getDb } from "./getDb.js";
4
4
  import { migrateIpField } from "./migrateIpField.js";
5
5
  const collectionsToUpgrade = [
6
- "powcaptchas",
7
- "usercommitments",
8
- "frictionlesstokens",
9
- "pendings"
6
+ "powcaptchas",
7
+ "usercommitments",
8
+ "frictionlesstokens",
9
+ "pendings",
10
10
  ];
11
- const migrateIpInCaptchaRecordsCommand = (pair, config, logger) => {
12
- logger = logger || getLogger(LogLevel.enum.info, "cli.migrate_ip_in_captcha_records");
13
- return {
14
- command: "migrateIpInCaptchaRecords",
15
- describe: "Migrate IP addresses in captcha records",
16
- builder: (yargs) => yargs.option("uri", {
17
- type: "string",
18
- desc: "DB Uri. When skipped, used the default connection based on the current environment"
19
- }),
20
- handler: async (argv) => {
21
- const uri = z.string().parse(argv.uri || "");
22
- try {
23
- const db = await getDb(pair, config, uri, logger);
24
- await migrateIpField(db, collectionsToUpgrade, logger);
25
- logger.info(() => ({
26
- msg: "migration completed"
27
- }));
28
- } catch (err) {
29
- logger.error(() => ({
30
- err,
31
- msg: "Error migrating captcha records"
32
- }));
33
- }
34
- }
35
- };
36
- };
37
- export {
38
- migrateIpInCaptchaRecordsCommand
11
+ export const migrateIpInCaptchaRecordsCommand = (pair, config, logger) => {
12
+ logger =
13
+ logger ||
14
+ getLogger(LogLevel.enum.info, "cli.migrate_ip_in_captcha_records");
15
+ return {
16
+ command: "migrateIpInCaptchaRecords",
17
+ describe: "Migrate IP addresses in captcha records",
18
+ builder: (yargs) => yargs.option("uri", {
19
+ type: "string",
20
+ desc: "DB Uri. When skipped, used the default connection based on the current environment",
21
+ }),
22
+ handler: async (argv) => {
23
+ const uri = z.string().parse(argv.uri || "");
24
+ try {
25
+ const db = await getDb(pair, config, uri, logger);
26
+ await migrateIpField(db, collectionsToUpgrade, logger);
27
+ logger.info(() => ({
28
+ msg: "migration completed",
29
+ }));
30
+ }
31
+ catch (err) {
32
+ logger.error(() => ({
33
+ err,
34
+ msg: "Error migrating captcha records",
35
+ }));
36
+ }
37
+ },
38
+ };
39
39
  };
40
+ //# sourceMappingURL=migrateIpInCaptchaRecords.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateIpInCaptchaRecords.js","sourceRoot":"","sources":["../../../src/commands/migrateIpInCaptchaRecords/migrateIpInCaptchaRecords.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGnE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,oBAAoB,GAAG;IAC5B,aAAa;IACb,iBAAiB;IACjB,oBAAoB;IACpB,UAAU;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAC/C,IAAiB,EACjB,MAA2B,EAC3B,MAA0B,EACV,EAAE;IAClB,MAAM;QACL,MAAM;YACN,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,mCAAmC,CAAC,CAAC;IAEpE,OAAO;QACN,OAAO,EAAE,2BAA2B;QACpC,QAAQ,EAAE,yCAAyC;QACnD,OAAO,EAAE,CAAC,KAAW,EAAE,EAAE,CACxB,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;YACnB,IAAI,EAAE,QAAiB;YACvB,IAAI,EAAE,oFAAoF;SACjF,CAAC;QACZ,OAAO,EAAE,KAAK,EAAE,IAAwB,EAAE,EAAE;YAC3C,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;YAE7C,IAAI,CAAC;gBACJ,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;gBAElD,MAAM,cAAc,CAAC,EAAE,EAAE,oBAAoB,EAAE,MAAM,CAAC,CAAC;gBAEvD,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;oBAClB,GAAG,EAAE,qBAAqB;iBAC1B,CAAC,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;oBACnB,GAAG;oBACH,GAAG,EAAE,iCAAiC;iBACtC,CAAC,CAAC,CAAC;YACL,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type Logger } from "@prosopo/common";
2
+ import type { KeyringPair } from "@prosopo/types";
3
+ import type { ProsopoConfigOutput } from "@prosopo/types";
4
+ import type { ArgumentsCamelCase, Argv } from "yargs";
5
+ declare const _default: (pair: KeyringPair, config: ProsopoConfigOutput, cmdArgs?: {
6
+ logger?: Logger;
7
+ }) => {
8
+ command: string;
9
+ describe: string;
10
+ builder: (yargs: Argv) => Argv<{
11
+ file: string;
12
+ }>;
13
+ handler: (argv: ArgumentsCamelCase) => Promise<void>;
14
+ middlewares: never[];
15
+ };
16
+ export default _default;
17
+ //# sourceMappingURL=providerSetDataset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerSetDataset.d.ts","sourceRoot":"","sources":["../../src/commands/providerSetDataset.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,KAAK,MAAM,EAAa,MAAM,iBAAiB,CAAC;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;+BAK/C,WAAW,UACT,mBAAmB,YACjB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;qBASX,IAAI;;;oBAMC,kBAAkB;;;AAlB1C,wBA4CE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerSetDataset.js","sourceRoot":"","sources":["../../src/commands/providerSetDataset.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI1C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,eAAe,CACd,IAAiB,EACjB,MAA2B,EAC3B,OAA6B,EAC5B,EAAE;IACH,MAAM,MAAM,GACX,OAAO,EAAE,MAAM;QACf,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,2BAA2B,CAAC,CAAC;IAE5D,OAAO;QACN,OAAO,EAAE,uBAAuB;QAChC,QAAQ,EAAE,6BAA6B;QACvC,OAAO,EAAE,CAAC,KAAW,EAAE,EAAE,CACxB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;YACpB,IAAI,EAAE,QAAiB;YACvB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,sCAAsC;SACnC,CAAC;QACZ,OAAO,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