@microsoft/rayfin-guide 1.34.0-alpha.1148 → 1.34.0-beta.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.
|
@@ -12,7 +12,9 @@ This guide explains how to configure Rayfin authentication in your application.
|
|
|
12
12
|
- **Token management** - Access tokens never exposed to application code.
|
|
13
13
|
- **Session Management** - Automatic state tracking with localStorage, sessionStorage, or custom storage.
|
|
14
14
|
- **Event System** - React-friendly session change notifications.
|
|
15
|
-
- **
|
|
15
|
+
- **Isomorphic** - Works in Node.js, React Native, and Electron without crashing.
|
|
16
|
+
The constructor auto-detects the runtime and skips browser APIs when `window` is undefined.
|
|
17
|
+
- **Async Storage** - Storage adapters can return promises for async backends (e.g., React Native AsyncStorage).
|
|
16
18
|
|
|
17
19
|
## Auth client API surface
|
|
18
20
|
|
|
@@ -23,7 +25,9 @@ The auth client exposes the following methods for sign-up, sign-in, session mana
|
|
|
23
25
|
| `signUp({ email, password })` | Register a new user. |
|
|
24
26
|
| `signIn({ email, password })` | Authenticate an existing user. |
|
|
25
27
|
| `signOut()` | End the current session. |
|
|
26
|
-
| `getSession()` | Return the current session (
|
|
28
|
+
| `getSession()` | Return the current session (async; check `isAuthenticated` or `user`). |
|
|
29
|
+
| `startAutoRefresh()` | Resume automatic token refresh (for React Native / manual control). |
|
|
30
|
+
| `stopAutoRefresh()` | Pause automatic token refresh. |
|
|
27
31
|
| `onSessionChange(callback)` | Subscribe to session state changes; returns an unsubscribe function. |
|
|
28
32
|
|
|
29
33
|
> **Important**
|
|
@@ -114,11 +118,15 @@ That hook keeps React in sync with the Rayfin auth session.
|
|
|
114
118
|
```typescript
|
|
115
119
|
import { useState, useEffect } from 'react';
|
|
116
120
|
import { auth } from './lib/rayfin';
|
|
121
|
+
import type { OpaqueSession } from '@microsoft/rayfin-auth';
|
|
117
122
|
|
|
118
123
|
export function useAuth() {
|
|
119
|
-
const [session, setSession] = useState(
|
|
124
|
+
const [session, setSession] = useState<OpaqueSession | null>(null);
|
|
120
125
|
|
|
121
|
-
useEffect(() =>
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
setSession(auth.getSession());
|
|
128
|
+
return auth.onSessionChange(setSession);
|
|
129
|
+
}, []);
|
|
122
130
|
|
|
123
131
|
return {
|
|
124
132
|
...session,
|
|
@@ -34,6 +34,9 @@ Rayfin's fluent client produces DAB-compliant GraphQL and returns typed entities
|
|
|
34
34
|
The GraphQL fluent client is available as `client.data.<Entity>`.
|
|
35
35
|
Some older examples may show `client.data.gql.<Entity>`.
|
|
36
36
|
|
|
37
|
+
Required `@text()` fields return an empty string when the stored value is empty.
|
|
38
|
+
Optional `@text({ optional: true })` fields preserve `null` so apps can distinguish an intentionally missing value from empty text.
|
|
39
|
+
|
|
37
40
|
### Read multiple records
|
|
38
41
|
|
|
39
42
|
Here is an example to read records and order by a column.
|
|
@@ -259,7 +262,7 @@ const env = loadEnv();
|
|
|
259
262
|
const client = new RayfinClient<AppSchema>({
|
|
260
263
|
baseUrl: env['VITE_RAYFIN_API_URL'],
|
|
261
264
|
publishableKey: env['VITE_RAYFIN_PUBLISHABLE_KEY'],
|
|
262
|
-
authStorage: false, //
|
|
265
|
+
authStorage: false, // Optional — Node.js has no localStorage but Auth auto-detects
|
|
263
266
|
});
|
|
264
267
|
|
|
265
268
|
async function seed() {
|
|
@@ -295,7 +298,8 @@ Run with `npx tsx scripts/seed.ts`, or add `"seed": "npx tsx scripts/seed.ts"` t
|
|
|
295
298
|
|
|
296
299
|
Key rules:
|
|
297
300
|
|
|
298
|
-
- Set `authStorage: false` —
|
|
301
|
+
- Set `authStorage: false` — disables session persistence in Node.js scripts.
|
|
302
|
+
This is optional since Auth now auto-detects Node.js and falls back to memory-only storage, but explicit `false` makes intent clear.
|
|
299
303
|
- Read `baseUrl` and `publishableKey` from `.env`, not hardcoded values — the port and key vary per project.
|
|
300
304
|
- Email/password auth works for **local development seeding only**.
|
|
301
305
|
Deployed Fabric apps use Entra SSO exclusively.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/rayfin-guide",
|
|
3
|
-
"version": "1.34.0-
|
|
3
|
+
"version": "1.34.0-beta.0",
|
|
4
4
|
"description": "Cross-cutting Builder guides for the Rayfin platform — discovered by `@microsoft/rayfin-docs` via the `rayfinDocs` package.json field convention.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|