UNPKG

@kinde-oss/kinde-auth-react

Version:

Kinde React SDK for authentication

2 lines (1 loc) 1.27 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-Cex2voa3.cjs");let a;async function o(){let n=0;for(;!a&&n<20;)await new Promise(e=>setTimeout(e,100)),n++}class c extends r.A{constructor(){super(),this.loadExpoStore()}async loadExpoStore(){try{a=await Promise.resolve().then(()=>require("./js-utils-CDTLCo61.cjs"))}catch(e){console.error("Error loading dependency expo storage:",e)}}async destroySession(){Object.values(r.a).forEach(async e=>{await this.removeSessionItem(e)})}async setSessionItem(e,t){if(await o(),await this.removeSessionItem(e),typeof t=="string"){r.b(t,Math.min(r.c.maxLength,2048)).forEach(async(s,i)=>{await a.setItemAsync(`${r.c.keyPrefix}${e}${i}`,s)});return}else throw new Error("Item value must be a string")}async getSessionItem(e){await o();const t=[];let s=0,i=await a.getItemAsync(`${r.c.keyPrefix}${String(e)}${s}`);for(;i;)t.push(i),s++,i=await a.getItemAsync(`${r.c.keyPrefix}${String(e)}${s}`);return t.join("")||null}async removeSessionItem(e){await o();let t=0,s=await a.getItemAsync(`${r.c.keyPrefix}${String(e)}${t}`);for(;s;)await a.deleteItemAsync(`${r.c.keyPrefix}${String(e)}${t}`),t++,s=await a.getItemAsync(`${r.c.keyPrefix}${String(e)}${t}`)}}exports.ExpoSecureStore=c;