@walletconnect/pay 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var u=require("@walletconnect/logger"),l=require("@walletconnect/utils");const h="https://api.pay.walletconnect.com",P="js-walletconnect-pay",f="1.0.0",T="pay",i="WalletConnectPay";function M(){return l.isIos()?"rn-ios":l.isAndroid()?"rn-android":l.isBrowser()?"browser":l.isNode()?"node":"unknown"}var C=Object.defineProperty,$=(n,e,t)=>e in n?C(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,N=(n,e,t)=>$(n,typeof e!="symbol"?e+"":e,t);class o extends Error{constructor(e,t,r){super(t),N(this,"code"),N(this,"originalMessage"),this.name="PayError",this.code=e,this.originalMessage=r??t,Object.setPrototypeOf(this,o.prototype)}static fromNativeError(e){if(e instanceof o)return e;const t=e instanceof Error?e.message:String(e);return t.includes("JSON parse error")?new o("JSON_PARSE",t):t.includes("JSON serialize error")?new o("JSON_SERIALIZE",t):t.includes("Payment options error")?new o("PAYMENT_OPTIONS",t):t.includes("Payment request error")?new o("PAYMENT_REQUEST",t):t.includes("Confirm payment error")?new o("CONFIRM_PAYMENT",t):new o("UNKNOWN",t)}}class p extends o{constructor(){super("NATIVE_MODULE_NOT_FOUND","WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked."),this.name="NativeModuleNotFoundError",Object.setPrototypeOf(this,p.prototype)}}class y extends o{constructor(e){super("PAYMENT_OPTIONS",`Failed to get payment options: ${e}`,e),this.name="PaymentOptionsError",Object.setPrototypeOf(this,y.prototype)}}class m extends o{constructor(e){super("PAYMENT_REQUEST",`Failed to get payment actions: ${e}`,e),this.name="PaymentActionsError",Object.setPrototypeOf(this,m.prototype)}}class g extends o{constructor(e){super("CONFIRM_PAYMENT",`Failed to confirm payment: ${e}`,e),this.name="ConfirmPaymentError",Object.setPrototypeOf(this,g.prototype)}}var _=Object.defineProperty,j=(n,e,t)=>e in n?_(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,L=(n,e,t)=>j(n,typeof e!="symbol"?e+"":e,t);let a,d=null;function O(){var n,e;if(d)return d;if(a!==void 0)return a;try{const t=globalThis.ReactNative;if((n=t?.NativeModules)!=null&&n.RNWalletConnectPay)return a=t.NativeModules.RNWalletConnectPay,a;const r=(e=globalThis.expo)==null?void 0:e.modules;return r!=null&&r.RNWalletConnectPay?(a=r.RNWalletConnectPay,a):(a=null,null)}catch{return a=null,null}}function k(n){d=n,a=n}function I(){return O()!==null}function U(){d=null,a=void 0}class w{constructor(e){L(this,"module");const t=O();if(!t)throw new p;if(t.initialize)try{const r=JSON.stringify(e);t.initialize(r)}catch(r){throw new o("INITIALIZATION_ERROR",`Failed to initialize native Pay module: ${r instanceof Error?r.message:String(r)}`)}this.module=t}async getPaymentOptions(e){var t;const r={paymentLink:e.paymentLink,accounts:e.accounts,includePaymentInfo:(t=e.includePaymentInfo)!=null?t:!1};try{const s=await this.module.getPaymentOptions(JSON.stringify(r));return JSON.parse(s)}catch(s){throw o.fromNativeError(s)}}async getRequiredPaymentActions(e){const t={paymentId:e.paymentId,optionId:e.optionId};try{const r=await this.module.getRequiredPaymentActions(JSON.stringify(t));return JSON.parse(r)}catch(r){throw o.fromNativeError(r)}}async confirmPayment(e){const t={paymentId:e.paymentId,optionId:e.optionId,signatures:e.signatures,collectedData:e.collectedData};try{const r=await this.module.confirmPayment(JSON.stringify(t));return JSON.parse(r)}catch(r){throw o.fromNativeError(r)}}}function b(n){return new w(n)}function v(){return I()?"native":null}function E(n){const e=v();if(!e)throw new Error("No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.");switch(e){case"native":return b(n);case"wasm":throw new Error("WASM provider not yet implemented");default:throw new Error(`Unknown provider type: ${e}`)}}function A(){return v()!==null}var D=Object.defineProperty,W=(n,e,t)=>e in n?D(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,c=(n,e,t)=>W(n,typeof e!="symbol"?e+"":e,t);class S{constructor(e){c(this,"projectId"),c(this,"apiKey"),c(this,"baseUrl"),c(this,"logger"),c(this,"provider");var t,r,s;this.projectId=e.projectId,this.apiKey=e.apiKey,this.baseUrl=(t=e.baseUrl)!=null?t:h,this.logger=typeof e.logger=="string"?u.pino(u.getDefaultLoggerOptions({level:e.logger})):(r=e.logger)!=null?r:u.pino(u.getDefaultLoggerOptions({level:"error"})),this.logger.trace(`${i} initialized`);const R={baseUrl:this.baseUrl,projectId:this.projectId,apiKey:this.apiKey,sdkName:P,sdkVersion:f,sdkPlatform:M(),bundleId:(s=l.getAppId())!=null?s:""};this.provider=E(R),this.logger.debug(`${i} provider initialized`)}static isAvailable(){return A()}async getPaymentOptions(e){this.logger.debug({paymentLink:e.paymentLink,accounts:e.accounts,includePaymentInfo:e.includePaymentInfo},`${i} getPaymentOptions`);try{const t=await this.provider.getPaymentOptions(e);return this.logger.debug({paymentId:t.paymentId,optionsCount:t.options.length},`${i} getPaymentOptions response`),t}catch(t){throw this.logger.error({error:t},`${i} getPaymentOptions error`),t instanceof o?t:new y(String(t))}}async getRequiredPaymentActions(e){this.logger.debug({paymentId:e.paymentId,optionId:e.optionId},`${i} getRequiredPaymentActions`);try{const t=await this.provider.getRequiredPaymentActions(e);return this.logger.debug({actionsCount:t.length},`${i} getRequiredPaymentActions response`),t}catch(t){throw this.logger.error({error:t},`${i} getRequiredPaymentActions error`),t instanceof o?t:new m(String(t))}}async confirmPayment(e){this.logger.debug({paymentId:e.paymentId,optionId:e.optionId,signaturesCount:e.signatures.length,hasCollectedData:!!e.collectedData},`${i} confirmPayment`);try{const t=await this.provider.confirmPayment(e);return this.logger.debug({status:t.status,isFinal:t.isFinal},`${i} confirmPayment response`),t}catch(t){throw this.logger.error({error:t},`${i} confirmPayment error`),t instanceof o?t:new g(String(t))}}}const F=S;exports.CLIENT_CONTEXT=T,exports.ConfirmPaymentError=g,exports.LOGGER_CONTEXT=i,exports.NativeModuleNotFoundError=p,exports.NativeProvider=w,exports.PAY_API_BASE_URL=h,exports.PayError=o,exports.PaymentActionsError=m,exports.PaymentOptionsError=y,exports.SDK_NAME=P,exports.SDK_VERSION=f,exports.WalletConnectPay=F,exports.createNativeProvider=b,exports.createProvider=E,exports.default=S,exports.detectProviderType=v,exports.isNativeProviderAvailable=I,exports.isProviderAvailable=A,exports.resetNativeModule=U,exports.setNativeModule=k;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var u=require("@walletconnect/logger"),l=require("@walletconnect/utils");const h="https://api.pay.walletconnect.com",P="js-walletconnect-pay",f="1.0.1",T="pay",i="WalletConnectPay";function M(){return l.isIos()?"rn-ios":l.isAndroid()?"rn-android":l.isBrowser()?"browser":l.isNode()?"node":"unknown"}var C=Object.defineProperty,$=(n,e,t)=>e in n?C(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,N=(n,e,t)=>$(n,typeof e!="symbol"?e+"":e,t);class o extends Error{constructor(e,t,r){super(t),N(this,"code"),N(this,"originalMessage"),this.name="PayError",this.code=e,this.originalMessage=r??t,Object.setPrototypeOf(this,o.prototype)}static fromNativeError(e){if(e instanceof o)return e;const t=e instanceof Error?e.message:String(e);return t.includes("JSON parse error")?new o("JSON_PARSE",t):t.includes("JSON serialize error")?new o("JSON_SERIALIZE",t):t.includes("Payment options error")?new o("PAYMENT_OPTIONS",t):t.includes("Payment request error")?new o("PAYMENT_REQUEST",t):t.includes("Confirm payment error")?new o("CONFIRM_PAYMENT",t):new o("UNKNOWN",t)}}class p extends o{constructor(){super("NATIVE_MODULE_NOT_FOUND","WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked."),this.name="NativeModuleNotFoundError",Object.setPrototypeOf(this,p.prototype)}}class y extends o{constructor(e){super("PAYMENT_OPTIONS",`Failed to get payment options: ${e}`,e),this.name="PaymentOptionsError",Object.setPrototypeOf(this,y.prototype)}}class m extends o{constructor(e){super("PAYMENT_REQUEST",`Failed to get payment actions: ${e}`,e),this.name="PaymentActionsError",Object.setPrototypeOf(this,m.prototype)}}class g extends o{constructor(e){super("CONFIRM_PAYMENT",`Failed to confirm payment: ${e}`,e),this.name="ConfirmPaymentError",Object.setPrototypeOf(this,g.prototype)}}var _=Object.defineProperty,j=(n,e,t)=>e in n?_(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,L=(n,e,t)=>j(n,typeof e!="symbol"?e+"":e,t);let a,d=null;function O(){var n,e;if(d)return d;if(a!==void 0)return a;try{const t=globalThis.ReactNative;if((n=t?.NativeModules)!=null&&n.RNWalletConnectPay)return a=t.NativeModules.RNWalletConnectPay,a;const r=(e=globalThis.expo)==null?void 0:e.modules;return r!=null&&r.RNWalletConnectPay?(a=r.RNWalletConnectPay,a):(a=null,null)}catch{return a=null,null}}function k(n){d=n,a=n}function I(){return O()!==null}function U(){d=null,a=void 0}class w{constructor(e){L(this,"module");const t=O();if(!t)throw new p;if(t.initialize)try{const r=JSON.stringify(e);t.initialize(r)}catch(r){throw new o("INITIALIZATION_ERROR",`Failed to initialize native Pay module: ${r instanceof Error?r.message:String(r)}`)}this.module=t}async getPaymentOptions(e){var t;const r={paymentLink:e.paymentLink,accounts:e.accounts,includePaymentInfo:(t=e.includePaymentInfo)!=null?t:!1};try{const s=await this.module.getPaymentOptions(JSON.stringify(r));return JSON.parse(s)}catch(s){throw o.fromNativeError(s)}}async getRequiredPaymentActions(e){const t={paymentId:e.paymentId,optionId:e.optionId};try{const r=await this.module.getRequiredPaymentActions(JSON.stringify(t));return JSON.parse(r)}catch(r){throw o.fromNativeError(r)}}async confirmPayment(e){const t={paymentId:e.paymentId,optionId:e.optionId,signatures:e.signatures,collectedData:e.collectedData};try{const r=await this.module.confirmPayment(JSON.stringify(t));return JSON.parse(r)}catch(r){throw o.fromNativeError(r)}}}function b(n){return new w(n)}function v(){return I()?"native":null}function E(n){const e=v();if(!e)throw new Error("No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.");switch(e){case"native":return b(n);case"wasm":throw new Error("WASM provider not yet implemented");default:throw new Error(`Unknown provider type: ${e}`)}}function A(){return v()!==null}var D=Object.defineProperty,W=(n,e,t)=>e in n?D(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,c=(n,e,t)=>W(n,typeof e!="symbol"?e+"":e,t);class S{constructor(e){c(this,"projectId"),c(this,"apiKey"),c(this,"baseUrl"),c(this,"logger"),c(this,"provider");var t,r,s;this.projectId=e.projectId,this.apiKey=e.apiKey,this.baseUrl=(t=e.baseUrl)!=null?t:h,this.logger=typeof e.logger=="string"?u.pino(u.getDefaultLoggerOptions({level:e.logger})):(r=e.logger)!=null?r:u.pino(u.getDefaultLoggerOptions({level:"error"})),this.logger.trace(`${i} initialized`);const R={baseUrl:this.baseUrl,projectId:this.projectId,apiKey:this.apiKey,sdkName:P,sdkVersion:f,sdkPlatform:M(),bundleId:(s=l.getAppId())!=null?s:""};this.provider=E(R),this.logger.debug(`${i} provider initialized`)}static isAvailable(){return A()}async getPaymentOptions(e){this.logger.debug({paymentLink:e.paymentLink,accounts:e.accounts,includePaymentInfo:e.includePaymentInfo},`${i} getPaymentOptions`);try{const t=await this.provider.getPaymentOptions(e);return this.logger.debug({paymentId:t.paymentId,optionsCount:t.options.length},`${i} getPaymentOptions response`),t}catch(t){throw this.logger.error({error:t},`${i} getPaymentOptions error`),t instanceof o?t:new y(String(t))}}async getRequiredPaymentActions(e){this.logger.debug({paymentId:e.paymentId,optionId:e.optionId},`${i} getRequiredPaymentActions`);try{const t=await this.provider.getRequiredPaymentActions(e);return this.logger.debug({actionsCount:t.length},`${i} getRequiredPaymentActions response`),t}catch(t){throw this.logger.error({error:t},`${i} getRequiredPaymentActions error`),t instanceof o?t:new m(String(t))}}async confirmPayment(e){this.logger.debug({paymentId:e.paymentId,optionId:e.optionId,signaturesCount:e.signatures.length,hasCollectedData:!!e.collectedData},`${i} confirmPayment`);try{const t=await this.provider.confirmPayment(e);return this.logger.debug({status:t.status,isFinal:t.isFinal},`${i} confirmPayment response`),t}catch(t){throw this.logger.error({error:t},`${i} confirmPayment error`),t instanceof o?t:new g(String(t))}}}const F=S;exports.CLIENT_CONTEXT=T,exports.ConfirmPaymentError=g,exports.LOGGER_CONTEXT=i,exports.NativeModuleNotFoundError=p,exports.NativeProvider=w,exports.PAY_API_BASE_URL=h,exports.PayError=o,exports.PaymentActionsError=m,exports.PaymentOptionsError=y,exports.SDK_NAME=P,exports.SDK_VERSION=f,exports.WalletConnectPay=F,exports.createNativeProvider=b,exports.createProvider=E,exports.default=S,exports.detectProviderType=v,exports.isNativeProviderAvailable=I,exports.isProviderAvailable=A,exports.resetNativeModule=U,exports.setNativeModule=k;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/constants/client.ts","../src/utils/platform.ts","../src/types/errors.ts","../src/providers/native.ts","../src/providers/index.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["/**\n * Client constants for WalletConnect Pay SDK\n */\n\n/** Default Pay API base URL */\nexport const PAY_API_BASE_URL = \"https://api.pay.walletconnect.com\";\n\n/** SDK name for tracking */\nexport const SDK_NAME = \"js-walletconnect-pay\";\n\n/** SDK version (from package.json) */\nexport const SDK_VERSION = `1.0.0`;\n\n/** Client context name */\nexport const CLIENT_CONTEXT = \"pay\";\n\n/** Logger context */\nexport const LOGGER_CONTEXT = \"WalletConnectPay\";\n","/**\n * Platform detection utilities for WalletConnect Pay SDK\n */\n\nimport { isIos, isAndroid, isBrowser, isNode } from \"@walletconnect/utils\";\n\n/**\n * Get the SDK platform based on the current environment\n * @returns Platform string: rn-ios, rn-android, browser, node, or unknown\n */\nexport function getSdkPlatform(): string {\n if (isIos()) return \"rn-ios\";\n if (isAndroid()) return \"rn-android\";\n if (isBrowser()) return \"browser\";\n if (isNode()) return \"node\";\n return \"unknown\";\n}\n","/**\n * Error types for WalletConnect Pay SDK\n */\n\n/**\n * Error codes from the native module\n */\nexport type PayErrorCode =\n | \"JSON_PARSE\"\n | \"JSON_SERIALIZE\"\n | \"PAYMENT_OPTIONS\"\n | \"PAYMENT_REQUEST\"\n | \"CONFIRM_PAYMENT\"\n | \"NATIVE_MODULE_NOT_FOUND\"\n | \"INITIALIZATION_ERROR\"\n | \"UNKNOWN\";\n\n/**\n * Base error class for Pay SDK\n */\nexport class PayError extends Error {\n public readonly code: PayErrorCode;\n public readonly originalMessage: string;\n\n constructor(code: PayErrorCode, message: string, originalMessage?: string) {\n super(message);\n this.name = \"PayError\";\n this.code = code;\n this.originalMessage = originalMessage ?? message;\n Object.setPrototypeOf(this, PayError.prototype);\n }\n\n static fromNativeError(error: unknown): PayError {\n if (error instanceof PayError) {\n return error;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n\n // Try to parse error code from message\n if (message.includes(\"JSON parse error\")) {\n return new PayError(\"JSON_PARSE\", message);\n }\n if (message.includes(\"JSON serialize error\")) {\n return new PayError(\"JSON_SERIALIZE\", message);\n }\n if (message.includes(\"Payment options error\")) {\n return new PayError(\"PAYMENT_OPTIONS\", message);\n }\n if (message.includes(\"Payment request error\")) {\n return new PayError(\"PAYMENT_REQUEST\", message);\n }\n if (message.includes(\"Confirm payment error\")) {\n return new PayError(\"CONFIRM_PAYMENT\", message);\n }\n\n return new PayError(\"UNKNOWN\", message);\n }\n}\n\n/**\n * Error thrown when native module is not available\n */\nexport class NativeModuleNotFoundError extends PayError {\n constructor() {\n super(\n \"NATIVE_MODULE_NOT_FOUND\",\n \"WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked.\",\n );\n this.name = \"NativeModuleNotFoundError\";\n Object.setPrototypeOf(this, NativeModuleNotFoundError.prototype);\n }\n}\n\n/**\n * Error thrown when payment options request fails\n */\nexport class PaymentOptionsError extends PayError {\n constructor(message: string) {\n super(\"PAYMENT_OPTIONS\", `Failed to get payment options: ${message}`, message);\n this.name = \"PaymentOptionsError\";\n Object.setPrototypeOf(this, PaymentOptionsError.prototype);\n }\n}\n\n/**\n * Error thrown when payment actions request fails\n */\nexport class PaymentActionsError extends PayError {\n constructor(message: string) {\n super(\"PAYMENT_REQUEST\", `Failed to get payment actions: ${message}`, message);\n this.name = \"PaymentActionsError\";\n Object.setPrototypeOf(this, PaymentActionsError.prototype);\n }\n}\n\n/**\n * Error thrown when payment confirmation fails\n */\nexport class ConfirmPaymentError extends PayError {\n constructor(message: string) {\n super(\"CONFIRM_PAYMENT\", `Failed to confirm payment: ${message}`, message);\n this.name = \"ConfirmPaymentError\";\n Object.setPrototypeOf(this, ConfirmPaymentError.prototype);\n }\n}\n","/**\n * Native Provider for WalletConnect Pay SDK\n *\n * Uses the React Native uniffi module for payment operations.\n */\n\nimport type {\n PaymentOptionsResponse,\n ConfirmPaymentResponse,\n Action,\n PayProvider,\n PayProviderConfig,\n GetPaymentOptionsParams,\n GetRequiredPaymentActionsParams,\n ConfirmPaymentParams,\n} from \"../types/index.js\";\nimport { NativeModuleNotFoundError, PayError } from \"../types/index.js\";\n\n/**\n * Native module interface expected from React Native\n */\ninterface NativePayModule {\n getPaymentOptions(requestJson: string): Promise<string>;\n getRequiredPaymentActions(requestJson: string): Promise<string>;\n confirmPayment(requestJson: string): Promise<string>;\n initialize?(configJson: string): void;\n}\n\n// Cached native module reference\nlet cachedNativeModule: NativePayModule | null | undefined;\n\n// Manually injected module reference\nlet injectedModule: NativePayModule | null = null;\n\n/**\n * Try to get the native module from React Native\n */\nfunction getNativeModule(): NativePayModule | null {\n // Return injected module if available\n if (injectedModule) {\n return injectedModule;\n }\n\n // Return cached result if already attempted\n if (cachedNativeModule !== undefined) {\n return cachedNativeModule;\n }\n\n try {\n // Access React Native's NativeModules via globalThis\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const reactNative = (globalThis as any).ReactNative;\n if (reactNative?.NativeModules?.RNWalletConnectPay) {\n cachedNativeModule = reactNative.NativeModules.RNWalletConnectPay as NativePayModule;\n return cachedNativeModule;\n }\n\n // Fallback: Try accessing via expo modules pattern\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const expoModules = (globalThis as any).expo?.modules;\n if (expoModules?.RNWalletConnectPay) {\n cachedNativeModule = expoModules.RNWalletConnectPay as NativePayModule;\n return cachedNativeModule;\n }\n\n cachedNativeModule = null;\n return null;\n } catch {\n cachedNativeModule = null;\n return null;\n }\n}\n\n/**\n * Set a custom native module instance\n * Use this to manually inject the native module if auto-discovery doesn't work\n */\nexport function setNativeModule(module: NativePayModule): void {\n injectedModule = module;\n cachedNativeModule = module;\n}\n\n/**\n * Check if native provider is available\n */\nexport function isNativeProviderAvailable(): boolean {\n return getNativeModule() !== null;\n}\n\n/**\n * Reset the native module (for testing)\n */\nexport function resetNativeModule(): void {\n injectedModule = null;\n cachedNativeModule = undefined;\n}\n\n/**\n * Native provider implementation using React Native uniffi module\n */\nexport class NativeProvider implements PayProvider {\n private readonly module: NativePayModule;\n\n constructor(config: PayProviderConfig) {\n const module = getNativeModule();\n\n if (!module) {\n throw new NativeModuleNotFoundError();\n }\n\n // Initialize the module with config\n if (module.initialize) {\n try {\n const configJson = JSON.stringify(config);\n module.initialize(configJson);\n } catch (error) {\n throw new PayError(\n \"INITIALIZATION_ERROR\",\n `Failed to initialize native Pay module: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n this.module = module;\n }\n\n async getPaymentOptions(params: GetPaymentOptionsParams): Promise<PaymentOptionsResponse> {\n const request = {\n paymentLink: params.paymentLink,\n accounts: params.accounts,\n includePaymentInfo: params.includePaymentInfo ?? false,\n };\n\n try {\n const responseJson = await this.module.getPaymentOptions(JSON.stringify(request));\n return JSON.parse(responseJson) as PaymentOptionsResponse;\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n\n async getRequiredPaymentActions(params: GetRequiredPaymentActionsParams): Promise<Action[]> {\n const request = {\n paymentId: params.paymentId,\n optionId: params.optionId,\n };\n\n try {\n const responseJson = await this.module.getRequiredPaymentActions(JSON.stringify(request));\n return JSON.parse(responseJson) as Action[];\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n\n async confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse> {\n const request = {\n paymentId: params.paymentId,\n optionId: params.optionId,\n signatures: params.signatures,\n collectedData: params.collectedData,\n };\n\n try {\n const responseJson = await this.module.confirmPayment(JSON.stringify(request));\n return JSON.parse(responseJson) as ConfirmPaymentResponse;\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n}\n\n/**\n * Create a native provider instance\n */\nexport function createNativeProvider(config: PayProviderConfig): PayProvider {\n return new NativeProvider(config);\n}\n","/**\n * Provider exports for WalletConnect Pay SDK\n */\n\nimport type { PayProvider, PayProviderConfig, PayProviderType } from \"../types/index.js\";\nimport { createNativeProvider, isNativeProviderAvailable } from \"./native.js\";\n\nexport * from \"./native.js\";\n\n/**\n * Detect the best available provider type for the current environment\n */\nexport function detectProviderType(): PayProviderType | null {\n // Check for native module (React Native)\n if (isNativeProviderAvailable()) {\n return \"native\";\n }\n\n // Future: Check for WASM support\n // if (isWasmProviderAvailable()) {\n // return \"wasm\";\n // }\n\n return null;\n}\n\n/**\n * Create a provider based on auto-detection\n * @param config - Provider configuration\n */\nexport function createProvider(config: PayProviderConfig): PayProvider {\n const providerType = detectProviderType();\n\n if (!providerType) {\n throw new Error(\n \"No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.\",\n );\n }\n\n switch (providerType) {\n case \"native\":\n return createNativeProvider(config);\n case \"wasm\":\n // Future: return createWasmProvider(config);\n throw new Error(\"WASM provider not yet implemented\");\n default:\n throw new Error(`Unknown provider type: ${providerType}`);\n }\n}\n\n/**\n * Check if any provider is available\n */\nexport function isProviderAvailable(): boolean {\n return detectProviderType() !== null;\n}\n","/**\n * WalletConnect Pay Client\n *\n * TypeScript wrapper around the Pay provider for payment processing.\n */\n\nimport { getDefaultLoggerOptions, pino } from \"@walletconnect/logger\";\nimport type { Logger } from \"@walletconnect/logger\";\nimport { getAppId } from \"@walletconnect/utils\";\n\nimport { PAY_API_BASE_URL, SDK_NAME, SDK_VERSION, LOGGER_CONTEXT } from \"./constants/index.js\";\nimport { getSdkPlatform } from \"./utils/index.js\";\nimport type {\n WalletConnectPayOptions,\n PaymentOptionsResponse,\n ConfirmPaymentResponse,\n Action,\n PayProvider,\n PayProviderConfig,\n GetPaymentOptionsParams,\n GetRequiredPaymentActionsParams,\n ConfirmPaymentParams,\n} from \"./types/index.js\";\nimport {\n PayError,\n PaymentOptionsError,\n PaymentActionsError,\n ConfirmPaymentError,\n} from \"./types/index.js\";\nimport { createProvider, isProviderAvailable } from \"./providers/index.js\";\n\nexport class WalletConnectPay {\n public readonly projectId: string;\n public readonly apiKey: string;\n public readonly baseUrl: string;\n\n private readonly logger: Logger;\n private readonly provider: PayProvider;\n\n /**\n * Initialize a new Pay client\n * @param opts - Client options\n */\n constructor(opts: WalletConnectPayOptions) {\n this.projectId = opts.projectId;\n this.apiKey = opts.apiKey;\n this.baseUrl = opts.baseUrl ?? PAY_API_BASE_URL;\n\n // Initialize logger\n this.logger =\n typeof opts.logger === \"string\"\n ? pino(getDefaultLoggerOptions({ level: opts.logger }))\n : (opts.logger ?? pino(getDefaultLoggerOptions({ level: \"error\" })));\n\n this.logger.trace(`${LOGGER_CONTEXT} initialized`);\n\n // Build provider config\n const providerConfig: PayProviderConfig = {\n baseUrl: this.baseUrl,\n projectId: this.projectId,\n apiKey: this.apiKey,\n sdkName: SDK_NAME,\n sdkVersion: SDK_VERSION,\n sdkPlatform: getSdkPlatform(),\n bundleId: getAppId() ?? \"\",\n };\n\n // Create provider (auto-detects available provider)\n this.provider = createProvider(providerConfig);\n this.logger.debug(`${LOGGER_CONTEXT} provider initialized`);\n }\n\n /**\n * Check if the Pay SDK is available on this platform\n */\n static isAvailable(): boolean {\n return isProviderAvailable();\n }\n\n /**\n * Get payment options for a payment link\n *\n * @param params - Payment options parameters\n * @param params.paymentLink - Payment link or payment ID\n * @param params.accounts - List of CAIP-10 account addresses\n * @param params.includePaymentInfo - Whether to include payment info in response\n * @returns Payment options response\n * @throws PaymentOptionsError if the request fails\n */\n async getPaymentOptions(params: GetPaymentOptionsParams): Promise<PaymentOptionsResponse> {\n this.logger.debug(\n {\n paymentLink: params.paymentLink,\n accounts: params.accounts,\n includePaymentInfo: params.includePaymentInfo,\n },\n `${LOGGER_CONTEXT} getPaymentOptions`,\n );\n\n try {\n const response = await this.provider.getPaymentOptions(params);\n\n this.logger.debug(\n { paymentId: response.paymentId, optionsCount: response.options.length },\n `${LOGGER_CONTEXT} getPaymentOptions response`,\n );\n\n return response;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} getPaymentOptions error`);\n throw error instanceof PayError ? error : new PaymentOptionsError(String(error));\n }\n }\n\n /**\n * Get required payment actions for a selected option\n *\n * @param params - Required actions parameters\n * @param params.paymentId - Payment ID\n * @param params.optionId - Selected option ID\n * @returns Array of actions to be signed\n * @throws PaymentActionsError if the request fails\n */\n async getRequiredPaymentActions(params: GetRequiredPaymentActionsParams): Promise<Action[]> {\n this.logger.debug(\n { paymentId: params.paymentId, optionId: params.optionId },\n `${LOGGER_CONTEXT} getRequiredPaymentActions`,\n );\n\n try {\n const actions = await this.provider.getRequiredPaymentActions(params);\n\n this.logger.debug(\n { actionsCount: actions.length },\n `${LOGGER_CONTEXT} getRequiredPaymentActions response`,\n );\n\n return actions;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} getRequiredPaymentActions error`);\n throw error instanceof PayError ? error : new PaymentActionsError(String(error));\n }\n }\n\n /**\n * Confirm a payment with wallet signatures\n *\n * @param params - Confirm payment parameters\n * @param params.paymentId - Payment ID\n * @param params.optionId - Selected option ID\n * @param params.signatures - Array of signatures from wallet RPC calls\n * @param params.collectedData - Optional collected data fields\n * @returns Confirm payment response with final status\n * @throws ConfirmPaymentError if the request fails\n */\n async confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse> {\n this.logger.debug(\n {\n paymentId: params.paymentId,\n optionId: params.optionId,\n signaturesCount: params.signatures.length,\n hasCollectedData: !!params.collectedData,\n },\n `${LOGGER_CONTEXT} confirmPayment`,\n );\n\n try {\n const response = await this.provider.confirmPayment(params);\n\n this.logger.debug(\n { status: response.status, isFinal: response.isFinal },\n `${LOGGER_CONTEXT} confirmPayment response`,\n );\n\n return response;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} confirmPayment error`);\n throw error instanceof PayError ? error : new ConfirmPaymentError(String(error));\n }\n }\n}\n","import { WalletConnectPay as Client } from \"./client.js\";\n\nexport * from \"./constants/index.js\";\nexport * from \"./types/index.js\";\nexport * from \"./providers/index.js\";\n\nexport const WalletConnectPay = Client;\nexport default Client;\n"],"names":["isIos","isAndroid","isBrowser","isNode","code","message","originalMessage","__publicField","error","c","l","cachedNativeModule","injectedModule","getNativeModule","_a","_b","reactNative","expoModules","e","module","config","NativeModuleNotFoundError","configJson","PayError","params","request","responseJson","isNativeProviderAvailable","providerType","createNativeProvider","WalletConnectPay","opts","_c","PAY_API_BASE_URL","pino","getDefaultLoggerOptions","LOGGER_CONTEXT","providerConfig","SDK_NAME","SDK_VERSION","getSdkPlatform","getAppId","createProvider","isProviderAvailable","response","PaymentOptionsError","actions","PaymentActionsError","ConfirmPaymentError","Client"],"mappings":";;;;;;;AAKa,MAAA,gBAAA,CAAmB,oCAGnB,QAAW,CAAA,sBAAA,CAGX,YAAc,OAGd,CAAA,cAAA,CAAiB,MAGjB,cAAiB,CAAA;;ACPvB,SAAS,cAAyB,EAAA,CACvC,OAAIA,WAAM,EAAA,CAAU,QAChBC,CAAAA,eAAAA,EAAoB,CAAA,YAAA,CACpBC,eAAU,EAAA,CAAU,SACpBC,CAAAA,YAAAA,EAAiB,CAAA,MAAA,CACd,SACT;;4KCIa,MAAA,QAAA,SAAiB,KAAM,CAIlC,WAAA,CAAYC,EAAoBC,CAAiBC,CAAAA,CA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AAC,CACjF,CACF,CAaA,MAAM,eAAegB,CAA+D,CAAA,CAClF,KAAK,MAAO,CAAA,KAAA,CACV,CACE,SAAWA,CAAAA,CAAAA,CAAO,UAClB,QAAUA,CAAAA,CAAAA,CAAO,SACjB,eAAiBA,CAAAA,CAAAA,CAAO,WAAW,MACnC,CAAA,gBAAA,CAAkB,CAAC,CAACA,CAAAA,CAAO,aAC7B,CACA,CAAA,CAAA,EAAGY,cAAc,CACnB,eAAA,CAAA,CAAA,CAEA,GAAI,CACF,MAAMQ,EAAW,MAAM,IAAA,CAAK,SAAS,cAAepB,CAAAA,CAAM,EAE1D,OAAK,IAAA,CAAA,MAAA,CAAO,MACV,CAAE,MAAA,CAAQoB,EAAS,MAAQ,CAAA,OAAA,CAASA,EAAS,OAAQ,CAAA,CACrD,GAAGR,cAAc,CAAA,wBAAA,CACnB,EAEOQ,CACT,CAAA,MAASpC,EAAO,CACd,MAAA,IAAA,CAAK,OAAO,KAAM,CAAA,CAAE,MAAAA,CAAM,CAAA,CAAG,GAAG4B,cAAc,CAAA,qBAAA,CAAuB,EAC/D5B,CAAiBe,YAAAA,QAAAA,CAAWf,EAAQ,IAAIwC,mBAAAA,CAAoB,OAAOxC,CAAK,CAAC,CACjF,CACF,CACF;;AC9KO,MAAM,gBAAmByC,CAAAA;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/constants/client.ts","../src/utils/platform.ts","../src/types/errors.ts","../src/providers/native.ts","../src/providers/index.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["/**\n * Client constants for WalletConnect Pay SDK\n */\n\n/** Default Pay API base URL */\nexport const PAY_API_BASE_URL = \"https://api.pay.walletconnect.com\";\n\n/** SDK name for tracking */\nexport const SDK_NAME = \"js-walletconnect-pay\";\n\n/** SDK version (from package.json) */\nexport const SDK_VERSION = `1.0.1`;\n\n/** Client context name */\nexport const CLIENT_CONTEXT = \"pay\";\n\n/** Logger context */\nexport const LOGGER_CONTEXT = \"WalletConnectPay\";\n","/**\n * Platform detection utilities for WalletConnect Pay SDK\n */\n\nimport { isIos, isAndroid, isBrowser, isNode } from \"@walletconnect/utils\";\n\n/**\n * Get the SDK platform based on the current environment\n * @returns Platform string: rn-ios, rn-android, browser, node, or unknown\n */\nexport function getSdkPlatform(): string {\n if (isIos()) return \"rn-ios\";\n if (isAndroid()) return \"rn-android\";\n if (isBrowser()) return \"browser\";\n if (isNode()) return \"node\";\n return \"unknown\";\n}\n","/**\n * Error types for WalletConnect Pay SDK\n */\n\n/**\n * Error codes from the native module\n */\nexport type PayErrorCode =\n | \"JSON_PARSE\"\n | \"JSON_SERIALIZE\"\n | \"PAYMENT_OPTIONS\"\n | \"PAYMENT_REQUEST\"\n | \"CONFIRM_PAYMENT\"\n | \"NATIVE_MODULE_NOT_FOUND\"\n | \"INITIALIZATION_ERROR\"\n | \"UNKNOWN\";\n\n/**\n * Base error class for Pay SDK\n */\nexport class PayError extends Error {\n public readonly code: PayErrorCode;\n public readonly originalMessage: string;\n\n constructor(code: PayErrorCode, message: string, originalMessage?: string) {\n super(message);\n this.name = \"PayError\";\n this.code = code;\n this.originalMessage = originalMessage ?? message;\n Object.setPrototypeOf(this, PayError.prototype);\n }\n\n static fromNativeError(error: unknown): PayError {\n if (error instanceof PayError) {\n return error;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n\n // Try to parse error code from message\n if (message.includes(\"JSON parse error\")) {\n return new PayError(\"JSON_PARSE\", message);\n }\n if (message.includes(\"JSON serialize error\")) {\n return new PayError(\"JSON_SERIALIZE\", message);\n }\n if (message.includes(\"Payment options error\")) {\n return new PayError(\"PAYMENT_OPTIONS\", message);\n }\n if (message.includes(\"Payment request error\")) {\n return new PayError(\"PAYMENT_REQUEST\", message);\n }\n if (message.includes(\"Confirm payment error\")) {\n return new PayError(\"CONFIRM_PAYMENT\", message);\n }\n\n return new PayError(\"UNKNOWN\", message);\n }\n}\n\n/**\n * Error thrown when native module is not available\n */\nexport class NativeModuleNotFoundError extends PayError {\n constructor() {\n super(\n \"NATIVE_MODULE_NOT_FOUND\",\n \"WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked.\",\n );\n this.name = \"NativeModuleNotFoundError\";\n Object.setPrototypeOf(this, NativeModuleNotFoundError.prototype);\n }\n}\n\n/**\n * Error thrown when payment options request fails\n */\nexport class PaymentOptionsError extends PayError {\n constructor(message: string) {\n super(\"PAYMENT_OPTIONS\", `Failed to get payment options: ${message}`, message);\n this.name = \"PaymentOptionsError\";\n Object.setPrototypeOf(this, PaymentOptionsError.prototype);\n }\n}\n\n/**\n * Error thrown when payment actions request fails\n */\nexport class PaymentActionsError extends PayError {\n constructor(message: string) {\n super(\"PAYMENT_REQUEST\", `Failed to get payment actions: ${message}`, message);\n this.name = \"PaymentActionsError\";\n Object.setPrototypeOf(this, PaymentActionsError.prototype);\n }\n}\n\n/**\n * Error thrown when payment confirmation fails\n */\nexport class ConfirmPaymentError extends PayError {\n constructor(message: string) {\n super(\"CONFIRM_PAYMENT\", `Failed to confirm payment: ${message}`, message);\n this.name = \"ConfirmPaymentError\";\n Object.setPrototypeOf(this, ConfirmPaymentError.prototype);\n }\n}\n","/**\n * Native Provider for WalletConnect Pay SDK\n *\n * Uses the React Native uniffi module for payment operations.\n */\n\nimport type {\n PaymentOptionsResponse,\n ConfirmPaymentResponse,\n Action,\n PayProvider,\n PayProviderConfig,\n GetPaymentOptionsParams,\n GetRequiredPaymentActionsParams,\n ConfirmPaymentParams,\n} from \"../types/index.js\";\nimport { NativeModuleNotFoundError, PayError } from \"../types/index.js\";\n\n/**\n * Native module interface expected from React Native\n */\ninterface NativePayModule {\n getPaymentOptions(requestJson: string): Promise<string>;\n getRequiredPaymentActions(requestJson: string): Promise<string>;\n confirmPayment(requestJson: string): Promise<string>;\n initialize?(configJson: string): void;\n}\n\n// Cached native module reference\nlet cachedNativeModule: NativePayModule | null | undefined;\n\n// Manually injected module reference\nlet injectedModule: NativePayModule | null = null;\n\n/**\n * Try to get the native module from React Native\n */\nfunction getNativeModule(): NativePayModule | null {\n // Return injected module if available\n if (injectedModule) {\n return injectedModule;\n }\n\n // Return cached result if already attempted\n if (cachedNativeModule !== undefined) {\n return cachedNativeModule;\n }\n\n try {\n // Access React Native's NativeModules via globalThis\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const reactNative = (globalThis as any).ReactNative;\n if (reactNative?.NativeModules?.RNWalletConnectPay) {\n cachedNativeModule = reactNative.NativeModules.RNWalletConnectPay as NativePayModule;\n return cachedNativeModule;\n }\n\n // Fallback: Try accessing via expo modules pattern\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const expoModules = (globalThis as any).expo?.modules;\n if (expoModules?.RNWalletConnectPay) {\n cachedNativeModule = expoModules.RNWalletConnectPay as NativePayModule;\n return cachedNativeModule;\n }\n\n cachedNativeModule = null;\n return null;\n } catch {\n cachedNativeModule = null;\n return null;\n }\n}\n\n/**\n * Set a custom native module instance\n * Use this to manually inject the native module if auto-discovery doesn't work\n */\nexport function setNativeModule(module: NativePayModule): void {\n injectedModule = module;\n cachedNativeModule = module;\n}\n\n/**\n * Check if native provider is available\n */\nexport function isNativeProviderAvailable(): boolean {\n return getNativeModule() !== null;\n}\n\n/**\n * Reset the native module (for testing)\n */\nexport function resetNativeModule(): void {\n injectedModule = null;\n cachedNativeModule = undefined;\n}\n\n/**\n * Native provider implementation using React Native uniffi module\n */\nexport class NativeProvider implements PayProvider {\n private readonly module: NativePayModule;\n\n constructor(config: PayProviderConfig) {\n const module = getNativeModule();\n\n if (!module) {\n throw new NativeModuleNotFoundError();\n }\n\n // Initialize the module with config\n if (module.initialize) {\n try {\n const configJson = JSON.stringify(config);\n module.initialize(configJson);\n } catch (error) {\n throw new PayError(\n \"INITIALIZATION_ERROR\",\n `Failed to initialize native Pay module: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n this.module = module;\n }\n\n async getPaymentOptions(params: GetPaymentOptionsParams): Promise<PaymentOptionsResponse> {\n const request = {\n paymentLink: params.paymentLink,\n accounts: params.accounts,\n includePaymentInfo: params.includePaymentInfo ?? false,\n };\n\n try {\n const responseJson = await this.module.getPaymentOptions(JSON.stringify(request));\n return JSON.parse(responseJson) as PaymentOptionsResponse;\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n\n async getRequiredPaymentActions(params: GetRequiredPaymentActionsParams): Promise<Action[]> {\n const request = {\n paymentId: params.paymentId,\n optionId: params.optionId,\n };\n\n try {\n const responseJson = await this.module.getRequiredPaymentActions(JSON.stringify(request));\n return JSON.parse(responseJson) as Action[];\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n\n async confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse> {\n const request = {\n paymentId: params.paymentId,\n optionId: params.optionId,\n signatures: params.signatures,\n collectedData: params.collectedData,\n };\n\n try {\n const responseJson = await this.module.confirmPayment(JSON.stringify(request));\n return JSON.parse(responseJson) as ConfirmPaymentResponse;\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n}\n\n/**\n * Create a native provider instance\n */\nexport function createNativeProvider(config: PayProviderConfig): PayProvider {\n return new NativeProvider(config);\n}\n","/**\n * Provider exports for WalletConnect Pay SDK\n */\n\nimport type { PayProvider, PayProviderConfig, PayProviderType } from \"../types/index.js\";\nimport { createNativeProvider, isNativeProviderAvailable } from \"./native.js\";\n\nexport * from \"./native.js\";\n\n/**\n * Detect the best available provider type for the current environment\n */\nexport function detectProviderType(): PayProviderType | null {\n // Check for native module (React Native)\n if (isNativeProviderAvailable()) {\n return \"native\";\n }\n\n // Future: Check for WASM support\n // if (isWasmProviderAvailable()) {\n // return \"wasm\";\n // }\n\n return null;\n}\n\n/**\n * Create a provider based on auto-detection\n * @param config - Provider configuration\n */\nexport function createProvider(config: PayProviderConfig): PayProvider {\n const providerType = detectProviderType();\n\n if (!providerType) {\n throw new Error(\n \"No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.\",\n );\n }\n\n switch (providerType) {\n case \"native\":\n return createNativeProvider(config);\n case \"wasm\":\n // Future: return createWasmProvider(config);\n throw new Error(\"WASM provider not yet implemented\");\n default:\n throw new Error(`Unknown provider type: ${providerType}`);\n }\n}\n\n/**\n * Check if any provider is available\n */\nexport function isProviderAvailable(): boolean {\n return detectProviderType() !== null;\n}\n","/**\n * WalletConnect Pay Client\n *\n * TypeScript wrapper around the Pay provider for payment processing.\n */\n\nimport { getDefaultLoggerOptions, pino } from \"@walletconnect/logger\";\nimport type { Logger } from \"@walletconnect/logger\";\nimport { getAppId } from \"@walletconnect/utils\";\n\nimport { PAY_API_BASE_URL, SDK_NAME, SDK_VERSION, LOGGER_CONTEXT } from \"./constants/index.js\";\nimport { getSdkPlatform } from \"./utils/index.js\";\nimport type {\n WalletConnectPayOptions,\n PaymentOptionsResponse,\n ConfirmPaymentResponse,\n Action,\n PayProvider,\n PayProviderConfig,\n GetPaymentOptionsParams,\n GetRequiredPaymentActionsParams,\n ConfirmPaymentParams,\n} from \"./types/index.js\";\nimport {\n PayError,\n PaymentOptionsError,\n PaymentActionsError,\n ConfirmPaymentError,\n} from \"./types/index.js\";\nimport { createProvider, isProviderAvailable } from \"./providers/index.js\";\n\nexport class WalletConnectPay {\n public readonly projectId: string;\n public readonly apiKey: string;\n public readonly baseUrl: string;\n\n private readonly logger: Logger;\n private readonly provider: PayProvider;\n\n /**\n * Initialize a new Pay client\n * @param opts - Client options\n */\n constructor(opts: WalletConnectPayOptions) {\n this.projectId = opts.projectId;\n this.apiKey = opts.apiKey;\n this.baseUrl = opts.baseUrl ?? PAY_API_BASE_URL;\n\n // Initialize logger\n this.logger =\n typeof opts.logger === \"string\"\n ? pino(getDefaultLoggerOptions({ level: opts.logger }))\n : (opts.logger ?? pino(getDefaultLoggerOptions({ level: \"error\" })));\n\n this.logger.trace(`${LOGGER_CONTEXT} initialized`);\n\n // Build provider config\n const providerConfig: PayProviderConfig = {\n baseUrl: this.baseUrl,\n projectId: this.projectId,\n apiKey: this.apiKey,\n sdkName: SDK_NAME,\n sdkVersion: SDK_VERSION,\n sdkPlatform: getSdkPlatform(),\n bundleId: getAppId() ?? \"\",\n };\n\n // Create provider (auto-detects available provider)\n this.provider = createProvider(providerConfig);\n this.logger.debug(`${LOGGER_CONTEXT} provider initialized`);\n }\n\n /**\n * Check if the Pay SDK is available on this platform\n */\n static isAvailable(): boolean {\n return isProviderAvailable();\n }\n\n /**\n * Get payment options for a payment link\n *\n * @param params - Payment options parameters\n * @param params.paymentLink - Payment link or payment ID\n * @param params.accounts - List of CAIP-10 account addresses\n * @param params.includePaymentInfo - Whether to include payment info in response\n * @returns Payment options response\n * @throws PaymentOptionsError if the request fails\n */\n async getPaymentOptions(params: GetPaymentOptionsParams): Promise<PaymentOptionsResponse> {\n this.logger.debug(\n {\n paymentLink: params.paymentLink,\n accounts: params.accounts,\n includePaymentInfo: params.includePaymentInfo,\n },\n `${LOGGER_CONTEXT} getPaymentOptions`,\n );\n\n try {\n const response = await this.provider.getPaymentOptions(params);\n\n this.logger.debug(\n { paymentId: response.paymentId, optionsCount: response.options.length },\n `${LOGGER_CONTEXT} getPaymentOptions response`,\n );\n\n return response;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} getPaymentOptions error`);\n throw error instanceof PayError ? error : new PaymentOptionsError(String(error));\n }\n }\n\n /**\n * Get required payment actions for a selected option\n *\n * @param params - Required actions parameters\n * @param params.paymentId - Payment ID\n * @param params.optionId - Selected option ID\n * @returns Array of actions to be signed\n * @throws PaymentActionsError if the request fails\n */\n async getRequiredPaymentActions(params: GetRequiredPaymentActionsParams): Promise<Action[]> {\n this.logger.debug(\n { paymentId: params.paymentId, optionId: params.optionId },\n `${LOGGER_CONTEXT} getRequiredPaymentActions`,\n );\n\n try {\n const actions = await this.provider.getRequiredPaymentActions(params);\n\n this.logger.debug(\n { actionsCount: actions.length },\n `${LOGGER_CONTEXT} getRequiredPaymentActions response`,\n );\n\n return actions;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} getRequiredPaymentActions error`);\n throw error instanceof PayError ? error : new PaymentActionsError(String(error));\n }\n }\n\n /**\n * Confirm a payment with wallet signatures\n *\n * @param params - Confirm payment parameters\n * @param params.paymentId - Payment ID\n * @param params.optionId - Selected option ID\n * @param params.signatures - Array of signatures from wallet RPC calls\n * @param params.collectedData - Optional collected data fields\n * @returns Confirm payment response with final status\n * @throws ConfirmPaymentError if the request fails\n */\n async confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse> {\n this.logger.debug(\n {\n paymentId: params.paymentId,\n optionId: params.optionId,\n signaturesCount: params.signatures.length,\n hasCollectedData: !!params.collectedData,\n },\n `${LOGGER_CONTEXT} confirmPayment`,\n );\n\n try {\n const response = await this.provider.confirmPayment(params);\n\n this.logger.debug(\n { status: response.status, isFinal: response.isFinal },\n `${LOGGER_CONTEXT} confirmPayment response`,\n );\n\n return response;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} confirmPayment error`);\n throw error instanceof PayError ? error : new ConfirmPaymentError(String(error));\n }\n }\n}\n","import { WalletConnectPay as Client } from \"./client.js\";\n\nexport * from \"./constants/index.js\";\nexport * from \"./types/index.js\";\nexport * from \"./providers/index.js\";\n\nexport const WalletConnectPay = Client;\nexport default Client;\n"],"names":["isIos","isAndroid","isBrowser","isNode","code","message","originalMessage","__publicField","error","c","l","cachedNativeModule","injectedModule","getNativeModule","_a","_b","reactNative","expoModules","e","module","config","NativeModuleNotFoundError","configJson","PayError","params","request","responseJson","isNativeProviderAvailable","providerType","createNativeProvider","WalletConnectPay","opts","_c","PAY_API_BASE_URL","pino","getDefaultLoggerOptions","LOGGER_CONTEXT","providerConfig","SDK_NAME","SDK_VERSION","getSdkPlatform","getAppId","createProvider","isProviderAvailable","response","PaymentOptionsError","actions","PaymentActionsError","ConfirmPaymentError","Client"],"mappings":";;;;;;;AAKa,MAAA,gBAAA,CAAmB,oCAGnB,QAAW,CAAA,sBAAA,CAGX,YAAc,OAGd,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M,isBrowser as $,isNode as C,getAppId as j}from"@walletconnect/utils";const f="https://api.pay.walletconnect.com",P="js-walletconnect-pay",v="1.0.0",k="pay",i="WalletConnectPay";function U(){return T()?"rn-ios":M()?"rn-android":$()?"browser":C()?"node":"unknown"}var J=Object.defineProperty,L=(n,e,t)=>e in n?J(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,N=(n,e,t)=>L(n,typeof e!="symbol"?e+"":e,t);class o extends Error{constructor(e,t,r){super(t),N(this,"code"),N(this,"originalMessage"),this.name="PayError",this.code=e,this.originalMessage=r??t,Object.setPrototypeOf(this,o.prototype)}static fromNativeError(e){if(e instanceof o)return e;const t=e instanceof Error?e.message:String(e);return t.includes("JSON parse error")?new o("JSON_PARSE",t):t.includes("JSON serialize error")?new o("JSON_SERIALIZE",t):t.includes("Payment options error")?new o("PAYMENT_OPTIONS",t):t.includes("Payment request error")?new o("PAYMENT_REQUEST",t):t.includes("Confirm payment error")?new o("CONFIRM_PAYMENT",t):new o("UNKNOWN",t)}}class u extends o{constructor(){super("NATIVE_MODULE_NOT_FOUND","WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked."),this.name="NativeModuleNotFoundError",Object.setPrototypeOf(this,u.prototype)}}class d extends o{constructor(e){super("PAYMENT_OPTIONS",`Failed to get payment options: ${e}`,e),this.name="PaymentOptionsError",Object.setPrototypeOf(this,d.prototype)}}class p extends o{constructor(e){super("PAYMENT_REQUEST",`Failed to get payment actions: ${e}`,e),this.name="PaymentActionsError",Object.setPrototypeOf(this,p.prototype)}}class y extends o{constructor(e){super("CONFIRM_PAYMENT",`Failed to confirm payment: ${e}`,e),this.name="ConfirmPaymentError",Object.setPrototypeOf(this,y.prototype)}}var W=Object.defineProperty,F=(n,e,t)=>e in n?W(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e,t)=>F(n,typeof e!="symbol"?e+"":e,t);let a,c=null;function O(){var n,e;if(c)return c;if(a!==void 0)return a;try{const t=globalThis.ReactNative;if((n=t?.NativeModules)!=null&&n.RNWalletConnectPay)return a=t.NativeModules.RNWalletConnectPay,a;const r=(e=globalThis.expo)==null?void 0:e.modules;return r!=null&&r.RNWalletConnectPay?(a=r.RNWalletConnectPay,a):(a=null,null)}catch{return a=null,null}}function q(n){c=n,a=n}function w(){return O()!==null}function K(){c=null,a=void 0}class I{constructor(e){D(this,"module");const t=O();if(!t)throw new u;if(t.initialize)try{const r=JSON.stringify(e);t.initialize(r)}catch(r){throw new o("INITIALIZATION_ERROR",`Failed to initialize native Pay module: ${r instanceof Error?r.message:String(r)}`)}this.module=t}async getPaymentOptions(e){var t;const r={paymentLink:e.paymentLink,accounts:e.accounts,includePaymentInfo:(t=e.includePaymentInfo)!=null?t:!1};try{const s=await this.module.getPaymentOptions(JSON.stringify(r));return JSON.parse(s)}catch(s){throw o.fromNativeError(s)}}async getRequiredPaymentActions(e){const t={paymentId:e.paymentId,optionId:e.optionId};try{const r=await this.module.getRequiredPaymentActions(JSON.stringify(t));return JSON.parse(r)}catch(r){throw o.fromNativeError(r)}}async confirmPayment(e){const t={paymentId:e.paymentId,optionId:e.optionId,signatures:e.signatures,collectedData:e.collectedData};try{const r=await this.module.confirmPayment(JSON.stringify(t));return JSON.parse(r)}catch(r){throw o.fromNativeError(r)}}}function b(n){return new I(n)}function m(){return w()?"native":null}function E(n){const e=m();if(!e)throw new Error("No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.");switch(e){case"native":return b(n);case"wasm":throw new Error("WASM provider not yet implemented");default:throw new Error(`Unknown provider type: ${e}`)}}function A(){return m()!==null}var x=Object.defineProperty,Y=(n,e,t)=>e in n?x(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,l=(n,e,t)=>Y(n,typeof e!="symbol"?e+"":e,t);class S{constructor(e){l(this,"projectId"),l(this,"apiKey"),l(this,"baseUrl"),l(this,"logger"),l(this,"provider");var t,r,s;this.projectId=e.projectId,this.apiKey=e.apiKey,this.baseUrl=(t=e.baseUrl)!=null?t:f,this.logger=typeof e.logger=="string"?g(h({level:e.logger})):(r=e.logger)!=null?r:g(h({level:"error"})),this.logger.trace(`${i} initialized`);const R={baseUrl:this.baseUrl,projectId:this.projectId,apiKey:this.apiKey,sdkName:P,sdkVersion:v,sdkPlatform:U(),bundleId:(s=j())!=null?s:""};this.provider=E(R),this.logger.debug(`${i} provider initialized`)}static isAvailable(){return A()}async getPaymentOptions(e){this.logger.debug({paymentLink:e.paymentLink,accounts:e.accounts,includePaymentInfo:e.includePaymentInfo},`${i} getPaymentOptions`);try{const t=await this.provider.getPaymentOptions(e);return this.logger.debug({paymentId:t.paymentId,optionsCount:t.options.length},`${i} getPaymentOptions response`),t}catch(t){throw this.logger.error({error:t},`${i} getPaymentOptions error`),t instanceof o?t:new d(String(t))}}async getRequiredPaymentActions(e){this.logger.debug({paymentId:e.paymentId,optionId:e.optionId},`${i} getRequiredPaymentActions`);try{const t=await this.provider.getRequiredPaymentActions(e);return this.logger.debug({actionsCount:t.length},`${i} getRequiredPaymentActions response`),t}catch(t){throw this.logger.error({error:t},`${i} getRequiredPaymentActions error`),t instanceof o?t:new p(String(t))}}async confirmPayment(e){this.logger.debug({paymentId:e.paymentId,optionId:e.optionId,signaturesCount:e.signatures.length,hasCollectedData:!!e.collectedData},`${i} confirmPayment`);try{const t=await this.provider.confirmPayment(e);return this.logger.debug({status:t.status,isFinal:t.isFinal},`${i} confirmPayment response`),t}catch(t){throw this.logger.error({error:t},`${i} confirmPayment error`),t instanceof o?t:new y(String(t))}}}const _=S;export{k as CLIENT_CONTEXT,y as ConfirmPaymentError,i as LOGGER_CONTEXT,u as NativeModuleNotFoundError,I as NativeProvider,f as PAY_API_BASE_URL,o as PayError,p as PaymentActionsError,d as PaymentOptionsError,P as SDK_NAME,v as SDK_VERSION,_ as WalletConnectPay,b as createNativeProvider,E as createProvider,S as default,m as detectProviderType,w as isNativeProviderAvailable,A as isProviderAvailable,K as resetNativeModule,q as setNativeModule};
1
+ import{pino as g,getDefaultLoggerOptions as h}from"@walletconnect/logger";import{isIos as T,isAndroid as M,isBrowser as $,isNode as C,getAppId as j}from"@walletconnect/utils";const f="https://api.pay.walletconnect.com",P="js-walletconnect-pay",v="1.0.1",k="pay",i="WalletConnectPay";function U(){return T()?"rn-ios":M()?"rn-android":$()?"browser":C()?"node":"unknown"}var J=Object.defineProperty,L=(n,e,t)=>e in n?J(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,N=(n,e,t)=>L(n,typeof e!="symbol"?e+"":e,t);class o extends Error{constructor(e,t,r){super(t),N(this,"code"),N(this,"originalMessage"),this.name="PayError",this.code=e,this.originalMessage=r??t,Object.setPrototypeOf(this,o.prototype)}static fromNativeError(e){if(e instanceof o)return e;const t=e instanceof Error?e.message:String(e);return t.includes("JSON parse error")?new o("JSON_PARSE",t):t.includes("JSON serialize error")?new o("JSON_SERIALIZE",t):t.includes("Payment options error")?new o("PAYMENT_OPTIONS",t):t.includes("Payment request error")?new o("PAYMENT_REQUEST",t):t.includes("Confirm payment error")?new o("CONFIRM_PAYMENT",t):new o("UNKNOWN",t)}}class u extends o{constructor(){super("NATIVE_MODULE_NOT_FOUND","WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked."),this.name="NativeModuleNotFoundError",Object.setPrototypeOf(this,u.prototype)}}class d extends o{constructor(e){super("PAYMENT_OPTIONS",`Failed to get payment options: ${e}`,e),this.name="PaymentOptionsError",Object.setPrototypeOf(this,d.prototype)}}class p extends o{constructor(e){super("PAYMENT_REQUEST",`Failed to get payment actions: ${e}`,e),this.name="PaymentActionsError",Object.setPrototypeOf(this,p.prototype)}}class y extends o{constructor(e){super("CONFIRM_PAYMENT",`Failed to confirm payment: ${e}`,e),this.name="ConfirmPaymentError",Object.setPrototypeOf(this,y.prototype)}}var W=Object.defineProperty,F=(n,e,t)=>e in n?W(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e,t)=>F(n,typeof e!="symbol"?e+"":e,t);let a,c=null;function O(){var n,e;if(c)return c;if(a!==void 0)return a;try{const t=globalThis.ReactNative;if((n=t?.NativeModules)!=null&&n.RNWalletConnectPay)return a=t.NativeModules.RNWalletConnectPay,a;const r=(e=globalThis.expo)==null?void 0:e.modules;return r!=null&&r.RNWalletConnectPay?(a=r.RNWalletConnectPay,a):(a=null,null)}catch{return a=null,null}}function q(n){c=n,a=n}function w(){return O()!==null}function K(){c=null,a=void 0}class I{constructor(e){D(this,"module");const t=O();if(!t)throw new u;if(t.initialize)try{const r=JSON.stringify(e);t.initialize(r)}catch(r){throw new o("INITIALIZATION_ERROR",`Failed to initialize native Pay module: ${r instanceof Error?r.message:String(r)}`)}this.module=t}async getPaymentOptions(e){var t;const r={paymentLink:e.paymentLink,accounts:e.accounts,includePaymentInfo:(t=e.includePaymentInfo)!=null?t:!1};try{const s=await this.module.getPaymentOptions(JSON.stringify(r));return JSON.parse(s)}catch(s){throw o.fromNativeError(s)}}async getRequiredPaymentActions(e){const t={paymentId:e.paymentId,optionId:e.optionId};try{const r=await this.module.getRequiredPaymentActions(JSON.stringify(t));return JSON.parse(r)}catch(r){throw o.fromNativeError(r)}}async confirmPayment(e){const t={paymentId:e.paymentId,optionId:e.optionId,signatures:e.signatures,collectedData:e.collectedData};try{const r=await this.module.confirmPayment(JSON.stringify(t));return JSON.parse(r)}catch(r){throw o.fromNativeError(r)}}}function b(n){return new I(n)}function m(){return w()?"native":null}function E(n){const e=m();if(!e)throw new Error("No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.");switch(e){case"native":return b(n);case"wasm":throw new Error("WASM provider not yet implemented");default:throw new Error(`Unknown provider type: ${e}`)}}function A(){return m()!==null}var x=Object.defineProperty,Y=(n,e,t)=>e in n?x(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,l=(n,e,t)=>Y(n,typeof e!="symbol"?e+"":e,t);class S{constructor(e){l(this,"projectId"),l(this,"apiKey"),l(this,"baseUrl"),l(this,"logger"),l(this,"provider");var t,r,s;this.projectId=e.projectId,this.apiKey=e.apiKey,this.baseUrl=(t=e.baseUrl)!=null?t:f,this.logger=typeof e.logger=="string"?g(h({level:e.logger})):(r=e.logger)!=null?r:g(h({level:"error"})),this.logger.trace(`${i} initialized`);const R={baseUrl:this.baseUrl,projectId:this.projectId,apiKey:this.apiKey,sdkName:P,sdkVersion:v,sdkPlatform:U(),bundleId:(s=j())!=null?s:""};this.provider=E(R),this.logger.debug(`${i} provider initialized`)}static isAvailable(){return A()}async getPaymentOptions(e){this.logger.debug({paymentLink:e.paymentLink,accounts:e.accounts,includePaymentInfo:e.includePaymentInfo},`${i} getPaymentOptions`);try{const t=await this.provider.getPaymentOptions(e);return this.logger.debug({paymentId:t.paymentId,optionsCount:t.options.length},`${i} getPaymentOptions response`),t}catch(t){throw this.logger.error({error:t},`${i} getPaymentOptions error`),t instanceof o?t:new d(String(t))}}async getRequiredPaymentActions(e){this.logger.debug({paymentId:e.paymentId,optionId:e.optionId},`${i} getRequiredPaymentActions`);try{const t=await this.provider.getRequiredPaymentActions(e);return this.logger.debug({actionsCount:t.length},`${i} getRequiredPaymentActions response`),t}catch(t){throw this.logger.error({error:t},`${i} getRequiredPaymentActions error`),t instanceof o?t:new p(String(t))}}async confirmPayment(e){this.logger.debug({paymentId:e.paymentId,optionId:e.optionId,signaturesCount:e.signatures.length,hasCollectedData:!!e.collectedData},`${i} confirmPayment`);try{const t=await this.provider.confirmPayment(e);return this.logger.debug({status:t.status,isFinal:t.isFinal},`${i} confirmPayment response`),t}catch(t){throw this.logger.error({error:t},`${i} confirmPayment error`),t instanceof o?t:new y(String(t))}}}const _=S;export{k as CLIENT_CONTEXT,y as ConfirmPaymentError,i as LOGGER_CONTEXT,u as NativeModuleNotFoundError,I as NativeProvider,f as PAY_API_BASE_URL,o as PayError,p as PaymentActionsError,d as PaymentOptionsError,P as SDK_NAME,v as SDK_VERSION,_ as WalletConnectPay,b as createNativeProvider,E as createProvider,S as default,m as detectProviderType,w as isNativeProviderAvailable,A as isProviderAvailable,K as resetNativeModule,q as setNativeModule};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/constants/client.ts","../src/utils/platform.ts","../src/types/errors.ts","../src/providers/native.ts","../src/providers/index.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["/**\n * Client constants for WalletConnect Pay SDK\n */\n\n/** Default Pay API base URL */\nexport const PAY_API_BASE_URL = \"https://api.pay.walletconnect.com\";\n\n/** SDK name for tracking */\nexport const SDK_NAME = \"js-walletconnect-pay\";\n\n/** SDK version (from package.json) */\nexport const SDK_VERSION = `1.0.0`;\n\n/** Client context name */\nexport const CLIENT_CONTEXT = \"pay\";\n\n/** Logger context */\nexport const LOGGER_CONTEXT = \"WalletConnectPay\";\n","/**\n * Platform detection utilities for WalletConnect Pay SDK\n */\n\nimport { isIos, isAndroid, isBrowser, isNode } from \"@walletconnect/utils\";\n\n/**\n * Get the SDK platform based on the current environment\n * @returns Platform string: rn-ios, rn-android, browser, node, or unknown\n */\nexport function getSdkPlatform(): string {\n if (isIos()) return \"rn-ios\";\n if (isAndroid()) return \"rn-android\";\n if (isBrowser()) return \"browser\";\n if (isNode()) return \"node\";\n return \"unknown\";\n}\n","/**\n * Error types for WalletConnect Pay SDK\n */\n\n/**\n * Error codes from the native module\n */\nexport type PayErrorCode =\n | \"JSON_PARSE\"\n | \"JSON_SERIALIZE\"\n | \"PAYMENT_OPTIONS\"\n | \"PAYMENT_REQUEST\"\n | \"CONFIRM_PAYMENT\"\n | \"NATIVE_MODULE_NOT_FOUND\"\n | \"INITIALIZATION_ERROR\"\n | \"UNKNOWN\";\n\n/**\n * Base error class for Pay SDK\n */\nexport class PayError extends Error {\n public readonly code: PayErrorCode;\n public readonly originalMessage: string;\n\n constructor(code: PayErrorCode, message: string, originalMessage?: string) {\n super(message);\n this.name = \"PayError\";\n this.code = code;\n this.originalMessage = originalMessage ?? message;\n Object.setPrototypeOf(this, PayError.prototype);\n }\n\n static fromNativeError(error: unknown): PayError {\n if (error instanceof PayError) {\n return error;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n\n // Try to parse error code from message\n if (message.includes(\"JSON parse error\")) {\n return new PayError(\"JSON_PARSE\", message);\n }\n if (message.includes(\"JSON serialize error\")) {\n return new PayError(\"JSON_SERIALIZE\", message);\n }\n if (message.includes(\"Payment options error\")) {\n return new PayError(\"PAYMENT_OPTIONS\", message);\n }\n if (message.includes(\"Payment request error\")) {\n return new PayError(\"PAYMENT_REQUEST\", message);\n }\n if (message.includes(\"Confirm payment error\")) {\n return new PayError(\"CONFIRM_PAYMENT\", message);\n }\n\n return new PayError(\"UNKNOWN\", message);\n }\n}\n\n/**\n * Error thrown when native module is not available\n */\nexport class NativeModuleNotFoundError extends PayError {\n constructor() {\n super(\n \"NATIVE_MODULE_NOT_FOUND\",\n \"WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked.\",\n );\n this.name = \"NativeModuleNotFoundError\";\n Object.setPrototypeOf(this, NativeModuleNotFoundError.prototype);\n }\n}\n\n/**\n * Error thrown when payment options request fails\n */\nexport class PaymentOptionsError extends PayError {\n constructor(message: string) {\n super(\"PAYMENT_OPTIONS\", `Failed to get payment options: ${message}`, message);\n this.name = \"PaymentOptionsError\";\n Object.setPrototypeOf(this, PaymentOptionsError.prototype);\n }\n}\n\n/**\n * Error thrown when payment actions request fails\n */\nexport class PaymentActionsError extends PayError {\n constructor(message: string) {\n super(\"PAYMENT_REQUEST\", `Failed to get payment actions: ${message}`, message);\n this.name = \"PaymentActionsError\";\n Object.setPrototypeOf(this, PaymentActionsError.prototype);\n }\n}\n\n/**\n * Error thrown when payment confirmation fails\n */\nexport class ConfirmPaymentError extends PayError {\n constructor(message: string) {\n super(\"CONFIRM_PAYMENT\", `Failed to confirm payment: ${message}`, message);\n this.name = \"ConfirmPaymentError\";\n Object.setPrototypeOf(this, ConfirmPaymentError.prototype);\n }\n}\n","/**\n * Native Provider for WalletConnect Pay SDK\n *\n * Uses the React Native uniffi module for payment operations.\n */\n\nimport type {\n PaymentOptionsResponse,\n ConfirmPaymentResponse,\n Action,\n PayProvider,\n PayProviderConfig,\n GetPaymentOptionsParams,\n GetRequiredPaymentActionsParams,\n ConfirmPaymentParams,\n} from \"../types/index.js\";\nimport { NativeModuleNotFoundError, PayError } from \"../types/index.js\";\n\n/**\n * Native module interface expected from React Native\n */\ninterface NativePayModule {\n getPaymentOptions(requestJson: string): Promise<string>;\n getRequiredPaymentActions(requestJson: string): Promise<string>;\n confirmPayment(requestJson: string): Promise<string>;\n initialize?(configJson: string): void;\n}\n\n// Cached native module reference\nlet cachedNativeModule: NativePayModule | null | undefined;\n\n// Manually injected module reference\nlet injectedModule: NativePayModule | null = null;\n\n/**\n * Try to get the native module from React Native\n */\nfunction getNativeModule(): NativePayModule | null {\n // Return injected module if available\n if (injectedModule) {\n return injectedModule;\n }\n\n // Return cached result if already attempted\n if (cachedNativeModule !== undefined) {\n return cachedNativeModule;\n }\n\n try {\n // Access React Native's NativeModules via globalThis\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const reactNative = (globalThis as any).ReactNative;\n if (reactNative?.NativeModules?.RNWalletConnectPay) {\n cachedNativeModule = reactNative.NativeModules.RNWalletConnectPay as NativePayModule;\n return cachedNativeModule;\n }\n\n // Fallback: Try accessing via expo modules pattern\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const expoModules = (globalThis as any).expo?.modules;\n if (expoModules?.RNWalletConnectPay) {\n cachedNativeModule = expoModules.RNWalletConnectPay as NativePayModule;\n return cachedNativeModule;\n }\n\n cachedNativeModule = null;\n return null;\n } catch {\n cachedNativeModule = null;\n return null;\n }\n}\n\n/**\n * Set a custom native module instance\n * Use this to manually inject the native module if auto-discovery doesn't work\n */\nexport function setNativeModule(module: NativePayModule): void {\n injectedModule = module;\n cachedNativeModule = module;\n}\n\n/**\n * Check if native provider is available\n */\nexport function isNativeProviderAvailable(): boolean {\n return getNativeModule() !== null;\n}\n\n/**\n * Reset the native module (for testing)\n */\nexport function resetNativeModule(): void {\n injectedModule = null;\n cachedNativeModule = undefined;\n}\n\n/**\n * Native provider implementation using React Native uniffi module\n */\nexport class NativeProvider implements PayProvider {\n private readonly module: NativePayModule;\n\n constructor(config: PayProviderConfig) {\n const module = getNativeModule();\n\n if (!module) {\n throw new NativeModuleNotFoundError();\n }\n\n // Initialize the module with config\n if (module.initialize) {\n try {\n const configJson = JSON.stringify(config);\n module.initialize(configJson);\n } catch (error) {\n throw new PayError(\n \"INITIALIZATION_ERROR\",\n `Failed to initialize native Pay module: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n this.module = module;\n }\n\n async getPaymentOptions(params: GetPaymentOptionsParams): Promise<PaymentOptionsResponse> {\n const request = {\n paymentLink: params.paymentLink,\n accounts: params.accounts,\n includePaymentInfo: params.includePaymentInfo ?? false,\n };\n\n try {\n const responseJson = await this.module.getPaymentOptions(JSON.stringify(request));\n return JSON.parse(responseJson) as PaymentOptionsResponse;\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n\n async getRequiredPaymentActions(params: GetRequiredPaymentActionsParams): Promise<Action[]> {\n const request = {\n paymentId: params.paymentId,\n optionId: params.optionId,\n };\n\n try {\n const responseJson = await this.module.getRequiredPaymentActions(JSON.stringify(request));\n return JSON.parse(responseJson) as Action[];\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n\n async confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse> {\n const request = {\n paymentId: params.paymentId,\n optionId: params.optionId,\n signatures: params.signatures,\n collectedData: params.collectedData,\n };\n\n try {\n const responseJson = await this.module.confirmPayment(JSON.stringify(request));\n return JSON.parse(responseJson) as ConfirmPaymentResponse;\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n}\n\n/**\n * Create a native provider instance\n */\nexport function createNativeProvider(config: PayProviderConfig): PayProvider {\n return new NativeProvider(config);\n}\n","/**\n * Provider exports for WalletConnect Pay SDK\n */\n\nimport type { PayProvider, PayProviderConfig, PayProviderType } from \"../types/index.js\";\nimport { createNativeProvider, isNativeProviderAvailable } from \"./native.js\";\n\nexport * from \"./native.js\";\n\n/**\n * Detect the best available provider type for the current environment\n */\nexport function detectProviderType(): PayProviderType | null {\n // Check for native module (React Native)\n if (isNativeProviderAvailable()) {\n return \"native\";\n }\n\n // Future: Check for WASM support\n // if (isWasmProviderAvailable()) {\n // return \"wasm\";\n // }\n\n return null;\n}\n\n/**\n * Create a provider based on auto-detection\n * @param config - Provider configuration\n */\nexport function createProvider(config: PayProviderConfig): PayProvider {\n const providerType = detectProviderType();\n\n if (!providerType) {\n throw new Error(\n \"No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.\",\n );\n }\n\n switch (providerType) {\n case \"native\":\n return createNativeProvider(config);\n case \"wasm\":\n // Future: return createWasmProvider(config);\n throw new Error(\"WASM provider not yet implemented\");\n default:\n throw new Error(`Unknown provider type: ${providerType}`);\n }\n}\n\n/**\n * Check if any provider is available\n */\nexport function isProviderAvailable(): boolean {\n return detectProviderType() !== null;\n}\n","/**\n * WalletConnect Pay Client\n *\n * TypeScript wrapper around the Pay provider for payment processing.\n */\n\nimport { getDefaultLoggerOptions, pino } from \"@walletconnect/logger\";\nimport type { Logger } from \"@walletconnect/logger\";\nimport { getAppId } from \"@walletconnect/utils\";\n\nimport { PAY_API_BASE_URL, SDK_NAME, SDK_VERSION, LOGGER_CONTEXT } from \"./constants/index.js\";\nimport { getSdkPlatform } from \"./utils/index.js\";\nimport type {\n WalletConnectPayOptions,\n PaymentOptionsResponse,\n ConfirmPaymentResponse,\n Action,\n PayProvider,\n PayProviderConfig,\n GetPaymentOptionsParams,\n GetRequiredPaymentActionsParams,\n ConfirmPaymentParams,\n} from \"./types/index.js\";\nimport {\n PayError,\n PaymentOptionsError,\n PaymentActionsError,\n ConfirmPaymentError,\n} from \"./types/index.js\";\nimport { createProvider, isProviderAvailable } from \"./providers/index.js\";\n\nexport class WalletConnectPay {\n public readonly projectId: string;\n public readonly apiKey: string;\n public readonly baseUrl: string;\n\n private readonly logger: Logger;\n private readonly provider: PayProvider;\n\n /**\n * Initialize a new Pay client\n * @param opts - Client options\n */\n constructor(opts: WalletConnectPayOptions) {\n this.projectId = opts.projectId;\n this.apiKey = opts.apiKey;\n this.baseUrl = opts.baseUrl ?? PAY_API_BASE_URL;\n\n // Initialize logger\n this.logger =\n typeof opts.logger === \"string\"\n ? pino(getDefaultLoggerOptions({ level: opts.logger }))\n : (opts.logger ?? pino(getDefaultLoggerOptions({ level: \"error\" })));\n\n this.logger.trace(`${LOGGER_CONTEXT} initialized`);\n\n // Build provider config\n const providerConfig: PayProviderConfig = {\n baseUrl: this.baseUrl,\n projectId: this.projectId,\n apiKey: this.apiKey,\n sdkName: SDK_NAME,\n sdkVersion: SDK_VERSION,\n sdkPlatform: getSdkPlatform(),\n bundleId: getAppId() ?? \"\",\n };\n\n // Create provider (auto-detects available provider)\n this.provider = createProvider(providerConfig);\n this.logger.debug(`${LOGGER_CONTEXT} provider initialized`);\n }\n\n /**\n * Check if the Pay SDK is available on this platform\n */\n static isAvailable(): boolean {\n return isProviderAvailable();\n }\n\n /**\n * Get payment options for a payment link\n *\n * @param params - Payment options parameters\n * @param params.paymentLink - Payment link or payment ID\n * @param params.accounts - List of CAIP-10 account addresses\n * @param params.includePaymentInfo - Whether to include payment info in response\n * @returns Payment options response\n * @throws PaymentOptionsError if the request fails\n */\n async getPaymentOptions(params: GetPaymentOptionsParams): Promise<PaymentOptionsResponse> {\n this.logger.debug(\n {\n paymentLink: params.paymentLink,\n accounts: params.accounts,\n includePaymentInfo: params.includePaymentInfo,\n },\n `${LOGGER_CONTEXT} getPaymentOptions`,\n );\n\n try {\n const response = await this.provider.getPaymentOptions(params);\n\n this.logger.debug(\n { paymentId: response.paymentId, optionsCount: response.options.length },\n `${LOGGER_CONTEXT} getPaymentOptions response`,\n );\n\n return response;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} getPaymentOptions error`);\n throw error instanceof PayError ? error : new PaymentOptionsError(String(error));\n }\n }\n\n /**\n * Get required payment actions for a selected option\n *\n * @param params - Required actions parameters\n * @param params.paymentId - Payment ID\n * @param params.optionId - Selected option ID\n * @returns Array of actions to be signed\n * @throws PaymentActionsError if the request fails\n */\n async getRequiredPaymentActions(params: GetRequiredPaymentActionsParams): Promise<Action[]> {\n this.logger.debug(\n { paymentId: params.paymentId, optionId: params.optionId },\n `${LOGGER_CONTEXT} getRequiredPaymentActions`,\n );\n\n try {\n const actions = await this.provider.getRequiredPaymentActions(params);\n\n this.logger.debug(\n { actionsCount: actions.length },\n `${LOGGER_CONTEXT} getRequiredPaymentActions response`,\n );\n\n return actions;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} getRequiredPaymentActions error`);\n throw error instanceof PayError ? error : new PaymentActionsError(String(error));\n }\n }\n\n /**\n * Confirm a payment with wallet signatures\n *\n * @param params - Confirm payment parameters\n * @param params.paymentId - Payment ID\n * @param params.optionId - Selected option ID\n * @param params.signatures - Array of signatures from wallet RPC calls\n * @param params.collectedData - Optional collected data fields\n * @returns Confirm payment response with final status\n * @throws ConfirmPaymentError if the request fails\n */\n async confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse> {\n this.logger.debug(\n {\n paymentId: params.paymentId,\n optionId: params.optionId,\n signaturesCount: params.signatures.length,\n hasCollectedData: !!params.collectedData,\n },\n `${LOGGER_CONTEXT} confirmPayment`,\n );\n\n try {\n const response = await this.provider.confirmPayment(params);\n\n this.logger.debug(\n { status: response.status, isFinal: response.isFinal },\n `${LOGGER_CONTEXT} confirmPayment response`,\n );\n\n return response;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} confirmPayment error`);\n throw error instanceof PayError ? error : new ConfirmPaymentError(String(error));\n }\n }\n}\n","import { WalletConnectPay as Client } from \"./client.js\";\n\nexport * from \"./constants/index.js\";\nexport * from \"./types/index.js\";\nexport * from \"./providers/index.js\";\n\nexport const WalletConnectPay = Client;\nexport default Client;\n"],"names":["isIos","isAndroid","isBrowser","isNode","code","message","originalMessage","__publicField","error","c","l","cachedNativeModule","injectedModule","getNativeModule","_a","_b","reactNative","expoModules","e","module","config","NativeModuleNotFoundError","configJson","PayError","params","request","responseJson","isNativeProviderAvailable","providerType","createNativeProvider","WalletConnectPay","opts","_c","PAY_API_BASE_URL","pino","getDefaultLoggerOptions","LOGGER_CONTEXT","providerConfig","SDK_NAME","SDK_VERSION","getSdkPlatform","getAppId","createProvider","isProviderAvailable","response","PaymentOptionsError","actions","PaymentActionsError","ConfirmPaymentError","Client"],"mappings":";;;AAKa,MAAA,gBAAA,CAAmB,oCAGnB,QAAW,CAAA,sBAAA,CAGX,YAAc,OAGd,CAAA,cAAA,CAAiB,MAGjB,cAAiB,CAAA;;ACPvB,SAAS,cAAyB,EAAA,CACvC,OAAIA,KAAM,EAAA,CAAU,QAChBC,CAAAA,SAAAA,EAAoB,CAAA,YAAA,CACpBC,SAAU,EAAA,CAAU,SACpBC,CAAAA,MAAAA,EAAiB,CAAA,MAAA,CACd,SACT;;4KCIa,MAAA,QAAA,SAAiB,KAAM,CAIlC,WAAA,CAAYC,EAAoBC,CAAiBC,CAAAA,CAAAA,CAA0B,CACzE,KAAMD,CAAAA,CAAO,EAJfE,CAAA,CAAA,IAAA,CAAgB,QAChBA,CAAA,CAAA,IAAA,CAAgB,mBAId,IAAK,CAAA,IAAA,CAAO,UACZ,CAAA,IAAA,CAAK,IAAOH,CAAAA,CAAAA,CACZ,KAAK,eAAkBE,CAAAA,CAAAA,EAAA,KAAAA,CAAmBD,CAAAA,CAAAA,CAC1C,OAAO,cAAe,CAAA,IAAA,CAAM,QAAS,CAAA,SAAS,EAChD,CAEA,OAAO,eAAgBG,CAAAA,CAAAA,CAA0B,CAC/C,GAAIA,CAAAA,YAAiB,SACnB,OAAOA,CAAAA,CAGT,MAAM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,MACV,CAAE,MAAA,CAAQoB,EAAS,MAAQ,CAAA,OAAA,CAASA,EAAS,OAAQ,CAAA,CACrD,GAAGR,cAAc,CAAA,wBAAA,CACnB,EAEOQ,CACT,CAAA,MAASpC,EAAO,CACd,MAAA,IAAA,CAAK,OAAO,KAAM,CAAA,CAAE,MAAAA,CAAM,CAAA,CAAG,GAAG4B,cAAc,CAAA,qBAAA,CAAuB,EAC/D5B,CAAiBe,YAAAA,QAAAA,CAAWf,EAAQ,IAAIwC,mBAAAA,CAAoB,OAAOxC,CAAK,CAAC,CACjF,CACF,CACF;;AC9KO,MAAM,gBAAmByC,CAAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/constants/client.ts","../src/utils/platform.ts","../src/types/errors.ts","../src/providers/native.ts","../src/providers/index.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["/**\n * Client constants for WalletConnect Pay SDK\n */\n\n/** Default Pay API base URL */\nexport const PAY_API_BASE_URL = \"https://api.pay.walletconnect.com\";\n\n/** SDK name for tracking */\nexport const SDK_NAME = \"js-walletconnect-pay\";\n\n/** SDK version (from package.json) */\nexport const SDK_VERSION = `1.0.1`;\n\n/** Client context name */\nexport const CLIENT_CONTEXT = \"pay\";\n\n/** Logger context */\nexport const LOGGER_CONTEXT = \"WalletConnectPay\";\n","/**\n * Platform detection utilities for WalletConnect Pay SDK\n */\n\nimport { isIos, isAndroid, isBrowser, isNode } from \"@walletconnect/utils\";\n\n/**\n * Get the SDK platform based on the current environment\n * @returns Platform string: rn-ios, rn-android, browser, node, or unknown\n */\nexport function getSdkPlatform(): string {\n if (isIos()) return \"rn-ios\";\n if (isAndroid()) return \"rn-android\";\n if (isBrowser()) return \"browser\";\n if (isNode()) return \"node\";\n return \"unknown\";\n}\n","/**\n * Error types for WalletConnect Pay SDK\n */\n\n/**\n * Error codes from the native module\n */\nexport type PayErrorCode =\n | \"JSON_PARSE\"\n | \"JSON_SERIALIZE\"\n | \"PAYMENT_OPTIONS\"\n | \"PAYMENT_REQUEST\"\n | \"CONFIRM_PAYMENT\"\n | \"NATIVE_MODULE_NOT_FOUND\"\n | \"INITIALIZATION_ERROR\"\n | \"UNKNOWN\";\n\n/**\n * Base error class for Pay SDK\n */\nexport class PayError extends Error {\n public readonly code: PayErrorCode;\n public readonly originalMessage: string;\n\n constructor(code: PayErrorCode, message: string, originalMessage?: string) {\n super(message);\n this.name = \"PayError\";\n this.code = code;\n this.originalMessage = originalMessage ?? message;\n Object.setPrototypeOf(this, PayError.prototype);\n }\n\n static fromNativeError(error: unknown): PayError {\n if (error instanceof PayError) {\n return error;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n\n // Try to parse error code from message\n if (message.includes(\"JSON parse error\")) {\n return new PayError(\"JSON_PARSE\", message);\n }\n if (message.includes(\"JSON serialize error\")) {\n return new PayError(\"JSON_SERIALIZE\", message);\n }\n if (message.includes(\"Payment options error\")) {\n return new PayError(\"PAYMENT_OPTIONS\", message);\n }\n if (message.includes(\"Payment request error\")) {\n return new PayError(\"PAYMENT_REQUEST\", message);\n }\n if (message.includes(\"Confirm payment error\")) {\n return new PayError(\"CONFIRM_PAYMENT\", message);\n }\n\n return new PayError(\"UNKNOWN\", message);\n }\n}\n\n/**\n * Error thrown when native module is not available\n */\nexport class NativeModuleNotFoundError extends PayError {\n constructor() {\n super(\n \"NATIVE_MODULE_NOT_FOUND\",\n \"WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked.\",\n );\n this.name = \"NativeModuleNotFoundError\";\n Object.setPrototypeOf(this, NativeModuleNotFoundError.prototype);\n }\n}\n\n/**\n * Error thrown when payment options request fails\n */\nexport class PaymentOptionsError extends PayError {\n constructor(message: string) {\n super(\"PAYMENT_OPTIONS\", `Failed to get payment options: ${message}`, message);\n this.name = \"PaymentOptionsError\";\n Object.setPrototypeOf(this, PaymentOptionsError.prototype);\n }\n}\n\n/**\n * Error thrown when payment actions request fails\n */\nexport class PaymentActionsError extends PayError {\n constructor(message: string) {\n super(\"PAYMENT_REQUEST\", `Failed to get payment actions: ${message}`, message);\n this.name = \"PaymentActionsError\";\n Object.setPrototypeOf(this, PaymentActionsError.prototype);\n }\n}\n\n/**\n * Error thrown when payment confirmation fails\n */\nexport class ConfirmPaymentError extends PayError {\n constructor(message: string) {\n super(\"CONFIRM_PAYMENT\", `Failed to confirm payment: ${message}`, message);\n this.name = \"ConfirmPaymentError\";\n Object.setPrototypeOf(this, ConfirmPaymentError.prototype);\n }\n}\n","/**\n * Native Provider for WalletConnect Pay SDK\n *\n * Uses the React Native uniffi module for payment operations.\n */\n\nimport type {\n PaymentOptionsResponse,\n ConfirmPaymentResponse,\n Action,\n PayProvider,\n PayProviderConfig,\n GetPaymentOptionsParams,\n GetRequiredPaymentActionsParams,\n ConfirmPaymentParams,\n} from \"../types/index.js\";\nimport { NativeModuleNotFoundError, PayError } from \"../types/index.js\";\n\n/**\n * Native module interface expected from React Native\n */\ninterface NativePayModule {\n getPaymentOptions(requestJson: string): Promise<string>;\n getRequiredPaymentActions(requestJson: string): Promise<string>;\n confirmPayment(requestJson: string): Promise<string>;\n initialize?(configJson: string): void;\n}\n\n// Cached native module reference\nlet cachedNativeModule: NativePayModule | null | undefined;\n\n// Manually injected module reference\nlet injectedModule: NativePayModule | null = null;\n\n/**\n * Try to get the native module from React Native\n */\nfunction getNativeModule(): NativePayModule | null {\n // Return injected module if available\n if (injectedModule) {\n return injectedModule;\n }\n\n // Return cached result if already attempted\n if (cachedNativeModule !== undefined) {\n return cachedNativeModule;\n }\n\n try {\n // Access React Native's NativeModules via globalThis\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const reactNative = (globalThis as any).ReactNative;\n if (reactNative?.NativeModules?.RNWalletConnectPay) {\n cachedNativeModule = reactNative.NativeModules.RNWalletConnectPay as NativePayModule;\n return cachedNativeModule;\n }\n\n // Fallback: Try accessing via expo modules pattern\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const expoModules = (globalThis as any).expo?.modules;\n if (expoModules?.RNWalletConnectPay) {\n cachedNativeModule = expoModules.RNWalletConnectPay as NativePayModule;\n return cachedNativeModule;\n }\n\n cachedNativeModule = null;\n return null;\n } catch {\n cachedNativeModule = null;\n return null;\n }\n}\n\n/**\n * Set a custom native module instance\n * Use this to manually inject the native module if auto-discovery doesn't work\n */\nexport function setNativeModule(module: NativePayModule): void {\n injectedModule = module;\n cachedNativeModule = module;\n}\n\n/**\n * Check if native provider is available\n */\nexport function isNativeProviderAvailable(): boolean {\n return getNativeModule() !== null;\n}\n\n/**\n * Reset the native module (for testing)\n */\nexport function resetNativeModule(): void {\n injectedModule = null;\n cachedNativeModule = undefined;\n}\n\n/**\n * Native provider implementation using React Native uniffi module\n */\nexport class NativeProvider implements PayProvider {\n private readonly module: NativePayModule;\n\n constructor(config: PayProviderConfig) {\n const module = getNativeModule();\n\n if (!module) {\n throw new NativeModuleNotFoundError();\n }\n\n // Initialize the module with config\n if (module.initialize) {\n try {\n const configJson = JSON.stringify(config);\n module.initialize(configJson);\n } catch (error) {\n throw new PayError(\n \"INITIALIZATION_ERROR\",\n `Failed to initialize native Pay module: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n this.module = module;\n }\n\n async getPaymentOptions(params: GetPaymentOptionsParams): Promise<PaymentOptionsResponse> {\n const request = {\n paymentLink: params.paymentLink,\n accounts: params.accounts,\n includePaymentInfo: params.includePaymentInfo ?? false,\n };\n\n try {\n const responseJson = await this.module.getPaymentOptions(JSON.stringify(request));\n return JSON.parse(responseJson) as PaymentOptionsResponse;\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n\n async getRequiredPaymentActions(params: GetRequiredPaymentActionsParams): Promise<Action[]> {\n const request = {\n paymentId: params.paymentId,\n optionId: params.optionId,\n };\n\n try {\n const responseJson = await this.module.getRequiredPaymentActions(JSON.stringify(request));\n return JSON.parse(responseJson) as Action[];\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n\n async confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse> {\n const request = {\n paymentId: params.paymentId,\n optionId: params.optionId,\n signatures: params.signatures,\n collectedData: params.collectedData,\n };\n\n try {\n const responseJson = await this.module.confirmPayment(JSON.stringify(request));\n return JSON.parse(responseJson) as ConfirmPaymentResponse;\n } catch (error) {\n throw PayError.fromNativeError(error);\n }\n }\n}\n\n/**\n * Create a native provider instance\n */\nexport function createNativeProvider(config: PayProviderConfig): PayProvider {\n return new NativeProvider(config);\n}\n","/**\n * Provider exports for WalletConnect Pay SDK\n */\n\nimport type { PayProvider, PayProviderConfig, PayProviderType } from \"../types/index.js\";\nimport { createNativeProvider, isNativeProviderAvailable } from \"./native.js\";\n\nexport * from \"./native.js\";\n\n/**\n * Detect the best available provider type for the current environment\n */\nexport function detectProviderType(): PayProviderType | null {\n // Check for native module (React Native)\n if (isNativeProviderAvailable()) {\n return \"native\";\n }\n\n // Future: Check for WASM support\n // if (isWasmProviderAvailable()) {\n // return \"wasm\";\n // }\n\n return null;\n}\n\n/**\n * Create a provider based on auto-detection\n * @param config - Provider configuration\n */\nexport function createProvider(config: PayProviderConfig): PayProvider {\n const providerType = detectProviderType();\n\n if (!providerType) {\n throw new Error(\n \"No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.\",\n );\n }\n\n switch (providerType) {\n case \"native\":\n return createNativeProvider(config);\n case \"wasm\":\n // Future: return createWasmProvider(config);\n throw new Error(\"WASM provider not yet implemented\");\n default:\n throw new Error(`Unknown provider type: ${providerType}`);\n }\n}\n\n/**\n * Check if any provider is available\n */\nexport function isProviderAvailable(): boolean {\n return detectProviderType() !== null;\n}\n","/**\n * WalletConnect Pay Client\n *\n * TypeScript wrapper around the Pay provider for payment processing.\n */\n\nimport { getDefaultLoggerOptions, pino } from \"@walletconnect/logger\";\nimport type { Logger } from \"@walletconnect/logger\";\nimport { getAppId } from \"@walletconnect/utils\";\n\nimport { PAY_API_BASE_URL, SDK_NAME, SDK_VERSION, LOGGER_CONTEXT } from \"./constants/index.js\";\nimport { getSdkPlatform } from \"./utils/index.js\";\nimport type {\n WalletConnectPayOptions,\n PaymentOptionsResponse,\n ConfirmPaymentResponse,\n Action,\n PayProvider,\n PayProviderConfig,\n GetPaymentOptionsParams,\n GetRequiredPaymentActionsParams,\n ConfirmPaymentParams,\n} from \"./types/index.js\";\nimport {\n PayError,\n PaymentOptionsError,\n PaymentActionsError,\n ConfirmPaymentError,\n} from \"./types/index.js\";\nimport { createProvider, isProviderAvailable } from \"./providers/index.js\";\n\nexport class WalletConnectPay {\n public readonly projectId: string;\n public readonly apiKey: string;\n public readonly baseUrl: string;\n\n private readonly logger: Logger;\n private readonly provider: PayProvider;\n\n /**\n * Initialize a new Pay client\n * @param opts - Client options\n */\n constructor(opts: WalletConnectPayOptions) {\n this.projectId = opts.projectId;\n this.apiKey = opts.apiKey;\n this.baseUrl = opts.baseUrl ?? PAY_API_BASE_URL;\n\n // Initialize logger\n this.logger =\n typeof opts.logger === \"string\"\n ? pino(getDefaultLoggerOptions({ level: opts.logger }))\n : (opts.logger ?? pino(getDefaultLoggerOptions({ level: \"error\" })));\n\n this.logger.trace(`${LOGGER_CONTEXT} initialized`);\n\n // Build provider config\n const providerConfig: PayProviderConfig = {\n baseUrl: this.baseUrl,\n projectId: this.projectId,\n apiKey: this.apiKey,\n sdkName: SDK_NAME,\n sdkVersion: SDK_VERSION,\n sdkPlatform: getSdkPlatform(),\n bundleId: getAppId() ?? \"\",\n };\n\n // Create provider (auto-detects available provider)\n this.provider = createProvider(providerConfig);\n this.logger.debug(`${LOGGER_CONTEXT} provider initialized`);\n }\n\n /**\n * Check if the Pay SDK is available on this platform\n */\n static isAvailable(): boolean {\n return isProviderAvailable();\n }\n\n /**\n * Get payment options for a payment link\n *\n * @param params - Payment options parameters\n * @param params.paymentLink - Payment link or payment ID\n * @param params.accounts - List of CAIP-10 account addresses\n * @param params.includePaymentInfo - Whether to include payment info in response\n * @returns Payment options response\n * @throws PaymentOptionsError if the request fails\n */\n async getPaymentOptions(params: GetPaymentOptionsParams): Promise<PaymentOptionsResponse> {\n this.logger.debug(\n {\n paymentLink: params.paymentLink,\n accounts: params.accounts,\n includePaymentInfo: params.includePaymentInfo,\n },\n `${LOGGER_CONTEXT} getPaymentOptions`,\n );\n\n try {\n const response = await this.provider.getPaymentOptions(params);\n\n this.logger.debug(\n { paymentId: response.paymentId, optionsCount: response.options.length },\n `${LOGGER_CONTEXT} getPaymentOptions response`,\n );\n\n return response;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} getPaymentOptions error`);\n throw error instanceof PayError ? error : new PaymentOptionsError(String(error));\n }\n }\n\n /**\n * Get required payment actions for a selected option\n *\n * @param params - Required actions parameters\n * @param params.paymentId - Payment ID\n * @param params.optionId - Selected option ID\n * @returns Array of actions to be signed\n * @throws PaymentActionsError if the request fails\n */\n async getRequiredPaymentActions(params: GetRequiredPaymentActionsParams): Promise<Action[]> {\n this.logger.debug(\n { paymentId: params.paymentId, optionId: params.optionId },\n `${LOGGER_CONTEXT} getRequiredPaymentActions`,\n );\n\n try {\n const actions = await this.provider.getRequiredPaymentActions(params);\n\n this.logger.debug(\n { actionsCount: actions.length },\n `${LOGGER_CONTEXT} getRequiredPaymentActions response`,\n );\n\n return actions;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} getRequiredPaymentActions error`);\n throw error instanceof PayError ? error : new PaymentActionsError(String(error));\n }\n }\n\n /**\n * Confirm a payment with wallet signatures\n *\n * @param params - Confirm payment parameters\n * @param params.paymentId - Payment ID\n * @param params.optionId - Selected option ID\n * @param params.signatures - Array of signatures from wallet RPC calls\n * @param params.collectedData - Optional collected data fields\n * @returns Confirm payment response with final status\n * @throws ConfirmPaymentError if the request fails\n */\n async confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse> {\n this.logger.debug(\n {\n paymentId: params.paymentId,\n optionId: params.optionId,\n signaturesCount: params.signatures.length,\n hasCollectedData: !!params.collectedData,\n },\n `${LOGGER_CONTEXT} confirmPayment`,\n );\n\n try {\n const response = await this.provider.confirmPayment(params);\n\n this.logger.debug(\n { status: response.status, isFinal: response.isFinal },\n `${LOGGER_CONTEXT} confirmPayment response`,\n );\n\n return response;\n } catch (error) {\n this.logger.error({ error }, `${LOGGER_CONTEXT} confirmPayment error`);\n throw error instanceof PayError ? error : new ConfirmPaymentError(String(error));\n }\n }\n}\n","import { WalletConnectPay as Client } from \"./client.js\";\n\nexport * from \"./constants/index.js\";\nexport * from \"./types/index.js\";\nexport * from \"./providers/index.js\";\n\nexport const WalletConnectPay = Client;\nexport default Client;\n"],"names":["isIos","isAndroid","isBrowser","isNode","code","message","originalMessage","__publicField","error","c","l","cachedNativeModule","injectedModule","getNativeModule","_a","_b","reactNative","expoModules","e","module","config","NativeModuleNotFoundError","configJson","PayError","params","request","responseJson","isNativeProviderAvailable","providerType","createNativeProvider","WalletConnectPay","opts","_c","PAY_API_BASE_URL","pino","getDefaultLoggerOptions","LOGGER_CONTEXT","providerConfig","SDK_NAME","SDK_VERSION","getSdkPlatform","getAppId","createProvider","isProviderAvailable","response","PaymentOptionsError","actions","PaymentActionsError","ConfirmPaymentError","Client"],"mappings":";;;AAKa,MAAA,gBAAA,CAAmB,oCAGnB,QAAW,CAAA,sBAAA,CAGX,YAAc,OAGd,CAAA,cAAA,CAAiB,MAGjB,cAAiB,CAAA;;ACPvB,SAAS,cAAyB,EAAA,CACvC,OAAIA,KAAM,EAAA,CAAU,QAChBC,CAAAA,SAAAA,EAAoB,CAAA,YAAA,CACpBC,SAAU,EAAA,CAAU,SACpBC,CAAAA,MAAAA,EAAiB,CAAA,MAAA,CACd,SACT;;4KCIa,MAAA,QAAA,SAAiB,KAAM,CAIlC,WAAA,CAAYC,EAAoBC,CAAiBC,CAAAA,CAAAA,CAA0B,CACzE,KAAMD,CAAAA,CAAO,EAJfE,CAAA,CAAA,IAAA,CAAgB,QAChBA,CAAA,CAAA,IAAA,CAAgB,mBAId,IAAK,CAAA,IAAA,CAAO,UACZ,CAAA,IAA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