@oobit/react-native-sdk 3.0.0 → 3.0.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @oobit/react-native-sdk
2
2
 
3
- A React Native SDK that enables wallet apps to integrate Oobit's crypto payment services. Let your users pay with cryptocurrency through Oobit's secure payment infrastructure.
3
+ A React Native SDK that enables wallet apps to integrate Oobit's crypto-to-card payment services.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@oobit/react-native-sdk.svg)](https://www.npmjs.com/package/@oobit/react-native-sdk)
6
6
  [![license](https://img.shields.io/npm/l/@oobit/react-native-sdk.svg)](https://github.com/oobit-tech/react-native-SDK/blob/main/LICENSE)
@@ -8,361 +8,39 @@ A React Native SDK that enables wallet apps to integrate Oobit's crypto payment
8
8
  ## Installation
9
9
 
10
10
  ```bash
11
- npm install @oobit/react-native-sdk
12
- # or
13
- yarn add @oobit/react-native-sdk
14
- ```
15
-
16
- ### Peer Dependencies
17
-
18
- Make sure you have these installed:
19
-
20
- ```bash
21
- npm install react-native-webview expo-linking expo-clipboard expo-intent-launcher expo-local-authentication
22
- # or
23
- yarn add react-native-webview expo-linking expo-clipboard expo-intent-launcher expo-local-authentication
11
+ npm install @oobit/react-native-sdk react-native-webview
24
12
  ```
25
13
 
26
14
  ## Quick Start
27
15
 
28
- ```typescript
29
- import { WidgetSDK } from '@oobit/react-native-sdk';
30
- import { View, Alert } from 'react-native';
31
-
32
- function MyApp() {
33
- return (
34
- <View style={{ flex: 1 }}>
35
- <WidgetSDK
36
- accessToken="your-jwt-token-from-backend"
37
- userWalletAddress="0x1234...abcd"
38
- environment="production"
39
- onReady={() => {
40
- console.log('Widget loaded successfully');
41
- }}
42
- onError={(code, message) => {
43
- Alert.alert('Error', message);
44
- }}
45
- onClose={() => {
46
- console.log('User closed the widget');
47
- }}
48
- onTransactionRequested={(token, amount, address, tag) => {
49
- console.log(`Send ${amount} ${token.symbol} to ${address}`);
50
- }}
51
- />
52
- </View>
53
- );
54
- }
55
- ```
56
-
57
- ## Props
58
-
59
- ### Required Props
60
-
61
- #### `accessToken: string`
62
- JWT access token from your backend for authentication.
63
-
64
- ```typescript
65
- <WidgetSDK accessToken="eyJhbGciOiJIUzI1NiIs..." />
66
- ```
67
-
68
- #### `userWalletAddress: string`
69
- The user's external wallet address for crypto deposits.
70
-
71
- ```typescript
72
- <WidgetSDK userWalletAddress="0x1234567890abcdef..." />
73
- ```
74
-
75
- ### Optional Props
76
-
77
- #### `environment?: 'development' | 'production'`
78
- The environment to use. Defaults to `'production'`.
79
-
80
- ```typescript
81
- <WidgetSDK environment="development" />
82
- ```
83
-
84
- #### `debug?: boolean`
85
- Enable debug logging to console. Defaults to `false`.
86
-
87
- ```typescript
88
- <WidgetSDK debug={true} />
89
- ```
90
-
91
- #### `loadingIndicatorColor?: string`
92
- Custom color for the loading indicator. Defaults to `'#007AFF'`.
93
-
94
- ```typescript
95
- <WidgetSDK loadingIndicatorColor="#6200EE" />
96
- ```
97
-
98
- ### Callback Props
99
-
100
- #### `onReady?: () => void`
101
- Called when the widget has finished loading and is ready for interaction.
102
-
103
- ```typescript
104
- <WidgetSDK
105
- onReady={() => {
106
- console.log('Widget is ready!');
107
- setIsLoading(false);
108
- }}
109
- />
110
- ```
111
-
112
- #### `onError?: (code: SDKErrorCode | string, message: string) => void`
113
- Called when an error occurs in the widget.
114
-
115
- **Error Codes:**
116
- - `TOKEN_EXPIRED` - The access token has expired
117
- - `PARSE_ERROR` - Failed to parse a message from the widget
118
- - `WEBVIEW_ERROR` - The WebView failed to load
119
-
120
- ```typescript
121
- <WidgetSDK
122
- onError={(code, message) => {
123
- console.error(`Widget error [${code}]: ${message}`);
124
-
125
- if (code === 'TOKEN_EXPIRED') {
126
- // Refresh token and reload
127
- refreshAuth();
128
- }
129
- }}
130
- />
131
- ```
132
-
133
- #### `onClose?: () => void`
134
- Called when the user requests to close the widget.
135
-
136
- ```typescript
137
- <WidgetSDK
138
- onClose={() => {
139
- navigation.goBack();
140
- }}
141
- />
142
- ```
143
-
144
- #### `onTransactionRequested?: (token, cryptoAmount, depositAddress, depositAddressTag) => void`
145
- Called when a crypto transaction is requested.
146
-
147
- ```typescript
148
- <WidgetSDK
149
- onTransactionRequested={(token, cryptoAmount, depositAddress, depositAddressTag) => {
150
- console.log(`Send ${cryptoAmount} ${token.symbol} to ${depositAddress}`);
151
- // Navigate to your send crypto screen
152
- navigation.navigate('SendCrypto', {
153
- token,
154
- amount: cryptoAmount,
155
- address: depositAddress,
156
- tag: depositAddressTag,
157
- });
158
- }}
159
- />
160
- ```
161
-
162
- #### `onLoadingChange?: (isLoading: boolean) => void`
163
- Called when the loading state changes.
164
-
165
- ```typescript
166
- <WidgetSDK
167
- onLoadingChange={(isLoading) => {
168
- setShowCustomLoader(isLoading);
169
- }}
170
- />
171
- ```
172
-
173
- ## Ref Methods
174
-
175
- You can control the widget programmatically using a ref:
176
-
177
- ```typescript
178
- import { useRef } from 'react';
179
- import { WidgetSDK, WidgetSDKRef } from '@oobit/react-native-sdk';
180
-
181
- function MyScreen() {
182
- const widgetRef = useRef<WidgetSDKRef>(null);
183
-
184
- const handleBackPress = () => {
185
- widgetRef.current?.navigateBack();
186
- };
187
-
188
- const handleRetry = () => {
189
- widgetRef.current?.reload();
190
- };
16
+ ```tsx
17
+ import { WidgetSDK } from "@oobit/react-native-sdk";
191
18
 
19
+ function PaymentScreen() {
192
20
  return (
193
21
  <WidgetSDK
194
- ref={widgetRef}
195
- accessToken={token}
196
- userWalletAddress={address}
22
+ accessToken="prod_your-jwt-token"
23
+ userWalletAddress="0x1234..."
24
+ onTransactionRequested={(transaction) => {
25
+ // Navigate to your transaction confirmation screen
26
+ navigation.navigate("ConfirmTransaction", { transaction });
27
+ }}
28
+ onClose={() => navigation.goBack()}
197
29
  />
198
30
  );
199
31
  }
200
32
  ```
201
33
 
202
- ### Available Methods
203
-
204
- | Method | Description |
205
- |--------|-------------|
206
- | `navigateBack()` | Navigate back within the widget |
207
- | `reload()` | Reload the widget |
208
-
209
- ## TypeScript Support
210
-
211
- The SDK is fully typed. Import types as needed:
212
-
213
- ```typescript
214
- import type {
215
- WidgetSDKConfig,
216
- WidgetSDKRef,
217
- SDKErrorCode,
218
- DepositToken,
219
- } from '@oobit/react-native-sdk';
220
- ```
221
-
222
- ### Message Type Constants
223
-
224
- For advanced use cases where you need to handle messages directly:
225
-
226
- ```typescript
227
- import { MessageTypes } from '@oobit/react-native-sdk';
228
-
229
- // Use constants instead of strings
230
- if (message.type === MessageTypes.ERROR) {
231
- // Handle error
232
- }
233
- ```
234
-
235
- ## Native Wallet Integration
236
-
237
- The SDK automatically handles adding cards to Apple Wallet (iOS) and Google Pay (Android).
238
-
239
- You can also manually open the wallet from your React Native app:
240
-
241
- ```typescript
242
- import { openNativeWallet, isWalletAvailable } from '@oobit/react-native-sdk';
243
-
244
- // Check if wallet is available
245
- const available = await isWalletAvailable();
246
-
247
- if (available) {
248
- // Open native wallet
249
- await openNativeWallet();
250
- }
251
- ```
252
-
253
- ## Platform Support
254
-
255
- | Platform | Supported | Notes |
256
- |----------|-----------|-------|
257
- | iOS | ✅ | Includes Apple Wallet integration |
258
- | Android | ✅ | Includes Google Pay integration |
259
- | Web | ❌ | React Native only |
260
-
261
- ## Complete Example
262
-
263
- ```typescript
264
- import React, { useState, useRef } from 'react';
265
- import { View, Button, StyleSheet, Alert } from 'react-native';
266
- import { WidgetSDK, WidgetSDKRef } from '@oobit/react-native-sdk';
267
-
268
- export default function PaymentScreen() {
269
- const [showWidget, setShowWidget] = useState(false);
270
- const widgetRef = useRef<WidgetSDKRef>(null);
271
-
272
- if (showWidget) {
273
- return (
274
- <View style={styles.container}>
275
- <WidgetSDK
276
- ref={widgetRef}
277
- accessToken="your-jwt-token"
278
- userWalletAddress="0x1234..."
279
- environment="production"
280
- debug={__DEV__}
281
- onReady={() => {
282
- console.log('Widget ready');
283
- }}
284
- onError={(code, message) => {
285
- Alert.alert('Error', `${code}: ${message}`);
286
- if (code === 'WEBVIEW_ERROR') {
287
- // Offer retry option
288
- Alert.alert('Error', 'Failed to load. Retry?', [
289
- { text: 'Cancel', onPress: () => setShowWidget(false) },
290
- { text: 'Retry', onPress: () => widgetRef.current?.reload() },
291
- ]);
292
- }
293
- }}
294
- onClose={() => {
295
- setShowWidget(false);
296
- }}
297
- onTransactionRequested={(token, amount, address, tag) => {
298
- Alert.alert(
299
- 'Transaction Requested',
300
- `Send ${amount} ${token.symbol} to ${address}`,
301
- );
302
- }}
303
- onLoadingChange={(isLoading) => {
304
- console.log('Loading:', isLoading);
305
- }}
306
- />
307
- </View>
308
- );
309
- }
310
-
311
- return (
312
- <View style={styles.container}>
313
- <Button
314
- title="Open Payment Widget"
315
- onPress={() => setShowWidget(true)}
316
- />
317
- </View>
318
- );
319
- }
320
-
321
- const styles = StyleSheet.create({
322
- container: {
323
- flex: 1,
324
- },
325
- });
326
- ```
327
-
328
- ## Dependencies
329
-
330
- ### Required Peer Dependencies
331
-
332
- ```json
333
- {
334
- "react": ">=18.0.0",
335
- "react-native": ">=0.70.0",
336
- "react-native-webview": ">=13.0.0",
337
- "expo-linking": ">=6.0.0",
338
- "expo-clipboard": ">=5.0.0",
339
- "expo-intent-launcher": ">=6.0.0",
340
- "expo-local-authentication": ">=14.0.0"
341
- }
342
- ```
343
-
344
- ## Troubleshooting
345
-
346
- ### Widget Not Loading
347
-
348
- 1. Verify `accessToken` is valid and not expired
349
- 2. Check that `userWalletAddress` is a valid address
350
- 3. Enable `debug={true}` to see console logs
351
- 4. Verify all peer dependencies are installed
352
-
353
- ### Callbacks Not Firing
354
-
355
- 1. Enable debug mode to see message logs
356
- 2. Check that your widget is sending proper postMessage events
357
- 3. Verify message format matches expected structure
358
-
359
- ### Error: TOKEN_EXPIRED
34
+ ## Documentation
360
35
 
361
- The access token has expired. Fetch a new token from your backend and re-render the widget with the new token.
36
+ For complete documentation, guides, and API reference, visit:
362
37
 
363
- ### Error: WEBVIEW_ERROR
38
+ **[Oobit Developer Docs](https://docs.oobit.com/docs/getting-started)**
364
39
 
365
- The WebView failed to load. This could be a network issue. Use `widgetRef.current?.reload()` to retry.
40
+ - [Getting Started](https://docs.oobit.com/docs/getting-started) - Installation and setup
41
+ - [Component Reference](https://docs.oobit.com/docs/component) - Props and methods
42
+ - [Handling Transactions](https://docs.oobit.com/docs/transactions) - Transaction flow guide
43
+ - [TypeScript Types](https://docs.oobit.com/docs/types) - Type definitions
366
44
 
367
45
  ## License
368
46
 
@@ -1,9 +1,5 @@
1
- /**
2
- * Widget SDK Component
3
- * Embeds the web widget in a WebView and handles bidirectional communication
4
- */
5
1
  import React from "react";
6
- import { WidgetSDKConfig } from "./types";
2
+ import type { WidgetSDKConfig } from "@oobit/core";
7
3
  export interface WidgetSDKRef {
8
4
  navigateBack: () => void;
9
5
  reload: () => void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetSDK.d.ts","sourceRoot":"","sources":["../../src/components/WidgetSDK.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAiB,eAAe,EAAE,MAAM,aAAa,CAAC;AAIlE,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,sFAkIrB,CAAC"}
@@ -1,8 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Widget SDK Component
4
- * Embeds the web widget in a WebView and handles bidirectional communication
5
- */
6
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
3
  if (k2 === undefined) k2 = k;
8
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -41,8 +37,8 @@ exports.WidgetSDK = void 0;
41
37
  const react_1 = __importStar(require("react"));
42
38
  const react_native_1 = require("react-native");
43
39
  const react_native_webview_1 = require("react-native-webview");
44
- const config_1 = require("./config");
45
- const walletUtils_1 = require("./walletUtils");
40
+ const core_1 = require("@oobit/core");
41
+ const walletUtils_1 = require("../utils/walletUtils");
46
42
  exports.WidgetSDK = (0, react_1.forwardRef)(({ accessToken, userWalletAddress, onClose, onTransactionRequested }, ref) => {
47
43
  const webViewRef = (0, react_1.useRef)(null);
48
44
  const [walletAvailable, setWalletAvailable] = (0, react_1.useState)(false);
@@ -93,16 +89,16 @@ exports.WidgetSDK = (0, react_1.forwardRef)(({ accessToken, userWalletAddress, o
93
89
  }
94
90
  }
95
91
  catch {
96
- // Ignore parse errors
92
+ // Invalid JSON from WebView - ignore
97
93
  }
98
94
  };
99
95
  const sendMessageToWidget = (message) => {
100
96
  webViewRef.current?.injectJavaScript(`window.postMessage(${JSON.stringify(message)}, '*'); true;`);
101
97
  };
102
98
  const finalWidgetUrl = (0, react_1.useMemo)(() => {
103
- const baseUrl = (0, config_1.getWidgetUrl)(accessToken);
99
+ const baseUrl = (0, core_1.getWidgetUrl)(accessToken);
104
100
  const params = new URLSearchParams({
105
- token: (0, config_1.stripTokenPrefix)(accessToken),
101
+ token: (0, core_1.stripTokenPrefix)(accessToken),
106
102
  platform: react_native_1.Platform.OS,
107
103
  userWalletAddress,
108
104
  });
@@ -124,6 +120,10 @@ exports.WidgetSDK = (0, react_1.forwardRef)(({ accessToken, userWalletAddress, o
124
120
  return false;
125
121
  }
126
122
  return true;
123
+ }} onOpenWindow={(syntheticEvent) => {
124
+ const { nativeEvent } = syntheticEvent;
125
+ const { targetUrl } = nativeEvent;
126
+ react_native_1.Linking.openURL(targetUrl).catch(() => { });
127
127
  }} javaScriptEnabled={true} domStorageEnabled={true} allowsInlineMediaPlayback={true} bounces={false} allowsBackForwardNavigationGestures={true} mixedContentMode="always"/>
128
128
  {isLoading && (<react_native_1.View style={styles.loadingOverlay}>
129
129
  <react_native_1.ActivityIndicator size="large" color="#007AFF"/>
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetSDK.js","sourceRoot":"","sources":["../../src/components/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O,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CACF,YAAY,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE;YAC/B,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC;YACvC,MAAM,EAAE,SAAS,EAAE,GAAG,WAAW,CAAC;YAClC,sBAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,CACF,iBAAiB,CAAC,CAAC,IAAI,CAAC,CACxB,iBAAiB,CAAC,CAAC,IAAI,CAAC,CACxB,yBAAyB,CAAC,CAAC,IAAI,CAAC,CAChC,OAAO,CAAC,CAAC,KAAK,CAAC,CACf,mCAAmC,CAAC,CAAC,IAAI,CAAC,CAC1C,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,EAAE,IAAI,EAAE,CAAC,EAAE;IACtB,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACpB,cAAc,EAAE;QACd,GAAG,yBAAU,CAAC,kBAAkB;QAChC,eAAe,EAAE,0BAA0B;QAC3C,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;CACF,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { EvmTransactionData, EvmTransactionRequest, SolanaTransactionRequest, TransactionRequest, TransactionTokenMetadata, WidgetSDKConfig, } from "./types";
2
- export { WidgetSDK } from "./WidgetSDK";
3
- export type { WidgetSDKRef } from "./WidgetSDK";
1
+ export { WidgetSDK } from './components/WidgetSDK';
2
+ export type { WidgetSDKRef } from './components/WidgetSDK';
3
+ export type { TransactionRequest, EvmTransactionRequest, SolanaTransactionRequest, TransactionTokenMetadata, WidgetSDKConfig, } from '@oobit/core';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,eAAe,GAChB,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WidgetSDK = void 0;
4
- var WidgetSDK_1 = require("./WidgetSDK");
4
+ var WidgetSDK_1 = require("./components/WidgetSDK");
5
5
  Object.defineProperty(exports, "WidgetSDK", { enumerable: true, get: function () { return WidgetSDK_1.WidgetSDK; } });
6
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,yCAAwC;AAA/B,sGAAA,SAAS,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AAA1C,sGAAA,SAAS,OAAA"}
@@ -0,0 +1,3 @@
1
+ export declare function openNativeWallet(): Promise<boolean>;
2
+ export declare function isWalletAvailable(): Promise<boolean>;
3
+ //# sourceMappingURL=walletUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletUtils.d.ts","sourceRoot":"","sources":["../../src/utils/walletUtils.ts"],"names":[],"mappings":"AAKA,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAgBzD;AA4DD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAY1D"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openNativeWallet = openNativeWallet;
4
+ exports.isWalletAvailable = isWalletAvailable;
5
+ const react_native_1 = require("react-native");
6
+ const core_1 = require("@oobit/core");
7
+ const GOOGLE_WALLET_PACKAGE = "com.google.android.apps.walletnfcrel";
8
+ async function openNativeWallet() {
9
+ try {
10
+ if (react_native_1.Platform.OS === "ios") {
11
+ return await openAppleWallet();
12
+ }
13
+ if (react_native_1.Platform.OS === "android") {
14
+ return await openGoogleWallet();
15
+ }
16
+ return false;
17
+ }
18
+ catch {
19
+ react_native_1.Alert.alert("Error", "Could not open wallet. Please check if the app is installed.");
20
+ return false;
21
+ }
22
+ }
23
+ async function openAppleWallet() {
24
+ const { passkit, fallback } = core_1.WALLET_URLS.ios;
25
+ // Try wallet:// scheme first (documented for recent iOS)
26
+ if (await tryOpenUrl("wallet://")) {
27
+ return true;
28
+ }
29
+ // Try shoebox:// scheme (unofficial but widely used)
30
+ if (await tryOpenUrl(passkit)) {
31
+ return true;
32
+ }
33
+ // Fallback to wallet.apple.com (opens in browser)
34
+ if (await tryOpenUrl(fallback)) {
35
+ return true;
36
+ }
37
+ throw new Error("Apple Wallet not available");
38
+ }
39
+ async function openGoogleWallet() {
40
+ const launchUrl = `market://launch?id=${GOOGLE_WALLET_PACKAGE}`;
41
+ // Try launching the app directly
42
+ if (await tryOpenUrl(launchUrl)) {
43
+ return true;
44
+ }
45
+ // App not installed - open Play Store
46
+ const playStoreUrl = `market://details?id=${GOOGLE_WALLET_PACKAGE}`;
47
+ const webPlayStoreUrl = `https://play.google.com/store/apps/details?id=${GOOGLE_WALLET_PACKAGE}`;
48
+ const opened = await tryOpenUrl(playStoreUrl) || await tryOpenUrl(webPlayStoreUrl);
49
+ if (opened) {
50
+ react_native_1.Alert.alert("Google Wallet", "Google Wallet is not installed. Opening Play Store to install the app.");
51
+ }
52
+ return false;
53
+ }
54
+ async function tryOpenUrl(url) {
55
+ try {
56
+ const canOpen = await react_native_1.Linking.canOpenURL(url);
57
+ if (canOpen) {
58
+ await react_native_1.Linking.openURL(url);
59
+ return true;
60
+ }
61
+ }
62
+ catch {
63
+ // URL scheme not available
64
+ }
65
+ return false;
66
+ }
67
+ async function isWalletAvailable() {
68
+ try {
69
+ if (react_native_1.Platform.OS === "ios") {
70
+ return await react_native_1.Linking.canOpenURL(core_1.WALLET_URLS.ios.passkit);
71
+ }
72
+ if (react_native_1.Platform.OS === "android") {
73
+ return await react_native_1.Linking.canOpenURL(core_1.WALLET_URLS.android.googlePay);
74
+ }
75
+ return false;
76
+ }
77
+ catch {
78
+ return false;
79
+ }
80
+ }
81
+ //# sourceMappingURL=walletUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletUtils.js","sourceRoot":"","sources":["../../src/utils/walletUtils.ts"],"names":[],"mappings":";;AAKA,4CAgBC;AA4DD,8CAYC;AA7FD,+CAAwD;AACxD,sCAA0C;AAE1C,MAAM,qBAAqB,GAAG,sCAAsC,CAAC;AAE9D,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC;QACH,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,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T,eAAe,EACf,wEAAwE,CACzE,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,GAAW;IACnC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,sBAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,sBAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,2BAA2B;IAC7B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAEM,KAAK,UAAU,iBAAiB;IACrC,IAAI,CAAC;QACH,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,MAAM,sBAAO,CAAC,UAAU,CAAC,kBAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,uBAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,MAAM,sBAAO,CAAC,UAAU,CAAC,kBAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oobit/react-native-sdk",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "React Native SDK for integrating Oobit crypto payments into wallet apps",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -35,7 +35,8 @@
35
35
  },
