@circle-fin/w3s-pw-react-native-sdk 1.1.5 → 2.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.
Files changed (114) hide show
  1. package/BARE_REACT_NATIVE_GUIDE.md +397 -0
  2. package/LICENSE +1 -1
  3. package/README.md +196 -90
  4. package/android/build.gradle +43 -126
  5. package/android/src/main/AndroidManifest.xml +12 -16
  6. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/ProgrammablewalletRnSdkModule.kt +414 -244
  7. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseCallback.kt +76 -74
  8. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/RecordsHelper.kt +602 -0
  9. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/models/Records.kt +43 -0
  10. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnImageSetter.kt +55 -33
  11. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnLayoutProvider.kt +81 -79
  12. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnViewSetterProvider.kt +93 -63
  13. package/app.json +8 -0
  14. package/build/ProgrammablewalletRnSdkModule.d.ts +44 -0
  15. package/build/ProgrammablewalletRnSdkModule.d.ts.map +1 -0
  16. package/build/ProgrammablewalletRnSdkModule.js +21 -0
  17. package/build/ProgrammablewalletRnSdkModule.js.map +1 -0
  18. package/build/WalletSdk.d.ts +20 -0
  19. package/build/WalletSdk.d.ts.map +1 -0
  20. package/build/WalletSdk.js +303 -0
  21. package/build/WalletSdk.js.map +1 -0
  22. package/build/bridgeSafe.d.ts +50 -0
  23. package/build/bridgeSafe.d.ts.map +1 -0
  24. package/build/bridgeSafe.js +136 -0
  25. package/build/bridgeSafe.js.map +1 -0
  26. package/build/index.d.ts +21 -0
  27. package/build/index.d.ts.map +1 -0
  28. package/build/index.js +21 -0
  29. package/build/index.js.map +1 -0
  30. package/{lib/typescript/src → build}/types.d.ts +72 -43
  31. package/build/types.d.ts.map +1 -0
  32. package/build/types.js +331 -0
  33. package/build/types.js.map +1 -0
  34. package/build/utils/securityQuestionUtils.d.ts +43 -0
  35. package/build/utils/securityQuestionUtils.d.ts.map +1 -0
  36. package/build/utils/securityQuestionUtils.js +109 -0
  37. package/build/utils/securityQuestionUtils.js.map +1 -0
  38. package/expo-module.config.json +11 -0
  39. package/ios/Array+Extension.swift +17 -15
  40. package/ios/BridgeHelper.swift +71 -92
  41. package/ios/{RnWalletSdk+CustomizeAdapter.swift → CustomizeAdapter.swift} +19 -29
  42. package/ios/ProgrammablewalletRnSdk.podspec +30 -0
  43. package/ios/ProgrammablewalletRnSdkModule.swift +384 -0
  44. package/ios/TextConfig.swift +17 -15
  45. package/ios/TextKey.swift +17 -15
  46. package/ios/UIApplication+Extension.swift +26 -17
  47. package/ios/UIColor+Extension.swift +34 -28
  48. package/ios/UITextField+Extension.swift +31 -0
  49. package/ios/UIView+Extension.swift +24 -17
  50. package/package.json +70 -136
  51. package/plugins/apple-signin-entitlements.js +16 -0
  52. package/plugins/infoplist-config.js +77 -0
  53. package/plugins/infoplist-config.md +72 -0
  54. package/plugins/podfile-modifier.js +84 -0
  55. package/plugins/podfile-modifier.md +33 -0
  56. package/plugins/withCopyFiles.js +132 -0
  57. package/plugins/withCopyFiles.md +81 -0
  58. package/src/ProgrammablewalletRnSdkModule.ts +68 -38
  59. package/src/WalletSdk.ts +297 -155
  60. package/src/bridgeSafe.ts +156 -0
  61. package/src/index.ts +21 -0
  62. package/src/types.ts +133 -110
  63. package/src/utils/securityQuestionUtils.ts +121 -0
  64. package/COPYRIGHT +0 -10
  65. package/android/gradle.properties +0 -21
  66. package/android/src/main/AndroidManifestNew.xml +0 -22
  67. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/BridgeHelper.kt +0 -399
  68. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/ProgrammablewalletRnSdkPackage.kt +0 -49
  69. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseCallback2.kt +0 -65
  70. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseLogoutCallback.kt +0 -47
  71. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseSocialCallback.kt +0 -53
  72. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/TestHelper.kt +0 -37
  73. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/annotation/ExcludeFromGeneratedCCReport.kt +0 -33
  74. package/android/src/newarch/ProgrammablewalletRnSdkSpec.kt +0 -29
  75. package/android/src/oldarch/ProgrammablewalletRnSdkSpec.kt +0 -76
  76. package/circlefin-w3s-pw-react-native-sdk.podspec +0 -41
  77. package/ios/EventEmitter.swift +0 -49
  78. package/ios/ProgrammablewalletRnSdk.h +0 -29
  79. package/ios/ProgrammablewalletRnSdk.mm +0 -162
  80. package/ios/ReactNativeEventEmitter.m +0 -27
  81. package/ios/ReactNativeEventEmitter.swift +0 -37
  82. package/ios/RnWalletSdk.swift +0 -385
  83. package/ios/programmablewallet-rn-sdk-Bridging-Header.h +0 -22
  84. package/lib/commonjs/NativeProgrammablewalletRnSdk.js +0 -24
  85. package/lib/commonjs/NativeProgrammablewalletRnSdk.js.map +0 -1
  86. package/lib/commonjs/ProgrammablewalletRnSdkModule.js +0 -38
  87. package/lib/commonjs/ProgrammablewalletRnSdkModule.js.map +0 -1
  88. package/lib/commonjs/WalletSdk.js +0 -206
  89. package/lib/commonjs/WalletSdk.js.map +0 -1
  90. package/lib/commonjs/index.js +0 -74
  91. package/lib/commonjs/index.js.map +0 -1
  92. package/lib/commonjs/types.js +0 -342
  93. package/lib/commonjs/types.js.map +0 -1
  94. package/lib/module/NativeProgrammablewalletRnSdk.js +0 -19
  95. package/lib/module/NativeProgrammablewalletRnSdk.js.map +0 -1
  96. package/lib/module/ProgrammablewalletRnSdkModule.js +0 -31
  97. package/lib/module/ProgrammablewalletRnSdkModule.js.map +0 -1
  98. package/lib/module/WalletSdk.js +0 -198
  99. package/lib/module/WalletSdk.js.map +0 -1
  100. package/lib/module/index.js +0 -18
  101. package/lib/module/index.js.map +0 -1
  102. package/lib/module/types.js +0 -334
  103. package/lib/module/types.js.map +0 -1
  104. package/lib/typescript/src/NativeProgrammablewalletRnSdk.d.ts +0 -28
  105. package/lib/typescript/src/NativeProgrammablewalletRnSdk.d.ts.map +0 -1
  106. package/lib/typescript/src/ProgrammablewalletRnSdkModule.d.ts +0 -3
  107. package/lib/typescript/src/ProgrammablewalletRnSdkModule.d.ts.map +0 -1
  108. package/lib/typescript/src/WalletSdk.d.ts +0 -3
  109. package/lib/typescript/src/WalletSdk.d.ts.map +0 -1
  110. package/lib/typescript/src/index.d.ts +0 -4
  111. package/lib/typescript/src/index.d.ts.map +0 -1
  112. package/lib/typescript/src/types.d.ts.map +0 -1
  113. package/src/NativeProgrammablewalletRnSdk.ts +0 -77
  114. package/src/index.tsx +0 -29
