@effectstream/frontend-sdk 0.104.1 → 0.200.2
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/mod.js +26 -12
- package/package.json +2 -2
package/dist/mod.js
CHANGED
|
@@ -18974,14 +18974,22 @@ class MidnightCrypto {
|
|
|
18974
18974
|
if (!signature || !verifyingKey)
|
|
18975
18975
|
return false;
|
|
18976
18976
|
const [ledgerMod, addrMod] = await Promise.all([
|
|
18977
|
-
import("@
|
|
18977
|
+
import("@midnightntwrk/ledger-v9"),
|
|
18978
18978
|
import("@midnightntwrk/wallet-sdk-address-format")
|
|
18979
18979
|
]);
|
|
18980
|
-
const
|
|
18980
|
+
const taggedVerifyingKey = {
|
|
18981
|
+
tag: "schnorr",
|
|
18982
|
+
value: verifyingKey
|
|
18983
|
+
};
|
|
18984
|
+
const taggedSignature = {
|
|
18985
|
+
tag: "schnorr",
|
|
18986
|
+
value: signature
|
|
18987
|
+
};
|
|
18988
|
+
const expectedHexAddress = ledgerMod.addressFromKey(taggedVerifyingKey).toLowerCase();
|
|
18981
18989
|
let decodedHex;
|
|
18982
18990
|
try {
|
|
18983
18991
|
const bech323 = addrMod.MidnightBech32m.parse(signerAddress);
|
|
18984
|
-
const decoded =
|
|
18992
|
+
const decoded = bech323.decode(addrMod.UnshieldedAddress, bech323.network);
|
|
18985
18993
|
decodedHex = decoded.hexString.toLowerCase();
|
|
18986
18994
|
} catch {
|
|
18987
18995
|
return false;
|
|
@@ -18989,7 +18997,7 @@ class MidnightCrypto {
|
|
|
18989
18997
|
if (decodedHex !== expectedHexAddress)
|
|
18990
18998
|
return false;
|
|
18991
18999
|
const messageBytes = new TextEncoder().encode(message);
|
|
18992
|
-
return ledgerMod.verifySignature(
|
|
19000
|
+
return ledgerMod.verifySignature(taggedVerifyingKey, messageBytes, taggedSignature);
|
|
18993
19001
|
} catch (err) {
|
|
18994
19002
|
console.error("[MidnightCrypto] error verifying signature:", err);
|
|
18995
19003
|
return false;
|
|
@@ -20604,16 +20612,16 @@ class MidnightLocalConnector {
|
|
|
20604
20612
|
const { hdMod, keystoreMod } = await loadKeystoreDeps();
|
|
20605
20613
|
const seed = args.seed ?? generateRandomHexSeed(32);
|
|
20606
20614
|
const unshieldedSeed = deriveUnshieldedSeed(hdMod, seed, hdMod.Roles.NightExternal);
|
|
20607
|
-
const unshieldedKeystore = keystoreMod.createKeystore(unshieldedSeed, args.networkId);
|
|
20615
|
+
const unshieldedKeystore = keystoreMod.createKeystore({ kind: "schnorr", secret: unshieldedSeed }, args.networkId);
|
|
20608
20616
|
const unshieldedAddress = unshieldedKeystore.getBech32Address().asString();
|
|
20609
|
-
const verifyingKey =
|
|
20617
|
+
const verifyingKey = schnorrValue(unshieldedKeystore.getPublicKey(), "verifying key");
|
|
20610
20618
|
const api = {
|
|
20611
20619
|
signData: async (data, options) => {
|
|
20612
20620
|
const bytes = options.encoding === "hex" ? Buffer2.from(data, "hex") : Buffer2.from(data, "utf-8");
|
|
20613
|
-
const signature = unshieldedKeystore.signData(bytes);
|
|
20621
|
+
const signature = schnorrValue(unshieldedKeystore.signData(bytes), "signature");
|
|
20614
20622
|
return {
|
|
20615
20623
|
data,
|
|
20616
|
-
signature
|
|
20624
|
+
signature,
|
|
20617
20625
|
verifyingKey
|
|
20618
20626
|
};
|
|
20619
20627
|
},
|
|
@@ -20641,8 +20649,8 @@ class MidnightLocalConnector {
|
|
|
20641
20649
|
const { hdMod, keystoreMod } = await loadKeystoreDeps();
|
|
20642
20650
|
const seed = args.seed ?? generateRandomHexSeed(32);
|
|
20643
20651
|
const unshieldedSeed = deriveUnshieldedSeed(hdMod, seed, hdMod.Roles.NightExternal);
|
|
20644
|
-
const unshieldedKeystore = keystoreMod.createKeystore(unshieldedSeed, args.networkId);
|
|
20645
|
-
const verifyingKey =
|
|
20652
|
+
const unshieldedKeystore = keystoreMod.createKeystore({ kind: "schnorr", secret: unshieldedSeed }, args.networkId);
|
|
20653
|
+
const verifyingKey = schnorrValue(unshieldedKeystore.getPublicKey(), "verifying key");
|
|
20646
20654
|
const fullNetworkUrls = {
|
|
20647
20655
|
indexer: networkUrls.indexer,
|
|
20648
20656
|
indexerWS: networkUrls.indexerWS,
|
|
@@ -20657,10 +20665,10 @@ class MidnightLocalConnector {
|
|
|
20657
20665
|
const api = {
|
|
20658
20666
|
signData: async (data, options) => {
|
|
20659
20667
|
const bytes = options.encoding === "hex" ? Buffer2.from(data, "hex") : Buffer2.from(data, "utf-8");
|
|
20660
|
-
const signature = unshieldedKeystore.signData(bytes);
|
|
20668
|
+
const signature = schnorrValue(unshieldedKeystore.signData(bytes), "signature");
|
|
20661
20669
|
return {
|
|
20662
20670
|
data,
|
|
20663
|
-
signature
|
|
20671
|
+
signature,
|
|
20664
20672
|
verifyingKey
|
|
20665
20673
|
};
|
|
20666
20674
|
},
|
|
@@ -20752,6 +20760,12 @@ function generateRandomHexSeed(byteLength2) {
|
|
|
20752
20760
|
crypto.getRandomValues(bytes);
|
|
20753
20761
|
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
20754
20762
|
}
|
|
20763
|
+
function schnorrValue(value, label) {
|
|
20764
|
+
if (value.tag !== "schnorr") {
|
|
20765
|
+
throw new Error(`Expected Schnorr ${label}, received ${value.tag}`);
|
|
20766
|
+
}
|
|
20767
|
+
return value.value;
|
|
20768
|
+
}
|
|
20755
20769
|
|
|
20756
20770
|
// ../effectstream-sdk/wallets/src/solana/solana.ts
|
|
20757
20771
|
import { getWallets } from "@wallet-standard/app";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effectstream/frontend-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.200.2",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"homepage": "https://effectstream.github.io/docs/",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"build": "bun run build.ts"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@effectstream/wallets": "0.
|
|
32
|
+
"@effectstream/wallets": "0.200.2"
|
|
33
33
|
},
|
|
34
34
|
"description": "React frontend SDK for EffectStream"
|
|
35
35
|
}
|