@openfort/openfort-js 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/sdk/src/api/funding.cjs +1 -0
- package/dist/cjs/sdk/src/core/openfort.cjs +1 -1
- package/dist/cjs/sdk/src/index.cjs +1 -1
- package/dist/cjs/sdk/src/version.cjs +1 -1
- package/dist/index.d.cts +218 -1
- package/dist/index.d.ts +218 -1
- package/dist/sdk/src/api/funding.js +1 -0
- package/dist/sdk/src/core/openfort.js +1 -1
- package/dist/sdk/src/index.js +1 -1
- package/dist/sdk/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../core/config/config.cjs"),t=require("../core/errors/openfortError.cjs");exports.FundingApi=class{async request(s,n){const r=e.SDKConfiguration.getInstance();if(!r)throw new t.ConfigurationError("Configuration not found");const i=await fetch(`${r.backendUrl}${s}`,{...n,headers:{Authorization:`Bearer ${r.baseConfiguration.publishableKey}`,"Content-Type":"application/json",...n?.headers??{}},signal:AbortSignal.timeout(3e4)});if(!i.ok){const e=await i.json().catch(()=>({})),s="string"==typeof e.error?e.error:e.error?.message;throw new t.RequestError(s??"Openfort funding request failed",i.status)}return i.json()}secrets=new Map;resolveSecret(e,t){const s=t??this.secrets.get(e);if(!s)throw new Error(`No clientSecret known for funding session ${e} — pass it explicitly (it was returned when the session was created)`);return s}remember(e){return e.clientSecret&&this.secrets.set(e.id,e.clientSecret),e}sessions={create:async e=>this.remember(await this.request("/v2/funding/sessions",{method:"POST",body:JSON.stringify(e)})),setPaymentMethod:async(e,t)=>this.request(`/v2/funding/sessions/${e}/payment_methods`,{method:"POST",body:JSON.stringify({clientSecret:this.resolveSecret(e,t.clientSecret),paymentMethod:t.paymentMethod})}),get:async(e,t)=>{const s=this.resolveSecret(e,t?.clientSecret);return this.request(`/v2/funding/sessions/${e}?clientSecret=${encodeURIComponent(s)}`)},wait:async(e,t)=>{const s=t?.pollMs??4e3,n=t?.timeoutMs??18e5,r=Date.now()+n;for(;;){const n=await this.sessions.get(e,t);if("succeeded"===n.status||"bounced"===n.status||"expired"===n.status)return n;if(Date.now()>=r)throw new Error(`Timed out waiting for funding session ${e} (last status: ${n.status})`);await new Promise(e=>setTimeout(e,s))}}};fund=async e=>{const t=await this.sessions.create({target:e.target,paymentMethod:e.paymentMethod,amountUnits:e.amountUnits,metadata:e.metadata,externalId:e.externalId,strict:e.strict});return this.sessions.wait(t.id,e.wait)};payLink=async e=>{const{url:t}=await this.request("/v2/funding/pay_link",{method:"POST",body:JSON.stringify({sessionId:e.sessionId,clientSecret:this.resolveSecret(e.sessionId,e.clientSecret),amount:e.amount,asset:e.asset})});return t};chains=async()=>{const{chains:e}=await this.request("/v2/funding/chains");return e}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.cjs"),t=require("../api/auth.cjs"),i=require("../api/embeddedWallet.cjs"),n=require("../api/
|
|
1
|
+
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.cjs"),t=require("../api/auth.cjs"),i=require("../api/embeddedWallet.cjs"),n=require("../api/funding.cjs"),a=require("../api/proxy.cjs"),s=require("../api/user.cjs"),r=require("../auth/authManager.cjs"),o=require("../storage/istorage.cjs"),h=require("../storage/lazyStorage.cjs"),l=require("../utils/typedEventEmitter.cjs"),u=require("./config/config.cjs"),c=require("./errors/authErrorCodes.cjs"),d=require("./errors/openfortError.cjs"),g=require("./errors/sentry.cjs"),f=require("./openfortInternal.cjs"),p=require("./passkey/handler.cjs");class I{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;fundingInstance;configuration;eventEmitter;iPasskeyHandler;static globalEventEmitter=null;get auth(){if(!this.authInstance)throw new d.ConfigurationError("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.");return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new d.ConfigurationError("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.");return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new d.ConfigurationError("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.");return this.userInstance}get proxy(){if(!this.proxyInstance)throw new d.ConfigurationError("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.");return this.proxyInstance}get funding(){if(!this.fundingInstance)throw new d.ConfigurationError("Openfort SDK not initialized. Please await waitForInitialization() before accessing funding.");return this.fundingInstance}initializeSynchronously(){try{this.iAuthManager=new r.AuthManager,this.openfortInternal=new f.OpenfortInternal(this.storage,this.authManager,this.eventEmitter),this.authInstance=new t.AuthApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new i.EmbeddedWalletApi(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter,this.passkeyHandler),this.userInstance=new s.UserApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.fundingInstance=new n.FundingApi,this.proxyInstance=new a.ProxyApi(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new d.SignerError(c.OPENFORT_AUTH_ERROR_CODES.MISSING_SIGNER,"Embedded wallet not initialized");const e=this.embeddedWalletInstance;return t=>e.signMessage(t,{hashMessage:!0,arrayifyMessage:!0})})}catch(e){throw new d.ConfigurationError("Openfort SDK synchronous initialization failed")}}constructor(e){if(this.configuration=new u.SDKConfiguration(e),this.storage=new h.LazyStorage(this.configuration.baseConfiguration.publishableKey,this.configuration.storage),this.eventEmitter=new l,I.globalEventEmitter){["onAuthInit","onAuthSuccess","onAuthFailure","onLogout","onSwitchAccount","onSignedMessage","onEmbeddedWalletCreated","onEmbeddedWalletRecovered","onAuthFlowOpen","onAuthFlowClose","onAuthFlowCancel"].forEach(e=>{this.eventEmitter.on(e,(...t)=>{I.globalEventEmitter?.emit(e,...t)})})}else I.globalEventEmitter=this.eventEmitter;this.iPasskeyHandler=e.overrides?.passkeyHandler??new p.PasskeyHandler({rpId:e.shieldConfiguration?.passkeyRpId,rpName:e.shieldConfiguration?.passkeyRpName,displayName:e.shieldConfiguration?.passkeyDisplayName}),g.InternalSentry.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}static getEventEmitter(){return I.globalEventEmitter||(I.globalEventEmitter=new l),I.globalEventEmitter}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(e){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(e)}get backendApiClients(){return new e.BackendApiClients({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey,nativeAppIdentifier:this.configuration.nativeAppIdentifier,storage:this.storage,onLogout:()=>{this.eventEmitter.emit("onLogout")}})}get authManager(){if(!this.iAuthManager)throw new d.RequestError("AuthManager not initialized");return this.iAuthManager}get passkeyHandler(){return this.iPasskeyHandler}static async isStorageAccessible(e){try{const t=o.StorageKeys.TEST,i="openfort_storage_test";e.save(t,i);const n=await e.get(t);return e.remove(t),n===i}catch(e){return!1}}async initializeAsync(){if(!await I.isStorageAccessible(this.storage))throw new d.OpenfortError("Storage is not accessible. The SDK needs a working key/value store to persist the session. On React Native, ensure the app is code-signed (an unsigned build cannot use the keychain) and that expo-secure-store — or your `overrides.storage` implementation — is installed and reachable.",c.OPENFORT_ERROR_CODES.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}}exports.Openfort=I;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=require("./core/openfort.cjs"),e=require("./api/auth.cjs"),o=require("./api/embeddedWallet.cjs"),t=require("./api/
|
|
1
|
+
"use strict";var r=require("./core/openfort.cjs"),e=require("./api/auth.cjs"),o=require("./api/embeddedWallet.cjs"),t=require("./api/funding.cjs"),s=require("./api/proxy.cjs"),n=require("./api/user.cjs"),i=require("./core/errors/authErrorCodes.cjs"),p=require("./core/errors/openfortError.cjs"),u=require("./core/passkey/errors.cjs"),a=require("./core/passkey/handler.cjs"),E=require("./core/passkey/utils.cjs"),c=require("./core/config/config.cjs"),d=require("./core/openfortInternal.cjs"),f=require("./utils/authorization.cjs"),y=require("./wallets/iframeManager.cjs"),x=require("./types/types.cjs"),P=require("./utils/crypto.cjs");const O=r.Openfort.getEventEmitter();exports.Openfort=r.Openfort,exports.AuthApi=e.AuthApi,exports.EmbeddedWalletApi=o.EmbeddedWalletApi,exports.FundingApi=t.FundingApi,exports.ProxyApi=s.ProxyApi,exports.UserApi=n.UserApi,exports.OPENFORT_AUTH_ERROR_CODES=i.OPENFORT_AUTH_ERROR_CODES,exports.OPENFORT_ERROR_CODES=i.OPENFORT_ERROR_CODES,exports.AuthenticationError=p.AuthenticationError,exports.AuthorizationError=p.AuthorizationError,exports.ConfigurationError=p.ConfigurationError,exports.OAuthError=p.OAuthError,exports.OTPError=p.OTPError,exports.OpenfortError=p.OpenfortError,exports.RecoveryError=p.RecoveryError,exports.RequestError=p.RequestError,exports.SessionError=p.SessionError,exports.SignerError=p.SignerError,exports.UserError=p.UserError,exports.PASSKEY_ERROR_CODES=u.PASSKEY_ERROR_CODES,exports.PasskeyAssertionFailedError=u.PasskeyAssertionFailedError,exports.PasskeyCreationFailedError=u.PasskeyCreationFailedError,exports.PasskeyPRFNotSupportedError=u.PasskeyPRFNotSupportedError,exports.PasskeySeedInvalidError=u.PasskeySeedInvalidError,exports.PasskeyUserCancelledError=u.PasskeyUserCancelledError,exports.PasskeyHandler=a.PasskeyHandler,exports.arrayBufferToBase64URL=E.arrayBufferToBase64URL,exports.base64ToArrayBuffer=E.base64ToArrayBuffer,exports.OpenfortConfiguration=c.OpenfortConfiguration,exports.SDKConfiguration=c.SDKConfiguration,exports.ShieldConfiguration=c.ShieldConfiguration,exports.OpenfortInternal=d.OpenfortInternal,exports.prepareAndSignAuthorization=f.prepareAndSignAuthorization,exports.serializeSignedAuthorization=f.serializeSignedAuthorization,exports.signAuthorization=f.signAuthorization,exports.IframeHandshakeTimeoutError=y.IframeHandshakeTimeoutError,exports.IframeSignEmptyResponseError=y.IframeSignEmptyResponseError,exports.IframeSignTimeoutError=y.IframeSignTimeoutError,exports.MissingProjectEntropyError=y.MissingProjectEntropyError,exports.MissingRecoveryPasswordError=y.MissingRecoveryPasswordError,exports.NotConfiguredError=y.NotConfiguredError,exports.OTPRequiredError=y.OTPRequiredError,exports.SessionEndedBeforeSetupError=y.SessionEndedBeforeSetupError,exports.WrongPasskeyError=y.WrongPasskeyError,exports.WrongRecoveryPasswordError=y.WrongRecoveryPasswordError,Object.defineProperty(exports,"AccountTypeEnum",{enumerable:!0,get:function(){return x.AccountTypeEnum}}),Object.defineProperty(exports,"AuthActionRequiredActions",{enumerable:!0,get:function(){return x.AuthActionRequiredActions}}),Object.defineProperty(exports,"AuthType",{enumerable:!0,get:function(){return x.AuthType}}),Object.defineProperty(exports,"BasicAuthProvider",{enumerable:!0,get:function(){return x.BasicAuthProvider}}),Object.defineProperty(exports,"ChainTypeEnum",{enumerable:!0,get:function(){return x.ChainTypeEnum}}),Object.defineProperty(exports,"EmbeddedState",{enumerable:!0,get:function(){return x.EmbeddedState}}),Object.defineProperty(exports,"OAuthProvider",{enumerable:!0,get:function(){return x.OAuthProvider}}),Object.defineProperty(exports,"OpenfortEvents",{enumerable:!0,get:function(){return x.OpenfortEvents}}),Object.defineProperty(exports,"RecoveryMethod",{enumerable:!0,get:function(){return x.RecoveryMethod}}),Object.defineProperty(exports,"ThirdPartyOAuthProvider",{enumerable:!0,get:function(){return x.ThirdPartyAuthProvider}}),Object.defineProperty(exports,"TokenType",{enumerable:!0,get:function(){return x.TokenType}}),exports.cryptoDigest=P.cryptoDigest,exports.openfortEvents=O;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="1.
|
|
1
|
+
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="1.5.0";
|
package/dist/index.d.cts
CHANGED
|
@@ -12666,6 +12666,221 @@ declare class RequestError extends OpenfortError {
|
|
|
12666
12666
|
constructor(error_description: string, statusCode?: number | undefined);
|
|
12667
12667
|
}
|
|
12668
12668
|
|
|
12669
|
+
/**
|
|
12670
|
+
* Funding (cross-chain wallet deposit) resource.
|
|
12671
|
+
*
|
|
12672
|
+
* Wraps the API's `/v2/funding` session endpoints: create a session for a
|
|
12673
|
+
* destination, set a single payment method (a source route) to mint a Relay
|
|
12674
|
+
* deposit address, then poll until terminal. Sessions are guarded by a
|
|
12675
|
+
* per-session `clientSecret` and authenticated with the project publishable key.
|
|
12676
|
+
*
|
|
12677
|
+
* NOTE: This thin wrapper calls the backend directly. Once the API's funding
|
|
12678
|
+
* endpoints are part of the published OpenAPI spec, this can move onto the
|
|
12679
|
+
* generated `BackendApiClients.fundingApi` like the other resources.
|
|
12680
|
+
*/
|
|
12681
|
+
/** Where the funded crypto should land (CAIP-2 chain + token + wallet). */
|
|
12682
|
+
interface FundingTarget {
|
|
12683
|
+
chain: string;
|
|
12684
|
+
currency: string;
|
|
12685
|
+
address: string;
|
|
12686
|
+
}
|
|
12687
|
+
/** The source route the user commits to sending from. */
|
|
12688
|
+
interface FundingSource {
|
|
12689
|
+
chain: string;
|
|
12690
|
+
currency: string;
|
|
12691
|
+
amount: string;
|
|
12692
|
+
}
|
|
12693
|
+
interface CreateFundingSessionParams {
|
|
12694
|
+
target: FundingTarget;
|
|
12695
|
+
/** Lock the deposit to a fixed amount (destination base units). */
|
|
12696
|
+
amountUnits?: string;
|
|
12697
|
+
metadata?: Record<string, string>;
|
|
12698
|
+
/** Idempotency/correlation key — reusing it returns the existing session. */
|
|
12699
|
+
externalId?: string;
|
|
12700
|
+
/** true = single-use deposit address; false (default) = open/reusable. */
|
|
12701
|
+
strict?: boolean;
|
|
12702
|
+
/**
|
|
12703
|
+
* One-call funding: set the payment method at creation when the source route
|
|
12704
|
+
* is already known — the session comes back in `waiting_payment` with the
|
|
12705
|
+
* deposit address, skipping the separate setPaymentMethod round trip.
|
|
12706
|
+
*/
|
|
12707
|
+
paymentMethod?: FundingPaymentMethodInput;
|
|
12708
|
+
}
|
|
12709
|
+
interface FundingPaymentMethodBase {
|
|
12710
|
+
source: FundingSource;
|
|
12711
|
+
/**
|
|
12712
|
+
* Origin-chain refund address (refunds land on the source chain). Optional —
|
|
12713
|
+
* the server defaults it to the target address for same-VM routes, or to a
|
|
12714
|
+
* source-VM stand-in for cross-VM routes (e.g. an EVM source funding a Solana
|
|
12715
|
+
* wallet), where the destination address isn't valid on the source chain.
|
|
12716
|
+
*/
|
|
12717
|
+
refundTo?: string;
|
|
12718
|
+
}
|
|
12719
|
+
/**
|
|
12720
|
+
* The source route the user commits to. `evm` / `solana` are self-custody
|
|
12721
|
+
* transfers; `cex` is a guided withdrawal from a centralized exchange — the same
|
|
12722
|
+
* deposit address, plus withdrawal guidance (network, minimum, memo) and no
|
|
12723
|
+
* wallet deeplinks (exchanges don't expose them).
|
|
12724
|
+
*/
|
|
12725
|
+
type FundingPaymentMethodInput = (FundingPaymentMethodBase & {
|
|
12726
|
+
type: 'evm';
|
|
12727
|
+
}) | (FundingPaymentMethodBase & {
|
|
12728
|
+
type: 'solana';
|
|
12729
|
+
}) | (FundingPaymentMethodBase & {
|
|
12730
|
+
type: 'cex';
|
|
12731
|
+
/** Exchange id, e.g. "binance" | "coinbase". */
|
|
12732
|
+
cex: string;
|
|
12733
|
+
});
|
|
12734
|
+
type FundingSessionStatus = 'requires_payment_method' | 'waiting_payment' | 'processing' | 'succeeded' | 'bounced' | 'expired';
|
|
12735
|
+
interface FundingFee {
|
|
12736
|
+
kind: string;
|
|
12737
|
+
amount: string;
|
|
12738
|
+
currency: string;
|
|
12739
|
+
}
|
|
12740
|
+
interface FundingWalletDeeplink {
|
|
12741
|
+
app: string;
|
|
12742
|
+
label: string;
|
|
12743
|
+
url: string;
|
|
12744
|
+
}
|
|
12745
|
+
/** Withdrawal guidance for a `cex` payment method. */
|
|
12746
|
+
interface FundingCexGuidance {
|
|
12747
|
+
/** Exchange id, e.g. "binance" | "coinbase". */
|
|
12748
|
+
exchange: string;
|
|
12749
|
+
/** Network name as the exchange labels it, e.g. "Base", "Polygon". */
|
|
12750
|
+
network: string;
|
|
12751
|
+
/** Minimum withdrawal in source base units, if the exchange enforces one. */
|
|
12752
|
+
minWithdrawal: string | null;
|
|
12753
|
+
/** True when the network requires a destination tag / memo. */
|
|
12754
|
+
requiresMemo: boolean;
|
|
12755
|
+
}
|
|
12756
|
+
interface FundingPaymentMethod {
|
|
12757
|
+
type: string;
|
|
12758
|
+
source: FundingSource;
|
|
12759
|
+
receiverAddress: string;
|
|
12760
|
+
addressUri: string;
|
|
12761
|
+
deeplinks: FundingWalletDeeplink[];
|
|
12762
|
+
/** Withdrawal guidance; present only for `cex` payment methods, else null. */
|
|
12763
|
+
cex: FundingCexGuidance | null;
|
|
12764
|
+
fees: FundingFee[];
|
|
12765
|
+
minAmount: string | null;
|
|
12766
|
+
}
|
|
12767
|
+
interface FundingSession {
|
|
12768
|
+
id: string;
|
|
12769
|
+
object: string;
|
|
12770
|
+
status: FundingSessionStatus;
|
|
12771
|
+
clientSecret: string;
|
|
12772
|
+
target: FundingTarget;
|
|
12773
|
+
amountUnits: string | null;
|
|
12774
|
+
metadata: Record<string, string> | null;
|
|
12775
|
+
externalId: string | null;
|
|
12776
|
+
strict: boolean;
|
|
12777
|
+
paymentMethod: FundingPaymentMethod | null;
|
|
12778
|
+
createdAt: number;
|
|
12779
|
+
expiresAt: number;
|
|
12780
|
+
}
|
|
12781
|
+
/**
|
|
12782
|
+
* Parameters for a Coinbase "Transfer funds" pay-link. Session-bound: the
|
|
12783
|
+
* destination chain and address come from the session, so the link can't be
|
|
12784
|
+
* redirected — the client only chooses the amount.
|
|
12785
|
+
*/
|
|
12786
|
+
interface PayLinkParams {
|
|
12787
|
+
/** Funding session (starts with fnd_) whose wallet receives the funds. */
|
|
12788
|
+
sessionId: string;
|
|
12789
|
+
/**
|
|
12790
|
+
* The session's client secret. Optional when the session was created on this
|
|
12791
|
+
* SDK instance (remembered from create()); required for sessions created elsewhere.
|
|
12792
|
+
*/
|
|
12793
|
+
clientSecret?: string;
|
|
12794
|
+
/** Amount to deliver, in the asset's human units (Coinbase enforces a minimum). */
|
|
12795
|
+
amount: string;
|
|
12796
|
+
/** Destination asset ticker; defaults to "USDC" server-side. */
|
|
12797
|
+
asset?: string;
|
|
12798
|
+
}
|
|
12799
|
+
/** A source currency available on a chain. */
|
|
12800
|
+
interface FundingCurrency {
|
|
12801
|
+
symbol: string;
|
|
12802
|
+
/** Contract address, or the zero address for the chain's native asset. */
|
|
12803
|
+
address: string;
|
|
12804
|
+
decimals: number;
|
|
12805
|
+
logo: string | null;
|
|
12806
|
+
/** True for the chain's native currency (ETH, SOL, POL, …). */
|
|
12807
|
+
native: boolean;
|
|
12808
|
+
}
|
|
12809
|
+
/** A source chain the rail can route from, with its routable currencies. */
|
|
12810
|
+
interface FundingChain {
|
|
12811
|
+
/** CAIP-2 chain id, e.g. "eip155:8453". */
|
|
12812
|
+
id: string;
|
|
12813
|
+
name: string;
|
|
12814
|
+
logo: string | null;
|
|
12815
|
+
vmType: string;
|
|
12816
|
+
currencies: FundingCurrency[];
|
|
12817
|
+
}
|
|
12818
|
+
declare class FundingApi {
|
|
12819
|
+
private request;
|
|
12820
|
+
/**
|
|
12821
|
+
* Client secrets remembered from create() responses, so follow-up calls in
|
|
12822
|
+
* the same SDK instance don't need to thread the secret manually. Passing an
|
|
12823
|
+
* explicit `clientSecret` always overrides (e.g. sessions created elsewhere).
|
|
12824
|
+
*/
|
|
12825
|
+
private readonly secrets;
|
|
12826
|
+
private resolveSecret;
|
|
12827
|
+
private remember;
|
|
12828
|
+
/** Funding session sub-resource: create → setPaymentMethod → get/wait. */
|
|
12829
|
+
readonly sessions: {
|
|
12830
|
+
create: (params: CreateFundingSessionParams) => Promise<FundingSession>;
|
|
12831
|
+
setPaymentMethod: (sessionId: string, params: {
|
|
12832
|
+
paymentMethod: FundingPaymentMethodInput;
|
|
12833
|
+
clientSecret?: string;
|
|
12834
|
+
}) => Promise<FundingSession>;
|
|
12835
|
+
get: (sessionId: string, params?: {
|
|
12836
|
+
clientSecret?: string;
|
|
12837
|
+
}) => Promise<FundingSession>;
|
|
12838
|
+
/**
|
|
12839
|
+
* Poll a session until it reaches a terminal status (`succeeded`, `bounced`,
|
|
12840
|
+
* or `expired`). Resolves with the terminal session; rejects on timeout.
|
|
12841
|
+
*/
|
|
12842
|
+
wait: (sessionId: string, params?: {
|
|
12843
|
+
clientSecret?: string;
|
|
12844
|
+
pollMs?: number;
|
|
12845
|
+
timeoutMs?: number;
|
|
12846
|
+
}) => Promise<FundingSession>;
|
|
12847
|
+
};
|
|
12848
|
+
/**
|
|
12849
|
+
* One-call deposit: create a session with the payment method set, then poll
|
|
12850
|
+
* until it reaches a terminal status (`succeeded`, `bounced`, or `expired`).
|
|
12851
|
+
* Bundles `sessions.create` + `sessions.wait` — the headless equivalent of the
|
|
12852
|
+
* React `useFunding().fund()` flow. Resolves with the terminal session; rejects
|
|
12853
|
+
* on timeout.
|
|
12854
|
+
*/
|
|
12855
|
+
readonly fund: (params: {
|
|
12856
|
+
target: FundingTarget;
|
|
12857
|
+
paymentMethod: FundingPaymentMethodInput;
|
|
12858
|
+
/** Lock the deposit to a fixed amount (destination base units). */
|
|
12859
|
+
amountUnits?: string;
|
|
12860
|
+
metadata?: Record<string, string>;
|
|
12861
|
+
/** Idempotency/correlation key — reusing it returns the existing session. */
|
|
12862
|
+
externalId?: string;
|
|
12863
|
+
/** true = single-use deposit address; false (default) = open/reusable. */
|
|
12864
|
+
strict?: boolean;
|
|
12865
|
+
/** Poll interval and overall timeout for the wait phase. */
|
|
12866
|
+
wait?: {
|
|
12867
|
+
pollMs?: number;
|
|
12868
|
+
timeoutMs?: number;
|
|
12869
|
+
};
|
|
12870
|
+
}) => Promise<FundingSession>;
|
|
12871
|
+
/**
|
|
12872
|
+
* Resolve a prefilled Coinbase "Transfer funds" URL that delivers the asset to
|
|
12873
|
+
* the session's wallet. Session-bound — the destination comes from the session,
|
|
12874
|
+
* so the client only chooses the amount. Powers the "send from an exchange" path.
|
|
12875
|
+
*/
|
|
12876
|
+
readonly payLink: (params: PayLinkParams) => Promise<string>;
|
|
12877
|
+
/**
|
|
12878
|
+
* The source chains + currencies the rail can route from — a live passthrough
|
|
12879
|
+
* of the provider's supported routes, for building the source picker.
|
|
12880
|
+
*/
|
|
12881
|
+
readonly chains: () => Promise<FundingChain[]>;
|
|
12882
|
+
}
|
|
12883
|
+
|
|
12669
12884
|
declare class ProxyApi {
|
|
12670
12885
|
private backendApiClients;
|
|
12671
12886
|
private validateAndRefreshToken;
|
|
@@ -12852,6 +13067,7 @@ declare class Openfort {
|
|
|
12852
13067
|
private embeddedWalletInstance?;
|
|
12853
13068
|
private userInstance?;
|
|
12854
13069
|
private proxyInstance?;
|
|
13070
|
+
private fundingInstance?;
|
|
12855
13071
|
private configuration;
|
|
12856
13072
|
eventEmitter: TypedEventEmitter<OpenfortEventMap>;
|
|
12857
13073
|
private iPasskeyHandler;
|
|
@@ -12864,6 +13080,7 @@ declare class Openfort {
|
|
|
12864
13080
|
get embeddedWallet(): EmbeddedWalletApi;
|
|
12865
13081
|
get user(): UserApi;
|
|
12866
13082
|
get proxy(): ProxyApi;
|
|
13083
|
+
get funding(): FundingApi;
|
|
12867
13084
|
private initializeSynchronously;
|
|
12868
13085
|
constructor(sdkConfiguration: OpenfortSDKConfiguration);
|
|
12869
13086
|
/**
|
|
@@ -13306,4 +13523,4 @@ declare function cryptoDigest(algorithm: string, data: BufferSource): Promise<Ar
|
|
|
13306
13523
|
*/
|
|
13307
13524
|
declare const openfortEvents: TypedEventEmitter<OpenfortEventMap>;
|
|
13308
13525
|
|
|
13309
|
-
export { AccountTypeEnum, AuthActionRequiredActions, AuthActionRequiredResponse, AuthApi, AuthInitPayload, AuthResponse, AuthType, AuthenticationError, Authorization, AuthorizationError, BasicAuthProvider, ChainTypeEnum, ConfigurationError, EmbeddedAccount, EmbeddedState, EmbeddedWalletApi, GrantPermissionsParameters, GrantPermissionsReturnType, IPasskeyHandler, IframeHandshakeTimeoutError, IframeSignEmptyResponseError, IframeSignTimeoutError, InitializeOAuthOptions, MissingProjectEntropyError, MissingRecoveryPasswordError, NotConfiguredError, OAuthError, OAuthProvider, OPENFORT_AUTH_ERROR_CODES, OPENFORT_ERROR_CODES, OTPError, OTPRequiredError, Openfort, OpenfortAuthErrorCode, OpenfortConfiguration, OpenfortError, OpenfortErrorCode, OpenfortEventMap, OpenfortEvents, OpenfortInternal, OpenfortSDKConfiguration, PASSKEY_ERROR_CODES, PasskeyAssertionFailedError, PasskeyCreateConfig, PasskeyCreationFailedError, PasskeyDeriveConfig, PasskeyDetails, PasskeyEnv, PasskeyErrorCode, PasskeyHandler, PasskeyPRFNotSupportedError, PasskeySeedInvalidError, PasskeyUserCancelledError, Permission, Policy, PrepareAuthorizationParams, Provider, ProxyApi, RecoveryError, RecoveryMethod, RecoveryMethodDetails, RecoveryParams, RequestError, RevokePermissionsRequestParams, SDKConfiguration, SDKOverrides, SessionEndedBeforeSetupError, SessionError, SessionResponse, ShieldAuthOptions, ShieldConfiguration, ShieldOptions, SignAuthorizationParams, SignedAuthorization, SignedMessagePayload, Signer, SignerError, IStorage as Storage, ThirdPartyAuthConfiguration, ThirdPartyAuthProvider as ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataPayload, User, ListAccountsGet200ResponseInner as UserAccount, UserApi, UserError, WrongPasskeyError, WrongRecoveryPasswordError, arrayBufferToBase64URL, base64ToArrayBuffer, cryptoDigest, openfortEvents, prepareAndSignAuthorization, serializeSignedAuthorization, signAuthorization };
|
|
13526
|
+
export { AccountTypeEnum, AuthActionRequiredActions, AuthActionRequiredResponse, AuthApi, AuthInitPayload, AuthResponse, AuthType, AuthenticationError, Authorization, AuthorizationError, BasicAuthProvider, ChainTypeEnum, ConfigurationError, CreateFundingSessionParams, EmbeddedAccount, EmbeddedState, EmbeddedWalletApi, FundingApi, FundingCexGuidance, FundingChain, FundingCurrency, FundingFee, FundingPaymentMethod, FundingPaymentMethodInput, FundingSession, FundingSessionStatus, FundingSource, FundingTarget, FundingWalletDeeplink, GrantPermissionsParameters, GrantPermissionsReturnType, IPasskeyHandler, IframeHandshakeTimeoutError, IframeSignEmptyResponseError, IframeSignTimeoutError, InitializeOAuthOptions, MissingProjectEntropyError, MissingRecoveryPasswordError, NotConfiguredError, OAuthError, OAuthProvider, OPENFORT_AUTH_ERROR_CODES, OPENFORT_ERROR_CODES, OTPError, OTPRequiredError, Openfort, OpenfortAuthErrorCode, OpenfortConfiguration, OpenfortError, OpenfortErrorCode, OpenfortEventMap, OpenfortEvents, OpenfortInternal, OpenfortSDKConfiguration, PASSKEY_ERROR_CODES, PasskeyAssertionFailedError, PasskeyCreateConfig, PasskeyCreationFailedError, PasskeyDeriveConfig, PasskeyDetails, PasskeyEnv, PasskeyErrorCode, PasskeyHandler, PasskeyPRFNotSupportedError, PasskeySeedInvalidError, PasskeyUserCancelledError, PayLinkParams, Permission, Policy, PrepareAuthorizationParams, Provider, ProxyApi, RecoveryError, RecoveryMethod, RecoveryMethodDetails, RecoveryParams, RequestError, RevokePermissionsRequestParams, SDKConfiguration, SDKOverrides, SessionEndedBeforeSetupError, SessionError, SessionResponse, ShieldAuthOptions, ShieldConfiguration, ShieldOptions, SignAuthorizationParams, SignedAuthorization, SignedMessagePayload, Signer, SignerError, IStorage as Storage, ThirdPartyAuthConfiguration, ThirdPartyAuthProvider as ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataPayload, User, ListAccountsGet200ResponseInner as UserAccount, UserApi, UserError, WrongPasskeyError, WrongRecoveryPasswordError, arrayBufferToBase64URL, base64ToArrayBuffer, cryptoDigest, openfortEvents, prepareAndSignAuthorization, serializeSignedAuthorization, signAuthorization };
|
package/dist/index.d.ts
CHANGED
|
@@ -12666,6 +12666,221 @@ declare class RequestError extends OpenfortError {
|
|
|
12666
12666
|
constructor(error_description: string, statusCode?: number | undefined);
|
|
12667
12667
|
}
|
|
12668
12668
|
|
|
12669
|
+
/**
|
|
12670
|
+
* Funding (cross-chain wallet deposit) resource.
|
|
12671
|
+
*
|
|
12672
|
+
* Wraps the API's `/v2/funding` session endpoints: create a session for a
|
|
12673
|
+
* destination, set a single payment method (a source route) to mint a Relay
|
|
12674
|
+
* deposit address, then poll until terminal. Sessions are guarded by a
|
|
12675
|
+
* per-session `clientSecret` and authenticated with the project publishable key.
|
|
12676
|
+
*
|
|
12677
|
+
* NOTE: This thin wrapper calls the backend directly. Once the API's funding
|
|
12678
|
+
* endpoints are part of the published OpenAPI spec, this can move onto the
|
|
12679
|
+
* generated `BackendApiClients.fundingApi` like the other resources.
|
|
12680
|
+
*/
|
|
12681
|
+
/** Where the funded crypto should land (CAIP-2 chain + token + wallet). */
|
|
12682
|
+
interface FundingTarget {
|
|
12683
|
+
chain: string;
|
|
12684
|
+
currency: string;
|
|
12685
|
+
address: string;
|
|
12686
|
+
}
|
|
12687
|
+
/** The source route the user commits to sending from. */
|
|
12688
|
+
interface FundingSource {
|
|
12689
|
+
chain: string;
|
|
12690
|
+
currency: string;
|
|
12691
|
+
amount: string;
|
|
12692
|
+
}
|
|
12693
|
+
interface CreateFundingSessionParams {
|
|
12694
|
+
target: FundingTarget;
|
|
12695
|
+
/** Lock the deposit to a fixed amount (destination base units). */
|
|
12696
|
+
amountUnits?: string;
|
|
12697
|
+
metadata?: Record<string, string>;
|
|
12698
|
+
/** Idempotency/correlation key — reusing it returns the existing session. */
|
|
12699
|
+
externalId?: string;
|
|
12700
|
+
/** true = single-use deposit address; false (default) = open/reusable. */
|
|
12701
|
+
strict?: boolean;
|
|
12702
|
+
/**
|
|
12703
|
+
* One-call funding: set the payment method at creation when the source route
|
|
12704
|
+
* is already known — the session comes back in `waiting_payment` with the
|
|
12705
|
+
* deposit address, skipping the separate setPaymentMethod round trip.
|
|
12706
|
+
*/
|
|
12707
|
+
paymentMethod?: FundingPaymentMethodInput;
|
|
12708
|
+
}
|
|
12709
|
+
interface FundingPaymentMethodBase {
|
|
12710
|
+
source: FundingSource;
|
|
12711
|
+
/**
|
|
12712
|
+
* Origin-chain refund address (refunds land on the source chain). Optional —
|
|
12713
|
+
* the server defaults it to the target address for same-VM routes, or to a
|
|
12714
|
+
* source-VM stand-in for cross-VM routes (e.g. an EVM source funding a Solana
|
|
12715
|
+
* wallet), where the destination address isn't valid on the source chain.
|
|
12716
|
+
*/
|
|
12717
|
+
refundTo?: string;
|
|
12718
|
+
}
|
|
12719
|
+
/**
|
|
12720
|
+
* The source route the user commits to. `evm` / `solana` are self-custody
|
|
12721
|
+
* transfers; `cex` is a guided withdrawal from a centralized exchange — the same
|
|
12722
|
+
* deposit address, plus withdrawal guidance (network, minimum, memo) and no
|
|
12723
|
+
* wallet deeplinks (exchanges don't expose them).
|
|
12724
|
+
*/
|
|
12725
|
+
type FundingPaymentMethodInput = (FundingPaymentMethodBase & {
|
|
12726
|
+
type: 'evm';
|
|
12727
|
+
}) | (FundingPaymentMethodBase & {
|
|
12728
|
+
type: 'solana';
|
|
12729
|
+
}) | (FundingPaymentMethodBase & {
|
|
12730
|
+
type: 'cex';
|
|
12731
|
+
/** Exchange id, e.g. "binance" | "coinbase". */
|
|
12732
|
+
cex: string;
|
|
12733
|
+
});
|
|
12734
|
+
type FundingSessionStatus = 'requires_payment_method' | 'waiting_payment' | 'processing' | 'succeeded' | 'bounced' | 'expired';
|
|
12735
|
+
interface FundingFee {
|
|
12736
|
+
kind: string;
|
|
12737
|
+
amount: string;
|
|
12738
|
+
currency: string;
|
|
12739
|
+
}
|
|
12740
|
+
interface FundingWalletDeeplink {
|
|
12741
|
+
app: string;
|
|
12742
|
+
label: string;
|
|
12743
|
+
url: string;
|
|
12744
|
+
}
|
|
12745
|
+
/** Withdrawal guidance for a `cex` payment method. */
|
|
12746
|
+
interface FundingCexGuidance {
|
|
12747
|
+
/** Exchange id, e.g. "binance" | "coinbase". */
|
|
12748
|
+
exchange: string;
|
|
12749
|
+
/** Network name as the exchange labels it, e.g. "Base", "Polygon". */
|
|
12750
|
+
network: string;
|
|
12751
|
+
/** Minimum withdrawal in source base units, if the exchange enforces one. */
|
|
12752
|
+
minWithdrawal: string | null;
|
|
12753
|
+
/** True when the network requires a destination tag / memo. */
|
|
12754
|
+
requiresMemo: boolean;
|
|
12755
|
+
}
|
|
12756
|
+
interface FundingPaymentMethod {
|
|
12757
|
+
type: string;
|
|
12758
|
+
source: FundingSource;
|
|
12759
|
+
receiverAddress: string;
|
|
12760
|
+
addressUri: string;
|
|
12761
|
+
deeplinks: FundingWalletDeeplink[];
|
|
12762
|
+
/** Withdrawal guidance; present only for `cex` payment methods, else null. */
|
|
12763
|
+
cex: FundingCexGuidance | null;
|
|
12764
|
+
fees: FundingFee[];
|
|
12765
|
+
minAmount: string | null;
|
|
12766
|
+
}
|
|
12767
|
+
interface FundingSession {
|
|
12768
|
+
id: string;
|
|
12769
|
+
object: string;
|
|
12770
|
+
status: FundingSessionStatus;
|
|
12771
|
+
clientSecret: string;
|
|
12772
|
+
target: FundingTarget;
|
|
12773
|
+
amountUnits: string | null;
|
|
12774
|
+
metadata: Record<string, string> | null;
|
|
12775
|
+
externalId: string | null;
|
|
12776
|
+
strict: boolean;
|
|
12777
|
+
paymentMethod: FundingPaymentMethod | null;
|
|
12778
|
+
createdAt: number;
|
|
12779
|
+
expiresAt: number;
|
|
12780
|
+
}
|
|
12781
|
+
/**
|
|
12782
|
+
* Parameters for a Coinbase "Transfer funds" pay-link. Session-bound: the
|
|
12783
|
+
* destination chain and address come from the session, so the link can't be
|
|
12784
|
+
* redirected — the client only chooses the amount.
|
|
12785
|
+
*/
|
|
12786
|
+
interface PayLinkParams {
|
|
12787
|
+
/** Funding session (starts with fnd_) whose wallet receives the funds. */
|
|
12788
|
+
sessionId: string;
|
|
12789
|
+
/**
|
|
12790
|
+
* The session's client secret. Optional when the session was created on this
|
|
12791
|
+
* SDK instance (remembered from create()); required for sessions created elsewhere.
|
|
12792
|
+
*/
|
|
12793
|
+
clientSecret?: string;
|
|
12794
|
+
/** Amount to deliver, in the asset's human units (Coinbase enforces a minimum). */
|
|
12795
|
+
amount: string;
|
|
12796
|
+
/** Destination asset ticker; defaults to "USDC" server-side. */
|
|
12797
|
+
asset?: string;
|
|
12798
|
+
}
|
|
12799
|
+
/** A source currency available on a chain. */
|
|
12800
|
+
interface FundingCurrency {
|
|
12801
|
+
symbol: string;
|
|
12802
|
+
/** Contract address, or the zero address for the chain's native asset. */
|
|
12803
|
+
address: string;
|
|
12804
|
+
decimals: number;
|
|
12805
|
+
logo: string | null;
|
|
12806
|
+
/** True for the chain's native currency (ETH, SOL, POL, …). */
|
|
12807
|
+
native: boolean;
|
|
12808
|
+
}
|
|
12809
|
+
/** A source chain the rail can route from, with its routable currencies. */
|
|
12810
|
+
interface FundingChain {
|
|
12811
|
+
/** CAIP-2 chain id, e.g. "eip155:8453". */
|
|
12812
|
+
id: string;
|
|
12813
|
+
name: string;
|
|
12814
|
+
logo: string | null;
|
|
12815
|
+
vmType: string;
|
|
12816
|
+
currencies: FundingCurrency[];
|
|
12817
|
+
}
|
|
12818
|
+
declare class FundingApi {
|
|
12819
|
+
private request;
|
|
12820
|
+
/**
|
|
12821
|
+
* Client secrets remembered from create() responses, so follow-up calls in
|
|
12822
|
+
* the same SDK instance don't need to thread the secret manually. Passing an
|
|
12823
|
+
* explicit `clientSecret` always overrides (e.g. sessions created elsewhere).
|
|
12824
|
+
*/
|
|
12825
|
+
private readonly secrets;
|
|
12826
|
+
private resolveSecret;
|
|
12827
|
+
private remember;
|
|
12828
|
+
/** Funding session sub-resource: create → setPaymentMethod → get/wait. */
|
|
12829
|
+
readonly sessions: {
|
|
12830
|
+
create: (params: CreateFundingSessionParams) => Promise<FundingSession>;
|
|
12831
|
+
setPaymentMethod: (sessionId: string, params: {
|
|
12832
|
+
paymentMethod: FundingPaymentMethodInput;
|
|
12833
|
+
clientSecret?: string;
|
|
12834
|
+
}) => Promise<FundingSession>;
|
|
12835
|
+
get: (sessionId: string, params?: {
|
|
12836
|
+
clientSecret?: string;
|
|
12837
|
+
}) => Promise<FundingSession>;
|
|
12838
|
+
/**
|
|
12839
|
+
* Poll a session until it reaches a terminal status (`succeeded`, `bounced`,
|
|
12840
|
+
* or `expired`). Resolves with the terminal session; rejects on timeout.
|
|
12841
|
+
*/
|
|
12842
|
+
wait: (sessionId: string, params?: {
|
|
12843
|
+
clientSecret?: string;
|
|
12844
|
+
pollMs?: number;
|
|
12845
|
+
timeoutMs?: number;
|
|
12846
|
+
}) => Promise<FundingSession>;
|
|
12847
|
+
};
|
|
12848
|
+
/**
|
|
12849
|
+
* One-call deposit: create a session with the payment method set, then poll
|
|
12850
|
+
* until it reaches a terminal status (`succeeded`, `bounced`, or `expired`).
|
|
12851
|
+
* Bundles `sessions.create` + `sessions.wait` — the headless equivalent of the
|
|
12852
|
+
* React `useFunding().fund()` flow. Resolves with the terminal session; rejects
|
|
12853
|
+
* on timeout.
|
|
12854
|
+
*/
|
|
12855
|
+
readonly fund: (params: {
|
|
12856
|
+
target: FundingTarget;
|
|
12857
|
+
paymentMethod: FundingPaymentMethodInput;
|
|
12858
|
+
/** Lock the deposit to a fixed amount (destination base units). */
|
|
12859
|
+
amountUnits?: string;
|
|
12860
|
+
metadata?: Record<string, string>;
|
|
12861
|
+
/** Idempotency/correlation key — reusing it returns the existing session. */
|
|
12862
|
+
externalId?: string;
|
|
12863
|
+
/** true = single-use deposit address; false (default) = open/reusable. */
|
|
12864
|
+
strict?: boolean;
|
|
12865
|
+
/** Poll interval and overall timeout for the wait phase. */
|
|
12866
|
+
wait?: {
|
|
12867
|
+
pollMs?: number;
|
|
12868
|
+
timeoutMs?: number;
|
|
12869
|
+
};
|
|
12870
|
+
}) => Promise<FundingSession>;
|
|
12871
|
+
/**
|
|
12872
|
+
* Resolve a prefilled Coinbase "Transfer funds" URL that delivers the asset to
|
|
12873
|
+
* the session's wallet. Session-bound — the destination comes from the session,
|
|
12874
|
+
* so the client only chooses the amount. Powers the "send from an exchange" path.
|
|
12875
|
+
*/
|
|
12876
|
+
readonly payLink: (params: PayLinkParams) => Promise<string>;
|
|
12877
|
+
/**
|
|
12878
|
+
* The source chains + currencies the rail can route from — a live passthrough
|
|
12879
|
+
* of the provider's supported routes, for building the source picker.
|
|
12880
|
+
*/
|
|
12881
|
+
readonly chains: () => Promise<FundingChain[]>;
|
|
12882
|
+
}
|
|
12883
|
+
|
|
12669
12884
|
declare class ProxyApi {
|
|
12670
12885
|
private backendApiClients;
|
|
12671
12886
|
private validateAndRefreshToken;
|
|
@@ -12852,6 +13067,7 @@ declare class Openfort {
|
|
|
12852
13067
|
private embeddedWalletInstance?;
|
|
12853
13068
|
private userInstance?;
|
|
12854
13069
|
private proxyInstance?;
|
|
13070
|
+
private fundingInstance?;
|
|
12855
13071
|
private configuration;
|
|
12856
13072
|
eventEmitter: TypedEventEmitter<OpenfortEventMap>;
|
|
12857
13073
|
private iPasskeyHandler;
|
|
@@ -12864,6 +13080,7 @@ declare class Openfort {
|
|
|
12864
13080
|
get embeddedWallet(): EmbeddedWalletApi;
|
|
12865
13081
|
get user(): UserApi;
|
|
12866
13082
|
get proxy(): ProxyApi;
|
|
13083
|
+
get funding(): FundingApi;
|
|
12867
13084
|
private initializeSynchronously;
|
|
12868
13085
|
constructor(sdkConfiguration: OpenfortSDKConfiguration);
|
|
12869
13086
|
/**
|
|
@@ -13306,4 +13523,4 @@ declare function cryptoDigest(algorithm: string, data: BufferSource): Promise<Ar
|
|
|
13306
13523
|
*/
|
|
13307
13524
|
declare const openfortEvents: TypedEventEmitter<OpenfortEventMap>;
|
|
13308
13525
|
|
|
13309
|
-
export { AccountTypeEnum, AuthActionRequiredActions, AuthActionRequiredResponse, AuthApi, AuthInitPayload, AuthResponse, AuthType, AuthenticationError, Authorization, AuthorizationError, BasicAuthProvider, ChainTypeEnum, ConfigurationError, EmbeddedAccount, EmbeddedState, EmbeddedWalletApi, GrantPermissionsParameters, GrantPermissionsReturnType, IPasskeyHandler, IframeHandshakeTimeoutError, IframeSignEmptyResponseError, IframeSignTimeoutError, InitializeOAuthOptions, MissingProjectEntropyError, MissingRecoveryPasswordError, NotConfiguredError, OAuthError, OAuthProvider, OPENFORT_AUTH_ERROR_CODES, OPENFORT_ERROR_CODES, OTPError, OTPRequiredError, Openfort, OpenfortAuthErrorCode, OpenfortConfiguration, OpenfortError, OpenfortErrorCode, OpenfortEventMap, OpenfortEvents, OpenfortInternal, OpenfortSDKConfiguration, PASSKEY_ERROR_CODES, PasskeyAssertionFailedError, PasskeyCreateConfig, PasskeyCreationFailedError, PasskeyDeriveConfig, PasskeyDetails, PasskeyEnv, PasskeyErrorCode, PasskeyHandler, PasskeyPRFNotSupportedError, PasskeySeedInvalidError, PasskeyUserCancelledError, Permission, Policy, PrepareAuthorizationParams, Provider, ProxyApi, RecoveryError, RecoveryMethod, RecoveryMethodDetails, RecoveryParams, RequestError, RevokePermissionsRequestParams, SDKConfiguration, SDKOverrides, SessionEndedBeforeSetupError, SessionError, SessionResponse, ShieldAuthOptions, ShieldConfiguration, ShieldOptions, SignAuthorizationParams, SignedAuthorization, SignedMessagePayload, Signer, SignerError, IStorage as Storage, ThirdPartyAuthConfiguration, ThirdPartyAuthProvider as ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataPayload, User, ListAccountsGet200ResponseInner as UserAccount, UserApi, UserError, WrongPasskeyError, WrongRecoveryPasswordError, arrayBufferToBase64URL, base64ToArrayBuffer, cryptoDigest, openfortEvents, prepareAndSignAuthorization, serializeSignedAuthorization, signAuthorization };
|
|
13526
|
+
export { AccountTypeEnum, AuthActionRequiredActions, AuthActionRequiredResponse, AuthApi, AuthInitPayload, AuthResponse, AuthType, AuthenticationError, Authorization, AuthorizationError, BasicAuthProvider, ChainTypeEnum, ConfigurationError, CreateFundingSessionParams, EmbeddedAccount, EmbeddedState, EmbeddedWalletApi, FundingApi, FundingCexGuidance, FundingChain, FundingCurrency, FundingFee, FundingPaymentMethod, FundingPaymentMethodInput, FundingSession, FundingSessionStatus, FundingSource, FundingTarget, FundingWalletDeeplink, GrantPermissionsParameters, GrantPermissionsReturnType, IPasskeyHandler, IframeHandshakeTimeoutError, IframeSignEmptyResponseError, IframeSignTimeoutError, InitializeOAuthOptions, MissingProjectEntropyError, MissingRecoveryPasswordError, NotConfiguredError, OAuthError, OAuthProvider, OPENFORT_AUTH_ERROR_CODES, OPENFORT_ERROR_CODES, OTPError, OTPRequiredError, Openfort, OpenfortAuthErrorCode, OpenfortConfiguration, OpenfortError, OpenfortErrorCode, OpenfortEventMap, OpenfortEvents, OpenfortInternal, OpenfortSDKConfiguration, PASSKEY_ERROR_CODES, PasskeyAssertionFailedError, PasskeyCreateConfig, PasskeyCreationFailedError, PasskeyDeriveConfig, PasskeyDetails, PasskeyEnv, PasskeyErrorCode, PasskeyHandler, PasskeyPRFNotSupportedError, PasskeySeedInvalidError, PasskeyUserCancelledError, PayLinkParams, Permission, Policy, PrepareAuthorizationParams, Provider, ProxyApi, RecoveryError, RecoveryMethod, RecoveryMethodDetails, RecoveryParams, RequestError, RevokePermissionsRequestParams, SDKConfiguration, SDKOverrides, SessionEndedBeforeSetupError, SessionError, SessionResponse, ShieldAuthOptions, ShieldConfiguration, ShieldOptions, SignAuthorizationParams, SignedAuthorization, SignedMessagePayload, Signer, SignerError, IStorage as Storage, ThirdPartyAuthConfiguration, ThirdPartyAuthProvider as ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataPayload, User, ListAccountsGet200ResponseInner as UserAccount, UserApi, UserError, WrongPasskeyError, WrongRecoveryPasswordError, arrayBufferToBase64URL, base64ToArrayBuffer, cryptoDigest, openfortEvents, prepareAndSignAuthorization, serializeSignedAuthorization, signAuthorization };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SDKConfiguration as e}from"../core/config/config.js";import{ConfigurationError as t,RequestError as s}from"../core/errors/openfortError.js";class n{async request(n,r){const i=e.getInstance();if(!i)throw new t("Configuration not found");const o=await fetch(`${i.backendUrl}${n}`,{...r,headers:{Authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"Content-Type":"application/json",...r?.headers??{}},signal:AbortSignal.timeout(3e4)});if(!o.ok){const e=await o.json().catch(()=>({})),t="string"==typeof e.error?e.error:e.error?.message;throw new s(t??"Openfort funding request failed",o.status)}return o.json()}secrets=new Map;resolveSecret(e,t){const s=t??this.secrets.get(e);if(!s)throw new Error(`No clientSecret known for funding session ${e} — pass it explicitly (it was returned when the session was created)`);return s}remember(e){return e.clientSecret&&this.secrets.set(e.id,e.clientSecret),e}sessions={create:async e=>this.remember(await this.request("/v2/funding/sessions",{method:"POST",body:JSON.stringify(e)})),setPaymentMethod:async(e,t)=>this.request(`/v2/funding/sessions/${e}/payment_methods`,{method:"POST",body:JSON.stringify({clientSecret:this.resolveSecret(e,t.clientSecret),paymentMethod:t.paymentMethod})}),get:async(e,t)=>{const s=this.resolveSecret(e,t?.clientSecret);return this.request(`/v2/funding/sessions/${e}?clientSecret=${encodeURIComponent(s)}`)},wait:async(e,t)=>{const s=t?.pollMs??4e3,n=t?.timeoutMs??18e5,r=Date.now()+n;for(;;){const n=await this.sessions.get(e,t);if("succeeded"===n.status||"bounced"===n.status||"expired"===n.status)return n;if(Date.now()>=r)throw new Error(`Timed out waiting for funding session ${e} (last status: ${n.status})`);await new Promise(e=>setTimeout(e,s))}}};fund=async e=>{const t=await this.sessions.create({target:e.target,paymentMethod:e.paymentMethod,amountUnits:e.amountUnits,metadata:e.metadata,externalId:e.externalId,strict:e.strict});return this.sessions.wait(t.id,e.wait)};payLink=async e=>{const{url:t}=await this.request("/v2/funding/pay_link",{method:"POST",body:JSON.stringify({sessionId:e.sessionId,clientSecret:this.resolveSecret(e.sessionId,e.clientSecret),amount:e.amount,asset:e.asset})});return t};chains=async()=>{const{chains:e}=await this.request("/v2/funding/chains");return e}}export{n as FundingApi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BackendApiClients as e}from"../../../packages/internal/openapi-clients/dist/index.js";import{AuthApi as t}from"../api/auth.js";import{EmbeddedWalletApi as i}from"../api/embeddedWallet.js";import{
|
|
1
|
+
import{BackendApiClients as e}from"../../../packages/internal/openapi-clients/dist/index.js";import{AuthApi as t}from"../api/auth.js";import{EmbeddedWalletApi as i}from"../api/embeddedWallet.js";import{FundingApi as n}from"../api/funding.js";import{ProxyApi as a}from"../api/proxy.js";import{UserApi as s}from"../api/user.js";import{AuthManager as r}from"../auth/authManager.js";import{StorageKeys as o}from"../storage/istorage.js";import{LazyStorage as h}from"../storage/lazyStorage.js";import l from"../utils/typedEventEmitter.js";import{SDKConfiguration as d}from"./config/config.js";import{OPENFORT_AUTH_ERROR_CODES as c,OPENFORT_ERROR_CODES as u}from"./errors/authErrorCodes.js";import{ConfigurationError as g,SignerError as f,RequestError as m,OpenfortError as p}from"./errors/openfortError.js";import{InternalSentry as w}from"./errors/sentry.js";import{OpenfortInternal as I}from"./openfortInternal.js";import{PasskeyHandler as y}from"./passkey/handler.js";class b{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;fundingInstance;configuration;eventEmitter;iPasskeyHandler;static globalEventEmitter=null;get auth(){if(!this.authInstance)throw new g("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.");return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new g("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.");return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new g("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.");return this.userInstance}get proxy(){if(!this.proxyInstance)throw new g("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.");return this.proxyInstance}get funding(){if(!this.fundingInstance)throw new g("Openfort SDK not initialized. Please await waitForInitialization() before accessing funding.");return this.fundingInstance}initializeSynchronously(){try{this.iAuthManager=new r,this.openfortInternal=new I(this.storage,this.authManager,this.eventEmitter),this.authInstance=new t(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new i(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter,this.passkeyHandler),this.userInstance=new s(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.fundingInstance=new n,this.proxyInstance=new a(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new f(c.MISSING_SIGNER,"Embedded wallet not initialized");const e=this.embeddedWalletInstance;return t=>e.signMessage(t,{hashMessage:!0,arrayifyMessage:!0})})}catch(e){throw new g("Openfort SDK synchronous initialization failed")}}constructor(e){if(this.configuration=new d(e),this.storage=new h(this.configuration.baseConfiguration.publishableKey,this.configuration.storage),this.eventEmitter=new l,b.globalEventEmitter){["onAuthInit","onAuthSuccess","onAuthFailure","onLogout","onSwitchAccount","onSignedMessage","onEmbeddedWalletCreated","onEmbeddedWalletRecovered","onAuthFlowOpen","onAuthFlowClose","onAuthFlowCancel"].forEach(e=>{this.eventEmitter.on(e,(...t)=>{b.globalEventEmitter?.emit(e,...t)})})}else b.globalEventEmitter=this.eventEmitter;this.iPasskeyHandler=e.overrides?.passkeyHandler??new y({rpId:e.shieldConfiguration?.passkeyRpId,rpName:e.shieldConfiguration?.passkeyRpName,displayName:e.shieldConfiguration?.passkeyDisplayName}),w.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}static getEventEmitter(){return b.globalEventEmitter||(b.globalEventEmitter=new l),b.globalEventEmitter}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(e){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(e)}get backendApiClients(){return new e({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey,nativeAppIdentifier:this.configuration.nativeAppIdentifier,storage:this.storage,onLogout:()=>{this.eventEmitter.emit("onLogout")}})}get authManager(){if(!this.iAuthManager)throw new m("AuthManager not initialized");return this.iAuthManager}get passkeyHandler(){return this.iPasskeyHandler}static async isStorageAccessible(e){try{const t=o.TEST,i="openfort_storage_test";e.save(t,i);const n=await e.get(t);return e.remove(t),n===i}catch(e){return!1}}async initializeAsync(){if(!await b.isStorageAccessible(this.storage))throw new p("Storage is not accessible. The SDK needs a working key/value store to persist the session. On React Native, ensure the app is code-signed (an unsigned build cannot use the keychain) and that expo-secure-store — or your `overrides.storage` implementation — is installed and reachable.",u.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}}export{b as Openfort};
|
package/dist/sdk/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Openfort as r}from"./core/openfort.js";export{AuthApi}from"./api/auth.js";export{EmbeddedWalletApi}from"./api/embeddedWallet.js";export{ProxyApi}from"./api/proxy.js";export{UserApi}from"./api/user.js";export{OPENFORT_AUTH_ERROR_CODES,OPENFORT_ERROR_CODES}from"./core/errors/authErrorCodes.js";export{AuthenticationError,AuthorizationError,ConfigurationError,OAuthError,OTPError,OpenfortError,RecoveryError,RequestError,SessionError,SignerError,UserError}from"./core/errors/openfortError.js";export{PASSKEY_ERROR_CODES,PasskeyAssertionFailedError,PasskeyCreationFailedError,PasskeyPRFNotSupportedError,PasskeySeedInvalidError,PasskeyUserCancelledError}from"./core/passkey/errors.js";export{PasskeyHandler}from"./core/passkey/handler.js";export{arrayBufferToBase64URL,base64ToArrayBuffer}from"./core/passkey/utils.js";export{OpenfortConfiguration,SDKConfiguration,ShieldConfiguration}from"./core/config/config.js";export{OpenfortInternal}from"./core/openfortInternal.js";export{prepareAndSignAuthorization,serializeSignedAuthorization,signAuthorization}from"./utils/authorization.js";export{IframeHandshakeTimeoutError,IframeSignEmptyResponseError,IframeSignTimeoutError,MissingProjectEntropyError,MissingRecoveryPasswordError,NotConfiguredError,OTPRequiredError,SessionEndedBeforeSetupError,WrongPasskeyError,WrongRecoveryPasswordError}from"./wallets/iframeManager.js";export{AccountTypeEnum,AuthActionRequiredActions,AuthType,BasicAuthProvider,ChainTypeEnum,EmbeddedState,OAuthProvider,OpenfortEvents,RecoveryMethod,ThirdPartyAuthProvider as ThirdPartyOAuthProvider,TokenType}from"./types/types.js";export{cryptoDigest}from"./utils/crypto.js";const o=r.getEventEmitter();export{r as Openfort,o as openfortEvents};
|
|
1
|
+
import{Openfort as r}from"./core/openfort.js";export{AuthApi}from"./api/auth.js";export{EmbeddedWalletApi}from"./api/embeddedWallet.js";export{FundingApi}from"./api/funding.js";export{ProxyApi}from"./api/proxy.js";export{UserApi}from"./api/user.js";export{OPENFORT_AUTH_ERROR_CODES,OPENFORT_ERROR_CODES}from"./core/errors/authErrorCodes.js";export{AuthenticationError,AuthorizationError,ConfigurationError,OAuthError,OTPError,OpenfortError,RecoveryError,RequestError,SessionError,SignerError,UserError}from"./core/errors/openfortError.js";export{PASSKEY_ERROR_CODES,PasskeyAssertionFailedError,PasskeyCreationFailedError,PasskeyPRFNotSupportedError,PasskeySeedInvalidError,PasskeyUserCancelledError}from"./core/passkey/errors.js";export{PasskeyHandler}from"./core/passkey/handler.js";export{arrayBufferToBase64URL,base64ToArrayBuffer}from"./core/passkey/utils.js";export{OpenfortConfiguration,SDKConfiguration,ShieldConfiguration}from"./core/config/config.js";export{OpenfortInternal}from"./core/openfortInternal.js";export{prepareAndSignAuthorization,serializeSignedAuthorization,signAuthorization}from"./utils/authorization.js";export{IframeHandshakeTimeoutError,IframeSignEmptyResponseError,IframeSignTimeoutError,MissingProjectEntropyError,MissingRecoveryPasswordError,NotConfiguredError,OTPRequiredError,SessionEndedBeforeSetupError,WrongPasskeyError,WrongRecoveryPasswordError}from"./wallets/iframeManager.js";export{AccountTypeEnum,AuthActionRequiredActions,AuthType,BasicAuthProvider,ChainTypeEnum,EmbeddedState,OAuthProvider,OpenfortEvents,RecoveryMethod,ThirdPartyAuthProvider as ThirdPartyOAuthProvider,TokenType}from"./types/types.js";export{cryptoDigest}from"./utils/crypto.js";const o=r.getEventEmitter();export{r as Openfort,o as openfortEvents};
|
package/dist/sdk/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="1.
|
|
1
|
+
const o="1.5.0",t="@openfort/openfort-js";export{t as PACKAGE,o as VERSION};
|
package/package.json
CHANGED