36
36
  "repository": {
37
37
  "type": "git",
38
- "url": "git+https://github.com/oobit-tech/react-native-SDK.git"
38
+ "url": "git+https://github.com/oobit-tech/react-native-SDK.git",
39
+ "directory": "packages/react-native"
39
40
  },
40
41
  "peerDependencies": {
41
42
  "react": ">=18.0.0",
@@ -43,29 +44,37 @@
43
44
  "react-native-webview": ">=13.0.0"
44
45
  },
45
46
  "dependencies": {
46
- "node-forge": "^1.3.1"
47
+ "node-forge": "^1.3.1",
48
+ "@oobit/core": "3.0.2"
47
49
  },
48
50
  "devDependencies": {
49
51
  "@types/node-forge": "^1.3.11",
50
52
  "@types/react": "~19.1.0",
51
- "@typescript-eslint/eslint-plugin": "^8.47.0",
52
- "@typescript-eslint/parser": "^8.47.0",
53
- "eslint": "^9.39.1",
54
53
  "react": "19.1.0",
55
54
  "react-native": "0.81.5",
56
55
  "react-native-webview": "13.15.0",
57
- "typescript": "~5.9.2"
56
+ "typescript": "~5.9.2",
57
+ "vitest": "^1.2.0",
58
+ "@testing-library/react-native": "^12.4.0",
59
+ "@oobit/typescript-config": "1.0.0",
60
+ "@oobit/eslint-config": "1.0.0"
58
61
  },
59
62
  "files": [
60
63
  "dist",
61
64
  "src",
62
65
  "README.md",
66
+ "SDK_ARCHITECTURE.md",
67
+ "SDK_QUICKSTART.md",
68
+ "WIDGET_INTEGRATION.md",
63
69
  "LICENSE"
64
70
  ],
65
71
  "scripts": {
66
72
  "build": "tsc",
67
- "prepublishOnly": "npm run build",
73
+ "dev": "tsc --watch",
68
74
  "typecheck": "tsc --noEmit",
69
- "clean": "rm -rf dist"
75
+ "clean": "rm -rf dist",
76
+ "lint": "eslint src/",
77
+ "test": "vitest run",
78
+ "test:watch": "vitest"
70
79
  }
71
- }
80
+ }