@privy-io/js-sdk-core
Version:
Vanilla JS client for the Privy Auth API
2 lines (1 loc) • 747 B
JavaScript
import{GetCrossAppConnections as r}from"@privy-io/routes";import{Token as e}from"../Token.mjs";import"jose";class t{async updateOnCrossAppAuthentication(r,e){let s=e.access_token,o=t.providerAccessTokenStorageKey(r);await this._storage.put(o,s)}async getProviderAccessToken(r){let s=t.providerAccessTokenStorageKey(r),o=await this._storage.get(s);if("string"!=typeof o)return null;try{if(new e(o).isExpired())throw Error("JWT is expired");return o}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};