@tfcorp/consumer-app-react-native-sdk 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,8 @@ presents the size modal full screen on its own. It uses the official True Fit
8
8
  materializes the account sign-in popup (`window.open`) so shoppers can register
9
9
  and get a personalized recommendation.
10
10
 
11
- This package exposes a single native view:
11
+ This package exposes a native view for the widget and a `trackOrder` function
12
+ for order confirmation reporting:
12
13
 
13
14
  ```tsx
14
15
  import {
@@ -55,8 +56,73 @@ export function ProductFitRecommendation() {
55
56
  | `storeKey` | `string` | Required |
56
57
  | `storeStyle` | `string` | Required |
57
58
  | `uiLocale` | `string` | Not set |
59
+ | `userToken` | `string` | Not set; one-time token used to bootstrap the native WebView cookie store |
58
60
  | `scriptUrl` | `string` | — (overrides `environment`; a full built-bundle URL. Raw Vite `.ts` dev entries are **not** supported) |
59
61
 
62
+ ## Legacy Expo SecureStore migration
63
+
64
+ The SDK can migrate a legacy user token supplied by the host application
65
+ without depending on `expo-secure-store`. Pass storage callbacks through
66
+ `legacyUserMigration`; omit the prop in applications that do not need the
67
+ migration.
68
+
69
+ ```tsx
70
+ import * as SecureStore from 'expo-secure-store';
71
+
72
+ import { TrueFitRecommendationView } from 'consumer-app-react-native-sdk';
73
+
74
+ const LEGACY_USER_TOKEN_KEY = 'TF-TOKEN';
75
+ const MIGRATION_COMPLETE_KEY = 'truefit-user-migration-complete';
76
+
77
+ const legacyUserMigration = {
78
+ readLegacyUserToken: async () => {
79
+ const migrationComplete = await SecureStore.getItemAsync(MIGRATION_COMPLETE_KEY);
80
+ if (migrationComplete === 'true') return null;
81
+ return await SecureStore.getItemAsync(LEGACY_USER_TOKEN_KEY);
82
+ },
83
+ completeLegacyUserMigration: async (migratedValue: string | null) => {
84
+ const storedToken = await SecureStore.getItemAsync(LEGACY_USER_TOKEN_KEY);
85
+ if (migratedValue && storedToken === migratedValue) {
86
+ await SecureStore.deleteItemAsync(LEGACY_USER_TOKEN_KEY);
87
+ }
88
+ await SecureStore.setItemAsync(MIGRATION_COMPLETE_KEY, 'true');
89
+ },
90
+ onLegacyUserMigrationError: (error: Error) => {
91
+ reportError(error);
92
+ },
93
+ };
94
+
95
+ export const ProductFitRecommendation = () => (
96
+ <TrueFitRecommendationView
97
+ config={{ storeKey: 'nda', storeStyle: '7093242789933' }}
98
+ legacyUserMigration={legacyUserMigration}
99
+ />
100
+ );
101
+ ```
102
+
103
+ `readLegacyUserToken` must return the raw SecureStore value. The SDK parses and
104
+ validates its serialized JSON shape:
105
+
106
+ ```json
107
+ {
108
+ "token": "<opaque token string>",
109
+ "creationTime": 0,
110
+ "maxAge": 63072000000
111
+ }
112
+ ```
113
+
114
+ Before mounting the native view, the SDK discards expired records and calls
115
+ `POST /api/experiments?forceMigrate=true` for valid tokens. On success it passes
116
+ the token returned in `x-tf-user-token` to the native SDK once, then calls
117
+ `completeLegacyUserMigration` with the original serialized value. The native
118
+ WebView cookie store owns subsequent JWT rotation.
119
+
120
+ The completion callback also runs when the reader returns no token or the
121
+ stored token is expired, allowing the host application to persist its marker
122
+ and avoid future legacy-token reads. It does not run after storage, network,
123
+ validation, or migration failures, so those failures remain retryable. While
124
+ the first migration check is pending, the recommendation view is not rendered.
125
+
60
126
  ### `options`
61
127
 
62
128
  | Name | Type | Default |
@@ -86,6 +152,65 @@ clipped by the webview.
86
152
  profile-based recommendation, `'general'` for a generic one, and `null` when
87
153
  there is none.
88
154
 
155
+ ## Order tracking
156
+
157
+ `trackOrder` reports a completed order from the order confirmation screen. It
158
+ forwards to the native order API on each platform (`TrueFitApi.trackOrder` on
159
+ Android, `TFOrderAPI.trackOrder` on iOS), which posts in the background and
160
+ never reports delivery back — there is nothing to await.
161
+
162
+ ```tsx
163
+ import { trackOrder, type TFTrackOrderProduct } from 'consumer-app-react-native-sdk';
164
+
165
+ const products: TFTrackOrderProduct[] = [
166
+ {
167
+ productId: '7093242789933',
168
+ quantity: 1,
169
+ price: 89.0,
170
+ currency: 'USD',
171
+ colorId: 'Black',
172
+ size: 'M',
173
+ sku: '7093242789933-BLK-M',
174
+ },
175
+ ];
176
+
177
+ trackOrder({
178
+ storeKey: 'nda',
179
+ orderId: 'order-123',
180
+ products,
181
+ environment: 'prod',
182
+ locale: 'en_US',
183
+ });
184
+ ```
185
+
186
+ ### `trackOrder(args)`
187
+
188
+ | Name | Type | Default |
189
+ | ------------- | ------------------------- | ---------------------------------------------- |
190
+ | `storeKey` | `string` | Required |
191
+ | `orderId` | `string` | Required |
192
+ | `products` | `TFTrackOrderProduct[]` | Required |
193
+ | `environment` | `'development' \| 'prod'` | `'prod'` — pass the same value the widget uses |
194
+ | `locale` | `string` | Not set |
195
+
196
+ ### `TFTrackOrderProduct`
197
+
198
+ | Name | Type | Notes |
199
+ | ----------- | -------- | ------------------------------------------------------------------- |
200
+ | `productId` | `string` | Required. Must match the ProductID in the Product Catalog feed |
201
+ | `quantity` | `number` | Required |
202
+ | `price` | `number` | Required. Unit price paid — the final price if the item was on sale |
203
+ | `currency` | `string` | Required |
204
+ | `colorId` | `string` | Optional, required for reporting |
205
+ | `size` | `string` | Optional, required for reporting |
206
+ | `sku` | `string` | Optional, required for reporting |
207
+
208
+ The native SDKs drop line items with a blank `productId` and skip the order
209
+ when all supplied products have blank IDs. The adapters skip calls with malformed
210
+ product arrays or missing, nonnumeric, or nonfinite quantities/prices.
211
+ `trackOrder` throws if the native module is
212
+ not linked, which means the app was not rebuilt after installing the package.
213
+
89
214
  ## Sign-in popup
90
215
 
91
216
  The widget's account sign-in opens the Keycloak login page via `window.open`.
@@ -103,13 +228,15 @@ the standalone True Fit native SDKs, which this package depends on:
103
228
  ```text
104
229
  React Native SDK (consumer-app-react-native-sdk)
105
230
  ├── TypeScript public API (src/index.tsx)
