@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.
@@ -243,12 +243,21 @@ var SIWE_MESSAGE_VALIDITY_MS = 24 * 60 * 60 * 1e3;
243
243
  function buildSiweStatement(chainId) {
244
244
  return `Sign in to Privana on chain ${chainId}`;
245
245
  }
246
+ function pickSiweDomain(response) {
247
+ const allowed = response.domains;
248
+ if (!allowed?.length) throw new Error("SIWE domain response contains no domains");
249
+ const primary = allowed[0];
250
+ if (typeof window === "undefined" || !window.location?.host) return primary;
251
+ const host = window.location.host.toLowerCase();
252
+ return allowed.some((domain) => domain.toLowerCase() === host) ? host : primary;
253
+ }
246
254
  async function buildSiweLoginMessage(api, params) {
247
255
  const { address, chainId, apiUrl } = params;
248
- const [{ domain }, { nonce }] = await Promise.all([
256
+ const [domainResponse, { nonce }] = await Promise.all([
249
257
  api.getSiweDomain(),
250
258
  api.getSiweNonce(address)
251
259
  ]);
260
+ const domain = pickSiweDomain(domainResponse);
252
261
  const issuedAt = /* @__PURE__ */ new Date();
253
262
  const expirationTime = new Date(issuedAt.getTime() + SIWE_MESSAGE_VALIDITY_MS);
254
263
  const uri = typeof window !== "undefined" && window.location.origin ? window.location.origin : apiUrl;
@@ -582,7 +591,7 @@ var PrivanaClient = class _PrivanaClient {
582
591
  return this.http.get(`/v1/accounting/withdraw/${index}`);
583
592
  }
584
593
  async getSiweDomain() {
585
- return this.http.get("/v1/accounting/auth/domain");
594
+ return this.http.get("/v1/accounting/auth/domains");
586
595
  }
587
596
  async getSiweNonce(userAddress) {
588
597
  const user = normalizeAddress(userAddress);
@@ -6057,5 +6066,5 @@ function useTransakOnRamp(options) {
6057
6066
  }
6058
6067
 
6059
6068
  export { AccountingApiError, Button, DEFAULT_LOCK_DURATION_SECONDS, DEFAULT_ONRAMP_LOCK_BUFFER, FiatOnRampForm, HOSTED_AUTH_CLOCK_SKEW_MS, HostedAuthError, HostedAuthRequiredError, HostedAuthStateMismatchError, HttpClient, LOCK_TYPES, MODIFY_LOCK_TYPES, NETWORK_CONFIG, NetworkError, PostDepositLockError, PrivanaClient, PrivanaProvider, SUPPORTED_CHAINS, SiweAuthProvider, Skeleton, TRANSFER_LOCKED_TYPES, TRANSFER_TYPES, ValidationError, WITHDRAW_FROM_LOCK_TYPES, WITHDRAW_TYPES, applyLockBuffer, applyRefreshResponse, buildHostedAuthSession, buildSiweStatement, buttonVariants, canRetryOnRampVerification, canUseBrowserStorage, canUseSharedBrowserStorage, clampLockAmount, clearHostedAuthPendingTransaction, clearPendingLock, cn, createDomain, createHostedAuthPendingStorageKey, createHostedAuthState, createHostedAuthStorageKey, createLockExpiry, createPkceChallenge, createPkceVerifier, createProductOnRampFlowSnapshot, createProductOnRampOutcomeCallbacks, createSignedLockRequest, formatCountdown, formatTimeRemaining, formatTokenAmount, getAccountingContract, getApiUrl, getBlockNumber, getBrowserStorageItem, getChainById, getChainId, getExplorerAddressUrl, getExplorerLabel, getSharedBrowserStorageItem, getTransactionReceipt, getTransakMinimumTargetBaseUnits, getWalletClient3 as getWalletClient, isHostedAuthRefreshActive, isHostedAuthSessionActive, isMoonPayProductOnRamp, isSignedLockUsable, loadPendingLock, matchesFrozenOnRampToken, matchesOnRampTransaction, matchesProductOnRampScope, normalizeAddress, normalizeHex, parseHostedAuthCallback, parseTokenAmount, persistHostedAuthPendingTransaction, readHostedAuthPendingTransaction, readStoredHostedAuthSession, removeBrowserStorageItem, removeSharedBrowserStorageItem, requireDepositLockOwner, requireServiceAddress, resolveProductOnRamp, savePendingLock, setBrowserStorageItem, setSharedBrowserStorageItem, shortenAddress, signLockMessage, signModifyLockMessage, signTransferLockedMessage, signTransferMessage, signWithdrawFromLockMessage, signWithdrawMessage, stripHostedAuthCallbackParams, submitPendingLock, syncHostedAuthSessionToClient, useDepositVerification, useEnsureCorrectChain, useFiatOnRamp, usePrivanaContext, usePrivateReadRequest, useSafeAccount, useSafePrivanaContext, useSiweAuth, useTransakOnRamp, waitForTransactionReceipt };
6060
- //# sourceMappingURL=chunk-KUHXTCVW.js.map
6061
- //# sourceMappingURL=chunk-KUHXTCVW.js.map
6069
+ //# sourceMappingURL=chunk-OHSIARZ3.js.map
6070
+ //# sourceMappingURL=chunk-OHSIARZ3.js.map