@circle-fin/w3s-pw-react-native-sdk 1.1.7 → 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 -116
  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 -159
  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 -390
  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 -211
  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 -203
  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,132 @@
1
+ /**
2
+ * Copyright 2025 Circle Internet Group, Inc. All rights reserved.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ const {
20
+ withXcodeProject,
21
+ withProjectBuildGradle,
22
+ } = require('@expo/config-plugins')
23
+ const fs = require('fs')
24
+ const path = require('path')
25
+
26
+ function ensureDir(dir) {
27
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
28
+ }
29
+
30
+ function copyFile(srcPath, dstPath, overwrite = true) {
31
+ ensureDir(path.dirname(dstPath))
32
+ if (!overwrite && fs.existsSync(dstPath)) {
33
+ console.log(`[withCopyFiles] Skipped (exists): ${dstPath}`)
34
+ return
35
+ }
36
+ fs.copyFileSync(srcPath, dstPath)
37
+ console.log(`[withCopyFiles] Copied: ${srcPath} -> ${dstPath}`)
38
+ }
39
+
40
+ function copyDirRecursive(srcDir, dstDir, overwrite = true, excludeFiles = []) {
41
+ if (!fs.existsSync(srcDir)) return
42
+ const entries = fs.readdirSync(srcDir, { withFileTypes: true })
43
+ for (const entry of entries) {
44
+ const s = path.join(srcDir, entry.name)
45
+ const d = path.join(dstDir, entry.name)
46
+
47
+ // Skip excluded files
48
+ if (excludeFiles.includes(entry.name)) {
49
+ console.log(`[withCopyFiles] Skipped (excluded): ${s}`)
50
+ continue
51
+ }
52
+
53
+ if (entry.isDirectory()) {
54
+ copyDirRecursive(s, d, overwrite, excludeFiles)
55
+ } else {
56
+ copyFile(s, d, overwrite)
57
+ }
58
+ }
59
+ }
60
+
61
+ function runCopyPlatform(
62
+ config,
63
+ { sourceDir, overwrite, platform, excludeFiles = [] },
64
+ ) {
65
+ const projectRoot = config.modRequest.projectRoot
66
+
67
+ // Expect source layout:
68
+ // <sourceDir>/
69
+ // android/ -> will sync into <projectRoot>/android/
70
+ // ios/ -> will sync into <projectRoot>/ios/
71
+ const srcRoot = path.resolve(projectRoot, sourceDir, platform)
72
+ const dstRoot = path.resolve(projectRoot, platform)
73
+
74
+ if (!fs.existsSync(srcRoot)) {
75
+ console.log(`[withCopyFiles] No ${platform} source folder: ${srcRoot}`)
76
+ return config
77
+ }
78
+
79
+ try {
80
+ console.log(`[withCopyFiles] Syncing ${platform}…`)
81
+ copyDirRecursive(srcRoot, dstRoot, overwrite, excludeFiles)
82
+ } catch (error) {
83
+ error.message = `[withCopyFiles] Error during file synchronization for ${platform}: ${error.message}`
84
+ throw error
85
+ }
86
+ return config
87
+ }
88
+
89
+ const withCopyFiles = (
90
+ config,
91
+ { sourceDir = 'prebuild-sync-src', overwrite = true } = {},
92
+ ) => {
93
+ // iOS
94
+ config = withXcodeProject(config, cfg => {
95
+ console.log('[withCopyFiles] iOS stage (withXcodeProject)')
96
+ return runCopyPlatform(cfg, { sourceDir, overwrite, platform: 'ios' })
97
+ })
98
+
99
+ // Android
100
+ config = withProjectBuildGradle(config, cfg => {
101
+ console.log('[withCopyFiles] Android stage (withProjectBuildGradle)')
102
+
103
+ const projectRoot = cfg.modRequest.projectRoot
104
+ const srcBuildGradle = path.resolve(
105
+ projectRoot,
106
+ sourceDir,
107
+ 'android',
108
+ 'build.gradle',
109
+ )
110
+
111
+ // Special handling for build.gradle: update modResults.contents instead of direct file copy
112
+ if (fs.existsSync(srcBuildGradle)) {
113
+ const buildGradleContents = fs.readFileSync(srcBuildGradle, 'utf8')
114
+ cfg.modResults.contents = buildGradleContents
115
+ console.log(
116
+ `[withCopyFiles] Updated build.gradle contents from: ${srcBuildGradle}`,
117
+ )
118
+ }
119
+
120
+ // Copy other Android files (excluding build.gradle which is handled above)
121
+ return runCopyPlatform(cfg, {
122
+ sourceDir,
123
+ overwrite,
124
+ platform: 'android',
125
+ excludeFiles: ['build.gradle'],
126
+ })
127
+ })
128
+
129
+ return config
130
+ }
131
+
132
+ module.exports = withCopyFiles
@@ -0,0 +1,81 @@
1
+ # Copy Files Plugin
2
+
3
+ Config plugin to **copy entire platform folders** (`android/`, `ios/`) from a source directory into your generated native project during prebuild.
4
+ Any files or folders present under `<sourceDir>/android` or `<sourceDir>/ios` will be copied recursively.
5
+
6
+ ---
7
+
8
+ ## Features
9
+
10
+ - Recursively copy files under `<sourceDir>/android` → `android/` and `<sourceDir>/ios` → `ios/`
11
+ - Automatically creates target folders if they don’t exist
12
+ - Supports **overwrite control** (`overwrite: true` or `false`)
13
+ - Works during the **Expo prebuild** process
14
+
15
+ ---
16
+
17
+ ## Usage
18
+
19
+ ### 1. Configure in `app.json` or `app.config.ts`
20
+
21
+ ```json
22
+ {
23
+ "expo": {
24
+ "plugins": [
25
+ [
26
+ "@circle-fin/w3s-pw-react-native-sdk/plugins/withCopyFiles",
27
+ {
28
+ "sourceDir": "prebuild-sync-src",
29
+ "overwrite": true
30
+ }
31
+ ]
32
+ ]
33
+ }
34
+ }
35
+ ```
36
+
37
+ > `sourceDir` is the path defined in your `app.json` or `app.config.js` under `expo.plugins` block, located within your project root.
38
+ > Inside it, you can have both `android/` and `ios/` subfolders.
39
+
40
+ ---
41
+
42
+ ### 2. Directory structure example
43
+
44
+ ```
45
+ prebuild-sync-src/
46
+ android/
47
+ app/build.gradle
48
+ app/src/main/res/values/strings.xml
49
+ ios/
50
+ YourApp/Info.plist
51
+ YourApp/CustomFile.m
52
+ ```
53
+
54
+ Anything under these subfolders will be copied into your generated `android/` or `ios/` directories.
55
+
56
+ ---
57
+
58
+ ### 3. Run prebuild
59
+
60
+ ```bash
61
+ npx expo prebuild
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Configuration Options
67
+
68
+ | Option | Default | Description |
69
+ | ----------- | --------------------- | --------------------------------------------------------------------------------------------------------- |
70
+ | `sourceDir` | `"prebuild-sync-src"` | Root directory containing your `android/` and/or `ios/` folders to copy |
71
+ | `overwrite` | `true` | Whether to overwrite existing files in the target location (`false` will skip if the file already exists) |
72
+
73
+ ---
74
+
75
+ ## Notes
76
+
77
+ - The plugin performs **one-way copy**: source → project native folders.
78
+ Removing files from the source won’t delete them in the target.
79
+ - Removing the plugin and running `expo prebuild --clean` restores native folders to their default state.
80
+ - Designed to be **idempotent** — running multiple times won’t duplicate files.
81
+ - Works seamlessly with EAS Build and local `expo prebuild`.
@@ -1,41 +1,71 @@
1
- // Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
2
- //
3
- // SPDX-License-Identifier: Apache-2.0
4
- //
5
- // Licensed under the Apache License, Version 2.0 (the "License");
6
- // you may not use this file except in compliance with the License.
7
- // You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing, software
12
- // distributed under the License is distributed on an "AS IS" BASIS,
13
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- // See the License for the specific language governing permissions and
15
- // limitations under the License.
16
- import { NativeModules, Platform } from 'react-native'
1
+ /**
2
+ * Copyright 2025 Circle Internet Group, Inc. All rights reserved.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
17
18
 
18
- const LINKING_ERROR =
19
- `The package '@circle-fin/w3s-pw-react-native-sdk' doesn't seem to be linked. Make sure: \n\n` +
20
- Platform.select({ ios: '- You have run \'pod install\'\n', default: '' }) +
21
- '- You rebuilt the app after installing the package\n' +
22
- '- You are not using Expo Go\n'
19
+ import { NativeModule, requireNativeModule } from 'expo-modules-core'
20
+ import {
21
+ ProgrammablewalletRnSdkModuleEvents,
22
+ Configuration,
23
+ DateFormat,
24
+ SuccessResult,
25
+ LoginResult,
26
+ SecurityQuestion,
27
+ TextConfig,
28
+ } from './types'
23
29
 
24
- // @ts-expect-error
25
- const isTurboModuleEnabled = global.__turboModuleProxy != null
30
+ declare class ProgrammablewalletRnSdkModule extends NativeModule<ProgrammablewalletRnSdkModuleEvents> {
31
+ sdkVersion: string
32
+ getDeviceId(): string
33
+ initSdk(configuration: Configuration): Promise<void>
34
+ setSecurityQuestions(securityQuestions: SecurityQuestion[]): void
35
+ execute(
36
+ userToken: string | null,
37
+ encryptionKey: string | null,
38
+ challengeIds: string[],
39
+ ): Promise<SuccessResult>
40
+ verifyOTP(
41
+ otpToken: string | null,
42
+ deviceToken: string | null,
43
+ deviceEncryptionKey: string | null,
44
+ ): Promise<LoginResult>
45
+ performLogin(
46
+ provider: string,
47
+ deviceToken: string,
48
+ deviceEncryptionKey: string,
49
+ ): Promise<LoginResult>
50
+ performLogout(provider: string): Promise<void>
51
+ setBiometricsPin(
52
+ userToken: string | null,
53
+ encryptionKey: string | null,
54
+ ): Promise<SuccessResult>
55
+ setDismissOnCallbackMap(map: Record<string, boolean>): void
56
+ moveTaskToFront(): void
57
+ moveRnTaskToFront(): void
58
+ setTextConfigsMap(map: Record<string, unknown[]>): void
59
+ setIconTextConfigsMap(map: Record<string, unknown>): void
60
+ setTextConfigMap(map: Record<string, TextConfig>): void
61
+ setImageMap(map: Record<string, string>): void
62
+ setDateFormat(format: DateFormat): void
63
+ setDebugging(debugging: boolean): void
64
+ setCustomUserAgent(userAgent: string): void
65
+ setErrorStringMap(map: Record<string, string>): void
66
+ }
26
67
 
27
- const programmablewalletRnSdkModule = isTurboModuleEnabled
28
- ? require('./NativeProgrammablewalletRnSdk').default
29
- : NativeModules.ProgrammablewalletRnSdk
30
-
31
- const WalletSdkModule = programmablewalletRnSdkModule
32
- ? programmablewalletRnSdkModule
33
- : new Proxy(
34
- {},
35
- {
36
- get() {
37
- throw new Error(LINKING_ERROR)
38
- },
39
- },
40
- )
41
- export default WalletSdkModule
68
+ // This call loads the native module object from the JSI.
69
+ export default requireNativeModule<ProgrammablewalletRnSdkModule>(
70
+ 'ProgrammablewalletRnSdk',
71
+ )