@settlemint/sdk-cli 1.1.3-prb2a0e155 → 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 +112 -7
- package/dist/cli.js.map +8 -7
- package/package.json +4 -4
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-
|
274465
|
+
version: "1.1.3-prf5602d46",
|
274466
274466
|
type: "module",
|
274467
274467
|
private: false,
|
274468
274468
|
license: "FSL-1.1-MIT",
|
@@ -274510,9 +274510,9 @@ 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-
|
274514
|
-
"@settlemint/sdk-utils": "1.1.3-
|
274515
|
-
"@types/node": "22.13.
|
274513
|
+
"@settlemint/sdk-js": "1.1.3-prf5602d46",
|
274514
|
+
"@settlemint/sdk-utils": "1.1.3-prf5602d46",
|
274515
|
+
"@types/node": "22.13.1",
|
274516
274516
|
"@types/semver": "7.5.8",
|
274517
274517
|
"@types/which": "3.0.4",
|
274518
274518
|
"get-tsconfig": "4.10.0",
|
@@ -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,6 +276554,50 @@ function initGraphQLTada() {
|
|
276551
276554
|
var t2 = initGraphQLTada();
|
276552
276555
|
|
276553
276556
|
// ../js/dist/settlemint.mjs
|
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
|
+
}
|
276554
276601
|
var graphql = initGraphQLTada();
|
276555
276602
|
var WorkspaceFragment = graphql(`
|
276556
276603
|
fragment Workspace on Workspace {
|
@@ -277948,6 +277995,13 @@ function createSettleMintClient(options) {
|
|
277948
277995
|
},
|
277949
277996
|
platform: {
|
277950
277997
|
config: getPlatformConfig(gqlClient)
|
277998
|
+
},
|
277999
|
+
wallet: {
|
278000
|
+
handleChallenge: (args) => handleChallenge({
|
278001
|
+
...args,
|
278002
|
+
instance: validatedOptions.instance,
|
278003
|
+
accessToken: validatedOptions.accessToken
|
278004
|
+
})
|
277951
278005
|
}
|
277952
278006
|
};
|
277953
278007
|
}
|
@@ -282159,7 +282213,7 @@ async function waitForCompletion({
|
|
282159
282213
|
restartIfTimeout = false
|
282160
282214
|
}) {
|
282161
282215
|
const serviceType = SETTLEMINT_CLIENT_MAP[type4];
|
282162
|
-
if (serviceType === "workspace" || serviceType === "application" || serviceType === "foundry" || serviceType === "applicationAccessToken" || serviceType === "platform") {
|
282216
|
+
if (serviceType === "workspace" || serviceType === "application" || serviceType === "foundry" || serviceType === "applicationAccessToken" || serviceType === "platform" || serviceType === "wallet") {
|
282163
282217
|
return true;
|
282164
282218
|
}
|
282165
282219
|
const service = settlemint[serviceType];
|
@@ -284062,7 +284116,7 @@ function applicationsListCommand() {
|
|
284062
284116
|
});
|
284063
284117
|
if (printToTerminal) {
|
284064
284118
|
const selectedWorkspace = await settlemint.workspace.read(workspaceUniqueName);
|
284065
|
-
table(`Applications for workspace ${selectedWorkspace.name} (${selectedWorkspace}) - ${getWorkspaceUrl(selectedInstance, selectedWorkspace)}`, applicationsData);
|
284119
|
+
table(`Applications for workspace ${selectedWorkspace.name} (${selectedWorkspace.uniqueName}) - ${getWorkspaceUrl(selectedInstance, selectedWorkspace)}`, applicationsData);
|
284066
284120
|
} else if (output === "json") {
|
284067
284121
|
jsonOutput(applicationsData);
|
284068
284122
|
} else if (output === "yaml") {
|
@@ -285274,6 +285328,56 @@ function smartContractSetCommand() {
|
|
285274
285328
|
return new Command("smart-contract-set").alias("scs").description("Manage smart contract sets and subgraphs").addCommand(createCommand4()).addCommand(foundry).addCommand(hardhat).addCommand(subgraph);
|
285275
285329
|
}
|
285276
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
|
+
|
285277
285381
|
// src/commands/index.ts
|
285278
285382
|
function getCommandPath(command) {
|
285279
285383
|
const parts = [];
|
@@ -285362,6 +285466,7 @@ function registerCommands() {
|
|
285362
285466
|
sdkcli.addCommand(createCommand2());
|
285363
285467
|
sdkcli.addCommand(loginCommand());
|
285364
285468
|
sdkcli.addCommand(logoutCommand());
|
285469
|
+
sdkcli.addCommand(verificationChallengeCommand());
|
285365
285470
|
return sdkcli;
|
285366
285471
|
}
|
285367
285472
|
async function sdkCliCommand(argv = process.argv) {
|
@@ -285381,4 +285486,4 @@ async function sdkCliCommand(argv = process.argv) {
|
|
285381
285486
|
// src/cli.ts
|
285382
285487
|
sdkCliCommand();
|
285383
285488
|
|
285384
|
-
//# debugId=
|
285489
|
+
//# debugId=4F025B50624C3CBA64756E2164756E21
|