@strivacity/sdk-remix 3.0.0-rc.0 → 3.0.1
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/CHANGELOG.md +26 -0
- package/README.md +208 -249
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## 3.0.1 (2026-04-20)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- handle language parameter from response body url correctly ([e42294b](https://github.com/Strivacity/sdk-js/commit/e42294b))
|
|
6
|
+
|
|
7
|
+
### 🧱 Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated sdk-core to 3.0.1
|
|
10
|
+
|
|
11
|
+
# 3.0.0 (2026-04-09)
|
|
12
|
+
|
|
13
|
+
### 🚀 Features
|
|
14
|
+
|
|
15
|
+
- ⚠️ EmbeddedFlow implemented ([a0e3ad8](https://github.com/Strivacity/sdk-js/commit/a0e3ad8))
|
|
16
|
+
- ⚠️ NativeFlow entry function now returns an object instead of a string ([9a8942d](https://github.com/Strivacity/sdk-js/commit/9a8942d))
|
|
17
|
+
|
|
18
|
+
### ⚠️ Breaking Changes
|
|
19
|
+
|
|
20
|
+
- EmbeddedFlow implemented ([a0e3ad8](https://github.com/Strivacity/sdk-js/commit/a0e3ad8))
|
|
21
|
+
- NativeFlow entry function now returns an object instead of a string ([9a8942d](https://github.com/Strivacity/sdk-js/commit/9a8942d))
|
|
22
|
+
|
|
23
|
+
### 🧱 Updated Dependencies
|
|
24
|
+
|
|
25
|
+
- Updated sdk-core to 3.0.0
|
|
26
|
+
|
|
1
27
|
## 3.0.0-rc.0 (2026-02-18)
|
|
2
28
|
|
|
3
29
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
# @strivacity/sdk-remix
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Remix library that integrates Strivacity's policy-driven authentication journeys into your application using the OAuth 2.0 PKCE flow. Supports `redirect`, `popup`, `native`, and `embedded` modes.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
See our [Developer Portal](https://www.strivacity.com/learn-support/developer-hub) to get started with developing with the Strivacity product.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This SDK allows you to integrate Strivacity's policy-driven journeys into your Remix application. It wraps the `@strivacity/sdk-core` library as a React context provider and exposes a `useStrivacity` hook that provides authentication state and methods throughout your component tree. The SDK uses the OAuth 2.0 PKCE flow to authenticate with Strivacity. For detailed configuration options, available modes, and advanced usage refer to the [`@strivacity/sdk-core` documentation](https://github.com/Strivacity/sdk-js/blob/main/packages/sdk-core/README.md).
|
|
10
|
+
|
|
11
|
+
## Demo Application
|
|
6
12
|
|
|
7
13
|
- [Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/remix)
|
|
8
14
|
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Remix: 2+
|
|
18
|
+
|
|
9
19
|
## Install
|
|
10
20
|
|
|
11
21
|
```bash
|
|
@@ -14,48 +24,45 @@ npm install @strivacity/sdk-remix
|
|
|
14
24
|
|
|
15
25
|
## Usage
|
|
16
26
|
|
|
17
|
-
###
|
|
27
|
+
### Initialization
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
Wrap your application with `StyAuthProvider` in your root layout:
|
|
20
30
|
|
|
21
31
|
```tsx
|
|
22
|
-
import {
|
|
23
|
-
import { StyAuthProvider, type SDKOptions } from '@strivacity/sdk-react';
|
|
32
|
+
import { StyAuthProvider, type SDKOptions } from '@strivacity/sdk-remix';
|
|
24
33
|
|
|
25
34
|
const options: SDKOptions = {
|
|
26
|
-
mode: 'redirect', // or 'popup'
|
|
35
|
+
mode: 'redirect', // or 'popup', 'native', 'embedded'
|
|
27
36
|
issuer: 'https://<YOUR_DOMAIN>',
|
|
28
37
|
scopes: ['openid', 'profile'],
|
|
29
38
|
clientId: '<YOUR_CLIENT_ID>',
|
|
30
39
|
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
31
40
|
};
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
export default function App() {
|
|
43
|
+
return (
|
|
35
44
|
<StyAuthProvider options={options}>
|
|
36
|
-
<
|
|
37
|
-
<Route path="/" element={<App />}>
|
|
38
|
-
...
|
|
39
|
-
</Route>
|
|
40
|
-
</Routes>
|
|
45
|
+
<Outlet />
|
|
41
46
|
</StyAuthProvider>
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
);
|
|
48
|
+
}
|
|
44
49
|
```
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
#### Redirect or popup mode
|
|
51
|
+
Use the `useStrivacity` hook in any component to access authentication state:
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
```tsx
|
|
54
|
+
import { useStrivacity } from '@strivacity/sdk-remix';
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
export default function MyComponent() {
|
|
57
|
+
const { loading, isAuthenticated, idTokenClaims } = useStrivacity();
|
|
58
|
+
}
|
|
59
|
+
```
|
|
53
60
|
|
|
54
|
-
|
|
61
|
+
### Redirect / Popup mode
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
In `redirect` mode the user is taken to the identity provider in the same window; in `popup` mode authentication happens in a popup. Both are initiated the same way from code.
|
|
57
64
|
|
|
58
|
-
|
|
65
|
+
#### Login page example
|
|
59
66
|
|
|
60
67
|
```tsx
|
|
61
68
|
import { useEffect } from 'react';
|
|
@@ -76,9 +83,9 @@ export default function Login() {
|
|
|
76
83
|
}
|
|
77
84
|
```
|
|
78
85
|
|
|
79
|
-
|
|
86
|
+
#### Callback page example
|
|
80
87
|
|
|
81
|
-
The callback page handles the response from the identity provider
|
|
88
|
+
The callback page handles the response from the identity provider. It calls `handleCallback()` and redirects to `/profile` on success:
|
|
82
89
|
|
|
83
90
|
```tsx
|
|
84
91
|
import { useEffect } from 'react';
|
|
@@ -108,11 +115,7 @@ export default function Callback() {
|
|
|
108
115
|
}
|
|
109
116
|
```
|
|
110
117
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
The profile page displays user information and authentication details after successful login. It uses the `useStrivacity` hook to access the authentication state and display relevant data such as access tokens, ID token claims, and expiration status.
|
|
114
|
-
|
|
115
|
-
We check if the user is authenticated and display their profile information. If the user is not authenticated, we redirect them to the login page.
|
|
118
|
+
#### Profile page example
|
|
116
119
|
|
|
117
120
|
```tsx
|
|
118
121
|
import { useStrivacity } from '@strivacity/sdk-remix';
|
|
@@ -163,11 +166,9 @@ export default function Profile() {
|
|
|
163
166
|
}
|
|
164
167
|
```
|
|
165
168
|
|
|
166
|
-
|
|
169
|
+
#### Logout page example
|
|
167
170
|
|
|
168
|
-
The
|
|
169
|
-
|
|
170
|
-
This URI must be configured in the Admin Console as an allowed post-logout redirect URI for your application.
|
|
171
|
+
The `postLogoutRedirectUri` parameter is optional and specifies where users are redirected after logout. This URI must be configured in the Admin Console as an allowed post-logout redirect URI.
|
|
171
172
|
|
|
172
173
|
```tsx
|
|
173
174
|
import { useEffect } from 'react';
|
|
@@ -196,15 +197,34 @@ export default function Logout() {
|
|
|
196
197
|
}
|
|
197
198
|
```
|
|
198
199
|
|
|
199
|
-
####
|
|
200
|
+
#### Component example
|
|
200
201
|
|
|
201
|
-
|
|
202
|
+
```tsx
|
|
203
|
+
import { useStrivacity } from '@strivacity/sdk-remix';
|
|
202
204
|
|
|
203
|
-
|
|
205
|
+
export default function Nav() {
|
|
206
|
+
const { isAuthenticated, idTokenClaims, login, logout } = useStrivacity();
|
|
207
|
+
const name = `${idTokenClaims?.given_name} ${idTokenClaims?.family_name}`;
|
|
208
|
+
|
|
209
|
+
return isAuthenticated ? (
|
|
210
|
+
<div>
|
|
211
|
+
<div>Welcome, {name}!</div>
|
|
212
|
+
<button onClick={() => logout()}>Logout</button>
|
|
213
|
+
</div>
|
|
214
|
+
) : (
|
|
215
|
+
<div>
|
|
216
|
+
<div>Not logged in</div>
|
|
217
|
+
<button onClick={() => login()}>Log in</button>
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Native mode
|
|
204
224
|
|
|
205
|
-
|
|
225
|
+
In `native` mode the `StyLoginRenderer` component renders the authentication UI inline using your custom widget components. You can define custom components for each input type; see [Example widgets](https://github.com/Strivacity/sdk-js/tree/main/apps/remix/app/components/widgets).
|
|
206
226
|
|
|
207
|
-
The example widgets use SCSS for styling and Luxon for date handling
|
|
227
|
+
The example widgets use SCSS for styling and Luxon for date handling:
|
|
208
228
|
|
|
209
229
|
```bash
|
|
210
230
|
npm install sass luxon
|
|
@@ -241,110 +261,71 @@ export const widgets = {
|
|
|
241
261
|
};
|
|
242
262
|
```
|
|
243
263
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
##### Login page example
|
|
264
|
+
#### Login page example
|
|
247
265
|
|
|
248
|
-
The
|
|
249
|
-
|
|
250
|
-
This example demonstrates how to handle session management, implement callback functions for various authentication events, and manage URL parameters for session continuity.
|
|
266
|
+
The login page extracts `session_id` and optionally `language` from the URL on load, cleans up the URL, and passes them to the renderer. When a `session_id` is present the renderer calls `startSession(sessionId)` to resume the existing flow instead of starting a new one. When a `language` parameter is present it overrides `uiLocales` to display the authentication UI in the specified language.
|
|
251
267
|
|
|
252
268
|
```tsx
|
|
253
|
-
import {
|
|
269
|
+
import { useEffect, useState } from 'react';
|
|
254
270
|
import { useNavigate } from 'react-router-dom';
|
|
255
|
-
import {
|
|
256
|
-
import { widgets } from '
|
|
271
|
+
import { StyLoginRenderer, FallbackError, type LoginFlowState } from '@strivacity/sdk-remix';
|
|
272
|
+
import { widgets } from '~/components/widgets';
|
|
257
273
|
|
|
258
274
|
export default function Login() {
|
|
259
275
|
const navigate = useNavigate();
|
|
260
|
-
const { options, login } = useStrivacity();
|
|
261
276
|
const [sessionId, setSessionId] = useState<string | null>(null);
|
|
262
277
|
|
|
263
|
-
/**
|
|
264
|
-
* Extract session_id from URL parameters and clean up the URL
|
|
265
|
-
* This is necessary for maintaining session state across external login providers
|
|
266
|
-
*/
|
|
267
278
|
useEffect(() => {
|
|
268
279
|
if (window.location.search !== '') {
|
|
269
280
|
const url = new URL(window.location.href);
|
|
270
|
-
|
|
271
|
-
setSessionId(sid);
|
|
281
|
+
setSessionId(url.searchParams.get('session_id'));
|
|
272
282
|
url.search = '';
|
|
273
283
|
window.history.replaceState({}, '', url.toString());
|
|
274
284
|
}
|
|
275
285
|
}, []);
|
|
276
286
|
|
|
277
|
-
/**
|
|
278
|
-
* Called when authentication is successful
|
|
279
|
-
* Redirects user to the profile page
|
|
280
|
-
*/
|
|
281
287
|
const onLogin = async () => {
|
|
282
288
|
await navigate('/profile');
|
|
283
289
|
};
|
|
284
290
|
|
|
285
|
-
/**
|
|
286
|
-
* Called when native flow cannot handle the authentication
|
|
287
|
-
* Falls back to redirect mode by navigating to the provided URL
|
|
288
|
-
* @param error - FallbackError containing the fallback URL and message
|
|
289
|
-
*/
|
|
290
291
|
const onFallback = (error: FallbackError) => {
|
|
291
292
|
if (error.url) {
|
|
292
|
-
console.log(`Fallback: ${error.url}`);
|
|
293
293
|
window.location.href = error.url.toString();
|
|
294
294
|
} else {
|
|
295
|
-
console.error(`FallbackError without URL: ${error.message}`);
|
|
296
295
|
alert(error);
|
|
297
296
|
}
|
|
298
297
|
};
|
|
299
298
|
|
|
300
|
-
/**
|
|
301
|
-
* Called when an error occurs during the authentication process
|
|
302
|
-
* @param error - Error message describing what went wrong
|
|
303
|
-
*/
|
|
304
299
|
const onError = (error: string) => {
|
|
305
|
-
console.error(`Error: ${error}`);
|
|
306
300
|
alert(error);
|
|
307
301
|
};
|
|
308
302
|
|
|
309
|
-
/**
|
|
310
|
-
* Called when the authentication flow wants to display a global message
|
|
311
|
-
* @param message - Message to display to the user
|
|
312
|
-
*/
|
|
313
303
|
const onGlobalMessage = (message: string) => {
|
|
314
304
|
alert(message);
|
|
315
305
|
};
|
|
316
306
|
|
|
317
|
-
/**
|
|
318
|
-
* Called when the authentication flow transitions between states
|
|
319
|
-
* Useful for tracking flow progress and inject custom logic such as logging or analytics
|
|
320
|
-
* @param params - Object containing previous and current flow states
|
|
321
|
-
*/
|
|
322
307
|
const onBlockReady = ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => {
|
|
323
308
|
console.log('previousState', previousState);
|
|
324
309
|
console.log('state', state);
|
|
325
310
|
};
|
|
326
311
|
|
|
327
312
|
return (
|
|
328
|
-
<
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
/>
|
|
338
|
-
</Suspense>
|
|
313
|
+
<StyLoginRenderer
|
|
314
|
+
widgets={widgets}
|
|
315
|
+
sessionId={sessionId}
|
|
316
|
+
onFallback={onFallback}
|
|
317
|
+
onLogin={() => void onLogin()}
|
|
318
|
+
onError={onError}
|
|
319
|
+
onGlobalMessage={onGlobalMessage}
|
|
320
|
+
onBlockReady={onBlockReady}
|
|
321
|
+
/>
|
|
339
322
|
);
|
|
340
323
|
}
|
|
341
324
|
```
|
|
342
325
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
The native mode callback page handles authentication responses when external identity providers redirect back to your application. This page checks for session IDs in the URL parameters and either continues the native flow or falls back to standard callback handling.
|
|
326
|
+
#### Callback page example
|
|
346
327
|
|
|
347
|
-
|
|
328
|
+
When a `session_id` is present in the URL the native flow is resumed by forwarding it to the login page. Otherwise the standard `handleCallback()` path is used:
|
|
348
329
|
|
|
349
330
|
```tsx
|
|
350
331
|
import { useEffect } from 'react';
|
|
@@ -352,7 +333,6 @@ import { useNavigate } from 'react-router-dom';
|
|
|
352
333
|
import { useStrivacity } from '@strivacity/sdk-remix';
|
|
353
334
|
|
|
354
335
|
export default function Callback() {
|
|
355
|
-
const query = globalThis?.window ? Object.fromEntries(new URLSearchParams(globalThis.window.location.search)) : {};
|
|
356
336
|
const navigate = useNavigate();
|
|
357
337
|
const { handleCallback } = useStrivacity();
|
|
358
338
|
|
|
@@ -374,45 +354,96 @@ export default function Callback() {
|
|
|
374
354
|
})();
|
|
375
355
|
}, []);
|
|
376
356
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
<
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
357
|
+
return (
|
|
358
|
+
<section>
|
|
359
|
+
<h1>Logging in...</h1>
|
|
360
|
+
</section>
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### Entry page example
|
|
366
|
+
|
|
367
|
+
The entry page processes flows started by an external process (e.g. password reset) by calling `entry()` to extract the necessary parameters to resume the flow and forwarding them to the callback page:
|
|
368
|
+
|
|
369
|
+
```tsx
|
|
370
|
+
import { useEffect } from 'react';
|
|
371
|
+
import { useNavigate } from 'react-router-dom';
|
|
372
|
+
import { useStrivacity } from '@strivacity/sdk-remix';
|
|
373
|
+
|
|
374
|
+
export default function Entry() {
|
|
375
|
+
const navigate = useNavigate();
|
|
376
|
+
const { entry } = useStrivacity();
|
|
377
|
+
|
|
378
|
+
useEffect(() => {
|
|
379
|
+
(async () => {
|
|
380
|
+
try {
|
|
381
|
+
const data = await entry();
|
|
382
|
+
|
|
383
|
+
if (data && Object.keys(data).length > 0) {
|
|
384
|
+
await navigate(`/callback?${new URLSearchParams(data).toString()}`);
|
|
385
|
+
} else {
|
|
386
|
+
await navigate('/');
|
|
387
|
+
}
|
|
388
|
+
} catch (error) {
|
|
389
|
+
console.error('Entry failed:', error);
|
|
390
|
+
await navigate('/');
|
|
391
|
+
}
|
|
392
|
+
})();
|
|
393
|
+
}, []);
|
|
394
|
+
|
|
395
|
+
return (
|
|
396
|
+
<section>
|
|
397
|
+
<h1>Loading...</h1>
|
|
398
|
+
</section>
|
|
399
|
+
);
|
|
394
400
|
}
|
|
395
401
|
```
|
|
396
402
|
|
|
397
|
-
|
|
403
|
+
#### Profile page example
|
|
398
404
|
|
|
399
405
|
Same as the profile page example in redirect/popup mode.
|
|
400
406
|
|
|
401
|
-
|
|
407
|
+
#### Logout page example
|
|
402
408
|
|
|
403
409
|
Same as the logout page example in redirect/popup mode.
|
|
404
410
|
|
|
411
|
+
### Embedded mode
|
|
412
|
+
|
|
413
|
+
In `embedded` mode the `<sty-login>` web component (loaded via `bundle.js` from the cluster) handles rendering. Import the bundle at application startup to register the Strivacity web components:
|
|
414
|
+
|
|
415
|
+
```tsx
|
|
416
|
+
import { StyAuthProvider } from '@strivacity/sdk-remix';
|
|
417
|
+
|
|
418
|
+
void import(`${window.ENV.VITE_ISSUER}/assets/components/bundle.js`);
|
|
419
|
+
|
|
420
|
+
export default function App() {
|
|
421
|
+
return (
|
|
422
|
+
<StyAuthProvider
|
|
423
|
+
options={{
|
|
424
|
+
mode: 'embedded',
|
|
425
|
+
issuer: 'https://<YOUR_DOMAIN>',
|
|
426
|
+
scopes: ['openid', 'profile'],
|
|
427
|
+
clientId: '<YOUR_CLIENT_ID>',
|
|
428
|
+
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
429
|
+
}}
|
|
430
|
+
>
|
|
431
|
+
<Outlet />
|
|
432
|
+
</StyAuthProvider>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
405
437
|
## Logging
|
|
406
438
|
|
|
407
439
|
The SDK supports optional logging to help you debug authentication flows and monitor SDK behavior. You can enable the built-in console logger or provide your own custom logger implementation.
|
|
408
440
|
|
|
409
441
|
### Using the Default Logger
|
|
410
442
|
|
|
411
|
-
Enable the default console logger by adding the `logging` option
|
|
443
|
+
Enable the default console logger by adding the `logging` option:
|
|
412
444
|
|
|
413
445
|
```tsx
|
|
414
|
-
import {
|
|
415
|
-
import { StyAuthProvider, type SDKOptions, DefaultLogging } from '@strivacity/sdk-remix';
|
|
446
|
+
import { StyAuthProvider, DefaultLogging, type SDKOptions } from '@strivacity/sdk-remix';
|
|
416
447
|
|
|
417
448
|
const options: SDKOptions = {
|
|
418
449
|
mode: 'redirect',
|
|
@@ -420,23 +451,13 @@ const options: SDKOptions = {
|
|
|
420
451
|
scopes: ['openid', 'profile'],
|
|
421
452
|
clientId: '<YOUR_CLIENT_ID>',
|
|
422
453
|
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
423
|
-
logging: DefaultLogging,
|
|
454
|
+
logging: DefaultLogging,
|
|
424
455
|
};
|
|
425
|
-
|
|
426
|
-
createRoot(document.getElementById('app')!).render(
|
|
427
|
-
<BrowserRouter>
|
|
428
|
-
<StyAuthProvider options={options}>
|
|
429
|
-
<Routes>{/* Your routes */}</Routes>
|
|
430
|
-
</StyAuthProvider>
|
|
431
|
-
</BrowserRouter>,
|
|
432
|
-
);
|
|
433
456
|
```
|
|
434
457
|
|
|
435
|
-
The default logger writes to the browser console and automatically prefixes messages with a correlation ID when available (via the `xEventId` property).
|
|
436
|
-
|
|
437
458
|
### Creating a Custom Logger
|
|
438
459
|
|
|
439
|
-
|
|
460
|
+
Implement the `SDKLogging` interface and pass your class to the `logging` option:
|
|
440
461
|
|
|
441
462
|
```typescript
|
|
442
463
|
import type { SDKLogging } from '@strivacity/sdk-remix';
|
|
@@ -445,7 +466,6 @@ export class MyLogger implements SDKLogging {
|
|
|
445
466
|
xEventId?: string;
|
|
446
467
|
|
|
447
468
|
debug(message: string): void {
|
|
448
|
-
// Send to your logging pipeline
|
|
449
469
|
console.debug(this.xEventId ? `[${this.xEventId}] ${message}` : message);
|
|
450
470
|
}
|
|
451
471
|
|
|
@@ -463,161 +483,100 @@ export class MyLogger implements SDKLogging {
|
|
|
463
483
|
}
|
|
464
484
|
```
|
|
465
485
|
|
|
466
|
-
|
|
486
|
+
The `SDKLogging` interface requires `debug`, `info`, `warn`, and `error` methods. The optional `xEventId` property, when set by the SDK, provides a correlation ID to trace related log messages across the authentication flow.
|
|
467
487
|
|
|
468
|
-
|
|
469
|
-
import { StyAuthProvider } from '@strivacity/sdk-remix';
|
|
470
|
-
import { MyLogger } from './logging/MyLogger';
|
|
488
|
+
## API Documentation
|
|
471
489
|
|
|
472
|
-
|
|
473
|
-
mode: 'redirect',
|
|
474
|
-
issuer: 'https://<YOUR_DOMAIN>',
|
|
475
|
-
scopes: ['openid', 'profile'],
|
|
476
|
-
clientId: '<YOUR_CLIENT_ID>',
|
|
477
|
-
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
478
|
-
logging: MyLogger, // Use your custom logger
|
|
479
|
-
};
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
### Logger Interface
|
|
483
|
-
|
|
484
|
-
The `SDKLogging` interface requires the following methods:
|
|
485
|
-
|
|
486
|
-
- **`debug(message: string): void`** - Log debug-level messages
|
|
487
|
-
- **`info(message: string): void`** - Log informational messages
|
|
488
|
-
- **`warn(message: string): void`** - Log warning messages
|
|
489
|
-
- **`error(message: string, error: Error): void`** - Log error messages with error objects
|
|
490
|
-
|
|
491
|
-
The optional `xEventId` property, when set by the SDK, provides a correlation ID to trace related log messages across the authentication flow.
|
|
492
|
-
|
|
493
|
-
### API Documentation
|
|
494
|
-
|
|
495
|
-
#### `useStrivacity` hook
|
|
490
|
+
### `useStrivacity` hook
|
|
496
491
|
|
|
497
492
|
```typescript
|
|
498
493
|
useStrivacity<T extends PopupContext | RedirectContext | NativeContext>(): T;
|
|
499
494
|
```
|
|
500
495
|
|
|
501
|
-
|
|
496
|
+
The hook returns a different context type depending on the `mode` configured in `StyAuthProvider`.
|
|
502
497
|
|
|
503
|
-
**
|
|
498
|
+
**Shared properties (all modes)**
|
|
504
499
|
|
|
505
|
-
- **`
|
|
506
|
-
- **`
|
|
507
|
-
- **`
|
|
508
|
-
- **`
|
|
509
|
-
- **`
|
|
510
|
-
- **`
|
|
511
|
-
- **`
|
|
500
|
+
- **`sdk: RedirectFlow | PopupFlow | NativeFlow`**: The underlying SDK flow instance.
|
|
501
|
+
- **`loading: boolean`**: `true` while the session is being initialized.
|
|
502
|
+
- **`options: SDKOptions`**: The configured SDK options.
|
|
503
|
+
- **`isAuthenticated: boolean`**: `true` when the user has a valid session.
|
|
504
|
+
- **`idTokenClaims: IdTokenClaims | null`**: Claims from the ID token, or `null` if not authenticated.
|
|
505
|
+
- **`accessToken: string | null`**: The current access token.
|
|
506
|
+
- **`refreshToken: string | null`**: The current refresh token.
|
|
507
|
+
- **`accessTokenExpired: boolean`**: `true` when the access token has expired.
|
|
508
|
+
- **`accessTokenExpirationDate: number | null`**: Expiration timestamp (Unix seconds) of the access token.
|
|
512
509
|
|
|
513
510
|
---
|
|
514
511
|
|
|
515
|
-
Type: `RedirectContext
|
|
516
|
-
Represents the available methods for Redirect-based interactions.
|
|
512
|
+
**Type: `RedirectContext`**
|
|
517
513
|
|
|
518
|
-
- **`login(options?: LoginOptions): Promise<void>`**: Initiates
|
|
519
|
-
|
|
520
|
-
- **`
|
|
521
|
-
|
|
522
|
-
- **`
|
|
523
|
-
- **`
|
|
524
|
-
- **`
|
|
525
|
-
- `options` (optional): Configuration options for logout.
|
|
526
|
-
- **`handleCallback(url?: string): Promise<void>`**: Handles the callback after a redirect-based authentication or token exchange.
|
|
527
|
-
- `url` (optional): The URL to handle for the callback.
|
|
514
|
+
- **`login(options?: LoginOptions): Promise<void>`**: Initiates login by redirecting to the identity provider.
|
|
515
|
+
- **`register(options?: RegisterOptions): Promise<void>`**: Initiates registration using a redirect flow.
|
|
516
|
+
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
517
|
+
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
518
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs the user out via redirect.
|
|
519
|
+
- **`handleCallback(url?: string): Promise<void>`**: Processes the authorization callback after redirect.
|
|
520
|
+
- **`entry(): Promise<Record<string, string>>`**: Processes an externally-initiated flow URL and returns the parameters needed to resume the flow.
|
|
528
521
|
|
|
529
522
|
---
|
|
530
523
|
|
|
531
|
-
Type: `PopupContext
|
|
532
|
-
Represents the available methods for Popup-based interactions.
|
|
524
|
+
**Type: `PopupContext`**
|
|
533
525
|
|
|
534
|
-
- **`login(options?: LoginOptions): Promise<void>`**: Initiates
|
|
535
|
-
|
|
536
|
-
- **`
|
|
537
|
-
|
|
538
|
-
- **`
|
|
539
|
-
- **`
|
|
540
|
-
- **`
|
|
541
|
-
- `options` (optional): Configuration options for logout.
|
|
542
|
-
- **`handleCallback(url?: string): Promise<void>`**: Handles the callback after a popup-based authentication or token exchange.
|
|
543
|
-
- `url` (optional): The URL to handle for the callback.
|
|
526
|
+
- **`login(options?: LoginOptions): Promise<void>`**: Initiates login using a popup window.
|
|
527
|
+
- **`register(options?: RegisterOptions): Promise<void>`**: Initiates registration using a popup.
|
|
528
|
+
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
529
|
+
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
530
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs the user out via popup.
|
|
531
|
+
- **`handleCallback(url?: string): Promise<void>`**: Processes the authorization callback.
|
|
532
|
+
- **`entry(): Promise<Record<string, string>>`**: Processes an externally-initiated flow URL.
|
|
544
533
|
|
|
545
534
|
---
|
|
546
535
|
|
|
547
|
-
Type: `NativeContext
|
|
548
|
-
Represents the available methods for native-based interactions.
|
|
536
|
+
**Type: `NativeContext`**
|
|
549
537
|
|
|
550
|
-
- **`login(options?: LoginOptions): Promise<NativeFlowHandler>`**: Initiates
|
|
551
|
-
|
|
552
|
-
- **`register(options?: RegisterOptions): Promise<NativeFlowHandler>`**: Registers a new user using a native flow.
|
|
553
|
-
- `options` (optional): Configuration options for registration.
|
|
538
|
+
- **`login(options?: LoginOptions): Promise<NativeFlowHandler>`**: Initiates login using the native flow.
|
|
539
|
+
- **`register(options?: RegisterOptions): Promise<NativeFlowHandler>`**: Initiates registration using the native flow.
|
|
554
540
|
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
555
541
|
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
556
|
-
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs
|
|
557
|
-
|
|
558
|
-
- **`
|
|
559
|
-
- `url` (optional): The URL to handle for the callback.
|
|
560
|
-
|
|
561
|
-
#### `StyLoginRenderer` component
|
|
562
|
-
|
|
563
|
-
The `StyLoginRenderer` component is used in native mode to render the authentication UI directly within your application. It provides a fully customizable login experience using your own UI components.
|
|
542
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs the user out via redirect.
|
|
543
|
+
- **`handleCallback(url?: string): Promise<void>`**: Processes the authorization callback.
|
|
544
|
+
- **`entry(): Promise<Record<string, string>>`**: Processes an externally-initiated flow URL.
|
|
564
545
|
|
|
565
|
-
|
|
566
|
-
StyLoginRenderer: React.FC<{
|
|
567
|
-
params?: NativeParams;
|
|
568
|
-
widgets?: PartialRecord<WidgetType, React.ComponentType<any>>;
|
|
569
|
-
sessionId?: string | null;
|
|
570
|
-
onLogin?: (claims?: IdTokenClaims | null) => void;
|
|
571
|
-
onFallback?: (error: FallbackError) => void;
|
|
572
|
-
onError?: (error: any) => void;
|
|
573
|
-
onGlobalMessage?: (message: string) => void;
|
|
574
|
-
onBlockReady?: ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => void;
|
|
575
|
-
}>;
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
**Properties**
|
|
579
|
-
|
|
580
|
-
- **`params?: NativeParams`** (optional): Additional parameters to pass to the native login flow. These parameters can include custom configuration options for the authentication process.
|
|
581
|
-
|
|
582
|
-
- **`widgets?: PartialRecord<WidgetType, React.ComponentType<any>>`** (optional): A collection of React components that define the UI widgets used in the authentication flow. Each widget type (input, button, layout, etc.) can be customized with your own components.
|
|
546
|
+
---
|
|
583
547
|
|
|
584
|
-
|
|
548
|
+
### `StyLoginRenderer` component
|
|
585
549
|
|
|
586
|
-
|
|
550
|
+
Used in `native` mode to render the authentication UI with your own widget components.
|
|
587
551
|
|
|
588
|
-
|
|
552
|
+
**Props**
|
|
589
553
|
|
|
590
|
-
- **`
|
|
554
|
+
- **`params?: NativeParams`**: Additional parameters for the native login flow.
|
|
555
|
+
- **`widgets?: PartialRecord<WidgetType, React.ComponentType>`**: Custom React components for each widget type used in the flow.
|
|
556
|
+
- **`sessionId?: string | null`**: Session ID for resuming an existing authentication session.
|
|
591
557
|
|
|
592
|
-
|
|
558
|
+
**Event callbacks**
|
|
593
559
|
|
|
594
|
-
- **`
|
|
560
|
+
- **`onLogin`**: Called on successful authentication. Receives `IdTokenClaims | null`.
|
|
561
|
+
- **`onFallback`**: Called when the native flow needs to fall back to redirect. Receives `FallbackError` with a fallback URL.
|
|
562
|
+
- **`onError`**: Called when an error occurs during authentication.
|
|
563
|
+
- **`onGlobalMessage`**: Called when the flow wants to display a global message (e.g. account lockout warning).
|
|
564
|
+
- **`onBlockReady`**: Called on flow state transitions. Receives `{ previousState: LoginFlowState; state: LoginFlowState }`. Useful for analytics and custom logging.
|
|
595
565
|
|
|
596
|
-
|
|
566
|
+
## Vulnerability Reporting
|
|
597
567
|
|
|
598
|
-
The
|
|
568
|
+
The [Guidelines for responsible disclosure](https://www.strivacity.com/report-a-security-issue) details the procedure for disclosing security issues. Please do not report security vulnerabilities on the public issue tracker.
|
|
599
569
|
|
|
600
|
-
|
|
601
|
-
- `date`: For date input fields
|
|
602
|
-
- `input`: For text input fields
|
|
603
|
-
- `layout`: For layout containers and form structure
|
|
604
|
-
- `loading`: For loading indicators
|
|
605
|
-
- `multiSelect`: For multi-select dropdown fields
|
|
606
|
-
- `passcode`: For passcode input fields
|
|
607
|
-
- `password`: For password input fields
|
|
608
|
-
- `phone`: For phone number input fields
|
|
609
|
-
- `select`: For single-select dropdown fields
|
|
610
|
-
- `static`: For static text and display elements
|
|
611
|
-
- `submit`: For form submission buttons
|
|
570
|
+
## License
|
|
612
571
|
|
|
613
|
-
|
|
572
|
+
@strivacity/sdk-remix is available under the MIT License. See the [LICENSE](https://github.com/Strivacity/sdk-js/blob/main/LICENSE) file for more info.
|
|
614
573
|
|
|
615
|
-
|
|
574
|
+
## Contributing
|
|
616
575
|
|
|
617
|
-
[
|
|
576
|
+
Please see our [contributing guide](https://github.com/Strivacity/sdk-js/blob/main/CONTRIBUTING.md).
|
|
618
577
|
|
|
619
578
|
## Migrating to v3.0
|
|
620
579
|
|
|
621
580
|
### Entry API Major Changes
|
|
622
581
|
|
|
623
|
-
Strivacity SDK's `entry()` API now returns a structured object instead of a plain string.
|
|
582
|
+
Strivacity SDK's `entry()` API now returns a structured object instead of a plain string. Check the example above in the usage section for more details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strivacity/sdk-remix",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Strivacity Remix SDK client",
|
|
6
6
|
"author": "strivacity <opensource@strivacity.com>",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "https://github.com/Strivacity/sdk-js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@strivacity/sdk-core": "3.0.
|
|
12
|
+
"@strivacity/sdk-core": "3.0.1"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"react": ">=18"
|