@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,109 @@
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
+ import { SecurityQuestion, InputType } from '../types';
19
+ /**
20
+ * Extract string representation from unknown value
21
+ * @param value - Value to convert to string
22
+ * @returns String representation
23
+ */
24
+ export function getStringFromUnknown(value) {
25
+ if (value === null || value === undefined)
26
+ return '';
27
+ if (typeof value === 'object' && value !== null) {
28
+ const obj = value;
29
+ if ('name' in obj && typeof obj.name === 'string') {
30
+ return obj.name;
31
+ }
32
+ }
33
+ return typeof value?.toString === 'function' ? value.toString() : '';
34
+ }
35
+ /**
36
+ * Normalize various input types to InputType enum values
37
+ * @param v - Input value to normalize
38
+ * @returns Normalized InputType or undefined
39
+ */
40
+ export function normalizeInputType(v) {
41
+ if (v == null)
42
+ return undefined;
43
+ if (v === InputType.text || v === InputType.datePicker) {
44
+ return v;
45
+ }
46
+ if (typeof v === 'string') {
47
+ const s = v.toLowerCase();
48
+ if (s.includes('date') || s.includes('birth'))
49
+ return InputType.datePicker;
50
+ if (s !== 'text' && s !== '') {
51
+ console.warn(`[WalletSdk] Unexpected inputType string: "${v}", using default "text"`);
52
+ }
53
+ return InputType.text;
54
+ }
55
+ if (typeof v === 'number') {
56
+ if (v === 1)
57
+ return InputType.datePicker;
58
+ if (v !== 0) {
59
+ console.warn(`[WalletSdk] Unexpected inputType number: ${v}, using default "text"`);
60
+ }
61
+ return InputType.text;
62
+ }
63
+ const hint = getStringFromUnknown(v).toLowerCase();
64
+ if (hint.includes('date'))
65
+ return InputType.datePicker;
66
+ if (v !== null && v !== undefined) {
67
+ console.warn(`[WalletSdk] Unexpected inputType: ${typeof v}, using default "text"`);
68
+ }
69
+ return InputType.text;
70
+ }
71
+ /**
72
+ * Convert security question input to standardized SecurityQuestion object
73
+ *
74
+ * Supports three input formats:
75
+ * 1. Tuple [title, inputType]
76
+ * 2. Object {title, inputType}
77
+ * 3. String or other primitive
78
+ *
79
+ * @param q - Security question input (any type)
80
+ * @returns Standardized SecurityQuestion instance
81
+ */
82
+ export function toPlainSecurityQuestion(q) {
83
+ const securityQuestion = new SecurityQuestion('', InputType.text);
84
+ if (Array.isArray(q)) {
85
+ // Handle array/tuple format: [title, inputType]
86
+ const [title, it] = q;
87
+ securityQuestion.title = String(title || '');
88
+ securityQuestion.inputType = normalizeInputType(it) ?? InputType.text;
89
+ }
90
+ else if (q && typeof q === 'object') {
91
+ // Handle object/class instances
92
+ const o = q;
93
+ securityQuestion.title = String(o.title ||
94
+ o.Title ||
95
+ (typeof o.getTitle === 'function' ? o.getTitle() : undefined) ||
96
+ '');
97
+ const inputTypeRaw = o.inputType ||
98
+ o.InputType ||
99
+ (typeof o.getInputType === 'function' ? o.getInputType() : undefined);
100
+ securityQuestion.inputType = normalizeInputType(inputTypeRaw) ?? InputType.text;
101
+ }
102
+ else {
103
+ // Handle string or other primitive
104
+ securityQuestion.title = String(q || '');
105
+ securityQuestion.inputType = InputType.text;
106
+ }
107
+ return securityQuestion;
108
+ }
109
+ //# sourceMappingURL=securityQuestionUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"securityQuestionUtils.js","sourceRoot":"","sources":["../../src/utils/securityQuestionUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEtD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAC/C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IAEpD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,KAAgC,CAAA;QAC5C,IAAI,MAAM,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAChD,OAAO,GAAG,CAAC,IAAI,CAAA;QACnB,CAAC;IACL,CAAC;IACD,OAAO,OAAO,KAAK,EAAE,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACxE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAU;IACzC,IAAI,CAAC,IAAI,IAAI;QAAE,OAAO,SAAS,CAAA;IAE/B,IAAI,CAAC,KAAK,SAAS,CAAC,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC,UAAU,EAAE,CAAC;QACr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: Apache-2.0\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SecurityQuestion, InputType } from '../types'\n\n/**\n * Extract string representation from unknown value\n * @param value - Value to convert to string\n * @returns String representation\n */\nexport function getStringFromUnknown(value: unknown): string {\n if (value === null || value === undefined) return ''\n\n if (typeof value === 'object' && value !== null) {\n const obj = value as Record<string, unknown>\n if ('name' in obj && typeof obj.name === 'string') {\n return obj.name\n }\n }\n return typeof value?.toString === 'function' ? value.toString() : ''\n}\n\n/**\n * Normalize various input types to InputType enum values\n * @param v - Input value to normalize\n * @returns Normalized InputType or undefined\n */\nexport function normalizeInputType(v: unknown): InputType | undefined {\n if (v == null) return undefined\n\n if (v === InputType.text || v === InputType.datePicker) {\n return v\n }\n\n if (typeof v === 'string') {\n const s = v.toLowerCase()\n if (s.includes('date') || s.includes('birth')) return InputType.datePicker\n if (s !== 'text' && s !== '') {\n console.warn(`[WalletSdk] Unexpected inputType string: \"${v}\", using default \"text\"`)\n }\n return InputType.text\n }\n\n if (typeof v === 'number') {\n if (v === 1) return InputType.datePicker\n if (v !== 0) {\n console.warn(`[WalletSdk] Unexpected inputType number: ${v}, using default \"text\"`)\n }\n return InputType.text\n }\n\n const hint = getStringFromUnknown(v).toLowerCase()\n if (hint.includes('date')) return InputType.datePicker\n\n if (v !== null && v !== undefined) {\n console.warn(`[WalletSdk] Unexpected inputType: ${typeof v}, using default \"text\"`)\n }\n\n return InputType.text\n}\n\n/**\n * Convert security question input to standardized SecurityQuestion object\n * \n * Supports three input formats:\n * 1. Tuple [title, inputType]\n * 2. Object {title, inputType}\n * 3. String or other primitive\n * \n * @param q - Security question input (any type)\n * @returns Standardized SecurityQuestion instance\n */\nexport function toPlainSecurityQuestion(q: unknown): SecurityQuestion {\n const securityQuestion = new SecurityQuestion('', InputType.text)\n\n if (Array.isArray(q)) {\n // Handle array/tuple format: [title, inputType]\n const [title, it] = q\n securityQuestion.title = String(title || '')\n securityQuestion.inputType = normalizeInputType(it) ?? InputType.text\n }\n else if (q && typeof q === 'object') {\n // Handle object/class instances\n const o = q as Record<string, unknown>\n securityQuestion.title = String(\n o.title ||\n o.Title ||\n (typeof o.getTitle === 'function' ? o.getTitle() : undefined) ||\n '',\n )\n\n const inputTypeRaw =\n o.inputType ||\n o.InputType ||\n (typeof o.getInputType === 'function' ? o.getInputType() : undefined)\n\n securityQuestion.inputType = normalizeInputType(inputTypeRaw) ?? InputType.text\n }\n else {\n // Handle string or other primitive\n securityQuestion.title = String(q || '')\n securityQuestion.inputType = InputType.text\n }\n\n return securityQuestion\n}\n"]}
@@ -0,0 +1,11 @@
1
+ {
2
+ "platforms": ["apple", "android"],
3
+ "apple": {
4
+ "modules": ["ProgrammablewalletRnSdkModule"]
5
+ },
6
+ "android": {
7
+ "modules": [
8
+ "com.circlefin.programmablewalletrnsdk.ProgrammablewalletRnSdkModule"
9
+ ]
10
+ }
11
+ }
@@ -1,18 +1,20 @@
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.
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
+ */
16
18
 
