@privy-io/js-sdk-core
Version:
Vanilla JS client for the Privy Auth API
2 lines (1 loc) • 1.06 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@privy-io/routes");exports.default=class{async link(t,n,i,s){await this._privyInternal.fetch(e.SiweLinkSmartWallet,{body:{message:t,signature:n,smart_wallet_type:i,smart_wallet_version:s}});let r=await this._privyInternal.refreshSession();return{user:r.user,identity_token:r.identity_token}}async init(t){var n;let{nonce:i}=await this._privyInternal.fetch(e.SiweInit,{body:{address:t.address}});return{nonce:i,message:`${(n={chainId:t.chainId.toString().replace("eip155:",""),address:t.address,issuedAt:(new Date).toISOString(),statement:"By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",domain:"privy.io",uri:"https://auth.privy.io",nonce:i}).domain} wants you to sign in with your Ethereum account:\n${n.address}\n\n${n.statement}\n\nURI: ${n.uri}\nVersion: 1\nChain ID: ${n.chainId}\nNonce: ${n.nonce}\nIssued At: ${n.issuedAt}\nResources:\n- https://privy.io`}}constructor(e){this._privyInternal=e}};