@app-swiss-knife/react-native-sdk 0.1.1 → 0.2.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 (53) hide show
  1. package/README.md +51 -0
  2. package/android/build.gradle +7 -0
  3. package/android/consumer-rules.pro +64 -0
  4. package/android/src/main/java/com/swissknife/purchases/Conversions.kt +85 -0
  5. package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +37 -30
  6. package/android/vendor/java/com/appswissknife/SwissKnife.kt +219 -51
  7. package/android/vendor/java/com/appswissknife/attribution/Attribution.kt +177 -25
  8. package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +1 -1
  9. package/android/vendor/java/com/appswissknife/identity/Identity.kt +15 -0
  10. package/android/vendor/java/com/appswissknife/net/IngestClient.kt +1 -1
  11. package/ios/SwissKnifePurchases.m +8 -0
  12. package/ios/SwissKnifePurchases.swift +35 -0
  13. package/ios/vendor/SwissKnifeiOS/Attribution/Attribution.swift +25 -7
  14. package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +1 -1
  15. package/ios/vendor/SwissKnifeiOS/Identity/Identity.swift +8 -2
  16. package/ios/vendor/SwissKnifeiOS/Net/BackendHttpClient.swift +32 -1
  17. package/ios/vendor/SwissKnifeiOS/Services/EntitlementsService.swift +35 -5
  18. package/ios/vendor/SwissKnifeiOS/Services/PurchaseService.swift +39 -22
  19. package/ios/vendor/SwissKnifeiOS/SwissKnife+DeviceID.swift +12 -2
  20. package/ios/vendor/SwissKnifeiOS/SwissKnife.swift +270 -32
  21. package/lib/commonjs/identity.js +59 -4
  22. package/lib/commonjs/identity.js.map +1 -1
  23. package/lib/commonjs/native/spec.js.map +1 -1
  24. package/lib/commonjs/purchases.js +95 -3
  25. package/lib/commonjs/purchases.js.map +1 -1
  26. package/lib/commonjs/types.js.map +1 -1
  27. package/lib/module/identity.js +59 -4
  28. package/lib/module/identity.js.map +1 -1
  29. package/lib/module/native/spec.js.map +1 -1
  30. package/lib/module/purchases.js +95 -3
  31. package/lib/module/purchases.js.map +1 -1
  32. package/lib/module/types.js.map +1 -1
  33. package/lib/typescript/commonjs/identity.d.ts +30 -4
  34. package/lib/typescript/commonjs/identity.d.ts.map +1 -1
  35. package/lib/typescript/commonjs/native/spec.d.ts +27 -0
  36. package/lib/typescript/commonjs/native/spec.d.ts.map +1 -1
  37. package/lib/typescript/commonjs/purchases.d.ts +46 -1
  38. package/lib/typescript/commonjs/purchases.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/types.d.ts +11 -2
  40. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  41. package/lib/typescript/module/identity.d.ts +30 -4
  42. package/lib/typescript/module/identity.d.ts.map +1 -1
  43. package/lib/typescript/module/native/spec.d.ts +27 -0
  44. package/lib/typescript/module/native/spec.d.ts.map +1 -1
  45. package/lib/typescript/module/purchases.d.ts +46 -1
  46. package/lib/typescript/module/purchases.d.ts.map +1 -1
  47. package/lib/typescript/module/types.d.ts +11 -2
  48. package/lib/typescript/module/types.d.ts.map +1 -1
  49. package/package.json +1 -1
  50. package/src/identity.ts +63 -4
  51. package/src/native/spec.ts +30 -0
  52. package/src/purchases.ts +103 -4
  53. package/src/types.ts +11 -2
@@ -208,7 +208,7 @@ internal object IngestPlaceholderDevice {
208
208
  appBuild = "unknown",
209
209
  locale = Locale.getDefault().toString(),
210
210
  timezone = TimeZone.getDefault().id,
211
- sdkVersion = "0.1.1",
211
+ sdkVersion = "0.2.0",
212
212
  bundleIdentifier = null,
213
213
  )
214
214
  }
@@ -10,9 +10,17 @@ RCT_EXTERN_METHOD(configure:(NSDictionary *)options
10
10
  resolver:(RCTPromiseResolveBlock)resolve
11
11
  rejecter:(RCTPromiseRejectBlock)reject)
