@strivacity/sdk-nuxt 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
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
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
|
+
- ⚠️ NativeFlow entry function now returns an object instead of a string ([9a8942d](https://github.com/Strivacity/sdk-js/commit/9a8942d))
|
|
16
|
+
|
|
17
|
+
### ⚠️ Breaking Changes
|
|
18
|
+
|
|
19
|
+
- NativeFlow entry function now returns an object instead of a string ([9a8942d](https://github.com/Strivacity/sdk-js/commit/9a8942d))
|
|
20
|
+
|
|
21
|
+
### 🧱 Updated Dependencies
|
|
22
|
+
|
|
23
|
+
- Updated sdk-core to 3.0.0
|
|
24
|
+
|
|
1
25
|
## 3.0.0-rc.0 (2026-02-18)
|
|
2
26
|
|
|
3
27
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
# @strivacity/sdk-nuxt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Nuxt 3 module 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 Nuxt 3 application. It registers itself as a Nuxt module and automatically provides the `useStrivacity` composable and `StyLoginRenderer` component throughout your application without needing explicit imports. 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/nuxt)
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Nuxt: 3+
|
|
18
|
+
|
|
19
|
+
## Install
|
|
10
20
|
|
|
11
21
|
```bash
|
|
12
22
|
npm install @strivacity/sdk-nuxt
|
|
13
23
|
```
|
|
14
24
|
|
|
15
|
-
|
|
25
|
+
## Usage
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
### Initialization
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
import { defineNuxtConfig } from 'nuxt/config';
|
|
29
|
+
Register the SDK as a Nuxt module in `nuxt.config.ts`:
|
|
21
30
|
|
|
31
|
+
```ts
|
|
32
|
+
// nuxt.config.ts
|
|
22
33
|
export default defineNuxtConfig({
|
|
23
|
-
...
|
|
24
34
|
modules: ['@strivacity/sdk-nuxt'],
|
|
25
35
|
strivacity: {
|
|
26
|
-
mode: 'redirect', // or 'popup'
|
|
36
|
+
mode: 'redirect', // or 'popup', 'native', 'embedded'
|
|
27
37
|
issuer: 'https://<YOUR_DOMAIN>',
|
|
28
38
|
scopes: ['openid', 'profile'],
|
|
29
39
|
clientId: '<YOUR_CLIENT_ID>',
|
|
@@ -32,22 +42,24 @@ export default defineNuxtConfig({
|
|
|
32
42
|
});
|
|
33
43
|
```
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
##### Redirect or popup mode
|
|
45
|
+
Use the auto-imported `useStrivacity` composable in any component to access authentication state:
|
|
38
46
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
```vue
|
|
48
|
+
<script setup>
|
|
49
|
+
const { loading, isAuthenticated, idTokenClaims } = useStrivacity();
|
|
50
|
+
</script>
|
|
51
|
+
```
|
|
42
52
|
|
|
43
|
-
|
|
53
|
+
### Redirect / Popup mode
|
|
44
54
|
|
|
45
|
-
|
|
55
|
+
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.
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
#### Login page example
|
|
48
58
|
|
|
49
59
|
```vue
|
|
50
60
|
<script setup>
|
|
61
|
+
import { onMounted } from 'vue';
|
|
62
|
+
|
|
51
63
|
const { login } = useStrivacity();
|
|
52
64
|
|
|
53
65
|
onMounted(() => {
|
|
@@ -62,12 +74,14 @@ onMounted(() => {
|
|
|
62
74
|
</template>
|
|
63
75
|
```
|
|
64
76
|
|
|
65
|
-
|
|
77
|
+
#### Callback page example
|
|
66
78
|
|
|
67
|
-
The callback page handles the response from the identity provider
|
|
79
|
+
The callback page handles the response from the identity provider. It calls `handleCallback()` and redirects to `/profile` on success:
|
|
68
80
|
|
|
69
81
|
```vue
|
|
70
82
|
<script setup>
|
|
83
|
+
import { onMounted } from 'vue';
|
|
84
|
+
|
|
71
85
|
const router = useRouter();
|
|
72
86
|
const { handleCallback } = useStrivacity();
|
|
73
87
|
|
|
@@ -88,11 +102,7 @@ onMounted(async () => {
|
|
|
88
102
|
</template>
|
|
89
103
|
```
|
|
90
104
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
The profile page displays user information and authentication details after successful login. It uses the `useStrivacity` composable to access the authentication state and display relevant data such as access tokens, ID token claims, and expiration status.
|
|
94
|
-
|
|
95
|
-
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.
|
|
105
|
+
#### Profile page example
|
|
96
106
|
|
|
97
107
|
```vue
|
|
98
108
|
<script setup>
|
|
@@ -103,33 +113,23 @@ const { loading, isAuthenticated, accessToken, accessTokenExpired, accessTokenEx
|
|
|
103
113
|
<section>
|
|
104
114
|
<h1 v-if="loading">Loading...</h1>
|
|
105
115
|
<dl v-else>
|
|
106
|
-
<dt>
|
|
107
|
-
<strong>accessToken</strong>
|
|
108
|
-
</dt>
|
|
116
|
+
<dt><strong>accessToken</strong></dt>
|
|
109
117
|
<dd>
|
|
110
118
|
<pre>{{ JSON.stringify(accessToken) }}</pre>
|
|
111
119
|
</dd>
|
|
112
|
-
<dt>
|
|
113
|
-
<strong>refreshToken</strong>
|
|
114
|
-
</dt>
|
|
120
|
+
<dt><strong>refreshToken</strong></dt>
|
|
115
121
|
<dd>
|
|
116
122
|
<pre>{{ JSON.stringify(refreshToken) }}</pre>
|
|
117
123
|
</dd>
|
|
118
|
-
<dt>
|
|
119
|
-
<strong>accessTokenExpired</strong>
|
|
120
|
-
</dt>
|
|
124
|
+
<dt><strong>accessTokenExpired</strong></dt>
|
|
121
125
|
<dd>
|
|
122
126
|
<pre>{{ JSON.stringify(accessTokenExpired) }}</pre>
|
|
123
127
|
</dd>
|
|
124
|
-
<dt>
|
|
125
|
-
<strong>accessTokenExpirationDate</strong>
|
|
126
|
-
</dt>
|
|
128
|
+
<dt><strong>accessTokenExpirationDate</strong></dt>
|
|
127
129
|
<dd>
|
|
128
130
|
<pre>{{ accessTokenExpirationDate ? new Date(accessTokenExpirationDate * 1000).toLocaleString() : JSON.stringify(null) }}</pre>
|
|
129
131
|
</dd>
|
|
130
|
-
<dt>
|
|
131
|
-
<strong>claims</strong>
|
|
132
|
-
</dt>
|
|
132
|
+
<dt><strong>claims</strong></dt>
|
|
133
133
|
<dd>
|
|
134
134
|
<pre>{{ JSON.stringify(idTokenClaims, null, 2) }}</pre>
|
|
135
135
|
</dd>
|
|
@@ -138,14 +138,14 @@ const { loading, isAuthenticated, accessToken, accessTokenExpired, accessTokenEx
|
|
|
138
138
|
</template>
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
The logout page handles user logout by terminating their session. The `postLogoutRedirectUri` parameter is optional and specifies where users should be redirected after logout. If not provided, users will be redirected to the identity provider's logout page.
|
|
141
|
+
#### Logout page example
|
|
144
142
|
|
|
145
|
-
This URI must be configured in the Admin Console as an allowed post-logout redirect URI
|
|
143
|
+
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.
|
|
146
144
|
|
|
147
145
|
```vue
|
|
148
146
|
<script setup>
|
|
147
|
+
import { onMounted } from 'vue';
|
|
148
|
+
|
|
149
149
|
const router = useRouter();
|
|
150
150
|
const { isAuthenticated, logout } = useStrivacity();
|
|
151
151
|
|
|
@@ -165,12 +165,12 @@ onMounted(async () => {
|
|
|
165
165
|
</template>
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
Here's a simple component example that demonstrates how to use the SDK in a component with login/logout functionality:
|
|
168
|
+
#### Component example
|
|
171
169
|
|
|
172
170
|
```vue
|
|
173
171
|
<script setup>
|
|
172
|
+
import { computed } from 'vue';
|
|
173
|
+
|
|
174
174
|
const { isAuthenticated, idTokenClaims, login, logout } = useStrivacity();
|
|
175
175
|
const name = computed(() => `${idTokenClaims.value?.given_name} ${idTokenClaims.value?.family_name}`);
|
|
176
176
|
</script>
|
|
@@ -187,15 +187,11 @@ const name = computed(() => `${idTokenClaims.value?.given_name} ${idTokenClaims.
|
|
|
187
187
|
</template>
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
### Native mode
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
In `native` mode the auto-imported `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/nuxt/app/components/widgets).
|
|
193
193
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
###### Example widgets
|
|
197
|
-
|
|
198
|
-
The example widgets use SCSS for styling and Luxon for date handling. You'll need to install these dependencies:
|
|
194
|
+
The example widgets use SCSS for styling and Luxon for date handling:
|
|
199
195
|
|
|
200
196
|
```bash
|
|
201
197
|
npm install sass luxon
|
|
@@ -232,84 +228,46 @@ export const widgets = {
|
|
|
232
228
|
};
|
|
233
229
|
```
|
|
234
230
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
###### Login page example
|
|
231
|
+
#### Login page example
|
|
238
232
|
|
|
239
|
-
The
|
|
240
|
-
|
|
241
|
-
This example demonstrates how to handle session management, implement callback functions for various authentication events, and manage URL parameters for session continuity.
|
|
233
|
+
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.
|
|
242
234
|
|
|
243
235
|
```vue
|
|
244
236
|
<script setup lang="ts">
|
|
245
|
-
import {
|
|
246
|
-
import {
|
|
237
|
+
import { ref } from 'vue';
|
|
238
|
+
import type { FallbackError, LoginFlowState } from '@strivacity/sdk-nuxt';
|
|
239
|
+
import { widgets } from '~/components/widgets';
|
|
247
240
|
|
|
248
241
|
const router = useRouter();
|
|
249
|
-
const { options, login } = useStrivacity();
|
|
250
242
|
const sessionId = ref<string | null>(null);
|
|
251
243
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const url = new URL(window.location.href);
|
|
259
|
-
const sid = url.searchParams.get('session_id');
|
|
260
|
-
sessionId.value = sid;
|
|
261
|
-
url.search = '';
|
|
262
|
-
window.history.replaceState({}, '', url.toString());
|
|
263
|
-
}
|
|
264
|
-
});
|
|
244
|
+
if (window.location.search !== '') {
|
|
245
|
+
const url = new URL(window.location.href);
|
|
246
|
+
sessionId.value = url.searchParams.get('session_id');
|
|
247
|
+
url.search = '';
|
|
248
|
+
history.replaceState({}, '', url.toString());
|
|
249
|
+
}
|
|
265
250
|
|
|
266
|
-
/**
|
|
267
|
-
* Called when authentication is successful
|
|
268
|
-
* Redirects user to the profile page
|
|
269
|
-
*/
|
|
270
251
|
const onLogin = async () => {
|
|
271
252
|
await router.push('/profile');
|
|
272
253
|
};
|
|
273
254
|
|
|
274
|
-
/**
|
|
275
|
-
* Called when native flow cannot handle the authentication
|
|
276
|
-
* Falls back to redirect mode by navigating to the provided URL
|
|
277
|
-
* @param error - FallbackError containing the fallback URL and message
|
|
278
|
-
*/
|
|
279
255
|
const onFallback = (error: FallbackError) => {
|
|
280
256
|
if (error.url) {
|
|
281
|
-
|
|
282
|
-
if (process.client) {
|
|
283
|
-
window.location.href = error.url.toString();
|
|
284
|
-
}
|
|
257
|
+
window.location.href = error.url.toString();
|
|
285
258
|
} else {
|
|
286
|
-
console.error(`FallbackError without URL: ${error.message}`);
|
|
287
259
|
alert(error);
|
|
288
260
|
}
|
|
289
261
|
};
|
|
290
262
|
|
|
291
|
-
/**
|
|
292
|
-
* Called when an error occurs during the authentication process
|
|
293
|
-
* @param error - Error message describing what went wrong
|
|
294
|
-
*/
|
|
295
263
|
const onError = (error: string) => {
|
|
296
|
-
console.error(`Error: ${error}`);
|
|
297
264
|
alert(error);
|
|
298
265
|
};
|
|
299
266
|
|
|
300
|
-
/**
|
|
301
|
-
* Called when the authentication flow wants to display a global message
|
|
302
|
-
* @param message - Message to display to the user
|
|
303
|
-
*/
|
|
304
267
|
const onGlobalMessage = (message: string) => {
|
|
305
268
|
alert(message);
|
|
306
269
|
};
|
|
307
270
|
|
|
308
|
-
/**
|
|
309
|
-
* Called when the authentication flow transitions between states
|
|
310
|
-
* Useful for tracking flow progress and inject custom logic such as logging or analytics
|
|
311
|
-
* @param params - Object containing previous and current flow states
|
|
312
|
-
*/
|
|
313
271
|
const onBlockReady = ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => {
|
|
314
272
|
console.log('previousState', previousState);
|
|
315
273
|
console.log('state', state);
|
|
@@ -329,32 +287,30 @@ const onBlockReady = ({ previousState, state }: { previousState: LoginFlowState;
|
|
|
329
287
|
</template>
|
|
330
288
|
```
|
|
331
289
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
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.
|
|
290
|
+
#### Callback page example
|
|
335
291
|
|
|
336
|
-
|
|
292
|
+
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:
|
|
337
293
|
|
|
338
294
|
```vue
|
|
339
295
|
<script setup>
|
|
340
|
-
|
|
296
|
+
import { onMounted, computed } from 'vue';
|
|
297
|
+
|
|
298
|
+
const query = computed(() => Object.fromEntries(new URLSearchParams(window.location.search)));
|
|
341
299
|
const router = useRouter();
|
|
342
300
|
const { handleCallback } = useStrivacity();
|
|
343
301
|
|
|
344
302
|
onMounted(async () => {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
const sessionId = url.searchParams.get('session_id');
|
|
303
|
+
const url = new URL(location.href);
|
|
304
|
+
const sessionId = url.searchParams.get('session_id');
|
|
348
305
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
306
|
+
if (sessionId) {
|
|
307
|
+
await router.push(`/login?session_id=${sessionId}`);
|
|
308
|
+
} else {
|
|
309
|
+
try {
|
|
310
|
+
await handleCallback();
|
|
311
|
+
await router.push('/profile');
|
|
312
|
+
} catch (error) {
|
|
313
|
+
console.error('Error during callback handling:', error);
|
|
358
314
|
}
|
|
359
315
|
}
|
|
360
316
|
});
|
|
@@ -374,28 +330,80 @@ onMounted(async () => {
|
|
|
374
330
|
</template>
|
|
375
331
|
```
|
|
376
332
|
|
|
377
|
-
|
|
333
|
+
#### Entry page example
|
|
334
|
+
|
|
335
|
+
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:
|
|
336
|
+
|
|
337
|
+
```vue
|
|
338
|
+
<script setup>
|
|
339
|
+
import { onMounted } from 'vue';
|
|
340
|
+
|
|
341
|
+
const router = useRouter();
|
|
342
|
+
const { entry } = useStrivacity();
|
|
343
|
+
|
|
344
|
+
onMounted(async () => {
|
|
345
|
+
try {
|
|
346
|
+
const data = await entry();
|
|
347
|
+
|
|
348
|
+
if (data && Object.keys(data).length > 0) {
|
|
349
|
+
await router.push(`/callback?${new URLSearchParams(data).toString()}`);
|
|
350
|
+
} else {
|
|
351
|
+
await router.push('/');
|
|
352
|
+
}
|
|
353
|
+
} catch (error) {
|
|
354
|
+
console.error('Entry failed:', error);
|
|
355
|
+
await router.push('/');
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
</script>
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### Profile page example
|
|
378
362
|
|
|
379
363
|
Same as the profile page example in redirect/popup mode.
|
|
380
364
|
|
|
381
|
-
|
|
365
|
+
#### Logout page example
|
|
382
366
|
|
|
383
367
|
Same as the logout page example in redirect/popup mode.
|
|
384
368
|
|
|
369
|
+
### Embedded mode
|
|
370
|
+
|
|
371
|
+
In `embedded` mode the `<sty-login>` web component (loaded via `bundle.js` from the cluster) handles rendering. Import the bundle in a Nuxt plugin to register the Strivacity web components:
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
// plugins/strivacity-bundle.client.ts
|
|
375
|
+
export default defineNuxtPlugin(() => {
|
|
376
|
+
const config = useRuntimeConfig();
|
|
377
|
+
void import(`${config.public.strivacity.issuer}/assets/components/bundle.js`);
|
|
378
|
+
});
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
```ts
|
|
382
|
+
// nuxt.config.ts
|
|
383
|
+
export default defineNuxtConfig({
|
|
384
|
+
modules: ['@strivacity/sdk-nuxt'],
|
|
385
|
+
strivacity: {
|
|
386
|
+
mode: 'embedded',
|
|
387
|
+
issuer: 'https://<YOUR_DOMAIN>',
|
|
388
|
+
scopes: ['openid', 'profile'],
|
|
389
|
+
clientId: '<YOUR_CLIENT_ID>',
|
|
390
|
+
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
385
395
|
## Logging
|
|
386
396
|
|
|
387
397
|
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.
|
|
388
398
|
|
|
389
399
|
### Using the Default Logger
|
|
390
400
|
|
|
391
|
-
Enable the default console logger by adding the `logging` option in
|
|
401
|
+
Enable the default console logger by adding the `logging` option in `nuxt.config.ts`:
|
|
392
402
|
|
|
393
|
-
```
|
|
394
|
-
import { defineNuxtConfig } from 'nuxt/config';
|
|
403
|
+
```ts
|
|
395
404
|
import { DefaultLogging } from '@strivacity/sdk-nuxt';
|
|
396
405
|
|
|
397
406
|
export default defineNuxtConfig({
|
|
398
|
-
ssr: false,
|
|
399
407
|
modules: ['@strivacity/sdk-nuxt'],
|
|
400
408
|
strivacity: {
|
|
401
409
|
mode: 'redirect',
|
|
@@ -403,16 +411,14 @@ export default defineNuxtConfig({
|
|
|
403
411
|
scopes: ['openid', 'profile'],
|
|
404
412
|
clientId: '<YOUR_CLIENT_ID>',
|
|
405
413
|
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
406
|
-
logging: DefaultLogging,
|
|
414
|
+
logging: DefaultLogging,
|
|
407
415
|
},
|
|
408
416
|
});
|
|
409
417
|
```
|
|
410
418
|
|
|
411
|
-
The default logger writes to the browser console and automatically prefixes messages with a correlation ID when available (via the `xEventId` property).
|
|
412
|
-
|
|
413
419
|
### Creating a Custom Logger
|
|
414
420
|
|
|
415
|
-
|
|
421
|
+
Implement the `SDKLogging` interface and pass your class to the `logging` option:
|
|
416
422
|
|
|
417
423
|
```typescript
|
|
418
424
|
import type { SDKLogging } from '@strivacity/sdk-nuxt';
|
|
@@ -421,7 +427,6 @@ export class MyLogger implements SDKLogging {
|
|
|
421
427
|
xEventId?: string;
|
|
422
428
|
|
|
423
429
|
debug(message: string): void {
|
|
424
|
-
// Send to your logging pipeline
|
|
425
430
|
console.debug(this.xEventId ? `[${this.xEventId}] ${message}` : message);
|
|
426
431
|
}
|
|
427
432
|
|
|
@@ -439,172 +444,100 @@ export class MyLogger implements SDKLogging {
|
|
|
439
444
|
}
|
|
440
445
|
```
|
|
441
446
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
```typescript
|
|
445
|
-
import { defineNuxtConfig } from 'nuxt/config';
|
|
446
|
-
import { MyLogger } from './logging/MyLogger';
|
|
447
|
-
|
|
448
|
-
export default defineNuxtConfig({
|
|
449
|
-
ssr: false,
|
|
450
|
-
modules: ['@strivacity/sdk-nuxt'],
|
|
451
|
-
strivacity: {
|
|
452
|
-
mode: 'redirect',
|
|
453
|
-
issuer: 'https://<YOUR_DOMAIN>',
|
|
454
|
-
scopes: ['openid', 'profile'],
|
|
455
|
-
clientId: '<YOUR_CLIENT_ID>',
|
|
456
|
-
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
457
|
-
logging: MyLogger, // Use your custom logger
|
|
458
|
-
},
|
|
459
|
-
});
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
### Logger Interface
|
|
447
|
+
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.
|
|
463
448
|
|
|
464
|
-
|
|
449
|
+
## API Documentation
|
|
465
450
|
|
|
466
|
-
|
|
467
|
-
- **`info(message: string): void`** - Log informational messages
|
|
468
|
-
- **`warn(message: string): void`** - Log warning messages
|
|
469
|
-
- **`error(message: string, error: Error): void`** - Log error messages with error objects
|
|
470
|
-
|
|
471
|
-
The optional `xEventId` property, when set by the SDK, provides a correlation ID to trace related log messages across the authentication flow.
|
|
472
|
-
|
|
473
|
-
### API Documentation
|
|
474
|
-
|
|
475
|
-
#### `useStrivacity` composable
|
|
451
|
+
### `useStrivacity` composable
|
|
476
452
|
|
|
477
453
|
```typescript
|
|
478
454
|
useStrivacity<T extends PopupContext | RedirectContext | NativeContext>(): T;
|
|
479
455
|
```
|
|
480
456
|
|
|
481
|
-
|
|
457
|
+
The composable returns a different context type depending on the `mode` configured in `nuxt.config.ts`.
|
|
482
458
|
|
|
483
|
-
**
|
|
459
|
+
**Shared properties (all modes)**
|
|
484
460
|
|
|
485
|
-
- **`sdk: RedirectFlow | PopupFlow | NativeFlow`**:
|
|
486
|
-
- **`loading: Ref<boolean>`**:
|
|
487
|
-
- **`options: SDKOptions`**: The configured options
|
|
488
|
-
- **`isAuthenticated: Ref<boolean>`**:
|
|
489
|
-
- **`idTokenClaims: Ref<IdTokenClaims | null>`**: Claims from the ID token, or null if not
|
|
490
|
-
- **`accessToken: Ref<string | null>`**: The access token
|
|
491
|
-
- **`refreshToken: Ref<string | null>`**: The refresh token
|
|
492
|
-
- **`accessTokenExpired: Ref<boolean>`**:
|
|
493
|
-
- **`accessTokenExpirationDate: Ref<number | null>`**: Expiration
|
|
461
|
+
- **`sdk: RedirectFlow | PopupFlow | NativeFlow`**: The underlying SDK flow instance.
|
|
462
|
+
- **`loading: Ref<boolean>`**: `true` while the session is being initialized.
|
|
463
|
+
- **`options: SDKOptions`**: The configured SDK options.
|
|
464
|
+
- **`isAuthenticated: Ref<boolean>`**: `true` when the user has a valid session.
|
|
465
|
+
- **`idTokenClaims: Ref<IdTokenClaims | null>`**: Claims from the ID token, or `null` if not authenticated.
|
|
466
|
+
- **`accessToken: Ref<string | null>`**: The current access token.
|
|
467
|
+
- **`refreshToken: Ref<string | null>`**: The current refresh token.
|
|
468
|
+
- **`accessTokenExpired: Ref<boolean>`**: `true` when the access token has expired.
|
|
469
|
+
- **`accessTokenExpirationDate: Ref<number | null>`**: Expiration timestamp (Unix seconds) of the access token.
|
|
494
470
|
|
|
495
471
|
---
|
|
496
472
|
|
|
497
473
|
**Type: `RedirectContext`**
|
|
498
474
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
- **`
|
|
502
|
-
|
|
503
|
-
- **`
|
|
504
|
-
|
|
505
|
-
- **`
|
|
506
|
-
- **`revoke(): Promise<void>`**: Revokes the current session tokens using a redirect flow.
|
|
507
|
-
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs out the user by redirecting to the identity provider.
|
|
508
|
-
- `options` (optional): Configuration options for logout.
|
|
509
|
-
- **`handleCallback(url?: string): Promise<void>`**: Handles the callback after a redirect-based authentication or token exchange.
|
|
510
|
-
- `url` (optional): The URL to handle for the callback.
|
|
475
|
+
- **`login(options?: LoginOptions): Promise<void>`**: Initiates login by redirecting to the identity provider.
|
|
476
|
+
- **`register(options?: RegisterOptions): Promise<void>`**: Initiates registration using a redirect flow.
|
|
477
|
+
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
478
|
+
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
479
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs the user out via redirect.
|
|
480
|
+
- **`handleCallback(url?: string): Promise<void>`**: Processes the authorization callback after redirect.
|
|
481
|
+
- **`entry(): Promise<Record<string, string>>`**: Processes an externally-initiated flow URL and returns the parameters needed to resume the flow.
|
|
511
482
|
|
|
512
483
|
---
|
|
513
484
|
|
|
514
485
|
**Type: `PopupContext`**
|
|
515
486
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
- **`
|
|
519
|
-
|
|
520
|
-
- **`
|
|
521
|
-
|
|
522
|
-
- **`
|
|
523
|
-
- **`revoke(): Promise<void>`**: Revokes the current session tokens using a popup flow.
|
|
524
|
-
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs out the user using a popup window.
|
|
525
|
-
- `options` (optional): Configuration options for logout.
|
|
526
|
-
- **`handleCallback(url?: string): Promise<void>`**: Handles the callback after a popup-based authentication or token exchange.
|
|
527
|
-
- `url` (optional): The URL to handle for the callback.
|
|
487
|
+
- **`login(options?: LoginOptions): Promise<void>`**: Initiates login using a popup window.
|
|
488
|
+
- **`register(options?: RegisterOptions): Promise<void>`**: Initiates registration using a popup.
|
|
489
|
+
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
490
|
+
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
491
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs the user out via popup.
|
|
492
|
+
- **`handleCallback(url?: string): Promise<void>`**: Processes the authorization callback.
|
|
493
|
+
- **`entry(): Promise<Record<string, string>>`**: Processes an externally-initiated flow URL.
|
|
528
494
|
|
|
529
495
|
---
|
|
530
496
|
|
|
531
497
|
**Type: `NativeContext`**
|
|
532
498
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
- **`login(options?: LoginOptions): Promise<NativeFlowHandler>`**: Initiates the login process using a native flow.
|
|
536
|
-
- `options` (optional): Configuration options for login.
|
|
537
|
-
- **`register(options?: RegisterOptions): Promise<NativeFlowHandler>`**: Registers a new user using a native flow.
|
|
538
|
-
- `options` (optional): Configuration options for registration.
|
|
499
|
+
- **`login(options?: LoginOptions): Promise<NativeFlowHandler>`**: Initiates login using the native flow.
|
|
500
|
+
- **`register(options?: RegisterOptions): Promise<NativeFlowHandler>`**: Initiates registration using the native flow.
|
|
539
501
|
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
540
502
|
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
541
|
-
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs
|
|
542
|
-
|
|
543
|
-
- **`
|
|
544
|
-
- `url` (optional): The URL to handle for the callback.
|
|
503
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs the user out via redirect.
|
|
504
|
+
- **`handleCallback(url?: string): Promise<void>`**: Processes the authorization callback.
|
|
505
|
+
- **`entry(): Promise<Record<string, string>>`**: Processes an externally-initiated flow URL.
|
|
545
506
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
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.
|
|
549
|
-
|
|
550
|
-
```typescript
|
|
551
|
-
StyLoginRenderer: Vue.Component<{
|
|
552
|
-
params?: NativeParams;
|
|
553
|
-
widgets?: PartialRecord<WidgetType, Vue.Component>;
|
|
554
|
-
sessionId?: string | null;
|
|
555
|
-
onLogin?: (claims?: IdTokenClaims | null) => void;
|
|
556
|
-
onFallback?: (error: FallbackError) => void;
|
|
557
|
-
onError?: (error: any) => void;
|
|
558
|
-
onGlobalMessage?: (message: string) => void;
|
|
559
|
-
onBlockReady?: ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => void;
|
|
560
|
-
}>;
|
|
561
|
-
```
|
|
507
|
+
---
|
|
562
508
|
|
|
563
|
-
|
|
509
|
+
### `StyLoginRenderer` component
|
|
564
510
|
|
|
565
|
-
-
|
|
511
|
+
Auto-imported in `native` mode to render the authentication UI with your own widget components.
|
|
566
512
|
|
|
567
|
-
|
|
513
|
+
**Props**
|
|
568
514
|
|
|
569
|
-
- **`
|
|
515
|
+
- **`params?: NativeParams`**: Additional parameters for the native login flow.
|
|
516
|
+
- **`widgets?: PartialRecord<WidgetType, Vue.Component>`**: Custom Vue components for each widget type used in the flow.
|
|
517
|
+
- **`sessionId?: string | null`**: Session ID for resuming an existing authentication session.
|
|
570
518
|
|
|
571
519
|
**Events**
|
|
572
520
|
|
|
573
|
-
- **`@login
|
|
574
|
-
|
|
575
|
-
- **`@
|
|
576
|
-
|
|
577
|
-
- **`@
|
|
578
|
-
|
|
579
|
-
- **`@global-message?: (message: string) => void`** (optional): Event emitted when the authentication flow wants to display a global message to the user (e.g., account lockout warnings, validation messages).
|
|
580
|
-
|
|
581
|
-
- **`@block-ready?: ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => void`** (optional): Event emitted when the authentication flow transitions between states. Useful for tracking progress, implementing custom logging, or injecting analytics. Receives both the previous and current flow states.
|
|
521
|
+
- **`@login`**: Emitted on successful authentication. Receives `IdTokenClaims | null`.
|
|
522
|
+
- **`@fallback`**: Emitted when the native flow needs to fall back to redirect. Receives `FallbackError` with a fallback URL.
|
|
523
|
+
- **`@error`**: Emitted when an error occurs during authentication.
|
|
524
|
+
- **`@global-message`**: Emitted when the flow wants to display a global message (e.g. account lockout warning).
|
|
525
|
+
- **`@block-ready`**: Emitted on flow state transitions. Receives `{ previousState: LoginFlowState; state: LoginFlowState }`. Useful for analytics and custom logging.
|
|
582
526
|
|
|
583
|
-
|
|
527
|
+
## Vulnerability Reporting
|
|
584
528
|
|
|
585
|
-
The
|
|
529
|
+
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.
|
|
586
530
|
|
|
587
|
-
|
|
588
|
-
- `date`: For date input fields
|
|
589
|
-
- `input`: For text input fields
|
|
590
|
-
- `layout`: For layout containers and form structure
|
|
591
|
-
- `loading`: For loading indicators
|
|
592
|
-
- `multiSelect`: For multi-select dropdown fields
|
|
593
|
-
- `passcode`: For passcode input fields
|
|
594
|
-
- `password`: For password input fields
|
|
595
|
-
- `phone`: For phone number input fields
|
|
596
|
-
- `select`: For single-select dropdown fields
|
|
597
|
-
- `static`: For static text and display elements
|
|
598
|
-
- `submit`: For form submission buttons
|
|
531
|
+
## License
|
|
599
532
|
|
|
600
|
-
|
|
533
|
+
@strivacity/sdk-nuxt is available under the MIT License. See the [LICENSE](https://github.com/Strivacity/sdk-js/blob/main/LICENSE) file for more info.
|
|
601
534
|
|
|
602
|
-
|
|
535
|
+
## Contributing
|
|
603
536
|
|
|
604
|
-
[
|
|
537
|
+
Please see our [contributing guide](https://github.com/Strivacity/sdk-js/blob/main/CONTRIBUTING.md).
|
|
605
538
|
|
|
606
539
|
## Migrating to v3.0
|
|
607
540
|
|
|
608
541
|
### Entry API Major Changes
|
|
609
542
|
|
|
610
|
-
Strivacity SDK's `entry()` API now returns a structured object instead of a plain string.
|
|
543
|
+
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/dist/module.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strivacity/sdk-nuxt",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Strivacity Nuxt SDK client",
|
|
6
6
|
"author": "strivacity <opensource@strivacity.com>",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@strivacity/sdk-core": "3.0.
|
|
13
|
+
"@strivacity/sdk-core": "3.0.1"
|
|
14
14
|
},
|
|
15
15
|
"main": "./dist/module.mjs",
|
|
16
16
|
"types": "./dist/types.d.mts",
|
|
File without changes
|