@settlemint/sdk-cli 1.1.3-pr1b1672e8 → 1.1.3-pr5ebbdf33

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-pr1b1672e8",
274465
+ version: "1.1.3-pr5ebbdf33",
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-pr1b1672e8",
274514
- "@settlemint/sdk-utils": "1.1.3-pr1b1672e8",
274513
+ "@settlemint/sdk-js": "1.1.3-pr5ebbdf33",
274514
+ "@settlemint/sdk-utils": "1.1.3-pr5ebbdf33",
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,47 @@ 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/${nodeId}/${userWalletAddress}/verifications`, {
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
+ throw new Error("Failed to handle challenge");
276585
+ }
276586
+ const verificationChallenges = await response.json();
276587
+ if (!verificationChallenges.length) {
276588
+ throw new Error("No verification challenges received");
276589
+ }
276590
+ const firstChallenge = verificationChallenges[0];
276591
+ const challenge = firstChallenge?.challenge;
276592
+ if (!challenge?.secret || !challenge?.salt) {
276593
+ throw new Error("Could not authenticate pin code, invalid challenge format");
276594
+ }
276595
+ const { secret, salt } = challenge;
276596
+ return generateChallengeResponse(pincode, salt, secret);
276597
+ }
276555
276598
  var graphql = initGraphQLTada();
276556
276599
  var WorkspaceFragment = graphql(`