17
19
  import Foundation
18
20
 
@@ -1,45 +1,38 @@
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.
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
+ */
16
18
 
17
19
  import Foundation
18
20
  import CircleProgrammableWalletSDK
19
21
 
20
- class BridgeHelper: NSObject {
21
-
22
- static func getSecurityQuestions(_ rnQuestions: NSArray) -> [SecurityQuestion] {
23
-
22
+ class BridgeHelper {
23
+
24
+ static func getSecurityQuestions(_ rnQuestions: [[String: Any]]) -> [SecurityQuestion] {
25
+
24
26
  func getInputType(_ string: String?) -> SecurityQuestion.InputType {
25
- if string == "datePicker" {
26
- return .datePicker
27
- }
28
- return .text
27
+ return string == "datePicker" ? .datePicker : .text
29
28
  }
30
-
31
- var questions: [SecurityQuestion] = []
32
- for e in rnQuestions {
33
- if let e = e as? [String: Any],
34
- let title = e["title"] as? String {
35
- let question = SecurityQuestion(title: title,
36
- inputType: getInputType(e["inputType"] as? String))
37
- questions.append(question)
38
- }
29
+
30
+ return rnQuestions.compactMap { e in
31
+ guard let title = e["title"] as? String else { return nil }
32
+ return SecurityQuestion(title: title, inputType: getInputType(e["inputType"] as? String))
39
33
  }
40
- return questions
41
34
  }
42
-
35
+
43
36
  static func getImageKey(rnKey: String) -> ImageStore.Img? {
44
37
  switch rnKey {
45
38
  case "close": return .naviClose
@@ -60,27 +53,23 @@ class BridgeHelper: NSObject {
60
53
  default: return nil
61
54
  }
62
55
  }
63
-
64
- static func getSecurityConfirmItemAndConfigs(_ rnDic: NSDictionary) -> ([SecurityConfirmItem], [TextConfig]) {
56
+
57
+ static func getSecurityConfirmItemAndConfigs(_ rnDic: [String: Any]) -> ([SecurityConfirmItem], [TextConfig]) {
65
58
  var items: [SecurityConfirmItem] = []
66
59
  var textConfigs: [TextConfig] = []
67
- if let rnItems = rnDic[IconTextsKey.securityConfirmationItems.rawValue] as? NSArray {
60
+ if let rnItems = rnDic[IconTextsKey.securityConfirmationItems.rawValue] as? [[String: Any]] {
68
61
  for e in rnItems {
69
- guard let e = e as? [String: Any],
70
- let dict = e["textConfig"] as? [String: Any] else { continue }
71
-
62
+ guard let dict = e["textConfig"] as? [String: Any] else { continue }
63
+
72
64
  let textConfig = getTextConfig(dict)
73
65
  if let text = textConfig.text {
74
66
  if let image = e["image"] as? String {
75
67
  if image.starts(with: "http") {
76
68
  items.append(SecurityConfirmItem(image: nil, imageUrl: URL(string: image), text: text))
77
- } else {
78
- var url = URL(string: image)
79
- if let url = url {
80
- items.append(SecurityConfirmItem(image: UIImage(contentsOfFile: url.path), text: text))
81
- }
69
+ } else if let url = URL(string: image) {
70
+ items.append(SecurityConfirmItem(image: UIImage(contentsOfFile: url.path), text: text))
82
71
  }
83
- } else{
72
+ } else {
84
73
  items.append(SecurityConfirmItem(text: text))
85
74
  }
86
75
  textConfigs.append(textConfig)
@@ -89,63 +78,59 @@ class BridgeHelper: NSObject {
89
78
  }
90
79
  return (items, textConfigs)
91
80
  }
92
-
93
- static func getTextsMap(_ rnDic: NSDictionary) -> [TextsKey: [TextConfig]] {
94
- var map: [TextsKey: [TextConfig]] = [:]
81
+
82
+ static func getTextMap(_ rnDic: [String: Any]) -> [TextKey: TextConfig] {
83
+ var map: [TextKey: TextConfig] = [:]
95
84
  for (key, value) in rnDic {
96
- guard let key = key as? String,
97
- let textsKey = TextsKey(rawValue: key),
98
- let value = value as? [[String: Any]] else { continue }
99
-
100
- let array: [TextConfig] = value.compactMap { getTextConfig($0) }
101
- map[textsKey] = array
85
+ guard let textKey = TextKey(rawValue: key),
86
+ let v = value as? [String: Any] else { continue }
87
+
88
+ map[textKey] = getTextConfig(v)
102
89
  }
103
90
  return map
104
91
  }
105
-
106
- static func getTextMap(_ rnDic: NSDictionary) -> [TextKey: TextConfig] {
107
- var map: [TextKey: TextConfig] = [:]
92
+
93
+ static func getTextsMap(_ rnDic: [String: Any]) -> [TextsKey: [TextConfig]] {
94
+ var map: [TextsKey: [TextConfig]] = [:]
108
95
  for (key, value) in rnDic {
109
- guard let key = key as? String,
110
- let textKey = TextKey(rawValue: key),
111
- let v = value as? [String: Any] else { continue }
112
-
113
- map[textKey] = getTextConfig(v)
96
+ guard let textsKey = TextsKey(rawValue: key),
97
+ let value = value as? [[String: Any]] else { continue }
98
+
99
+ let array: [TextConfig] = value.compactMap { getTextConfig($0) }
100
+ map[textsKey] = array
114
101
  }
115
102
  return map
116
103
  }
117
-
118
- static func getDismissOnCallbackMap(_ rnDic: NSDictionary) -> [Int: Bool] {
104
+
105
+ static func getDismissOnCallbackMap(_ rnDic: [String: Bool]) -> [Int: Bool] {
119
106
  var map: [Int: Bool] = [:]
120
107
  for (key, value) in rnDic {
121
- guard let key = key as? String,
122
- let intKey = Int(key),
123
- let v = value as? Bool else { continue }
124
- map[intKey] = v
108
+ if let intKey = Int(key) {
109
+ map[intKey] = value
110
+ }
125
111
  }
126
112
  return map
127
113
  }
128
114
 
129
- public static func getErrorStringMap(_ rnDic: NSDictionary) -> [Int: String] {
115
+ static func getErrorStringMap(_ rnDic: [String: String]) -> [Int: String] {
130
116
  var map: [Int: String] = [:]
131
117
  for (key, value) in rnDic {
132
- guard let key = key as? String,
133
- let intKey = Int(key),
134
- let v = value as? String else { continue }
135
- map[intKey] = v
118
+ if let intKey = Int(key) {
119
+ map[intKey] = value
120
+ }
136
121
  }
137
122
  return map
138
123
  }
139
124
 
140
- public static func getErrorString(_ code: Int, _ errorStr: String?, _ textMap: [TextKey: TextConfig]) -> String?{
125
+ static func getErrorString(_ code: Int, _ errorStr: String?, _ textMap: [TextKey: TextConfig]) -> String?{
141
126
  var constMap: [Int: [String]] = [:]
142
- constMap[ApiError.ErrorCode.incorrectUserPin.rawValue] = ["The PIN you entered is incorrect.",
127
+ constMap[ApiError.ErrorCode.incorrectUserPin.rawValue] = ["The PIN you entered is incorrect.",
143
128
  "You have %@ attempts left.",
144
129
  TextKey.circlepw_pin_remain_attemps_template.rawValue]
145
- constMap[ApiError.ErrorCode.incorrectSecurityAnswers.rawValue] = ["The answers you entered are incorrect.",
130
+ constMap[ApiError.ErrorCode.incorrectSecurityAnswers.rawValue] = ["The answers you entered are incorrect.",
146
131
  "You have %@ attempts left",
147
132
  TextKey.circlepw_answer_remain_attemps_template.rawValue]
148
- constMap[ApiError.ErrorCode.userPinLocked.rawValue] = ["You’ve used up all PIN attempts.",
133
+ constMap[ApiError.ErrorCode.userPinLocked.rawValue] = ["You’ve used up all PIN attempts.",
149
134
  "Please wait for %@ mins to retry later.",
150
135
  TextKey.circlepw_pin_lock_period_template.rawValue]
151
136
  constMap[ApiError.ErrorCode.securityAnswersLocked.rawValue] = ["The answers you entered are incorrect.",
@@ -154,33 +139,27 @@ class BridgeHelper: NSObject {
154
139
  guard let textKey = TextKey(rawValue: constMap[code]?[safe: 2] ?? "") else { return errorStr }
155
140
  let textConfig: TextConfig? = textMap[textKey]
156
141
  let configText = textConfig?.text ?? constMap[code]?[safe: 1]
157
-
142
+
158
143
  guard let text = configText else { return errorStr }
159
144
  if let errStr = errorStr {
160
145
  return "\(errStr) \(text)"
161
- } else{
162
- if let errStr = constMap[code]?[safe: 0] {
163
- return "\(errStr) \(text)"
164
- } else{
165
- return "\(text)"
166
- }
146
+ } else {
147
+ return constMap[code]?[safe: 0].map { "\($0) \(text)" } ?? text
167
148
  }
168
149
  }
169
150
  }
170
151
 
171
152
  extension BridgeHelper {
172
-
173
- private static func getTextConfig(_ dict: [String: Any]) -> TextConfig {
153
+
154
+ private static func getTextConfig(_ dict: [String: Any]) -> TextConfig {
174
155
  var textConfig = TextConfig(text: dict["text"] as? String,
175
156
  textColor: dict["textColor"] as? String,
176
157
  gradientColors: nil,
177
158
  font: dict["font"] as? String)
178
-
179
- if let gradientColors = dict["gradientColors"] as? NSArray {
180
- let colors: [String] = gradientColors.compactMap { $0 as? String }
181
- textConfig.gradientColors = colors
159
+
160
+ if let gradientColors = dict["gradientColors"] as? [String] {
161
+ textConfig.gradientColors = gradientColors
182
162
  }
183
163
  return textConfig
184
164
  }
185
-
186
165
  }
@@ -1,23 +1,25 @@
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.
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
+ */
16
18
 
17
19
  import Foundation
18
20
  import CircleProgrammableWalletSDK
19
21
 
20
- extension RNWalletSdk {
22
+ extension ProgrammablewalletRnSdkModule {
21
23
 
22
24
  func customizeAdapter(controller: UIViewController) {
23
25
 
@@ -469,7 +471,7 @@ extension RNWalletSdk {
469
471
  }
470
472
  }
471
473
 
472
- extension RNWalletSdk {
474
+ extension ProgrammablewalletRnSdkModule {
473
475
 
474
476
  private func setText(label: UILabel, textConfig: TextConfig, shouldReplaceText: Bool = true) {
475
477
  if let text = textConfig.text, shouldReplaceText {
@@ -525,15 +527,3 @@ extension RNWalletSdk {
525
527
  }
526
528
  }
527
529
  }
528
-
529
- private extension UITextField {
530
-
531
- func placeholderColor(color: UIColor) {
532
- guard let placeholder = self.placeholder, let font = self.font else { return }
533
- let attributeString = [
534
- .foregroundColor: color,
535
- .font: font,
536
- ] as [NSAttributedString.Key: Any]
537
- self.attributedPlaceholder = NSAttributedString(string: placeholder, attributes: attributeString)
538
- }
539
- }
@@ -0,0 +1,30 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'ProgrammablewalletRnSdk'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.description = package['description']
10
+ s.license = package['license']
11
+ s.author = package['author']
12
+ s.homepage = package['homepage']
13
+ s.platforms = {
14
+ :ios => '15.1',
15
+ :tvos => '15.1'
16
+ }
17
+ s.swift_version = '5.0'
18
+ s.source = { git: 'https://github.com/circlefin/w3s-react-native-sdk.git' }
19
+ s.static_framework = true
20
+
21
+ s.dependency 'ExpoModulesCore'
22
+ s.dependency 'CircleProgrammableWalletSDK_static', '1.1.9'
23
+
24
+ # Swift/Objective-C compatibility
25
+ s.pod_target_xcconfig = {
26
+ 'DEFINES_MODULE' => 'YES',
27
+ }
28
+
29
+ s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
30
+ end