@@ -0,0 +1,397 @@
1
+ # Bare React Native Integration Guide
2
+
3
+ This guide provides step-by-step instructions for integrating the Circle User-Controlled Wallets SDK into a **bare React Native** project (projects created with `npx react-native init`, without Expo).
4
+
5
+ > [!NOTE]
6
+ > **Expo users**: If you prefer manual iOS configuration instead of using the `podfile-modifier` plugin, you can also follow this guide. However, be aware that `expo prebuild` regenerates files, requiring manual reapplication of changes.
7
+
8
+ ## System Requirements
9
+
10
+ - React Native 0.60+ (recommended 0.76-0.81)
11
+ - Node.js 16+ and npm/yarn
12
+ - Android API 21+ (recommended API 33+)
13
+ - iOS 15.1+ (recommended iOS 17+)
14
+ - CocoaPods (for iOS projects)
15
+
16
+ > [!NOTE]
17
+ > For React Native 0.82+, the `install-expo-modules` tool may not yet have version mappings available. In this case, you can manually install Expo by running `npm install expo` and following [Expo's manual installation guide](https://docs.expo.dev/bare/installing-expo-modules/).
18
+
19
+ ## Installation Steps
20
+
21
+ ### Step 1: Install Dependencies
22
+
23
+ Install the SDK package through npm:
24
+
25
+ ```bash
26
+ npm install @circle-fin/w3s-pw-react-native-sdk
27
+ ```
28
+
29
+ or yarn:
30
+
31
+ ```bash
32
+ yarn add @circle-fin/w3s-pw-react-native-sdk
33
+ ```
34
+
35
+ Then install Expo modules:
36
+
37
+ ```bash
38
+ npx install-expo-modules@latest
39
+ ```
40
+
41
+ > [!NOTE]
42
+ >
43
+ > - This command automatically installs `expo-modules-core` and configures:
44
+ > - iOS Podfile autolinking scripts
45
+ > - Android Gradle settings (`settings.gradle`)
46
+ > - Metro bundler configuration
47
+ > - Babel configuration
48
+ > - The SDK uses Expo Modules architecture for cross-platform compatibility
49
+ > - These dependencies are lightweight and do not add Expo-specific features to your app bundle
50
+ > - [Learn more about installing Expo modules in bare React Native](https://docs.expo.dev/bare/installing-expo-modules/)
51
+
52
+ ### Step 2: Configure Android
53
+
54
+ #### 2.1 Configure Circle SDK Maven Repository
55
+
56
+ > [!NOTE]
57
+ > The SDK depends on `w3s-android-sdk` hosted on GitHub Gradle registry, which requires authentication.
58
+
59
+ **Create `android/local.properties`** with your GitHub credentials:
60
+
61
+ ```properties
62
+ pwsdk.maven.url=https://maven.pkg.github.com/circlefin/w3s-android-sdk
63
+ pwsdk.maven.username=<YOUR_GITHUB_USERNAME>
64
+ pwsdk.maven.password=<YOUR_GITHUB_PAT>
65
+ ```
66
+
67
+ Get a [Personal Access Token](https://github.com/settings/tokens) with `read:packages` permission.
68
+
69
+ > [!WARNING]
70
+ > **Security**: Make sure `local.properties` is in your `.gitignore` since it contains credentials and shouldn't be committed to version control.
71
+
72
+ **Add to `android/build.gradle`** (project-level):
73
+
74
+ <details>
75
+ <summary><strong>Groovy (build.gradle)</strong></summary>
76
+
77
+ ```gradle
78
+ // --- Add imports at the top of the file ---
79
+ import java.util.Properties
80
+ import java.io.File
81
+
82
+ // --- Add inside your repositories block ---
83
+ allprojects {
84
+ repositories {
85
+ // Keep your other repositories here
86
+ // google()
87
+ // mavenCentral()
88
+
89
+ maven {
90
+ // Load credentials from local.properties (not committed to VCS)
91
+ def localPropertiesFile = new File(rootDir, "local.properties")
92
+ if (!localPropertiesFile.exists()) {
93
+ throw new GradleException(
94
+ "local.properties file not found. Please create it in the project root directory " +
95
+ "with your GitHub credentials (pwsdk.maven.url, pwsdk.maven.username, pwsdk.maven.password)"
96
+ )
97
+ }
98
+
99
+ Properties properties = new Properties()
100
+ properties.load(localPropertiesFile.newDataInputStream())
101
+
102
+ // Private Maven repo URL and basic auth credentials
103
+ url properties.getProperty('pwsdk.maven.url')
104
+ credentials {
105
+ username properties.getProperty('pwsdk.maven.username')
106
+ password properties.getProperty('pwsdk.maven.password')
107
+ }
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ </details>
114
+
115
+ <details>
116
+ <summary><strong>Kotlin (build.gradle.kts)</strong></summary>
117
+
118
+ ```kotlin
119
+ // --- Add imports at the top of the file ---
120
+ import java.util.Properties
121
+ import java.io.File
122
+
123
+ // --- Add inside your repositories block ---
124
+ allprojects {
125
+ repositories {
126
+ // Keep your other repositories here
127
+ // google()
128
+ // mavenCentral()
129
+
130
+ maven {
131
+ // Load credentials from local.properties (not committed to VCS)
132
+ val localPropertiesFile = File(rootDir, "local.properties")
133
+ if (!localPropertiesFile.exists()) {
134
+ throw GradleException(
135
+ "local.properties file not found. Please create it in the project root directory " +
136
+ "with your GitHub credentials (pwsdk.maven.url, pwsdk.maven.username, pwsdk.maven.password)"
137
+ )
138
+ }
139
+
140
+ val props = Properties().apply {
141
+ load(localPropertiesFile.inputStream())
142
+ }
143
+
144
+ // Private Maven repo URL and basic auth credentials
145
+ url = uri(props.getProperty("pwsdk.maven.url"))
146
+ credentials {
147
+ username = props.getProperty("pwsdk.maven.username")
148
+ password = props.getProperty("pwsdk.maven.password")
149
+ }
150
+ }
151
+ }
152
+ }
153
+ ```
154
+
155
+ </details>
156
+
157
+ #### 2.2 Verify Expo Modules Configuration (Optional)
158
+
159
+ Verify that `npx install-expo-modules@latest` configured the following. If any configurations are missing, add them manually or see the [Expo Modules Installation Guide](https://docs.expo.dev/bare/installing-expo-modules/) for details.
160
+
161
+ `android/settings.gradle` should include:
162
+
163
+ ```gradle
164
+ apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
165
+ useExpoModules()
166
+ ```
167
+
168
+ `android/app/build.gradle` should include:
169
+
170
+ ```gradle
171
+ apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
172
+ ```
173
+
174
+ ### Step 3: Configure iOS
175
+
176
+ This section provides manual iOS Podfile configuration. You may need to adjust these settings or merge with your existing Podfile configuration.
177
+
178
+ > [!IMPORTANT]
179
+ > **If using `expo prebuild`**: The Podfile will be regenerated each time you run `expo prebuild --clean`. Manual changes must be reapplied after each rebuild, or use the `podfile-modifier` config plugin to automate this.
180
+
181
+ **Step 1:** Add the spec repository sources and require Expo autolinking at the top of your `ios/Podfile`:
182
+
183
+ ```ruby
184
+ source 'https://github.com/circlefin/w3s-ios-sdk.git'
185
+ source 'https://github.com/CocoaPods/Specs.git'
186
+
187
+ require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
188
+ require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
189
+
190
+ platform :ios, '15.1'
191
+ ```
192
+
193
+ **Step 2:** Configure static linkage with dynamic framework exceptions (inside your target block):
194
+
195
+ ```ruby
196
+ # Prepare React Native project (add before target block)
197
+ prepare_react_native_project!
198
+
199
+ target 'YourAppName' do
200
+ # Enable Expo Modules autolinking (required for SDK)
201
+ use_expo_modules!
202
+
203
+ # Get native modules configuration
204
+ config = use_native_modules!
205
+
206
+ # Configure static frameworks (required for Circle SDK)
207
+ use_frameworks! :linkage => :static
208
+
209
+ # Configure dynamic frameworks exceptions (exceptions to static framework rule)
210
+ dynamic_frameworks = ['GoogleSignIn', 'FBSDKLoginKit', 'AppAuth', 'GTMAppAuth', 'GTMSessionFetcher']
211
+
212
+ pre_install do |installer|
213
+ installer.pod_targets.each do |target|
214
+ if dynamic_frameworks.include?(target.name)
215
+ def target.build_type
216
+ Pod::BuildType.dynamic_framework
217
+ end
218
+ end
219
+ end
220
+ end
221
+
222
+ # React Native configuration
223
+ use_react_native!(
224
+ :path => config[:reactNativePath],
225
+ # Add other React Native options as needed
226
+ )
227
+ end
228
+ ```
229
+
230
+ **Step 3:** (Optional) Add the post-install hook for build settings:
231
+
232
+ > [!TIP]
233
+ > This step is primarily for **bare React Native projects**. If you encounter build issues such as architecture mismatches, module stability warnings, or deployment target version conflicts, add this configuration. If your project already has a `post_install` hook, merge these settings into it.
234
+
235
+ ```ruby
236
+ post_install do |installer|
237
+ installer.pods_project.targets.each do |target|
238
+ target.build_configurations.each do |config|
239
+ config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
240
+ config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
241
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.1'
242
+ end
243
+ end
244
+ end
245
+ ```
246
+
247
+ **Step 4:** Run `pod install`
248
+
249
+ ```shell
250
+ cd ios && pod install && cd ..
251
+ ```
252
+
253
+ ### Step 4: Verify Configuration (Optional)
254
+
255
+ After running `npx install-expo-modules@latest`, these configurations should be set up automatically. Verify them and add manually if missing.
256
+
257
+ #### Verify Metro Bundler Configuration
258
+
259
+ `metro.config.js` should include:
260
+
261
+ ```javascript
262
+ const { getDefaultConfig } = require('expo/metro-config')
263
+
264
+ const config = getDefaultConfig(__dirname)
265
+
266
+ module.exports = config
267
+ ```
268
+
269
+ #### Verify Babel Configuration
270
+
271
+ `babel.config.js` should include:
272
+
273
+ ```javascript
274
+ module.exports = function (api) {
275
+ api.cache(true)
276
+ return {
277
+ presets: ['babel-preset-expo'],
278
+ }
279
+ }
280
+ ```
281
+
282
+ ### Step 5: Run Your App
283
+
284
+ Build and run your app:
285
+
286
+ For iOS:
287
+
288
+ ```bash
289
+ npx react-native run-ios
290
+ ```
291
+
292
+ For Android:
293
+
294
+ ```bash
295
+ npx react-native run-android
296
+ ```
297
+
298
+ Learn more about [Running On Device](https://reactnative.dev/docs/running-on-device).
299
+
300
+ ## Troubleshooting
301
+
302
+ ### Installation Issues
303
+
304
+ **Issue**: `npx install-expo-modules@latest` fails with "Unable to find compatible Expo SDK version"
305
+
306
+ - **Cause**: This occurs when using a very recent React Native version (e.g., 0.82+) that hasn't been added to the `install-expo-modules` tool's version mapping yet.
307
+ - **Solution**:
308
+ - Option 1: Use a tested React Native version (0.76-0.81) for the smoothest setup experience
309
+ - Option 2: Manually install Expo modules:
310
+ ```bash
311
+ npm install expo
312
+ ```
313
+ Then follow [Expo's manual installation guide](https://docs.expo.dev/bare/installing-expo-modules/) to configure your iOS and Android projects.
314
+
315
+ **Issue**: `npx install-expo-modules@latest` fails with other errors
316
+
317
+ - **Solution**: Ensure Node.js 16+ is installed. Try clearing npm cache: `npm cache clean --force`
318
+
319
+ ### Android Build Issues
320
+
321
+ **Issue**: `expo-modules-core` not found
322
+
323
+ - **Solution**:
324
+ - Run `npx install-expo-modules@latest` again
325
+ - Verify `android/settings.gradle` includes Expo autolinking configuration
326
+ - Clean and rebuild: `cd android && ./gradlew clean && cd ..`
327
+
328
+ **Issue**: Maven repository authentication failed
329
+
330
+ - **Solution**:
331
+ - Verify your `local.properties` file has correct GitHub credentials
332
+ - Ensure your GitHub Personal Access Token has `read:packages` permission
333
+ - Ensure the `local.properties` file is present in the `android/` directory for local builds. This file must be added to your project's `.gitignore` file to prevent committing credentials to version control.
334
+
335
+ **Issue**: Duplicate class errors
336
+
337
+ - **Solution**: Clean Gradle cache and rebuild:
338
+
339
+ ```bash
340
+ cd android
341
+ ./gradlew clean
342
+ cd ..
343
+ ```
344
+
345
+ If the issue persists, also clear the Gradle cache:
346
+
347
+ ```bash
348
+ rm -rf ~/.gradle/caches/
349
+ ```
350
+
351
+ ### iOS Build Issues
352
+
353
+ **Issue**: `ExpoModulesCore` pod not found
354
+
355
+ - **Solution**:
356
+ - Run `npx install-expo-modules@latest` again
357
+ - Ensure `require` statements are added at the top of Podfile
358
+ - Run `pod repo update` then `pod install`
359
+ - Delete `ios/Pods` and `ios/Podfile.lock`, then run `pod install` again
360
+
361
+ **Issue**: Static framework conflicts
362
+
363
+ - **Solution**: Ensure `use_frameworks! :linkage => :static` is configured correctly with dynamic framework exceptions as shown in Step 3
364
+
365
+ **Issue**: CocoaPods installation fails with Circle SDK repository error
366
+
367
+ - **Solution**:
368
+ - Verify the Circle SDK repository source is added at the top of Podfile
369
+ - Run `pod repo update`
370
+ - Check your internet connection
371
+
372
+ **Issue**: Build fails with "Module 'ExpoModulesCore' not found"
373
+
374
+ - **Solution**:
375
+ - Ensure `use_expo_modules!` is called in your Podfile before `use_react_native!`
376
+ - Clean build folder in Xcode: Product → Clean Build Folder
377
+ - Delete `ios/build` folder and rebuild
378
+
379
+ ### Metro Bundler Issues
380
+
381
+ **Issue**: Module not found errors or cache issues
382
+
383
+ - **Solution**: Clear Metro cache:
384
+ ```bash
385
+ npx react-native start --reset-cache
386
+ ```
387
+
388
+ **Issue**: "Unable to resolve module" errors
389
+
390
+ - **Solution**:
391
+ - Ensure `metro.config.js` is configured correctly
392
+ - Clear Metro cache and reinstall dependencies:
393
+ ```bash
394
+ rm -rf node_modules
395
+ npm install
396
+ npx react-native start --reset-cache
397
+ ```
package/LICENSE CHANGED
@@ -175,7 +175,7 @@
175
175
 
176
176
  END OF TERMS AND CONDITIONS
177
177
 
178
- © 2024, Circle Internet Financial, LTD. All rights reserved.
178
+ © 2024-2025, Circle Internet Financial, LTD. All rights reserved.
179
179
 
180
180
  Licensed under the Apache License, Version 2.0 (the "License");
181
181
  you may not use this file except in compliance with the License.