@privy-io/js-sdk-core
Version:
Vanilla JS client for the Privy Auth API
2 lines (1 loc) • 751 B
JavaScript
import{GetCrossAppConnections as r}from"@privy-io/public-api";import{Token as e}from"../Token.mjs";import"jose";class t{async updateOnCrossAppAuthentication(r,e){let s=e.access_token,i=t.providerAccessTokenStorageKey(r);await this._storage.put(i,s)}async getProviderAccessToken(r){let s=t.providerAccessTokenStorageKey(r),i=await this._storage.get(s);if("string"!=typeof i)return null;try{if(new e(i).isExpired())throw Error("JWT is expired");return i}catch{return await this._storage.del(s),null}}async getCrossAppConnections(){return await this._privyInternal.fetch(r,{params:{app_id:this._privyInternal.appId}})}constructor(r,e){this._privyInternal=r,this._storage=e}}t.providerAccessTokenStorageKey=r=>`privy:cross-app:${r}`;export{t as default};