106
- ├── Android adapter (ViewManager + prop mappers) → depends on truefit-android-sdk
107
- └── iOS adapter (RCTViewManager + prop mappers) → depends on TrueFitRecommendation pod
231
+ ├── Android adapter (ViewManager + order module + mappers) → depends on truefit-android-sdk
232
+ └── iOS adapter (RCTViewManager + order module + mappers) → depends on TrueFitRecommendation pod
108
233
  ```
109
234
 
110
- The adapters only map props to native config, forward native callbacks to JS
111
- events, and integrate the native view into React Native layout/lifecycle, so the
112
- widget behaviour matches the standalone native SDK sample apps exactly.
235
+ The adapters only map props and arguments to native types, forward native
236
+ callbacks to JS events, and integrate the native view into React Native
237
+ layout/lifecycle, so the widget behaviour matches the standalone native SDK
238
+ sample apps exactly. Order tracking contains no transport of its own; it calls
239
+ the native SDKs' order API directly.
113
240
 
114
241
  ## Native SDK dependencies
115
242
 
@@ -0,0 +1,69 @@
1
+ package com.truefit.reactnative
2
+
3
+ import android.util.Log
4
+ import com.facebook.react.bridge.Promise
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
7
+ import com.facebook.react.bridge.ReactMethod
8
+ import com.facebook.react.bridge.ReadableMap
9
+ import com.facebook.react.bridge.ReadableType
10
+ import com.truefit.recommendation.TrueFit
11
+ import com.truefit.recommendation.TrueFitApi
12
+
13
+ /**
14
+ * Bridges the standalone Android SDK's order tracking to JS. The SDK owns
15
+ * transport, validation, threading and logging; this module only maps the JS
16
+ * arguments onto it. Like the SDK call it is fire-and-forget: it never throws
17
+ * and never reports delivery back to JS.
18
+ */
19
+ class TrueFitOrderModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
20
+
21
+ override fun getName() = NAME
22
+
23
+ @ReactMethod
24
+ fun getToken(promise: Promise) {
25
+ promise.resolve(TrueFit.getToken())
26
+ }
27
+
28
+ @ReactMethod
29
+ fun trackOrder(arguments: ReadableMap) {
30
+ val storeKey = arguments.nonBlankString("storeKey")
31
+ if (storeKey == null) {
32
+ Log.w(NAME, "trackOrder skipped: storeKey is required")
33
+ return
34
+ }
35
+
36
+ val orderId = arguments.nonBlankString("orderId")
37
+ if (orderId == null) {
38
+ Log.w(NAME, "trackOrder skipped: orderId is required")
39
+ return
40
+ }
41
+
42
+ if (!arguments.hasKey("products") || arguments.getType("products") != ReadableType.Array) {
43
+ Log.w(NAME, "trackOrder skipped: products must be an array")
44
+ return
45
+ }
46
+ val productArguments = arguments.getArray("products") ?: return
47
+ val products = TrueFitRecommendationProps.trackOrderProducts(productArguments)
48
+ if (products == null) {
49
+ Log.w(NAME, "trackOrder skipped: malformed products")
50
+ return
51
+ }
52
+
53
+ TrueFitApi.trackOrder(
54
+ storeKey = storeKey,
55
+ orderId = orderId,
56
+ products = products,
57
+ environment = TrueFitRecommendationProps.environment(
58
+ arguments.nonBlankString("environment"),
59
+ ),
60
+ locale = arguments.nonBlankString("locale"),
61
+ )
62
+ }
63
+
64
+ companion object {
65
+ const val NAME = "TrueFitOrderModule"
66
+ }
67
+ }
68
+
69
+ private fun ReadableMap.nonBlankString(name: String): String? = stringOrNull(name)?.takeIf { it.isNotBlank() }
@@ -6,7 +6,8 @@ import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.uimanager.ViewManager
7
7
 
8
8
  class TrueFitRecommendationPackage : ReactPackage {
9
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> = emptyList()
9
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
10
+ listOf(TrueFitOrderModule(reactContext))
10
11
 
11
12
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
12
13
  listOf(TrueFitRecommendationViewManager())
@@ -1,7 +1,9 @@
1
1
  package com.truefit.reactnative
2
2
 
3
+ import com.facebook.react.bridge.ReadableArray
3
4
  import com.facebook.react.bridge.ReadableMap
4
5
  import com.facebook.react.bridge.ReadableType
6
+ import com.truefit.recommendation.TFTrackOrderProduct
5
7
  import com.truefit.recommendation.TrueFitEnvironment
6
8
  import com.truefit.recommendation.TrueFitRecommendationConfig
7
9
  import com.truefit.recommendation.TrueFitRecommendationOptions
@@ -28,7 +30,7 @@ object TrueFitRecommendationProps {
28
30
  return TrueFitRecommendationConfig(
29
31
  storeKey = storeKey,
30
32
  storeStyle = storeStyle,
31
- environment = mapEnvironment(map.stringOrNull("environment")),
33
+ environment = environment(map.stringOrNull("environment")),
32
34
  uiLocale = map.stringOrNull("uiLocale")?.takeIf { it.isNotBlank() },
33
35
  userToken = map.stringOrNull("userToken")?.takeIf { it.isNotBlank() },
34
36
  // A full script URL overrides `environment` (e.g. a built bundle).
@@ -61,14 +63,38 @@ object TrueFitRecommendationProps {
61
63
  )
62
64
  }
63
65
 
64
- private fun mapEnvironment(name: String?): TrueFitEnvironment = when (name?.lowercase()) {
66
+ fun trackOrderProducts(array: ReadableArray): List<TFTrackOrderProduct>? {
67
+ return (0 until array.size()).map { index ->
68
+ if (array.getType(index) != ReadableType.Map) return null
69
+ val product = array.getMap(index) ?: return null
70
+ val productId = product.stringOrNull("productId").orEmpty()
71
+ val quantity = product.orderNumberOrNull("quantity") ?: return null
72
+ val price = product.orderNumberOrNull("price") ?: return null
73
+
74
+ TFTrackOrderProduct(
75
+ productId = productId,
76
+ quantity = quantity.toInt(),
77
+ price = price,
78
+ currency = product.stringOrNull("currency").orEmpty(),
79
+ colorId = product.stringOrNull("colorId")?.takeIf { it.isNotBlank() },
80
+ size = product.stringOrNull("size")?.takeIf { it.isNotBlank() },
81
+ sku = product.stringOrNull("sku")?.takeIf { it.isNotBlank() },
82
+ )
83
+ }
84
+ }
85
+
86
+ fun environment(name: String?): TrueFitEnvironment = when (name?.lowercase()) {
65
87
  "development", "dev" -> TrueFitEnvironment.Development
66
88
  "prod", "production" -> TrueFitEnvironment.Prod
67
89
  else -> TrueFitEnvironment.Prod
68
90
  }
69
91
  }
70
92
 
71
- private fun ReadableMap.stringOrNull(name: String): String? {
93
+ /**
94
+ * JS numbers reach the bridge as `Number`, so read them as strings too rather
95
+ * than letting `getString` throw on a numeric storeKey/productId.
96
+ */
97
+ internal fun ReadableMap.stringOrNull(name: String): String? {
72
98
  if (!hasKey(name) || isNull(name)) return null
73
99
 
74
100
  return when (getType(name)) {
@@ -88,6 +114,11 @@ private fun ReadableMap.intOrDefault(name: String, defaultValue: Int): Int =
88
114
  private fun ReadableMap.longOrDefault(name: String, defaultValue: Long): Long =
89
115
  if (hasKey(name) && !isNull(name)) getDouble(name).toLong() else defaultValue
90
116
 
117
+ private fun ReadableMap.orderNumberOrNull(name: String): Double? {
118
+ if (!hasKey(name) || getType(name) != ReadableType.Number) return null
119
+ return getDouble(name).takeIf { it.isFinite() }
120
+ }
121
+
91
122
  private fun ReadableMap.floatOrDefault(name: String, defaultValue: Float): Float =
92
123
  if (hasKey(name) && !isNull(name)) getDouble(name).toFloat() else defaultValue
93
124
 
@@ -0,0 +1,25 @@
1
+ import Foundation
2
+ import TrueFitRecommendation
3
+
4
+ enum TrueFitBridgeValues {
5
+ static func environment(_ name: String) -> TrueFitEnvironment {
6
+ switch name.lowercased() {
7
+ case "development", "dev":
8
+ .development
9
+ case "prod", "production":
10
+ .prod
11
+ default:
12
+ .prod
13
+ }
14
+ }
15
+
16
+ static func string(_ value: Any?) -> String? {
17
+ if let string = value as? String { return string }
18
+ if let number = value as? NSNumber { return number.stringValue }
19
+ return nil
20
+ }
21
+ }
22
+
23
+ extension String {
24
+ var nonEmpty: String? { isEmpty ? nil : self }
25
+ }
@@ -0,0 +1,9 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ @interface RCT_EXTERN_MODULE(TrueFitOrderModule, NSObject)
4
+
5
+ RCT_EXTERN_METHOD(trackOrder:(NSDictionary *)arguments)
6
+ RCT_EXTERN_METHOD(getToken:(RCTPromiseResolveBlock)resolve
7
+ rejecter:(RCTPromiseRejectBlock)reject)
8
+
9
+ @end
@@ -0,0 +1,75 @@
1
+ import CoreFoundation
2
+ import React
3
+ import TrueFitRecommendation
4
+
5
+ // Thin React Native adapter over the standalone iOS SDK's order tracking
6
+ // (`TFOrderAPI`). The SDK owns transport, validation and threading; this module
7
+ // only maps the JS arguments onto it. Like the SDK call it is fire-and-forget:
8
+ // it never throws and never reports delivery back to JS.
9
+ @objc(TrueFitOrderModule)
10
+ final class TrueFitOrderModule: NSObject {
11
+ // No UI is touched, so the module does not need main-queue setup.
12
+ @objc static func requiresMainQueueSetup() -> Bool {
13
+ false
14
+ }
15
+
16
+ @objc func trackOrder(_ arguments: NSDictionary) {
17
+ guard let storeKey = TrueFitBridgeValues.string(arguments["storeKey"])?.nonEmpty else {
18
+ NSLog("[TrueFit:OrderModule] trackOrder skipped: storeKey is required")
19
+ return
20
+ }
21
+ guard let orderId = TrueFitBridgeValues.string(arguments["orderId"])?.nonEmpty else {
22
+ NSLog("[TrueFit:OrderModule] trackOrder skipped: orderId is required")
23
+ return
24
+ }
25
+
26
+ guard let products = Self.products(from: arguments["products"]) else {
27
+ NSLog("[TrueFit:OrderModule] trackOrder skipped: malformed products")
28
+ return
29
+ }
30
+
31
+ TFOrderAPI().trackOrder(
32
+ storeKey: storeKey,
33
+ environment: TrueFitBridgeValues.string(arguments["environment"])
34
+ .map(TrueFitBridgeValues.environment) ?? .prod,
35
+ locale: TrueFitBridgeValues.string(arguments["locale"])?.nonEmpty,
36
+ orderID: orderId,
37
+ products: products
38
+ )
39
+ }
40
+
41
+ @objc func getToken(
42
+ _ resolve: @escaping RCTPromiseResolveBlock,
43
+ rejecter _: @escaping RCTPromiseRejectBlock
44
+ ) {
45
+ TFTokenManager.getToken { token in
46
+ resolve(token)
47
+ }
48
+ }
49
+
50
+ // MARK: - Argument mapping
51
+
52
+ private static func products(from value: Any?) -> [TFTrackOrderProduct]? {
53
+ guard let entries = value as? [NSDictionary] else { return nil }
54
+ var products: [TFTrackOrderProduct] = []
55
+ for entry in entries {
56
+ guard let quantity = entry["quantity"] as? NSNumber,
57
+ let price = entry["price"] as? NSNumber,
58
+ CFGetTypeID(quantity) != CFBooleanGetTypeID(),
59
+ CFGetTypeID(price) != CFBooleanGetTypeID(),
60
+ quantity.doubleValue.isFinite, price.doubleValue.isFinite
61
+ else { return nil }
62
+
63
+ products.append(TFTrackOrderProduct(
64
+ productId: TrueFitBridgeValues.string(entry["productId"]) ?? "",
65
+ quantity: quantity.intValue,
66
+ price: price.doubleValue,
67
+ currency: TrueFitBridgeValues.string(entry["currency"]) ?? "",
68
+ colorId: TrueFitBridgeValues.string(entry["colorId"])?.nonEmpty,
69
+ size: TrueFitBridgeValues.string(entry["size"])?.nonEmpty,
70
+ sku: TrueFitBridgeValues.string(entry["sku"])?.nonEmpty
71
+ ))
72
+ }
73
+ return products
74
+ }
75
+ }
@@ -111,18 +111,19 @@ final class TrueFitReactNativeView: UIView {
111
111
  // MARK: - Prop mapping
112
112
 
113
113
  private static func config(from dictionary: NSDictionary) -> TrueFitRecommendationConfig? {
114
- guard let storeKey = string(dictionary["storeKey"]), !storeKey.isEmpty,
115
- let storeStyle = string(dictionary["storeStyle"]), !storeStyle.isEmpty
114
+ guard let storeKey = TrueFitBridgeValues.string(dictionary["storeKey"]), !storeKey.isEmpty,
115
+ let storeStyle = TrueFitBridgeValues.string(dictionary["storeStyle"]), !storeStyle.isEmpty
116
116
  else {
117
117
  return nil
118
118
  }
119
119
 
120
- let environment = string(dictionary["environment"]).flatMap(mapEnvironment) ?? .prod
121
- let uiLocale = string(dictionary["uiLocale"])?.nonEmpty
122
- let userToken = string(dictionary["userToken"])?.nonEmpty
120
+ let environment = TrueFitBridgeValues.string(dictionary["environment"])
121
+ .map(TrueFitBridgeValues.environment) ?? .prod
122
+ let uiLocale = TrueFitBridgeValues.string(dictionary["uiLocale"])?.nonEmpty
123
+ let userToken = TrueFitBridgeValues.string(dictionary["userToken"])?.nonEmpty
123
124
  // A full script URL overrides `environment` (e.g. a built bundle). Raw
124
125
  // Vite dev entries (.ts) are not supported by the SDK.
125
- let scriptUrlOverride = string(dictionary["scriptUrl"])?.nonEmpty
126
+ let scriptUrlOverride = TrueFitBridgeValues.string(dictionary["scriptUrl"])?.nonEmpty
126
127
 
127
128
  return TrueFitRecommendationConfig(
128
129
  storeKey: storeKey,
@@ -134,17 +135,6 @@ final class TrueFitReactNativeView: UIView {
134
135
  )
135
136
  }
136
137
 
137
- private static func mapEnvironment(_ name: String) -> TrueFitEnvironment {
138
- switch name.lowercased() {
139
- case "development", "dev":
140
- .development
141
- case "prod", "production":
142
- .prod
143
- default:
144
- .prod
145
- }
146
- }
147
-
148
138
  private static func options(from dictionary: NSDictionary?) -> TrueFitRecommendationOptions {
149
139
  var options = TrueFitRecommendationOptions()
150
140
  guard let dictionary else { return options }
@@ -173,14 +163,4 @@ final class TrueFitReactNativeView: UIView {
173
163
 
174
164
  return options
175
165
  }
176
-
177
- private static func string(_ value: Any?) -> String? {
178
- if let string = value as? String { return string }
179
- if let number = value as? NSNumber { return number.stringValue }
180
- return nil
181
- }
182
- }
183
-
184
- private extension String {
185
- var nonEmpty: String? { isEmpty ? nil : self }
186
166
  }
@@ -3,12 +3,38 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TrueFitRecommendationView = TrueFitRecommendationView;
7
- exports.default = void 0;
6
+ exports.trackOrder = exports.getToken = exports.default = exports.TrueFitRecommendationView = void 0;
8
7
  var _react = _interopRequireWildcard(require("react"));
9
8
  var _reactNative = require("react-native");
9
+ var _zod = require("zod");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
+ const DEVELOPMENT_BASE_URL = 'https://consumer-dev.truefitcorp.com';
13
+ const PRODUCTION_BASE_URL = 'https://consumer-v2.truefitcorp.com';
14
+ const LEGACY_USER_TOKEN_HEADER = 'x-tf-usertoken';
15
+ const USER_TOKEN_HEADER = 'x-tf-user-token';
16
+ const legacyUserMigrationSchema = _zod.z.object({
17
+ readLegacyUserToken: _zod.z.custom(value => typeof value === 'function'),
18
+ completeLegacyUserMigration: _zod.z.custom(value => typeof value === 'function'),
19
+ onLegacyUserMigrationError: _zod.z.custom(value => typeof value === 'function').optional()
20
+ });
21
+ const legacyUserTokenRecordSchema = _zod.z.object({
22
+ token: _zod.z.string().min(1),
23
+ creationTime: _zod.z.number().int().nonnegative(),
24
+ maxAge: _zod.z.number().int().nonnegative()
25
+ });
26
+ const migrationResponseSchema = _zod.z.object({
27
+ migrated: _zod.z.boolean()
28
+ });
29
+ const legacyUserMigrationStateSchema = _zod.z.discriminatedUnion('status', [_zod.z.object({
30
+ status: _zod.z.literal('pending'),
31
+ migrationKey: _zod.z.string()
32
+ }), _zod.z.object({
33
+ status: _zod.z.literal('ready'),
34
+ migrationKey: _zod.z.string().nullable(),
35
+ userToken: _zod.z.string().nullable()
36
+ })]);
37
+
12
38
  /**
13
39
  * Which True Fit environment to point at. The native SDKs resolve the widget
14
40
  * script URL from this internally; consumers never pass raw URLs.
@@ -20,17 +46,209 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
20
46
  * recommendation, `'general'` for a generic one, and `null` when there is none.
21
47
  */
22
48
 
49
+ /** One line item in a completed order, reported through {@link trackOrder}. */
50
+
23
51
  const NativeTrueFitRecommendationView = (0, _reactNative.requireNativeComponent)('TrueFitRecommendationView');
24
52
  const DEFAULT_MIN_HEIGHT = 86;
25
- function TrueFitRecommendationView({
26
- config,
27
- options,
28
- style,
29
- onPresentationModeChange,
30
- onHeightChange,
31
- onWidgetResult,
32
- onAutoSizeSelect
33
- }) {
53
+ const pendingLegacyUserMigrations = new Map();
54
+ const resolveApiBaseUrl = args => {
55
+ const {
56
+ config
57
+ } = args;
58
+ if (config.scriptUrl) return new URL(config.scriptUrl).origin;
59
+ if (config.environment === 'development') return DEVELOPMENT_BASE_URL;
60
+ return PRODUCTION_BASE_URL;
61
+ };
62
+ const parseLegacyUserTokenRecord = storedValue => legacyUserTokenRecordSchema.parse(JSON.parse(storedValue));
63
+ const isLegacyUserTokenExpired = args => {
64
+ const {
65
+ creationTime,
66
+ maxAge
67
+ } = args;
68
+ return Date.now() >= creationTime + maxAge;
69
+ };
70
+ const migrateLegacyUser = async args => {
71
+ const {
72
+ config,
73
+ legacyUserMigration
74
+ } = args;
75
+ const {
76
+ completeLegacyUserMigration,
77
+ readLegacyUserToken
78
+ } = legacyUserMigration;
79
+ const storedValue = await readLegacyUserToken();
80
+ if (!storedValue) {
81
+ try {
82
+ await completeLegacyUserMigration(null);
83
+ } catch (value) {
84
+ legacyUserMigration.onLegacyUserMigrationError?.(getError(value));
85
+ }
86
+ return null;
87
+ }
88
+ const legacyUserTokenRecord = parseLegacyUserTokenRecord(storedValue);
89
+ if (isLegacyUserTokenExpired(legacyUserTokenRecord)) {
90
+ try {
91
+ await completeLegacyUserMigration(storedValue);
92
+ } catch (value) {
93
+ legacyUserMigration.onLegacyUserMigrationError?.(getError(value));
94
+ }
95
+ return null;
96
+ }
97
+ const apiBaseUrl = resolveApiBaseUrl({
98
+ config
99
+ });
100
+ const migrationUrl = `${apiBaseUrl}/api/experiments?storeKey=${encodeURIComponent(config.storeKey ?? '')}&forceMigrate=true`;
101
+ const response = await fetch(migrationUrl, {
102
+ method: 'POST',
103
+ credentials: 'include',
104
+ headers: {
105
+ [LEGACY_USER_TOKEN_HEADER]: legacyUserTokenRecord.token
106
+ }
107
+ });
108
+ if (!response.ok) {
109
+ throw new Error(`Legacy user migration failed with status ${response.status}`);
110
+ }
111
+ const migrationResponse = migrationResponseSchema.parse(await response.json());
112
+ if (!migrationResponse.migrated) return null;
113
+ const migratedUserToken = response.headers.get(USER_TOKEN_HEADER)?.trim();
114
+ if (!migratedUserToken) {
115
+ throw new Error('Legacy user migration did not return a user token');
116
+ }
117
+ try {
118
+ await completeLegacyUserMigration(storedValue);
119
+ } catch (value) {
120
+ legacyUserMigration.onLegacyUserMigrationError?.(getError(value));
121
+ }
122
+ return migratedUserToken;
123
+ };
124
+ const getError = value => value instanceof Error ? value : new Error(String(value));
125
+ const getLegacyUserMigration = args => {
126
+ const {
127
+ config,
128
+ legacyUserMigration,
129
+ migrationKey
130
+ } = args;
131
+ const pendingMigration = pendingLegacyUserMigrations.get(migrationKey);
132
+ if (pendingMigration) return pendingMigration;
133
+ const migration = migrateLegacyUser({
134
+ config,
135
+ legacyUserMigration
136
+ });
137
+ pendingLegacyUserMigrations.set(migrationKey, migration);
138
+ const clearPendingMigration = () => {
139
+ if (pendingLegacyUserMigrations.get(migrationKey) === migration) {
140
+ pendingLegacyUserMigrations.delete(migrationKey);
141
+ }
142
+ };
143
+ void migration.then(clearPendingMigration, clearPendingMigration);
144
+ return migration;
145
+ };
146
+ const useLegacyUserMigration = args => {
147
+ const {
148
+ config,
149
+ legacyUserMigration
150
+ } = args;
151
+ const legacyUserMigrationRef = (0, _react.useRef)(legacyUserMigration);
152
+ legacyUserMigrationRef.current = legacyUserMigration;
153
+ const environment = config?.environment;
154
+ const scriptUrl = config?.scriptUrl;
155
+ const storeKey = config?.storeKey;
156
+ const configuredUserToken = config?.userToken;
157
+ const hasLegacyUserMigration = Boolean(legacyUserMigration);
158
+ const shouldMigrate = Boolean(hasLegacyUserMigration && storeKey && !configuredUserToken);
159
+ const migrationKey = JSON.stringify([environment, scriptUrl, storeKey]);
160
+ const [migrationState, setMigrationState] = (0, _react.useState)(() => {
161
+ if (shouldMigrate) return {
162
+ status: 'pending',
163
+ migrationKey
164
+ };
165
+ return {
166
+ status: 'ready',
167
+ migrationKey: null,
168
+ userToken: null
169
+ };
170
+ });
171
+ (0, _react.useEffect)(() => {
172
+ const currentLegacyUserMigration = legacyUserMigrationRef.current;
173
+ if (!currentLegacyUserMigration || !storeKey || configuredUserToken) {
174
+ setMigrationState({
175
+ status: 'ready',
176
+ migrationKey: null,
177
+ userToken: null
178
+ });
179
+ return;
180
+ }
181
+ const parsedLegacyUserMigration = legacyUserMigrationSchema.parse(currentLegacyUserMigration);
182
+ const migrationConfig = {
183
+ environment,
184
+ scriptUrl,
185
+ storeKey
186
+ };
187
+ let isActive = true;
188
+ setMigrationState({
189
+ status: 'pending',
190
+ migrationKey
191
+ });
192
+ const migrate = async () => {
193
+ try {
194
+ const userToken = await getLegacyUserMigration({
195
+ config: migrationConfig,
196
+ legacyUserMigration: parsedLegacyUserMigration,
197
+ migrationKey
198
+ });
199
+ if (isActive) {
200
+ setMigrationState({
201
+ status: 'ready',
202
+ migrationKey,
203
+ userToken
204
+ });
205
+ }
206
+ } catch (value) {
207
+ parsedLegacyUserMigration.onLegacyUserMigrationError?.(getError(value));
208
+ if (isActive) {
209
+ setMigrationState({
210
+ status: 'ready',
211
+ migrationKey,
212
+ userToken: null
213
+ });
214
+ }
215
+ }
216
+ };
217
+ void migrate();
218
+ return () => {
219
+ isActive = false;
220
+ };
221
+ }, [configuredUserToken, environment, hasLegacyUserMigration, scriptUrl, storeKey]);
222
+ if (!shouldMigrate) {
223
+ return {
224
+ status: 'ready',
225
+ migrationKey: null,
226
+ userToken: null
227
+ };
228
+ }
229
+ if (migrationState.migrationKey !== migrationKey) {
230
+ return {
231
+ status: 'pending',
232
+ migrationKey
233
+ };
234
+ }
235
+ return migrationState;
236
+ };
237
+ const TrueFitRecommendationView = args => {
238
+ const {
239
+ config,
240
+ legacyUserMigration,
241
+ options,
242
+ style,
243
+ onPresentationModeChange,
244
+ onHeightChange,
245
+ onWidgetResult,
246
+ onAutoSizeSelect
247
+ } = args;
248
+ const migrationState = useLegacyUserMigration({
249
+ config,
250
+ legacyUserMigration
251
+ });
34
252
  const minHeight = options?.minWidgetHeight ?? DEFAULT_MIN_HEIGHT;
35
253
  const [measuredHeight, setMeasuredHeight] = (0, _react.useState)(minHeight);
36
254
  const [presentationMode, setPresentationMode] = (0, _react.useState)('widget');
@@ -56,11 +274,16 @@ function TrueFitRecommendationView({
56
274
  zIndex: presentationMode === 'modal' ? 1000 : undefined,
57
275
  elevation: presentationMode === 'modal' ? 16 : undefined
58
276
  }], [measuredHeight, minHeight, presentationMode, style]);
277
+ if (migrationState.status === 'pending') return null;
278
+ const resolvedConfig = migrationState.userToken ? {
279
+ ...config,
280
+ userToken: migrationState.userToken
281
+ } : config;
59
282
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
60
283
  style: containerStyle,
61
284
  collapsable: false,
62
285
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeTrueFitRecommendationView, {
63
- config: config,
286
+ config: resolvedConfig,
64
287
  options: options,
65
288
  style: styles.nativeView,
66
289
  onHeightChange: handleHeightChange,
@@ -69,7 +292,8 @@ function TrueFitRecommendationView({
69
292
  onAutoSizeSelect: handleAutoSizeSelect
70
293
  })
71
294
  });
72
- }
295
+ };
296
+ exports.TrueFitRecommendationView = TrueFitRecommendationView;
73
297
  const styles = _reactNative.StyleSheet.create({
74
298
  container: {
75
299
  width: '100%',
@@ -81,5 +305,41 @@ const styles = _reactNative.StyleSheet.create({
81
305
  height: '100%'
82
306
  }
83
307
  });
308
+ const trueFitNativeModule = _reactNative.NativeModules.TrueFitOrderModule;
309
+
310
+ /** Returns the current True Fit user token from the native WebView cookie store. */
311
+ const getToken = async () => {
312
+ if (!trueFitNativeModule) {
313
+ throw new Error("True Fit token access is unavailable because the native module is not linked. Rebuild the app after installing 'consumer-app-react-native-sdk' (on iOS, run pod install first).");
314
+ }
315
+ return trueFitNativeModule.getToken();
316
+ };
317
+
318
+ /**
319
+ * Reports a completed order to True Fit, for the order confirmation screen.
320
+ * Forwards straight to the native SDKs' order API, which posts in the
321
+ * background and never reports delivery back — so there is nothing to await.
322
+ */
323
+ exports.getToken = getToken;
324
+ const trackOrder = args => {
325
+ const {
326
+ storeKey,
327
+ orderId,
328
+ products,
329
+ environment = 'prod',
330
+ locale
331
+ } = args;
332
+ if (!trueFitNativeModule) {
333
+ throw new Error("True Fit order tracking is unavailable because the native module is not linked. Rebuild the app after installing 'consumer-app-react-native-sdk' (on iOS, run pod install first).");
334
+ }
335
+ trueFitNativeModule.trackOrder({
336
+ storeKey,
337
+ orderId,
338
+ products,
339
+ environment,
340
+ locale
341
+ });
342
+ };
343
+ exports.trackOrder = trackOrder;
84
344
  var _default = exports.default = TrueFitRecommendationView;
85
345
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NativeTrueFitRecommendationView","requireNativeComponent","DEFAULT_MIN_HEIGHT","TrueFitRecommendationView","config","options","style","onPresentationModeChange","onHeightChange","onWidgetResult","onAutoSizeSelect","minHeight","minWidgetHeight","measuredHeight","setMeasuredHeight","useState","presentationMode","setPresentationMode","handleHeightChange","useCallback","event","nextHeight","Math","max","nativeEvent","height","handlePresentationModeChange","nextMode","mode","styleId","handleWidgetResult","handleAutoSizeSelect","containerStyle","useMemo","styles","container","zIndex","undefined","elevation","jsx","View","collapsable","children","nativeView","StyleSheet","create","width","overflow","position","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOsB,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,i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AAI;IAAClC,KAAK,EAAE0B,cAAe;IAACS,WAAW,EAAE,KAAM;IAAAC,QAAA,eAC9C,IAAA9D,WAAA,CAAA2D,GAAA,EAACvC,+BAA+B;MAC9BI,MAAM,EAAEA,MAAO;MACfC,OAAO,EAAEA,OAAQ;MACjBC,KAAK,EAAE4B,MAAM,CAACS,UAAW;MACzBnC,cAAc,EAAEU,kBAAmB;MACnCX,wBAAwB,EAAEmB,4BAA6B;MACvDjB,cAAc,EAAEqB,kBAAmB;MACnCpB,gBAAgB,EAAEqB;IAAqB,CACxC;EAAC,CACE,CAAC;AAEX;AAEA,MAAMG,MAAM,GAAGU,uBAAU,CAACC,MAAM,CAAC;EAC/BV,SAAS,EAAE;IACTW,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE,SAAS;IACnBC,QAAQ,EAAE;EACZ,CAAC;EACDL,UAAU,EAAE;IACVG,KAAK,EAAE,MAAM;IACbrB,MAAM,EAAE;EACV;AACF,CAAC,CAAC;AAAC,IAAAwB,QAAA,GAAAC,OAAA,CAAA3D,OAAA,GAEYY,yBAAyB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_zod","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEVELOPMENT_BASE_URL","PRODUCTION_BASE_URL","LEGACY_USER_TOKEN_HEADER","USER_TOKEN_HEADER","legacyUserMigrationSchema","z","object","readLegacyUserToken","custom","value","completeLegacyUserMigration","onLegacyUserMigrationError","optional","legacyUserTokenRecordSchema","token","string","min","creationTime","number","int","nonnegative","maxAge","migrationResponseSchema","migrated","boolean","legacyUserMigrationStateSchema","discriminatedUnion","status","literal","migrationKey","nullable","userToken","NativeTrueFitRecommendationView","requireNativeComponent","DEFAULT_MIN_HEIGHT","pendingLegacyUserMigrations","Map","resolveApiBaseUrl","args","config","scriptUrl","URL","origin","environment","parseLegacyUserTokenRecord","storedValue","parse","JSON","isLegacyUserTokenExpired","Date","now","migrateLegacyUser","legacyUserMigration","getError","legacyUserTokenRecord","apiBaseUrl","migrationUrl","encodeURIComponent","storeKey","response","fetch","method","credentials","headers","ok","Error","migrationResponse","json","migratedUserToken","trim","String","getLegacyUserMigration","pendingMigration","migration","clearPendingMigration","delete","then","useLegacyUserMigration","legacyUserMigrationRef","useRef","current","configuredUserToken","hasLegacyUserMigration","Boolean","shouldMigrate","stringify","migrationState","setMigrationState","useState","useEffect","currentLegacyUserMigration","parsedLegacyUserMigration","migrationConfig","isActive","migrate","TrueFitRecommendationView","options","style","onPresentationModeChange","onHeightChange","onWidgetResult","onAutoSizeSelect","minHeight","minWidgetHeight","measuredHeight","setMeasuredHeight","presentationMode","setPresentationMode","handleHeightChange","useCallback","event","nextHeight","Math","max","nativeEvent","height","handlePresentationModeChange","nextMode","mode","styleId","handleWidgetResult","handleAutoSizeSelect","containerStyle","useMemo","styles","container","zIndex","undefined","elevation","resolvedConfig","jsx","View","collapsable","children","nativeView","exports","StyleSheet","create","width","overflow","position","trueFitNativeModule","NativeModules","TrueFitOrderModule","getToken","trackOrder","orderId","products","locale","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,IAAA,GAAAF,OAAA;AAAwB,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,C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IAAEwF,OAAO;IAAEC,QAAQ;IAAExG,WAAW,GAAG,MAAM;IAAEyG;EAAO,CAAC,GAAG9G,IAAI;EAE1E,IAAI,CAACuG,mBAAmB,EAAE;IACxB,MAAM,IAAI5E,KAAK,CACb,mLACF,CAAC;EACH;EAEA4E,mBAAmB,CAACI,UAAU,CAAC;IAAEvF,QAAQ;IAAEwF,OAAO;IAAEC,QAAQ;IAAExG,WAAW;IAAEyG;EAAO,CAAC,CAAC;AACtF,CAAC;AAACb,OAAA,CAAAU,UAAA,GAAAA,UAAA;AAAA,IAAAI,QAAA,GAAAd,OAAA,CAAAhJ,OAAA,GAEawG,yBAAyB","ignoreList":[]}
@@ -1,7 +1,34 @@
1
1
  "use strict";
2
2
 
3
- import React, { useCallback, useMemo, useState } from 'react';
4
- import { requireNativeComponent, StyleSheet, View } from 'react-native';
3
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
+ import { NativeModules, requireNativeComponent, StyleSheet, View } from 'react-native';
5
+ import { z } from 'zod';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const DEVELOPMENT_BASE_URL = 'https://consumer-dev.truefitcorp.com';
8
+ const PRODUCTION_BASE_URL = 'https://consumer-v2.truefitcorp.com';
9
+ const LEGACY_USER_TOKEN_HEADER = 'x-tf-usertoken';
10
+ const USER_TOKEN_HEADER = 'x-tf-user-token';
11
+ const legacyUserMigrationSchema = z.object({
12
+ readLegacyUserToken: z.custom(value => typeof value === 'function'),
13
+ completeLegacyUserMigration: z.custom(value => typeof value === 'function'),
14
+ onLegacyUserMigrationError: z.custom(value => typeof value === 'function').optional()
15
+ });
16
+ const legacyUserTokenRecordSchema = z.object({
17
+ token: z.string().min(1),
18
+ creationTime: z.number().int().nonnegative(),
19
+ maxAge: z.number().int().nonnegative()
20
+ });
21
+ const migrationResponseSchema = z.object({
22
+ migrated: z.boolean()
23
+ });
24
+ const legacyUserMigrationStateSchema = z.discriminatedUnion('status', [z.object({
25
+ status: z.literal('pending'),
26
+ migrationKey: z.string()
27
+ }), z.object({
28
+ status: z.literal('ready'),
29
+ migrationKey: z.string().nullable(),
30
+ userToken: z.string().nullable()
31
+ })]);
5
32
 
6
33
  /**
7
34
  * Which True Fit environment to point at. The native SDKs resolve the widget
@@ -13,18 +40,210 @@ import { requireNativeComponent, StyleSheet, View } from 'react-native';
13
40
  * `successType` is `'personal'` when the shopper has a profile-based
14
41
  * recommendation, `'general'` for a generic one, and `null` when there is none.
15
42
  */
16
- import { jsx as _jsx } from "react/jsx-runtime";
43
+
44
+ /** One line item in a completed order, reported through {@link trackOrder}. */
45
+
17
46
  const NativeTrueFitRecommendationView = requireNativeComponent('TrueFitRecommendationView');
18
47
  const DEFAULT_MIN_HEIGHT = 86;
19
- export function TrueFitRecommendationView({
20
- config,
21
- options,
22
- style,
23
- onPresentationModeChange,
24
- onHeightChange,
25
- onWidgetResult,
26
- onAutoSizeSelect
27
- }) {
48
+ const pendingLegacyUserMigrations = new Map();
49
+ const resolveApiBaseUrl = args => {
50
+ const {
51
+ config
52
+ } = args;
53
+ if (config.scriptUrl) return new URL(config.scriptUrl).origin;
54
+ if (config.environment === 'development') return DEVELOPMENT_BASE_URL;
55
+ return PRODUCTION_BASE_URL;
56
+ };
57
+ const parseLegacyUserTokenRecord = storedValue => legacyUserTokenRecordSchema.parse(JSON.parse(storedValue));
58
+ const isLegacyUserTokenExpired = args => {
59
+ const {
60
+ creationTime,
61
+ maxAge
62
+ } = args;
63
+ return Date.now() >= creationTime + maxAge;
64
+ };
65
+ const migrateLegacyUser = async args => {
66
+ const {
67
+ config,
68
+ legacyUserMigration
69
+ } = args;
70
+ const {
71
+ completeLegacyUserMigration,
72
+ readLegacyUserToken
73
+ } = legacyUserMigration;
74
+ const storedValue = await readLegacyUserToken();
75
+ if (!storedValue) {
76
+ try {
77
+ await completeLegacyUserMigration(null);
78
+ } catch (value) {
79
+ legacyUserMigration.onLegacyUserMigrationError?.(getError(value));
80
+ }
81
+ return null;
82
+ }
83
+ const legacyUserTokenRecord = parseLegacyUserTokenRecord(storedValue);
84
+ if (isLegacyUserTokenExpired(legacyUserTokenRecord)) {
85
+ try {
86
+ await completeLegacyUserMigration(storedValue);
87
+ } catch (value) {
88
+ legacyUserMigration.onLegacyUserMigrationError?.(getError(value));
89
+ }
90
+ return null;
91
+ }
92
+ const apiBaseUrl = resolveApiBaseUrl({
93
+ config
94
+ });
95
+ const migrationUrl = `${apiBaseUrl}/api/experiments?storeKey=${encodeURIComponent(config.storeKey ?? '')}&forceMigrate=true`;
96
+ const response = await fetch(migrationUrl, {
97
+ method: 'POST',
98
+ credentials: 'include',
99
+ headers: {
100
+ [LEGACY_USER_TOKEN_HEADER]: legacyUserTokenRecord.token
101
+ }
102
+ });
103
+ if (!response.ok) {
104
+ throw new Error(`Legacy user migration failed with status ${response.status}`);
105
+ }
106
+ const migrationResponse = migrationResponseSchema.parse(await response.json());
107
+ if (!migrationResponse.migrated) return null;
108
+ const migratedUserToken = response.headers.get(USER_TOKEN_HEADER)?.trim();
109
+ if (!migratedUserToken) {
110
+ throw new Error('Legacy user migration did not return a user token');
111
+ }
112
+ try {
113
+ await completeLegacyUserMigration(storedValue);
114
+ } catch (value) {
115
+ legacyUserMigration.onLegacyUserMigrationError?.(getError(value));
116
+ }
117
+ return migratedUserToken;
118
+ };
119
+ const getError = value => value instanceof Error ? value : new Error(String(value));
120
+ const getLegacyUserMigration = args => {
121
+ const {
122
+ config,
123
+ legacyUserMigration,
124
+ migrationKey
125
+ } = args;
126
+ const pendingMigration = pendingLegacyUserMigrations.get(migrationKey);
127
+ if (pendingMigration) return pendingMigration;
128
+ const migration = migrateLegacyUser({
129
+ config,
130
+ legacyUserMigration
131
+ });
132
+ pendingLegacyUserMigrations.set(migrationKey, migration);
133
+ const clearPendingMigration = () => {
134
+ if (pendingLegacyUserMigrations.get(migrationKey) === migration) {
135
+ pendingLegacyUserMigrations.delete(migrationKey);
136
+ }
137
+ };
138
+ void migration.then(clearPendingMigration, clearPendingMigration);
139
+ return migration;
140
+ };
141
+ const useLegacyUserMigration = args => {
142
+ const {
143
+ config,
144
+ legacyUserMigration
145
+ } = args;
146
+ const legacyUserMigrationRef = useRef(legacyUserMigration);
147
+ legacyUserMigrationRef.current = legacyUserMigration;
148
+ const environment = config?.environment;
149
+ const scriptUrl = config?.scriptUrl;
150
+ const storeKey = config?.storeKey;
151
+ const configuredUserToken = config?.userToken;
152
+ const hasLegacyUserMigration = Boolean(legacyUserMigration);
153
+ const shouldMigrate = Boolean(hasLegacyUserMigration && storeKey && !configuredUserToken);
154
+ const migrationKey = JSON.stringify([environment, scriptUrl, storeKey]);
155
+ const [migrationState, setMigrationState] = useState(() => {
156
+ if (shouldMigrate) return {
157
+ status: 'pending',
158
+ migrationKey
159
+ };
160
+ return {
161
+ status: 'ready',
162
+ migrationKey: null,
163
+ userToken: null
164
+ };
165
+ });
166
+ useEffect(() => {
167
+ const currentLegacyUserMigration = legacyUserMigrationRef.current;
168
+ if (!currentLegacyUserMigration || !storeKey || configuredUserToken) {
169
+ setMigrationState({
170
+ status: 'ready',
171
+ migrationKey: null,
172
+ userToken: null
173
+ });
174
+ return;
175
+ }
176
+ const parsedLegacyUserMigration = legacyUserMigrationSchema.parse(currentLegacyUserMigration);
177
+ const migrationConfig = {
178
+ environment,
179
+ scriptUrl,
180
+ storeKey
181
+ };
182
+ let isActive = true;
183
+ setMigrationState({
184
+ status: 'pending',
185
+ migrationKey
186
+ });
187
+ const migrate = async () => {
188
+ try {
189
+ const userToken = await getLegacyUserMigration({
190
+ config: migrationConfig,
191
+ legacyUserMigration: parsedLegacyUserMigration,
192
+ migrationKey
193
+ });
194
+ if (isActive) {
195
+ setMigrationState({
196
+ status: 'ready',
197
+ migrationKey,
198
+ userToken
199
+ });
200
+ }
201
+ } catch (value) {
202
+ parsedLegacyUserMigration.onLegacyUserMigrationError?.(getError(value));
203
+ if (isActive) {
204
+ setMigrationState({
205
+ status: 'ready',
206
+ migrationKey,
207
+ userToken: null
208
+ });
209
+ }
210
+ }
211
+ };
212
+ void migrate();
213
+ return () => {
214
+ isActive = false;
215
+ };
216
+ }, [configuredUserToken, environment, hasLegacyUserMigration, scriptUrl, storeKey]);
217
+ if (!shouldMigrate) {
218
+ return {
219
+ status: 'ready',
220
+ migrationKey: null,
221
+ userToken: null
222
+ };
223
+ }
224
+ if (migrationState.migrationKey !== migrationKey) {
225
+ return {
226
+ status: 'pending',
227
+ migrationKey
228
+ };
229
+ }
230
+ return migrationState;
231
+ };
232
+ export const TrueFitRecommendationView = args => {
233
+ const {
234
+ config,
235
+ legacyUserMigration,
236
+ options,
237
+ style,
238
+ onPresentationModeChange,
239
+ onHeightChange,
240
+ onWidgetResult,
241
+ onAutoSizeSelect
242
+ } = args;
243
+ const migrationState = useLegacyUserMigration({
244
+ config,
245
+ legacyUserMigration
246
+ });
28
247
  const minHeight = options?.minWidgetHeight ?? DEFAULT_MIN_HEIGHT;
29
248
  const [measuredHeight, setMeasuredHeight] = useState(minHeight);
30
249
  const [presentationMode, setPresentationMode] = useState('widget');
@@ -50,11 +269,16 @@ export function TrueFitRecommendationView({
50
269
  zIndex: presentationMode === 'modal' ? 1000 : undefined,
51
270
  elevation: presentationMode === 'modal' ? 16 : undefined
52
271
  }], [measuredHeight, minHeight, presentationMode, style]);
272
+ if (migrationState.status === 'pending') return null;
273
+ const resolvedConfig = migrationState.userToken ? {
274
+ ...config,
275
+ userToken: migrationState.userToken
276
+ } : config;
53
277
  return /*#__PURE__*/_jsx(View, {
54
278
  style: containerStyle,
55
279
  collapsable: false,
56
280
  children: /*#__PURE__*/_jsx(NativeTrueFitRecommendationView, {
57
- config: config,
281
+ config: resolvedConfig,
58
282
  options: options,
59
283
  style: styles.nativeView,
60
284
  onHeightChange: handleHeightChange,
@@ -63,7 +287,7 @@ export function TrueFitRecommendationView({
63
287
  onAutoSizeSelect: handleAutoSizeSelect
64
288
  })
65
289
  });
66
- }
290
+ };
67
291
  const styles = StyleSheet.create({
68
292
  container: {
69
293
  width: '100%',
@@ -75,5 +299,39 @@ const styles = StyleSheet.create({
75
299
  height: '100%'
76
300
  }
77
301
  });
302
+ const trueFitNativeModule = NativeModules.TrueFitOrderModule;
303
+
304
+ /** Returns the current True Fit user token from the native WebView cookie store. */
305
+ export const getToken = async () => {
306
+ if (!trueFitNativeModule) {
307
+ throw new Error("True Fit token access is unavailable because the native module is not linked. Rebuild the app after installing 'consumer-app-react-native-sdk' (on iOS, run pod install first).");
308
+ }
309
+ return trueFitNativeModule.getToken();
310
+ };
311
+
312
+ /**
313
+ * Reports a completed order to True Fit, for the order confirmation screen.
314
+ * Forwards straight to the native SDKs' order API, which posts in the
315
+ * background and never reports delivery back — so there is nothing to await.
316
+ */
317
+ export const trackOrder = args => {
318
+ const {
319
+ storeKey,
320
+ orderId,
321
+ products,
322
+ environment = 'prod',
323
+ locale
324
+ } = args;
325
+ if (!trueFitNativeModule) {
326
+ throw new Error("True Fit order tracking is unavailable because the native module is not linked. Rebuild the app after installing 'consumer-app-react-native-sdk' (on iOS, run pod install first).");
327
+ }
328
+ trueFitNativeModule.trackOrder({
329
+ storeKey,
330
+ orderId,
331
+ products,
332
+ environment,
333
+ locale
334
+ });
335
+ };
78
336
  export default TrueFitRecommendationView;
79
337
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useCallback","useMemo","useState","requireNativeComponent","StyleSheet","View","jsx","_jsx","NativeTrueFitRecommendationView","DEFAULT_MIN_HEIGHT","TrueFitRecommendationView","config","options","style","onPresentationModeChange","onHeightChange","onWidgetResult","onAutoSizeSelect","minHeight","minWidgetHeight","measuredHeight","setMeasuredHeight","presentationMode","setPresentationMode","handleHeightChange","event","nextHeight","Math","max","nativeEvent","height","handlePresentationModeChange","nextMode","mode","styleId","handleWidgetResult","handleAutoSizeSelect","containerStyle","styles","container","zIndex","undefined","elevation","collapsable","children","nativeView","create","width","overflow","position"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW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;AAEF,eAAepB,yBAAyB","ignoreList":[]}
1
+ {"version":3,"names":["React","useCallback","useEffect","useMemo","useRef","useState","NativeModules","requireNativeComponent","StyleSheet","View","z","jsx","_jsx","DEVELOPMENT_BASE_URL","PRODUCTION_BASE_URL","LEGACY_USER_TOKEN_HEADER","USER_TOKEN_HEADER","legacyUserMigrationSchema","object","readLegacyUserToken","custom","value","completeLegacyUserMigration","onLegacyUserMigrationError","optional","legacyUserTokenRecordSchema","token","string","min","creationTime","number","int","nonnegative","maxAge","migrationResponseSchema","migrated","boolean","legacyUserMigrationStateSchema","discriminatedUnion","status","literal","migrationKey","nullable","userToken","NativeTrueFitRecommendationView","DEFAULT_MIN_HEIGHT","pendingLegacyUserMigrations","Map","resolveApiBaseUrl","args","config","scriptUrl","URL","origin","environment","parseLegacyUserTokenRecord","storedValue","parse","JSON","isLegacyUserTokenExpired","Date","now","migrateLegacyUser","legacyUserMigration","getError","legacyUserTokenRecord","apiBaseUrl","migrationUrl","encodeURIComponent","storeKey","response","fetch","method","credentials","headers","ok","Error","migrationResponse","json","migratedUserToken","get","trim","String","getLegacyUserMigration","pendingMigration","migration","set","clearPendingMigration","delete","then","useLegacyUserMigration","legacyUserMigrationRef","current","configuredUserToken","hasLegacyUserMigration","Boolean","shouldMigrate","stringify","migrationState","setMigrationState","currentLegacyUserMigration","parsedLegacyUserMigration","migrationConfig","isActive","migrate","TrueFitRecommendationView","options","style","onPresentationModeChange","onHeightChange","onWidgetResult","onAutoSizeSelect","minHeight","minWidgetHeight","measuredHeight","setMeasuredHeight","presentationMode","setPresentationMode","handleHeightChange","event","nextHeight","Math","max","nativeEvent","height","handlePresentationModeChange","nextMode","mode","styleId","handleWidgetResult","handleAutoSizeSelect","containerStyle","styles","container","zIndex","undefined","elevation","resolvedConfig","collapsable","children","nativeView","create","width","overflow","position","trueFitNativeModule","TrueFitOrderModule","getToken","trackOrder","orderId","products","locale"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,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,cAAc,EAAEmB,kBAAmB;MACnClB,gBAAgB,EAAEmB;IAAqB,CACxC;EAAC,CACE,CAAC;AAEX,CAAC;AAED,MAAME,MAAM,GAAG5H,UAAU,CAACqI,MAAM,CAAC;EAC/BR,SAAS,EAAE;IACTS,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE,SAAS;IACnBC,QAAQ,EAAE;EACZ,CAAC;EACDJ,UAAU,EAAE;IACVE,KAAK,EAAE,MAAM;IACblB,MAAM,EAAE;EACV;AACF,CAAC,CAAC;AAEF,MAAMqB,mBAAoD,GAAG3I,aAAa,CAAC4I,kBAAkB;;AAE7F;AACA,OAAO,MAAMC,QAAQ,GAAG,MAAAA,CAAA,KAAoC;EAC1D,IAAI,CAACF,mBAAmB,EAAE;IACxB,MAAM,IAAIrE,KAAK,CACb,iLACF,CAAC;EACH;EACA,OAAOqE,mBAAmB,CAACE,QAAQ,CAAC,CAAC;AACvC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAInG,IAAoB,IAAK;EAClD,MAAM;IAAEoB,QAAQ;IAAEgF,OAAO;IAAEC,QAAQ;IAAEhG,WAAW,GAAG,MAAM;IAAEiG;EAAO,CAAC,GAAGtG,IAAI;EAE1E,IAAI,CAACgG,mBAAmB,EAAE;IACxB,MAAM,IAAIrE,KAAK,CACb,mLACF,CAAC;EACH;EAEAqE,mBAAmB,CAACG,UAAU,CAAC;IAAE/E,QAAQ;IAAEgF,OAAO;IAAEC,QAAQ;IAAEhG,WAAW;IAAEiG;EAAO,CAAC,CAAC;AACtF,CAAC;AAED,eAAe9C,yBAAyB","ignoreList":[]}
@@ -1,5 +1,12 @@
1
1
  import React from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
+ import { z } from 'zod';
4
+ declare const legacyUserMigrationSchema: z.ZodObject<{
5
+ readLegacyUserToken: z.ZodCustom<() => Promise<string | null>, () => Promise<string | null>>;
6
+ completeLegacyUserMigration: z.ZodCustom<(storedValue: string | null) => Promise<void>, (storedValue: string | null) => Promise<void>>;
7
+ onLegacyUserMigrationError: z.ZodOptional<z.ZodCustom<(error: Error) => void, (error: Error) => void>>;
8
+ }, z.core.$strip>;
9
+ export type LegacyUserMigration = z.infer<typeof legacyUserMigrationSchema>;
3
10
  /**
4
11
  * Which True Fit environment to point at. The native SDKs resolve the widget
5
12
  * script URL from this internally; consumers never pass raw URLs.
@@ -10,7 +17,7 @@ export type TrueFitRecommendationConfig = {
10
17
  storeKey?: string;
11
18
  storeStyle?: string;
12
19
  uiLocale?: string;
13
- /** Connect user token to seed into the Android widget cookie store. */
20
+ /** Connect user token used once to seed the native WebView cookie store. */
14
21
  userToken?: string;
15
22
  /**
16
23
  * Full widget script URL that overrides `environment` (e.g. a built bundle).
@@ -46,8 +53,32 @@ export type TrueFitAutoSizeSelect = {
46
53
  styleId: string;
47
54
  size: string;
48
55
  };
56
+ /** One line item in a completed order, reported through {@link trackOrder}. */
57
+ export type TFTrackOrderProduct = {
58
+ /**
59
+ * The style purchased. Must match the ProductID supplied in the Product
60
+ * Catalog feed; line items without one are dropped before the order is sent.
61
+ */
62
+ productId: string;
63
+ quantity: number;
64
+ /** Unit price paid — the final price if the item was on sale. */
65
+ price: number;
66
+ currency: string;
67
+ colorId?: string;
68
+ size?: string;
69
+ sku?: string;
70
+ };
71
+ export type TrackOrderArgs = {
72
+ storeKey: string;
73
+ orderId: string;
74
+ products: TFTrackOrderProduct[];
75
+ /** Pass the same value the widget uses so both target one backend. */
76
+ environment?: TrueFitEnvironment;
77
+ locale?: string;
78
+ };
49
79
  export type TrueFitRecommendationViewProps = {
50
80
  config?: TrueFitRecommendationConfig;
81
+ legacyUserMigration?: LegacyUserMigration;
51
82
  options?: TrueFitRecommendationOptions;
52
83
  style?: StyleProp<ViewStyle>;
53
84
  onPresentationModeChange?: (mode: TrueFitPresentationMode, styleId?: string | null) => void;
@@ -55,6 +86,14 @@ export type TrueFitRecommendationViewProps = {
55
86
  onWidgetResult?: (result: TrueFitWidgetResult) => void;
56
87
  onAutoSizeSelect?: (selection: TrueFitAutoSizeSelect) => void;
57
88
  };
58
- export declare function TrueFitRecommendationView({ config, options, style, onPresentationModeChange, onHeightChange, onWidgetResult, onAutoSizeSelect, }: TrueFitRecommendationViewProps): React.JSX.Element;
89
+ export declare const TrueFitRecommendationView: (args: TrueFitRecommendationViewProps) => React.JSX.Element | null;
90
+ /** Returns the current True Fit user token from the native WebView cookie store. */
91
+ export declare const getToken: () => Promise<string | null>;
92
+ /**
93
+ * Reports a completed order to True Fit, for the order confirmation screen.
94
+ * Forwards straight to the native SDKs' order API, which posts in the
95
+ * background and never reports delivery back — so there is nothing to await.
96
+ */
97
+ export declare const trackOrder: (args: TrackOrderArgs) => void;
59
98
  export default TrueFitRecommendationView;
60
99
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAGL,SAAS,EAGT,SAAS,EACV,MAAM,cAAc,CAAC;AAEtB;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yBAAyB,CAAC,EAAE,MAA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,IAAI,EAAE,uBAAuB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5F,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACvD,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAC;CAC/D,CAAC;AA0KF,eAAO,MAAM,yBAAyB,GAAI,MAAM,8BAA8B,6BAoF7E,CAAC;AAgBF,oFAAoF;AACpF,eAAO,MAAM,QAAQ,QAAa,OAAO,CAAC,MAAM,GAAG,IAAI,CAOtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,cAAc,SAU9C,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tfcorp/consumer-app-react-native-sdk",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "React Native bridge for the True Fit recommendation WebView SDK.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -25,6 +25,9 @@
25
25
  "react": "*",
26
26
  "react-native": "*"
27
27
  },
28
+ "dependencies": {
29
+ "zod": "4.3.6"
30
+ },
28
31
  "devDependencies": {
29
32
  "@types/react": "^18.2.0",
30
33
  "del-cli": "^5.1.0",