@openfort/openfort-js 0.9.2 → 0.9.4
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/cjs/packages/internal/openapi-clients/dist/index.js +1 -1
- package/dist/cjs/sdk/src/api/auth.js +1 -1
- package/dist/cjs/sdk/src/api/embeddedWallet.js +1 -1
- package/dist/cjs/sdk/src/api/proxy.js +1 -1
- package/dist/cjs/sdk/src/api/user.js +1 -1
- package/dist/cjs/sdk/src/auth/authManager.js +1 -1
- package/dist/cjs/sdk/src/core/config/config.js +1 -1
- package/dist/cjs/sdk/src/core/errors/openfortError.js +1 -1
- package/dist/cjs/sdk/src/core/openfort.js +1 -1
- package/dist/cjs/sdk/src/core/openfortInternal.js +1 -1
- package/dist/cjs/sdk/src/storage/istorage.js +1 -1
- package/dist/cjs/sdk/src/types/types.js +1 -1
- package/dist/cjs/sdk/src/utils/debug.js +1 -0
- package/dist/cjs/sdk/src/version.js +1 -1
- package/dist/cjs/sdk/src/wallets/embedded.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/addEthereumChain.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/evmProvider.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/revokeSession.js +1 -1
- package/dist/cjs/sdk/src/wallets/iframeManager.js +1 -1
- package/dist/cjs/sdk/src/wallets/messaging/ReactNativeMessenger.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/CallOptions.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/PenpalBugError.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/PenpalError.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/Reply.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/backwardCompatibility.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/connect.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/connectCallHandler.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/connectRemoteProxy.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/errorSerialization.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/getPromiseWithResolvers.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/guards.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/messengers/WindowMessenger.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/methodSerialization.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/namespace.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/once.js +1 -0
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/shakeHands.js +1 -0
- package/dist/cjs/sdk/src/wallets/types.js +1 -1
- package/dist/index.d.ts +71 -34
- package/dist/packages/internal/openapi-clients/dist/index.js +1 -1
- package/dist/sdk/src/api/auth.js +1 -1
- package/dist/sdk/src/api/embeddedWallet.js +1 -1
- package/dist/sdk/src/api/proxy.js +1 -1
- package/dist/sdk/src/api/user.js +1 -1
- package/dist/sdk/src/auth/authManager.js +1 -1
- package/dist/sdk/src/core/config/config.js +1 -1
- package/dist/sdk/src/core/errors/openfortError.js +1 -1
- package/dist/sdk/src/core/openfort.js +1 -1
- package/dist/sdk/src/core/openfortInternal.js +1 -1
- package/dist/sdk/src/storage/istorage.js +1 -1
- package/dist/sdk/src/types/types.js +1 -1
- package/dist/sdk/src/utils/debug.js +1 -0
- package/dist/sdk/src/version.js +1 -1
- package/dist/sdk/src/wallets/embedded.js +1 -1
- package/dist/sdk/src/wallets/evm/addEthereumChain.js +1 -1
- package/dist/sdk/src/wallets/evm/evmProvider.js +1 -1
- package/dist/sdk/src/wallets/evm/revokeSession.js +1 -1
- package/dist/sdk/src/wallets/iframeManager.js +1 -1
- package/dist/sdk/src/wallets/messaging/ReactNativeMessenger.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/CallOptions.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/PenpalBugError.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/PenpalError.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/Reply.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/backwardCompatibility.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/connect.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/connectCallHandler.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/connectRemoteProxy.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/errorSerialization.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/getPromiseWithResolvers.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/guards.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/messengers/WindowMessenger.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/methodSerialization.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/namespace.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/once.js +1 -0
- package/dist/sdk/src/wallets/messaging/browserMessenger/shakeHands.js +1 -0
- package/dist/sdk/src/wallets/types.js +1 -1
- package/package.json +2 -3
- package/dist/cjs/node_modules/penpal/dist/penpal.js +0 -1
- package/dist/cjs/sdk/src/core/configuration/recovery.js +0 -1
- package/dist/cjs/sdk/src/wallets/signer.js +0 -1
- package/dist/node_modules/penpal/dist/penpal.js +0 -1
- package/dist/sdk/src/core/configuration/recovery.js +0 -1
- package/dist/sdk/src/wallets/signer.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../../utils/debug.js"),t=require("./browserMessenger/PenpalError.js");require("./browserMessenger/backwardCompatibility.js");exports.ReactNativeMessenger=class{messagePoster;handlers=new Set;isInitialized=!1;hasBeenUsed=!1;validateMessage;messageBuffer=[];nextNumericId=1;stringToNumericId=new Map;numericToStringId=new Map;constructor(s){if(this.messagePoster=s,!s||"function"!=typeof s.postMessage)throw new t("CONNECTION_DESTROYED","Invalid message poster provided");e.debugLog("ReactNativeMessenger created")}initialize(s){if(this.isInitialized)return void e.debugLog("ReactNativeMessenger already initialized");if(this.hasBeenUsed)throw new t("CONNECTION_DESTROYED","A messenger can only be used for a single connection");this.validateMessage=s?.validateReceivedMessage,this.isInitialized=!0,this.hasBeenUsed=!0,e.debugLog(`ReactNativeMessenger initialized, processing ${this.messageBuffer.length} buffered messages`);const a=[...this.messageBuffer];this.messageBuffer=[],a.forEach(e=>{this.processMessage(e)})}sendMessage(s,a){if(!this.isInitialized)throw new t("CONNECTION_DESTROYED","ReactNativeMessenger not initialized");a&&a.length>0&&e.debugLog("React Native: Ignoring transferables (not supported)"),e.debugLog("ReactNativeMessenger sending message:",s);try{let t=s;"penpal"===s?.namespace&&(t=this.convertToDeprecatedFormat(s),e.debugLog("React Native: Converted message:",t));const a=JSON.stringify(t);this.messagePoster.postMessage(a)}catch(e){throw new t("TRANSMISSION_FAILED",`Failed to send message through React Native WebView: ${e instanceof Error?e.message:String(e)}`)}}addMessageHandler(t){this.handlers.add(t),e.debugLog(`Message handler added, total handlers: ${this.handlers.size}`)}removeMessageHandler(t){this.handlers.delete(t),e.debugLog(`Message handler removed, total handlers: ${this.handlers.size}`)}handleMessage(t){if(e.debugLog("[HANDSHAKE DEBUG] ReactNativeMessenger.handleMessage called with:",t),!this.isInitialized){const s=this.messageBuffer.length+1;return e.debugLog(`[HANDSHAKE DEBUG] ReactNativeMessenger: Message received but not initialized, buffering message (${s} total)`),void this.messageBuffer.push(t)}e.debugLog("[HANDSHAKE DEBUG] ReactNativeMessenger is initialized, processing message"),this.processMessage(t)}processMessage(t){e.debugLog("[HANDSHAKE DEBUG] ReactNativeMessenger processing message:",t);const s=this.convertFromDeprecatedFormat(t);if(e.debugLog("[HANDSHAKE DEBUG] Message after conversion:",s),this.validateMessage&&!this.validateMessage(s))return void e.debugLog("[HANDSHAKE DEBUG] Message validation failed:",s);e.debugLog(`[HANDSHAKE DEBUG] Routing message to ${this.handlers.size} handlers`);let a=0;this.handlers.forEach(t=>{a++;try{e.debugLog(`[HANDSHAKE DEBUG] Calling handler ${a}/${this.handlers.size}`),t(s),e.debugLog(`[HANDSHAKE DEBUG] Handler ${a} completed successfully`)}catch(t){e.debugLog(`[HANDSHAKE DEBUG] Error in handler ${a}:`,t)}})}convertToDeprecatedFormat(t){if("penpal"!==t?.namespace)return t;switch(t.type){case"SYN":{const s={originalMessage:t};return e.debugLog("React Native: Converting SYN to deprecated format to avoid MessagePorts",s),{penpal:"syn",participantId:t.participantId}}case"ACK1":return e.debugLog("React Native: Converting ACK1 to deprecated format",{originalMessage:t}),{penpal:"synAck",methodNames:t.methodPaths||[]};case"ACK2":return e.debugLog("React Native: Converting ACK2 to deprecated format",{originalMessage:t}),{penpal:"ack"};case"REPLY":{e.debugLog("React Native: Converting REPLY to deprecated format",{originalMessage:t});const s=this.getNumericId(t.callId);return t.isError?{penpal:"reply",id:s,resolution:"rejected",returnValue:t.value,returnValueIsError:t.isSerializedErrorInstance||!1}:{penpal:"reply",id:s,resolution:"fulfilled",returnValue:t.value}}case"CALL":e.debugLog("React Native: Converting CALL to deprecated format",{originalMessage:t});return{penpal:"call",id:this.getNumericId(t.id),methodName:t.methodPath.join("."),args:t.args};case"DESTROY":return{namespace:"penpal",type:"DESTROY"};default:return t}}convertFromDeprecatedFormat(t){if(t?.penpal)switch(t.penpal){case"syn":{e.debugLog("[HANDSHAKE DEBUG] React Native: Converting deprecated SYN to modern format",{originalMessage:t});const s={namespace:"penpal",type:"SYN",participantId:t.participantId};return e.debugLog("[HANDSHAKE DEBUG] Converted SYN:",s),s}case"synAck":{e.debugLog("[HANDSHAKE DEBUG] React Native: Converting deprecated synAck to modern ACK1 format",{originalMessage:t});const s={namespace:"penpal",type:"ACK1",methodPaths:t.methodNames?.map(e=>e.split("."))||[],channel:void 0};return e.debugLog("[HANDSHAKE DEBUG] Converted ACK1:",s),s}case"ack":{e.debugLog("[HANDSHAKE DEBUG] React Native: Converting deprecated ack to modern ACK2 format",{originalMessage:t});const s={namespace:"penpal",type:"ACK2",channel:void 0};return e.debugLog("[HANDSHAKE DEBUG] Converted ACK2:",s),s}case"reply":{e.debugLog("React Native: Converting deprecated reply to modern REPLY format",{originalMessage:t});const s=this.getStringId(t.id);s||e.debugLog(`Warning: No string ID mapping found for numeric ID ${t.id}, using as-is`);const a=s||String(t.id);return"fulfilled"===t.resolution?{namespace:"penpal",type:"REPLY",callId:a,value:t.returnValue}:{namespace:"penpal",type:"REPLY",callId:a,isError:!0,value:t.returnValue,isSerializedErrorInstance:t.returnValueIsError||!1}}case"call":{e.debugLog("React Native: Converting deprecated call to modern CALL format",{originalMessage:t});const s=this.getStringId(t.id);return s||e.debugLog(`Warning: No string ID mapping found for numeric ID ${t.id}, using as-is`),{namespace:"penpal",type:"CALL",id:s||String(t.id),methodPath:t.methodName.split("."),args:t.args}}default:return e.debugLog("React Native: Unknown deprecated penpal message type:",t.penpal),t}return t}setupMessagePort(t){e.debugLog("React Native: setupMessagePort called but ignored (MessagePort not supported)")}destroy(){this.isInitialized&&(this.handlers.clear(),this.messageBuffer=[],this.stringToNumericId.clear(),this.numericToStringId.clear(),this.nextNumericId=1,this.isInitialized=!1,this.hasBeenUsed=!1,e.debugLog("ReactNativeMessenger destroyed and ready for reuse"))}reset(){e.debugLog("ReactNativeMessenger reset for reuse"),this.handlers.clear(),this.messageBuffer=[],this.isInitialized=!1,this.hasBeenUsed=!1,this.nextNumericId=1,this.stringToNumericId.clear(),this.numericToStringId.clear()}getNumericId(t){let s=this.stringToNumericId.get(t);return s||(s=this.nextNumericId++,this.stringToNumericId.set(t,s),this.numericToStringId.set(s,t),e.debugLog(`ID mapping created: "${t}" -> ${s}`)),s}getStringId(e){return this.numericToStringId.get(e)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=Symbol("CallOptions");module.exports=class{transferables;timeout;#t=t;constructor(t){this.transferables=t?.transferables,this.timeout=t?.timeout}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class e extends Error{constructor(e){super(`You've hit a bug in Penpal. Please file an issue with the following information: ${e}`)}}module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class r extends Error{code;constructor(r,e){super(e),this.name="PenpalError",this.code=r}}module.exports=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=Symbol("Reply");module.exports=class{value;transferables;#s=s;constructor(s,e){this.value=s,this.transferables=e?.transferables}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./namespace.js"),a=require("./guards.js"),r=require("./PenpalBugError.js");const l="deprecated-penpal";var n,t;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(n||(n={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(t||(t={}));const s=e=>e.split("."),i=e=>e.join("."),p=e=>new r(`Unexpected message to translate: ${JSON.stringify(e)}`);exports.DEPRECATED_PENPAL_PARTICIPANT_ID=l,exports.downgradeMessage=e=>{if(a.isAck1Message(e))return{penpal:n.SynAck,methodNames:e.methodPaths.map(i)};if(a.isCallMessage(e))return{penpal:n.Call,id:e.id,methodName:i(e.methodPath),args:e.args};if(a.isReplyMessage(e))return e.isError?{penpal:n.Reply,id:e.callId,resolution:t.Rejected,...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:n.Reply,id:e.callId,resolution:t.Fulfilled,returnValue:e.value};throw p(e)},exports.isDeprecatedMessage=e=>a.isObject(e)&&"penpal"in e,exports.upgradeMessage=a=>{if(a.penpal===n.Syn)return{namespace:e,channel:void 0,type:"SYN",participantId:l};if(a.penpal===n.SynAck)return{namespace:e,channel:void 0,type:"ACK1",methodPaths:a.methodNames.map(s)};if(a.penpal===n.Ack)return{namespace:e,channel:void 0,type:"ACK2"};if(a.penpal===n.Call)return{namespace:e,channel:void 0,type:"CALL",id:a.id,methodPath:s(a.methodName),args:a.args};if(a.penpal===n.Reply)return a.resolution===t.Fulfilled?{namespace:e,channel:void 0,type:"REPLY",callId:a.id,value:a.returnValue}:{namespace:e,channel:void 0,type:"REPLY",callId:a.id,isError:!0,...a.returnValueIsError?{value:a.returnValue,isSerializedErrorInstance:!0}:{value:a.returnValue}};throw p(a)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./PenpalError.js"),s=require("./shakeHands.js"),n=require("./guards.js"),r=require("./once.js"),t=require("./namespace.js");const o=new WeakSet;module.exports=({messenger:a,methods:i={},timeout:c,channel:d,log:u})=>{if(!a)throw new e("INVALID_ARGUMENT","messenger must be defined");if(o.has(a))throw new e("INVALID_ARGUMENT","A messenger can only be used for a single connection");o.add(a);const g=[a.destroy],h=r(e=>{if(e){const e={namespace:t,channel:d,type:"DESTROY"};try{a.sendMessage(e)}catch(e){}}for(const e of g)e();u?.("Connection destroyed")}),l=e=>n.isMessage(e)&&e.channel===d;return{promise:(async()=>{try{a.initialize({log:u,validateReceivedMessage:l}),a.addMessageHandler(e=>{n.isDestroyMessage(e)&&h(!1)});const{remoteProxy:e,destroy:r}=await s({messenger:a,methods:i,timeout:c,channel:d,log:u});return g.push(r),e}catch(e){throw h(!0),e}})(),destroy:()=>{h(!0)}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./errorSerialization.js"),r=require("./Reply.js"),a=require("./PenpalError.js"),t=require("./methodSerialization.js"),s=require("./guards.js"),n=require("./namespace.js");const o=(r,a,t)=>({namespace:n,channel:r,type:"REPLY",callId:a,isError:!0,...t instanceof Error?{value:e.serializeError(t),isSerializedErrorInstance:!0}:{value:t}});module.exports=(e,i,l,d)=>{let h=!1;const c=async c=>{if(h)return;if(!s.isCallMessage(c))return;d?.(`Received ${t.formatMethodPath(c.methodPath)}() call`,c);const{methodPath:u,args:m,id:M}=c;let f,g;try{const e=t.getMethodAtMethodPath(u,i);if(!e)throw new a("METHOD_NOT_FOUND",`Method \`${t.formatMethodPath(u)}\` is not found.`);let s=await e(...m);s instanceof r&&(g=s.transferables,s=await s.value),f={namespace:n,channel:l,type:"REPLY",callId:M,value:s}}catch(e){f=o(l,M,e)}if(!h)try{d?.(`Sending ${t.formatMethodPath(u)}() reply`,f),e.sendMessage(f,g)}catch(r){throw"DataCloneError"===r.name&&(f=o(l,M,r),d?.(`Sending ${t.formatMethodPath(u)}() reply`,f),e.sendMessage(f)),r}};return e.addMessageHandler(c),()=>{h=!0,e.removeMessageHandler(c)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../../../utils/crypto.js"),t=require("./errorSerialization.js"),r=require("./methodSerialization.js"),a=require("./CallOptions.js"),o=require("./PenpalError.js"),s=require("./guards.js"),n=require("./namespace.js");const l=new Set(["apply","call","bind"]),i=(e,t,r=[])=>new Proxy(r.length?()=>{}:Object.create(null),{get(a,o){if("then"!==o)return r.length&&l.has(o)?Reflect.get(a,o):i(e,t,[...r,o])},apply:(t,a,o)=>e(r,o)}),d=e=>new o("CONNECTION_DESTROYED",`Method call ${r.formatMethodPath(e)}() failed due to destroyed connection`);module.exports=(l,c,h)=>{let u=!1;const m=new Map,f=e=>{if(!s.isReplyMessage(e))return;const{callId:a,value:o,isError:n,isSerializedErrorInstance:l}=e,i=m.get(a);i&&(m.delete(a),h?.(`Received ${r.formatMethodPath(i.methodPath)}() call`,e),n?i.reject(l?t.deserializeError(o):o):i.resolve(o))};l.addMessageHandler(f);return{remoteProxy:i((t,s)=>{if(u)throw d(t);const i=e.randomUUID(),f=s[s.length-1],g=f instanceof a,{timeout:M,transferables:p}=g?f:{},P=g?s.slice(0,-1):s;return new Promise((e,a)=>{const s=void 0!==M?window.setTimeout(()=>{m.delete(i),a(new o("METHOD_CALL_TIMEOUT",`Method call ${r.formatMethodPath(t)}() timed out after ${M}ms`))},M):void 0;m.set(i,{methodPath:t,resolve:e,reject:a,timeoutId:s});try{const e={namespace:n,channel:c,type:"CALL",id:i,methodPath:t,args:P};h?.(`Sending ${r.formatMethodPath(t)}() call`,e),l.sendMessage(e,p)}catch(e){a(new o("TRANSMISSION_FAILED",e.message))}})},h),destroy:()=>{u=!0,l.removeMessageHandler(f);for(const{methodPath:e,reject:t,timeoutId:r}of m.values())clearTimeout(r),t(d(e));m.clear()}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./PenpalError.js");exports.deserializeError=({name:r,message:s,stack:a,penpalCode:n})=>{const o=n?new e(n,s):new Error(s);return o.name=r,o.stack=a,o},exports.serializeError=r=>({name:r.name,message:r.message,stack:r.stack,penpalCode:r instanceof e?r.code:void 0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";module.exports=()=>{let e,r;return{promise:new Promise((s,t)=>{e=s,r=t}),resolve:e,reject:r}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./namespace.js");const s=e=>"object"==typeof e&&null!==e;exports.isAck1Message=e=>"ACK1"===e.type,exports.isAck2Message=e=>"ACK2"===e.type,exports.isCallMessage=e=>"CALL"===e.type,exports.isDestroyMessage=e=>"DESTROY"===e.type,exports.isFunction=e=>"function"==typeof e,exports.isMessage=t=>s(t)&&t.namespace===e,exports.isObject=s,exports.isReplyMessage=e=>"REPLY"===e.type,exports.isSynMessage=e=>"SYN"===e.type;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../backwardCompatibility.js"),s=require("../guards.js"),i=require("../PenpalError.js"),t=require("../PenpalBugError.js");module.exports=class{#e;#s;#i;#t;#r;#o=new Set;#a;#n=!1;constructor({remoteWindow:e,allowedOrigins:s}){if(!e)throw new i("INVALID_ARGUMENT","remoteWindow must be defined");this.#e=e,this.#s=s?.length?s:[window.origin]}initialize=({log:e,validateReceivedMessage:s})=>{this.#i=e,this.#t=s,window.addEventListener("message",this.#g)};sendMessage=(i,r)=>{if(s.isSynMessage(i)){const e=this.#d(i);return void this.#e.postMessage(i,{targetOrigin:e,transfer:r})}if(s.isAck1Message(i)||this.#n){const s=this.#n?e.downgradeMessage(i):i,t=this.#d(i);return void this.#e.postMessage(s,{targetOrigin:t,transfer:r})}if(s.isAck2Message(i)){const{port1:e,port2:s}=new MessageChannel;this.#a=e,e.addEventListener("message",this.#l),e.start();const t=[s,...r||[]],o=this.#d(i);return void this.#e.postMessage(i,{targetOrigin:o,transfer:t})}if(!this.#a)throw new t("Port is undefined");this.#a.postMessage(i,{transfer:r})};addMessageHandler=e=>{this.#o.add(e)};removeMessageHandler=e=>{this.#o.delete(e)};destroy=()=>{window.removeEventListener("message",this.#g),this.#h(),this.#o.clear()};#c=e=>this.#s.some(s=>s instanceof RegExp?s.test(e):s===e||"*"===s);#d=e=>{if(s.isSynMessage(e))return"*";if(!this.#r)throw new t("Concrete remote origin not set");return"null"===this.#r&&this.#s.includes("*")?"*":this.#r};#h=()=>{this.#a?.removeEventListener("message",this.#l),this.#a?.close(),this.#a=void 0};#g=({source:i,origin:r,ports:o,data:a})=>{if(i===this.#e&&(e.isDeprecatedMessage(a)&&(this.#i?.("Please upgrade the child window to the latest version of Penpal."),this.#n=!0,a=e.upgradeMessage(a)),this.#t?.(a)))if(this.#c(r)){if(s.isSynMessage(a)&&(this.#h(),this.#r=r),s.isAck2Message(a)&&!this.#n){if([this.#a]=o,!this.#a)throw new t("No port received on ACK2");this.#a.addEventListener("message",this.#l),this.#a.start()}for(const e of this.#o)e(a)}else this.#i?.(`Received a message from origin \`${r}\` which did not match allowed origins \`[${this.#s.join(", ")}]\``)};#l=({data:e})=>{if(this.#t?.(e))for(const s of this.#o)s(e)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("./guards.js");const o=(e,s=[])=>{const r=[];for(const c of Object.keys(e)){const n=e[c];t.isFunction(n)?r.push([...s,c]):t.isObject(n)&&r.push(...o(n,[...s,c]))}return r};exports.extractMethodPathsFromMethods=o,exports.formatMethodPath=t=>t.join("."),exports.getMethodAtMethodPath=(o,e)=>{const s=o.reduce((o,e)=>t.isObject(o)?o[e]:void 0,e);return t.isFunction(s)?s:void 0};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";module.exports="penpal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";module.exports=e=>{let t,r=!1;return(...s)=>(r||(r=!0,t=e(...s)),t)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../../../utils/crypto.js"),s=require("./PenpalError.js"),r=require("./connectCallHandler.js"),t=require("./connectRemoteProxy.js"),a=require("./guards.js"),n=require("./getPromiseWithResolvers.js"),o=require("./methodSerialization.js"),i=require("./backwardCompatibility.js"),c=require("./namespace.js");module.exports=({messenger:d,methods:h,timeout:m,channel:u,log:A})=>{const p=e.randomUUID();let I;const l=[];let g=!1;const P=o.extractMethodPathsFromMethods(h),{promise:S,resolve:N,reject:C}=n(),y=void 0!==m?setTimeout(()=>{C(new s("CONNECTION_TIMEOUT",`Connection timed out after ${m}ms`))},m):void 0,E=()=>{for(const e of l)e()},M=()=>{if(g)return;l.push(r(d,h,u,A));const{remoteProxy:e,destroy:s}=t(d,u,A);l.push(s),clearTimeout(y),g=!0,N({remoteProxy:e,destroy:E})},T=()=>{const e={namespace:c,type:"SYN",channel:u,participantId:p};A?.("Sending handshake SYN",e);try{d.sendMessage(e)}catch(e){C(new s("TRANSMISSION_FAILED",e.message))}},R=e=>{a.isSynMessage(e)&&(e=>{if(A?.("Received handshake SYN",e),e.participantId===I&&I!==i.DEPRECATED_PENPAL_PARTICIPANT_ID)return;if(I=e.participantId,T(),!(p>I||I===i.DEPRECATED_PENPAL_PARTICIPANT_ID))return;const r={namespace:c,channel:u,type:"ACK1",methodPaths:P};A?.("Sending handshake ACK1",r);try{d.sendMessage(r)}catch(e){C(new s("TRANSMISSION_FAILED",e.message))}})(e),a.isAck1Message(e)&&(e=>{A?.("Received handshake ACK1",e);const r={namespace:c,channel:u,type:"ACK2"};A?.("Sending handshake ACK2",r);try{d.sendMessage(r)}catch(e){return void C(new s("TRANSMISSION_FAILED",e.message))}M()})(e),a.isAck2Message(e)&&(e=>{A?.("Received handshake ACK2",e),M()})(e)};return d.addMessageHandler(R),l.push(()=>d.removeMessageHandler(R)),T(),S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e;exports.Event=void 0,(e=exports.Event||(exports.Event={})).LOADED="loaded",e.CONFIGURE="configure",e.CONFIGURED="configured",e.UPDATE_AUTHENTICATION="update-authentication",e.AUTHENTICATION_UPDATED="authentication-updated",e.SIGN="sign",e.SET_RECOVERY_METHOD="set-recovery-method",e.SWITCH_CHAIN="switch-chain",e.CHAIN_SWITCHED="chain-switched",e.EXPORT="export",e.SIGNED="signed",e.LOGOUT="logout",e.LOGGED_OUT="logged-out",e.GET_CURRENT_DEVICE="get-current-device",e.CURRENT_DEVICE="current-device",e.PING="ping",e.PONG="pong";
|
|
1
|
+
"use strict";var e;exports.Event=void 0,(e=exports.Event||(exports.Event={})).LOADED="loaded",e.CONFIGURE="configure",e.CONFIGURED="configured",e.UPDATE_AUTHENTICATION="update-authentication",e.AUTHENTICATION_UPDATED="authentication-updated",e.SIGN="sign",e.SET_RECOVERY_METHOD="set-recovery-method",e.SWITCH_CHAIN="switch-chain",e.CHAIN_SWITCHED="chain-switched",e.EXPORT="export",e.SIGNED="signed",e.LOGOUT="logout",e.LOGGED_OUT="logged-out",e.GET_CURRENT_DEVICE="get-current-device",e.CURRENT_DEVICE="current-device",e.PING="ping",e.PONG="pong";exports.ShieldAuthType=void 0,(exports.ShieldAuthType||(exports.ShieldAuthType={})).OPENFORT="openfort",exports.ExportPrivateKeyRequest=class{uuid;action=exports.Event.EXPORT;requestConfiguration;constructor(e,t){this.uuid=e,this.requestConfiguration=t}},exports.GetCurrentDeviceRequest=class{uuid;action=exports.Event.GET_CURRENT_DEVICE;playerID;constructor(e,t){this.uuid=e,this.playerID=t}},exports.INCORRECT_USER_ENTROPY_ERROR="incorrect-user-entropy-error",exports.MISSING_PROJECT_ENTROPY_ERROR="missing-project-entropy-error",exports.MISSING_USER_ENTROPY_ERROR="missing-user-entropy-error",exports.NOT_CONFIGURED_ERROR="not-configured-error",exports.SetRecoveryMethodRequest=class{uuid;action=exports.Event.SET_RECOVERY_METHOD;recoveryMethod;recoveryPassword;encryptionSession;requestConfiguration;constructor(e,t,r,o,s){this.uuid=e,this.recoveryMethod=t,this.recoveryPassword=r,this.encryptionSession=o,this.requestConfiguration=s}},exports.SignRequest=class{uuid;action=exports.Event.SIGN;message;requireArrayify;requireHash;requestConfiguration;constructor(e,t,r,o,s){this.uuid=e,this.message=t,this.requireArrayify=r,this.requireHash=o,this.requestConfiguration=s}},exports.SwitchChainRequest=class{uuid;action=exports.Event.SWITCH_CHAIN;chainId;requestConfiguration;constructor(e,t,r){this.uuid=e,this.chainId=t,this.requestConfiguration=r}},exports.UpdateAuthenticationRequest=class{uuid;action=exports.Event.UPDATE_AUTHENTICATION;accessToken;recovery;constructor(e,t,r){this.uuid=e,this.accessToken=t,this.recovery=r}},exports.isErrorResponse=function(e){return"error"in e};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ declare enum OpenfortErrorType {
|
|
|
6
6
|
USER_REGISTRATION_ERROR = "USER_REGISTRATION_ERROR",
|
|
7
7
|
LOGOUT_ERROR = "LOGOUT_ERROR",
|
|
8
8
|
OPERATION_NOT_SUPPORTED_ERROR = "OPERATION_NOT_SUPPORTED_ERROR",
|
|
9
|
-
MISSING_SESSION_SIGNER_ERROR = "MISSING_SESSION_SIGNER_ERROR",
|
|
10
9
|
MISSING_EMBEDDED_SIGNER_ERROR = "MISSING_EMBEDDED_SIGNER_ERROR",
|
|
11
10
|
MISSING_SIGNER_ERROR = "MISSING_SIGNER_ERROR",
|
|
12
11
|
USER_NOT_AUTHORIZED_ON_ECOSYSTEM = "USER_NOT_AUTHORIZED_ON_ECOSYSTEM",
|
|
@@ -40,6 +39,20 @@ interface ShieldAuthOptions {
|
|
|
40
39
|
apiSecret?: string;
|
|
41
40
|
}
|
|
42
41
|
|
|
42
|
+
interface Signer$1 {
|
|
43
|
+
sign(message: Uint8Array | string, requireArrayify?: boolean, requireHash?: boolean): Promise<string>;
|
|
44
|
+
disconnect(): Promise<void>;
|
|
45
|
+
switchChain({ chainId }: {
|
|
46
|
+
chainId: number;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
setEmbeddedRecovery({ recoveryMethod, recoveryPassword, encryptionSession }: {
|
|
49
|
+
recoveryMethod: RecoveryMethod;
|
|
50
|
+
recoveryPassword?: string;
|
|
51
|
+
encryptionSession?: string;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
export(): Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
interface ShieldAuthentication {
|
|
44
57
|
auth: ShieldAuthType;
|
|
45
58
|
token: string;
|
|
@@ -48,8 +61,10 @@ interface ShieldAuthentication {
|
|
|
48
61
|
encryptionSession?: string;
|
|
49
62
|
}
|
|
50
63
|
declare enum ShieldAuthType {
|
|
51
|
-
OPENFORT = "openfort"
|
|
52
|
-
|
|
64
|
+
OPENFORT = "openfort"
|
|
65
|
+
}
|
|
66
|
+
interface MessagePoster {
|
|
67
|
+
postMessage(message: string): void;
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
declare enum EmbeddedState {
|
|
@@ -59,6 +74,16 @@ declare enum EmbeddedState {
|
|
|
59
74
|
CREATING_ACCOUNT = 3,
|
|
60
75
|
READY = 4
|
|
61
76
|
}
|
|
77
|
+
declare enum OpenfortEvents {
|
|
78
|
+
LOGGED_OUT = "loggedOut",
|
|
79
|
+
SIGNER_CONFIGURED = "signerConfigured",
|
|
80
|
+
TOKEN_REFRESHED = "tokenRefreshed"
|
|
81
|
+
}
|
|
82
|
+
interface OpenfortEventMap extends Record<string, any> {
|
|
83
|
+
[OpenfortEvents.LOGGED_OUT]: [];
|
|
84
|
+
[OpenfortEvents.SIGNER_CONFIGURED]: [Signer$1];
|
|
85
|
+
[OpenfortEvents.TOKEN_REFRESHED]: [];
|
|
86
|
+
}
|
|
62
87
|
declare enum RecoveryMethod {
|
|
63
88
|
PASSWORD = "password",
|
|
64
89
|
AUTOMATIC = "automatic"
|
|
@@ -392,11 +417,9 @@ type RecoverParams = {
|
|
|
392
417
|
|
|
393
418
|
declare enum StorageKeys {
|
|
394
419
|
AUTHENTICATION = "openfort.authentication",
|
|
395
|
-
SIGNER = "openfort.signer",
|
|
396
420
|
CONFIGURATION = "openfort.configuration",
|
|
397
421
|
ACCOUNT = "openfort.account",
|
|
398
422
|
TEST = "openfort.test",
|
|
399
|
-
RECOVERY = "openfort.recovery",
|
|
400
423
|
SESSION = "openfort.session",
|
|
401
424
|
PKCE_STATE = "openfort.pkce_state",
|
|
402
425
|
PKCE_VERIFIER = "openfort.pkce_verifier"
|
|
@@ -1470,7 +1493,7 @@ interface AccountCreateRequest {
|
|
|
1470
1493
|
'publicKey': string;
|
|
1471
1494
|
}
|
|
1472
1495
|
declare const AccountCreateRequestAccountTypeEnum: {
|
|
1473
|
-
readonly
|
|
1496
|
+
readonly Solana: "solana";
|
|
1474
1497
|
};
|
|
1475
1498
|
type AccountCreateRequestAccountTypeEnum = typeof AccountCreateRequestAccountTypeEnum[keyof typeof AccountCreateRequestAccountTypeEnum];
|
|
1476
1499
|
|
|
@@ -6866,18 +6889,7 @@ declare class AuthManager {
|
|
|
6866
6889
|
requestEmailVerification(email: string, redirectUrl: string): Promise<void>;
|
|
6867
6890
|
verifyEmail(email: string, state: string): Promise<void>;
|
|
6868
6891
|
signupEmailPassword(email: string, password: string, name?: string, ecosystemGame?: string): Promise<AuthResponse$1 | AuthActionRequiredResponse>;
|
|
6869
|
-
/**
|
|
6870
|
-
* Validates credentials following Privy's approach:
|
|
6871
|
-
* - Only decode and check expiration on client
|
|
6872
|
-
* - No cryptographic verification
|
|
6873
|
-
* - Server verifies on every API call
|
|
6874
|
-
*/
|
|
6875
6892
|
validateCredentials(authentication: Authentication, forceRefresh?: boolean): Promise<Auth>;
|
|
6876
|
-
/**
|
|
6877
|
-
* Check if a token is active (exists and not expired)
|
|
6878
|
-
* Similar to Privy's tokenIsActive method
|
|
6879
|
-
*/
|
|
6880
|
-
isTokenActive(token: string | null): boolean;
|
|
6881
6893
|
/**
|
|
6882
6894
|
* Refresh tokens with the server
|
|
6883
6895
|
* Server will verify the refresh token and issue new tokens
|
|
@@ -6894,12 +6906,24 @@ declare class AuthManager {
|
|
|
6894
6906
|
linkEmail(email: string, password: string, accessToken: string, ecosystemGame?: string): Promise<AuthPlayerResponse$1 | AuthActionRequiredResponse>;
|
|
6895
6907
|
}
|
|
6896
6908
|
|
|
6909
|
+
declare class TypedEventEmitter<T extends Record<string, any[]>> {
|
|
6910
|
+
private emitter;
|
|
6911
|
+
on<K extends keyof T>(event: K, listener: (...args: T[K]) => void): this;
|
|
6912
|
+
off<K extends keyof T>(event: K, listener: (...args: T[K]) => void): this;
|
|
6913
|
+
emit<K extends keyof T>(event: K, ...args: T[K]): boolean;
|
|
6914
|
+
once<K extends keyof T>(event: K, listener: (...args: T[K]) => void): this;
|
|
6915
|
+
removeAllListeners<K extends keyof T>(event?: K): this;
|
|
6916
|
+
listenerCount<K extends keyof T>(event: K): number;
|
|
6917
|
+
listeners<K extends keyof T>(event: K): ((...args: T[K]) => void)[];
|
|
6918
|
+
}
|
|
6919
|
+
|
|
6897
6920
|
declare class AuthApi {
|
|
6898
6921
|
private storage;
|
|
6899
6922
|
private authManager;
|
|
6900
6923
|
private validateAndRefreshToken;
|
|
6901
6924
|
private ensureInitialized;
|
|
6902
|
-
|
|
6925
|
+
private eventEmitter;
|
|
6926
|
+
constructor(storage: IStorage, authManager: AuthManager, validateAndRefreshToken: () => Promise<void>, ensureInitialized: () => Promise<void>, eventEmitter: TypedEventEmitter<OpenfortEventMap>);
|
|
6903
6927
|
logInWithEmailPassword({ email, password, ecosystemGame }: {
|
|
6904
6928
|
email: string;
|
|
6905
6929
|
password: string;
|
|
@@ -7004,14 +7028,27 @@ declare class AuthApi {
|
|
|
7004
7028
|
}
|
|
7005
7029
|
|
|
7006
7030
|
declare class EmbeddedWalletApi {
|
|
7007
|
-
private storage;
|
|
7008
|
-
private validateAndRefreshToken;
|
|
7009
|
-
private ensureInitialized;
|
|
7010
|
-
private
|
|
7031
|
+
private readonly storage;
|
|
7032
|
+
private readonly validateAndRefreshToken;
|
|
7033
|
+
private readonly ensureInitialized;
|
|
7034
|
+
private readonly eventEmitter;
|
|
7011
7035
|
private iframeManager;
|
|
7012
|
-
|
|
7036
|
+
private iframeManagerPromise;
|
|
7037
|
+
private signer;
|
|
7038
|
+
private signerPromise;
|
|
7039
|
+
private provider;
|
|
7040
|
+
private messagePoster;
|
|
7041
|
+
private messenger;
|
|
7042
|
+
constructor(storage: IStorage, validateAndRefreshToken: () => Promise<void>, ensureInitialized: () => Promise<void>, eventEmitter: TypedEventEmitter<OpenfortEventMap>);
|
|
7013
7043
|
private get backendApiClients();
|
|
7014
7044
|
private getIframeManager;
|
|
7045
|
+
private createIframeManager;
|
|
7046
|
+
/**
|
|
7047
|
+
* Ensure signer is available, creating it from storage if needed
|
|
7048
|
+
*/
|
|
7049
|
+
private ensureSigner;
|
|
7050
|
+
private createSigner;
|
|
7051
|
+
private createIframe;
|
|
7015
7052
|
configure(params?: EmbeddedAccountConfigureParams): Promise<EmbeddedAccount>;
|
|
7016
7053
|
signMessage(message: string | Uint8Array, options?: {
|
|
7017
7054
|
hashMessage?: boolean;
|
|
@@ -7027,13 +7064,6 @@ declare class EmbeddedWalletApi {
|
|
|
7027
7064
|
get(): Promise<EmbeddedAccount>;
|
|
7028
7065
|
list(): Promise<EmbeddedAccount[]>;
|
|
7029
7066
|
getEmbeddedState(): Promise<EmbeddedState>;
|
|
7030
|
-
/**
|
|
7031
|
-
* Returns an Ethereum provider using the configured signer.
|
|
7032
|
-
*
|
|
7033
|
-
* @param options - Configuration options for the Ethereum provider.
|
|
7034
|
-
* @returns A Provider instance.
|
|
7035
|
-
* @throws {OpenfortError} If the signer is not an EmbeddedSigner.
|
|
7036
|
-
*/
|
|
7037
7067
|
getEthereumProvider(options?: {
|
|
7038
7068
|
policy?: string;
|
|
7039
7069
|
chains?: Record<number, string>;
|
|
@@ -7046,14 +7076,18 @@ declare class EmbeddedWalletApi {
|
|
|
7046
7076
|
}): Promise<Provider>;
|
|
7047
7077
|
ping(delay: number): Promise<boolean>;
|
|
7048
7078
|
getURL(): string;
|
|
7079
|
+
setMessagePoster(poster: MessagePoster): Promise<void>;
|
|
7080
|
+
private handleTokenRefreshed;
|
|
7081
|
+
private handleLogout;
|
|
7082
|
+
onMessage(message: Record<string, unknown>): Promise<void>;
|
|
7083
|
+
isReady(): boolean;
|
|
7049
7084
|
}
|
|
7050
7085
|
|
|
7051
7086
|
declare class UserApi {
|
|
7052
7087
|
private storage;
|
|
7053
7088
|
private authManager;
|
|
7054
7089
|
private validateAndRefreshToken;
|
|
7055
|
-
|
|
7056
|
-
constructor(storage: IStorage, authManager: AuthManager, validateAndRefreshToken: () => Promise<void>, ensureInitialized: () => Promise<void>);
|
|
7090
|
+
constructor(storage: IStorage, authManager: AuthManager, validateAndRefreshToken: () => Promise<void>);
|
|
7057
7091
|
get(): Promise<AuthPlayerResponse$1>;
|
|
7058
7092
|
}
|
|
7059
7093
|
|
|
@@ -7062,7 +7096,8 @@ declare class ProxyApi {
|
|
|
7062
7096
|
private backendApiClients;
|
|
7063
7097
|
private validateAndRefreshToken;
|
|
7064
7098
|
private ensureInitialized;
|
|
7065
|
-
|
|
7099
|
+
private getSignerSignFunction?;
|
|
7100
|
+
constructor(storage: IStorage, backendApiClients: BackendApiClients, validateAndRefreshToken: () => Promise<void>, ensureInitialized: () => Promise<void>, getSignerSignFunction?: (() => Promise<(message: string | Uint8Array) => Promise<string>>) | undefined);
|
|
7066
7101
|
sendSignatureTransactionIntentRequest(transactionIntentId: string, signableHash?: string | null, signature?: string | null, optimistic?: boolean): Promise<TransactionIntentResponse$1>;
|
|
7067
7102
|
sendSignatureSessionRequest(sessionId: string, signature: string, optimistic?: boolean): Promise<SessionResponse$1>;
|
|
7068
7103
|
}
|
|
@@ -7078,6 +7113,7 @@ declare class Openfort {
|
|
|
7078
7113
|
private userInstance?;
|
|
7079
7114
|
private proxyInstance?;
|
|
7080
7115
|
private configuration;
|
|
7116
|
+
eventEmitter: TypedEventEmitter<OpenfortEventMap>;
|
|
7081
7117
|
get auth(): AuthApi;
|
|
7082
7118
|
get embeddedWallet(): EmbeddedWalletApi;
|
|
7083
7119
|
get user(): UserApi;
|
|
@@ -7127,7 +7163,8 @@ declare class Openfort {
|
|
|
7127
7163
|
declare class OpenfortInternal {
|
|
7128
7164
|
private storage;
|
|
7129
7165
|
private authManager;
|
|
7130
|
-
|
|
7166
|
+
private eventEmitter;
|
|
7167
|
+
constructor(storage: IStorage, authManager: AuthManager, eventEmitter: TypedEventEmitter<OpenfortEventMap>);
|
|
7131
7168
|
getAccessToken(): Promise<string | null>;
|
|
7132
7169
|
/**
|
|
7133
7170
|
* Validates and refreshes the access token if needed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"axios";import t from"axios-retry";const n="https://api.openfort.xyz".replace(/\/+$/,"");class s{basePath;axios;configuration;constructor(t,s=n,a=e){this.basePath=s,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,n){if(null==n)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function c(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,n)):Object.keys(t).forEach(s=>c(e,t[s],`${n}${""!==n?".":""}${s}`)):e.has(n)?e.append(n,t):e.set(n,t))}const h=function(e,...t){const n=new URLSearchParams(e.search);c(n,t),e.search=n.toString()},u=function(e,t,n){const s="string"!=typeof e;return(s&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):s)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,n,s){return(a=t,i=n)=>{const o={...e.options,url:(s?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const s=function(e){return{cancelTransferOwnership:async(t,n,s={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",n);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},completeRecovery:async(t,n,s={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",n);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},createAccount:async(t,n={})=>{o("createAccount","createAccountRequest",t);const s=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},createAccountV2:async(t,n={})=>{o("createAccountV2","accountCreateRequest",t);const s=new URL("/v2/accounts",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},deployAccount:async(t,n,s={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",n);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},disableAccount:async(t,n={})=>{o("disableAccount","id",t);const s="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccount:async(t,n,s={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getAccountV2:async(t,n={})=>{o("getAccountV2","accountId",t);const s="/v2/accounts/{accountId}".replace("{accountId}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},getAccounts:async(t,n,s,a,o,c,u={})=>{const l=new URL("/v1/accounts",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==t&&(w.limit=t),void 0!==n&&(w.skip=n),void 0!==s&&(w.order=s),void 0!==a&&(w.player=a),void 0!==o&&(w.address=o),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},listAccountsV2:async(t,n,s,a,o={})=>{const r=new URL("/v2/accounts",i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...o},l={};void 0!==t&&(l.limit=t),void 0!==n&&(l.skip=n),void 0!==s&&(l.order=s),void 0!==a&&(l.accountType=a),h(r,l);let p=c&&c.headers?c.headers:{};return u.headers={...p,...o.headers},{url:d(r),options:u}},requestTransferOwnership:async(t,n,s={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",n);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},signPayload:async(t,n,s={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",n);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},startRecovery:async(t,n,s={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",n);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},syncAccount:async(t,n={})=>{o("syncAccount","id",t);const s="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await s.cancelTransferOwnership(a,i,o);return l(r,e,n,t)},async completeRecovery(a,i,o){const r=await s.completeRecovery(a,i,o);return l(r,e,n,t)},async createAccount(a,i){const o=await s.createAccount(a,i);return l(o,e,n,t)},async createAccountV2(a,i){const o=await s.createAccountV2(a,i);return l(o,e,n,t)},async deployAccount(a,i,o){const r=await s.deployAccount(a,i,o);return l(r,e,n,t)},async disableAccount(a,i){const o=await s.disableAccount(a,i);return l(o,e,n,t)},async getAccount(a,i,o){const r=await s.getAccount(a,i,o);return l(r,e,n,t)},async getAccountV2(a,i){const o=await s.getAccountV2(a,i);return l(o,e,n,t)},async getAccounts(a,i,o,r,c,h,u){const d=await s.getAccounts(a,i,o,r,c,h,u);return l(d,e,n,t)},async listAccountsV2(a,i,o,r,c){const h=await s.listAccountsV2(a,i,o,r,c);return l(h,e,n,t)},async requestTransferOwnership(a,i,o){const r=await s.requestTransferOwnership(a,i,o);return l(r,e,n,t)},async signPayload(a,i,o){const r=await s.signPayload(a,i,o);return l(r,e,n,t)},async startRecovery(a,i,o){const r=await s.startRecovery(a,i,o);return l(r,e,n,t)},async syncAccount(a,i){const o=await s.syncAccount(a,i);return l(o,e,n,t)}}};class y extends s{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}createAccountV2(e,t){return p(this.configuration).createAccountV2(e.accountCreateRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.accountId,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}listAccountsV2(e={},t){return p(this.configuration).listAccountsV2(e.limit,e.skip,e.order,e.accountType,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};class b{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}}export{b as BackendApiClients,f as createConfig};
|
|
1
|
+
import e from"axios";import t from"axios-retry";const n="https://api.openfort.io".replace(/\/+$/,"");class s{basePath;axios;configuration;constructor(t,s=n,a=e){this.basePath=s,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,n){if(null==n)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function c(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,n)):Object.keys(t).forEach(s=>c(e,t[s],`${n}${""!==n?".":""}${s}`)):e.has(n)?e.append(n,t):e.set(n,t))}const h=function(e,...t){const n=new URLSearchParams(e.search);c(n,t),e.search=n.toString()},u=function(e,t,n){const s="string"!=typeof e;return(s&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):s)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,n,s){return(a=t,i=n)=>{const o={...e.options,url:(s?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const s=function(e){return{cancelTransferOwnership:async(t,n,s={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",n);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},completeRecovery:async(t,n,s={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",n);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},createAccount:async(t,n={})=>{o("createAccount","createAccountRequest",t);const s=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},createAccountV2:async(t,n={})=>{o("createAccountV2","accountCreateRequest",t);const s=new URL("/v2/accounts",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},deployAccount:async(t,n,s={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",n);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},disableAccount:async(t,n={})=>{o("disableAccount","id",t);const s="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccount:async(t,n,s={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getAccountV2:async(t,n={})=>{o("getAccountV2","accountId",t);const s="/v2/accounts/{accountId}".replace("{accountId}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},getAccounts:async(t,n,s,a,o,c,u={})=>{const l=new URL("/v1/accounts",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==t&&(w.limit=t),void 0!==n&&(w.skip=n),void 0!==s&&(w.order=s),void 0!==a&&(w.player=a),void 0!==o&&(w.address=o),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},listAccountsV2:async(t,n,s,a,o={})=>{const r=new URL("/v2/accounts",i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...o},l={};void 0!==t&&(l.limit=t),void 0!==n&&(l.skip=n),void 0!==s&&(l.order=s),void 0!==a&&(l.accountType=a),h(r,l);let p=c&&c.headers?c.headers:{};return u.headers={...p,...o.headers},{url:d(r),options:u}},requestTransferOwnership:async(t,n,s={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",n);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},signPayload:async(t,n,s={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",n);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},startRecovery:async(t,n,s={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",n);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},syncAccount:async(t,n={})=>{o("syncAccount","id",t);const s="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await s.cancelTransferOwnership(a,i,o);return l(r,e,n,t)},async completeRecovery(a,i,o){const r=await s.completeRecovery(a,i,o);return l(r,e,n,t)},async createAccount(a,i){const o=await s.createAccount(a,i);return l(o,e,n,t)},async createAccountV2(a,i){const o=await s.createAccountV2(a,i);return l(o,e,n,t)},async deployAccount(a,i,o){const r=await s.deployAccount(a,i,o);return l(r,e,n,t)},async disableAccount(a,i){const o=await s.disableAccount(a,i);return l(o,e,n,t)},async getAccount(a,i,o){const r=await s.getAccount(a,i,o);return l(r,e,n,t)},async getAccountV2(a,i){const o=await s.getAccountV2(a,i);return l(o,e,n,t)},async getAccounts(a,i,o,r,c,h,u){const d=await s.getAccounts(a,i,o,r,c,h,u);return l(d,e,n,t)},async listAccountsV2(a,i,o,r,c){const h=await s.listAccountsV2(a,i,o,r,c);return l(h,e,n,t)},async requestTransferOwnership(a,i,o){const r=await s.requestTransferOwnership(a,i,o);return l(r,e,n,t)},async signPayload(a,i,o){const r=await s.signPayload(a,i,o);return l(r,e,n,t)},async startRecovery(a,i,o){const r=await s.startRecovery(a,i,o);return l(r,e,n,t)},async syncAccount(a,i){const o=await s.syncAccount(a,i);return l(o,e,n,t)}}};class y extends s{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}createAccountV2(e,t){return p(this.configuration).createAccountV2(e.accountCreateRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.accountId,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}listAccountsV2(e={},t){return p(this.configuration).listAccountsV2(e.limit,e.skip,e.order,e.accountType,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};class b{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}}export{b as BackendApiClients,f as createConfig};
|
package/dist/sdk/src/api/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{StorageKeys as
|
|
1
|
+
import{StorageKeys as e}from"../storage/istorage.js";import{Authentication as t}from"../core/configuration/authentication.js";import{OpenfortError as a,OpenfortErrorType as i}from"../core/errors/openfortError.js";import{OpenfortEvents as s}from"../types/types.js";class n{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(e,t,a,i,s){this.storage=e,this.authManager=t,this.validateAndRefreshToken=a,this.ensureInitialized=i,this.eventEmitter=s}async logInWithEmailPassword({email:e,password:a,ecosystemGame:i}){await this.ensureInitialized();const s=await this.authManager.loginEmailPassword(e,a,i);return"action"in s||new t("jwt",s.token,s.player.id,s.refreshToken).save(this.storage),s}async signUpGuest(){await this.ensureInitialized();const e=await this.authManager.registerGuest();return new t("jwt",e.token,e.player.id,e.refreshToken).save(this.storage),e}async signUpWithEmailPassword({email:e,password:a,options:i,ecosystemGame:s}){await this.ensureInitialized();const n=await this.authManager.signupEmailPassword(e,a,i?.data.name,s);return"action"in n||new t("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async linkEmailPassword({email:e,password:t,authToken:a,ecosystemGame:i}){return await this.validateAndRefreshToken(),await this.authManager.linkEmail(e,t,a,i)}async unlinkEmailPassword({email:e,authToken:t}){return await this.validateAndRefreshToken(),await this.authManager.unlinkEmail(e,t)}async requestEmailVerification({email:e,redirectUrl:t}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(e,t)}async resetPassword({email:e,password:t,state:a}){await this.ensureInitialized(),await this.authManager.resetPassword(e,t,a)}async requestResetPassword({email:e,redirectUrl:t}){await this.ensureInitialized(),await this.authManager.requestResetPassword(e,t)}async verifyEmail({email:e,state:t}){await this.ensureInitialized(),await this.authManager.verifyEmail(e,t)}async initOAuth({provider:e,options:t,ecosystemGame:a}){return await this.ensureInitialized(),await this.authManager.initOAuth(e,t,a)}async initLinkOAuth({provider:e,options:s,ecosystemGame:n}){await this.validateAndRefreshToken();const r=await t.fromStorage(this.storage);if(!r)throw new a("No authentication found",i.NOT_LOGGED_IN_ERROR);return await this.authManager.linkOAuth(r,e,s,n)}async linkThirdPartyProvider({provider:e,token:s,tokenType:n}){await this.validateAndRefreshToken();const r=await t.fromStorage(this.storage);if(!r)throw new a("No authentication found",i.NOT_LOGGED_IN_ERROR);return await this.authManager.linkThirdParty(r,e,s,n)}async unlinkOAuth({provider:e,authToken:t}){return await this.validateAndRefreshToken(),await this.authManager.unlinkOAuth(e,t)}async poolOAuth(e){await this.ensureInitialized();const a=await this.authManager.poolOAuth(e);return new t("jwt",a.token,a.player.id,a.refreshToken).save(this.storage),a}async authenticateWithThirdPartyProvider({provider:e,token:a,tokenType:i,ecosystemGame:s}){await this.ensureInitialized();const n=await this.authManager.authenticateThirdParty(e,a,i,s);return new t("third_party",a,n.id,null,e,i).save(this.storage),n}async loginWithIdToken({provider:e,token:a,ecosystemGame:i}){await this.ensureInitialized();const s=await this.authManager.loginWithIdToken(e,a,i);return new t("jwt",s.token,s.player.id,s.refreshToken).save(this.storage),s}async initSIWE({address:e,ecosystemGame:t}){return await this.ensureInitialized(),await this.authManager.initSIWE(e,t)}async authenticateWithSIWE({signature:e,message:a,walletClientType:i,connectorType:s}){await this.ensureInitialized();const n=await this.authManager.authenticateSIWE(e,a,i,s);return new t("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async linkWallet({signature:e,message:t,walletClientType:a,connectorType:i,authToken:s}){return await this.validateAndRefreshToken(),await this.authManager.linkWallet(e,t,a,i,s)}async unlinkWallet({address:e,authToken:t}){return await this.validateAndRefreshToken(),await this.authManager.unlinkWallet(e,t)}async storeCredentials(e){if(await this.ensureInitialized(),!e.player)throw new a("Player ID is required to store credentials",i.INVALID_CONFIGURATION);new t("jwt",e.accessToken,e.player,e.refreshToken).save(this.storage)}async logout(){const a=await t.fromStorage(this.storage);if(a&&a.refreshToken){try{await this.authManager.logout(a.token,a.refreshToken)}catch(e){}this.storage.remove(e.AUTHENTICATION),this.eventEmitter.emit(s.LOGGED_OUT)}}}export{n as AuthApi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BackendApiClients as e}from"../../../packages/internal/openapi-clients/dist/index.js";import{SignerManager as t}from"../wallets/signer.js";import{Account as r}from"../core/configuration/account.js";import{Authentication as i}from"../core/configuration/authentication.js";import{SDKConfiguration as o}from"../core/config/config.js";import{OpenfortError as a,OpenfortErrorType as n,withOpenfortError as s}from"../core/errors/openfortError.js";import{getSignedTypedData as d}from"../wallets/evm/walletHelpers.js";import{EvmProvider as c}from"../wallets/evm/evmProvider.js";import"../wallets/evm/types.js";import{announceProvider as h,openfortProviderInfo as f}from"../wallets/evm/provider/eip6963.js";import g from"../utils/typedEventEmitter.js";import{RecoveryMethod as l,EmbeddedState as u}from"../types/types.js";import{IframeManager as w}from"../wallets/iframeManager.js";class p{storage;validateAndRefreshToken;ensureInitialized;provider=null;iframeManager=null;constructor(e,t,r){this.storage=e,this.validateAndRefreshToken=t,this.ensureInitialized=r}get backendApiClients(){const t=o.fromStorage();if(!t)throw new a("Configuration not found",n.INVALID_CONFIGURATION);return new e({basePath:t.backendUrl,accessToken:t.baseConfiguration.publishableKey})}getIframeManager(){if(!this.iframeManager){const e=o.fromStorage();if(!e)throw new a("Configuration not found",n.INVALID_CONFIGURATION);this.iframeManager=new w(e,this.storage)}return this.iframeManager}async configure(e={}){const r=e.recoveryParams??{recoveryMethod:l.AUTOMATIC};await this.ensureInitialized(),await this.validateAndRefreshToken();const i=o.fromStorage();let s=null;(r.recoveryMethod===l.PASSWORD||e.shieldAuthentication?.encryptionSession)&&(s={encryptionSession:e.shieldAuthentication?.encryptionSession||null,recoveryPassword:r.recoveryMethod===l.PASSWORD?r.password:null,encryptionPart:i?.shieldConfiguration?.shieldEncryptionKey||null});let d=null,c=null;if(e.shieldAuthentication&&(d="openfort"===e.shieldAuthentication.auth?"openfort":"custom",c=e.shieldAuthentication.token),!this.storage)throw new a("Storage not available in EmbeddedWalletApi",n.INVALID_CONFIGURATION);return await t.embedded(this.storage,e.chainId,s,d,c),this.get()}async signMessage(e,r){await this.ensureInitialized(),await this.validateAndRefreshToken();const i=await t.fromStorage(this.storage);if(!i)throw new a("No signer configured",n.MISSING_SIGNER_ERROR);const{hashMessage:o=!0,arrayifyMessage:s=!1}=r||{};return await i.sign(e,s,o)}async signTypedData(e,i,o){await this.ensureInitialized(),await this.validateAndRefreshToken();const s=await t.fromStorage(this.storage),c=await r.fromStorage(this.storage);if(!s||!c)throw new a("No signer configured",n.MISSING_SIGNER_ERROR);return await d({domain:e,types:i,message:o},c.type,Number(c.chainId),s,c.address)}async exportPrivateKey(){await this.ensureInitialized(),await this.validateAndRefreshToken();const e=await t.fromStorage(this.storage);if(!e)throw new a("No signer configured",n.MISSING_SIGNER_ERROR);return await e.export()}async setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:r,encryptionSession:i}){await this.ensureInitialized(),await this.validateAndRefreshToken();const o=await t.fromStorage(this.storage);if(!o)throw new a("No signer configured",n.MISSING_SIGNER_ERROR);if("password"===e&&!r)throw new a("Recovery password is required",n.INVALID_CONFIGURATION);await o.setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:r,encryptionSession:i})}async get(){const e=await r.fromStorage(this.storage);if(!e)throw new a("No signer configured",n.MISSING_SIGNER_ERROR);const t=await i.fromStorage(this.storage);if(!t)throw new a("No access token found",n.INTERNAL_ERROR);return{chainId:e.chainId.toString(),owner:{id:t.player},address:e.address,ownerAddress:e.ownerAddress,chainType:"ethereum",implementationType:e.type}}async list(){const e=o.fromStorage();if(!e)throw new a("Configuration not found",n.INVALID_CONFIGURATION);await this.ensureInitialized(),await this.validateAndRefreshToken();const t=await i.fromStorage(this.storage);if(!t)throw new a("No access token found",n.NOT_LOGGED_IN_ERROR);return s(async()=>(await this.backendApiClients.accountsApi.getAccounts(void 0,{headers:{authorization:`Bearer ${e.baseConfiguration.publishableKey}`,"x-player-token":t.token,"x-auth-provider":t.thirdPartyProvider,"x-token-type":t.thirdPartyTokenType}})).data.data.map(e=>({owner:{id:e.player.id},chainType:"ethereum",address:e.address,ownerAddress:e.ownerAddress,createdAt:e.createdAt,implementationType:e.accountType,chainId:e.chainId.toString()})),{default:n.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await i.fromStorage(this.storage))return u.UNAUTHENTICATED;if(!await t.fromStorage(this.storage))return u.EMBEDDED_SIGNER_NOT_CONFIGURED;return await r.fromStorage(this.storage)?u.READY:u.CREATING_ACCOUNT}catch(e){return console.error("Failed to get embedded state:",e),u.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const o={announceProvider:!0,...e},a=await i.fromStorage(this.storage),n=await t.fromStorage(this.storage),s=await r.fromStorage(this.storage);return this.provider?this.provider&&o.policy&&this.provider.updatePolicy(o.policy):(this.provider=new c({storage:this.storage,openfortEventEmitter:new g,signer:n||void 0,account:s||void 0,authentication:a||void 0,backendApiClients:this.backendApiClients,policyId:o.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:o.chains}),o.announceProvider&&h({info:{...f,...o.providerInfo},provider:this.provider})),this.provider}async ping(e){try{const t=this.getIframeManager();if(!t.isLoaded())return!1;e>0&&await new Promise(t=>{setTimeout(t,e)});const r=await i.fromStorage(this.storage);if(r)try{return await t.getCurrentUser(r.player),!0}catch(e){return!1}return t.isLoaded()}catch(e){return!1}}getURL(){const e=o.fromStorage();if(!e)throw new a("Configuration not found",n.INVALID_CONFIGURATION);return e.iframeUrl}}export{p as EmbeddedWalletApi};
|
|
1
|
+
import{BackendApiClients as e}from"../../../packages/internal/openapi-clients/dist/index.js";import{StorageKeys as t}from"../storage/istorage.js";import{Account as r}from"../core/configuration/account.js";import{Authentication as a}from"../core/configuration/authentication.js";import{SDKConfiguration as i}from"../core/config/config.js";import{OpenfortError as n,OpenfortErrorType as s,withOpenfortError as o}from"../core/errors/openfortError.js";import{getSignedTypedData as d}from"../wallets/evm/walletHelpers.js";import{EvmProvider as g}from"../wallets/evm/evmProvider.js";import"../wallets/evm/types.js";import{announceProvider as c,openfortProviderInfo as m}from"../wallets/evm/provider/eip6963.js";import{OpenfortEvents as h,RecoveryMethod as l,EmbeddedState as f}from"../types/types.js";import{IframeManager as u}from"../wallets/iframeManager.js";import{EmbeddedSigner as p}from"../wallets/embedded.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import w from"../wallets/messaging/browserMessenger/messengers/WindowMessenger.js";import{ReactNativeMessenger as A}from"../wallets/messaging/ReactNativeMessenger.js";import{debugLog as y}from"../utils/debug.js";class E{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,t,r,a){this.storage=e,this.validateAndRefreshToken=t,this.ensureInitialized=r,this.eventEmitter=a,this.eventEmitter.on(h.TOKEN_REFRESHED,()=>{y("Handling token refresh event in EmbeddedWalletApi"),this.handleTokenRefreshed()}),this.eventEmitter.on(h.LOGGED_OUT,()=>{y("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const t=i.fromStorage();if(!t)throw new n("Configuration not found",s.INVALID_CONFIGURATION);return new e({basePath:t.backendUrl,accessToken:t.baseConfiguration.publishableKey})}async getIframeManager(){if(y("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return y("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return y("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;y("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return y("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,y("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw y("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){y("[HANDSHAKE DEBUG] createIframeManager starting");const e=i.fromStorage();if(!e)throw y("[HANDSHAKE DEBUG] Configuration not found"),new n("Configuration not found",s.INVALID_CONFIGURATION);let t;if(y("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)y("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new A(this.messagePoster),y("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),t=this.messenger;else{y("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const r=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;t=new w({remoteWindow:r.contentWindow,allowedOrigins:[a]}),y("[HANDSHAKE DEBUG] Created WindowMessenger")}y("[HANDSHAKE DEBUG] Creating IframeManager instance");const r=new u(e,this.storage,t);return y("[HANDSHAKE DEBUG] Initializing IframeManager"),await r.initialize(),y("[HANDSHAKE DEBUG] IframeManager initialized successfully"),r}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager(),t=new p(e,this.storage);return this.eventEmitter.emit(h.SIGNER_CONFIGURED,t),t}createIframe(e){if("undefined"==typeof document)throw new n("Document is not available. Please provide a message poster for non-browser environments.",s.INVALID_CONFIGURATION);const t=document.getElementById("openfort-iframe");t&&t.remove();const r=document.createElement("iframe");return r.style.display="none",r.id="openfort-iframe",r.src=e,document.body.appendChild(r),y("Iframe created and appended to document"),r}async configure(e={}){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:l.AUTOMATIC};if(!i.fromStorage())throw new n("Configuration not found",s.INVALID_CONFIGURATION);let o;(t.recoveryMethod===l.PASSWORD||e.shieldAuthentication?.encryptionSession)&&(o={encryptionSession:e.shieldAuthentication?.encryptionSession,recoveryPassword:t.recoveryMethod===l.PASSWORD?t.password:void 0});const d=await this.getIframeManager(),g=await d.configure({chainId:e.chainId,entropy:o});new r(g.address,g.chainId,g.ownerAddress,g.accountType).save(this.storage);const c=new p(d,this.storage);this.eventEmitter.emit(h.SIGNER_CONFIGURED,c);const m=await a.fromStorage(this.storage);if(!m)throw new n("No access token found",s.NOT_LOGGED_IN_ERROR);return{chainId:g.chainId.toString(),owner:{id:m.player},address:g.address,ownerAddress:"solana"===g.accountType?void 0:g.ownerAddress,chainType:"solana"===g.accountType?"solana":"ethereum",implementationType:"solana"===g.accountType?void 0:g.accountType}}async signMessage(e,t){await this.validateAndRefreshToken();const r=await this.ensureSigner(),{hashMessage:a=!0,arrayifyMessage:i=!1}=t||{};return await r.sign(e,i,a)}async signTypedData(e,t,a){await this.validateAndRefreshToken();const i=await this.ensureSigner(),o=await r.fromStorage(this.storage);if(!o)throw new n("No account found",s.MISSING_SIGNER_ERROR);return await d({domain:e,types:t,message:a},o.type,Number(o.chainId),i,o.address)}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:t,encryptionSession:r}){await this.validateAndRefreshToken();const a=await this.ensureSigner();if("password"===e&&!t)throw new n("Recovery password is required",s.INVALID_CONFIGURATION);await a.setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:t,encryptionSession:r})}async get(){const e=await r.fromStorage(this.storage);if(!e)throw new n("No signer configured",s.MISSING_SIGNER_ERROR);const t=await a.fromStorage(this.storage);if(!t)throw new n("No access token found",s.NOT_LOGGED_IN_ERROR);return{chainId:e.chainId.toString(),owner:{id:t.player},address:e.address,ownerAddress:"solana"===e.type?void 0:e.ownerAddress,chainType:"solana"===e.type?"solana":"ethereum",implementationType:"solana"===e.type?void 0:e.type}}async list(){const e=i.fromStorage();if(!e)throw new n("Configuration not found",s.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const t=await a.fromStorage(this.storage);if(!t)throw new n("No access token found",s.NOT_LOGGED_IN_ERROR);return o(async()=>(await this.backendApiClients.accountsApi.getAccounts(void 0,{headers:{authorization:`Bearer ${e.baseConfiguration.publishableKey}`,"x-player-token":t.token,"x-auth-provider":t.thirdPartyProvider,"x-token-type":t.thirdPartyTokenType}})).data.data.map(e=>({owner:{id:e.player.id},chainType:"ethereum",address:e.address,ownerAddress:e.ownerAddress,createdAt:e.createdAt,implementationType:e.accountType,chainId:e.chainId.toString()})),{default:s.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await a.fromStorage(this.storage))return f.UNAUTHENTICATED;return await r.fromStorage(this.storage)?f.READY:f.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return y("Failed to get embedded state:",e),f.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const t={announceProvider:!0,...e},i=await a.fromStorage(this.storage),n=await r.fromStorage(this.storage);let s;try{s=n?await this.ensureSigner():void 0}catch(e){s=void 0}return this.provider?this.provider&&t.policy&&this.provider.updatePolicy(t.policy):(this.provider=new g({storage:this.storage,openfortEventEmitter:this.eventEmitter,signer:s||void 0,account:n||void 0,authentication:i||void 0,backendApiClients:this.backendApiClients,policyId:t.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:t.chains}),t.announceProvider&&c({info:{...m,...t.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(t=>{setTimeout(t,e)});const t=await this.getIframeManager();if(!t.isLoaded())return!1;const r=await a.fromStorage(this.storage);if(r)try{return await t.getCurrentDevice(r.player),!0}catch(e){return!1}return t.isLoaded()}catch(e){return y("Ping failed:",e),!1}}getURL(){const e=i.fromStorage();if(!e)throw new n("Configuration not found",s.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new n("Invalid message poster",s.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager&&(this.iframeManager.destroy(),this.iframeManager=null,this.iframeManagerPromise=null),this.signer&&(this.signer=null,this.signerPromise=null)}async handleTokenRefreshed(){if(this.iframeManager)try{await this.iframeManager.updateAuthentication(),y("Updated IframeManager authentication after token refresh")}catch(e){y("Failed to update IframeManager authentication:",e)}else y("IframeManager not initialized, skipping authentication update")}async handleLogout(){if(this.signer){try{await this.signer.disconnect(),y("Logged out embedded signer")}catch(e){y("Failed to logout embedded signer:",e)}this.signer=null,this.signerPromise=null}this.storage.remove(t.ACCOUNT),this.iframeManager&&(this.iframeManager.destroy(),this.iframeManager=null,this.iframeManagerPromise=null),this.messenger&&(this.messenger.destroy(),this.messenger=null),this.provider&&(this.provider=null)}async onMessage(e){if(!e||"object"!=typeof e)return void y("Invalid message received:",e);y("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const t="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(t&&this.messenger&&this.messagePoster)return y("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const r=await this.getIframeManager();y(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${r.isLoaded()}`),t&&!r.isLoaded()&&y("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),y("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await r.onMessage(e),y("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}}export{E as EmbeddedWalletApi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{SDKConfiguration as i}from"../core/config/config.js";import{OpenfortError as t,OpenfortErrorType as n,withOpenfortError as e}from"../core/errors/openfortError.js";class s{storage;backendApiClients;validateAndRefreshToken;ensureInitialized;getSignerSignFunction;constructor(i,t,n,e,s){this.storage=i,this.backendApiClients=t,this.validateAndRefreshToken=n,this.ensureInitialized=e,this.getSignerSignFunction=s}async sendSignatureTransactionIntentRequest(s,a=null,r=null,o=!1){await this.ensureInitialized();if(!i.fromStorage())throw new t("Configuration not found",n.INVALID_CONFIGURATION);await this.validateAndRefreshToken();let u=r;if(!u){if(!a)throw new t("No signableHash or signature provided",n.OPERATION_NOT_SUPPORTED_ERROR);if(!this.getSignerSignFunction)throw new t("In order to sign a transaction intent, a signer must be configured",n.MISSING_SIGNER_ERROR);const i=await this.getSignerSignFunction();u=await i(a)}const g={id:s,signatureRequest:{signature:u,optimistic:o}};return e(async()=>(await this.backendApiClients.transactionIntentsApi.signature(g)).data,{default:n.INTERNAL_ERROR})}async sendSignatureSessionRequest(i,t,s){await this.ensureInitialized();const a={id:i,signatureRequest:{signature:t,optimistic:s}};return e(async()=>(await this.backendApiClients.sessionsApi.signatureSession(a)).data,{default:n.INTERNAL_ERROR})}}export{s as ProxyApi};
|
package/dist/sdk/src/api/user.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Authentication as
|
|
1
|
+
import{Authentication as t}from"../core/configuration/authentication.js";import{OpenfortError as e,OpenfortErrorType as r}from"../core/errors/openfortError.js";class a{storage;authManager;validateAndRefreshToken;constructor(t,e,r){this.storage=t,this.authManager=e,this.validateAndRefreshToken=r}async get(){await this.validateAndRefreshToken();const a=await t.fromStorage(this.storage);if(!a)throw new e("No access token found",r.NOT_LOGGED_IN_ERROR);return await this.authManager.getUser(a)}}export{a as UserApi};
|