@settlemint/sdk-cli 1.1.3-prdba810bd → 1.1.3-prf5602d46

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/cli.js CHANGED
@@ -274462,7 +274462,7 @@ function pruneCurrentEnv(currentEnv, env2) {
274462
274462
  var package_default = {
274463
274463
  name: "@settlemint/sdk-cli",
274464
274464
  description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
274465
- version: "1.1.3-prdba810bd",
274465
+ version: "1.1.3-prf5602d46",
274466
274466
  type: "module",
274467
274467
  private: false,
274468
274468
  license: "FSL-1.1-MIT",
@@ -274510,8 +274510,8 @@ var package_default = {
274510
274510
  "@inquirer/input": "4.1.5",
274511
274511
  "@inquirer/password": "4.0.8",
274512
274512
  "@inquirer/select": "4.0.8",
274513
- "@settlemint/sdk-js": "1.1.3-prdba810bd",
274514
- "@settlemint/sdk-utils": "1.1.3-prdba810bd",
274513
+ "@settlemint/sdk-js": "1.1.3-prf5602d46",
274514
+ "@settlemint/sdk-utils": "1.1.3-prf5602d46",
274515
274515
  "@types/node": "22.13.1",
274516
274516
  "@types/semver": "7.5.8",
274517
274517
  "@types/which": "3.0.4",
@@ -276470,6 +276470,9 @@ var parseRequestArgs = (documentOrOptions, variables, requestHeaders) => {
276470
276470
  signal: undefined
276471
276471
  };
276472
276472
  };
276473
+ // ../js/dist/settlemint.mjs
276474
+ import { createHash } from "node:crypto";
276475
+
276473
276476
  // ../../node_modules/gql.tada/dist/gql-tada.mjs
276474
276477
  init_graphql_web();
276475
276478
  var a2 = 0;
@@ -276551,7 +276554,50 @@ function initGraphQLTada() {
276551
276554
  var t2 = initGraphQLTada();
276552
276555
 
276553
276556
  // ../js/dist/settlemint.mjs
276554
- import { createHash } from "node:crypto";
276557
+ function hashPincode(pincode, salt) {
276558
+ return createHash("sha256").update(`${salt}${pincode}`).digest("hex");
276559
+ }
276560
+ function generateChallengeResponse(pincode, salt, challenge) {
276561
+ const hashedPincode = hashPincode(pincode, salt);
276562
+ return createHash("sha256").update(`${hashedPincode}_${challenge}`).digest("hex");
276563
+ }
276564
+ async function handleChallenge({
276565
+ userWalletAddress,
276566
+ pincode,
276567
+ accessToken,
276568
+ instance,
276569
+ nodeId
276570
+ }) {
276571
+ const response = await fetch(`${instance}/cm/nodes/${encodeURIComponent(nodeId)}/user-wallets/${encodeURIComponent(userWalletAddress)}/verifications/challenges`, {
276572
+ method: "POST",
276573
+ headers: {
276574
+ "Content-Type": "application/json",
276575
+ "x-auth-token": accessToken
276576
+ },
276577
+ body: JSON.stringify({
276578
+ pincode,
276579
+ verificationType: "PINCODE",
276580
+ name: "pincode"
276581
+ })
276582
+ });
276583
+ if (!response.ok) {
276584
+ if (response.status === 404) {
276585
+ throw new Error(`No user wallet found with address '${userWalletAddress}' for node '${nodeId}'`);
276586
+ }
276587
+ throw new Error("Failed to handle challenge");
276588
+ }
276589
+ const verificationChallenges = await response.json();
276590
+ if (!verificationChallenges.length) {
276591
+ throw new Error("No verification challenges received");
276592
+ }
276593
+ const firstChallenge = verificationChallenges[0];
276594
+ const challenge = firstChallenge?.challenge;
276595
+ if (!challenge?.secret || !challenge?.salt) {
276596
+ throw new Error("Could not authenticate pin code, invalid challenge format");
276597
+ }
276598
+ const { secret, salt } = challenge;
276599
+ return generateChallengeResponse(pincode, salt, secret);
276600
+ }
276555
276601
  var graphql = initGraphQLTada();
276556
276602
  var WorkspaceFragment = graphql(`
276557
276603
  fragment Workspace on Workspace {
@@ -277852,50 +277898,6 @@ var ClientOptionsSchema = z.object({
277852
277898
  accessToken: AccessTokenSchema2,
277853
277899
  instance: UrlSchema2
277854
277900
  });
277855
- function hashPincode(pincode, salt) {
277856
- return createHash("sha256").update(`${salt}${pincode}`).digest("hex");
277857
- }
277858
- function generateResponse(pincode, salt, challenge) {
277859
- const hashedPincode = hashPincode(pincode, salt);
277860
- return createHash("sha256").update(`${hashedPincode}_${challenge}`).digest("hex");
277861
- }
277862
- async function getPincodeVerificationResponse({
277863
- userWalletAddress,
277864
- pincode,
277865
- accessToken,
277866
- instance,
277867
- nodeId
277868
- }) {
277869
- const response = await fetch(`${instance}/cm/nodes/${encodeURIComponent(nodeId)}/user-wallets/${encodeURIComponent(userWalletAddress)}/verifications/challenges`, {
277870
- method: "POST",
277871
- headers: {
277872
- "Content-Type": "application/json",
277873
- "x-auth-token": accessToken
277874
- },
277875
- body: JSON.stringify({
277876
- pincode,
277877
- verificationType: "PINCODE",
277878
- name: "pincode"
277879
- })
277880
- });
277881
- if (!response.ok) {
277882
- if (response.status === 404) {
277883
- throw new Error(`No user wallet found with address '${userWalletAddress}' for node '${nodeId}'`);
277884
- }
277885
- throw new Error("Failed to get verification challenge");
277886
- }
277887
- const verificationChallenges = await response.json();
277888
- if (!verificationChallenges.length) {
277889
- throw new Error("No verification challenges received");
277890
- }
277891
- const firstChallenge = verificationChallenges[0];
277892
- const challenge = firstChallenge?.challenge;
277893
- if (!challenge?.secret || !challenge?.salt) {
277894
- throw new Error("Could not authenticate pin code, invalid challenge format");
277895
- }
277896
- const { secret, salt } = challenge;
277897
- return generateResponse(pincode, salt, secret);
277898
- }
277899
277901
  function createSettleMintClient(options) {
277900
277902
  ensureServer();
277901
277903
  const validatedOptions = options.anonymous ? validate2(z.object({
@@ -277995,7 +277997,7 @@ function createSettleMintClient(options) {
277995
277997
  config: getPlatformConfig(gqlClient)
277996
277998
  },
277997
277999
  wallet: {
277998
- pincodeVerificationResponse: (args) => getPincodeVerificationResponse({
278000
+ handleChallenge: (args) => handleChallenge({
277999
278001
  ...args,
278000
278002
  instance: validatedOptions.instance,
278001
278003
  accessToken: validatedOptions.accessToken
@@ -282158,6 +282160,11 @@ function logoutCommand() {
282158
282160
  });
282159
282161
  }
282160
282162
 
282163
+ // src/commands/platform/common/cluster-service.args.ts
282164
+ function addClusterServiceArgs(cmd2) {
282165
+ return cmd2.option("--provider <provider>", "Network provider (run `settlemint platform config` to see available providers)").option("--region <region>", "Deployment region (run `settlemint platform config` to see available regions)").addOption(new Option("--size <size>", "Network size").choices(["CUSTOM", "LARGE", "MEDIUM", "SMALL"]).argParser((value4) => value4).default("SMALL")).addOption(new Option("--type <type>", "Network type").choices(["DEDICATED", "SHARED"]).argParser((value4) => value4).default("SHARED"));
282166
+ }
282167
+
282161
282168
  // src/constants/resource-type.ts
282162
282169
  var SETTLEMINT_CLIENT_MAP = {
282163
282170
  application: "application",
@@ -282194,71 +282201,6 @@ var LABELS_MAP = {
282194
282201
  }
282195
282202
  };
282196
282203
 
282197
- // src/spinners/service.spinner.ts
282198
- async function serviceSpinner(type4, task) {
282199
- const { plural } = LABELS_MAP[type4];
282200
- return spinner({
282201
- startMessage: `Loading ${plural} services`,
282202
- stopMessage: `Loaded ${plural} services`,
282203
- task
282204
- });
282205
- }
282206
-
282207
- // src/commands/pincode-verification-response.ts
282208
- function pincodeVerificationResponseCommand() {
282209
- return new Command("pincode-verification-response").alias("pvr").description("Get pincode verification response for a blockchain node").requiredOption("--wallet-address <walletAddress>", "The wallet address to get pincode verification response for").option("-i, --instance <instance>", "The instance to connect to (defaults to the instance in the .env file)").option("--blockchain-node <blockchainNode>", "Blockchain Node unique name to get pincode verification response for").action(async ({ instance, blockchainNode, walletAddress }) => {
282210
- intro("Generating pincode verification response for wallet address");
282211
- const env2 = await loadEnv(false, false);
282212
- const applicationUniqueName = env2.SETTLEMINT_APPLICATION;
282213
- if (!applicationUniqueName) {
282214
- return missingApplication();
282215
- }
282216
- const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(env2, true);
282217
- const personalAccessToken = await getInstanceCredentials(selectedInstance);
282218
- if (!personalAccessToken) {
282219
- return missingPersonalAccessTokenError();
282220
- }
282221
- const settlemint = createSettleMintClient({
282222
- accessToken: personalAccessToken.personalAccessToken,
282223
- instance: selectedInstance
282224
- });
282225
- const blockchainNodes = await serviceSpinner("blockchain node", () => settlemint.blockchainNode.list(applicationUniqueName));
282226
- let selectedBlockchainNode = blockchainNode ? blockchainNodes.find((node) => node.uniqueName === blockchainNode) : undefined;
282227
- if (!selectedBlockchainNode) {
282228
- selectedBlockchainNode = await blockchainNodePrompt({
282229
- env: env2,
282230
- nodes: blockchainNodes,
282231
- accept: false,
282232
- isRequired: true
282233
- });
282234
- if (!selectedBlockchainNode) {
282235
- return nothingSelectedError("blockchain node");
282236
- }
282237
- }
282238
- const pincode = await esm_default5({
282239
- message: "Enter your pincode",
282240
- validate(value4) {
282241
- if (!value4.trim()) {
282242
- return "Pincode is required";
282243
- }
282244
- return true;
282245
- }
282246
- });
282247
- const pincodeVerificationResponse = await settlemint.wallet.pincodeVerificationResponse({
282248
- userWalletAddress: walletAddress,
282249
- pincode,
282250
- nodeId: selectedBlockchainNode.id
282251
- });
282252
- note(`Pincode verification response: ${pincodeVerificationResponse}`);
282253
- outro("Pincode verification response generated");
282254
- });
282255
- }
282256
-
282257
- // src/commands/platform/common/cluster-service.args.ts
282258
- function addClusterServiceArgs(cmd2) {
282259
- return cmd2.option("--provider <provider>", "Network provider (run `settlemint platform config` to see available providers)").option("--region <region>", "Deployment region (run `settlemint platform config` to see available regions)").addOption(new Option("--size <size>", "Network size").choices(["CUSTOM", "LARGE", "MEDIUM", "SMALL"]).argParser((value4) => value4).default("SMALL")).addOption(new Option("--type <type>", "Network type").choices(["DEDICATED", "SHARED"]).argParser((value4) => value4).default("SHARED"));
282260
- }
282261
-
282262
282204
  // src/commands/platform/utils/wait-for-completion.ts
282263
282205
  class TimeoutError extends Error {
282264
282206
  }
@@ -282888,6 +282830,16 @@ async function blockchainNetworkPrompt({
282888
282830
  });
282889
282831
  }
282890
282832
 
282833
+ // src/spinners/service.spinner.ts
282834
+ async function serviceSpinner(type4, task) {
282835
+ const { plural } = LABELS_MAP[type4];
282836
+ return spinner({
282837
+ startMessage: `Loading ${plural} services`,
282838
+ stopMessage: `Loaded ${plural} services`,
282839
+ task
282840
+ });
282841
+ }
282842
+
282891
282843
  // src/commands/platform/blockchain-node/besu/create.ts
282892
282844
  function blockchainNodeBesuCreateCommand() {
282893
282845
  return getCreateCommand({
@@ -285376,6 +285328,56 @@ function smartContractSetCommand() {
285376
285328
  return new Command("smart-contract-set").alias("scs").description("Manage smart contract sets and subgraphs").addCommand(createCommand4()).addCommand(foundry).addCommand(hardhat).addCommand(subgraph);
285377
285329
  }
285378
285330
 
285331
+ // src/commands/verification-challenge.ts
285332
+ function verificationChallengeCommand() {
285333
+ return new Command("verification-challenge").alias("vch").description("Get verification challenges for a blockchain node").requiredOption("--wallet-address <walletAddress>", "The wallet address to get verification challenges for").option("-i, --instance <instance>", "The instance to connect to (defaults to the instance in the .env file)").option("--blockchain-node <blockchainNode>", "Blockchain Node unique name to get verification challenges for").action(async ({ instance, blockchainNode, walletAddress }) => {
285334
+ intro("Generating verification challenge for wallet address");
285335
+ const env2 = await loadEnv(false, false);
285336
+ const applicationUniqueName = env2.SETTLEMINT_APPLICATION;
285337
+ if (!applicationUniqueName) {
285338
+ return missingApplication();
285339
+ }
285340
+ const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(env2, true);
285341
+ const personalAccessToken = await getInstanceCredentials(selectedInstance);
285342
+ if (!personalAccessToken) {
285343
+ return missingPersonalAccessTokenError();
285344
+ }
285345
+ const settlemint = createSettleMintClient({
285346
+ accessToken: personalAccessToken.personalAccessToken,
285347
+ instance: selectedInstance
285348
+ });
285349
+ const blockchainNodes = await serviceSpinner("blockchain node", () => settlemint.blockchainNode.list(applicationUniqueName));
285350
+ let selectedBlockchainNode = blockchainNode ? blockchainNodes.find((node) => node.uniqueName === blockchainNode) : undefined;
285351
+ if (!selectedBlockchainNode) {
285352
+ selectedBlockchainNode = await blockchainNodePrompt({
285353
+ env: env2,
285354
+ nodes: blockchainNodes,
285355
+ accept: false,
285356
+ isRequired: true
285357
+ });
285358
+ if (!selectedBlockchainNode) {
285359
+ return nothingSelectedError("blockchain node");
285360
+ }
285361
+ }
285362
+ const pincode = await esm_default5({
285363
+ message: "Enter your pincode",
285364
+ validate(value4) {
285365
+ if (value4.length !== 6) {
285366
+ return "Pincode must be 6 digits";
285367
+ }
285368
+ return true;
285369
+ }
285370
+ });
285371
+ const challengeResponse = await settlemint.wallet.handleChallenge({
285372
+ userWalletAddress: walletAddress,
285373
+ pincode,
285374
+ nodeId: selectedBlockchainNode.id
285375
+ });
285376
+ note(`Challenge response: ${challengeResponse}`);
285377
+ outro("Verification challenge generated");
285378
+ });
285379
+ }
285380
+
285379
285381
  // src/commands/index.ts
285380
285382
  function getCommandPath(command) {
285381
285383
  const parts = [];
@@ -285464,7 +285466,7 @@ function registerCommands() {
285464
285466
  sdkcli.addCommand(createCommand2());
285465
285467
  sdkcli.addCommand(loginCommand());
285466
285468
  sdkcli.addCommand(logoutCommand());
285467
- sdkcli.addCommand(pincodeVerificationResponseCommand());
285469
+ sdkcli.addCommand(verificationChallengeCommand());
285468
285470
  return sdkcli;
285469
285471
  }
285470
285472
  async function sdkCliCommand(argv = process.argv) {
@@ -285484,4 +285486,4 @@ async function sdkCliCommand(argv = process.argv) {
285484
285486
  // src/cli.ts
285485
285487
  sdkCliCommand();
285486
285488
 
285487
- //# debugId=565E7171A9162CE164756E2164756E21
285489
+ //# debugId=4F025B50624C3CBA64756E2164756E21