12
12
 
13
+ // Core without the store — no StoreKit observer, no install registration.
14
+ RCT_EXTERN_METHOD(configureCore:(NSDictionary *)options
15
+ resolver:(RCTPromiseResolveBlock)resolve
16
+ rejecter:(RCTPromiseRejectBlock)reject)
17
+
13
18
  RCT_EXTERN_METHOD(isConfigured:(RCTPromiseResolveBlock)resolve
14
19
  rejecter:(RCTPromiseRejectBlock)reject)
15
20
 
21
+ RCT_EXTERN_METHOD(isCoreConfigured:(RCTPromiseResolveBlock)resolve
22
+ rejecter:(RCTPromiseRejectBlock)reject)
23
+
16
24
  RCT_EXTERN_METHOD(getCustomerInfo:(RCTPromiseResolveBlock)resolve
17
25
  rejecter:(RCTPromiseRejectBlock)reject)
18
26
 
@@ -104,12 +104,47 @@ class SwissKnifePurchases: RCTEventEmitter {
104
104
  resolve(nil)
105
105
  }
106
106
 
107
+ // Configure everything EXCEPT the store. Starts NO
108
+ // `StoreKit.Transaction.updates` observer, so an app whose purchases are
109
+ // owned by another library (RevenueCat, hand-rolled StoreKit) can adopt
110
+ // identity / attribution / analytics without two observers racing to
111
+ // `transaction.finish()` the same renewal. Also registers no install.
112
+ @objc(configureCore:resolver:rejecter:)
113
+ func configureCore(_ options: NSDictionary,
114
+ resolver resolve: @escaping RCTPromiseResolveBlock,
115
+ rejecter reject: @escaping RCTPromiseRejectBlock) {
116
+ guard let apiKey = options["apiKey"] as? String, !apiKey.isEmpty else {
117
+ reject("CONFIGURATION", "configureCore requires a non-empty apiKey", nil)
118
+ return
119
+ }
120
+ let attribution = SwissKnife.Attribution.Configuration(
121
+ autoPromptATT: (options["autoPromptATT"] as? Bool) ?? false,
122
+ // Inert on this path (core never auto-registers) but carried through so
123
+ // a later `configure(...)` with the same options behaves as documented.
124
+ sendInstallOnFirstLaunch: (options["sendInstallOnFirstLaunch"] as? Bool) ?? true
125
+ )
126
+ SwissKnife.configureCore(
127
+ apiKey: apiKey,
128
+ appUserID: options["appUserID"] as? String,
129
+ proxyURL: options["proxyURL"] as? String,
130
+ logLevel: options["logLevel"] as? String,
131
+ attribution: attribution
132
+ )
133
+ resolve(nil)
134
+ }
135
+
107
136
  @objc(isConfigured:rejecter:)
108
137
  func isConfigured(_ resolve: @escaping RCTPromiseResolveBlock,
109
138
  rejecter reject: @escaping RCTPromiseRejectBlock) {
110
139
  resolve(SwissKnife.isConfigured)
111
140
  }
112
141
 
142
+ @objc(isCoreConfigured:rejecter:)
143
+ func isCoreConfigured(_ resolve: @escaping RCTPromiseResolveBlock,
144
+ rejecter reject: @escaping RCTPromiseRejectBlock) {
145
+ resolve(SwissKnife.isCoreConfigured)
146
+ }
147
+
113
148
  // MARK: CustomerInfo / Offerings
114
149
 
115
150
  @objc(getCustomerInfo:rejecter:)
