@oxyhq/core 3.4.14 → 3.4.15

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  OxyHQ SDK Foundation. Platform-agnostic core library that works in Node.js, browser, and React Native environments. No React dependency.
4
4
 
5
- **Current published version: 3.4.13**
5
+ **Current published version: 3.4.15**
6
6
 
7
7
  ## Installation
8
8
 
@@ -21,7 +21,7 @@ bun add @oxyhq/core
21
21
  - **Platform detection utilities**
22
22
  - **Device management**
23
23
  - **Linked clients** for app backends that need the active Oxy bearer token
24
- - **User identity normalization** so SDK user payloads always expose `id`
24
+ - **User identity and handle normalization** so SDK user payloads expose `id` and apps build local/federated profile handles consistently
25
25
  - **Server middleware** for Express request identity and per-user rate limiting
26
26
 
27
27
  ## Exports
@@ -46,6 +46,29 @@ const user = await oxyClient.getUserById('123');
46
46
  const keyManager = new KeyManager();
47
47
  ```
48
48
 
49
+ ## User Identity And Handles
50
+
51
+ SDK user payloads may arrive with either `id` or Mongo-style `_id`; normalize
52
+ them before exposing state to apps:
53
+
54
+ ```ts
55
+ import { getNormalizedUserId, normalizeUserIdentity } from '@oxyhq/core';
56
+
57
+ const id = getNormalizedUserId(user);
58
+ const normalizedUser = normalizeUserIdentity(user);
59
+ ```
60
+
61
+ For profile display/routing, use `getNormalizedUserHandle()`. It strips a
62
+ leading `@`, preserves an existing `user@instance` handle, and appends
63
+ `instance`/`federation.domain` only for federated users:
64
+
65
+ ```ts
66
+ import { getNormalizedUserHandle } from '@oxyhq/core';
67
+
68
+ getNormalizedUserHandle({ username: 'alice' }); // "alice"
69
+ getNormalizedUserHandle({ username: 'alice', isFederated: true, instance: 'example.social' }); // "alice@example.social"
70
+ ```
71
+
49
72
  ## Linked App API Clients
50
73
 
51
74
  Apps that call their own backend should derive API clients from the active SDK