@oobit/react-native-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ /**
3
+ * Widget SDK Component
4
+ * Embeds the web widget in a WebView and handles bidirectional communication
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.WidgetSDK = void 0;
41
+ const react_1 = __importStar(require("react"));
42
+ const react_native_1 = require("react-native");
43
+ const react_native_webview_1 = require("react-native-webview");
44
+ const config_1 = require("./config");
45
+ const walletUtils_1 = require("./walletUtils");
46
+ exports.WidgetSDK = (0, react_1.forwardRef)(({ accessToken, userWalletAddress, onReady, onCardCreated, onError, onClose, onTransactionRequested, }, ref) => {
47
+ const webViewRef = (0, react_1.useRef)(null);
48
+ const [walletAvailable, setWalletAvailable] = (0, react_1.useState)(false);
49
+ const [isLoading, setIsLoading] = (0, react_1.useState)(true);
50
+ const hasLoadedOnce = (0, react_1.useRef)(false);
51
+ // Check wallet availability on mount
52
+ (0, react_1.useEffect)(() => {
53
+ checkWalletAvailability();
54
+ }, []);
55
+ // Handle Android hardware back button
56
+ (0, react_1.useEffect)(() => {
57
+ const backHandler = react_native_1.BackHandler.addEventListener("hardwareBackPress", () => {
58
+ // Send back pressed message to widget
59
+ sendMessageToWidget({
60
+ type: "native:back-pressed",
61
+ timestamp: Date.now(),
62
+ });
63
+ // Return true to prevent default back behavior
64
+ return true;
65
+ });
66
+ return () => backHandler.remove();
67
+ }, []);
68
+ // Expose navigateBack method via ref
69
+ (0, react_1.useImperativeHandle)(ref, () => ({
70
+ navigateBack: () => {
71
+ sendMessageToWidget({
72
+ type: "native:navigate-back",
73
+ timestamp: Date.now(),
74
+ });
75
+ },
76
+ }));
77
+ const checkWalletAvailability = async () => {
78
+ const available = await (0, walletUtils_1.isWalletAvailable)();
79
+ setWalletAvailable(available);
80
+ };
81
+ /**
82
+ * Handle messages from the web widget
83
+ */
84
+ const handleMessage = (event) => {
85
+ try {
86
+ const message = JSON.parse(event.nativeEvent.data);
87
+ console.log("[WidgetSDK] Received message:", message.type);
88
+ switch (message.type) {
89
+ case "widget:ready":
90
+ handleReady();
91
+ break;
92
+ case "widget:open-wallet":
93
+ handleOpenWallet();
94
+ break;
95
+ case "widget:card-created":
96
+ handleCardCreated(message);
97
+ break;
98
+ case "widget:error":
99
+ handleError(message);
100
+ break;
101
+ case "widget:close":
102
+ handleClose();
103
+ break;
104
+ case "widget:transaction-requested":
105
+ handleTransactionRequested(message);
106
+ break;
107
+ case "widget:token-expired":
108
+ console.error("[WidgetSDK] Access token expired");
109
+ onError?.("TOKEN_EXPIRED", "Access token has expired");
110
+ break;
111
+ default:
112
+ console.warn("[WidgetSDK] Unknown message type:", message);
113
+ }
114
+ }
115
+ catch (error) {
116
+ console.error("[WidgetSDK] Failed to parse message:", error);
117
+ onError?.("PARSE_ERROR", "Failed to parse widget message");
118
+ }
119
+ };
120
+ const handleReady = () => {
121
+ console.log("[WidgetSDK] Widget ready");
122
+ onReady?.();
123
+ // Send platform info to widget
124
+ sendMessageToWidget({
125
+ type: "native:platform-info",
126
+ payload: {
127
+ platform: react_native_1.Platform.OS,
128
+ walletAvailable,
129
+ },
130
+ });
131
+ };
132
+ const handleOpenWallet = async () => {
133
+ console.log("[WidgetSDK] Opening native wallet...");
134
+ const success = await (0, walletUtils_1.openNativeWallet)();
135
+ // Notify widget of result
136
+ sendMessageToWidget({
137
+ type: "native:wallet-opened",
138
+ payload: { success },
139
+ });
140
+ };
141
+ const handleCardCreated = (message) => {
142
+ if (message.type !== "widget:card-created")
143
+ return;
144
+ const { cardId, cardType, last4 } = message.payload;
145
+ console.log("[WidgetSDK] Card created:", cardId);
146
+ onCardCreated?.(cardId, cardType, last4);
147
+ };
148
+ const handleError = (message) => {
149
+ if (message.type !== "widget:error")
150
+ return;
151
+ const { code, message: errorMessage } = message.payload;
152
+ console.error("[WidgetSDK] Widget error:", code, errorMessage);
153
+ onError?.(code, errorMessage);
154
+ };
155
+ const handleClose = () => {
156
+ console.log("[WidgetSDK] Widget closed");
157
+ onClose?.();
158
+ };
159
+ const handleTransactionRequested = (message) => {
160
+ if (message.type !== "widget:transaction-requested")
161
+ return;
162
+ const { token, cryptoAmount, depositAddress, depositAddressTag } = message.payload;
163
+ console.log("[WidgetSDK] Transaction requested:", {
164
+ token,
165
+ cryptoAmount,
166
+ depositAddress,
167
+ depositAddressTag,
168
+ });
169
+ onTransactionRequested?.(token, cryptoAmount, depositAddress, depositAddressTag);
170
+ };
171
+ /**
172
+ * Send message to the web widget
173
+ */
174
+ const sendMessageToWidget = (message) => {
175
+ const js = `
176
+ window.postMessage(${JSON.stringify(message)}, '*');
177
+ true;
178
+ `;
179
+ webViewRef.current?.injectJavaScript(js);
180
+ };
181
+ /**
182
+ * Build the widget URL with query parameters
183
+ */
184
+ const finalWidgetUrl = (0, react_1.useMemo)(() => {
185
+ // Construct URL with token, platform, and wallet address
186
+ const params = new URLSearchParams({
187
+ token: accessToken,
188
+ platform: react_native_1.Platform.OS,
189
+ userWalletAddress: userWalletAddress,
190
+ });
191
+ const url = `${config_1.WIDGET_CONFIG.URL}?${params.toString()}`;
192
+ console.log("[WidgetSDK] Widget URL:", url.substring(0, 100) + "...");
193
+ return url;
194
+ }, [accessToken, userWalletAddress]);
195
+ return (<react_native_1.View style={styles.container}>
196
+ <react_native_webview_1.WebView ref={webViewRef} style={styles.webview} source={{ uri: finalWidgetUrl }} onMessage={handleMessage} onLoadEnd={() => {
197
+ if (!hasLoadedOnce.current) {
198
+ hasLoadedOnce.current = true;
199
+ setIsLoading(false);
200
+ }
201
+ }} onError={(syntheticEvent) => {
202
+ const { nativeEvent } = syntheticEvent;
203
+ console.error("[WidgetSDK] WebView error:", nativeEvent);
204
+ setIsLoading(false);
205
+ onError?.("WEBVIEW_ERROR", "Failed to load widget");
206
+ }}
207
+ // IMPORTANT: Allow external URLs to open in native apps
208
+ onShouldStartLoadWithRequest={(request) => {
209
+ const { url } = request;
210
+ // Allow wallet URLs to open in native apps
211
+ if (url.startsWith("shoebox://") || // Apple Wallet
212
+ url.includes("pay.google.com") || // Google Wallet
213
+ url.includes("wallet.google.com") ||
214
+ url.includes("wallet.apple.com")) {
215
+ console.log("[WidgetSDK] Opening external URL:", url);
216
+ react_native_1.Linking.openURL(url).catch((err) => {
217
+ console.error("[WidgetSDK] Failed to open URL:", err);
218
+ });
219
+ return false; // Don't load in WebView
220
+ }
221
+ // Allow normal widget navigation
222
+ return true;
223
+ }}
224
+ // Security settings
225
+ javaScriptEnabled={true} domStorageEnabled={true} allowsInlineMediaPlayback={true}
226
+ // iOS specific
227
+ bounces={false} allowsBackForwardNavigationGestures={true}
228
+ // Android specific
229
+ mixedContentMode="always"/>
230
+ {isLoading && (<react_native_1.View style={styles.loadingOverlay}>
231
+ <react_native_1.ActivityIndicator size="large" color="#007AFF"/>
232
+ </react_native_1.View>)}
233
+ </react_native_1.View>);
234
+ });
235
+ const styles = react_native_1.StyleSheet.create({
236
+ container: {
237
+ flex: 1,
238
+ },
239
+ webview: {
240
+ flex: 1,
241
+ },
242
+ loadingOverlay: {
243
+ ...react_native_1.StyleSheet.absoluteFillObject,
244
+ backgroundColor: 'rgba(255, 255, 255, 0.9)',
245
+ justifyContent: 'center',
246
+ alignItems: 'center',
247
+ },
248
+ });
249
+ //# sourceMappingURL=WidgetSDK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetSDK.js","sourceRoot":"","sources":["../src/WidgetSDK.tsx"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAOe;AACf,+CAAmG;AACnG,+DAAoE;AACpE,qCAAyC;AAEzC,+CAAoE;AAMvD,QAAA,SAAS,GAAG,IAAA,kBAAU,EACjC,CACE,EACE,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,aAAa,EACb,OAAO,EACP,OAAO,EACP,sBAAsB,GACvB,EACD,GAAG,EACH,EAAE;IACF,MAAM,UAAU,GAAG,IAAA,cAAM,EAAU,IAAI,CAAC,CAAC;IACzC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IACjD,MAAM,aAAa,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;IAEpC,qCAAqC;IACrC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,uBAAuB,EAAE,CAAC;IAC5B,CAAC,EAAE,EAAE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C;IAC1C,mBAAmB;IACnB,gBAAgB,CAAC,QAAQ,EAE3B;QAAA,CAAC,SAAS,IAAI,CACZ,CAAC,mBAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CACjC;YAAA,CAAC,gCAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EACjD;UAAA,EAAE,mBAAI,CAAC,CACR,CACH;MAAA,EAAE,mBAAI,CAAC,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,IAAI,EAAE,CAAC;KACR;IACD,OAAO,EAAE;QACP,IAAI,EAAE,CAAC;KACR;IACD,cAAc,EAAE;QACd,GAAG,yBAAU,CAAC,kBAAkB;QAChC,eAAe,EAAE,0BAA0B;QAC3C,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;CACF,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Widget SDK Configuration
3
+ * Environment-based configuration for the widget URL
4
+ */
5
+ /**
6
+ * Widget URL configuration
7
+ * - Development: Uses localhost (update IP for your network)
8
+ * - Production: Uses production widget URL
9
+ */
10
+ export declare const WIDGET_CONFIG: {
11
+ /**
12
+ * Base widget URL
13
+ * In development (__DEV__ = true), uses localhost
14
+ * In production (__DEV__ = false), uses production URL
15
+ */
16
+ readonly URL: "https://oobit-widget-dev.web.app" | "https://widget.oobit.com";
17
+ };
18
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,eAAO,MAAM,aAAa;IACxB;;;;OAIG;;CAIK,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * Widget SDK Configuration
4
+ * Environment-based configuration for the widget URL
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.WIDGET_CONFIG = void 0;
8
+ /**
9
+ * Widget URL configuration
10
+ * - Development: Uses localhost (update IP for your network)
11
+ * - Production: Uses production widget URL
12
+ */
13
+ exports.WIDGET_CONFIG = {
14
+ /**
15
+ * Base widget URL
16
+ * In development (__DEV__ = true), uses localhost
17
+ * In production (__DEV__ = false), uses production URL
18
+ */
19
+ URL: __DEV__
20
+ ? "https://oobit-widget-dev.web.app" // Development: Vite dev server default
21
+ : "https://widget.oobit.com", // Production: Oobit widget URL
22
+ };
23
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;;GAIG;AACU,QAAA,aAAa,GAAG;IAC3B;;;;OAIG;IACH,GAAG,EAAE,OAAO;QACV,CAAC,CAAC,kCAAkC,CAAC,uCAAuC;QAC5E,CAAC,CAAC,0BAA0B,EAAE,+BAA+B;CACvD,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Widget SDK - Public API
3
+ * Export all public components, types, and utilities
4
+ */
5
+ export { WidgetSDK } from './WidgetSDK';
6
+ export type { WidgetSDKRef } from './WidgetSDK';
7
+ export type { WidgetSDKConfig, DepositToken, WidgetMessageType, BaseWidgetMessage, WidgetMessage, WidgetReadyMessage, OpenWalletMessage, CardCreatedMessage, WidgetErrorMessage, WidgetCloseMessage, TransactionRequestedMessage, NativeMessageType, NativeMessage, NativeBackPressedMessage, NativeNavigateBackMessage, NativePlatformInfoMessage, NativeWalletOpenedMessage, } from './types';
8
+ export { WALLET_URLS, MessageTypes } from './types';
9
+ export { WIDGET_CONFIG } from './config';
10
+ export { openNativeWallet, isWalletAvailable } from './walletUtils';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,YAAY,EAEV,eAAe,EACf,YAAY,EAGZ,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAG3B,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * Widget SDK - Public API
4
+ * Export all public components, types, and utilities
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.isWalletAvailable = exports.openNativeWallet = exports.WIDGET_CONFIG = exports.MessageTypes = exports.WALLET_URLS = exports.WidgetSDK = void 0;
8
+ var WidgetSDK_1 = require("./WidgetSDK");
9
+ Object.defineProperty(exports, "WidgetSDK", { enumerable: true, get: function () { return WidgetSDK_1.WidgetSDK; } });
10
+ // Export constants
11
+ var types_1 = require("./types");
12
+ Object.defineProperty(exports, "WALLET_URLS", { enumerable: true, get: function () { return types_1.WALLET_URLS; } });
13
+ Object.defineProperty(exports, "MessageTypes", { enumerable: true, get: function () { return types_1.MessageTypes; } });
14
+ var config_1 = require("./config");
15
+ Object.defineProperty(exports, "WIDGET_CONFIG", { enumerable: true, get: function () { return config_1.WIDGET_CONFIG; } });
16
+ // Export wallet utilities
17
+ var walletUtils_1 = require("./walletUtils");
18
+ Object.defineProperty(exports, "openNativeWallet", { enumerable: true, get: function () { return walletUtils_1.openNativeWallet; } });
19
+ Object.defineProperty(exports, "isWalletAvailable", { enumerable: true, get: function () { return walletUtils_1.isWalletAvailable; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AA6BlB,mBAAmB;AACnB,iCAAoD;AAA3C,oGAAA,WAAW,OAAA;AAAE,qGAAA,YAAY,OAAA;AAClC,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AAEtB,0BAA0B;AAC1B,6CAAoE;AAA3D,+GAAA,gBAAgB,OAAA;AAAE,gHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Widget SDK Types
3
+ * Messages that can be sent between the web widget and React Native
4
+ */
5
+ /**
6
+ * Token information for transaction confirmation
7
+ * Minimal fields needed to display a send transaction confirmation page
8
+ */
9
+ export interface DepositToken {
10
+ symbol: string;
11
+ name: string;
12
+ iconUrl: string | null;
13
+ networkName: string;
14
+ }
15
+ export type WidgetMessageType = 'widget:ready' | 'widget:open-wallet' | 'widget:card-created' | 'widget:error' | 'widget:close' | 'widget:transaction-requested' | 'widget:token-expired';
16
+ /**
17
+ * Native Message Types
18
+ * Messages sent from the native app to the web widget
19
+ */
20
+ export type NativeMessageType = 'native:platform-info' | 'native:wallet-opened' | 'native:back-pressed' | 'native:navigate-back';
21
+ export interface NativeBackPressedMessage {
22
+ type: 'native:back-pressed';
23
+ timestamp: number;
24
+ }
25
+ export interface NativeNavigateBackMessage {
26
+ type: 'native:navigate-back';
27
+ timestamp: number;
28
+ }
29
+ export interface NativePlatformInfoMessage {
30
+ type: 'native:platform-info';
31
+ payload: {
32
+ platform: string;
33
+ walletAvailable: boolean;
34
+ };
35
+ }
36
+ export interface NativeWalletOpenedMessage {
37
+ type: 'native:wallet-opened';
38
+ payload: {
39
+ success: boolean;
40
+ };
41
+ }
42
+ export type NativeMessage = NativeBackPressedMessage | NativeNavigateBackMessage | NativePlatformInfoMessage | NativeWalletOpenedMessage;
43
+ export interface BaseWidgetMessage {
44
+ type: WidgetMessageType;
45
+ timestamp: number;
46
+ }
47
+ export interface WidgetReadyMessage extends BaseWidgetMessage {
48
+ type: 'widget:ready';
49
+ }
50
+ export interface OpenWalletMessage extends BaseWidgetMessage {
51
+ type: 'widget:open-wallet';
52
+ payload: {
53
+ platform: 'ios' | 'android';
54
+ };
55
+ }
56
+ export interface CardCreatedMessage extends BaseWidgetMessage {
57
+ type: 'widget:card-created';
58
+ payload: {
59
+ cardId: string;
60
+ cardType: 'virtual' | 'physical';
61
+ last4: string;
62
+ };
63
+ }
64
+ export interface WidgetErrorMessage extends BaseWidgetMessage {
65
+ type: 'widget:error';
66
+ payload: {
67
+ code: string;
68
+ message: string;
69
+ };
70
+ }
71
+ export interface WidgetCloseMessage extends BaseWidgetMessage {
72
+ type: 'widget:close';
73
+ }
74
+ export interface TransactionRequestedMessage extends BaseWidgetMessage {
75
+ type: 'widget:transaction-requested';
76
+ payload: {
77
+ token: DepositToken;
78
+ cryptoAmount: string;
79
+ depositAddress: string;
80
+ depositAddressTag: string | null;
81
+ };
82
+ }
83
+ export interface TokenExpiredMessage extends BaseWidgetMessage {
84
+ type: 'widget:token-expired';
85
+ payload?: {
86
+ reason?: string;
87
+ };
88
+ }
89
+ export type WidgetMessage = WidgetReadyMessage | OpenWalletMessage | CardCreatedMessage | WidgetErrorMessage | WidgetCloseMessage | TransactionRequestedMessage | TokenExpiredMessage;
90
+ /**
91
+ * SDK Configuration
92
+ */
93
+ export interface WidgetSDKConfig {
94
+ accessToken: string;
95
+ userWalletAddress: string;
96
+ onReady?: () => void;
97
+ onCardCreated?: (cardId: string, cardType: string, last4: string) => void;
98
+ onError?: (code: string, message: string) => void;
99
+ onClose?: () => void;
100
+ onTransactionRequested?: (token: DepositToken, cryptoAmount: string, depositAddress: string, depositAddressTag: string | null) => void;
101
+ }
102
+ /**
103
+ * Platform-specific wallet URLs
104
+ */
105
+ export declare const WALLET_URLS: {
106
+ readonly ios: {
107
+ readonly passkit: "shoebox://";
108
+ readonly fallback: "https://wallet.apple.com";
109
+ };
110
+ readonly android: {
111
+ readonly googlePay: "https://pay.google.com/gp/w/home/wallet";
112
+ readonly fallback: "https://wallet.google.com";
113
+ };
114
+ };
115
+ /**
116
+ * Message type constants that clients can use
117
+ * @example
118
+ * if (message.type === MessageTypes.READY) {
119
+ * // Handle ready
120
+ * }
121
+ */
122
+ export declare const MessageTypes: {
123
+ readonly READY: "widget:ready";
124
+ readonly OPEN_WALLET: "widget:open-wallet";
125
+ readonly CARD_CREATED: "widget:card-created";
126
+ readonly ERROR: "widget:error";
127
+ readonly CLOSE: "widget:close";
128
+ readonly TRANSACTION_REQUESTED: "widget:transaction-requested";
129
+ readonly TOKEN_EXPIRED: "widget:token-expired";
130
+ readonly PLATFORM_INFO: "native:platform-info";
131
+ readonly WALLET_OPENED: "native:wallet-opened";
132
+ readonly BACK_PRESSED: "native:back-pressed";
133
+ readonly NAVIGATE_BACK: "native:navigate-back";
134
+ };
135
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,iBAAiB,GACzB,cAAc,GACd,oBAAoB,GACpB,qBAAqB,GACrB,cAAc,GACd,cAAc,GACd,8BAA8B,GAC9B,sBAAsB,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB,sBAAsB,GACtB,sBAAsB,GACtB,qB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O,MAAM,WAAW;;;;;;;;;CASd,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;CAcf,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Widget SDK Types
4
+ * Messages that can be sent between the web widget and React Native
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.MessageTypes = exports.WALLET_URLS = void 0;
8
+ /**
9
+ * Platform-specific wallet URLs
10
+ */
11
+ exports.WALLET_URLS = {
12
+ ios: {
13
+ passkit: 'shoebox://', // Apple Wallet deep link
14
+ fallback: 'https://wallet.apple.com',
15
+ },
16
+ android: {
17
+ googlePay: 'https://pay.google.com/gp/w/home/wallet',
18
+ fallback: 'https://wallet.google.com',
19
+ },
20
+ };
21
+ /**
22
+ * Message type constants that clients can use
23
+ * @example
24
+ * if (message.type === MessageTypes.READY) {
25
+ * // Handle ready
26
+ * }
27
+ */
28
+ exports.MessageTypes = {
29
+ // Widget → Native
30
+ READY: 'widget:ready',
31
+ OPEN_WALLET: 'widget:open-wallet',
32
+ CARD_CREATED: 'widget:card-created',
33
+ ERROR: 'widget:error',
34
+ CLOSE: 'widget:close',
35
+ TRANSACTION_REQUESTED: 'widget:transaction-requested',
36
+ TOKEN_EXPIRED: 'widget:token-expired',
37
+ // Native → Widget
38
+ PLATFORM_INFO: 'native:platform-info',
39
+ WALLET_OPENED: 'native:wallet-opened',
40
+ BACK_PRESSED: 'native:back-pressed',
41
+ NAVIGATE_BACK: 'native:navigate-back',
42
+ };
43
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2IH;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,GAAG,EAAE;QACH,OAAO,EAAE,YAAY,EAAE,yBAAyB;QAChD,QAAQ,EAAE,0BAA0B;KACrC;IACD,OAAO,EAAE;QACP,SAAS,EAAE,yCAAyC;QACpD,QAAQ,EAAE,2BAA2B;KACtC;CACO,CAAC;AAEX;;;;;;GAMG;AACU,QAAA,YAAY,GAAG;IAC1B,kBAAkB;IAClB,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,oBAAoB;IACjC,YAAY,EAAE,qBAAqB;IACnC,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;IACrB,qBAAqB,EAAE,8BAA8B;IACrD,aAAa,EAAE,sBAAsB;IACrC,kBAAkB;IAClB,aAAa,EAAE,sBAAsB;IACrC,aAAa,EAAE,sBAAsB;IACrC,YAAY,EAAE,qBAAqB;IACnC,aAAa,EAAE,sBAAsB;CAC7B,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Wallet Integration Utilities
3
+ * Handles opening Apple Wallet (iOS) and Google Wallet (Android)
4
+ */
5
+ /**
6
+ * Opens the native wallet app based on platform
7
+ * @returns Promise that resolves when wallet opens successfully
8
+ */
9
+ export declare const openNativeWallet: () => Promise<boolean>;
10
+ /**
11
+ * Check if wallet is available on the current platform
12
+ */
13
+ export declare const isWalletAvailable: () => Promise<boolean>;
14
+ //# sourceMappingURL=walletUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletUtils.d.ts","sourceRoot":"","sources":["../src/walletUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,OAAO,CAkBxD,CAAC;AA2HF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,OAAO,CAYzD,CAAC"}