@@ -149,7 +149,10 @@ public extension SwissKnife {
149
149
  if let cached = state.cached {
150
150
  return cached
151
151
  }
152
- guard SwissKnife.isConfigured else {
152
+ // Core gate, not the purchase engine — attribution has nothing to
153
+ // do with StoreKit. `configureCore(...)` (or `Analytics.init` →
154
+ // `ensureObservabilityBackend`) is enough.
155
+ guard SwissKnife.isCoreConfigured else {
153
156
  // Pre-configure caller — best-effort no-op. The
154
157
  // alternative (throwing `.notConfigured`) is correct but
155
158
  // hostile for "I called Attribution from didFinishLaunching
@@ -184,7 +187,8 @@ public extension SwissKnife {
184
187
  if let cached = state.cached {
185
188
  return cached
186
189
  }
187
- guard SwissKnife.isConfigured else {
190
+ // Core gate — see `requestTrackingAuthorizationAndRegister()`.
191
+ guard SwissKnife.isCoreConfigured else {
188
192
  return nil
189
193
  }
190
194
  return try await postInstall(advertisingId: advertisingId)
@@ -192,12 +196,26 @@ public extension SwissKnife {
192
196
 
193
197
  // MARK: Internal — SwissKnife configure-time wiring
194
198
 
195
- /// Called by `SwissKnife.configure(...)` to snapshot the
196
- /// configuration and (when `sendInstallOnFirstLaunch` is true)
197
- /// kick off a background install registration. The kick-off is
198
- /// fire-and-forget — callers do NOT need to await it.
199
- internal static func _configure(_ configuration: Configuration) {
199
+ /// Called by `SwissKnife.configureCore(...)` to snapshot the
200
+ /// configuration. **Deliberately has no side effects** — it does NOT
201
+ /// register an install.
202
+ ///
203
+ /// Why the split: enabling core (identity + analytics + attribution
204
+ /// *reads*) must not silently emit an install event. Hosts that own
205
+ /// attribution elsewhere would get their install data corrupted by an
206
+ /// SDK they only adopted for analytics. `sendInstallOnFirstLaunch`
207
+ /// therefore fires from `SwissKnife.configurePurchases(...)` — see
208
+ /// `_sendInstallOnFirstLaunchIfEnabled()`.
209
+ internal static func _configureCore(_ configuration: Configuration) {
200
210
  self.configuration = configuration
211
+ }
212
+
213
+ /// Called by `SwissKnife.configurePurchases(...)`. Honours
214
+ /// `Configuration.sendInstallOnFirstLaunch` (default `true`), so the
215
+ /// legacy `SwissKnife.configure(...)` — which is core + purchases —
216
+ /// keeps registering the install exactly as it always did. The
217
+ /// kick-off is fire-and-forget; callers do NOT await it.
218
+ internal static func _sendInstallOnFirstLaunchIfEnabled() {
201
219
  guard configuration.sendInstallOnFirstLaunch else { return }
202
220
  // Background — never block configure(...) on the network
203
221
  // call. The MainActor jump is required by ATTrackingManager.
@@ -99,7 +99,7 @@ internal enum DeviceContextProvider {
99
99
  /// Round A baseline. The build pipeline (`swiss-build`) will eventually
100
100
  /// inject this via `-D` flag, but for now keep it in source so we don't
101
101
  /// have to thread build settings through the SPM Package.swift.
102
- static let sdkVersionConstant: String = "0.1.1"
102
+ static let sdkVersionConstant: String = "0.2.0"
103
103
 
104
104
  private static let cacheLock = DispatchQueue(label: "com.swissknife.context.device")
105
105
  private static var cached: DeviceContext?
@@ -131,7 +131,12 @@ public extension SwissKnife {
131
131
  /// identify side effect.
132
132
  @discardableResult
133
133
  public static func logIn(_ userId: String) async throws -> LogInResult {
134
- guard SwissKnife.isConfigured else { throw PurchasesError.notConfigured }
134
+ // Gates on CORE, not on the purchase engine. Identity is a core
135
+ // capability: an app that keeps its own IAP library (or ships
136
+ // analytics only) calls `SwissKnife.configureCore(...)` — or just
137
+ // `ensureObservabilityBackend(...)` via `Analytics.init` — and
138
+ // identity works, with no StoreKit observer anywhere.
139
+ guard SwissKnife.isCoreConfigured else { throw PurchasesError.notConfigured }
135
140
  precondition(!userId.isEmpty, "logIn requires a non-empty userId")
136
141
 
137
142
  let previous = current
@@ -201,7 +206,8 @@ public extension SwissKnife {
201
206
  /// keeps it stable across logout (analytics continuity for the
202
207
  /// same physical install). Use `wipe()` for a full identity reset.
203
208
  public static func logOut() async throws {
204
- guard SwissKnife.isConfigured else { throw PurchasesError.notConfigured }
209
+ // Core gate — see `logIn(_:)`.
210
+ guard SwissKnife.isCoreConfigured else { throw PurchasesError.notConfigured }
205
211
  let previous = current
206
212
  let anonId = previous.anonymousId
207
213
  let newSnapshot = Snapshot(anonymousId: anonId, userId: nil)
@@ -308,7 +308,21 @@ internal final class BackendHttpClient: @unchecked Sendable {
308
308
  throw PurchasesError.unknown(message: "Invalid URL: \(raw)")
309
309
  }
310
310
  if !query.isEmpty {
311
- components.queryItems = query.map { URLQueryItem(name: $0.0, value: $0.1) }
311
+ // `components.queryItems` is NOT safe here. Foundation leaves `+`,
312
+ // `&` and `=` unescaped inside a query-item VALUE, and the server
313
+ // parses the query with `URLSearchParams`, which decodes `+` as a
314
+ // space. So a `user_id` of `user+tag@example.com` reached the
315
+ // backend as `user tag@example.com` — a different subject from the
316
+ // one `subscriptions/validate` wrote in its JSON body, which is why
317
+ // entitlements silently went missing for anyone using a plus-tagged
318
+ // email as their app user id. Encode to the RFC 3986 unreserved set
319
+ // ourselves and hand Foundation the finished string.
320
+ components.percentEncodedQueryItems = query.map {
321
+ URLQueryItem(
322
+ name: percentEncodeQueryComponent($0.0),
323
+ value: percentEncodeQueryComponent($0.1)
324
+ )
325
+ }
312
326
  }
313
327
  guard let url = components.url else {
314
328
  throw PurchasesError.unknown(message: "Invalid URL components for: \(raw)")
@@ -316,6 +330,23 @@ internal final class BackendHttpClient: @unchecked Sendable {
316
330
  return url
317
331
  }
318
332
 
333
+ /// RFC 3986 *unreserved* set — everything else is percent-encoded. Chosen
334
+ /// over `.urlQueryAllowed` because that set deliberately permits the
335
+ /// sub-delimiters (`+`, `&`, `=`, `$`, `,`, …) that give a query value its
336
+ /// structure, which is exactly what corrupts a value carrying them.
337
+ /// Round-trips: the server percent-decodes back to the original bytes, so
338
+ /// values that were already safe (including `$SKAnonymousID:<id>`) resolve
339
+ /// to the identical subject they did before.
340
+ private static let unreservedQueryCharacters: CharacterSet = {
341
+ var set = CharacterSet.alphanumerics
342
+ set.insert(charactersIn: "-._~")
343
+ return set
344
+ }()
345
+
346
+ private static func percentEncodeQueryComponent(_ value: String) -> String {
347
+ value.addingPercentEncoding(withAllowedCharacters: unreservedQueryCharacters) ?? value
348
+ }
349
+
319
350
  /// Pull an `error` field out of a JSON error body if present. Best-effort
320
351
  /// — non-JSON bodies (e.g. an HTML error page from a misconfigured
321
352
  /// reverse proxy) yield `nil` and the caller falls back to the HTTP
@@ -64,6 +64,16 @@ public final class EntitlementsService {
64
64
  /// network call on the next `current()` request.
65
65
  public static let cacheTTL: TimeInterval = 24 * 60 * 60
66
66
 
67
+ /// RFC 3986 *unreserved* set. Anything outside it is percent-encoded
68
+ /// before going into the `user_id` query value. Deliberately stricter
69
+ /// than `.urlQueryAllowed`, which leaves `+`, `&` and `=` intact — the
70
+ /// three characters that actually corrupt a query value.
71
+ private static let queryValueAllowed: CharacterSet = {
72
+ var set = CharacterSet.alphanumerics
73
+ set.insert(charactersIn: "-._~")
74
+ return set
75
+ }()
76
+
67
77
  private let log = OSLog(subsystem: "com.swissknife", category: "entitlements")
68
78
  private let queue = DispatchQueue(label: "com.swissknife.entitlements")
69
79
 
@@ -297,6 +307,13 @@ public final class EntitlementsService {
297
307
  }
298
308
  }
299
309
 
310
+ /// Test seam — the subject this cache is currently keyed against. Used by
311
+ /// `BackendSubjectIdTests` to assert that `subscriptions/validate` and
312
+ /// `entitlements/list` resolve the SAME subject in every configure shape.
313
+ internal var _currentUserIdForTesting: String? {
314
+ queue.sync { currentUserId }
315
+ }
316
+
300
317
  /// Test seam — write a known cache entry to disk so tests can exercise
301
318
  /// the read path without going through `refresh()`.
302
319
  internal func _seedCacheForTesting(_ info: CustomerInfo, fetchedAt: Date) {
@@ -319,11 +336,24 @@ public final class EntitlementsService {
319
336
  }
320
337
  let base = (urlOpt?.isEmpty == false ? urlOpt! : "https://api.swiss-knife.dev")
321
338
  .trimmingTrailingSlash()
322
- // Effective user id: the configured one, else the SDK's anonymous id.
323
- // We fall back to the keychain-backed device id so first-launch
324
- // refresh still has *something* to identify the user with.
325
- let effectiveUserId = (userId?.isEmpty == false) ? userId! : DeviceID.get()
326
- let urlString = "\(base)/api/sdk/entitlements/list?user_id=\(effectiveUserId)"
339
+ // Effective subject id: the id this cache is keyed against, else the
340
+ // SDK's *prefixed* anonymous id. NEVER the bare keychain device id —
341
+ // that used to be the fallback here, which wrote the raw device UUID
342
+ // into a user-visible column. See `SwissKnife.backendSubjectId()`.
343
+ let effectiveUserId = (userId?.isEmpty == false)
344
+ ? userId!
345
+ : SwissKnife.backendSubjectId()
346
+ // Percent-encode before interpolating. A host-supplied appUserID may
347
+ // contain `+`, `&`, `@` or a space: unencoded, `+` decodes server-side
348
+ // as a space (so the subject `entitlements/list` asks for stops
349
+ // matching the one `subscriptions/validate` wrote in its JSON body),
350
+ // and a space makes `URL(string:)` return nil outright. The anonymous
351
+ // form round-trips unchanged — `$` and `:` re-decode to themselves —
352
+ // so this re-keys nobody.
353
+ let encodedUserId = effectiveUserId
354
+ .addingPercentEncoding(withAllowedCharacters: Self.queryValueAllowed)
355
+ ?? effectiveUserId
356
+ let urlString = "\(base)/api/sdk/entitlements/list?user_id=\(encodedUserId)"
327
357
  guard let url = URL(string: urlString) else {
328
358
  throw PurchasesError.unknown(message: "Invalid entitlements URL: \(urlString)")
329
359
  }
@@ -61,8 +61,32 @@ public final class PurchaseService {
61
61
 
62
62
  private var observerTask: Task<Void, Never>?
63
63
 
64
+ /// How many times `startObservingTransactionUpdates()` has actually spun
65
+ /// up a `StoreKit.Transaction.updates` iteration in this process.
66
+ ///
67
+ /// This exists purely so tests can assert an ABSENCE: that configuring the
68
+ /// SDK's core (identity / attribution / analytics) starts **zero** StoreKit
69
+ /// observers. Without a counter that fact is unobservable — `observerTask`
70
+ /// is private and a `Task` gives nothing to introspect — so "no observer
71
+ /// was created" could only be asserted by not crashing, which proves
72
+ /// nothing. See `Tests/…/StoreOwnershipSeparationTests.swift`.
73
+ private var observerStartCount: Int = 0
74
+
64
75
  private init() {}
65
76
 
77
+ // MARK: Observer introspection (test-only)
78
+
79
+ /// Number of `Transaction.updates` listeners started since the last
80
+ /// `_resetForTesting()`. Production code must not branch on this.
81
+ internal var observerStartCountForTesting: Int {
82
+ queue.sync { observerStartCount }
83
+ }
84
+
85
+ /// Whether a `Transaction.updates` listener task is currently installed.
86
+ internal var isObservingTransactionUpdatesForTesting: Bool {
87
+ queue.sync { observerTask != nil }
88
+ }
89
+
66
90
  // MARK: Configure
67
91
 
68
92
  internal func configure(serverURL: String?, apiKey: String) {
@@ -78,6 +102,7 @@ public final class PurchaseService {
78
102
  internal func startObservingTransactionUpdates() {
79
103
  queue.sync {
80
104
  observerTask?.cancel()
105
+ observerStartCount += 1
81
106
  observerTask = Task { [weak self] in
82
107
  if #available(iOS 15.0, macOS 12.0, *) {
83
108
  for await update in StoreKit.Transaction.updates {
@@ -97,6 +122,7 @@ public final class PurchaseService {
97
122
  queue.sync {
98
123
  observerTask?.cancel()
99
124
  observerTask = nil
125
+ observerStartCount = 0
100
126
  serverURL = nil
101
127
  apiKey = nil
102
128
  http = BackendHttpClient.shared
@@ -283,11 +309,12 @@ public final class PurchaseService {
283
309
  _ transaction: StoreKit.Transaction,
284
310
  jws: String
285
311
  ) async throws {
286
- // Effective user id — same fallback logic as EntitlementsService.
287
- let userId: String = {
288
- let configured = SwissKnife.appUserIDOrNil()
289
- return (configured?.isEmpty == false) ? configured! : DeviceID.get()
290
- }()
312
+ // Effective subject id — single source of truth, shared with
313
+ // EntitlementsService. NEVER the bare device id: see
314
+ // `SwissKnife.backendSubjectId()` for why, and for why the previous
315
+ // `appUserIDOrNil() ?? DeviceID.get()` shape leaked it on the
316
+ // `configurePurchases`-without-`configureCore` path.
317
+ let userId = SwissKnife.backendSubjectId()
291
318
  let body: [String: Any] = [
292
319
  "user_id": userId,
293
320
  "platform": "ios",
@@ -355,20 +382,10 @@ internal typealias VerificationResult2 = StoreKit.VerificationResult<StoreKit.Tr
355
382
 
356
383
  // MARK: - SwissKnife appUserID accessor for the service layer
357
384
  //
358
- // `SwissKnife.appUserID` currently still routes through RC (commit 5 swaps
359
- // it). We want to read it from the service layer without taking a hard
360
- // dependency on RC being configured — `appUserIDOrNil()` returns nil when
361
- // the SDK isn't configured yet, which the validate call falls back from to
362
- // the device id.
363
-
364
- internal extension SwissKnife {
365
- static func appUserIDOrNil() -> String? {
366
- guard isConfigured else { return nil }
367
- // Wave 1: route through the Identity snapshot. `userId` is the
368
- // identified id when known, else the anonymous id. Falling back
369
- // to the anonymous id matches the prior facade behaviour where
370
- // `SwissKnife.appUserID` returned whichever was currently active.
371
- let snapshot = Identity.current
372
- return snapshot.userId ?? snapshot.anonymousId
373
- }
374
- }
385
+ // Removed: `appUserIDOrNil()`. It gated on `isCoreConfigured` and returned
386
+ // nil for a purchases-only app, which forced its single caller (the validate
387
+ // POST above) into a `?? DeviceID.get()` fallback that leaked the raw
388
+ // Keychain device UUID as the backend subject id. `SwissKnife.backendSubjectId()`
389
+ // replaces it: no core gate, never bare, and it returns exactly the value
390
+ // `EntitlementsService` was configured with so validate and entitlements/list
391
+ // agree on the subject.
@@ -22,8 +22,18 @@ public extension SwissKnife {
22
22
  /// **For the React Native bridge only.** Native-iOS consumers should not
23
23
  /// call this directly — use `SKAnalytics` for analytics identity. The
24
24
  /// value survives app restart and reinstall (Keychain outlives the app
25
- /// sandbox) and never leaves the device (`ThisDeviceOnly` accessibility +
26
- /// `synchronizable=false`). See `DeviceID.swift` for the full rationale.
25
+ /// sandbox) and is never *synced* off the device by iOS — `ThisDeviceOnly`
26
+ /// accessibility + `synchronizable=false` keep it out of iCloud Keychain.
27
+ /// See `DeviceID.swift` for the full rationale.
28
+ ///
29
+ /// It is NOT a value that stays local, though, and this comment used to
30
+ /// read as if it were. The SDK transmits it: as `device_id` on every
31
+ /// analytics event, and — because the anonymous subject is derived as
32
+ /// `"$SKAnonymousID:" + DeviceID.get()` — embedded in the `user_id` sent to
33
+ /// `subscriptions/validate` and `entitlements/list`, from where it reaches
34
+ /// `app_users.external_user_id` and the dashboard. Any server-side control
35
+ /// that treats this value as unguessable must account for that. See
36
+ /// `SwissKnife.backendSubjectId()`.
27
37
  static func getDeviceId() -> String {
28
38
  DeviceID.get()
29
39
  }