@settlemint/sdk-js 2.1.2 → 2.1.3-pree605c2a
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/README.md +18 -18
- package/dist/settlemint.cjs +13 -17
- package/dist/settlemint.cjs.map +1 -1
- package/dist/settlemint.d.cts +15 -4
- package/dist/settlemint.d.ts +15 -4
- package/dist/settlemint.mjs +13 -17
- package/dist/settlemint.mjs.map +1 -1
- package/package.json +2 -2
package/dist/settlemint.d.ts
CHANGED
|
@@ -31418,13 +31418,23 @@ declare const ClientOptionsSchema: z.ZodObject<{
|
|
|
31418
31418
|
*/
|
|
31419
31419
|
type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
31420
31420
|
|
|
31421
|
-
interface
|
|
31421
|
+
interface PincodeVerificationChallengesArgs {
|
|
31422
31422
|
userWalletAddress: string;
|
|
31423
|
-
pincode: string;
|
|
31424
31423
|
accessToken: string;
|
|
31425
31424
|
instance: string;
|
|
31426
31425
|
nodeId: string;
|
|
31427
31426
|
}
|
|
31427
|
+
interface PincodeVerificationChallengeResponseArgs {
|
|
31428
|
+
verificationChallenge: VerificationChallenge;
|
|
31429
|
+
pincode: string;
|
|
31430
|
+
}
|
|
31431
|
+
interface VerificationChallenge {
|
|
31432
|
+
name: string;
|
|
31433
|
+
challenge: {
|
|
31434
|
+
secret: string;
|
|
31435
|
+
salt: string;
|
|
31436
|
+
};
|
|
31437
|
+
}
|
|
31428
31438
|
|
|
31429
31439
|
/**
|
|
31430
31440
|
* Options for the Settlemint client.
|
|
@@ -31511,7 +31521,8 @@ interface SettlemintClient {
|
|
|
31511
31521
|
config: () => Promise<PlatformConfig>;
|
|
31512
31522
|
};
|
|
31513
31523
|
wallet: {
|
|
31514
|
-
|
|
31524
|
+
pincodeVerificationChallengeResponse: (args: PincodeVerificationChallengeResponseArgs) => string;
|
|
31525
|
+
pincodeVerificationChallenges: (args: Omit<PincodeVerificationChallengesArgs, "instance" | "accessToken">) => Promise<VerificationChallenge[]>;
|
|
31515
31526
|
};
|
|
31516
31527
|
}
|
|
31517
31528
|
/**
|
|
@@ -31540,4 +31551,4 @@ interface SettlemintClient {
|
|
|
31540
31551
|
*/
|
|
31541
31552
|
declare function createSettleMintClient(options: SettlemintClientOptions): SettlemintClient;
|
|
31542
31553
|
|
|
31543
|
-
export { type Application, type BlockchainNetwork, type BlockchainNode, type CustomDeployment, type Insights, type IntegrationTool, type Middleware, type MiddlewareWithSubgraphs, type PlatformConfig, type PrivateKey, type SettlemintClient, type SettlemintClientOptions, type Storage, type Workspace, createSettleMintClient };
|
|
31554
|
+
export { type Application, type BlockchainNetwork, type BlockchainNode, type CustomDeployment, type Insights, type IntegrationTool, type Middleware, type MiddlewareWithSubgraphs, type PlatformConfig, type PrivateKey, type SettlemintClient, type SettlemintClientOptions, type Storage, type VerificationChallenge, type Workspace, createSettleMintClient };
|
package/dist/settlemint.mjs
CHANGED
|
@@ -1522,26 +1522,20 @@ function generateResponse(pincode, salt, challenge) {
|
|
|
1522
1522
|
const hashedPincode = hashPincode(pincode, salt);
|
|
1523
1523
|
return createHash("sha256").update(`${hashedPincode}_${challenge}`).digest("hex");
|
|
1524
1524
|
}
|
|
1525
|
-
async function
|
|
1525
|
+
async function getPincodeVerificationChallenges({
|
|
1526
1526
|
userWalletAddress,
|
|
1527
|
-
pincode,
|
|
1528
1527
|
accessToken,
|
|
1529
1528
|
instance,
|
|
1530
1529
|
nodeId
|
|
1531
1530
|
}) {
|
|
1532
1531
|
const response = await fetch(
|
|
1533
|
-
`${instance}/cm/nodes/${encodeURIComponent(nodeId)}/user-wallets/${encodeURIComponent(userWalletAddress)}/verifications/challenges`,
|
|
1532
|
+
`${instance}/cm/nodes/${encodeURIComponent(nodeId)}/user-wallets/${encodeURIComponent(userWalletAddress)}/verifications/challenges?type=PINCODE`,
|
|
1534
1533
|
{
|
|
1535
1534
|
method: "POST",
|
|
1536
1535
|
headers: {
|
|
1537
1536
|
"Content-Type": "application/json",
|
|
1538
1537
|
"x-auth-token": accessToken
|
|
1539
|
-
}
|
|
1540
|
-
body: JSON.stringify({
|
|
1541
|
-
pincode,
|
|
1542
|
-
verificationType: "PINCODE",
|
|
1543
|
-
name: "pincode"
|
|
1544
|
-
})
|
|
1538
|
+
}
|
|
1545
1539
|
}
|
|
1546
1540
|
);
|
|
1547
1541
|
if (!response.ok) {
|
|
@@ -1551,15 +1545,16 @@ async function getPincodeVerificationResponse({
|
|
|
1551
1545
|
throw new Error("Failed to get verification challenge");
|
|
1552
1546
|
}
|
|
1553
1547
|
const verificationChallenges = await response.json();
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1548
|
+
return verificationChallenges;
|
|
1549
|
+
}
|
|
1550
|
+
function getPincodeVerificationChallengeResponse({
|
|
1551
|
+
verificationChallenge,
|
|
1552
|
+
pincode
|
|
1553
|
+
}) {
|
|
1554
|
+
if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt) {
|
|
1560
1555
|
throw new Error("Could not authenticate pin code, invalid challenge format");
|
|
1561
1556
|
}
|
|
1562
|
-
const { secret, salt } = challenge;
|
|
1557
|
+
const { secret, salt } = verificationChallenge.challenge;
|
|
1563
1558
|
return generateResponse(pincode, salt, secret);
|
|
1564
1559
|
}
|
|
1565
1560
|
|
|
@@ -1666,7 +1661,8 @@ function createSettleMintClient(options) {
|
|
|
1666
1661
|
config: getPlatformConfig(gqlClient)
|
|
1667
1662
|
},
|
|
1668
1663
|
wallet: {
|
|
1669
|
-
|
|
1664
|
+
pincodeVerificationChallengeResponse: getPincodeVerificationChallengeResponse,
|
|
1665
|
+
pincodeVerificationChallenges: (args) => getPincodeVerificationChallenges({
|
|
1670
1666
|
...args,
|
|
1671
1667
|
instance: validatedOptions.instance,
|
|
1672
1668
|
accessToken: validatedOptions.accessToken
|