@oasisprotocol/privana-sdk 0.5.11 → 0.6.0
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/{chunk-KUHXTCVW.js → chunk-OHSIARZ3.js} +13 -4
- package/dist/chunk-OHSIARZ3.js.map +1 -0
- package/dist/{chunk-4RHSKIPZ.cjs → chunk-VNECVPMU.cjs} +13 -4
- package/dist/chunk-VNECVPMU.cjs.map +1 -0
- package/dist/index.cjs +263 -263
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/on-ramp.cjs +5 -5
- package/dist/on-ramp.d.cts +2 -2
- package/dist/on-ramp.d.ts +2 -2
- package/dist/on-ramp.js +1 -1
- package/dist/{pending-lock-DIL2jCaT.d.cts → pending-lock-rsz1iwZ-.d.cts} +1 -1
- package/dist/{pending-lock-DIL2jCaT.d.ts → pending-lock-rsz1iwZ-.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-4RHSKIPZ.cjs.map +0 -1
- package/dist/chunk-KUHXTCVW.js.map +0 -1
|
@@ -245,12 +245,21 @@ var SIWE_MESSAGE_VALIDITY_MS = 24 * 60 * 60 * 1e3;
|
|
|
245
245
|
function buildSiweStatement(chainId) {
|
|
246
246
|
return `Sign in to Privana on chain ${chainId}`;
|
|
247
247
|
}
|
|
248
|
+
function pickSiweDomain(response) {
|
|
249
|
+
const allowed = response.domains;
|
|
250
|
+
if (!allowed?.length) throw new Error("SIWE domain response contains no domains");
|
|
251
|
+
const primary = allowed[0];
|
|
252
|
+
if (typeof window === "undefined" || !window.location?.host) return primary;
|
|
253
|
+
const host = window.location.host.toLowerCase();
|
|
254
|
+
return allowed.some((domain) => domain.toLowerCase() === host) ? host : primary;
|
|
255
|
+
}
|
|
248
256
|
async function buildSiweLoginMessage(api, params) {
|
|
249
257
|
const { address, chainId, apiUrl } = params;
|
|
250
|
-
const [
|
|
258
|
+
const [domainResponse, { nonce }] = await Promise.all([
|
|
251
259
|
api.getSiweDomain(),
|
|
252
260
|
api.getSiweNonce(address)
|
|
253
261
|
]);
|
|
262
|
+
const domain = pickSiweDomain(domainResponse);
|
|
254
263
|
const issuedAt = /* @__PURE__ */ new Date();
|
|
255
264
|
const expirationTime = new Date(issuedAt.getTime() + SIWE_MESSAGE_VALIDITY_MS);
|
|
256
265
|
const uri = typeof window !== "undefined" && window.location.origin ? window.location.origin : apiUrl;
|
|
@@ -584,7 +593,7 @@ var PrivanaClient = class _PrivanaClient {
|
|
|
584
593
|
return this.http.get(`/v1/accounting/withdraw/${index}`);
|
|
585
594
|
}
|
|
586
595
|
async getSiweDomain() {
|
|
587
|
-
return this.http.get("/v1/accounting/auth/
|
|
596
|
+
return this.http.get("/v1/accounting/auth/domains");
|
|
588
597
|
}
|
|
589
598
|
async getSiweNonce(userAddress) {
|
|
590
599
|
const user = normalizeAddress(userAddress);
|
|
@@ -6163,5 +6172,5 @@ exports.useSafePrivanaContext = useSafePrivanaContext;
|
|
|
6163
6172
|
exports.useSiweAuth = useSiweAuth;
|
|
6164
6173
|
exports.useTransakOnRamp = useTransakOnRamp;
|
|
6165
6174
|
exports.waitForTransactionReceipt = waitForTransactionReceipt;
|
|
6166
|
-
//# sourceMappingURL=chunk-
|
|
6167
|
-
//# sourceMappingURL=chunk-
|
|
6175
|
+
//# sourceMappingURL=chunk-VNECVPMU.cjs.map
|
|
6176
|
+
//# sourceMappingURL=chunk-VNECVPMU.cjs.map
|