@tiun/react-native-sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3 -3
- package/dist/index.mjs +176 -174
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,12 @@ export declare interface CheckoutOptions {
|
|
|
9
9
|
* Specific product ID to checkout (optional, for future use)
|
|
10
10
|
*/
|
|
11
11
|
productId?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Your own identifier for this purchase (e.g. an order or booking ID).
|
|
14
|
+
* Required for repeatable products, which can be bought more than once —
|
|
15
|
+
* each purchase is tied to its reference ID.
|
|
16
|
+
*/
|
|
17
|
+
referenceId?: string;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
declare interface PaywallHideEvent {
|
|
@@ -101,6 +107,8 @@ export declare type TiunUser = UserInfo;
|
|
|
101
107
|
declare interface UserInfo {
|
|
102
108
|
userId: string;
|
|
103
109
|
email: string;
|
|
110
|
+
/** Whether the user has opted in to the newsletter. */
|
|
111
|
+
hasNewsletterOptIn: boolean;
|
|
104
112
|
productAccess: string[];
|
|
105
113
|
}
|
|
106
114
|
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var pe;function Re(){if(pe)return X;pe=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function a(u,o,d){var f=null;if(d!==void 0&&(f=""+d),o.key!==void 0&&(f=""+o.key),"key"in o){d={};for(var
|
|
9
|
+
*/var pe;function Re(){if(pe)return X;pe=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function a(u,o,d){var f=null;if(d!==void 0&&(f=""+d),o.key!==void 0&&(f=""+o.key),"key"in o){d={};for(var E in o)E!=="key"&&(d[E]=o[E])}else d=o;return o=d.ref,{$$typeof:t,type:u,key:f,ref:o!==void 0?o:null,props:d}}return X.Fragment=r,X.jsx=a,X.jsxs=a,X}var Q={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var he;function ge(){return he||(he=1,process.env.NODE_ENV!=="production"&&function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===
|
|
17
|
+
*/var he;function ge(){return he||(he=1,process.env.NODE_ENV!=="production"&&function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===R?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case q:return"Profiler";case N:return"StrictMode";case G:return"Suspense";case c:return"SuspenseList";case I:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case z:return"Portal";case B:return(e.displayName||"Context")+".Provider";case U:return(e._context.displayName||"Context")+".Consumer";case D:var s=e.render;return e=e.displayName,e||(e=s.displayName||s.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case m:return s=e.displayName||null,s!==null?s:t(e.type)||"Memo";case v:s=e._payload,e=e._init;try{return t(e(s))}catch{}}return null}function r(e){return""+e}function a(e){try{r(e);var s=!1}catch{s=!0}if(s){s=console;var h=s.error,S=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return h.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",S),r(e)}}function u(e){if(e===w)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===v)return"<...>";try{var s=t(e);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function o(){var e=i.A;return e===null?null:e.getOwner()}function d(){return Error("react-stack-top-frame")}function f(e){if(n.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function E(e,s){function h(){p||(p=!0,console.error("%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://react.dev/link/special-props)",s))}h.isReactWarning=!0,Object.defineProperty(e,"key",{get:h,configurable:!0})}function V(){var e=t(this.type);return C[e]||(C[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function A(e,s,h,S,W,x,oe,ie){return h=x.ref,e={$$typeof:j,type:e,key:s,props:x,_owner:W},(h!==void 0?h:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:V}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:oe}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ie}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function L(e,s,h,S,W,x,oe,ie){var _=s.children;if(_!==void 0)if(S)if(T(_)){for(S=0;S<_.length;S++)P(_[S]);Object.freeze&&Object.freeze(_)}else console.error("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 P(_);if(n.call(s,"key")){_=t(e);var H=Object.keys(s).filter(function(ye){return ye!=="key"});S=0<H.length?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}",$[_+S]||(H=0<H.length?"{"+H.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,v,S,H,S),$[S+v]=!0)}if(S=null,p!==void 0&&(a(p),S=""+p),f(c)&&(a(c.key),S=""+c.key),"key"in c){p={};for(var ae in c)ae!=="key"&&(p[ae]=c[ae])}else p=c;return S&&T(p,typeof e=="function"?e.displayName||e.name||"Unknown":e),A(e,S,x,W,o(),p,oe,ie)}function I(e){typeof e=="object"&&e!==null&&e.$$typeof===j&&e._store&&(e._store.validated=1)}var k=l,j=Symbol.for("react.transitional.element"),z=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),B=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),s=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),m=Symbol.for("react.client.reference"),i=k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,n=Object.prototype.hasOwnProperty,E=Array.isArray,R=console.createTask?console.createTask:function(){return null};k={"react-stack-bottom-frame":function(e){return e()}};var h,C={},O=k["react-stack-bottom-frame"].bind(k,d)(),Y=R(u(d)),$={};Q.Fragment=y,Q.jsx=function(e,c,p,v,W){var x=1e4>i.recentlyCreatedOwnerStacks++;return L(e,c,p,!1,v,W,x?Error("react-stack-top-frame"):O,x?R(u(e)):Y)},Q.jsxs=function(e,c,p,v,W){var x=1e4>i.recentlyCreatedOwnerStacks++;return L(e,c,p,!0,v,W,x?Error("react-stack-top-frame"):O,x?R(u(e)):Y)}}()),Q}process.env.NODE_ENV==="production"?se.exports=Re():se.exports=ge();var g=se.exports;const ke={errorPillText:"Technical Error",errorNotificationTitle:"Technical error",errorNotificationSubtitle:"Please reload the page or contact our support.",errorTitle:"Technical error",errorTextBeforeEmail:"Try reloading the page. If the error persists, please contact ",errorTextAfterEmail:" and we’ll help you right away.",connectionErrorTitle:"No connection",connectionErrorText:"We couldn’t reach tiun. Check your internet connection and try again.",connectionErrorCta:"Try again"},Ne={errorPillText:"Erreur Technique",errorNotificationTitle:"Erreur technique",errorNotificationSubtitle:"Veuillez recharger la page ou contacter notre support.",errorTitle:"Erreur technique",errorTextBeforeEmail:"Veuillez recharger la page. Si l’erreur persiste, contactez ",errorTextAfterEmail:" et nous vous aiderons immédiatement.",connectionErrorTitle:"Pas de connexion",connectionErrorText:"Impossible de joindre tiun. Vérifiez votre connexion Internet et réessayez.",connectionErrorCta:"Réessayer"},Ce={errorPillText:"Technischer Fehler",errorNotificationTitle:"Technischer Fehler",errorNotificationSubtitle:"Bitte lade die Seite neu, oder kontaktiere unseren Support.",errorTitle:"Technischer Fehler",errorTextBeforeEmail:"Bitte lade die Seite neu. Sollte der Fehler weiterhin auftreten, kontaktiere ",errorTextAfterEmail:" und wir helfen Dir sofort weiter.",connectionErrorTitle:"Keine Verbindung",connectionErrorText:"tiun konnte nicht erreicht werden. Überprüfe deine Internetverbindung und versuche es erneut.",connectionErrorCta:"Erneut versuchen"},Oe={errorPillText:"Technischer Fehler",errorNotificationTitle:"Technischer Fehler",errorNotificationSubtitle:"Bitte laden Sie die Seite neu, oder kontaktieren Sie unseren Support.",errorTitle:"Technischer Fehler",errorTextBeforeEmail:"Bitte laden Sie die Seite neu. Sollte der Fehler weiterhin auftreten, kontaktieren Sie ",errorTextAfterEmail:" und wir helfen Ihnen sofort weiter.",connectionErrorTitle:"Keine Verbindung",connectionErrorText:"tiun konnte nicht erreicht werden. Überprüfen Sie Ihre Internetverbindung und versuchen Sie es erneut.",connectionErrorCta:"Erneut versuchen"};function Ie(t,r="informal"){switch((t??"en").trim().toLowerCase()){case"de":return r==="formal"?Oe:Ce;case"fr":return Ne;default:return ke}}const K={start:"TIUN_START",checkout:"TIUN_CHECKOUT",updateContent:"TIUN_UPDATE_CONTENT",login:"TIUN_LOGIN",logout:"TIUN_LOGOUT",getVerificationToken:"TIUN_GET_VERIFICATION_TOKEN",setAppearance:"TIUN_SET_APPEARANCE",overlayChange:"TIUN_OVERLAY_CHANGE",popPubKeyRequest:"TIUN_POP_PUBKEY_REQUEST",popSignRequest:"TIUN_POP_SIGN_REQUEST",tokenGet:"TIUN_TOKEN_GET",tokenPersist:"TIUN_TOKEN_PERSIST",nativeReset:"TIUN_NATIVE_RESET",popPubKey:"TIUN_POP_PUBKEY",restoreToken:"TIUN_RESTORE_TOKEN",popSignResult:"TIUN_POP_SIGN_RESULT",resolveCheckout:"TIUN_RESOLVE_CHECKOUT"},Pe="__TIUN_NATIVE_CRYPTO__",xe="https://api.tiun.live";function ue(t){return(t.host??xe).replace(/\/$/,"")}function re(t){return`app.tiun.pop.${t.snippetId||"default"}`}function Z(t){return`app.tiun.token.${t.snippetId||"default"}`}function Ae(t){return`${`${ue(t)}/live_api/v2/snippets/${encodeURIComponent(t.snippetId)}/webview_return`}?to=${encodeURIComponent(t.returnUrl)}`}function je(t){const r={language:t.language??"en"},a=Object.entries(r).map(([o,d])=>`${encodeURIComponent(o)}=${encodeURIComponent(d)}`).join("&"),u=`${ue(t)}/live_api/v2/snippets/${encodeURIComponent(t.snippetId)}/webview_host`;return a?`${u}?${a}`:u}function Te(t){const r=t.indexOf("?");if(!(r<0))for(const a of t.slice(r+1).split("&")){const u=a.indexOf("=");if((u<0?a:a.slice(0,u))==="status"){const d=u<0?"":a.slice(u+1);return d?decodeURIComponent(d):void 0}}}function Ue(t,r){const a=t.returnUrl.split("?")[0];return r.startsWith(a)}const le="1005";function de(t){return t==null?void 0:t.code}async function $e(t){try{return await te.getPublicKey(t)}catch(r){if(de(r)===le)return te.generate(t,{requireUserAuthentication:!1});throw r}}async function Fe(t){try{return await te.getPublicKey(t)}catch(r){if(de(r)===le)return null;throw r}}function Le(t,r){return te.sign(t,r)}async function We(t){try{await te.removeKey(t)}catch(r){if(de(r)!==le)throw r}}const Ve="tiun_auth_token";async function qe(t){const r=await ne.getGenericPassword({service:t});return r?r.password:null}async function Ye(t,r){await ne.setGenericPassword(Ve,r,{service:t,accessible:ne.ACCESSIBLE.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY})}async function ce(t){await ne.resetGenericPassword({service:t})}function Be(t){const r=Ie(t);return{title:r.connectionErrorTitle,text:r.connectionErrorText,cta:r.connectionErrorCta}}function De({language:t,dark:r,onRetry:a}){const u=Be(t),o=r?Ge:null;return g.jsxs(b.View,{style:[F.container,o==null?void 0:o.container],children:[g.jsxs(b.View,{style:F.content,children:[g.jsx(b.Text,{style:[F.title,o==null?void 0:o.title],children:u.title}),g.jsx(b.View,{style:[F.iconBadge,o==null?void 0:o.iconBadge],children:g.jsx(b.Text,{style:[F.iconGlyph,o==null?void 0:o.iconGlyph],children:"!"})}),g.jsx(b.Text,{style:[F.text,o==null?void 0:o.text],children:u.text})]}),g.jsx(b.Pressable,{accessibilityRole:"button",onPress:a,style:({pressed:d})=>[F.button,o==null?void 0:o.button,d&&F.buttonPressed],children:g.jsx(b.Text,{style:[F.buttonText,o==null?void 0:o.buttonText],children:u.cta})})]})}const F=b.StyleSheet.create({container:{...b.StyleSheet.absoluteFillObject,backgroundColor:"#fff",padding:24,justifyContent:"space-between"},content:{flex:1,alignItems:"center",justifyContent:"center",gap:24},title:{fontSize:20,fontWeight:"600",color:"#000",textAlign:"center"},iconBadge:{width:40,height:40,borderRadius:20,backgroundColor:"#FCE7F3",alignItems:"center",justifyContent:"center"},iconGlyph:{color:"#DB2777",fontSize:22,fontWeight:"700",lineHeight:26},text:{fontSize:16,fontWeight:"500",color:"#4B5563",textAlign:"center"},button:{backgroundColor:"#000",borderRadius:999,minHeight:56,alignItems:"center",justifyContent:"center",alignSelf:"stretch"},buttonPressed:{opacity:.9},buttonText:{color:"#fff",fontSize:16,fontWeight:"500"}}),Ge=b.StyleSheet.create({container:{backgroundColor:"#0a0a0a"},title:{color:"#fafafa"},iconBadge:{backgroundColor:"#500724"},iconGlyph:{color:"#F472B6"},text:{color:"#A1A1AA"},button:{backgroundColor:"#fafafa"},buttonText:{color:"#000"}}),He=Se.WebView;function J(t){return`try{window.tiunHost&&${t};}catch(e){}; true;`}const Ke=l.forwardRef(function({config:r,onEvent:a},u){const o=!!r.debug,d=b.useColorScheme(),f=r.appearance==="dark"||r.appearance==="auto"&&d==="dark"?"dark":"light",T=l.useRef(null),[V,A]=l.useState(!1),[L,I]=l.useState(!1),k=l.useRef(!1),j=l.useRef(!1),z=()=>{var i;I(!1),(i=T.current)==null||i.reload()};l.useEffect(()=>{if(!L)return;const i=b.AppState.addEventListener("change",n=>{var E;n==="active"&&(I(!1),(E=T.current)==null||E.reload())});return()=>i.remove()},[L]);const y=`window.${Pe} = true;window.__TIUN_CONFIG__ = Object.assign({}, window.__TIUN_CONFIG__, { returnUrl: ${JSON.stringify(Ae(r))}, appearance: ${JSON.stringify(f)} });true;`,N=(i,...n)=>{var E;return(E=T.current)==null?void 0:E.injectJavaScript(J(`window.tiunHost.${i}(${n.map(R=>JSON.stringify(R)??"null").join(",")})`))},q=l.useRef(f);l.useEffect(()=>{f!==q.current&&(q.current=f,N("setAppearance",f))},[f]);const U=i=>{var n;j.current||(j.current=!0,M.close().catch(()=>{}),M.closeAuth().catch(()=>{}),A(!0),(n=T.current)==null||n.injectJavaScript(J(`window.tiunHost.resolveCheckout(${i?JSON.stringify(i):""})`)))},B=i=>{var n,E,R;switch(i.type){case K.popPubKeyRequest:return $e(re(r)).then(h=>N("popPubKey",h)).catch(h=>{o&&console.warn("[tiun] ensurePopKey failed:",h),N("popPubKey",null)}),!0;case K.tokenGet:return(async()=>{try{const h=await qe(Z(r));if(h&&!await Fe(re(r))){await ce(Z(r)),N("restoreToken",null);return}N("restoreToken",h)}catch{N("restoreToken",null)}})(),!0;case K.popSignRequest:{const h=(n=i.payload)==null?void 0:n.requestId,C=(E=i.payload)==null?void 0:E.information;return Le(re(r),C).then(O=>N("popSignResult",h,O,null)).catch(O=>{const Y=(O==null?void 0:O.code)??"sign_failed";o&&console.warn("[tiun] popSign failed:",O),N("popSignResult",h,null,String(Y))}),!0}case K.tokenPersist:{const h=((R=i.payload)==null?void 0:R.token)??null;return(h?Ye(Z(r),h):ce(Z(r))).catch(C=>o&&console.warn("[tiun] token persist failed:",C)),!0}case K.nativeReset:return Promise.allSettled([We(re(r)),ce(Z(r))]),!0;default:return!1}};l.useImperativeHandle(u,()=>({login:()=>{var i;A(!0),(i=T.current)==null||i.injectJavaScript(J("window.tiunHost.login()"))},checkout:i=>{var n;A(!0),k.current=!0,j.current=!1,(n=T.current)==null||n.injectJavaScript(J(`window.tiunHost.checkout(${i?JSON.stringify(i):""})`))},logout:()=>{var i;return(i=T.current)==null?void 0:i.injectJavaScript(J("window.tiunHost.logout()"))},getVerificationToken:i=>{var n;return(n=T.current)==null?void 0:n.injectJavaScript(J(`window.tiunHost.getVerificationToken(${i?JSON.stringify(i):""})`))},resolveCheckout:U,reload:()=>{var i;return(i=T.current)==null?void 0:i.reload()}}),[]);const D=i=>{var E,R,h;let n=null;try{n=JSON.parse(i.nativeEvent.data)}catch{o&&console.warn("[tiun] non-JSON bridge message:",i.nativeEvent.data);return}if(!(!n||typeof n.type!="string")){if(n.type==="console"){o&&console.log("[tiun webview]",(E=n.payload)==null?void 0:E.level,(R=n.payload)==null?void 0:R.message);return}if((n.type==="cryptoCheck"||n.type==="hostBridgeReady")&&I(!1),o&&console.log("[tiun] <-",n.type,n.payload),!B(n)){if(n.type===K.overlayChange){const C=!!((h=n.payload)!=null&&h.overlay);A(C),C||(k.current=!1)}a(n)}}},G=i=>{if(k.current=!1,b.Platform.OS==="ios"){M.openAuth(i,r.returnUrl).then(n=>{n.type==="success"&&n.url?U(Te(n.url)):n.type==="cancel"&&U("cancelled")}).catch(n=>o&&console.warn("[tiun] openAuth error:",n));return}M.open(i,{showTitle:!1,enableUrlBarHiding:!1,enableDefaultShare:!1,forceCloseOnRedirection:!1}).then(n=>{n.type==="cancel"&&U("cancelled")}).catch(n=>o&&console.warn("[tiun] in-app browser open error:",n))},s=i=>{M.open(i,{modalPresentationStyle:"fullScreen",modalEnabled:!0,animated:!0,enableBarCollapsing:!0}).catch(n=>o&&console.warn("[tiun] in-app browser open failed:",n))},_=i=>{var E;const n=(E=i.nativeEvent)==null?void 0:E.targetUrl;n&&(k.current?G(n):s(n))},w=i=>{const n=i.url;return n.startsWith(ue(r))||n.startsWith("about:")||n.startsWith("data:")||n==="about:blank"?!0:n.startsWith("http://")||n.startsWith("https://")?(k.current&&i.isTopFrame!==!1?G(n):s(n),!1):!0},{width:P,height:m}=b.useWindowDimensions();return g.jsxs(b.View,{pointerEvents:V?"auto":"none",style:[ee.container,{width:P,height:m},V?ee.visible:ee.hidden],children:[g.jsx(He,{ref:T,source:{uri:je(r)},originWhitelist:["*"],onMessage:D,onShouldStartLoadWithRequest:w,onOpenWindow:_,injectedJavaScriptBeforeContentLoaded:y,javaScriptEnabled:!0,domStorageEnabled:!0,style:ee.webview,containerStyle:ee.webview,onError:i=>{o&&console.warn("[tiun] webview load error:",i.nativeEvent),I(!0)},onHttpError:i=>{o&&console.warn("[tiun] webview http error:",i.nativeEvent),I(!0)}}),L&&V?g.jsx(De,{language:r.language,dark:f==="dark",onRetry:z}):null]})}),ee=b.StyleSheet.create({container:{position:"absolute",top:0,left:0,zIndex:9999,elevation:9999},webview:{flex:1,backgroundColor:"transparent"},visible:{opacity:1},hidden:{opacity:0}});class Je{constructor(){fe(this,"listeners",new Map)}on(r,a){let u=this.listeners.get(r);return u||(u=new Set,this.listeners.set(r,u)),u.add(a),()=>{var o;(o=this.listeners.get(r))==null||o.delete(a)}}emit(r,a){const u=this.listeners.get(r);if(u)for(const o of u)try{o(a)}catch{}}}const Ee=l.createContext(null),be=l.createContext(null);function ze({config:t,children:r}){const a=l.useRef(null),u=l.useRef(!1),o=l.useRef([]),d=l.useRef(new Map),f=l.useRef(new Je).current,[T,V]=l.useState(!1),[A,L]=l.useState(null),[I,k]=l.useState(!1),[j,z]=l.useState(null),y=l.useCallback(s=>{u.current?s():o.current.push(s)},[]),N=l.useCallback(s=>{var _,w,P,m,i,n,E,R,h,C,O,Y;switch(s.type){case"cryptoCheck":z(!!((_=s.payload)!=null&&_.subtle&&((w=s.payload)!=null&&w.secureContext)));break;case"TIUN_SNIPPET_INITIALIZED":{u.current=!0,k(!0),f.emit("ready",void 0);const $=o.current;o.current=[],$.forEach(e=>e());break}case"TIUN_USER_CHANGE":{const $=!!((P=s.payload)!=null&&P.isAuthenticated),e=((m=s.payload)==null?void 0:m.user)??null;V($),L(e),f.emit("userChange",{isAuthenticated:$,user:e}),((i=s.payload)==null?void 0:i.userEvent)==="login"&&f.emit("login",{user:e}),((n=s.payload)==null?void 0:n.userEvent)==="logout"&&f.emit("logout",void 0);break}case"TIUN_VERIFICATION_TOKEN":{const $=((E=s.payload)==null?void 0:E.token)??null,e=(R=s.payload)==null?void 0:R.requestId;e&&d.current.has(e)&&(d.current.get(e)($),d.current.delete(e));break}case"TIUN_SHOW_PAYWALL":f.emit("paywallShow",{isConnected:!!((h=s.payload)!=null&&h.isConnected)});break;case"TIUN_HIDE_PAYWALL":f.emit("paywallHide",{sessionId:((C=s.payload)==null?void 0:C.sessionId)??"",isConnected:((O=s.payload)==null?void 0:O.isConnected)??!0});break;case"TIUN_ERROR":f.emit("error",((Y=s.payload)==null?void 0:Y.error)??s.payload??{});break}},[f]);l.useEffect(()=>{const s=w=>{if(!w||!Ue(t,w))return;const P=Te(w);y(()=>{var m;return(m=a.current)==null?void 0:m.resolveCheckout(P)})},_=b.Linking.addEventListener("url",({url:w})=>s(w));return b.Linking.getInitialURL().then(s).catch(()=>{}),()=>_.remove()},[t,y]);const q=l.useCallback(()=>y(()=>{var s;return(s=a.current)==null?void 0:s.login()}),[y]),U=l.useCallback(()=>y(()=>{var s;return(s=a.current)==null?void 0:s.logout()}),[y]),B=l.useCallback(s=>y(()=>{var _;return(_=a.current)==null?void 0:_.checkout(s==null?void 0:s.productId)}),[y]),D=l.useCallback(()=>new Promise(s=>{const _=`vt_${Math.random().toString(36).slice(2)}_${Date.now()}`;let w=!1;const P=m=>{w||(w=!0,d.current.delete(_),s(m))};d.current.set(_,P),y(()=>{var m;return(m=a.current)==null?void 0:m.getVerificationToken(_)}),setTimeout(()=>P(null),5e3)}),[y]),G=l.useMemo(()=>({isAuthenticated:T,user:A,ready:I,cryptoOk:j,login:q,logout:U,checkout:B,getUserVerificationToken:D}),[T,A,I,j,q,U,B,D]);return g.jsx(Ee.Provider,{value:G,children:g.jsxs(be.Provider,{value:f,children:[r,g.jsx(Ke,{ref:a,config:t,onEvent:N})]})})}function Me(){const t=l.useContext(Ee);if(!t)throw new Error("useTiun must be used within a <TiunProvider>");return t}function Xe(t,r){const a=l.useContext(be),u=l.useRef(r);u.current=r,l.useEffect(()=>{if(!a)throw new Error("useTiunEvent must be used within a <TiunProvider>");return a.on(t,o=>u.current(o))},[a,t])}exports.TiunProvider=ze;exports.useTiun=Me;exports.useTiunEvent=Xe;
|
|
22
|
+
<%s key={someKey} {...props} />`,S,_,H,_),$[_+S]=!0)}if(_=null,h!==void 0&&(a(h),_=""+h),f(s)&&(a(s.key),_=""+s.key),"key"in s){h={};for(var ae in s)ae!=="key"&&(h[ae]=s[ae])}else h=s;return _&&E(h,typeof e=="function"?e.displayName||e.name||"Unknown":e),A(e,_,x,W,o(),h,oe,ie)}function P(e){typeof e=="object"&&e!==null&&e.$$typeof===j&&e._store&&(e._store.validated=1)}var k=l,j=Symbol.for("react.transitional.element"),z=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),B=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),i=k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,n=Object.prototype.hasOwnProperty,T=Array.isArray,y=console.createTask?console.createTask:function(){return null};k={"react-stack-bottom-frame":function(e){return e()}};var p,C={},O=k["react-stack-bottom-frame"].bind(k,d)(),Y=y(u(d)),$={};Q.Fragment=w,Q.jsx=function(e,s,h,S,W){var x=1e4>i.recentlyCreatedOwnerStacks++;return L(e,s,h,!1,S,W,x?Error("react-stack-top-frame"):O,x?y(u(e)):Y)},Q.jsxs=function(e,s,h,S,W){var x=1e4>i.recentlyCreatedOwnerStacks++;return L(e,s,h,!0,S,W,x?Error("react-stack-top-frame"):O,x?y(u(e)):Y)}}()),Q}process.env.NODE_ENV==="production"?se.exports=Re():se.exports=ge();var g=se.exports;const ke={errorPillText:"Technical Error",errorNotificationTitle:"Technical error",errorNotificationSubtitle:"Please reload the page or contact our support.",errorTitle:"Technical error",errorTextBeforeEmail:"Try reloading the page. If the error persists, please contact ",errorTextAfterEmail:" and we’ll help you right away.",connectionErrorTitle:"No connection",connectionErrorText:"We couldn’t reach tiun. Check your internet connection and try again.",connectionErrorCta:"Try again"},Ne={errorPillText:"Erreur Technique",errorNotificationTitle:"Erreur technique",errorNotificationSubtitle:"Veuillez recharger la page ou contacter notre support.",errorTitle:"Erreur technique",errorTextBeforeEmail:"Veuillez recharger la page. Si l’erreur persiste, contactez ",errorTextAfterEmail:" et nous vous aiderons immédiatement.",connectionErrorTitle:"Pas de connexion",connectionErrorText:"Impossible de joindre tiun. Vérifiez votre connexion Internet et réessayez.",connectionErrorCta:"Réessayer"},Ce={errorPillText:"Technischer Fehler",errorNotificationTitle:"Technischer Fehler",errorNotificationSubtitle:"Bitte lade die Seite neu, oder kontaktiere unseren Support.",errorTitle:"Technischer Fehler",errorTextBeforeEmail:"Bitte lade die Seite neu. Sollte der Fehler weiterhin auftreten, kontaktiere ",errorTextAfterEmail:" und wir helfen Dir sofort weiter.",connectionErrorTitle:"Keine Verbindung",connectionErrorText:"tiun konnte nicht erreicht werden. Überprüfe deine Internetverbindung und versuche es erneut.",connectionErrorCta:"Erneut versuchen"},Oe={errorPillText:"Technischer Fehler",errorNotificationTitle:"Technischer Fehler",errorNotificationSubtitle:"Bitte laden Sie die Seite neu, oder kontaktieren Sie unseren Support.",errorTitle:"Technischer Fehler",errorTextBeforeEmail:"Bitte laden Sie die Seite neu. Sollte der Fehler weiterhin auftreten, kontaktieren Sie ",errorTextAfterEmail:" und wir helfen Ihnen sofort weiter.",connectionErrorTitle:"Keine Verbindung",connectionErrorText:"tiun konnte nicht erreicht werden. Überprüfen Sie Ihre Internetverbindung und versuchen Sie es erneut.",connectionErrorCta:"Erneut versuchen"};function Pe(t,r="informal"){switch((t??"en").trim().toLowerCase()){case"de":return r==="formal"?Oe:Ce;case"fr":return Ne;default:return ke}}const K={start:"TIUN_START",checkout:"TIUN_CHECKOUT",updateContent:"TIUN_UPDATE_CONTENT",login:"TIUN_LOGIN",logout:"TIUN_LOGOUT",getVerificationToken:"TIUN_GET_VERIFICATION_TOKEN",setAppearance:"TIUN_SET_APPEARANCE",overlayChange:"TIUN_OVERLAY_CHANGE",popPubKeyRequest:"TIUN_POP_PUBKEY_REQUEST",popSignRequest:"TIUN_POP_SIGN_REQUEST",tokenGet:"TIUN_TOKEN_GET",tokenPersist:"TIUN_TOKEN_PERSIST",nativeReset:"TIUN_NATIVE_RESET",popPubKey:"TIUN_POP_PUBKEY",restoreToken:"TIUN_RESTORE_TOKEN",popSignResult:"TIUN_POP_SIGN_RESULT",resolveCheckout:"TIUN_RESOLVE_CHECKOUT"},Ie="__TIUN_NATIVE_CRYPTO__",xe="https://api.tiun.live";function ue(t){return(t.host??xe).replace(/\/$/,"")}function re(t){return`app.tiun.pop.${t.snippetId||"default"}`}function Z(t){return`app.tiun.token.${t.snippetId||"default"}`}function Ae(t){return`${`${ue(t)}/live_api/v2/snippets/${encodeURIComponent(t.snippetId)}/webview_return`}?to=${encodeURIComponent(t.returnUrl)}`}function je(t){const r={language:t.language??"en"},a=Object.entries(r).map(([o,d])=>`${encodeURIComponent(o)}=${encodeURIComponent(d)}`).join("&"),u=`${ue(t)}/live_api/v2/snippets/${encodeURIComponent(t.snippetId)}/webview_host`;return a?`${u}?${a}`:u}function Te(t){const r=t.indexOf("?");if(!(r<0))for(const a of t.slice(r+1).split("&")){const u=a.indexOf("=");if((u<0?a:a.slice(0,u))==="status"){const d=u<0?"":a.slice(u+1);return d?decodeURIComponent(d):void 0}}}function Ue(t,r){const a=t.returnUrl.split("?")[0];return r.startsWith(a)}const le="1005";function de(t){return t==null?void 0:t.code}async function $e(t){try{return await te.getPublicKey(t)}catch(r){if(de(r)===le)return te.generate(t,{requireUserAuthentication:!1});throw r}}async function Fe(t){try{return await te.getPublicKey(t)}catch(r){if(de(r)===le)return null;throw r}}function Le(t,r){return te.sign(t,r)}async function We(t){try{await te.removeKey(t)}catch(r){if(de(r)!==le)throw r}}const Ve="tiun_auth_token";async function qe(t){const r=await ne.getGenericPassword({service:t});return r?r.password:null}async function Ye(t,r){await ne.setGenericPassword(Ve,r,{service:t,accessible:ne.ACCESSIBLE.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY})}async function ce(t){await ne.resetGenericPassword({service:t})}function Be(t){const r=Pe(t);return{title:r.connectionErrorTitle,text:r.connectionErrorText,cta:r.connectionErrorCta}}function De({language:t,dark:r,onRetry:a}){const u=Be(t),o=r?Ge:null;return g.jsxs(b.View,{style:[F.container,o==null?void 0:o.container],children:[g.jsxs(b.View,{style:F.content,children:[g.jsx(b.Text,{style:[F.title,o==null?void 0:o.title],children:u.title}),g.jsx(b.View,{style:[F.iconBadge,o==null?void 0:o.iconBadge],children:g.jsx(b.Text,{style:[F.iconGlyph,o==null?void 0:o.iconGlyph],children:"!"})}),g.jsx(b.Text,{style:[F.text,o==null?void 0:o.text],children:u.text})]}),g.jsx(b.Pressable,{accessibilityRole:"button",onPress:a,style:({pressed:d})=>[F.button,o==null?void 0:o.button,d&&F.buttonPressed],children:g.jsx(b.Text,{style:[F.buttonText,o==null?void 0:o.buttonText],children:u.cta})})]})}const F=b.StyleSheet.create({container:{...b.StyleSheet.absoluteFillObject,backgroundColor:"#fff",padding:24,justifyContent:"space-between"},content:{flex:1,alignItems:"center",justifyContent:"center",gap:24},title:{fontSize:20,fontWeight:"600",color:"#000",textAlign:"center"},iconBadge:{width:40,height:40,borderRadius:20,backgroundColor:"#FCE7F3",alignItems:"center",justifyContent:"center"},iconGlyph:{color:"#DB2777",fontSize:22,fontWeight:"700",lineHeight:26},text:{fontSize:16,fontWeight:"500",color:"#4B5563",textAlign:"center"},button:{backgroundColor:"#000",borderRadius:999,minHeight:56,alignItems:"center",justifyContent:"center",alignSelf:"stretch"},buttonPressed:{opacity:.9},buttonText:{color:"#fff",fontSize:16,fontWeight:"500"}}),Ge=b.StyleSheet.create({container:{backgroundColor:"#0a0a0a"},title:{color:"#fafafa"},iconBadge:{backgroundColor:"#500724"},iconGlyph:{color:"#F472B6"},text:{color:"#A1A1AA"},button:{backgroundColor:"#fafafa"},buttonText:{color:"#000"}}),He=Se.WebView;function J(t){return`try{window.tiunHost&&${t};}catch(e){}; true;`}const Ke=l.forwardRef(function({config:r,onEvent:a},u){const o=!!r.debug,d=b.useColorScheme(),f=r.appearance==="dark"||r.appearance==="auto"&&d==="dark"?"dark":"light",E=l.useRef(null),[V,A]=l.useState(!1),[L,P]=l.useState(!1),k=l.useRef(!1),j=l.useRef(!1),z=()=>{var i;P(!1),(i=E.current)==null||i.reload()};l.useEffect(()=>{if(!L)return;const i=b.AppState.addEventListener("change",n=>{var T;n==="active"&&(P(!1),(T=E.current)==null||T.reload())});return()=>i.remove()},[L]);const w=`window.${Ie} = true;window.__TIUN_CONFIG__ = Object.assign({}, window.__TIUN_CONFIG__, { returnUrl: ${JSON.stringify(Ae(r))}, appearance: ${JSON.stringify(f)} });true;`,N=(i,...n)=>{var T;return(T=E.current)==null?void 0:T.injectJavaScript(J(`window.tiunHost.${i}(${n.map(y=>JSON.stringify(y)??"null").join(",")})`))},q=l.useRef(f);l.useEffect(()=>{f!==q.current&&(q.current=f,N("setAppearance",f))},[f]);const U=i=>{var n;j.current||(j.current=!0,M.close().catch(()=>{}),M.closeAuth().catch(()=>{}),A(!0),(n=E.current)==null||n.injectJavaScript(J(`window.tiunHost.resolveCheckout(${i?JSON.stringify(i):""})`)))},B=i=>{var n,T,y;switch(i.type){case K.popPubKeyRequest:return $e(re(r)).then(p=>N("popPubKey",p)).catch(p=>{o&&console.warn("[tiun] ensurePopKey failed:",p),N("popPubKey",null)}),!0;case K.tokenGet:return(async()=>{try{const p=await qe(Z(r));if(p&&!await Fe(re(r))){await ce(Z(r)),N("restoreToken",null);return}N("restoreToken",p)}catch{N("restoreToken",null)}})(),!0;case K.popSignRequest:{const p=(n=i.payload)==null?void 0:n.requestId,C=(T=i.payload)==null?void 0:T.information;return Le(re(r),C).then(O=>N("popSignResult",p,O,null)).catch(O=>{const Y=(O==null?void 0:O.code)??"sign_failed";o&&console.warn("[tiun] popSign failed:",O),N("popSignResult",p,null,String(Y))}),!0}case K.tokenPersist:{const p=((y=i.payload)==null?void 0:y.token)??null;return(p?Ye(Z(r),p):ce(Z(r))).catch(C=>o&&console.warn("[tiun] token persist failed:",C)),!0}case K.nativeReset:return Promise.allSettled([We(re(r)),ce(Z(r))]),!0;default:return!1}};l.useImperativeHandle(u,()=>({login:()=>{var i;A(!0),(i=E.current)==null||i.injectJavaScript(J("window.tiunHost.login()"))},checkout:(i,n)=>{var y;A(!0),k.current=!0,j.current=!1;const T=n?[i||null,n]:i?[i]:[];(y=E.current)==null||y.injectJavaScript(J(`window.tiunHost.checkout(${T.map(p=>JSON.stringify(p)).join(",")})`))},logout:()=>{var i;return(i=E.current)==null?void 0:i.injectJavaScript(J("window.tiunHost.logout()"))},getVerificationToken:i=>{var n;return(n=E.current)==null?void 0:n.injectJavaScript(J(`window.tiunHost.getVerificationToken(${i?JSON.stringify(i):""})`))},resolveCheckout:U,reload:()=>{var i;return(i=E.current)==null?void 0:i.reload()}}),[]);const D=i=>{var T,y,p;let n=null;try{n=JSON.parse(i.nativeEvent.data)}catch{o&&console.warn("[tiun] non-JSON bridge message:",i.nativeEvent.data);return}if(!(!n||typeof n.type!="string")){if(n.type==="console"){o&&console.log("[tiun webview]",(T=n.payload)==null?void 0:T.level,(y=n.payload)==null?void 0:y.message);return}if((n.type==="cryptoCheck"||n.type==="hostBridgeReady")&&P(!1),o&&console.log("[tiun] <-",n.type,n.payload),!B(n)){if(n.type===K.overlayChange){const C=!!((p=n.payload)!=null&&p.overlay);A(C),C||(k.current=!1)}a(n)}}},G=i=>{if(k.current=!1,b.Platform.OS==="ios"){M.openAuth(i,r.returnUrl).then(n=>{n.type==="success"&&n.url?U(Te(n.url)):n.type==="cancel"&&U("cancelled")}).catch(n=>o&&console.warn("[tiun] openAuth error:",n));return}M.open(i,{showTitle:!1,enableUrlBarHiding:!1,enableDefaultShare:!1,forceCloseOnRedirection:!1}).then(n=>{n.type==="cancel"&&U("cancelled")}).catch(n=>o&&console.warn("[tiun] in-app browser open error:",n))},c=i=>{M.open(i,{modalPresentationStyle:"fullScreen",modalEnabled:!0,animated:!0,enableBarCollapsing:!0}).catch(n=>o&&console.warn("[tiun] in-app browser open failed:",n))},m=i=>{var T;const n=(T=i.nativeEvent)==null?void 0:T.targetUrl;n&&(k.current?G(n):c(n))},v=i=>{const n=i.url;return n.startsWith(ue(r))||n.startsWith("about:")||n.startsWith("data:")||n==="about:blank"?!0:n.startsWith("http://")||n.startsWith("https://")?(k.current&&i.isTopFrame!==!1?G(n):c(n),!1):!0},{width:I,height:R}=b.useWindowDimensions();return g.jsxs(b.View,{pointerEvents:V?"auto":"none",style:[ee.container,{width:I,height:R},V?ee.visible:ee.hidden],children:[g.jsx(He,{ref:E,source:{uri:je(r)},originWhitelist:["*"],onMessage:D,onShouldStartLoadWithRequest:v,onOpenWindow:m,injectedJavaScriptBeforeContentLoaded:w,javaScriptEnabled:!0,domStorageEnabled:!0,style:ee.webview,containerStyle:ee.webview,onError:i=>{o&&console.warn("[tiun] webview load error:",i.nativeEvent),P(!0)},onHttpError:i=>{o&&console.warn("[tiun] webview http error:",i.nativeEvent),P(!0)}}),L&&V?g.jsx(De,{language:r.language,dark:f==="dark",onRetry:z}):null]})}),ee=b.StyleSheet.create({container:{position:"absolute",top:0,left:0,zIndex:9999,elevation:9999},webview:{flex:1,backgroundColor:"transparent"},visible:{opacity:1},hidden:{opacity:0}});class Je{constructor(){fe(this,"listeners",new Map)}on(r,a){let u=this.listeners.get(r);return u||(u=new Set,this.listeners.set(r,u)),u.add(a),()=>{var o;(o=this.listeners.get(r))==null||o.delete(a)}}emit(r,a){const u=this.listeners.get(r);if(u)for(const o of u)try{o(a)}catch{}}}const Ee=l.createContext(null),be=l.createContext(null);function ze({config:t,children:r}){const a=l.useRef(null),u=l.useRef(!1),o=l.useRef([]),d=l.useRef(new Map),f=l.useRef(new Je).current,[E,V]=l.useState(!1),[A,L]=l.useState(null),[P,k]=l.useState(!1),[j,z]=l.useState(null),w=l.useCallback(c=>{u.current?c():o.current.push(c)},[]),N=l.useCallback(c=>{var m,v,I,R,i,n,T,y,p,C,O,Y;switch(c.type){case"cryptoCheck":z(!!((m=c.payload)!=null&&m.subtle&&((v=c.payload)!=null&&v.secureContext)));break;case"TIUN_SNIPPET_INITIALIZED":{u.current=!0,k(!0),f.emit("ready",void 0);const $=o.current;o.current=[],$.forEach(e=>e());break}case"TIUN_USER_CHANGE":{const $=!!((I=c.payload)!=null&&I.isAuthenticated),e=((R=c.payload)==null?void 0:R.user)??null;V($),L(e),f.emit("userChange",{isAuthenticated:$,user:e}),((i=c.payload)==null?void 0:i.userEvent)==="login"&&f.emit("login",{user:e}),((n=c.payload)==null?void 0:n.userEvent)==="logout"&&f.emit("logout",void 0);break}case"TIUN_VERIFICATION_TOKEN":{const $=((T=c.payload)==null?void 0:T.token)??null,e=(y=c.payload)==null?void 0:y.requestId;e&&d.current.has(e)&&(d.current.get(e)($),d.current.delete(e));break}case"TIUN_SHOW_PAYWALL":f.emit("paywallShow",{isConnected:!!((p=c.payload)!=null&&p.isConnected)});break;case"TIUN_HIDE_PAYWALL":f.emit("paywallHide",{sessionId:((C=c.payload)==null?void 0:C.sessionId)??"",isConnected:((O=c.payload)==null?void 0:O.isConnected)??!0});break;case"TIUN_ERROR":f.emit("error",((Y=c.payload)==null?void 0:Y.error)??c.payload??{});break}},[f]);l.useEffect(()=>{const c=v=>{if(!v||!Ue(t,v))return;const I=Te(v);w(()=>{var R;return(R=a.current)==null?void 0:R.resolveCheckout(I)})},m=b.Linking.addEventListener("url",({url:v})=>c(v));return b.Linking.getInitialURL().then(c).catch(()=>{}),()=>m.remove()},[t,w]);const q=l.useCallback(()=>w(()=>{var c;return(c=a.current)==null?void 0:c.login()}),[w]),U=l.useCallback(()=>w(()=>{var c;return(c=a.current)==null?void 0:c.logout()}),[w]),B=l.useCallback(c=>w(()=>{var m;return(m=a.current)==null?void 0:m.checkout(c==null?void 0:c.productId,c==null?void 0:c.referenceId)}),[w]),D=l.useCallback(()=>new Promise(c=>{const m=`vt_${Math.random().toString(36).slice(2)}_${Date.now()}`;let v=!1;const I=R=>{v||(v=!0,d.current.delete(m),c(R))};d.current.set(m,I),w(()=>{var R;return(R=a.current)==null?void 0:R.getVerificationToken(m)}),setTimeout(()=>I(null),5e3)}),[w]),G=l.useMemo(()=>({isAuthenticated:E,user:A,ready:P,cryptoOk:j,login:q,logout:U,checkout:B,getUserVerificationToken:D}),[E,A,P,j,q,U,B,D]);return g.jsx(Ee.Provider,{value:G,children:g.jsxs(be.Provider,{value:f,children:[r,g.jsx(Ke,{ref:a,config:t,onEvent:N})]})})}function Me(){const t=l.useContext(Ee);if(!t)throw new Error("useTiun must be used within a <TiunProvider>");return t}function Xe(t,r){const a=l.useContext(be),u=l.useRef(r);u.current=r,l.useEffect(()=>{if(!a)throw new Error("useTiunEvent must be used within a <TiunProvider>");return a.on(t,o=>u.current(o))},[a,t])}exports.TiunProvider=ze;exports.useTiun=Me;exports.useTiunEvent=Xe;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Ne = Object.defineProperty;
|
|
2
2
|
var Ce = (r, t, a) => t in r ? Ne(r, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : r[t] = a;
|
|
3
3
|
var Te = (r, t, a) => (Ce(r, typeof t != "symbol" ? t + "" : t, a), a);
|
|
4
|
-
import
|
|
4
|
+
import Oe, { forwardRef as Ie, useRef as P, useState as z, useEffect as oe, useImperativeHandle as Pe, createContext as ve, useCallback as K, useMemo as xe, useContext as _e } from "react";
|
|
5
5
|
import { StyleSheet as ie, View as ne, Text as te, Pressable as Ae, useColorScheme as Ue, AppState as je, useWindowDimensions as $e, Platform as Fe, Linking as Ee } from "react-native";
|
|
6
6
|
import { WebView as Le } from "react-native-webview";
|
|
7
7
|
import { close as We, closeAuth as Ve, openAuth as Ye, open as be } from "react-native-inappbrowser-nitro";
|
|
@@ -27,8 +27,8 @@ function De() {
|
|
|
27
27
|
var d = null;
|
|
28
28
|
if (u !== void 0 && (d = "" + u), o.key !== void 0 && (d = "" + o.key), "key" in o) {
|
|
29
29
|
u = {};
|
|
30
|
-
for (var
|
|
31
|
-
|
|
30
|
+
for (var T in o)
|
|
31
|
+
T !== "key" && (u[T] = o[T]);
|
|
32
32
|
} else
|
|
33
33
|
u = o;
|
|
34
34
|
return o = u.ref, {
|
|
@@ -58,11 +58,11 @@ function Ke() {
|
|
|
58
58
|
if (e == null)
|
|
59
59
|
return null;
|
|
60
60
|
if (typeof e == "function")
|
|
61
|
-
return e.$$typeof ===
|
|
61
|
+
return e.$$typeof === m ? null : e.displayName || e.name || null;
|
|
62
62
|
if (typeof e == "string")
|
|
63
63
|
return e;
|
|
64
64
|
switch (e) {
|
|
65
|
-
case
|
|
65
|
+
case b:
|
|
66
66
|
return "Fragment";
|
|
67
67
|
case V:
|
|
68
68
|
return "Profiler";
|
|
@@ -70,9 +70,9 @@ function Ke() {
|
|
|
70
70
|
return "StrictMode";
|
|
71
71
|
case H:
|
|
72
72
|
return "Suspense";
|
|
73
|
-
case
|
|
73
|
+
case c:
|
|
74
74
|
return "SuspenseList";
|
|
75
|
-
case
|
|
75
|
+
case O:
|
|
76
76
|
return "Activity";
|
|
77
77
|
}
|
|
78
78
|
if (typeof e == "object")
|
|
@@ -86,14 +86,14 @@ function Ke() {
|
|
|
86
86
|
case U:
|
|
87
87
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
88
88
|
case G:
|
|
89
|
-
var
|
|
90
|
-
return e = e.displayName, e || (e =
|
|
91
|
-
case
|
|
92
|
-
return
|
|
93
|
-
case
|
|
94
|
-
|
|
89
|
+
var s = e.render;
|
|
90
|
+
return e = e.displayName, e || (e = s.displayName || s.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
91
|
+
case _:
|
|
92
|
+
return s = e.displayName || null, s !== null ? s : r(e.type) || "Memo";
|
|
93
|
+
case y:
|
|
94
|
+
s = e._payload, e = e._init;
|
|
95
95
|
try {
|
|
96
|
-
return r(e(
|
|
96
|
+
return r(e(s));
|
|
97
97
|
} catch {
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -105,28 +105,28 @@ function Ke() {
|
|
|
105
105
|
function a(e) {
|
|
106
106
|
try {
|
|
107
107
|
t(e);
|
|
108
|
-
var
|
|
108
|
+
var s = !1;
|
|
109
109
|
} catch {
|
|
110
|
-
|
|
110
|
+
s = !0;
|
|
111
111
|
}
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
var
|
|
115
|
-
return
|
|
116
|
-
|
|
112
|
+
if (s) {
|
|
113
|
+
s = console;
|
|
114
|
+
var p = s.error, w = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
115
|
+
return p.call(
|
|
116
|
+
s,
|
|
117
117
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
118
|
-
|
|
118
|
+
w
|
|
119
119
|
), t(e);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
function l(e) {
|
|
123
|
-
if (e ===
|
|
123
|
+
if (e === b)
|
|
124
124
|
return "<>";
|
|
125
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
125
|
+
if (typeof e == "object" && e !== null && e.$$typeof === y)
|
|
126
126
|
return "<...>";
|
|
127
127
|
try {
|
|
128
|
-
var
|
|
129
|
-
return
|
|
128
|
+
var s = r(e);
|
|
129
|
+
return s ? "<" + s + ">" : "<...>";
|
|
130
130
|
} catch {
|
|
131
131
|
return "<...>";
|
|
132
132
|
}
|
|
@@ -140,21 +140,21 @@ function Ke() {
|
|
|
140
140
|
}
|
|
141
141
|
function d(e) {
|
|
142
142
|
if (n.call(e, "key")) {
|
|
143
|
-
var
|
|
144
|
-
if (
|
|
143
|
+
var s = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
144
|
+
if (s && s.isReactWarning)
|
|
145
145
|
return !1;
|
|
146
146
|
}
|
|
147
147
|
return e.key !== void 0;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
function
|
|
151
|
-
|
|
149
|
+
function T(e, s) {
|
|
150
|
+
function p() {
|
|
151
|
+
f || (f = !0, console.error(
|
|
152
152
|
"%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://react.dev/link/special-props)",
|
|
153
|
-
|
|
153
|
+
s
|
|
154
154
|
));
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
get:
|
|
156
|
+
p.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
157
|
+
get: p,
|
|
158
158
|
configurable: !0
|
|
159
159
|
});
|
|
160
160
|
}
|
|
@@ -164,14 +164,14 @@ function Ke() {
|
|
|
164
164
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
165
165
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
166
166
|
}
|
|
167
|
-
function x(e,
|
|
168
|
-
return
|
|
167
|
+
function x(e, s, p, w, L, I, ce, se) {
|
|
168
|
+
return p = I.ref, e = {
|
|
169
169
|
$$typeof: A,
|
|
170
170
|
type: e,
|
|
171
|
-
key:
|
|
172
|
-
props:
|
|
171
|
+
key: s,
|
|
172
|
+
props: I,
|
|
173
173
|
_owner: L
|
|
174
|
-
}, (
|
|
174
|
+
}, (p !== void 0 ? p : null) !== null ? Object.defineProperty(e, "ref", {
|
|
175
175
|
enumerable: !1,
|
|
176
176
|
get: W
|
|
177
177
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
@@ -196,54 +196,54 @@ function Ke() {
|
|
|
196
196
|
value: se
|
|
197
197
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
198
198
|
}
|
|
199
|
-
function F(e,
|
|
200
|
-
var
|
|
201
|
-
if (
|
|
202
|
-
if (
|
|
203
|
-
if (
|
|
204
|
-
for (
|
|
205
|
-
C(w
|
|
206
|
-
Object.freeze && Object.freeze(
|
|
199
|
+
function F(e, s, p, w, L, I, ce, se) {
|
|
200
|
+
var v = s.children;
|
|
201
|
+
if (v !== void 0)
|
|
202
|
+
if (w)
|
|
203
|
+
if (h(v)) {
|
|
204
|
+
for (w = 0; w < v.length; w++)
|
|
205
|
+
C(v[w]);
|
|
206
|
+
Object.freeze && Object.freeze(v);
|
|
207
207
|
} else
|
|
208
208
|
console.error(
|
|
209
209
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
210
210
|
);
|
|
211
211
|
else
|
|
212
|
-
C(
|
|
213
|
-
if (n.call(
|
|
214
|
-
|
|
215
|
-
var D = Object.keys(
|
|
212
|
+
C(v);
|
|
213
|
+
if (n.call(s, "key")) {
|
|
214
|
+
v = r(e);
|
|
215
|
+
var D = Object.keys(s).filter(function(ge) {
|
|
216
216
|
return ge !== "key";
|
|
217
217
|
});
|
|
218
|
-
|
|
218
|
+
w = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", j[v + w] || (D = 0 < D.length ? "{" + D.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
219
219
|
`A props object containing a "key" prop is being spread into JSX:
|
|
220
220
|
let props = %s;
|
|
221
221
|
<%s {...props} />
|
|
222
222
|
React keys must be passed directly to JSX without using spread:
|
|
223
223
|
let props = %s;
|
|
224
224
|
<%s key={someKey} {...props} />`,
|
|
225
|
-
y,
|
|
226
225
|
w,
|
|
226
|
+
v,
|
|
227
227
|
D,
|
|
228
|
-
|
|
229
|
-
), j[
|
|
228
|
+
v
|
|
229
|
+
), j[v + w] = !0);
|
|
230
230
|
}
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
for (var le in
|
|
234
|
-
le !== "key" && (
|
|
231
|
+
if (v = null, p !== void 0 && (a(p), v = "" + p), d(s) && (a(s.key), v = "" + s.key), "key" in s) {
|
|
232
|
+
p = {};
|
|
233
|
+
for (var le in s)
|
|
234
|
+
le !== "key" && (p[le] = s[le]);
|
|
235
235
|
} else
|
|
236
|
-
|
|
237
|
-
return
|
|
238
|
-
|
|
236
|
+
p = s;
|
|
237
|
+
return v && T(
|
|
238
|
+
p,
|
|
239
239
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
240
240
|
), x(
|
|
241
241
|
e,
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
v,
|
|
243
|
+
I,
|
|
244
244
|
L,
|
|
245
245
|
o(),
|
|
246
|
-
|
|
246
|
+
p,
|
|
247
247
|
ce,
|
|
248
248
|
se
|
|
249
249
|
);
|
|
@@ -251,7 +251,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
251
251
|
function C(e) {
|
|
252
252
|
typeof e == "object" && e !== null && e.$$typeof === A && e._store && (e._store.validated = 1);
|
|
253
253
|
}
|
|
254
|
-
var R =
|
|
254
|
+
var R = Oe, A = Symbol.for("react.transitional.element"), M = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), V = Symbol.for("react.profiler"), U = Symbol.for("react.consumer"), B = Symbol.for("react.context"), G = Symbol.for("react.forward_ref"), H = Symbol.for("react.suspense"), c = Symbol.for("react.suspense_list"), _ = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), m = Symbol.for("react.client.reference"), i = R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, n = Object.prototype.hasOwnProperty, h = Array.isArray, E = console.createTask ? console.createTask : function() {
|
|
255
255
|
return null;
|
|
256
256
|
};
|
|
257
257
|
R = {
|
|
@@ -259,33 +259,33 @@ React keys must be passed directly to JSX without using spread:
|
|
|
259
259
|
return e();
|
|
260
260
|
}
|
|
261
261
|
};
|
|
262
|
-
var
|
|
262
|
+
var f, g = {}, N = R["react-stack-bottom-frame"].bind(
|
|
263
263
|
R,
|
|
264
264
|
u
|
|
265
|
-
)(), Y =
|
|
266
|
-
Q.Fragment =
|
|
267
|
-
var
|
|
265
|
+
)(), Y = E(l(u)), j = {};
|
|
266
|
+
Q.Fragment = b, Q.jsx = function(e, s, p, w, L) {
|
|
267
|
+
var I = 1e4 > i.recentlyCreatedOwnerStacks++;
|
|
268
268
|
return F(
|
|
269
269
|
e,
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
s,
|
|
271
|
+
p,
|
|
272
272
|
!1,
|
|
273
|
-
|
|
273
|
+
w,
|
|
274
274
|
L,
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
I ? Error("react-stack-top-frame") : N,
|
|
276
|
+
I ? E(l(e)) : Y
|
|
277
277
|
);
|
|
278
|
-
}, Q.jsxs = function(e,
|
|
279
|
-
var
|
|
278
|
+
}, Q.jsxs = function(e, s, p, w, L) {
|
|
279
|
+
var I = 1e4 > i.recentlyCreatedOwnerStacks++;
|
|
280
280
|
return F(
|
|
281
281
|
e,
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
s,
|
|
283
|
+
p,
|
|
284
284
|
!0,
|
|
285
|
-
|
|
285
|
+
w,
|
|
286
286
|
L,
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
I ? Error("react-stack-top-frame") : N,
|
|
288
|
+
I ? E(l(e)) : Y
|
|
289
289
|
);
|
|
290
290
|
};
|
|
291
291
|
}()), Q;
|
|
@@ -548,26 +548,26 @@ const $ = ie.create({
|
|
|
548
548
|
function J(r) {
|
|
549
549
|
return `try{window.tiunHost&&${r};}catch(e){}; true;`;
|
|
550
550
|
}
|
|
551
|
-
const ht =
|
|
551
|
+
const ht = Ie(
|
|
552
552
|
function({ config: t, onEvent: a }, l) {
|
|
553
|
-
const o = !!t.debug, u = Ue(), d = t.appearance === "dark" || t.appearance === "auto" && u === "dark" ? "dark" : "light",
|
|
553
|
+
const o = !!t.debug, u = Ue(), d = t.appearance === "dark" || t.appearance === "auto" && u === "dark" ? "dark" : "light", T = P(null), [W, x] = z(!1), [F, C] = z(!1), R = P(!1), A = P(!1), M = () => {
|
|
554
554
|
var i;
|
|
555
|
-
C(!1), (i =
|
|
555
|
+
C(!1), (i = T.current) == null || i.reload();
|
|
556
556
|
};
|
|
557
557
|
oe(() => {
|
|
558
558
|
if (!F)
|
|
559
559
|
return;
|
|
560
560
|
const i = je.addEventListener("change", (n) => {
|
|
561
|
-
var
|
|
562
|
-
n === "active" && (C(!1), (
|
|
561
|
+
var h;
|
|
562
|
+
n === "active" && (C(!1), (h = T.current) == null || h.reload());
|
|
563
563
|
});
|
|
564
564
|
return () => i.remove();
|
|
565
565
|
}, [F]);
|
|
566
|
-
const
|
|
567
|
-
var
|
|
568
|
-
return (
|
|
566
|
+
const b = `window.${Qe} = true;window.__TIUN_CONFIG__ = Object.assign({}, window.__TIUN_CONFIG__, { returnUrl: ${JSON.stringify(et(t))}, appearance: ${JSON.stringify(d)} });true;`, k = (i, ...n) => {
|
|
567
|
+
var h;
|
|
568
|
+
return (h = T.current) == null ? void 0 : h.injectJavaScript(
|
|
569
569
|
J(
|
|
570
|
-
`window.tiunHost.${i}(${n.map((
|
|
570
|
+
`window.tiunHost.${i}(${n.map((E) => JSON.stringify(E) ?? "null").join(",")})`
|
|
571
571
|
)
|
|
572
572
|
);
|
|
573
573
|
}, V = P(d);
|
|
@@ -578,41 +578,41 @@ const ht = Oe(
|
|
|
578
578
|
var n;
|
|
579
579
|
A.current || (A.current = !0, We().catch(() => {
|
|
580
580
|
}), Ve().catch(() => {
|
|
581
|
-
}), x(!0), (n =
|
|
581
|
+
}), x(!0), (n = T.current) == null || n.injectJavaScript(
|
|
582
582
|
J(
|
|
583
583
|
`window.tiunHost.resolveCheckout(${i ? JSON.stringify(i) : ""})`
|
|
584
584
|
)
|
|
585
585
|
));
|
|
586
586
|
}, B = (i) => {
|
|
587
|
-
var n,
|
|
587
|
+
var n, h, E;
|
|
588
588
|
switch (i.type) {
|
|
589
589
|
case q.popPubKeyRequest:
|
|
590
|
-
return nt(re(t)).then((
|
|
591
|
-
o && console.warn("[tiun] ensurePopKey failed:",
|
|
590
|
+
return nt(re(t)).then((f) => k("popPubKey", f)).catch((f) => {
|
|
591
|
+
o && console.warn("[tiun] ensurePopKey failed:", f), k("popPubKey", null);
|
|
592
592
|
}), !0;
|
|
593
593
|
case q.tokenGet:
|
|
594
594
|
return (async () => {
|
|
595
595
|
try {
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
596
|
+
const f = await st(Z(t));
|
|
597
|
+
if (f && !await ot(re(t))) {
|
|
598
598
|
await ue(Z(t)), k("restoreToken", null);
|
|
599
599
|
return;
|
|
600
600
|
}
|
|
601
|
-
k("restoreToken",
|
|
601
|
+
k("restoreToken", f);
|
|
602
602
|
} catch {
|
|
603
603
|
k("restoreToken", null);
|
|
604
604
|
}
|
|
605
605
|
})(), !0;
|
|
606
606
|
case q.popSignRequest: {
|
|
607
|
-
const
|
|
608
|
-
return it(re(t), g).then((N) => k("popSignResult",
|
|
607
|
+
const f = (n = i.payload) == null ? void 0 : n.requestId, g = (h = i.payload) == null ? void 0 : h.information;
|
|
608
|
+
return it(re(t), g).then((N) => k("popSignResult", f, N, null)).catch((N) => {
|
|
609
609
|
const Y = (N == null ? void 0 : N.code) ?? "sign_failed";
|
|
610
|
-
o && console.warn("[tiun] popSign failed:", N), k("popSignResult",
|
|
610
|
+
o && console.warn("[tiun] popSign failed:", N), k("popSignResult", f, null, String(Y));
|
|
611
611
|
}), !0;
|
|
612
612
|
}
|
|
613
613
|
case q.tokenPersist: {
|
|
614
|
-
const
|
|
615
|
-
return (
|
|
614
|
+
const f = ((E = i.payload) == null ? void 0 : E.token) ?? null;
|
|
615
|
+
return (f ? lt(Z(t), f) : ue(Z(t))).catch(
|
|
616
616
|
(g) => o && console.warn("[tiun] token persist failed:", g)
|
|
617
617
|
), !0;
|
|
618
618
|
}
|
|
@@ -630,27 +630,29 @@ const ht = Oe(
|
|
|
630
630
|
() => ({
|
|
631
631
|
login: () => {
|
|
632
632
|
var i;
|
|
633
|
-
x(!0), (i =
|
|
633
|
+
x(!0), (i = T.current) == null || i.injectJavaScript(
|
|
634
634
|
J("window.tiunHost.login()")
|
|
635
635
|
);
|
|
636
636
|
},
|
|
637
|
-
checkout: (i) => {
|
|
638
|
-
var
|
|
639
|
-
x(!0), R.current = !0, A.current = !1
|
|
637
|
+
checkout: (i, n) => {
|
|
638
|
+
var E;
|
|
639
|
+
x(!0), R.current = !0, A.current = !1;
|
|
640
|
+
const h = n ? [i || null, n] : i ? [i] : [];
|
|
641
|
+
(E = T.current) == null || E.injectJavaScript(
|
|
640
642
|
J(
|
|
641
|
-
`window.tiunHost.checkout(${
|
|
643
|
+
`window.tiunHost.checkout(${h.map((f) => JSON.stringify(f)).join(",")})`
|
|
642
644
|
)
|
|
643
645
|
);
|
|
644
646
|
},
|
|
645
647
|
logout: () => {
|
|
646
648
|
var i;
|
|
647
|
-
return (i =
|
|
649
|
+
return (i = T.current) == null ? void 0 : i.injectJavaScript(
|
|
648
650
|
J("window.tiunHost.logout()")
|
|
649
651
|
);
|
|
650
652
|
},
|
|
651
653
|
getVerificationToken: (i) => {
|
|
652
654
|
var n;
|
|
653
|
-
return (n =
|
|
655
|
+
return (n = T.current) == null ? void 0 : n.injectJavaScript(
|
|
654
656
|
J(
|
|
655
657
|
`window.tiunHost.getVerificationToken(${i ? JSON.stringify(i) : ""})`
|
|
656
658
|
)
|
|
@@ -659,14 +661,14 @@ const ht = Oe(
|
|
|
659
661
|
resolveCheckout: U,
|
|
660
662
|
reload: () => {
|
|
661
663
|
var i;
|
|
662
|
-
return (i =
|
|
664
|
+
return (i = T.current) == null ? void 0 : i.reload();
|
|
663
665
|
}
|
|
664
666
|
}),
|
|
665
667
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
666
668
|
[]
|
|
667
669
|
);
|
|
668
670
|
const G = (i) => {
|
|
669
|
-
var
|
|
671
|
+
var h, E, f;
|
|
670
672
|
let n = null;
|
|
671
673
|
try {
|
|
672
674
|
n = JSON.parse(i.nativeEvent.data);
|
|
@@ -681,14 +683,14 @@ const ht = Oe(
|
|
|
681
683
|
if (n.type === "console") {
|
|
682
684
|
o && console.log(
|
|
683
685
|
"[tiun webview]",
|
|
684
|
-
(
|
|
685
|
-
(
|
|
686
|
+
(h = n.payload) == null ? void 0 : h.level,
|
|
687
|
+
(E = n.payload) == null ? void 0 : E.message
|
|
686
688
|
);
|
|
687
689
|
return;
|
|
688
690
|
}
|
|
689
691
|
if ((n.type === "cryptoCheck" || n.type === "hostBridgeReady") && C(!1), o && console.log("[tiun] <-", n.type, n.payload), !B(n)) {
|
|
690
692
|
if (n.type === q.overlayChange) {
|
|
691
|
-
const g = !!((
|
|
693
|
+
const g = !!((f = n.payload) != null && f.overlay);
|
|
692
694
|
x(g), g || (R.current = !1);
|
|
693
695
|
}
|
|
694
696
|
a(n);
|
|
@@ -711,7 +713,7 @@ const ht = Oe(
|
|
|
711
713
|
}).catch(
|
|
712
714
|
(n) => o && console.warn("[tiun] in-app browser open error:", n)
|
|
713
715
|
);
|
|
714
|
-
},
|
|
716
|
+
}, c = (i) => {
|
|
715
717
|
be(i, {
|
|
716
718
|
modalPresentationStyle: "fullScreen",
|
|
717
719
|
modalEnabled: !0,
|
|
@@ -720,34 +722,34 @@ const ht = Oe(
|
|
|
720
722
|
}).catch(
|
|
721
723
|
(n) => o && console.warn("[tiun] in-app browser open failed:", n)
|
|
722
724
|
);
|
|
723
|
-
},
|
|
724
|
-
var
|
|
725
|
-
const n = (
|
|
726
|
-
n && (R.current ? H(n) :
|
|
727
|
-
},
|
|
725
|
+
}, _ = (i) => {
|
|
726
|
+
var h;
|
|
727
|
+
const n = (h = i.nativeEvent) == null ? void 0 : h.targetUrl;
|
|
728
|
+
n && (R.current ? H(n) : c(n));
|
|
729
|
+
}, y = (i) => {
|
|
728
730
|
const n = i.url;
|
|
729
|
-
return n.startsWith(fe(t)) || n.startsWith("about:") || n.startsWith("data:") || n === "about:blank" ? !0 : n.startsWith("http://") || n.startsWith("https://") ? (R.current && i.isTopFrame !== !1 ? H(n) :
|
|
730
|
-
}, { width:
|
|
731
|
+
return n.startsWith(fe(t)) || n.startsWith("about:") || n.startsWith("data:") || n === "about:blank" ? !0 : n.startsWith("http://") || n.startsWith("https://") ? (R.current && i.isTopFrame !== !1 ? H(n) : c(n), !1) : !0;
|
|
732
|
+
}, { width: O, height: m } = $e();
|
|
731
733
|
return /* @__PURE__ */ S.jsxs(
|
|
732
734
|
ne,
|
|
733
735
|
{
|
|
734
736
|
pointerEvents: W ? "auto" : "none",
|
|
735
737
|
style: [
|
|
736
738
|
ee.container,
|
|
737
|
-
{ width:
|
|
739
|
+
{ width: O, height: m },
|
|
738
740
|
W ? ee.visible : ee.hidden
|
|
739
741
|
],
|
|
740
742
|
children: [
|
|
741
743
|
/* @__PURE__ */ S.jsx(
|
|
742
744
|
pt,
|
|
743
745
|
{
|
|
744
|
-
ref:
|
|
746
|
+
ref: T,
|
|
745
747
|
source: { uri: tt(t) },
|
|
746
748
|
originWhitelist: ["*"],
|
|
747
749
|
onMessage: G,
|
|
748
|
-
onShouldStartLoadWithRequest:
|
|
749
|
-
onOpenWindow:
|
|
750
|
-
injectedJavaScriptBeforeContentLoaded:
|
|
750
|
+
onShouldStartLoadWithRequest: y,
|
|
751
|
+
onOpenWindow: _,
|
|
752
|
+
injectedJavaScriptBeforeContentLoaded: b,
|
|
751
753
|
javaScriptEnabled: !0,
|
|
752
754
|
domStorageEnabled: !0,
|
|
753
755
|
style: ee.webview,
|
|
@@ -810,14 +812,14 @@ class Tt {
|
|
|
810
812
|
}
|
|
811
813
|
const Re = ve(null), ke = ve(null);
|
|
812
814
|
function mt({ config: r, children: t }) {
|
|
813
|
-
const a = P(null), l = P(!1), o = P([]), u = P(/* @__PURE__ */ new Map()), d = P(new Tt()).current, [
|
|
814
|
-
l.current ?
|
|
815
|
+
const a = P(null), l = P(!1), o = P([]), u = P(/* @__PURE__ */ new Map()), d = P(new Tt()).current, [T, W] = z(!1), [x, F] = z(null), [C, R] = z(!1), [A, M] = z(null), b = K((c) => {
|
|
816
|
+
l.current ? c() : o.current.push(c);
|
|
815
817
|
}, []), k = K(
|
|
816
|
-
(
|
|
817
|
-
var
|
|
818
|
-
switch (
|
|
818
|
+
(c) => {
|
|
819
|
+
var _, y, O, m, i, n, h, E, f, g, N, Y;
|
|
820
|
+
switch (c.type) {
|
|
819
821
|
case "cryptoCheck":
|
|
820
|
-
M(!!((
|
|
822
|
+
M(!!((_ = c.payload) != null && _.subtle && ((y = c.payload) != null && y.secureContext)));
|
|
821
823
|
break;
|
|
822
824
|
case "TIUN_SNIPPET_INITIALIZED": {
|
|
823
825
|
l.current = !0, R(!0), d.emit("ready", void 0);
|
|
@@ -826,72 +828,72 @@ function mt({ config: r, children: t }) {
|
|
|
826
828
|
break;
|
|
827
829
|
}
|
|
828
830
|
case "TIUN_USER_CHANGE": {
|
|
829
|
-
const j = !!((
|
|
830
|
-
W(j), F(e), d.emit("userChange", { isAuthenticated: j, user: e }), ((i =
|
|
831
|
+
const j = !!((O = c.payload) != null && O.isAuthenticated), e = ((m = c.payload) == null ? void 0 : m.user) ?? null;
|
|
832
|
+
W(j), F(e), d.emit("userChange", { isAuthenticated: j, user: e }), ((i = c.payload) == null ? void 0 : i.userEvent) === "login" && d.emit("login", { user: e }), ((n = c.payload) == null ? void 0 : n.userEvent) === "logout" && d.emit("logout", void 0);
|
|
831
833
|
break;
|
|
832
834
|
}
|
|
833
835
|
case "TIUN_VERIFICATION_TOKEN": {
|
|
834
|
-
const j = ((
|
|
836
|
+
const j = ((h = c.payload) == null ? void 0 : h.token) ?? null, e = (E = c.payload) == null ? void 0 : E.requestId;
|
|
835
837
|
e && u.current.has(e) && (u.current.get(e)(j), u.current.delete(e));
|
|
836
838
|
break;
|
|
837
839
|
}
|
|
838
840
|
case "TIUN_SHOW_PAYWALL":
|
|
839
|
-
d.emit("paywallShow", { isConnected: !!((
|
|
841
|
+
d.emit("paywallShow", { isConnected: !!((f = c.payload) != null && f.isConnected) });
|
|
840
842
|
break;
|
|
841
843
|
case "TIUN_HIDE_PAYWALL":
|
|
842
844
|
d.emit("paywallHide", {
|
|
843
|
-
sessionId: ((g =
|
|
844
|
-
isConnected: ((N =
|
|
845
|
+
sessionId: ((g = c.payload) == null ? void 0 : g.sessionId) ?? "",
|
|
846
|
+
isConnected: ((N = c.payload) == null ? void 0 : N.isConnected) ?? !0
|
|
845
847
|
});
|
|
846
848
|
break;
|
|
847
849
|
case "TIUN_ERROR":
|
|
848
|
-
d.emit("error", ((Y =
|
|
850
|
+
d.emit("error", ((Y = c.payload) == null ? void 0 : Y.error) ?? c.payload ?? {});
|
|
849
851
|
break;
|
|
850
852
|
}
|
|
851
853
|
},
|
|
852
854
|
[d]
|
|
853
855
|
);
|
|
854
856
|
oe(() => {
|
|
855
|
-
const
|
|
856
|
-
if (!
|
|
857
|
+
const c = (y) => {
|
|
858
|
+
if (!y || !rt(r, y))
|
|
857
859
|
return;
|
|
858
|
-
const
|
|
859
|
-
|
|
860
|
-
var
|
|
861
|
-
return (
|
|
860
|
+
const O = Se(y);
|
|
861
|
+
b(() => {
|
|
862
|
+
var m;
|
|
863
|
+
return (m = a.current) == null ? void 0 : m.resolveCheckout(O);
|
|
862
864
|
});
|
|
863
|
-
},
|
|
864
|
-
return Ee.getInitialURL().then(
|
|
865
|
-
}), () =>
|
|
866
|
-
}, [r,
|
|
867
|
-
const V = K(() =>
|
|
868
|
-
var
|
|
869
|
-
return (
|
|
870
|
-
}), [
|
|
871
|
-
var
|
|
872
|
-
return (
|
|
873
|
-
}), [
|
|
874
|
-
(
|
|
875
|
-
var
|
|
876
|
-
return (
|
|
865
|
+
}, _ = Ee.addEventListener("url", ({ url: y }) => c(y));
|
|
866
|
+
return Ee.getInitialURL().then(c).catch(() => {
|
|
867
|
+
}), () => _.remove();
|
|
868
|
+
}, [r, b]);
|
|
869
|
+
const V = K(() => b(() => {
|
|
870
|
+
var c;
|
|
871
|
+
return (c = a.current) == null ? void 0 : c.login();
|
|
872
|
+
}), [b]), U = K(() => b(() => {
|
|
873
|
+
var c;
|
|
874
|
+
return (c = a.current) == null ? void 0 : c.logout();
|
|
875
|
+
}), [b]), B = K(
|
|
876
|
+
(c) => b(() => {
|
|
877
|
+
var _;
|
|
878
|
+
return (_ = a.current) == null ? void 0 : _.checkout(c == null ? void 0 : c.productId, c == null ? void 0 : c.referenceId);
|
|
877
879
|
}),
|
|
878
|
-
[
|
|
880
|
+
[b]
|
|
879
881
|
), G = K(
|
|
880
|
-
() => new Promise((
|
|
881
|
-
const
|
|
882
|
-
let
|
|
883
|
-
const
|
|
884
|
-
|
|
882
|
+
() => new Promise((c) => {
|
|
883
|
+
const _ = `vt_${Math.random().toString(36).slice(2)}_${Date.now()}`;
|
|
884
|
+
let y = !1;
|
|
885
|
+
const O = (m) => {
|
|
886
|
+
y || (y = !0, u.current.delete(_), c(m));
|
|
885
887
|
};
|
|
886
|
-
u.current.set(
|
|
887
|
-
var
|
|
888
|
-
return (
|
|
889
|
-
}), setTimeout(() =>
|
|
888
|
+
u.current.set(_, O), b(() => {
|
|
889
|
+
var m;
|
|
890
|
+
return (m = a.current) == null ? void 0 : m.getVerificationToken(_);
|
|
891
|
+
}), setTimeout(() => O(null), 5e3);
|
|
890
892
|
}),
|
|
891
|
-
[
|
|
893
|
+
[b]
|
|
892
894
|
), H = xe(
|
|
893
895
|
() => ({
|
|
894
|
-
isAuthenticated:
|
|
896
|
+
isAuthenticated: T,
|
|
895
897
|
user: x,
|
|
896
898
|
ready: C,
|
|
897
899
|
cryptoOk: A,
|
|
@@ -900,7 +902,7 @@ function mt({ config: r, children: t }) {
|
|
|
900
902
|
checkout: B,
|
|
901
903
|
getUserVerificationToken: G
|
|
902
904
|
}),
|
|
903
|
-
[
|
|
905
|
+
[T, x, C, A, V, U, B, G]
|
|
904
906
|
);
|
|
905
907
|
return /* @__PURE__ */ S.jsx(Re.Provider, { value: H, children: /* @__PURE__ */ S.jsxs(ke.Provider, { value: d, children: [
|
|
906
908
|
t,
|