@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,303 @@
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 { bridgeSafe } from './bridgeSafe';
19
+ const packageJson = require('../package.json');
20
+ import ProgrammablewalletRnSdk from './ProgrammablewalletRnSdkModule';
21
+ import { Image } from 'react-native';
22
+ // SDK event identifiers
23
+ const EVENT_NAME_ON_SUCCESS = 'CirclePwOnSuccess';
24
+ const EVENT_NAME_ON_ERROR = 'CirclePwOnError';
25
+ const USER_AGENT_RN = 'Circle-Programmable-Wallet-SDK-RN';
26
+ /**
27
+ * Resolves React Native image sources to URI strings for native bridge
28
+ * @param source - React Native image source
29
+ * @returns Resolved URI string or null
30
+ */
31
+ function getImageUrl(source) {
32
+ if (!source) {
33
+ return null;
34
+ }
35
+ const resolved = Image.resolveAssetSource(source);
36
+ if (!resolved ||
37
+ typeof resolved.uri !== 'string' ||
38
+ resolved.uri.trim() === '') {
39
+ return null;
40
+ }
41
+ return resolved.uri;
42
+ }
43
+ // Import security question utility functions
44
+ import { toPlainSecurityQuestion } from './utils/securityQuestionUtils';
45
+ export const WalletSdk = (() => {
46
+ const defaultUserAgentRn = USER_AGENT_RN + '/' + packageJson.version;
47
+ return {
48
+ sdkVersion: {
49
+ native: ProgrammablewalletRnSdk.sdkVersion,
50
+ rn: packageJson.version,
51
+ },
52
+ get deviceId() {
53
+ return ProgrammablewalletRnSdk.getDeviceId();
54
+ },
55
+ getDeviceId: ProgrammablewalletRnSdk.getDeviceId,
56
+ init(configuration) {
57
+ const promise = ProgrammablewalletRnSdk.initSdk(configuration);
58
+ ProgrammablewalletRnSdk.setCustomUserAgent(defaultUserAgentRn);
59
+ return promise;
60
+ },
61
+ setSecurityQuestions(securityQuestions) {
62
+ try {
63
+ // Convert each input to a proper SecurityQuestion object
64
+ const normalized = (securityQuestions || []).map(q => toPlainSecurityQuestion(q));
65
+ // toPlainSecurityQuestion already performs the necessary serialization
66
+ // No need for bridgeSafe here as each question has been converted to a plain object
67
+ // with only primitive properties (string title and enum inputType)
68
+ ProgrammablewalletRnSdk.setSecurityQuestions(normalized);
69
+ }
70
+ catch (e) {
71
+ console.error('setSecurityQuestions failed:', e);
72
+ }
73
+ },
74
+ execute(userToken, encryptionKey, challengeIds, successCallback, errorCallback) {
75
+ const successListener = ProgrammablewalletRnSdk.addListener(EVENT_NAME_ON_SUCCESS, (event) => {
76
+ console.debug('[WalletSdk] Execute result');
77
+ successCallback(event);
78
+ cleanup();
79
+ });
80
+ const errorListener = ProgrammablewalletRnSdk.addListener(EVENT_NAME_ON_ERROR, (event) => {
81
+ console.debug('[WalletSdk] Error event received:', event);
82
+ // Convert event to Error object if needed
83
+ const error = event instanceof Error
84
+ ? event
85
+ : new Error(event?.message || 'Unknown error');
86
+ errorCallback(error);
87
+ cleanup();
88
+ });
89
+ // Cleanup function to remove listeners
90
+ const cleanup = () => {
91
+ successListener?.remove();
92
+ errorListener?.remove();
93
+ };
94
+ // Call native execute method
95
+ ProgrammablewalletRnSdk.execute(userToken, encryptionKey, challengeIds)
96
+ .then((successResult) => {
97
+ // If Promise resolves but no event was fired, call success callback
98
+ console.debug('[WalletSdk] Promise resolved');
99
+ successCallback(successResult);
100
+ cleanup();
101
+ })
102
+ .catch((e) => {
103
+ // If Promise rejects but no event was fired, call error callback
104
+ console.debug('[WalletSdk] Promise rejected:', e);
105
+ errorCallback(e);
106
+ cleanup();
107
+ });
108
+ },
109
+ verifyOTP(otpToken, deviceToken, deviceEncryptionKey, successCallback, errorCallback) {
110
+ ProgrammablewalletRnSdk.addListener(EVENT_NAME_ON_ERROR, (event) => {
111
+ // Convert event to Error object if needed
112
+ const error = event instanceof Error
113
+ ? event
114
+ : new Error(event?.message || 'Unknown error');
115
+ errorCallback(error);
116
+ });
117
+ ProgrammablewalletRnSdk.verifyOTP(otpToken, deviceToken, deviceEncryptionKey)
118
+ .then((result) => {
119
+ successCallback(result);
120
+ })
121
+ .catch((e) => {
122
+ errorCallback(e);
123
+ })
124
+ .finally(() => {
125
+ ProgrammablewalletRnSdk.removeAllListeners(EVENT_NAME_ON_ERROR);
126
+ });
127
+ },
128
+ performLogin(provider, deviceToken, deviceEncryptionKey, successCallback, errorCallback) {
129
+ ProgrammablewalletRnSdk.performLogin(provider, deviceToken, deviceEncryptionKey)
130
+ .then((successResult) => {
131
+ console.debug('[WalletSdk] performLogin Promise resolved:', successResult);
132
+ successCallback(successResult);
133
+ })
134
+ .catch((e) => {
135
+ console.debug('[WalletSdk] performLogin Promise rejected:', e);
136
+ errorCallback(e);
137
+ });
138
+ },
139
+ performLogout(provider, completedCallback, errorCallback) {
140
+ ProgrammablewalletRnSdk.performLogout(provider)
141
+ .then(() => {
142
+ console.debug('[WalletSdk] performLogout Promise resolved');
143
+ completedCallback();
144
+ })
145
+ .catch((e) => {
146
+ console.debug('[WalletSdk] performLogout Promise rejected:', e);
147
+ errorCallback(e);
148
+ });
149
+ },
150
+ setBiometricsPin(userToken, encryptionKey, successCallback, errorCallback) {
151
+ const successListener = ProgrammablewalletRnSdk.addListener(EVENT_NAME_ON_SUCCESS, (event) => {
152
+ successCallback(event);
153
+ cleanup();
154
+ });
155
+ const errorListener = ProgrammablewalletRnSdk.addListener(EVENT_NAME_ON_ERROR, (event) => {
156
+ console.debug('[WalletSdk] setBiometricsPin Error event received:', event);
157
+ // Convert event to Error object if needed
158
+ const error = event instanceof Error
159
+ ? event
160
+ : new Error(event?.message || 'Unknown error');
161
+ errorCallback(error);
162
+ cleanup();
163
+ });
164
+ // Cleanup function to remove listeners
165
+ const cleanup = () => {
166
+ successListener?.remove();
167
+ errorListener?.remove();
168
+ };
169
+ // Call native setBiometricsPin method
170
+ ProgrammablewalletRnSdk.setBiometricsPin(userToken, encryptionKey)
171
+ .then((successResult) => {
172
+ // If Promise resolves but no event was fired, call success callback
173
+ console.debug('[WalletSdk] setBiometricsPin Promise resolved:', successResult);
174
+ successCallback(successResult);
175
+ cleanup();
176
+ })
177
+ .catch((e) => {
178
+ // If Promise rejects but no event was fired, call error callback
179
+ console.debug('[WalletSdk] setBiometricsPin Promise rejected:', e);
180
+ errorCallback(e);
181
+ cleanup();
182
+ });
183
+ },
184
+ setDismissOnCallbackMap(map) {
185
+ try {
186
+ // Use bridgeSafe for serialization and ensure the result is a non-null object
187
+ const serialized = bridgeSafe(map);
188
+ ProgrammablewalletRnSdk.setDismissOnCallbackMap(serialized);
189
+ }
190
+ catch (e) {
191
+ console.error('setDismissOnCallbackMap failed:', e);
192
+ }
193
+ },
194
+ moveTaskToFront() {
195
+ try {
196
+ ProgrammablewalletRnSdk.moveTaskToFront();
197
+ }
198
+ catch (e) {
199
+ console.error('moveTaskToFront failed:', e);
200
+ }
201
+ },
202
+ moveRnTaskToFront() {
203
+ try {
204
+ ProgrammablewalletRnSdk.moveRnTaskToFront();
205
+ }
206
+ catch (e) {
207
+ console.error('moveRnTaskToFront failed:', e);
208
+ }
209
+ },
210
+ setTextConfigsMap(map) {
211
+ try {
212
+ // Use bridgeSafe for serialization and ensure the result is a non-null object
213
+ const serialized = bridgeSafe(map);
214
+ ProgrammablewalletRnSdk.setTextConfigsMap(serialized);
215
+ }
216
+ catch (e) {
217
+ console.error('setTextConfigsMap failed:', e);
218
+ }
219
+ },
220
+ setIconTextConfigsMap(rawMap) {
221
+ try {
222
+ // Create a transformed plain object instead of a Map
223
+ const processedObj = {};
224
+ Array.from(rawMap.entries()).forEach(([key, configs]) => {
225
+ const processedConfigs = configs.map(config => {
226
+ const { image, textConfig = {} } = config;
227
+ // Process image URL, as this is React Native specific logic
228
+ return {
229
+ image: image ? getImageUrl(image) : null,
230
+ textConfig,
231
+ };
232
+ });
233
+ processedObj[String(key)] = processedConfigs;
234
+ });
235
+ // Use bridgeSafe for serialization and ensure the result is a non-null object
236
+ const serialized = bridgeSafe(processedObj);
237
+ ProgrammablewalletRnSdk.setIconTextConfigsMap(serialized);
238
+ }
239
+ catch (e) {
240
+ console.error('setIconTextConfigsMap Error:', e);
241
+ }
242
+ },
243
+ setTextConfigMap(map) {
244
+ try {
245
+ // Use bridgeSafe for serialization and ensure the result is a non-null object
246
+ const serialized = bridgeSafe(map);
247
+ ProgrammablewalletRnSdk.setTextConfigMap(serialized);
248
+ }
249
+ catch (e) {
250
+ console.error('setTextConfigMap failed:', e);
251
+ }
252
+ },
253
+ setImageMap(map) {
254
+ try {
255
+ // Process image URLs, this part needs to be preserved
256
+ const processedMap = new Map();
257
+ map.forEach((value, key) => {
258
+ const url = getImageUrl(value);
259
+ // Only keep non-null URLs
260
+ if (url !== null) {
261
+ processedMap.set(key, url);
262
+ }
263
+ });
264
+ // Use bridgeSafe for serialization and ensure the result is a non-null object
265
+ const serialized = bridgeSafe(processedMap);
266
+ ProgrammablewalletRnSdk.setImageMap(serialized);
267
+ }
268
+ catch (e) {
269
+ console.error('setImageMap failed:', e);
270
+ }
271
+ },
272
+ setDateFormat(format) {
273
+ try {
274
+ ProgrammablewalletRnSdk.setDateFormat(format);
275
+ }
276
+ catch (e) {
277
+ console.error('setDateFormat failed:', e);
278
+ }
279
+ },
280
+ setDebugging(debugging) {
281
+ try {
282
+ ProgrammablewalletRnSdk.setDebugging(debugging);
283
+ }
284
+ catch (e) {
285
+ console.error('setDebugging failed:', e);
286
+ }
287
+ },
288
+ setCustomUserAgent(userAgent) {
289
+ ProgrammablewalletRnSdk.setCustomUserAgent(defaultUserAgentRn + ' | ' + userAgent);
290
+ },
291
+ setErrorStringMap(map) {
292
+ try {
293
+ // Use bridgeSafe for serialization and ensure the result is a non-null object
294
+ const serialized = bridgeSafe(map);
295
+ ProgrammablewalletRnSdk.setErrorStringMap(serialized);
296
+ }
297
+ catch (e) {
298
+ console.error('setErrorStringMap failed:', e);
299
+ }
300
+ },
301
+ };
302
+ })();
303
+ //# sourceMappingURL=WalletSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletSdk.js","sourceRoot":"","sources":["../src/WalletSdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAuBH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AAE9C,OAAO,uBAAuB,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAuB,KAAK,EAAE,MAAM,cAAc,CAAA;AAEzD,wBAAwB;AACxB,MAAM,qBAAqB,GAAG,mBAAmB,CAAA;AACjD,MAAM,mBAAmB,GAAG,iBAAiB,CAAA;AAC7C,MAAM,aAAa,GAAG,mCAAmC,CAAA;AAEzD;;;;GAIG;AACH,SAAS,WAAW,CAA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,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAA;YAC3C,CAAC;QACH,CAAC;QACD,YAAY,CAAC,SAAkB;YAC7B,IAAI,CAAC;gBACH,uBAAuB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;YACjD,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAA;YAC1C,CAAC;QACH,CAAC;QACD,kBAAkB,CAAC,SAAiB;YAClC,uBAAuB,CAAC,kBAAkB,CACxC,kBAAkB,GAAG,KAAK,GAAG,SAAS,CACvC,CAAA;QACH,CAAC;QACD,iBAAiB,CAAC,GAA2B;YAC3C,IAAI,CAAC;gBACH,8EAA8E;gBAC9E,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAA2B,CAAA;gBAC5D,uBAAuB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA;YACvD,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,CAAC,CAAC,CAAA;YAC/C,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAC,EAAE,CAAA","sourcesContent":["/**\n * Copyright 2025 Circle Internet Group, Inc. All rights reserved.\n *\n * SPDX-License-Identifier: 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 {\n IWalletSdk,\n Configuration,\n TextsKey,\n IconTextsKey,\n TextKey,\n ImageKey,\n DateFormat,\n ErrorCode,\n SuccessCallback,\n LoginSuccessCallback,\n CompletedCallback,\n ErrorCallback,\n SuccessResult,\n LoginResult,\n IconTextConfig,\n TextConfig,\n SocialProvider,\n SecurityQuestion,\n InputType,\n} from './types'\nimport { bridgeSafe } from './bridgeSafe'\nconst packageJson = require('../package.json')\n\nimport ProgrammablewalletRnSdk from './ProgrammablewalletRnSdkModule'\nimport { ImageSourcePropType, Image } from 'react-native'\n\n// SDK event identifiers\nconst EVENT_NAME_ON_SUCCESS = 'CirclePwOnSuccess'\nconst EVENT_NAME_ON_ERROR = 'CirclePwOnError'\nconst USER_AGENT_RN = 'Circle-Programmable-Wallet-SDK-RN'\n\n/**\n * Resolves React Native image sources to URI strings for native bridge\n * @param source - React Native image source\n * @returns Resolved URI string or null\n */\nfunction getImageUrl(source: ImageSourcePropType): string | null {\n if (!source) {\n return null\n }\n const resolved = Image.resolveAssetSource(source)\n if (\n !resolved ||\n typeof resolved.uri !== 'string' ||\n resolved.uri.trim() === ''\n ) {\n return null\n }\n return resolved.uri\n}\n\n// Import security question utility functions\nimport { toPlainSecurityQuestion } from './utils/securityQuestionUtils'\n\nexport const WalletSdk = ((): IWalletSdk => {\n const defaultUserAgentRn = USER_AGENT_RN + '/' + packageJson.version\n return {\n sdkVersion: {\n native: ProgrammablewalletRnSdk.sdkVersion,\n rn: packageJson.version,\n },\n get deviceId() {\n return ProgrammablewalletRnSdk.getDeviceId()\n },\n getDeviceId: ProgrammablewalletRnSdk.getDeviceId,\n init(configuration: Configuration): Promise<void> {\n const promise = ProgrammablewalletRnSdk.initSdk(configuration)\n ProgrammablewalletRnSdk.setCustomUserAgent(defaultUserAgentRn)\n return promise\n },\n setSecurityQuestions(securityQuestions: Array<{ title: string; inputType?: InputType | string | number }>): void {\n try {\n // Convert each input to a proper SecurityQuestion object\n const normalized: SecurityQuestion[] = (securityQuestions || []).map(q => toPlainSecurityQuestion(q))\n\n // toPlainSecurityQuestion already performs the necessary serialization\n // No need for bridgeSafe here as each question has been converted to a plain object\n // with only primitive properties (string title and enum inputType)\n ProgrammablewalletRnSdk.setSecurityQuestions(normalized)\n } catch (e) {\n console.error('setSecurityQuestions failed:', e)\n }\n },\n execute(\n userToken: string,\n encryptionKey: string,\n challengeIds: string[],\n successCallback: SuccessCallback,\n errorCallback: ErrorCallback,\n ): void {\n const successListener = ProgrammablewalletRnSdk.addListener(\n EVENT_NAME_ON_SUCCESS,\n (event: unknown) => {\n console.debug('[WalletSdk] Execute result')\n successCallback(event as SuccessResult)\n cleanup()\n },\n )\n\n const errorListener = ProgrammablewalletRnSdk.addListener(\n EVENT_NAME_ON_ERROR,\n (event: unknown) => {\n console.debug('[WalletSdk] Error event received:', event)\n // Convert event to Error object if needed\n const error =\n event instanceof Error\n ? event\n : new Error((event as { message?: string })?.message || 'Unknown error')\n errorCallback(error)\n cleanup()\n },\n )\n\n // Cleanup function to remove listeners\n const cleanup = () => {\n successListener?.remove()\n errorListener?.remove()\n }\n\n // Call native execute method\n ProgrammablewalletRnSdk.execute(userToken, encryptionKey, challengeIds)\n .then((successResult: SuccessResult) => {\n // If Promise resolves but no event was fired, call success callback\n console.debug('[WalletSdk] Promise resolved')\n successCallback(successResult)\n cleanup()\n })\n .catch((e: Error) => {\n // If Promise rejects but no event was fired, call error callback\n console.debug('[WalletSdk] Promise rejected:', e)\n errorCallback(e)\n cleanup()\n })\n },\n verifyOTP(\n otpToken: string,\n deviceToken: string,\n deviceEncryptionKey: string,\n successCallback: LoginSuccessCallback,\n errorCallback: ErrorCallback,\n ): void {\n ProgrammablewalletRnSdk.addListener(EVENT_NAME_ON_ERROR, (event: unknown) => {\n // Convert event to Error object if needed\n const error =\n event instanceof Error\n ? event\n : new Error((event as { message?: string })?.message || 'Unknown error')\n errorCallback(error)\n })\n ProgrammablewalletRnSdk.verifyOTP(\n otpToken,\n deviceToken,\n deviceEncryptionKey,\n )\n .then((result: LoginResult) => {\n successCallback(result)\n })\n .catch((e: Error) => {\n errorCallback(e)\n })\n .finally(() => {\n ProgrammablewalletRnSdk.removeAllListeners(EVENT_NAME_ON_ERROR)\n })\n },\n performLogin(\n provider: SocialProvider,\n deviceToken: string,\n deviceEncryptionKey: string,\n successCallback: LoginSuccessCallback,\n errorCallback: ErrorCallback,\n ): void {\n ProgrammablewalletRnSdk.performLogin(\n provider,\n deviceToken,\n deviceEncryptionKey,\n )\n .then((successResult: LoginResult) => {\n console.debug(\n '[WalletSdk] performLogin Promise resolved:',\n successResult,\n )\n successCallback(successResult)\n })\n .catch((e: Error) => {\n console.debug('[WalletSdk] performLogin Promise rejected:', e)\n errorCallback(e)\n })\n },\n performLogout(\n provider: SocialProvider,\n completedCallback: CompletedCallback,\n errorCallback: ErrorCallback,\n ): void {\n ProgrammablewalletRnSdk.performLogout(provider)\n .then(() => {\n console.debug('[WalletSdk] performLogout Promise resolved')\n completedCallback()\n })\n .catch((e: Error) => {\n console.debug('[WalletSdk] performLogout Promise rejected:', e)\n errorCallback(e)\n })\n },\n setBiometricsPin(\n userToken: string,\n encryptionKey: string,\n successCallback: SuccessCallback,\n errorCallback: ErrorCallback,\n ): void {\n const successListener = ProgrammablewalletRnSdk.addListener(\n EVENT_NAME_ON_SUCCESS,\n (event: unknown) => {\n successCallback(event as SuccessResult)\n cleanup()\n },\n )\n\n const errorListener = ProgrammablewalletRnSdk.addListener(\n EVENT_NAME_ON_ERROR,\n (event: unknown) => {\n console.debug(\n '[WalletSdk] setBiometricsPin Error event received:',\n event,\n )\n // Convert event to Error object if needed\n const error =\n event instanceof Error\n ? event\n : new Error((event as { message?: string })?.message || 'Unknown error')\n errorCallback(error)\n cleanup()\n },\n )\n\n // Cleanup function to remove listeners\n const cleanup = () => {\n successListener?.remove()\n errorListener?.remove()\n }\n\n // Call native setBiometricsPin method\n ProgrammablewalletRnSdk.setBiometricsPin(userToken, encryptionKey)\n .then((successResult: SuccessResult) => {\n // If Promise resolves but no event was fired, call success callback\n console.debug(\n '[WalletSdk] setBiometricsPin Promise resolved:',\n successResult,\n )\n successCallback(successResult)\n cleanup()\n })\n .catch((e: Error) => {\n // If Promise rejects but no event was fired, call error callback\n console.debug('[WalletSdk] setBiometricsPin Promise rejected:', e)\n errorCallback(e)\n cleanup()\n })\n },\n\n setDismissOnCallbackMap(map: Map<ErrorCode, boolean>): void {\n try {\n // Use bridgeSafe for serialization and ensure the result is a non-null object\n const serialized = bridgeSafe(map) as Record<string, boolean>\n ProgrammablewalletRnSdk.setDismissOnCallbackMap(serialized)\n } catch (e) {\n console.error('setDismissOnCallbackMap failed:', e)\n }\n },\n moveTaskToFront(): void {\n try {\n ProgrammablewalletRnSdk.moveTaskToFront()\n } catch (e) {\n console.error('moveTaskToFront failed:', e)\n }\n },\n moveRnTaskToFront(): void {\n try {\n ProgrammablewalletRnSdk.moveRnTaskToFront()\n } catch (e) {\n console.error('moveRnTaskToFront failed:', e)\n }\n },\n setTextConfigsMap(map: Map<TextsKey, TextConfig[]>): void {\n try {\n // Use bridgeSafe for serialization and ensure the result is a non-null object\n const serialized = bridgeSafe(map) as Record<string, TextConfig[]>\n ProgrammablewalletRnSdk.setTextConfigsMap(serialized)\n } catch (e) {\n console.error('setTextConfigsMap failed:', e)\n }\n },\n\n setIconTextConfigsMap(\n rawMap: Map<IconTextsKey, Array<IconTextConfig>>,\n ): void {\n try {\n // Create a transformed plain object instead of a Map\n const processedObj: Record<string, Array<{ image: string | null; textConfig: TextConfig }>> = {}\n\n Array.from(rawMap.entries()).forEach(([key, configs]) => {\n const processedConfigs = configs.map(config => {\n const { image, textConfig = {} } = config as IconTextConfig\n // Process image URL, as this is React Native specific logic\n return {\n image: image ? getImageUrl(image) : null,\n textConfig,\n }\n })\n processedObj[String(key)] = processedConfigs\n })\n\n // Use bridgeSafe for serialization and ensure the result is a non-null object\n const serialized = bridgeSafe(processedObj) as Record<string, unknown>\n ProgrammablewalletRnSdk.setIconTextConfigsMap(serialized)\n } catch (e) {\n console.error('setIconTextConfigsMap Error:', e)\n }\n },\n setTextConfigMap(map: Map<TextKey, TextConfig>): void {\n try {\n // Use bridgeSafe for serialization and ensure the result is a non-null object\n const serialized = bridgeSafe(map) as Record<string, TextConfig>\n ProgrammablewalletRnSdk.setTextConfigMap(serialized)\n } catch (e) {\n console.error('setTextConfigMap failed:', e)\n }\n },\n\n setImageMap(map: Map<ImageKey, ImageSourcePropType>): void {\n try {\n // Process image URLs, this part needs to be preserved\n const processedMap = new Map<ImageKey, string>()\n\n map.forEach((value, key) => {\n const url = getImageUrl(value)\n // Only keep non-null URLs\n if (url !== null) {\n processedMap.set(key, url)\n }\n })\n\n // Use bridgeSafe for serialization and ensure the result is a non-null object\n const serialized = bridgeSafe(processedMap) as Record<string, string>\n ProgrammablewalletRnSdk.setImageMap(serialized)\n } catch (e) {\n console.error('setImageMap failed:', e)\n }\n },\n setDateFormat(format: DateFormat): void {\n try {\n ProgrammablewalletRnSdk.setDateFormat(format)\n } catch (e) {\n console.error('setDateFormat failed:', e)\n }\n },\n setDebugging(debugging: boolean): void {\n try {\n ProgrammablewalletRnSdk.setDebugging(debugging)\n } catch (e) {\n console.error('setDebugging failed:', e)\n }\n },\n setCustomUserAgent(userAgent: string): void {\n ProgrammablewalletRnSdk.setCustomUserAgent(\n defaultUserAgentRn + ' | ' + userAgent,\n )\n },\n setErrorStringMap(map: Map<ErrorCode, string>): void {\n try {\n // Use bridgeSafe for serialization and ensure the result is a non-null object\n const serialized = bridgeSafe(map) as Record<string, string>\n ProgrammablewalletRnSdk.setErrorStringMap(serialized)\n } catch (e) {\n console.error('setErrorStringMap failed:', e)\n }\n },\n }\n})()\n"]}
@@ -0,0 +1,50 @@
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
+ * Bridge-safe utilities for React Native/Expo
20
+ * - bridgeSafe: Converts values to JSON-safe format
21
+ * - bridgeDiff: Detects data loss or unexpected transformations
22
+ */
23
+ export type BridgePrimitive = string | number | boolean | null;
24
+ export type BridgeValue = BridgePrimitive | {
25
+ [k: string]: BridgeValue;
26
+ } | BridgeValue[];
27
+ type TypeName = 'null' | 'boolean' | 'number' | 'string' | 'array' | 'object' | 'date' | 'bigint' | 'map' | 'set' | 'function' | 'symbol' | 'undefined' | 'nan' | 'infinity';
28
+ export declare function bridgeSafe<T = unknown>(input: T): BridgeValue;
29
+ export interface BridgeDiff {
30
+ lostPaths: string[];
31
+ transformed: Array<{
32
+ path: string;
33
+ from: TypeName;
34
+ to: TypeName;
35
+ note?: string;
36
+ }>;
37
+ }
38
+ export interface DiffPolicy {
39
+ /** allow typical transforms without flagging */
40
+ allow?: Partial<Record<`${TypeName}->${TypeName}`, boolean>>;
41
+ /** treat dropping undefined/function/symbol as allowed (default true) */
42
+ allowDropSpecial?: boolean;
43
+ }
44
+ /**
45
+ * Compare original and bridged values to identify transformations and data loss
46
+ * @note This is a best-effort detector that cannot guarantee perfect bijection
47
+ */
48
+ export declare function bridgeDiff(original: unknown, bridged: BridgeValue, policy?: DiffPolicy): BridgeDiff;
49
+ export {};
50
+ //# sourceMappingURL=bridgeSafe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridgeSafe.d.ts","sourceRoot":"","sources":["../src/bridgeSafe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC/D,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,GAAG,WAAW,EAAE,CAAC;AAEzF,KAAK,QAAQ,GACP,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GACxC,OAAO,GAAG,QAAQ,GAClB,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GACjC,UAAU,GAAG,QAAQ,GAAG,WAAW,GACnC,KAAK,GAAG,UAAU,CAAC;AAuBzB,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAqB7D;AAED,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAC;QAAC,EAAE,EAAE,QAAQ,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrF;AAED,MAAM,WAAW,UAAU;IACvB,gDAAgD;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,KAAK,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7D,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,CA4DnG"}
@@ -0,0 +1,136 @@
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
+ function typeOf(x) {
19
+ if (x === null)
20
+ return 'null';
21
+ const t = typeof x;
22
+ if (t === 'number') {
23
+ if (Number.isNaN(x))
24
+ return 'nan';
25
+ if (!Number.isFinite(x))
26
+ return 'infinity';
27
+ return 'number';
28
+ }
29
+ if (t === 'bigint')
30
+ return 'bigint';
31
+ if (t === 'function')
32
+ return 'function';
33
+ if (t === 'symbol')
34
+ return 'symbol';
35
+ if (t === 'undefined')
36
+ return 'undefined';
37
+ if (t === 'string' || t === 'boolean')
38
+ return t;
39
+ // Check complex types
40
+ if (x instanceof Date)
41
+ return 'date';
42
+ if (Array.isArray(x))
43
+ return 'array';
44
+ if (x instanceof Map)
45
+ return 'map';
46
+ if (x instanceof Set)
47
+ return 'set';
48
+ return 'object';
49
+ }
50
+ export function bridgeSafe(input) {
51
+ const seen = new WeakSet();
52
+ const replacer = (_k, v) => {
53
+ const ty = typeOf(v);
54
+ if (ty === 'undefined' || ty === 'function' || ty === 'symbol')
55
+ return undefined;
56
+ if (ty === 'nan' || ty === 'infinity')
57
+ return String(v);
58
+ if (ty === 'bigint')
59
+ return String(v);
60
+ if (ty === 'date')
61
+ return v.toISOString();
62
+ if (ty === 'map') {
63
+ return Object.fromEntries(Array.from(v.entries(), ([k, val]) => [String(k), val]));
64
+ }
65
+ if (ty === 'set') {
66
+ return Array.from(v.values());
67
+ }
68
+ if (v && typeof v === 'object') {
69
+ if (seen.has(v))
70
+ return '[Circular]';
71
+ seen.add(v);
72
+ }
73
+ return v;
74
+ };
75
+ return JSON.parse(JSON.stringify(input, replacer));
76
+ }
77
+ /**
78
+ * Compare original and bridged values to identify transformations and data loss
79
+ * @note This is a best-effort detector that cannot guarantee perfect bijection
80
+ */
81
+ export function bridgeDiff(original, bridged, policy) {
82
+ const allow = new Set(Object.entries({
83
+ 'date->string': true,
84
+ 'bigint->string': true,
85
+ 'map->object': true,
86
+ 'set->array': true,
87
+ 'nan->string': true,
88
+ 'infinity->string': true,
89
+ ...(policy?.allow ?? {}),
90
+ }).filter(([, v]) => v).map(([k]) => k));
91
+ const allowDropSpecial = policy?.allowDropSpecial ?? true;
92
+ const lostPaths = [];
93
+ const transformed = [];
94
+ function walk(o, b, path) {
95
+ const to = typeOf(b);
96
+ const fo = typeOf(o);
97
+ // record transform
98
+ if (!(fo === to || allow.has(`${fo}->${to}`))) {
99
+ // exclude expected object/array shape diffs handled below
100
+ if (!(fo === 'object' && to === 'object') && !(fo === 'array' && to === 'array')) {
101
+ transformed.push({ path, from: fo, to });
102
+ }
103
+ }
104
+ // if bridged is undefined, nothing to recurse
105
+ if (b === undefined)
106
+ return;
107
+ if (to === 'object') {
108
+ const oKeys = (o && typeof o === 'object') ? Object.keys(o) : [];
109
+ const bKeys = (b && typeof b === 'object') ? Object.keys(b) : [];
110
+ // find missing keys
111
+ for (const k of oKeys) {
112
+ if (!(k in b)) {
113
+ const child = o[k];
114
+ const tChild = typeOf(child);
115
+ const droppedSpecial = (tChild === 'undefined' || tChild === 'function' || tChild === 'symbol');
116
+ if (!(allowDropSpecial && droppedSpecial)) {
117
+ lostPaths.push(path ? `${path}.${k}` : k);
118
+ }
119
+ }
120
+ }
121
+ // recurse
122
+ for (const k of bKeys) {
123
+ walk(o?.[k], b[k], path ? `${path}.${k}` : k);
124
+ }
125
+ }
126
+ else if (to === 'array') {
127
+ const len = Array.isArray(b) ? b.length : 0;
128
+ for (let i = 0; i < len; i++) {
129
+ walk(o?.[i], b[i], `${path}[${i}]`);
130
+ }
131
+ }
132
+ }
133
+ walk(original, bridged, '');
134
+ return { lostPaths, transformed };
135
+ }
136
+ //# sourceMappingURL=bridgeSafe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridgeSafe.js","sourceRoot":"","sources":["../src/bridgeSafe.ts"],"names":[],"mappings":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AC,CAAC,CAAA;YAC1D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC3B,IAAI,CAAE,CAAe,EAAE,CAAC,CAAC,CAAC,EAAG,CAAe,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;YACrE,CAAC;QACL,CAAC;IACL,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,CAAA;IAE3B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAA;AACrC,CAAC","sourcesContent":["/**\n * Copyright 2025 Circle Internet Group, Inc. All rights reserved.\n *\n * SPDX-License-Identifier: 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\n/**\n * Bridge-safe utilities for React Native/Expo\n * - bridgeSafe: Converts values to JSON-safe format\n * - bridgeDiff: Detects data loss or unexpected transformations\n */\n\nexport type BridgePrimitive = string | number | boolean | null;\nexport type BridgeValue = BridgePrimitive | { [k: string]: BridgeValue } | BridgeValue[];\n\ntype TypeName =\n | 'null' | 'boolean' | 'number' | 'string'\n | 'array' | 'object'\n | 'date' | 'bigint' | 'map' | 'set'\n | 'function' | 'symbol' | 'undefined'\n | 'nan' | 'infinity';\n\nfunction typeOf(x: unknown): TypeName {\n if (x === null) return 'null'\n const t = typeof x\n if (t === 'number') {\n if (Number.isNaN(x as number)) return 'nan'\n if (!Number.isFinite(x as number)) return 'infinity'\n return 'number'\n }\n if (t === 'bigint') return 'bigint'\n if (t === 'function') return 'function'\n if (t === 'symbol') return 'symbol'\n if (t === 'undefined') return 'undefined'\n if (t === 'string' || t === 'boolean') return t\n // Check complex types\n if (x instanceof Date) return 'date'\n if (Array.isArray(x)) return 'array'\n if (x instanceof Map) return 'map'\n if (x instanceof Set) return 'set'\n return 'object'\n}\n\nexport function bridgeSafe<T = unknown>(input: T): BridgeValue {\n const seen = new WeakSet<object>()\n const replacer = (_k: string, v: unknown) => {\n const ty = typeOf(v)\n if (ty === 'undefined' || ty === 'function' || ty === 'symbol') return undefined\n if (ty === 'nan' || ty === 'infinity') return String(v)\n if (ty === 'bigint') return String(v)\n if (ty === 'date') return (v as Date).toISOString()\n if (ty === 'map') {\n return Object.fromEntries(Array.from((v as Map<unknown, unknown>).entries(), ([k, val]) => [String(k), val]))\n }\n if (ty === 'set') {\n return Array.from((v as Set<unknown>).values())\n }\n if (v && typeof v === 'object') {\n if (seen.has(v)) return '[Circular]'\n seen.add(v)\n }\n return v\n }\n return JSON.parse(JSON.stringify(input, replacer)) as BridgeValue\n}\n\nexport interface BridgeDiff {\n lostPaths: string[]; // paths that disappeared after serialization\n transformed: Array<{ path: string; from: TypeName; to: TypeName; note?: string }>;\n}\n\nexport interface DiffPolicy {\n /** allow typical transforms without flagging */\n allow?: Partial<Record<`${TypeName}->${TypeName}`, boolean>>;\n /** treat dropping undefined/function/symbol as allowed (default true) */\n allowDropSpecial?: boolean;\n}\n\n/**\n * Compare original and bridged values to identify transformations and data loss\n * @note This is a best-effort detector that cannot guarantee perfect bijection\n */\nexport function bridgeDiff(original: unknown, bridged: BridgeValue, policy?: DiffPolicy): BridgeDiff {\n const allow = new Set<string>(Object.entries({\n 'date->string': true,\n 'bigint->string': true,\n 'map->object': true,\n 'set->array': true,\n 'nan->string': true,\n 'infinity->string': true,\n ...(policy?.allow ?? {}),\n }).filter(([, v]) => v).map(([k]) => k))\n\n const allowDropSpecial = policy?.allowDropSpecial ?? true\n\n const lostPaths: string[] = []\n const transformed: Array<{ path: string; from: TypeName; to: TypeName; note?: string }> = []\n\n function walk(o: unknown, b: unknown, path: string) {\n const to = typeOf(b)\n const fo = typeOf(o)\n\n // record transform\n if (!(fo === to || allow.has(`${fo}->${to}`))) {\n // exclude expected object/array shape diffs handled below\n if (!(fo === 'object' && to === 'object') && !(fo === 'array' && to === 'array')) {\n transformed.push({ path, from: fo, to })\n }\n }\n\n // if bridged is undefined, nothing to recurse\n if (b === undefined) return\n\n if (to === 'object') {\n const oKeys = (o && typeof o === 'object') ? Object.keys(o) : []\n const bKeys = (b && typeof b === 'object') ? Object.keys(b) : []\n // find missing keys\n for (const k of oKeys) {\n if (!(k in (b as Record<string, unknown>))) {\n const child = (o as Record<string, unknown>)[k]\n const tChild = typeOf(child)\n const droppedSpecial = (tChild === 'undefined' || tChild === 'function' || tChild === 'symbol')\n if (!(allowDropSpecial && droppedSpecial)) {\n lostPaths.push(path ? `${path}.${k}` : k)\n }\n }\n }\n // recurse\n for (const k of bKeys) {\n walk((o as Record<string, unknown>)?.[k], (b as Record<string, unknown>)[k], path ? `${path}.${k}` : k)\n }\n } else if (to === 'array') {\n const len = Array.isArray(b) ? (b as unknown[]).length : 0\n for (let i = 0; i < len; i++) {\n walk((o as unknown[])?.[i], (b as unknown[])[i], `${path}[${i}]`)\n }\n }\n }\n\n walk(original, bridged, '')\n\n return { lostPaths, transformed }\n}\n\n"]}
@@ -0,0 +1,21 @@
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
+ export { default } from './ProgrammablewalletRnSdkModule';
19
+ export * from './types';
20
+ export { WalletSdk } from './WalletSdk';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AACzD,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
package/build/index.js ADDED
@@ -0,0 +1,21 @@
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
+ export { default } from './ProgrammablewalletRnSdkModule';
19
+ export * from './types';
20
+ export { WalletSdk } from './WalletSdk';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AACzD,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA","sourcesContent":["/**\n * Copyright 2025 Circle Internet Group, Inc. All rights reserved.\n *\n * SPDX-License-Identifier: 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\nexport { default } from './ProgrammablewalletRnSdkModule'\nexport * from './types'\nexport { WalletSdk } from './WalletSdk'\n"]}