276557
276600
  fragment Workspace on Workspace {
@@ -277852,50 +277895,6 @@ var ClientOptionsSchema = z.object({
277852
277895
  accessToken: AccessTokenSchema2,
277853
277896
  instance: UrlSchema2
277854
277897
  });
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
277898
  function createSettleMintClient(options) {
277900
277899
  ensureServer();
277901
277900
  const validatedOptions = options.anonymous ? validate2(z.object({
@@ -277995,7 +277994,7 @@ function createSettleMintClient(options) {
277995
277994
  config: getPlatformConfig(gqlClient)
277996
277995
  },
277997
277996
  wallet: {
277998
- pincodeVerificationResponse: (args) => getPincodeVerificationResponse({
277997
+ handleChallenge: (args) => handleChallenge({
277999
277998
  ...args,
278000
277999
  instance: validatedOptions.instance,
278001
278000
  accessToken: validatedOptions.accessToken
@@ -282158,6 +282157,11 @@ function logoutCommand() {
282158
282157
  });
282159
282158
  }
282160
282159
 
282160
+ // src/commands/platform/common/cluster-service.args.ts
282161
+ function addClusterServiceArgs(cmd2) {
282162
+ 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"));
282163
+ }
282164
+
282161
282165
  // src/constants/resource-type.ts
282162
282166
  var SETTLEMINT_CLIENT_MAP = {
282163
282167
  application: "application",
@@ -282194,71 +282198,6 @@ var LABELS_MAP = {
282194
282198
  }
282195
282199
  };
282196
282200
 
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.length !== 6) {
282242
- return "Pincode must be 6 digits";
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
282201
  // src/commands/platform/utils/wait-for-completion.ts
282263
282202
  class TimeoutError extends Error {
282264
282203
  }
@@ -282888,6 +282827,16 @@ async function blockchainNetworkPrompt({
282888
282827
  });
282889
282828
  }
282890
282829
 
282830
+ // src/spinners/service.spinner.ts
282831
+ async function serviceSpinner(type4, task) {
282832
+ const { plural } = LABELS_MAP[type4];
282833
+ return spinner({
282834
+ startMessage: `Loading ${plural} services`,
282835
+ stopMessage: `Loaded ${plural} services`,
282836
+ task
282837
+ });
282838
+ }
282839
+
282891
282840
  // src/commands/platform/blockchain-node/besu/create.ts
282892
282841
  function blockchainNodeBesuCreateCommand() {
282893
282842
  return getCreateCommand({
@@ -284164,7 +284113,7 @@ function applicationsListCommand() {
284164
284113
  });
284165
284114
  if (printToTerminal) {
284166
284115
  const selectedWorkspace = await settlemint.workspace.read(workspaceUniqueName);
284167
- table(`Applications for workspace ${selectedWorkspace.name} (${selectedWorkspace.uniqueName}) - ${getWorkspaceUrl(selectedInstance, selectedWorkspace)}`, applicationsData);
284116
+ table(`Applications for workspace ${selectedWorkspace.name} (${selectedWorkspace}) - ${getWorkspaceUrl(selectedInstance, selectedWorkspace)}`, applicationsData);
284168
284117
  } else if (output === "json") {
284169
284118
  jsonOutput(applicationsData);
284170
284119
  } else if (output === "yaml") {
@@ -285376,6 +285325,56 @@ function smartContractSetCommand() {
285376
285325
  return new Command("smart-contract-set").alias("scs").description("Manage smart contract sets and subgraphs").addCommand(createCommand4()).addCommand(foundry).addCommand(hardhat).addCommand(subgraph);
285377
285326
  }
285378
285327
 
285328
+ // src/commands/verification-challenge.ts
285329
+ function verificationChallengeCommand() {
285330
+ 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 }) => {
285331
+ intro("Generating verification challenge for wallet address");
285332
+ const env2 = await loadEnv(false, false);
285333
+ const applicationUniqueName = env2.SETTLEMINT_APPLICATION;
285334
+ if (!applicationUniqueName) {
285335
+ return missingApplication();
285336
+ }
285337
+ const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(env2, true);
285338
+ const personalAccessToken = await getInstanceCredentials(selectedInstance);
285339
+ if (!personalAccessToken) {
285340
+ return missingPersonalAccessTokenError();
285341
+ }
285342
+ const settlemint = createSettleMintClient({
285343
+ accessToken: personalAccessToken.personalAccessToken,
285344
+ instance: selectedInstance
285345
+ });
285346
+ const blockchainNodes = await serviceSpinner("blockchain node", () => settlemint.blockchainNode.list(applicationUniqueName));
285347
+ let selectedBlockchainNode = blockchainNode ? blockchainNodes.find((node) => node.uniqueName === blockchainNode) : undefined;
285348
+ if (!selectedBlockchainNode) {
285349
+ selectedBlockchainNode = await blockchainNodePrompt({
285350
+ env: env2,
285351
+ nodes: blockchainNodes,
285352
+ accept: true,
285353
+ isRequired: true
285354
+ });
285355
+ if (!selectedBlockchainNode) {
285356
+ return nothingSelectedError("blockchain node");
285357
+ }
285358
+ }
285359
+ const pincode = await esm_default5({
285360
+ message: "Enter your pincode",
285361
+ validate(value4) {
285362
+ if (value4.length !== 6) {
285363
+ return "Pincode must be 6 digits";
285364
+ }
285365
+ return true;
285366
+ }
285367
+ });
285368
+ const challengeResponse = await settlemint.wallet.handleChallenge({
285369
+ userWalletAddress: walletAddress,
285370
+ pincode,
285371
+ nodeId: selectedBlockchainNode.id
285372
+ });
285373
+ note(`Challenge response: ${challengeResponse}`);
285374
+ outro("Verification challenge generated");
285375
+ });
285376
+ }
285377
+
285379
285378
  // src/commands/index.ts
285380
285379
  function getCommandPath(command) {
285381
285380
  const parts = [];
@@ -285464,7 +285463,7 @@ function registerCommands() {
285464
285463
  sdkcli.addCommand(createCommand2());
285465
285464
  sdkcli.addCommand(loginCommand());
285466
285465
  sdkcli.addCommand(logoutCommand());
285467
- sdkcli.addCommand(pincodeVerificationResponseCommand());
285466
+ sdkcli.addCommand(verificationChallengeCommand());
285468
285467
  return sdkcli;
285469
285468
  }
285470
285469
  async function sdkCliCommand(argv = process.argv) {
@@ -285484,4 +285483,4 @@ async function sdkCliCommand(argv = process.argv) {
285484
285483
  // src/cli.ts
285485
285484
  sdkCliCommand();
285486
285485
 
285487
- //# debugId=51EB421484775DD264756E2164756E21
285486
+ //# debugId=3A9ED6D85F1F5DF464756E2164756E21