@rhea-finance/confidential-swap 0.3.5 → 0.3.6
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/index.cjs +14 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -600,6 +600,17 @@ function validateSigned(unsigned, signed, identity) {
|
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
// src/api.ts
|
|
603
|
+
function toMultiPayload(data) {
|
|
604
|
+
if (data.standard !== "tip191") return data;
|
|
605
|
+
if (data.signature.startsWith("secp256k1:")) {
|
|
606
|
+
const bytes2 = import_base4.base58.decode(data.signature.slice("secp256k1:".length));
|
|
607
|
+
responseAssert(bytes2.length === 65 && bytes2[64] <= 1, "Invalid TIP-191 signature.");
|
|
608
|
+
return data;
|
|
609
|
+
}
|
|
610
|
+
const bytes = import_base4.base16.decode(normalizeSecpSignature(data.signature).slice(2).toUpperCase());
|
|
611
|
+
bytes[64] = bytes[64] - 27;
|
|
612
|
+
return { ...data, signature: `secp256k1:${import_base4.base58.encode(bytes)}` };
|
|
613
|
+
}
|
|
603
614
|
function record(value) {
|
|
604
615
|
responseAssert(value && typeof value === "object" && !Array.isArray(value), "Expected an object response.");
|
|
605
616
|
return value;
|
|
@@ -724,7 +735,7 @@ var HttpConfidentialApi = class {
|
|
|
724
735
|
return { accessToken: r.accessToken, refreshToken, expiresAt: this.now() + r.expiresIn * 1e3, refreshExpiresAt };
|
|
725
736
|
}
|
|
726
737
|
async authenticate(data, signal) {
|
|
727
|
-
return this.session(await this.request(`${this.proxy}/auth/authenticate`, "POST", { signedData: data }, void 0, signal));
|
|
738
|
+
return this.session(await this.request(`${this.proxy}/auth/authenticate`, "POST", { signedData: toMultiPayload(data) }, void 0, signal));
|
|
728
739
|
}
|
|
729
740
|
async refresh(session, signal) {
|
|
730
741
|
return this.session(await this.request(`${this.proxy}/auth/refresh`, "POST", { refreshToken: session.refreshToken }, void 0, signal), session);
|
|
@@ -790,7 +801,7 @@ var HttpConfidentialApi = class {
|
|
|
790
801
|
return data.intent;
|
|
791
802
|
}
|
|
792
803
|
async submitIntent(signedData, signal) {
|
|
793
|
-
const data = record(await this.request(`${this.proxy}/submit-intent`, "POST", { type: "swap_transfer", signedData }, void 0, signal));
|
|
804
|
+
const data = record(await this.request(`${this.proxy}/submit-intent`, "POST", { type: "swap_transfer", signedData: toMultiPayload(signedData) }, void 0, signal));
|
|
794
805
|
return text(data.intentHash, "Intent hash");
|
|
795
806
|
}
|
|
796
807
|
async privateRequest(path, method, body, token, signal) {
|
|
@@ -806,7 +817,7 @@ var HttpConfidentialApi = class {
|
|
|
806
817
|
const data = record(await this.privateRequest(
|
|
807
818
|
"withdraws",
|
|
808
819
|
"POST",
|
|
809
|
-
request,
|
|
820
|
+
{ ...request, withdraws: request.withdraws.map((row) => ({ ...row, signed_payload: toMultiPayload(row.signed_payload) })) },
|
|
810
821
|
this.config.withdrawAuthorization === "bearer" ? token : void 0,
|
|
811
822
|
signal
|
|
812
823
|
));
|