@strivacity/sdk-vue 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 +27 -0
- package/README.md +220 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
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
|
+
- custom sdk mode added ([17812c6](https://github.com/Strivacity/sdk-js/commit/17812c6))
|
|
16
|
+
- ⚠️ EmbeddedFlow implemented ([a0e3ad8](https://github.com/Strivacity/sdk-js/commit/a0e3ad8))
|
|
17
|
+
- ⚠️ NativeFlow entry function now returns an object instead of a string ([9a8942d](https://github.com/Strivacity/sdk-js/commit/9a8942d))
|
|
18
|
+
|
|
19
|
+
### ⚠️ Breaking Changes
|
|
20
|
+
|
|
21
|
+
- EmbeddedFlow implemented ([a0e3ad8](https://github.com/Strivacity/sdk-js/commit/a0e3ad8))
|
|
22
|
+
- NativeFlow entry function now returns an object instead of a string ([9a8942d](https://github.com/Strivacity/sdk-js/commit/9a8942d))
|
|
23
|
+
|
|
24
|
+
### 🧱 Updated Dependencies
|
|
25
|
+
|
|
26
|
+
- Updated sdk-core to 3.0.0
|
|
27
|
+
|
|
1
28
|
## 3.0.0-rc.0 (2026-02-18)
|
|
2
29
|
|
|
3
30
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# @strivacity/sdk-vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Vue 3 plugin 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 Vue 3 application. It wraps the `@strivacity/sdk-core` library as a Vue plugin and exposes a `useStrivacity` composable that provides reactive authentication state and methods throughout your application. 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/vue)
|
|
8
14
|
- [Ionic Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/ionic-vue)
|
|
9
15
|
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Vue.js: 3+
|
|
19
|
+
|
|
10
20
|
## Install
|
|
11
21
|
|
|
12
22
|
```bash
|
|
@@ -15,7 +25,9 @@ npm install @strivacity/sdk-vue
|
|
|
15
25
|
|
|
16
26
|
## Usage
|
|
17
27
|
|
|
18
|
-
###
|
|
28
|
+
### Initialization
|
|
29
|
+
|
|
30
|
+
Register the SDK as a Vue plugin using `createStrivacitySDK` in your application's entry point:
|
|
19
31
|
|
|
20
32
|
```js
|
|
21
33
|
import { createApp } from 'vue';
|
|
@@ -24,7 +36,7 @@ import { createStrivacitySDK } from '@strivacity/sdk-vue';
|
|
|
24
36
|
|
|
25
37
|
const app = createApp(App);
|
|
26
38
|
const sdk = createStrivacitySDK({
|
|
27
|
-
mode: 'redirect', // or 'popup'
|
|
39
|
+
mode: 'redirect', // or 'popup', 'native', 'embedded'
|
|
28
40
|
issuer: 'https://<YOUR_DOMAIN>',
|
|
29
41
|
scopes: ['openid', 'profile'],
|
|
30
42
|
clientId: '<YOUR_CLIENT_ID>',
|
|
@@ -35,24 +47,21 @@ app.use(sdk);
|
|
|
35
47
|
app.mount('#app');
|
|
36
48
|
```
|
|
37
49
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- [Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/vue)
|
|
41
|
-
- [Ionic Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/ionic-vue)
|
|
50
|
+
Use the `useStrivacity` composable in any component to access authentication state:
|
|
42
51
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
When using redirect or popup mode, the authentication flow involves two main components: a login page that initiates the authentication process, and a callback page that handles the response from the identity provider.
|
|
52
|
+
```vue
|
|
53
|
+
<script setup>
|
|
54
|
+
import { useStrivacity } from '@strivacity/sdk-vue';
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
const { loading, isAuthenticated, idTokenClaims } = useStrivacity();
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
### Redirect / Popup mode
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
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.
|
|
54
63
|
|
|
55
|
-
|
|
64
|
+
#### Login page example
|
|
56
65
|
|
|
57
66
|
```vue
|
|
58
67
|
<script setup>
|
|
@@ -73,9 +82,9 @@ onMounted(() => {
|
|
|
73
82
|
</template>
|
|
74
83
|
```
|
|
75
84
|
|
|
76
|
-
|
|
85
|
+
#### Callback page example
|
|
77
86
|
|
|
78
|
-
The callback page handles the response from the identity provider
|
|
87
|
+
The callback page handles the response from the identity provider. It calls `handleCallback()` and redirects to `/profile` on success:
|
|
79
88
|
|
|
80
89
|
```vue
|
|
81
90
|
<script setup>
|
|
@@ -103,11 +112,7 @@ onMounted(async () => {
|
|
|
103
112
|
</template>
|
|
104
113
|
```
|
|
105
114
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
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.
|
|
109
|
-
|
|
110
|
-
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.
|
|
115
|
+
#### Profile page example
|
|
111
116
|
|
|
112
117
|
```vue
|
|
113
118
|
<script setup>
|
|
@@ -120,33 +125,23 @@ const { loading, isAuthenticated, accessToken, accessTokenExpired, accessTokenEx
|
|
|
120
125
|
<section>
|
|
121
126
|
<h1 v-if="loading">Loading...</h1>
|
|
122
127
|
<dl v-else>
|
|
123
|
-
<dt>
|
|
124
|
-
<strong>accessToken</strong>
|
|
125
|
-
</dt>
|
|
128
|
+
<dt><strong>accessToken</strong></dt>
|
|
126
129
|
<dd>
|
|
127
130
|
<pre>{{ JSON.stringify(accessToken) }}</pre>
|
|
128
131
|
</dd>
|
|
129
|
-
<dt>
|
|
130
|
-
<strong>refreshToken</strong>
|
|
131
|
-
</dt>
|
|
132
|
+
<dt><strong>refreshToken</strong></dt>
|
|
132
133
|
<dd>
|
|
133
134
|
<pre>{{ JSON.stringify(refreshToken) }}</pre>
|
|
134
135
|
</dd>
|
|
135
|
-
<dt>
|
|
136
|
-
<strong>accessTokenExpired</strong>
|
|
137
|
-
</dt>
|
|
136
|
+
<dt><strong>accessTokenExpired</strong></dt>
|
|
138
137
|
<dd>
|
|
139
138
|
<pre>{{ JSON.stringify(accessTokenExpired) }}</pre>
|
|
140
139
|
</dd>
|
|
141
|
-
<dt>
|
|
142
|
-
<strong>accessTokenExpirationDate</strong>
|
|
143
|
-
</dt>
|
|
140
|
+
<dt><strong>accessTokenExpirationDate</strong></dt>
|
|
144
141
|
<dd>
|
|
145
142
|
<pre>{{ accessTokenExpirationDate ? new Date(accessTokenExpirationDate * 1000).toLocaleString() : JSON.stringify(null) }}</pre>
|
|
146
143
|
</dd>
|
|
147
|
-
<dt>
|
|
148
|
-
<strong>claims</strong>
|
|
149
|
-
</dt>
|
|
144
|
+
<dt><strong>claims</strong></dt>
|
|
150
145
|
<dd>
|
|
151
146
|
<pre>{{ JSON.stringify(idTokenClaims, null, 2) }}</pre>
|
|
152
147
|
</dd>
|
|
@@ -155,11 +150,9 @@ const { loading, isAuthenticated, accessToken, accessTokenExpired, accessTokenEx
|
|
|
155
150
|
</template>
|
|
156
151
|
```
|
|
157
152
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
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.
|
|
153
|
+
#### Logout page example
|
|
161
154
|
|
|
162
|
-
This URI must be configured in the Admin Console as an allowed post-logout redirect URI
|
|
155
|
+
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.
|
|
163
156
|
|
|
164
157
|
```vue
|
|
165
158
|
<script setup>
|
|
@@ -186,9 +179,7 @@ onMounted(async () => {
|
|
|
186
179
|
</template>
|
|
187
180
|
```
|
|
188
181
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
Here's a simple component example that demonstrates how to use the SDK in a component with login/logout functionality:
|
|
182
|
+
#### Component example
|
|
192
183
|
|
|
193
184
|
```vue
|
|
194
185
|
<script setup>
|
|
@@ -211,15 +202,11 @@ const name = computed(() => `${idTokenClaims.value?.given_name} ${idTokenClaims.
|
|
|
211
202
|
</template>
|
|
212
203
|
```
|
|
213
204
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
If you are using `native` mode, you can use the `StyLoginRenderer` component to render the login UI.
|
|
205
|
+
### Native mode
|
|
217
206
|
|
|
218
|
-
|
|
207
|
+
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/vue/src/components/widgets).
|
|
219
208
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
The example widgets use SCSS for styling and Luxon for date handling. You'll need to install these dependencies:
|
|
209
|
+
The example widgets use SCSS for styling and Luxon for date handling:
|
|
223
210
|
|
|
224
211
|
```bash
|
|
225
212
|
npm install sass luxon
|
|
@@ -256,84 +243,47 @@ export const widgets = {
|
|
|
256
243
|
};
|
|
257
244
|
```
|
|
258
245
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
##### Login page example
|
|
246
|
+
#### Login page example
|
|
262
247
|
|
|
263
|
-
The
|
|
264
|
-
|
|
265
|
-
This example demonstrates how to handle session management, implement callback functions for various authentication events, and manage URL parameters for session continuity.
|
|
248
|
+
The login page extracts `session_id`, `short_app_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.
|
|
266
249
|
|
|
267
250
|
```vue
|
|
268
251
|
<script setup lang="ts">
|
|
269
|
-
import { ref
|
|
252
|
+
import { ref } from 'vue';
|
|
270
253
|
import { useRouter } from 'vue-router';
|
|
271
254
|
import { FallbackError, useStrivacity, type LoginFlowState } from '@strivacity/sdk-vue';
|
|
272
|
-
import { widgets } from './components/widgets';
|
|
255
|
+
import { widgets } from './components/widgets';
|
|
273
256
|
|
|
274
257
|
const router = useRouter();
|
|
275
|
-
const { options, login } = useStrivacity();
|
|
276
258
|
const sessionId = ref<string | null>(null);
|
|
277
259
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const url = new URL(window.location.href);
|
|
285
|
-
const sid = url.searchParams.get('session_id');
|
|
286
|
-
sessionId.value = sid;
|
|
287
|
-
url.search = '';
|
|
288
|
-
window.history.replaceState({}, '', url.toString());
|
|
289
|
-
}
|
|
290
|
-
});
|
|
260
|
+
if (window.location.search !== '') {
|
|
261
|
+
const url = new URL(window.location.href);
|
|
262
|
+
sessionId.value = url.searchParams.get('session_id');
|
|
263
|
+
url.search = '';
|
|
264
|
+
history.replaceState({}, '', url.toString());
|
|
265
|
+
}
|
|
291
266
|
|
|
292
|
-
/**
|
|
293
|
-
* Called when authentication is successful
|
|
294
|
-
* Redirects user to the profile page
|
|
295
|
-
*/
|
|
296
267
|
const onLogin = async () => {
|
|
297
268
|
await router.push('/profile');
|
|
298
269
|
};
|
|
299
270
|
|
|
300
|
-
/**
|
|
301
|
-
* Called when native flow cannot handle the authentication
|
|
302
|
-
* Falls back to redirect mode by navigating to the provided URL
|
|
303
|
-
* @param error - FallbackError containing the fallback URL and message
|
|
304
|
-
*/
|
|
305
271
|
const onFallback = (error: FallbackError) => {
|
|
306
272
|
if (error.url) {
|
|
307
|
-
console.log(`Fallback: ${error.url}`);
|
|
308
273
|
window.location.href = error.url.toString();
|
|
309
274
|
} else {
|
|
310
|
-
console.error(`FallbackError without URL: ${error.message}`);
|
|
311
275
|
alert(error);
|
|
312
276
|
}
|
|
313
277
|
};
|
|
314
278
|
|
|
315
|
-
/**
|
|
316
|
-
* Called when an error occurs during the authentication process
|
|
317
|
-
* @param error - Error message describing what went wrong
|
|
318
|
-
*/
|
|
319
279
|
const onError = (error: string) => {
|
|
320
|
-
console.error(`Error: ${error}`);
|
|
321
280
|
alert(error);
|
|
322
281
|
};
|
|
323
282
|
|
|
324
|
-
/**
|
|
325
|
-
* Called when the authentication flow wants to display a global message
|
|
326
|
-
* @param message - Message to display to the user
|
|
327
|
-
*/
|
|
328
283
|
const onGlobalMessage = (message: string) => {
|
|
329
284
|
alert(message);
|
|
330
285
|
};
|
|
331
286
|
|
|
332
|
-
/**
|
|
333
|
-
* Called when the authentication flow transitions between states
|
|
334
|
-
* Useful for tracking flow progress and inject custom logic such as logging or analytics
|
|
335
|
-
* @param params - Object containing previous and current flow states
|
|
336
|
-
*/
|
|
337
287
|
const onBlockReady = ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => {
|
|
338
288
|
console.log('previousState', previousState);
|
|
339
289
|
console.log('state', state);
|
|
@@ -353,11 +303,9 @@ const onBlockReady = ({ previousState, state }: { previousState: LoginFlowState;
|
|
|
353
303
|
</template>
|
|
354
304
|
```
|
|
355
305
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
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.
|
|
306
|
+
#### Callback page example
|
|
359
307
|
|
|
360
|
-
|
|
308
|
+
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:
|
|
361
309
|
|
|
362
310
|
```vue
|
|
363
311
|
<script setup>
|
|
@@ -365,7 +313,7 @@ import { onMounted, computed } from 'vue';
|
|
|
365
313
|
import { useRouter } from 'vue-router';
|
|
366
314
|
import { useStrivacity } from '@strivacity/sdk-vue';
|
|
367
315
|
|
|
368
|
-
const query = computed(() =>
|
|
316
|
+
const query = computed(() => Object.fromEntries(new URLSearchParams(window.location.search)));
|
|
369
317
|
const router = useRouter();
|
|
370
318
|
const { handleCallback } = useStrivacity();
|
|
371
319
|
|
|
@@ -400,14 +348,124 @@ onMounted(async () => {
|
|
|
400
348
|
</template>
|
|
401
349
|
```
|
|
402
350
|
|
|
403
|
-
|
|
351
|
+
#### Entry page example
|
|
352
|
+
|
|
353
|
+
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 login page:
|
|
354
|
+
|
|
355
|
+
```vue
|
|
356
|
+
<script setup>
|
|
357
|
+
import { onMounted } from 'vue';
|
|
358
|
+
import { useRouter } from 'vue-router';
|
|
359
|
+
import { useStrivacity } from '@strivacity/sdk-vue';
|
|
360
|
+
|
|
361
|
+
const router = useRouter();
|
|
362
|
+
const { entry } = useStrivacity();
|
|
363
|
+
|
|
364
|
+
onMounted(async () => {
|
|
365
|
+
try {
|
|
366
|
+
const data = await entry();
|
|
367
|
+
|
|
368
|
+
if (data && Object.keys(data).length > 0) {
|
|
369
|
+
await router.push(`/callback?${new URLSearchParams(data).toString()}`);
|
|
370
|
+
} else {
|
|
371
|
+
await router.push('/');
|
|
372
|
+
}
|
|
373
|
+
} catch (error) {
|
|
374
|
+
console.error('Entry failed:', error);
|
|
375
|
+
await router.push('/');
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
</script>
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
#### Profile page example
|
|
404
382
|
|
|
405
383
|
Same as the profile page example in redirect/popup mode.
|
|
406
384
|
|
|
407
|
-
|
|
385
|
+
#### Logout page example
|
|
408
386
|
|
|
409
387
|
Same as the logout page example in redirect/popup mode.
|
|
410
388
|
|
|
389
|
+
### Embedded mode
|
|
390
|
+
|
|
391
|
+
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:
|
|
392
|
+
|
|
393
|
+
```js
|
|
394
|
+
import { createApp } from 'vue';
|
|
395
|
+
import App from './App.vue';
|
|
396
|
+
import { createStrivacitySDK } from '@strivacity/sdk-vue';
|
|
397
|
+
|
|
398
|
+
void import(`${import.meta.env.VITE_ISSUER}/assets/components/bundle.js`);
|
|
399
|
+
|
|
400
|
+
const app = createApp(App);
|
|
401
|
+
const sdk = createStrivacitySDK({
|
|
402
|
+
mode: 'embedded',
|
|
403
|
+
issuer: 'https://<YOUR_DOMAIN>',
|
|
404
|
+
scopes: ['openid', 'profile'],
|
|
405
|
+
clientId: '<YOUR_CLIENT_ID>',
|
|
406
|
+
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
app.use(sdk);
|
|
410
|
+
app.mount('#app');
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### Login page example
|
|
414
|
+
|
|
415
|
+
The login page extracts `session_id`, `short_app_id`, and optionally `language` from the URL on load and passes them to the `<sty-login>` web component. When a `language` parameter is present it overrides `uiLocales` to display the authentication UI in the specified language. The bundle registers `<sty-login>`, `<sty-notifications>`, and `<sty-language-selector>` as custom elements.
|
|
416
|
+
|
|
417
|
+
```vue
|
|
418
|
+
<script setup lang="ts">
|
|
419
|
+
import { ref } from 'vue';
|
|
420
|
+
import { useRouter } from 'vue-router';
|
|
421
|
+
import { useStrivacity } from '@strivacity/sdk-vue';
|
|
422
|
+
|
|
423
|
+
const router = useRouter();
|
|
424
|
+
const shortAppId = ref<string | null>(null);
|
|
425
|
+
const sessionId = ref<string | null>(null);
|
|
426
|
+
|
|
427
|
+
if (location.search !== '') {
|
|
428
|
+
const url = new URL(window.location.href);
|
|
429
|
+
shortAppId.value = url.searchParams.get('short_app_id');
|
|
430
|
+
sessionId.value = url.searchParams.get('session_id');
|
|
431
|
+
url.search = '';
|
|
432
|
+
history.replaceState({}, '', url.toString());
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const onLogin = async () => {
|
|
436
|
+
await router.push('/profile');
|
|
437
|
+
};
|
|
438
|
+
const onClose = () => {
|
|
439
|
+
location.reload();
|
|
440
|
+
};
|
|
441
|
+
const onError = (event: CustomEvent) => {
|
|
442
|
+
alert(event.detail);
|
|
443
|
+
};
|
|
444
|
+
</script>
|
|
445
|
+
|
|
446
|
+
<template>
|
|
447
|
+
<sty-notifications></sty-notifications>
|
|
448
|
+
<sty-login :shortAppId="shortAppId" :sessionId="sessionId" @close="onClose" @login="onLogin" @error="onError($event.detail)"></sty-login>
|
|
449
|
+
<sty-language-selector></sty-language-selector>
|
|
450
|
+
</template>
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
#### Callback page example
|
|
454
|
+
|
|
455
|
+
Same as the callback page example in native mode.
|
|
456
|
+
|
|
457
|
+
#### Entry page example
|
|
458
|
+
|
|
459
|
+
Same as the entry page example in native mode.
|
|
460
|
+
|
|
461
|
+
#### Profile page example
|
|
462
|
+
|
|
463
|
+
Same as the profile page example in native mode.
|
|
464
|
+
|
|
465
|
+
#### Logout page example
|
|
466
|
+
|
|
467
|
+
Same as the logout page example in native mode.
|
|
468
|
+
|
|
411
469
|
## Logging
|
|
412
470
|
|
|
413
471
|
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.
|
|
@@ -417,27 +475,23 @@ The SDK supports optional logging to help you debug authentication flows and mon
|
|
|
417
475
|
Enable the default console logger by adding the `logging` option when creating the SDK:
|
|
418
476
|
|
|
419
477
|
```js
|
|
420
|
-
import { createApp } from 'vue';
|
|
421
478
|
import { createStrivacitySDK, DefaultLogging } from '@strivacity/sdk-vue';
|
|
422
479
|
|
|
423
|
-
const app = createApp(App);
|
|
424
480
|
const sdk = createStrivacitySDK({
|
|
425
481
|
mode: 'redirect',
|
|
426
482
|
issuer: 'https://<YOUR_DOMAIN>',
|
|
427
483
|
scopes: ['openid', 'profile'],
|
|
428
484
|
clientId: '<YOUR_CLIENT_ID>',
|
|
429
485
|
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
430
|
-
logging: DefaultLogging,
|
|
486
|
+
logging: DefaultLogging,
|
|
431
487
|
});
|
|
432
|
-
|
|
433
|
-
app.use(sdk);
|
|
434
488
|
```
|
|
435
489
|
|
|
436
490
|
The default logger writes to the browser console and automatically prefixes messages with a correlation ID when available (via the `xEventId` property).
|
|
437
491
|
|
|
438
492
|
### Creating a Custom Logger
|
|
439
493
|
|
|
440
|
-
|
|
494
|
+
Implement the `SDKLogging` interface and pass your class to the `logging` option:
|
|
441
495
|
|
|
442
496
|
```typescript
|
|
443
497
|
import type { SDKLogging } from '@strivacity/sdk-vue';
|
|
@@ -446,7 +500,6 @@ export class MyLogger implements SDKLogging {
|
|
|
446
500
|
xEventId?: string;
|
|
447
501
|
|
|
448
502
|
debug(message: string): void {
|
|
449
|
-
// Send to your logging pipeline
|
|
450
503
|
console.debug(this.xEventId ? `[${this.xEventId}] ${message}` : message);
|
|
451
504
|
}
|
|
452
505
|
|
|
@@ -464,168 +517,110 @@ export class MyLogger implements SDKLogging {
|
|
|
464
517
|
}
|
|
465
518
|
```
|
|
466
519
|
|
|
467
|
-
Then register your custom logger when creating the SDK:
|
|
468
|
-
|
|
469
520
|
```js
|
|
470
521
|
import { createStrivacitySDK } from '@strivacity/sdk-vue';
|
|
471
522
|
import { MyLogger } from './logging/MyLogger';
|
|
472
523
|
|
|
473
524
|
const sdk = createStrivacitySDK({
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
scopes: ['openid', 'profile'],
|
|
477
|
-
clientId: '<YOUR_CLIENT_ID>',
|
|
478
|
-
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
479
|
-
logging: MyLogger, // Use your custom logger
|
|
525
|
+
// ...other options
|
|
526
|
+
logging: MyLogger,
|
|
480
527
|
});
|
|
481
528
|
```
|
|
482
529
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
The `SDKLogging` interface requires the following methods:
|
|
486
|
-
|
|
487
|
-
- **`debug(message: string): void`** - Log debug-level messages
|
|
488
|
-
- **`info(message: string): void`** - Log informational messages
|
|
489
|
-
- **`warn(message: string): void`** - Log warning messages
|
|
490
|
-
- **`error(message: string, error: Error): void`** - Log error messages with error objects
|
|
491
|
-
|
|
492
|
-
The optional `xEventId` property, when set by the SDK, provides a correlation ID to trace related log messages across the authentication flow.
|
|
530
|
+
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.
|
|
493
531
|
|
|
494
532
|
## API Documentation
|
|
495
533
|
|
|
496
|
-
|
|
534
|
+
### `useStrivacity` composable
|
|
497
535
|
|
|
498
536
|
```typescript
|
|
499
537
|
useStrivacity<T extends PopupContext | RedirectContext | NativeContext>(): T;
|
|
500
538
|
```
|
|
501
539
|
|
|
502
|
-
|
|
540
|
+
The composable returns a different context type depending on the `mode` configured when creating the SDK.
|
|
503
541
|
|
|
504
|
-
**
|
|
542
|
+
**Shared properties (all modes)**
|
|
505
543
|
|
|
506
|
-
- **`sdk: RedirectFlow | PopupFlow | NativeFlow`**:
|
|
507
|
-
- **`loading: Ref<boolean>`**:
|
|
508
|
-
- **`options: SDKOptions`**: The configured options
|
|
509
|
-
- **`isAuthenticated: Ref<boolean>`**:
|
|
510
|
-
- **`idTokenClaims: Ref<IdTokenClaims | null>`**: Claims from the ID token, or null if not
|
|
511
|
-
- **`accessToken: Ref<string | null>`**: The access token
|
|
512
|
-
- **`refreshToken: Ref<string | null>`**: The refresh token
|
|
513
|
-
- **`accessTokenExpired: Ref<boolean>`**:
|
|
514
|
-
- **`accessTokenExpirationDate: Ref<number | null>`**: Expiration
|
|
544
|
+
- **`sdk: RedirectFlow | PopupFlow | NativeFlow`**: The underlying SDK flow instance.
|
|
545
|
+
- **`loading: Ref<boolean>`**: `true` while the session is being initialized.
|
|
546
|
+
- **`options: SDKOptions`**: The configured SDK options.
|
|
547
|
+
- **`isAuthenticated: Ref<boolean>`**: `true` when the user has a valid session.
|
|
548
|
+
- **`idTokenClaims: Ref<IdTokenClaims | null>`**: Claims from the ID token, or `null` if not authenticated.
|
|
549
|
+
- **`accessToken: Ref<string | null>`**: The current access token.
|
|
550
|
+
- **`refreshToken: Ref<string | null>`**: The current refresh token.
|
|
551
|
+
- **`accessTokenExpired: Ref<boolean>`**: `true` when the access token has expired.
|
|
552
|
+
- **`accessTokenExpirationDate: Ref<number | null>`**: Expiration timestamp (Unix ms) of the access token.
|
|
515
553
|
|
|
516
554
|
---
|
|
517
555
|
|
|
518
556
|
**Type: `RedirectContext`**
|
|
519
557
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
- **`
|
|
523
|
-
|
|
524
|
-
- **`
|
|
525
|
-
|
|
526
|
-
- **`
|
|
527
|
-
- **`revoke(): Promise<void>`**: Revokes the current session tokens using a redirect flow.
|
|
528
|
-
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs out the user by redirecting to the identity provider.
|
|
529
|
-
- `options` (optional): Configuration options for logout.
|
|
530
|
-
- **`handleCallback(url?: string): Promise<void>`**: Handles the callback after a redirect-based authentication or token exchange.
|
|
531
|
-
- `url` (optional): The URL to handle for the callback.
|
|
558
|
+
- **`login(options?: LoginOptions): Promise<void>`**: Initiates login by redirecting to the identity provider.
|
|
559
|
+
- **`register(options?: RegisterOptions): Promise<void>`**: Initiates registration using a redirect flow.
|
|
560
|
+
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
561
|
+
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
562
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs the user out via redirect.
|
|
563
|
+
- **`handleCallback(url?: string): Promise<void>`**: Processes the authorization callback after redirect.
|
|
564
|
+
- **`entry(): Promise<Record<string, string>>`**: Processes an externally-initiated flow URL and returns the parameters needed to resume the flow (e.g. `session_id`, `short_app_id`).
|
|
532
565
|
|
|
533
566
|
---
|
|
534
567
|
|
|
535
568
|
**Type: `PopupContext`**
|
|
536
569
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
- **`
|
|
540
|
-
|
|
541
|
-
- **`
|
|
542
|
-
|
|
543
|
-
- **`
|
|
544
|
-
- **`revoke(): Promise<void>`**: Revokes the current session tokens using a popup flow.
|
|
545
|
-
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs out the user using a popup window.
|
|
546
|
-
- `options` (optional): Configuration options for logout.
|
|
547
|
-
- **`handleCallback(url?: string): Promise<void>`**: Handles the callback after a popup-based authentication or token exchange.
|
|
548
|
-
- `url` (optional): The URL to handle for the callback.
|
|
570
|
+
- **`login(options?: LoginOptions): Promise<void>`**: Initiates login using a popup window.
|
|
571
|
+
- **`register(options?: RegisterOptions): Promise<void>`**: Initiates registration using a popup.
|
|
572
|
+
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
573
|
+
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
574
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs the user out via popup.
|
|
575
|
+
- **`handleCallback(url?: string): Promise<void>`**: Processes the authorization callback.
|
|
576
|
+
- **`entry(): Promise<Record<string, string>>`**: Processes an externally-initiated flow URL and returns the parameters needed to resume the flow.
|
|
549
577
|
|
|
550
578
|
---
|
|
551
579
|
|
|
552
580
|
**Type: `NativeContext`**
|
|
553
581
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
- **`login(options?: LoginOptions): Promise<NativeFlowHandler>`**: Initiates the login process using a native flow.
|
|
557
|
-
- `options` (optional): Configuration options for login.
|
|
558
|
-
- **`register(options?: RegisterOptions): Promise<NativeFlowHandler>`**: Registers a new user using a native flow.
|
|
559
|
-
- `options` (optional): Configuration options for registration.
|
|
582
|
+
- **`login(options?: LoginOptions): Promise<NativeFlowHandler>`**: Initiates login using the native flow.
|
|
583
|
+
- **`register(options?: RegisterOptions): Promise<NativeFlowHandler>`**: Initiates registration using the native flow.
|
|
560
584
|
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
561
585
|
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
562
|
-
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs
|
|
563
|
-
|
|
564
|
-
- **`
|
|
565
|
-
- `url` (optional): The URL to handle for the callback.
|
|
566
|
-
|
|
567
|
-
#### `StyLoginRenderer` component
|
|
568
|
-
|
|
569
|
-
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.
|
|
586
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs the user out via redirect.
|
|
587
|
+
- **`handleCallback(url?: string): Promise<void>`**: Processes the authorization callback.
|
|
588
|
+
- **`entry(): Promise<Record<string, string>>`**: Processes an externally-initiated flow URL and returns the parameters needed to resume the flow.
|
|
570
589
|
|
|
571
|
-
|
|
572
|
-
StyLoginRenderer: Vue.Component<{
|
|
573
|
-
params?: NativeParams;
|
|
574
|
-
widgets?: PartialRecord<WidgetType, Vue.Component>;
|
|
575
|
-
sessionId?: string | null;
|
|
576
|
-
onLogin?: (claims?: IdTokenClaims | null) => void;
|
|
577
|
-
onFallback?: (error: FallbackError) => void;
|
|
578
|
-
onError?: (error: any) => void;
|
|
579
|
-
onGlobalMessage?: (message: string) => void;
|
|
580
|
-
onBlockReady?: ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => void;
|
|
581
|
-
}>;
|
|
582
|
-
```
|
|
590
|
+
---
|
|
583
591
|
|
|
584
|
-
|
|
592
|
+
### `StyLoginRenderer` component
|
|
585
593
|
|
|
586
|
-
|
|
594
|
+
Used in `native` mode to render the authentication UI with your own widget components.
|
|
587
595
|
|
|
588
|
-
|
|
596
|
+
**Props**
|
|
589
597
|
|
|
590
|
-
- **`
|
|
598
|
+
- **`params?: NativeParams`**: Additional parameters for the native login flow.
|
|
599
|
+
- **`widgets?: PartialRecord<WidgetType, Vue.Component>`**: Custom Vue components for each widget type used in the flow.
|
|
600
|
+
- **`sessionId?: string | null`**: Session ID for resuming an existing authentication session. Typically extracted from URL parameters when returning from an external identity provider.
|
|
591
601
|
|
|
592
602
|
**Events**
|
|
593
603
|
|
|
594
|
-
- **`@login
|
|
595
|
-
|
|
596
|
-
- **`@
|
|
604
|
+
- **`@login`**: Emitted on successful authentication. Receives `IdTokenClaims | null`.
|
|
605
|
+
- **`@fallback`**: Emitted when the native flow needs to fall back to redirect. Receives `FallbackError` with a fallback URL.
|
|
606
|
+
- **`@error`**: Emitted when an error occurs during authentication.
|
|
607
|
+
- **`@global-message`**: Emitted when the flow wants to display a global message (e.g. account lockout warning).
|
|
608
|
+
- **`@block-ready`**: Emitted on flow state transitions. Receives `{ previousState: LoginFlowState; state: LoginFlowState }`. Useful for analytics and custom logging.
|
|
597
609
|
|
|
598
|
-
|
|
610
|
+
## Vulnerability Reporting
|
|
599
611
|
|
|
600
|
-
|
|
612
|
+
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.
|
|
601
613
|
|
|
602
|
-
|
|
614
|
+
## License
|
|
603
615
|
|
|
604
|
-
|
|
616
|
+
@strivacity/sdk-vue is available under the MIT License. See the [LICENSE](https://github.com/Strivacity/sdk-js/blob/main/LICENSE) file for more info.
|
|
605
617
|
|
|
606
|
-
|
|
618
|
+
## Contributing
|
|
607
619
|
|
|
608
|
-
|
|
609
|
-
- `date`: For date input fields
|
|
610
|
-
- `input`: For text input fields
|
|
611
|
-
- `layout`: For layout containers and form structure
|
|
612
|
-
- `loading`: For loading indicators
|
|
613
|
-
- `multiSelect`: For multi-select dropdown fields
|
|
614
|
-
- `passcode`: For passcode input fields
|
|
615
|
-
- `password`: For password input fields
|
|
616
|
-
- `phone`: For phone number input fields
|
|
617
|
-
- `select`: For single-select dropdown fields
|
|
618
|
-
- `static`: For static text and display elements
|
|
619
|
-
- `submit`: For form submission buttons
|
|
620
|
-
|
|
621
|
-
Each widget component receives props specific to its type and function within the authentication flow.
|
|
622
|
-
|
|
623
|
-
## Links
|
|
624
|
-
|
|
625
|
-
- [Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/vue)
|
|
620
|
+
Please see our [contributing guide](https://github.com/Strivacity/sdk-js/blob/main/CONTRIBUTING.md).
|
|
626
621
|
|
|
627
622
|
## Migrating to v3.0
|
|
628
623
|
|
|
629
624
|
### Entry API Major Changes
|
|
630
625
|
|
|
631
|
-
Strivacity SDK's `entry()` API now returns a structured object instead of a plain string.
|
|
626
|
+
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/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { IdTokenClaims, SDKOptions } from '@strivacity/sdk-core';\nimport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\nimport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\nimport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\nimport { type App, ref } from 'vue';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';\nimport { DefaultLogging } from '@strivacity/sdk-core/utils/Logging';\nimport { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';\nimport { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';\nimport { STRIVACITY_SDK, useStrivacity } from './composables';\nimport LoginRendererComponent from './login-renderer.vue';\n\nexport * from '@strivacity/sdk-core';\nexport { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';\nexport type * from './types';\nexport type { PopupFlow, RedirectFlow, NativeFlow };\nexport { HttpClient, DefaultLogging, LocalStorage, SessionStorage, useStrivacity };\n\n/**\n * Checks if the user is authenticated.\n *\n * @returns {Promise<boolean>} A promise that resolves to `true` if the user is authenticated, otherwise `false`.\n */\nexport let isAuthenticated: () => Promise<boolean> = () => Promise.resolve(false);\n\n/**\n * Creates a Strivacity SDK plugin for Vue.\n *\n * @param {SDKOptions} options - The options used to configure the SDK.\n *\n * @returns {Plugin} A Vue plugin that can be installed in the application.\n */\nexport const createStrivacitySDK = (options: SDKOptions) => {\n\tconst sdk = initFlow(options);\n\n\tconst plugin = {\n\t\tinstall: (app: App) => {\n\t\t\tconst loadingRef = ref<boolean>(true);\n\t\t\tconst optionsRef = ref<SDKOptions>(sdk.options);\n\t\t\tconst isAuthenticatedRef = ref<boolean>(false);\n\t\t\tconst idTokenClaimsRef = ref<IdTokenClaims | null>(null);\n\t\t\tconst accessTokenRef = ref<string | null>(null);\n\t\t\tconst refreshTokenRef = ref<string | null>(null);\n\t\t\tconst accessTokenExpiredRef = ref<boolean>(true);\n\t\t\tconst accessTokenExpirationDateRef = ref<number | null>(null);\n\n\t\t\tconst updateSession = async () => {\n\t\t\t\tisAuthenticatedRef.value = await sdk.isAuthenticated;\n\t\t\t\tidTokenClaimsRef.value = sdk.idTokenClaims || null;\n\t\t\t\taccessTokenRef.value = sdk.accessToken || null;\n\t\t\t\trefreshTokenRef.value = sdk.refreshToken || null;\n\t\t\t\taccessTokenExpiredRef.value = sdk.accessTokenExpired;\n\t\t\t\taccessTokenExpirationDateRef.value = sdk.accessTokenExpirationDate || null;\n\n\t\t\t\tif (loadingRef.value) {\n\t\t\t\t\tloadingRef.value = false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tisAuthenticated = () => sdk.isAuthenticated;\n\n\t\t\tsdk.subscribeToEvent('init', updateSession);\n\t\t\tsdk.subscribeToEvent('loggedIn', updateSession);\n\t\t\tsdk.subscribeToEvent('sessionLoaded', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession);\n\t\t\tsdk.subscribeToEvent('logoutInitiated', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevoked', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession);\n\n\t\t\tapp.component('StyLoginRenderer', LoginRendererComponent);\n\t\t\tapp.provide(STRIVACITY_SDK, {\n\t\t\t\tsdk: sdk,\n\t\t\t\tloading: loadingRef,\n\t\t\t\toptions: optionsRef,\n\t\t\t\tisAuthenticated: isAuthenticatedRef,\n\t\t\t\tidTokenClaims: idTokenClaimsRef,\n\t\t\t\taccessToken: accessTokenRef,\n\t\t\t\trefreshToken: refreshTokenRef,\n\t\t\t\taccessTokenExpired: accessTokenExpiredRef,\n\t\t\t\taccessTokenExpirationDate: accessTokenExpirationDateRef,\n\n\t\t\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.login(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.login(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.register(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.register(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tentry: async (url?: string) => {\n\t\t\t\t\treturn await sdk.entry(url);\n\t\t\t\t},\n\t\t\t\trefresh: async () => {\n\t\t\t\t\tawait sdk.refresh();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\trevoke: async () => {\n\t\t\t\t\tawait sdk.revoke();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\t\t\tawait sdk.logout(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\t\t\tawait sdk.handleCallback(url);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\n\treturn plugin;\n};\n"],"names":["isAuthenticated","createStrivacitySDK","options","sdk","initFlow","app","loadingRef","ref","optionsRef","isAuthenticatedRef","idTokenClaimsRef","accessTokenRef","refreshTokenRef","accessTokenExpiredRef","accessTokenExpirationDateRef","updateSession","LoginRendererComponent","STRIVACITY_SDK","url"],"mappings":"2iBAwBWA,QAAAA,gBAA0C,IAAM,QAAQ,QAAQ,EAAK,EASzE,MAAMC,EAAuBC,GAAwB,CAC3D,MAAMC,EAAMC,EAAAA,SAASF,CAAO,EAwF5B,MAtFe,CACd,QAAUG,GAAa,CACtB,MAAMC,EAAaC,EAAAA,IAAa,EAAI,EAC9BC,EAAaD,EAAAA,IAAgBJ,EAAI,OAAO,EACxCM,EAAqBF,EAAAA,IAAa,EAAK,EACvCG,EAAmBH,EAAAA,IAA0B,IAAI,EACjDI,EAAiBJ,EAAAA,IAAmB,IAAI,EACxCK,EAAkBL,EAAAA,IAAmB,IAAI,EACzCM,EAAwBN,EAAAA,IAAa,EAAI,EACzCO,EAA+BP,EAAAA,IAAmB,IAAI,EAEtDQ,EAAgB,SAAY,CACjCN,EAAmB,MAAQ,MAAMN,EAAI,gBACrCO,EAAiB,MAAQP,EAAI,eAAiB,KAC9CQ,EAAe,MAAQR,EAAI,aAAe,KAC1CS,EAAgB,MAAQT,EAAI,cAAgB,KAC5CU,EAAsB,MAAQV,EAAI,mBAClCW,EAA6B,MAAQX,EAAI,2BAA6B,KAElEG,EAAW,QACdA,EAAW,MAAQ,GAErB,EAEAN,QAAAA,gBAAkB,IAAMG,EAAI,gBAE5BA,EAAI,iBAAiB,OAAQY,CAAa,EAC1CZ,EAAI,iBAAiB,WAAYY,CAAa,EAC9CZ,EAAI,iBAAiB,gBAAiBY,CAAa,EACnDZ,EAAI,iBAAiB,iBAAkBY,CAAa,EACpDZ,EAAI,iBAAiB,qBAAsBY,CAAa,EACxDZ,EAAI,iBAAiB,kBAAmBY,CAAa,EACrDZ,EAAI,iBAAiB,eAAgBY,CAAa,EAClDZ,EAAI,iBAAiB,oBAAqBY,CAAa,EAEvDV,EAAI,UAAU,mBAAoBW,WAAsB,EACxDX,EAAI,QAAQY,iBAAgB,CAC3B,IAAAd,EACA,QAASG,EACT,QAASE,EACT,gBAAiBC,EACjB,cAAeC,EACf,YAAaC,EACb,aAAcC,EACd,mBAAoBC,EACpB,0BAA2BC,EAE3B,MAAO,MAAOZ,GAA8F,CAC3G,GAAIC,EAAI,QAAQ,OAAS,SACxB,OAAOA,EAAI,MAAMD,CAAO,EAGzB,MAAMC,EAAI,MAAMD,CAAO,EACvB,MAAMa,EAAA,CACP,EACA,SAAU,MAAOb,GAAuG,CACvH,GAAIC,EAAI,QAAQ,OAAS,SACxB,OAAOA,EAAI,SAASD,CAAO,EAG5B,MAAMC,EAAI,SAASD,CAAO,EAC1B,MAAMa,EAAA,CACP,EACA,MAAO,MAAOG,GACN,MAAMf,EAAI,MAAMe,CAAG,EAE3B,QAAS,SAAY,CACpB,MAAMf,EAAI,QAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,SAAY,CACnB,MAAMZ,EAAI,OAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,MAAOb,GAA0E,CACxF,MAAMC,EAAI,OAAOD,CAAO,EACxB,MAAMa,EAAA,CACP,EACA,eAAgB,MAAOG,GAAqH,CAC3I,MAAMf,EAAI,eAAee,CAAG,EAC5B,MAAMH,EAAA,CACP,CAAA,CACA,CACF,CAAA,CAIF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { IdTokenClaims, SDKOptions } from '@strivacity/sdk-core';\nimport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\nimport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\nimport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\nimport { type App, ref } from 'vue';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';\nimport { DefaultLogging } from '@strivacity/sdk-core/utils/Logging';\nimport { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';\nimport { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';\nimport { STRIVACITY_SDK, useStrivacity } from './composables';\nimport LoginRendererComponent from './login-renderer.vue';\n\nexport * from '@strivacity/sdk-core';\nexport { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';\nexport type * from './types';\nexport type { PopupFlow, RedirectFlow, NativeFlow };\nexport { HttpClient, DefaultLogging, LocalStorage, SessionStorage, useStrivacity };\n\n/**\n * Checks if the user is authenticated.\n *\n * @returns {Promise<boolean>} A promise that resolves to `true` if the user is authenticated, otherwise `false`.\n */\nexport let isAuthenticated: () => Promise<boolean> = () => Promise.resolve(false);\n\n/**\n * Creates a Strivacity SDK plugin for Vue.\n *\n * @param {SDKOptions} options - The options used to configure the SDK.\n *\n * @returns {Plugin} A Vue plugin that can be installed in the application.\n */\nexport const createStrivacitySDK = (options: SDKOptions) => {\n\tconst sdk = initFlow(options) as NativeFlow | PopupFlow | RedirectFlow;\n\n\tconst plugin = {\n\t\tinstall: (app: App) => {\n\t\t\tconst loadingRef = ref<boolean>(true);\n\t\t\tconst optionsRef = ref<SDKOptions>(sdk.options);\n\t\t\tconst isAuthenticatedRef = ref<boolean>(false);\n\t\t\tconst idTokenClaimsRef = ref<IdTokenClaims | null>(null);\n\t\t\tconst accessTokenRef = ref<string | null>(null);\n\t\t\tconst refreshTokenRef = ref<string | null>(null);\n\t\t\tconst accessTokenExpiredRef = ref<boolean>(true);\n\t\t\tconst accessTokenExpirationDateRef = ref<number | null>(null);\n\n\t\t\tconst updateSession = async () => {\n\t\t\t\tisAuthenticatedRef.value = await sdk.isAuthenticated;\n\t\t\t\tidTokenClaimsRef.value = sdk.idTokenClaims || null;\n\t\t\t\taccessTokenRef.value = sdk.accessToken || null;\n\t\t\t\trefreshTokenRef.value = sdk.refreshToken || null;\n\t\t\t\taccessTokenExpiredRef.value = sdk.accessTokenExpired;\n\t\t\t\taccessTokenExpirationDateRef.value = sdk.accessTokenExpirationDate || null;\n\n\t\t\t\tif (loadingRef.value) {\n\t\t\t\t\tloadingRef.value = false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tisAuthenticated = () => sdk.isAuthenticated;\n\n\t\t\tsdk.subscribeToEvent('init', updateSession);\n\t\t\tsdk.subscribeToEvent('loggedIn', updateSession);\n\t\t\tsdk.subscribeToEvent('sessionLoaded', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession);\n\t\t\tsdk.subscribeToEvent('logoutInitiated', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevoked', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession);\n\n\t\t\tapp.component('StyLoginRenderer', LoginRendererComponent);\n\t\t\tapp.provide(STRIVACITY_SDK, {\n\t\t\t\tsdk: sdk,\n\t\t\t\tloading: loadingRef,\n\t\t\t\toptions: optionsRef,\n\t\t\t\tisAuthenticated: isAuthenticatedRef,\n\t\t\t\tidTokenClaims: idTokenClaimsRef,\n\t\t\t\taccessToken: accessTokenRef,\n\t\t\t\trefreshToken: refreshTokenRef,\n\t\t\t\taccessTokenExpired: accessTokenExpiredRef,\n\t\t\t\taccessTokenExpirationDate: accessTokenExpirationDateRef,\n\n\t\t\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.login(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.login(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.register(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.register(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tentry: async (url?: string) => {\n\t\t\t\t\treturn await sdk.entry(url);\n\t\t\t\t},\n\t\t\t\trefresh: async () => {\n\t\t\t\t\tawait sdk.refresh();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\trevoke: async () => {\n\t\t\t\t\tawait sdk.revoke();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\t\t\tawait sdk.logout(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\t\t\tawait sdk.handleCallback(url);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\n\treturn plugin;\n};\n"],"names":["isAuthenticated","createStrivacitySDK","options","sdk","initFlow","app","loadingRef","ref","optionsRef","isAuthenticatedRef","idTokenClaimsRef","accessTokenRef","refreshTokenRef","accessTokenExpiredRef","accessTokenExpirationDateRef","updateSession","LoginRendererComponent","STRIVACITY_SDK","url"],"mappings":"2iBAwBWA,QAAAA,gBAA0C,IAAM,QAAQ,QAAQ,EAAK,EASzE,MAAMC,EAAuBC,GAAwB,CAC3D,MAAMC,EAAMC,EAAAA,SAASF,CAAO,EAwF5B,MAtFe,CACd,QAAUG,GAAa,CACtB,MAAMC,EAAaC,EAAAA,IAAa,EAAI,EAC9BC,EAAaD,EAAAA,IAAgBJ,EAAI,OAAO,EACxCM,EAAqBF,EAAAA,IAAa,EAAK,EACvCG,EAAmBH,EAAAA,IAA0B,IAAI,EACjDI,EAAiBJ,EAAAA,IAAmB,IAAI,EACxCK,EAAkBL,EAAAA,IAAmB,IAAI,EACzCM,EAAwBN,EAAAA,IAAa,EAAI,EACzCO,EAA+BP,EAAAA,IAAmB,IAAI,EAEtDQ,EAAgB,SAAY,CACjCN,EAAmB,MAAQ,MAAMN,EAAI,gBACrCO,EAAiB,MAAQP,EAAI,eAAiB,KAC9CQ,EAAe,MAAQR,EAAI,aAAe,KAC1CS,EAAgB,MAAQT,EAAI,cAAgB,KAC5CU,EAAsB,MAAQV,EAAI,mBAClCW,EAA6B,MAAQX,EAAI,2BAA6B,KAElEG,EAAW,QACdA,EAAW,MAAQ,GAErB,EAEAN,QAAAA,gBAAkB,IAAMG,EAAI,gBAE5BA,EAAI,iBAAiB,OAAQY,CAAa,EAC1CZ,EAAI,iBAAiB,WAAYY,CAAa,EAC9CZ,EAAI,iBAAiB,gBAAiBY,CAAa,EACnDZ,EAAI,iBAAiB,iBAAkBY,CAAa,EACpDZ,EAAI,iBAAiB,qBAAsBY,CAAa,EACxDZ,EAAI,iBAAiB,kBAAmBY,CAAa,EACrDZ,EAAI,iBAAiB,eAAgBY,CAAa,EAClDZ,EAAI,iBAAiB,oBAAqBY,CAAa,EAEvDV,EAAI,UAAU,mBAAoBW,WAAsB,EACxDX,EAAI,QAAQY,iBAAgB,CAC3B,IAAAd,EACA,QAASG,EACT,QAASE,EACT,gBAAiBC,EACjB,cAAeC,EACf,YAAaC,EACb,aAAcC,EACd,mBAAoBC,EACpB,0BAA2BC,EAE3B,MAAO,MAAOZ,GAA8F,CAC3G,GAAIC,EAAI,QAAQ,OAAS,SACxB,OAAOA,EAAI,MAAMD,CAAO,EAGzB,MAAMC,EAAI,MAAMD,CAAO,EACvB,MAAMa,EAAA,CACP,EACA,SAAU,MAAOb,GAAuG,CACvH,GAAIC,EAAI,QAAQ,OAAS,SACxB,OAAOA,EAAI,SAASD,CAAO,EAG5B,MAAMC,EAAI,SAASD,CAAO,EAC1B,MAAMa,EAAA,CACP,EACA,MAAO,MAAOG,GACN,MAAMf,EAAI,MAAMe,CAAG,EAE3B,QAAS,SAAY,CACpB,MAAMf,EAAI,QAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,SAAY,CACnB,MAAMZ,EAAI,OAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,MAAOb,GAA0E,CACxF,MAAMC,EAAI,OAAOD,CAAO,EACxB,MAAMa,EAAA,CACP,EACA,eAAgB,MAAOG,GAAqH,CAC3I,MAAMf,EAAI,eAAee,CAAG,EAC5B,MAAMH,EAAA,CACP,CAAA,CACA,CACF,CAAA,CAIF"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { IdTokenClaims, SDKOptions } from '@strivacity/sdk-core';\nimport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\nimport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\nimport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\nimport { type App, ref } from 'vue';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';\nimport { DefaultLogging } from '@strivacity/sdk-core/utils/Logging';\nimport { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';\nimport { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';\nimport { STRIVACITY_SDK, useStrivacity } from './composables';\nimport LoginRendererComponent from './login-renderer.vue';\n\nexport * from '@strivacity/sdk-core';\nexport { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';\nexport type * from './types';\nexport type { PopupFlow, RedirectFlow, NativeFlow };\nexport { HttpClient, DefaultLogging, LocalStorage, SessionStorage, useStrivacity };\n\n/**\n * Checks if the user is authenticated.\n *\n * @returns {Promise<boolean>} A promise that resolves to `true` if the user is authenticated, otherwise `false`.\n */\nexport let isAuthenticated: () => Promise<boolean> = () => Promise.resolve(false);\n\n/**\n * Creates a Strivacity SDK plugin for Vue.\n *\n * @param {SDKOptions} options - The options used to configure the SDK.\n *\n * @returns {Plugin} A Vue plugin that can be installed in the application.\n */\nexport const createStrivacitySDK = (options: SDKOptions) => {\n\tconst sdk = initFlow(options);\n\n\tconst plugin = {\n\t\tinstall: (app: App) => {\n\t\t\tconst loadingRef = ref<boolean>(true);\n\t\t\tconst optionsRef = ref<SDKOptions>(sdk.options);\n\t\t\tconst isAuthenticatedRef = ref<boolean>(false);\n\t\t\tconst idTokenClaimsRef = ref<IdTokenClaims | null>(null);\n\t\t\tconst accessTokenRef = ref<string | null>(null);\n\t\t\tconst refreshTokenRef = ref<string | null>(null);\n\t\t\tconst accessTokenExpiredRef = ref<boolean>(true);\n\t\t\tconst accessTokenExpirationDateRef = ref<number | null>(null);\n\n\t\t\tconst updateSession = async () => {\n\t\t\t\tisAuthenticatedRef.value = await sdk.isAuthenticated;\n\t\t\t\tidTokenClaimsRef.value = sdk.idTokenClaims || null;\n\t\t\t\taccessTokenRef.value = sdk.accessToken || null;\n\t\t\t\trefreshTokenRef.value = sdk.refreshToken || null;\n\t\t\t\taccessTokenExpiredRef.value = sdk.accessTokenExpired;\n\t\t\t\taccessTokenExpirationDateRef.value = sdk.accessTokenExpirationDate || null;\n\n\t\t\t\tif (loadingRef.value) {\n\t\t\t\t\tloadingRef.value = false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tisAuthenticated = () => sdk.isAuthenticated;\n\n\t\t\tsdk.subscribeToEvent('init', updateSession);\n\t\t\tsdk.subscribeToEvent('loggedIn', updateSession);\n\t\t\tsdk.subscribeToEvent('sessionLoaded', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession);\n\t\t\tsdk.subscribeToEvent('logoutInitiated', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevoked', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession);\n\n\t\t\tapp.component('StyLoginRenderer', LoginRendererComponent);\n\t\t\tapp.provide(STRIVACITY_SDK, {\n\t\t\t\tsdk: sdk,\n\t\t\t\tloading: loadingRef,\n\t\t\t\toptions: optionsRef,\n\t\t\t\tisAuthenticated: isAuthenticatedRef,\n\t\t\t\tidTokenClaims: idTokenClaimsRef,\n\t\t\t\taccessToken: accessTokenRef,\n\t\t\t\trefreshToken: refreshTokenRef,\n\t\t\t\taccessTokenExpired: accessTokenExpiredRef,\n\t\t\t\taccessTokenExpirationDate: accessTokenExpirationDateRef,\n\n\t\t\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.login(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.login(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.register(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.register(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tentry: async (url?: string) => {\n\t\t\t\t\treturn await sdk.entry(url);\n\t\t\t\t},\n\t\t\t\trefresh: async () => {\n\t\t\t\t\tawait sdk.refresh();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\trevoke: async () => {\n\t\t\t\t\tawait sdk.revoke();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\t\t\tawait sdk.logout(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\t\t\tawait sdk.handleCallback(url);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\n\treturn plugin;\n};\n"],"names":["isAuthenticated","createStrivacitySDK","options","sdk","initFlow","app","loadingRef","ref","optionsRef","isAuthenticatedRef","idTokenClaimsRef","accessTokenRef","refreshTokenRef","accessTokenExpiredRef","accessTokenExpirationDateRef","updateSession","LoginRendererComponent","STRIVACITY_SDK","url"],"mappings":"2sBAwBO,IAAIA,EAA0C,IAAM,QAAQ,QAAQ,EAAK,EASzE,MAAMC,EAAuBC,GAAwB,CAC3D,MAAMC,EAAMC,EAASF,CAAO,EAwF5B,MAtFe,CACd,QAAUG,GAAa,CACtB,MAAMC,EAAaC,EAAa,EAAI,EAC9BC,EAAaD,EAAgBJ,EAAI,OAAO,EACxCM,EAAqBF,EAAa,EAAK,EACvCG,EAAmBH,EAA0B,IAAI,EACjDI,EAAiBJ,EAAmB,IAAI,EACxCK,EAAkBL,EAAmB,IAAI,EACzCM,EAAwBN,EAAa,EAAI,EACzCO,EAA+BP,EAAmB,IAAI,EAEtDQ,EAAgB,SAAY,CACjCN,EAAmB,MAAQ,MAAMN,EAAI,gBACrCO,EAAiB,MAAQP,EAAI,eAAiB,KAC9CQ,EAAe,MAAQR,EAAI,aAAe,KAC1CS,EAAgB,MAAQT,EAAI,cAAgB,KAC5CU,EAAsB,MAAQV,EAAI,mBAClCW,EAA6B,MAAQX,EAAI,2BAA6B,KAElEG,EAAW,QACdA,EAAW,MAAQ,GAErB,EAEAN,EAAkB,IAAMG,EAAI,gBAE5BA,EAAI,iBAAiB,OAAQY,CAAa,EAC1CZ,EAAI,iBAAiB,WAAYY,CAAa,EAC9CZ,EAAI,iBAAiB,gBAAiBY,CAAa,EACnDZ,EAAI,iBAAiB,iBAAkBY,CAAa,EACpDZ,EAAI,iBAAiB,qBAAsBY,CAAa,EACxDZ,EAAI,iBAAiB,kBAAmBY,CAAa,EACrDZ,EAAI,iBAAiB,eAAgBY,CAAa,EAClDZ,EAAI,iBAAiB,oBAAqBY,CAAa,EAEvDV,EAAI,UAAU,mBAAoBW,CAAsB,EACxDX,EAAI,QAAQY,EAAgB,CAC3B,IAAAd,EACA,QAASG,EACT,QAASE,EACT,gBAAiBC,EACjB,cAAeC,EACf,YAAaC,EACb,aAAcC,EACd,mBAAoBC,EACpB,0BAA2BC,EAE3B,MAAO,MAAOZ,GAA8F,CAC3G,GAAIC,EAAI,QAAQ,OAAS,SACxB,OAAOA,EAAI,MAAMD,CAAO,EAGzB,MAAMC,EAAI,MAAMD,CAAO,EACvB,MAAMa,EAAA,CACP,EACA,SAAU,MAAOb,GAAuG,CACvH,GAAIC,EAAI,QAAQ,OAAS,SACxB,OAAOA,EAAI,SAASD,CAAO,EAG5B,MAAMC,EAAI,SAASD,CAAO,EAC1B,MAAMa,EAAA,CACP,EACA,MAAO,MAAOG,GACN,MAAMf,EAAI,MAAMe,CAAG,EAE3B,QAAS,SAAY,CACpB,MAAMf,EAAI,QAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,SAAY,CACnB,MAAMZ,EAAI,OAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,MAAOb,GAA0E,CACxF,MAAMC,EAAI,OAAOD,CAAO,EACxB,MAAMa,EAAA,CACP,EACA,eAAgB,MAAOG,GAAqH,CAC3I,MAAMf,EAAI,eAAee,CAAG,EAC5B,MAAMH,EAAA,CACP,CAAA,CACA,CACF,CAAA,CAIF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { IdTokenClaims, SDKOptions } from '@strivacity/sdk-core';\nimport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\nimport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\nimport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\nimport { type App, ref } from 'vue';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';\nimport { DefaultLogging } from '@strivacity/sdk-core/utils/Logging';\nimport { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';\nimport { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';\nimport { STRIVACITY_SDK, useStrivacity } from './composables';\nimport LoginRendererComponent from './login-renderer.vue';\n\nexport * from '@strivacity/sdk-core';\nexport { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';\nexport type * from './types';\nexport type { PopupFlow, RedirectFlow, NativeFlow };\nexport { HttpClient, DefaultLogging, LocalStorage, SessionStorage, useStrivacity };\n\n/**\n * Checks if the user is authenticated.\n *\n * @returns {Promise<boolean>} A promise that resolves to `true` if the user is authenticated, otherwise `false`.\n */\nexport let isAuthenticated: () => Promise<boolean> = () => Promise.resolve(false);\n\n/**\n * Creates a Strivacity SDK plugin for Vue.\n *\n * @param {SDKOptions} options - The options used to configure the SDK.\n *\n * @returns {Plugin} A Vue plugin that can be installed in the application.\n */\nexport const createStrivacitySDK = (options: SDKOptions) => {\n\tconst sdk = initFlow(options) as NativeFlow | PopupFlow | RedirectFlow;\n\n\tconst plugin = {\n\t\tinstall: (app: App) => {\n\t\t\tconst loadingRef = ref<boolean>(true);\n\t\t\tconst optionsRef = ref<SDKOptions>(sdk.options);\n\t\t\tconst isAuthenticatedRef = ref<boolean>(false);\n\t\t\tconst idTokenClaimsRef = ref<IdTokenClaims | null>(null);\n\t\t\tconst accessTokenRef = ref<string | null>(null);\n\t\t\tconst refreshTokenRef = ref<string | null>(null);\n\t\t\tconst accessTokenExpiredRef = ref<boolean>(true);\n\t\t\tconst accessTokenExpirationDateRef = ref<number | null>(null);\n\n\t\t\tconst updateSession = async () => {\n\t\t\t\tisAuthenticatedRef.value = await sdk.isAuthenticated;\n\t\t\t\tidTokenClaimsRef.value = sdk.idTokenClaims || null;\n\t\t\t\taccessTokenRef.value = sdk.accessToken || null;\n\t\t\t\trefreshTokenRef.value = sdk.refreshToken || null;\n\t\t\t\taccessTokenExpiredRef.value = sdk.accessTokenExpired;\n\t\t\t\taccessTokenExpirationDateRef.value = sdk.accessTokenExpirationDate || null;\n\n\t\t\t\tif (loadingRef.value) {\n\t\t\t\t\tloadingRef.value = false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tisAuthenticated = () => sdk.isAuthenticated;\n\n\t\t\tsdk.subscribeToEvent('init', updateSession);\n\t\t\tsdk.subscribeToEvent('loggedIn', updateSession);\n\t\t\tsdk.subscribeToEvent('sessionLoaded', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession);\n\t\t\tsdk.subscribeToEvent('logoutInitiated', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevoked', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession);\n\n\t\t\tapp.component('StyLoginRenderer', LoginRendererComponent);\n\t\t\tapp.provide(STRIVACITY_SDK, {\n\t\t\t\tsdk: sdk,\n\t\t\t\tloading: loadingRef,\n\t\t\t\toptions: optionsRef,\n\t\t\t\tisAuthenticated: isAuthenticatedRef,\n\t\t\t\tidTokenClaims: idTokenClaimsRef,\n\t\t\t\taccessToken: accessTokenRef,\n\t\t\t\trefreshToken: refreshTokenRef,\n\t\t\t\taccessTokenExpired: accessTokenExpiredRef,\n\t\t\t\taccessTokenExpirationDate: accessTokenExpirationDateRef,\n\n\t\t\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.login(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.login(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.register(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.register(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tentry: async (url?: string) => {\n\t\t\t\t\treturn await sdk.entry(url);\n\t\t\t\t},\n\t\t\t\trefresh: async () => {\n\t\t\t\t\tawait sdk.refresh();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\trevoke: async () => {\n\t\t\t\t\tawait sdk.revoke();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\t\t\tawait sdk.logout(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\t\t\tawait sdk.handleCallback(url);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\n\treturn plugin;\n};\n"],"names":["isAuthenticated","createStrivacitySDK","options","sdk","initFlow","app","loadingRef","ref","optionsRef","isAuthenticatedRef","idTokenClaimsRef","accessTokenRef","refreshTokenRef","accessTokenExpiredRef","accessTokenExpirationDateRef","updateSession","LoginRendererComponent","STRIVACITY_SDK","url"],"mappings":"2sBAwBO,IAAIA,EAA0C,IAAM,QAAQ,QAAQ,EAAK,EASzE,MAAMC,EAAuBC,GAAwB,CAC3D,MAAMC,EAAMC,EAASF,CAAO,EAwF5B,MAtFe,CACd,QAAUG,GAAa,CACtB,MAAMC,EAAaC,EAAa,EAAI,EAC9BC,EAAaD,EAAgBJ,EAAI,OAAO,EACxCM,EAAqBF,EAAa,EAAK,EACvCG,EAAmBH,EAA0B,IAAI,EACjDI,EAAiBJ,EAAmB,IAAI,EACxCK,EAAkBL,EAAmB,IAAI,EACzCM,EAAwBN,EAAa,EAAI,EACzCO,EAA+BP,EAAmB,IAAI,EAEtDQ,EAAgB,SAAY,CACjCN,EAAmB,MAAQ,MAAMN,EAAI,gBACrCO,EAAiB,MAAQP,EAAI,eAAiB,KAC9CQ,EAAe,MAAQR,EAAI,aAAe,KAC1CS,EAAgB,MAAQT,EAAI,cAAgB,KAC5CU,EAAsB,MAAQV,EAAI,mBAClCW,EAA6B,MAAQX,EAAI,2BAA6B,KAElEG,EAAW,QACdA,EAAW,MAAQ,GAErB,EAEAN,EAAkB,IAAMG,EAAI,gBAE5BA,EAAI,iBAAiB,OAAQY,CAAa,EAC1CZ,EAAI,iBAAiB,WAAYY,CAAa,EAC9CZ,EAAI,iBAAiB,gBAAiBY,CAAa,EACnDZ,EAAI,iBAAiB,iBAAkBY,CAAa,EACpDZ,EAAI,iBAAiB,qBAAsBY,CAAa,EACxDZ,EAAI,iBAAiB,kBAAmBY,CAAa,EACrDZ,EAAI,iBAAiB,eAAgBY,CAAa,EAClDZ,EAAI,iBAAiB,oBAAqBY,CAAa,EAEvDV,EAAI,UAAU,mBAAoBW,CAAsB,EACxDX,EAAI,QAAQY,EAAgB,CAC3B,IAAAd,EACA,QAASG,EACT,QAASE,EACT,gBAAiBC,EACjB,cAAeC,EACf,YAAaC,EACb,aAAcC,EACd,mBAAoBC,EACpB,0BAA2BC,EAE3B,MAAO,MAAOZ,GAA8F,CAC3G,GAAIC,EAAI,QAAQ,OAAS,SACxB,OAAOA,EAAI,MAAMD,CAAO,EAGzB,MAAMC,EAAI,MAAMD,CAAO,EACvB,MAAMa,EAAA,CACP,EACA,SAAU,MAAOb,GAAuG,CACvH,GAAIC,EAAI,QAAQ,OAAS,SACxB,OAAOA,EAAI,SAASD,CAAO,EAG5B,MAAMC,EAAI,SAASD,CAAO,EAC1B,MAAMa,EAAA,CACP,EACA,MAAO,MAAOG,GACN,MAAMf,EAAI,MAAMe,CAAG,EAE3B,QAAS,SAAY,CACpB,MAAMf,EAAI,QAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,SAAY,CACnB,MAAMZ,EAAI,OAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,MAAOb,GAA0E,CACxF,MAAMC,EAAI,OAAOD,CAAO,EACxB,MAAMa,EAAA,CACP,EACA,eAAgB,MAAOG,GAAqH,CAC3I,MAAMf,EAAI,eAAee,CAAG,EAC5B,MAAMH,EAAA,CACP,CAAA,CACA,CACF,CAAA,CAIF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strivacity/sdk-vue",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Strivacity Vue.js 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
|
"vue": ">=3"
|