@oxyhq/core 3.4.13 → 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 +25 -2
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +10 -4
- package/dist/cjs/utils/userHandle.js +37 -0
- package/dist/cjs/utils/userIdentity.js +9 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/utils/userHandle.js +33 -0
- package/dist/esm/utils/userIdentity.js +9 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/utils/userHandle.d.ts +26 -0
- package/dist/types/utils/userIdentity.d.ts +9 -0
- package/package.json +1 -1
- package/src/__tests__/userIdentity.test.ts +70 -0
- package/src/index.ts +14 -1
- package/src/utils/asyncUtils.ts +1 -2
- package/src/utils/userHandle.ts +49 -0
- package/src/utils/userIdentity.ts +9 -0
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.
|
|
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
|
|
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
|