UNPKG

@privy-io/js-sdk-core

Version:

Vanilla JS client for the Privy Auth API

2 lines (1 loc) 812 B
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@privy-io/public-api"),r=require("../Token.js");require("jose");class t{async updateOnCrossAppAuthentication(e,r){let s=r.access_token,i=t.providerAccessTokenStorageKey(e);await this._storage.put(i,s)}async getProviderAccessToken(e){let s=t.providerAccessTokenStorageKey(e),i=await this._storage.get(s);if("string"!=typeof i)return null;try{if(new r.Token(i).isExpired())throw Error("JWT is expired");return i}catch{return await this._storage.del(s),null}}async getCrossAppConnections(){return await this._privyInternal.fetch(e.GetCrossAppConnections,{params:{app_id:this._privyInternal.appId}})}constructor(e,r){this._privyInternal=e,this._storage=r}}t.providerAccessTokenStorageKey=e=>`privy:cross-app:${e}`,exports.default=t;