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