@oxyhq/core 3.4.14 → 3.4.16

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.16**
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 contracts and handle normalization** so SDK user payloads expose required `id`/`displayName` fields 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,34 @@ 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
+ `User.displayName` is a required API contract. The API composes it server-side
62
+ from the structured name when present, otherwise from the username/server
63
+ fallback. UI consumers should render `displayName` directly instead of rebuilding
64
+ names from `name.first`, `name.last`, `name.full`, or `username`.
65
+
66
+ For profile display/routing, use `getNormalizedUserHandle()`. It strips a
67
+ leading `@`, preserves an existing `user@instance` handle, and appends
68
+ `instance`/`federation.domain` only for federated users:
69
+
70
+ ```ts
71
+ import { getNormalizedUserHandle } from '@oxyhq/core';
72
+
73
+ getNormalizedUserHandle({ username: 'alice' }); // "alice"
74
+ getNormalizedUserHandle({ username: 'alice', isFederated: true, instance: 'example.social' }); // "alice@example.social"
75
+ ```
76
+
49
77
  ## Linked App API Clients
50
78
 
51
79
  Apps that call their own backend should derive API clients from the active SDK