UNPKG

expo-ii-integration

Version:

Expo library to enable smartphone native applications to invoke Internet Identity through a web application

36 lines (33 loc) 23.3 kB
"use strict";var pt=Object.defineProperty;var yt=(a,r,o)=>r in a?pt(a,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[r]=o;var K=(a,r,o)=>yt(a,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),ee=require("@dfinity/agent"),U=require("@dfinity/identity"),mt=require("expo-web-browser"),Et=require("expo-linking"),bt=require("expo-router");function wt(a){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const o in a)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(a,o);Object.defineProperty(r,o,s.get?s:{enumerable:!0,get:()=>a[o]})}}return r.default=a,Object.freeze(r)}const Fe=wt(mt);class Rt{constructor({dfxNetwork:r,localIPAddress:o,replicaPort:s=4943,canisterPort:g=14943,internetIdentityPort:u=24943}){this.getBackendCanisterURL=d=>{var y,v;return this.dfxNetwork!=="local"?`https://${d}.ic0.app/`:(v=(y=window==null?void 0:window.location)==null?void 0:y.origin)!=null&&v.includes("localhost")?`http://localhost:${this.replicaPort}/?canisterId=${d}`:`https://${this.localIPAddress}:${this.canisterPort}/?canisterId=${d}`},this.getFrontendCanisterURL=d=>this.dfxNetwork!=="local"?`https://${d}.icp0.io/`:this.isLocalhostSubdomainSupported()?this.getLocalhostSubdomainCanisterURL(d):`https://${this.localIPAddress}:${this.canisterPort}/?canisterId=${d}`,this.getInternetIdentityURL=d=>this.dfxNetwork!=="local"?"https://identity.ic0.app/":this.isLocalhostSubdomainSupported()?this.getLocalhostSubdomainCanisterURL(d):`https://${this.localIPAddress}:${this.internetIdentityPort}/?canisterId=${d}`,this.isLocalhostSubdomainSupported=()=>{var d,y,v,_;return(y=(d=window==null?void 0:window.location)==null?void 0:d.origin)!=null&&y.includes("localhost")?!!(((_=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)==null?void 0:_.toLowerCase())||"").includes("chrome"):!1},this.getLocalhostSubdomainCanisterURL=d=>`http://${d}.localhost:${this.replicaPort}/`,this.createActor=({canisterId:d,interfaceFactory:y,identity:v=new ee.AnonymousIdentity})=>{const _=this.getBackendCanisterURL(d),w={host:_,identity:v},b=new ee.HttpAgent(w);return this.dfxNetwork==="local"&&b.fetchRootKey().catch(I=>{throw console.warn(`Your local replica is not running: ${_}`),console.error(I),I}),ee.Actor.createActor(y,{agent:b,canisterId:d})},this.dfxNetwork=r,this.localIPAddress=o,this.replicaPort=s,this.canisterPort=g,this.internetIdentityPort=u}}class _t extends Error{constructor(r,o){var s;super(`Expected origin ${r}, got ${o}`),this.expectedOrigin=r,this.actualOrigin=o,this.name="OriginMismatchError",(s=Error.captureStackTrace)==null||s.call(Error,this,this.constructor)}}class It{constructor(r=console.error){this.handlers={},this.errorFunc=r}on(r,o){return this.handlers[r]=o,this}handleEvent(r){const o=r.data;if(this.isValidMessageData(o)){const s=this.handlers[o.kind];s?s(o):console.warn(`No handler registered for message kind: ${o.kind}`)}else console.warn("Invalid message format:",o)}isValidMessageData(r){if(!r||typeof r!="object")return!1;const o=r;return"kind"in r&&typeof o.kind=="string"}async open({url:r}){const o=new URL(r);this.close(),this.setupEventHandler(o);const s=document.createElement("div");s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.width="100%",s.style.height="100%",s.style.backgroundColor="rgba(0, 0, 0, 0.5)",s.style.zIndex="2147483646",s.style.display="flex",s.style.justifyContent="center",s.style.alignItems="center";const g=document.createElement("div");g.style.position="relative",g.style.width="400px",g.style.height="600px",this.iframe=document.createElement("iframe"),this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none",this.iframe.style.borderRadius="8px",this.iframe.style.backgroundColor="white",this.iframe.src=o.toString();const u=document.createElement("button");u.textContent="×",u.style.position="absolute",u.style.top="-16px",u.style.right="-16px",u.style.fontSize="24px",u.style.width="32px",u.style.height="32px",u.style.border="none",u.style.borderRadius="50%",u.style.background="white",u.style.color="#333",u.style.cursor="pointer",u.style.display="flex",u.style.alignItems="center",u.style.justifyContent="center",u.style.boxShadow="0 2px 4px rgba(0,0,0,0.2)",u.style.zIndex="2147483647",u.onclick=()=>this.close(),g.appendChild(this.iframe),g.appendChild(u),s.appendChild(g),document.body.appendChild(s)}async close(){var r;if(this.iframe){const o=(r=this.iframe.parentElement)==null?void 0:r.parentElement;o&&o.parentElement&&o.parentElement.removeChild(o),delete this.iframe}this.removeEventHandler()}setupEventHandler(r){this.eventHandler=o=>{var s;try{if(((s=window==null?void 0:window.location)==null?void 0:s.origin)===o.origin)return;if(o.origin!==r.origin)throw console.log("event",o),new _t(r.origin,o.origin);this.handleEvent(o)}catch(g){const u=typeof g=="string"?new Error(g):g instanceof Error?g:new Error(String(g));this.handleError(u)}},window.addEventListener("message",this.eventHandler)}removeEventHandler(){this.eventHandler&&(window.removeEventListener("message",this.eventHandler),this.eventHandler=void 0)}handleError(r){this.close(),this.errorFunc(r)}}class Pt extends It{constructor(r=console.error){super(r)}}const St=({easDeepLinkType:a,deepLink:r,frontendCanisterId:o})=>{if(r.startsWith("exp://"))return"expo-go";if(r.startsWith("http://localhost:8081"))return"dev-server";if(r.includes(o))return"icp";if(a)return a;throw new Error(`Could not determine deep link type: { "easDeepLinkType": ${a===void 0?"undefined":`"${a}"`}, "deepLink": "${r}", "frontendCanisterId": "${o}" }`)};function Ct(a,r){if(a.byteLength!==r.byteLength)return!1;const o=new Uint8Array(a),s=new Uint8Array(r);return o.every((g,u)=>g===s[u])}function xt({localIPAddress:a,dfxNetwork:r,easDeepLinkType:o,deepLink:s,frontendCanisterId:g,iiIntegrationCanisterId:u,appKeyStorage:d,delegationStorage:y,platform:v}){const[_,w]=k.useState(!1),b=Et.useURL(),[I,A]=k.useState(void 0),[q,N]=k.useState(void 0),H=k.useRef(void 0),j=bt.usePathname(),m=k.useRef(void 0),te=k.useCallback(()=>{console.log("Saving path when login:",j),j&&(m.current=j)},[j]),re=k.useCallback(()=>{console.log("Clearing path when login:",m.current),m.current=void 0},[]);k.useEffect(()=>{if(_){console.log("skipping first useEffect");return}if(I){console.log("skipping first useEffect because identity is already set");return}(async()=>{try{const R=await d.find(),P=await y.find();if(R&&P){const D=U.DelegationIdentity.fromDelegation(R,P);A(D)}else if(!R){const D=U.Ed25519KeyIdentity.generate();await d.save(D),await y.remove()}}catch(R){N(R)}finally{w(!0)}})()},[]);const z=async R=>{console.log("Processing delegation");const P=U.DelegationChain.fromJSON(R);await y.save(P);const D=await d.retrieve(),$=P.delegations,L=$[$.length-1];if(!Ct(L.delegation.pubkey,D.getPublicKey().toDer()))throw new Error("Last delegation public key does not match app key");const S=U.DelegationIdentity.fromDelegation(D,P);A(S),console.log("identity set from delegation")};return k.useEffect(()=>{if(I||!b)return;const P=new URLSearchParams(b==null?void 0:b.split("#")[1]).get("delegation");console.log("Delegation from URL:",P?"present":"not present"),P&&(async()=>{try{await z(P),Fe.dismissBrowser()}catch(D){N(D)}})()},[b]),{identity:I,isReady:_,isAuthenticated:!!I,login:async()=>{try{console.log("Logging in"),te();const R=await d.retrieve(),P=ee.toHex(R.getPublicKey().toDer()),$=new Rt({dfxNetwork:r,localIPAddress:a}).getFrontendCanisterURL(u);console.log("iiIntegrationURL",$);const L=St({easDeepLinkType:o,deepLink:s,frontendCanisterId:g});console.log("deepLinkType",L);const S=new URL($);if(S.searchParams.set("pubkey",P),S.searchParams.set("deep-link-type",L),v==="web"){const O=new Pt;H.current=O,O.on("success",async F=>{console.log("IIIntegration success"),await z(F.delegation),O.close(),H.current=void 0}),await O.open({url:S.toString()})}else await Fe.openBrowserAsync(S.toString())}catch(R){N(R)}},logout:async()=>{console.log("Logging out");try{await y.remove(),A(void 0),console.log("identity set to undefined after logout")}catch(R){N(R)}},pathWhenLogin:m.current,clearPathWhenLogin:re,authError:q}}var fe={exports:{}},B={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var We;function kt(){if(We)return B;We=1;var a=k,r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,g=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function d(y,v,_){var w,b={},I=null,A=null;_!==void 0&&(I=""+_),v.key!==void 0&&(I=""+v.key),v.ref!==void 0&&(A=v.ref);for(w in v)s.call(v,w)&&!u.hasOwnProperty(w)&&(b[w]=v[w]);if(y&&y.defaultProps)for(w in v=y.defaultProps,v)b[w]===void 0&&(b[w]=v[w]);return{$$typeof:r,type:y,key:I,ref:A,props:b,_owner:g.current}}return B.Fragment=o,B.jsx=d,B.jsxs=d,B}var J={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ue;function Ot(){return Ue||(Ue=1,process.env.NODE_ENV!=="production"&&function(){var a=k,r=Symbol.for("react.element"),o=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),y=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),A=Symbol.for("react.offscreen"),q=Symbol.iterator,N="@@iterator";function H(e){if(e===null||typeof e!="object")return null;var t=q&&e[q]||e[N];return typeof t=="function"?t:null}var j=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function m(e){{for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];te("error",e,n)}}function te(e,t,n){{var i=j.ReactDebugCurrentFrame,f=i.getStackAddendum();f!==""&&(t+="%s",n=n.concat([f]));var h=n.map(function(c){return String(c)});h.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,h)}}var re=!1,z=!1,de=!1,he=!1,R=!1,P;P=Symbol.for("react.module.reference");function D(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===u||R||e===g||e===_||e===w||he||e===A||re||z||de||typeof e=="object"&&e!==null&&(e.$$typeof===I||e.$$typeof===b||e.$$typeof===d||e.$$typeof===y||e.$$typeof===v||e.$$typeof===P||e.getModuleId!==void 0))}function $(e,t,n){var i=e.displayName;if(i)return i;var f=t.displayName||t.name||"";return f!==""?n+"("+f+")":n}function L(e){return e.displayName||"Context"}function S(e){if(e==null)return null;if(typeof e.tag=="number"&&m("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case s:return"Fragment";case o:return"Portal";case u:return"Profiler";case g:return"StrictMode";case _:return"Suspense";case w:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case y:var t=e;return L(t)+".Consumer";case d:var n=e;return L(n._context)+".Provider";case v:return $(e,e.render,"ForwardRef");case b:var i=e.displayName||null;return i!==null?i:S(e.type)||"Memo";case I:{var f=e,h=f._payload,c=f._init;try{return S(c(h))}catch{return null}}}return null}var O=Object.assign,F=0,ve,ge,pe,ye,me,Ee,be;function we(){}we.__reactDisabledLog=!0;function Me(){{if(F===0){ve=console.log,ge=console.info,pe=console.warn,ye=console.error,me=console.group,Ee=console.groupCollapsed,be=console.groupEnd;var e={configurable:!0,enumerable:!0,value:we,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}F++}}function Ke(){{if(F--,F===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},e,{value:ve}),info:O({},e,{value:ge}),warn:O({},e,{value:pe}),error:O({},e,{value:ye}),group:O({},e,{value:me}),groupCollapsed:O({},e,{value:Ee}),groupEnd:O({},e,{value:be})})}F<0&&m("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ne=j.ReactCurrentDispatcher,oe;function G(e,t,n){{if(oe===void 0)try{throw Error()}catch(f){var i=f.stack.trim().match(/\n( *(at )?)/);oe=i&&i[1]||""}return` `+oe+e}}var ie=!1,X;{var Be=typeof WeakMap=="function"?WeakMap:Map;X=new Be}function Re(e,t){if(!e||ie)return"";{var n=X.get(e);if(n!==void 0)return n}var i;ie=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var h;h=ne.current,ne.current=null,Me();try{if(t){var c=function(){throw Error()};if(Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(x){i=x}Reflect.construct(e,[],c)}else{try{c.call()}catch(x){i=x}e.call(c.prototype)}}else{try{throw Error()}catch(x){i=x}e()}}catch(x){if(x&&i&&typeof x.stack=="string"){for(var l=x.stack.split(` `),C=i.stack.split(` `),p=l.length-1,E=C.length-1;p>=1&&E>=0&&l[p]!==C[E];)E--;for(;p>=1&&E>=0;p--,E--)if(l[p]!==C[E]){if(p!==1||E!==1)do if(p--,E--,E<0||l[p]!==C[E]){var T=` `+l[p].replace(" at new "," at ");return e.displayName&&T.includes("<anonymous>")&&(T=T.replace("<anonymous>",e.displayName)),typeof e=="function"&&X.set(e,T),T}while(p>=1&&E>=0);break}}}finally{ie=!1,ne.current=h,Ke(),Error.prepareStackTrace=f}var V=e?e.displayName||e.name:"",W=V?G(V):"";return typeof e=="function"&&X.set(e,W),W}function Je(e,t,n){return Re(e,!1)}function qe(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function Z(e,t,n){if(e==null)return"";if(typeof e=="function")return Re(e,qe(e));if(typeof e=="string")return G(e);switch(e){case _:return G("Suspense");case w:return G("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return Je(e.render);case b:return Z(e.type,t,n);case I:{var i=e,f=i._payload,h=i._init;try{return Z(h(f),t,n)}catch{}}}return""}var M=Object.prototype.hasOwnProperty,_e={},Ie=j.ReactDebugCurrentFrame;function Q(e){if(e){var t=e._owner,n=Z(e.type,e._source,t?t.type:null);Ie.setExtraStackFrame(n)}else Ie.setExtraStackFrame(null)}function He(e,t,n,i,f){{var h=Function.call.bind(M);for(var c in e)if(h(e,c)){var l=void 0;try{if(typeof e[c]!="function"){var C=Error((i||"React class")+": "+n+" type `"+c+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[c]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw C.name="Invariant Violation",C}l=e[c](t,c,i,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(p){l=p}l&&!(l instanceof Error)&&(Q(f),m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",i||"React class",n,c,typeof l),Q(null)),l instanceof Error&&!(l.message in _e)&&(_e[l.message]=!0,Q(f),m("Failed %s type: %s",n,l.message),Q(null))}}}var ze=Array.isArray;function ae(e){return ze(e)}function Ge(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,n=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function Xe(e){try{return Pe(e),!1}catch{return!0}}function Pe(e){return""+e}function Se(e){if(Xe(e))return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ge(e)),Pe(e)}var Ce=j.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},xe,ke;function Qe(e){if(M.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function et(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function tt(e,t){typeof e.ref=="string"&&Ce.current}function rt(e,t){{var n=function(){xe||(xe=!0,m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function nt(e,t){{var n=function(){ke||(ke=!0,m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var ot=function(e,t,n,i,f,h,c){var l={$$typeof:r,type:e,key:t,ref:n,props:c,_owner:h};return l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:f}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l};function it(e,t,n,i,f){{var h,c={},l=null,C=null;n!==void 0&&(Se(n),l=""+n),et(t)&&(Se(t.key),l=""+t.key),Qe(t)&&(C=t.ref,tt(t,f));for(h in t)M.call(t,h)&&!Ze.hasOwnProperty(h)&&(c[h]=t[h]);if(e&&e.defaultProps){var p=e.defaultProps;for(h in p)c[h]===void 0&&(c[h]=p[h])}if(l||C){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;l&&rt(c,E),C&&nt(c,E)}return ot(e,l,C,f,i,Ce.current,c)}}var se=j.ReactCurrentOwner,Oe=j.ReactDebugCurrentFrame;function Y(e){if(e){var t=e._owner,n=Z(e.type,e._source,t?t.type:null);Oe.setExtraStackFrame(n)}else Oe.setExtraStackFrame(null)}var le;le=!1;function ce(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function Te(){{if(se.current){var e=S(se.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function at(e){return""}var je={};function st(e){{var t=Te();if(!t){var n=typeof e=="string"?e:e.displayName||e.name;n&&(t=` Check the top-level render call using <`+n+">.")}return t}}function De(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=st(t);if(je[n])return;je[n]=!0;var i="";e&&e._owner&&e._owner!==se.current&&(i=" It was passed a child from "+S(e._owner.type)+"."),Y(e),m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,i),Y(null)}}function Ae(e,t){{if(typeof e!="object")return;if(ae(e))for(var n=0;n<e.length;n++){var i=e[n];ce(i)&&De(i,t)}else if(ce(e))e._store&&(e._store.validated=!0);else if(e){var f=H(e);if(typeof f=="function"&&f!==e.entries)for(var h=f.call(e),c;!(c=h.next()).done;)ce(c.value)&&De(c.value,t)}}}function lt(e){{var t=e.type;if(t==null||typeof t=="string")return;var n;if(typeof t=="function")n=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===v||t.$$typeof===b))n=t.propTypes;else return;if(n){var i=S(t);He(n,e.props,"prop",i,e)}else if(t.PropTypes!==void 0&&!le){le=!0;var f=S(t);m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",f||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&m("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ct(e){{for(var t=Object.keys(e.props),n=0;n<t.length;n++){var i=t[n];if(i!=="children"&&i!=="key"){Y(e),m("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",i),Y(null);break}}e.ref!==null&&(Y(e),m("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}var $e={};function Le(e,t,n,i,f,h){{var c=D(e);if(!c){var l="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(l+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var C=at();C?l+=C:l+=Te();var p;e===null?p="null":ae(e)?p="array":e!==void 0&&e.$$typeof===r?(p="<"+(S(e.type)||"Unknown")+" />",l=" Did you accidentally export a JSX literal instead of a component?"):p=typeof e,m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",p,l)}var E=it(e,t,n,f,h);if(E==null)return E;if(c){var T=t.children;if(T!==void 0)if(i)if(ae(T)){for(var V=0;V<T.length;V++)Ae(T[V],e);Object.freeze&&Object.freeze(T)}else m("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ae(T,e)}if(M.call(t,"key")){var W=S(e),x=Object.keys(t).filter(function(gt){return gt!=="key"}),ue=x.length>0?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}";if(!$e[W+ue]){var vt=x.length>0?"{"+x.join(": ..., ")+": ...}":"{}";m(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,ue,W,vt,W),$e[W+ue]=!0}}return e===s?ct(E):lt(E),E}}function ut(e,t,n){return Le(e,t,n,!0)}function ft(e,t,n){return Le(e,t,n,!1)}var dt=ft,ht=ut;J.Fragment=s,J.jsx=dt,J.jsxs=ht}()),J}process.env.NODE_ENV==="production"?fe.exports=kt():fe.exports=Ot();var Tt=fe.exports;const Ne=k.createContext(void 0);function jt(){const a=k.useContext(Ne);if(a===void 0)throw new Error("useIIIntegrationContext must be used within an IIIntegrationProvider");return a}function Dt({children:a,value:r}){return Tt.jsx(Ne.Provider,{value:r,children:a})}class Ye{constructor(r,o){K(this,"storage");K(this,"key");this.storage=r,this.key=o}async find(){const r=await this.storage.find(this.key);if(r)return U.Ed25519KeyIdentity.fromJSON(r)}async retrieve(){const r=await this.find();if(!r)throw new Error(`No value found for key ${this.key}`);return r}async save(r){return this.storage.save(this.key,JSON.stringify(r.toJSON()))}async remove(){return this.storage.remove(this.key)}}const At="appKey";class $t extends Ye{constructor(r){super(r,At)}}class Ve{constructor(r,o){K(this,"storage");K(this,"key");this.storage=r,this.key=o}async find(){const r=await this.storage.find(this.key);if(!r)return;const o=U.DelegationChain.fromJSON(r);if(!U.isDelegationValid(o)){console.log("Invalid delegation chain, removing delegation"),await this.remove();return}return o}async retrieve(){const r=await this.find();if(!r)throw new Error(`No value found for key ${this.key}`);return r}async save(r){return this.storage.save(this.key,JSON.stringify(r.toJSON()))}async remove(){return this.storage.remove(this.key)}}const Lt="delegation";class Ft extends Ve{constructor(r){super(r,Lt)}}exports.AppKeyStorage=$t;exports.DelegationChainValueStorageWrapper=Ve;exports.DelegationStorage=Ft;exports.Ed25519KeyIdentityValueStorageWrapper=Ye;exports.IIIntegrationProvider=Dt;exports.useIIIntegration=xt;exports.useIIIntegrationContext=jt;