@strivacity/sdk-svelte 2.1.2
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 +5 -0
- package/LICENSE +21 -0
- package/README.md +542 -0
- package/dist/AuthProvider.cjs +2 -0
- package/dist/AuthProvider.cjs.map +1 -0
- package/dist/AuthProvider.mjs +2 -0
- package/dist/AuthProvider.mjs.map +1 -0
- package/dist/AuthProvider.svelte.d.ts +1 -0
- package/dist/LoginRenderer.cjs +2 -0
- package/dist/LoginRenderer.cjs.map +1 -0
- package/dist/LoginRenderer.mjs +2 -0
- package/dist/LoginRenderer.mjs.map +1 -0
- package/dist/LoginRenderer.svelte.d.ts +1 -0
- package/dist/composables.cjs +2 -0
- package/dist/composables.cjs.map +1 -0
- package/dist/composables.d.ts +12 -0
- package/dist/composables.mjs +2 -0
- package/dist/composables.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +181 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +27 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Strivacity Inc. <opensource@strivacity.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
# Strivacity SDK for Svelte
|
|
2
|
+
|
|
3
|
+
Svelte SDK for integrating with Strivacity Identity Platform.
|
|
4
|
+
|
|
5
|
+
> **The SDK supports Svelte version 4 and above**
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @strivacity/sdk-svelte
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
This SDK supports three authentication modes: **redirect** (default), **popup**, and **native**. Each mode provides a different user experience for authentication flows.
|
|
16
|
+
|
|
17
|
+
### Adding the SDK to your main Svelte application
|
|
18
|
+
|
|
19
|
+
Wrap your application with the `StyAuthProvider` component to provide authentication context to all child components:
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { StyAuthProvider, type SDKOptions } from '@strivacity/sdk-svelte';
|
|
24
|
+
import Router from './Router.svelte';
|
|
25
|
+
|
|
26
|
+
const options: SDKOptions = {
|
|
27
|
+
mode: 'redirect', // or 'popup' or 'native'
|
|
28
|
+
issuer: 'https://<YOUR_DOMAIN>',
|
|
29
|
+
scopes: ['openid', 'profile'],
|
|
30
|
+
clientId: '<YOUR_CLIENT_ID>',
|
|
31
|
+
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
32
|
+
};
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<StyAuthProvider {options}>
|
|
36
|
+
<Router />
|
|
37
|
+
</StyAuthProvider>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Redirect mode (default)
|
|
41
|
+
|
|
42
|
+
In redirect mode, users are redirected to the identity provider's login page and then back to your application after authentication.
|
|
43
|
+
|
|
44
|
+
##### Login page example
|
|
45
|
+
|
|
46
|
+
```svelte
|
|
47
|
+
<script lang="ts">
|
|
48
|
+
import { onMount } from 'svelte';
|
|
49
|
+
import { useStrivacity, type RedirectContext } from '@strivacity/sdk-svelte';
|
|
50
|
+
|
|
51
|
+
const { login } = useStrivacity<RedirectContext>();
|
|
52
|
+
|
|
53
|
+
onMount(() => {
|
|
54
|
+
login();
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
##### Callback page example
|
|
60
|
+
|
|
61
|
+
```svelte
|
|
62
|
+
<script lang="ts">
|
|
63
|
+
import { onMount } from 'svelte';
|
|
64
|
+
import { goto } from '$app/navigation';
|
|
65
|
+
import { useStrivacity, type RedirectContext } from '@strivacity/sdk-svelte';
|
|
66
|
+
|
|
67
|
+
const { handleCallback } = useStrivacity<RedirectContext>();
|
|
68
|
+
|
|
69
|
+
onMount(async () => {
|
|
70
|
+
try {
|
|
71
|
+
await handleCallback();
|
|
72
|
+
await goto('/profile');
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('Error during callback handling:', error);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<h1>Logging in...</h1>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
##### Profile page example
|
|
83
|
+
|
|
84
|
+
```svelte
|
|
85
|
+
<script lang="ts">
|
|
86
|
+
import { useStrivacity, type RedirectContext } from '@strivacity/sdk-svelte';
|
|
87
|
+
import { goto } from '$app/navigation';
|
|
88
|
+
|
|
89
|
+
const { isAuthenticated, idTokenClaims, logout } = useStrivacity<RedirectContext>();
|
|
90
|
+
|
|
91
|
+
async function handleLogout() {
|
|
92
|
+
await logout();
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
{#if $isAuthenticated}
|
|
97
|
+
<h1>Welcome, {$idTokenClaims?.name || 'User'}</h1>
|
|
98
|
+
<button onclick={handleLogout}>Logout</button>
|
|
99
|
+
{:else}
|
|
100
|
+
<p>Not authenticated</p>
|
|
101
|
+
{/if}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
##### Logout page example
|
|
105
|
+
|
|
106
|
+
```svelte
|
|
107
|
+
<script lang="ts">
|
|
108
|
+
import { onMount } from 'svelte';
|
|
109
|
+
import { useStrivacity, type RedirectContext } from '@strivacity/sdk-svelte';
|
|
110
|
+
|
|
111
|
+
const { logout } = useStrivacity<RedirectContext>();
|
|
112
|
+
|
|
113
|
+
onMount(() => {
|
|
114
|
+
logout();
|
|
115
|
+
});
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<h1>Logging out...</h1>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Popup mode
|
|
122
|
+
|
|
123
|
+
In popup mode, authentication happens in a popup window, allowing users to stay on the same page.
|
|
124
|
+
|
|
125
|
+
##### Login page example
|
|
126
|
+
|
|
127
|
+
```svelte
|
|
128
|
+
<script lang="ts">
|
|
129
|
+
import { useStrivacity, type PopupContext } from '@strivacity/sdk-svelte';
|
|
130
|
+
import { goto } from '$app/navigation';
|
|
131
|
+
|
|
132
|
+
const { login } = useStrivacity<PopupContext>();
|
|
133
|
+
|
|
134
|
+
async function handleLogin() {
|
|
135
|
+
try {
|
|
136
|
+
await login();
|
|
137
|
+
await goto('/profile');
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error('Login error:', error);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<button onclick={handleLogin}>Login</button>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
##### Callback page example
|
|
148
|
+
|
|
149
|
+
Same as the callback page example in redirect mode.
|
|
150
|
+
|
|
151
|
+
##### Profile page example
|
|
152
|
+
|
|
153
|
+
Same as the profile page example in redirect mode.
|
|
154
|
+
|
|
155
|
+
##### Logout page example
|
|
156
|
+
|
|
157
|
+
Same as the logout page example in redirect mode.
|
|
158
|
+
|
|
159
|
+
## Native mode
|
|
160
|
+
|
|
161
|
+
In native mode, authentication UI is rendered directly within your application using customizable widgets. This provides the most seamless user experience.
|
|
162
|
+
|
|
163
|
+
##### Login page example
|
|
164
|
+
|
|
165
|
+
```svelte
|
|
166
|
+
<script lang="ts">
|
|
167
|
+
import { StyLoginRenderer, useStrivacity, type NativeContext } from '@strivacity/sdk-svelte';
|
|
168
|
+
import { goto } from '$app/navigation';
|
|
169
|
+
import { widgets } from './components/widgets';
|
|
170
|
+
import type { FallbackError, IdTokenClaims, LoginFlowState } from '@strivacity/sdk-svelte';
|
|
171
|
+
|
|
172
|
+
const { handleCallback } = useStrivacity<NativeContext>();
|
|
173
|
+
|
|
174
|
+
// Extract session_id from URL for continuing flows
|
|
175
|
+
let sessionId = $state<string | null>(null);
|
|
176
|
+
|
|
177
|
+
if (typeof window !== 'undefined') {
|
|
178
|
+
const url = new URL(window.location.href);
|
|
179
|
+
sessionId = url.searchParams.get('session_id');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Called when authentication is successful
|
|
184
|
+
* @param claims - ID token claims of the authenticated user
|
|
185
|
+
*/
|
|
186
|
+
const onLogin = async (claims?: IdTokenClaims | null) => {
|
|
187
|
+
console.log('Login successful:', claims);
|
|
188
|
+
await goto('/profile');
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Called when native flow cannot handle the authentication
|
|
193
|
+
* Falls back to redirect mode by navigating to the provided URL
|
|
194
|
+
* @param error - FallbackError containing the fallback URL and message
|
|
195
|
+
*/
|
|
196
|
+
const onFallback = (error: FallbackError) => {
|
|
197
|
+
if (error.url) {
|
|
198
|
+
console.log(`Fallback: ${error.url}`);
|
|
199
|
+
window.location.href = error.url.toString();
|
|
200
|
+
} else {
|
|
201
|
+
console.error(`FallbackError without URL: ${error.message}`);
|
|
202
|
+
alert(error);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Called when an error occurs during the authentication process
|
|
208
|
+
* @param error - Error message describing what went wrong
|
|
209
|
+
*/
|
|
210
|
+
const onError = (error: string) => {
|
|
211
|
+
console.error(`Error: ${error}`);
|
|
212
|
+
alert(error);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Called when the authentication flow wants to display a global message
|
|
217
|
+
* @param message - Message to display to the user
|
|
218
|
+
*/
|
|
219
|
+
const onGlobalMessage = (message: string) => {
|
|
220
|
+
alert(message);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Called when the authentication flow transitions between states
|
|
225
|
+
* Useful for tracking flow progress and inject custom logic such as logging or analytics
|
|
226
|
+
* @param params - Object containing previous and current flow states
|
|
227
|
+
*/
|
|
228
|
+
const onBlockReady = ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => {
|
|
229
|
+
console.log('previousState', previousState);
|
|
230
|
+
console.log('state', state);
|
|
231
|
+
};
|
|
232
|
+
</script>
|
|
233
|
+
|
|
234
|
+
<StyLoginRenderer
|
|
235
|
+
{widgets}
|
|
236
|
+
{sessionId}
|
|
237
|
+
onlogin={onLogin}
|
|
238
|
+
onfallback={onFallback}
|
|
239
|
+
onerror={onError}
|
|
240
|
+
onglobalmessage={onGlobalMessage}
|
|
241
|
+
onblockready={onBlockReady}
|
|
242
|
+
/>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
##### Callback page example
|
|
246
|
+
|
|
247
|
+
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.
|
|
248
|
+
|
|
249
|
+
This component is essential for handling social login providers (like Google, Facebook, etc.) that require redirect-based authentication even within native mode flows.
|
|
250
|
+
|
|
251
|
+
```svelte
|
|
252
|
+
<script lang="ts">
|
|
253
|
+
import { onMount } from 'svelte';
|
|
254
|
+
import { goto } from '$app/navigation';
|
|
255
|
+
import { useStrivacity, type NativeContext } from '@strivacity/sdk-svelte';
|
|
256
|
+
|
|
257
|
+
const { handleCallback } = useStrivacity<NativeContext>();
|
|
258
|
+
|
|
259
|
+
let query = $state<Record<string, string>>({});
|
|
260
|
+
|
|
261
|
+
if (typeof window !== 'undefined') {
|
|
262
|
+
query = Object.fromEntries(new URLSearchParams(window.location.search));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
onMount(async () => {
|
|
266
|
+
const url = new URL(location.href);
|
|
267
|
+
const sessionId = url.searchParams.get('session_id');
|
|
268
|
+
|
|
269
|
+
if (sessionId) {
|
|
270
|
+
await goto(`/login?session_id=${sessionId}`);
|
|
271
|
+
} else {
|
|
272
|
+
try {
|
|
273
|
+
await handleCallback();
|
|
274
|
+
await goto('/profile');
|
|
275
|
+
} catch (error) {
|
|
276
|
+
console.error('Error during callback handling:', error);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
</script>
|
|
281
|
+
|
|
282
|
+
{#if query.error}
|
|
283
|
+
<section>
|
|
284
|
+
<h1>Error in authentication</h1>
|
|
285
|
+
<div>
|
|
286
|
+
<h4>{query.error}</h4>
|
|
287
|
+
<p>{query.error_description}</p>
|
|
288
|
+
</div>
|
|
289
|
+
</section>
|
|
290
|
+
{:else}
|
|
291
|
+
<section>
|
|
292
|
+
<h1>Logging in...</h1>
|
|
293
|
+
</section>
|
|
294
|
+
{/if}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
##### Profile page example
|
|
298
|
+
|
|
299
|
+
Same as the profile page example in redirect/popup mode.
|
|
300
|
+
|
|
301
|
+
##### Logout page example
|
|
302
|
+
|
|
303
|
+
Same as the logout page example in redirect/popup mode.
|
|
304
|
+
|
|
305
|
+
## Logging
|
|
306
|
+
|
|
307
|
+
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.
|
|
308
|
+
|
|
309
|
+
### Using the Default Logger
|
|
310
|
+
|
|
311
|
+
Enable the default console logger by adding the `logging` option when creating the SDK:
|
|
312
|
+
|
|
313
|
+
```svelte
|
|
314
|
+
<script lang="ts">
|
|
315
|
+
import { StyAuthProvider, DefaultLogging, type SDKOptions } from '@strivacity/sdk-svelte';
|
|
316
|
+
import Router from './Router.svelte';
|
|
317
|
+
|
|
318
|
+
const options: SDKOptions = {
|
|
319
|
+
mode: 'redirect',
|
|
320
|
+
issuer: 'https://<YOUR_DOMAIN>',
|
|
321
|
+
scopes: ['openid', 'profile'],
|
|
322
|
+
clientId: '<YOUR_CLIENT_ID>',
|
|
323
|
+
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
324
|
+
logging: DefaultLogging, // Enable built-in console logging
|
|
325
|
+
};
|
|
326
|
+
</script>
|
|
327
|
+
|
|
328
|
+
<StyAuthProvider {options}>
|
|
329
|
+
<Router />
|
|
330
|
+
</StyAuthProvider>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
The default logger writes to the browser console and automatically prefixes messages with a correlation ID when available (via the `xEventId` property).
|
|
334
|
+
|
|
335
|
+
### Creating a Custom Logger
|
|
336
|
+
|
|
337
|
+
You can provide your own logger by implementing the `SDKLogging` interface with four methods: `debug`, `info`, `warn`, and `error`. An optional `xEventId` property is honored for log correlation.
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
import type { SDKLogging } from '@strivacity/sdk-svelte';
|
|
341
|
+
|
|
342
|
+
export class MyLogger implements SDKLogging {
|
|
343
|
+
xEventId?: string;
|
|
344
|
+
|
|
345
|
+
debug(message: string): void {
|
|
346
|
+
// Send to your logging pipeline
|
|
347
|
+
console.debug(this.xEventId ? `[${this.xEventId}] ${message}` : message);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
info(message: string): void {
|
|
351
|
+
console.info(this.xEventId ? `[${this.xEventId}] ${message}` : message);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
warn(message: string): void {
|
|
355
|
+
console.warn(this.xEventId ? `[${this.xEventId}] ${message}` : message);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
error(message: string, error: Error): void {
|
|
359
|
+
console.error(this.xEventId ? `[${this.xEventId}] ${message}` : message, error);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Then register your custom logger when creating the SDK:
|
|
365
|
+
|
|
366
|
+
```svelte
|
|
367
|
+
<script lang="ts">
|
|
368
|
+
import { StyAuthProvider, type SDKOptions } from '@strivacity/sdk-svelte';
|
|
369
|
+
import { MyLogger } from './logging/MyLogger';
|
|
370
|
+
import Router from './Router.svelte';
|
|
371
|
+
|
|
372
|
+
const options: SDKOptions = {
|
|
373
|
+
mode: 'redirect',
|
|
374
|
+
issuer: 'https://<YOUR_DOMAIN>',
|
|
375
|
+
scopes: ['openid', 'profile'],
|
|
376
|
+
clientId: '<YOUR_CLIENT_ID>',
|
|
377
|
+
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
378
|
+
logging: MyLogger, // Use your custom logger
|
|
379
|
+
};
|
|
380
|
+
</script>
|
|
381
|
+
|
|
382
|
+
<StyAuthProvider {options}>
|
|
383
|
+
<Router />
|
|
384
|
+
</StyAuthProvider>
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Logger Interface
|
|
388
|
+
|
|
389
|
+
The `SDKLogging` interface requires the following methods:
|
|
390
|
+
|
|
391
|
+
- **`debug(message: string): void`** - Log debug-level messages
|
|
392
|
+
- **`info(message: string): void`** - Log informational messages
|
|
393
|
+
- **`warn(message: string): void`** - Log warning messages
|
|
394
|
+
- **`error(message: string, error: Error): void`** - Log error messages with error objects
|
|
395
|
+
|
|
396
|
+
The optional `xEventId` property, when set by the SDK, provides a correlation ID to trace related log messages across the authentication flow.
|
|
397
|
+
|
|
398
|
+
## API Documentation
|
|
399
|
+
|
|
400
|
+
### `useStrivacity` function
|
|
401
|
+
|
|
402
|
+
```typescript
|
|
403
|
+
useStrivacity<T extends PopupContext | RedirectContext | NativeContext>(): T;
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
You can choose between `PopupContext`, `RedirectContext`, or `NativeContext` using the `mode` option when configuring the SDK.
|
|
407
|
+
|
|
408
|
+
**Properties**
|
|
409
|
+
|
|
410
|
+
All properties return Svelte stores that you can subscribe to using the `$` prefix in templates.
|
|
411
|
+
|
|
412
|
+
- **`sdk: RedirectFlow | PopupFlow | NativeFlow`**: Returns the SDK instance based on the configured mode.
|
|
413
|
+
- **`loading: Readable<boolean>`**: Indicates if the session is being loaded.
|
|
414
|
+
- **`options: SDKOptions`**: The configured options for the SDK.
|
|
415
|
+
- **`isAuthenticated: Readable<boolean>`**: Indicates whether the user is authenticated.
|
|
416
|
+
- **`idTokenClaims: Readable<IdTokenClaims | null>`**: Claims from the ID token, or null if not available.
|
|
417
|
+
- **`accessToken: Readable<string | null>`**: The access token, or null if not available.
|
|
418
|
+
- **`refreshToken: Readable<string | null>`**: The refresh token, or null if not available.
|
|
419
|
+
- **`accessTokenExpired: Readable<boolean>`**: Indicates if the access token has expired.
|
|
420
|
+
- **`accessTokenExpirationDate: Readable<number | null>`**: Expiration date of the access token, or null if not set.
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
**Type: `RedirectContext`**
|
|
425
|
+
|
|
426
|
+
Represents the available methods for redirect-based interactions.
|
|
427
|
+
|
|
428
|
+
- **`login(options?: LoginOptions): Promise<void>`**: Initiates the login process by redirecting the user to the identity provider.
|
|
429
|
+
- `options` (optional): Configuration options for login.
|
|
430
|
+
- **`register(options?: RegisterOptions): Promise<void>`**: Registers a new user using a redirect flow.
|
|
431
|
+
- `options` (optional): Configuration options for registration.
|
|
432
|
+
- **`refresh(): Promise<void>`**: Refreshes the user's session using a redirect flow.
|
|
433
|
+
- **`revoke(): Promise<void>`**: Revokes the current session tokens using a redirect flow.
|
|
434
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs out the user by redirecting to the identity provider.
|
|
435
|
+
- `options` (optional): Configuration options for logout.
|
|
436
|
+
- **`handleCallback(url?: string): Promise<void>`**: Handles the callback after a redirect-based authentication or token exchange.
|
|
437
|
+
- `url` (optional): The URL to handle for the callback.
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
**Type: `PopupContext`**
|
|
442
|
+
|
|
443
|
+
Represents the available methods for popup-based interactions.
|
|
444
|
+
|
|
445
|
+
- **`login(options?: LoginOptions): Promise<void>`**: Initiates the login process using a popup window.
|
|
446
|
+
- `options` (optional): Configuration options for login.
|
|
447
|
+
- **`register(options?: RegisterOptions): Promise<void>`**: Registers a new user using a popup flow.
|
|
448
|
+
- `options` (optional): Configuration options for registration.
|
|
449
|
+
- **`refresh(): Promise<void>`**: Refreshes the user's session using a popup.
|
|
450
|
+
- **`revoke(): Promise<void>`**: Revokes the current session tokens using a popup flow.
|
|
451
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs out the user using a popup window.
|
|
452
|
+
- `options` (optional): Configuration options for logout.
|
|
453
|
+
- **`handleCallback(url?: string): Promise<void>`**: Handles the callback after a popup-based authentication or token exchange.
|
|
454
|
+
- `url` (optional): The URL to handle for the callback.
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
**Type: `NativeContext`**
|
|
459
|
+
|
|
460
|
+
Represents the available methods for native-based interactions.
|
|
461
|
+
|
|
462
|
+
- **`login(options?: LoginOptions): Promise<NativeFlowHandler>`**: Initiates the login process using a native flow.
|
|
463
|
+
- `options` (optional): Configuration options for login.
|
|
464
|
+
- **`register(options?: RegisterOptions): Promise<NativeFlowHandler>`**: Registers a new user using a native flow.
|
|
465
|
+
- `options` (optional): Configuration options for registration.
|
|
466
|
+
- **`refresh(): Promise<void>`**: Refreshes the user's session.
|
|
467
|
+
- **`revoke(): Promise<void>`**: Revokes the current session tokens.
|
|
468
|
+
- **`logout(options?: LogoutOptions): Promise<void>`**: Logs out the user by redirecting to the logout page.
|
|
469
|
+
- `options` (optional): Configuration options for logout.
|
|
470
|
+
- **`handleCallback(url?: string): Promise<void>`**: Handles the callback after a redirect-based authentication. This will be called automatically by the native flow handler during fallback.
|
|
471
|
+
- `url` (optional): The URL to handle for the callback.
|
|
472
|
+
|
|
473
|
+
### `StyLoginRenderer` component
|
|
474
|
+
|
|
475
|
+
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.
|
|
476
|
+
|
|
477
|
+
```typescript
|
|
478
|
+
StyLoginRenderer: Svelte.Component<{
|
|
479
|
+
params?: NativeParams;
|
|
480
|
+
widgets?: PartialRecord<WidgetType, Svelte.Component>;
|
|
481
|
+
sessionId?: string | null;
|
|
482
|
+
onlogin?: (claims?: IdTokenClaims | null) => void;
|
|
483
|
+
onfallback?: (error: FallbackError) => void;
|
|
484
|
+
onerror?: (error: any) => void;
|
|
485
|
+
onglobalmessage?: (message: string) => void;
|
|
486
|
+
onblockready?: ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => void;
|
|
487
|
+
}>;
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
**Properties**
|
|
491
|
+
|
|
492
|
+
- **`params?: NativeParams`** (optional): Additional parameters to pass to the native login flow. These parameters can include custom configuration options for the authentication process.
|
|
493
|
+
|
|
494
|
+
- **`widgets?: PartialRecord<WidgetType, Svelte.Component>`** (optional): A collection of Svelte components that define the UI widgets used in the authentication flow. Each widget type (input, button, layout, etc.) can be customized with your own components.
|
|
495
|
+
|
|
496
|
+
- **`sessionId?: string | null`** (optional): The session ID for continuing an existing authentication session. This is typically extracted from URL parameters when returning from external identity providers.
|
|
497
|
+
|
|
498
|
+
**Callback Props**
|
|
499
|
+
|
|
500
|
+
In Svelte 5, events are replaced with callback props. All callbacks are optional:
|
|
501
|
+
|
|
502
|
+
- **`onlogin?: (claims?: IdTokenClaims | null) => void`** (optional): Called when authentication is successful. Receives the ID token claims as a parameter.
|
|
503
|
+
|
|
504
|
+
- **`onfallback?: (error: FallbackError) => void`** (optional): Called when the native flow cannot handle the authentication and needs to fall back to redirect mode. The error parameter contains the fallback URL.
|
|
505
|
+
|
|
506
|
+
- **`onerror?: (error: any) => void`** (optional): Called when an error occurs during the authentication process. Use this to handle and display error messages to users.
|
|
507
|
+
|
|
508
|
+
- **`onglobalmessage?: (message: string) => void`** (optional): Called when the authentication flow wants to display a global message to the user (e.g., account lockout warnings, validation messages).
|
|
509
|
+
|
|
510
|
+
- **`onblockready?: ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => void`** (optional): Called 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.
|
|
511
|
+
|
|
512
|
+
**Widget Types**
|
|
513
|
+
|
|
514
|
+
The `widgets` prop accepts the following widget types:
|
|
515
|
+
|
|
516
|
+
- `checkbox`: For checkbox input fields
|
|
517
|
+
- `close`: For close buttons
|
|
518
|
+
- `date`: For date input fields
|
|
519
|
+
- `input`: For text input fields
|
|
520
|
+
- `layout`: For layout containers and form structure
|
|
521
|
+
- `loading`: For loading indicators
|
|
522
|
+
- `multiSelect`: For multi-select dropdown fields
|
|
523
|
+
- `passcode`: For passcode input fields
|
|
524
|
+
- `password`: For password input fields
|
|
525
|
+
- `passkeyEnroll`: For passkey enrollment
|
|
526
|
+
- `passkeyLogin`: For passkey login
|
|
527
|
+
- `phone`: For phone number input fields
|
|
528
|
+
- `select`: For single-select dropdown fields
|
|
529
|
+
- `static`: For static text and display elements
|
|
530
|
+
- `submit`: For form submission buttons
|
|
531
|
+
- `webauthnEnroll`: For WebAuthn enrollment
|
|
532
|
+
- `webauthnLogin`: For WebAuthn login
|
|
533
|
+
|
|
534
|
+
Each widget component receives props specific to its type and function within the authentication flow.
|
|
535
|
+
|
|
536
|
+
## Links
|
|
537
|
+
|
|
538
|
+
- [Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/svelte)
|
|
539
|
+
|
|
540
|
+
## License
|
|
541
|
+
|
|
542
|
+
MIT
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";require("svelte/internal/disclose-version");const d=require("svelte/internal/client"),c=require("svelte"),k=require("@strivacity/sdk-core"),T=require("./composables.cjs");function b(o){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(i,e,s.get?s:{enumerable:!0,get:()=>o[e]})}}return i.default=o,Object.freeze(i)}const a=b(d);function f(o,i){a.push(i,!0);const e=k.initFlow(i.options);let s=a.proxy({loading:!0,isAuthenticated:!1,idTokenClaims:null,accessToken:null,refreshToken:null,accessTokenExpired:!0,accessTokenExpirationDate:null});const t=async()=>{s.isAuthenticated=await e.isAuthenticated,s.idTokenClaims=e.idTokenClaims||null,s.accessToken=e.accessToken||null,s.refreshToken=e.refreshToken||null,s.accessTokenExpired=e.accessTokenExpired,s.accessTokenExpirationDate=e.accessTokenExpirationDate||null,s.loading&&(s.loading=!1)},l=[e.subscribeToEvent("init",t),e.subscribeToEvent("loggedIn",t),e.subscribeToEvent("sessionLoaded",t),e.subscribeToEvent("tokenRefreshed",t),e.subscribeToEvent("tokenRefreshFailed",t),e.subscribeToEvent("logoutInitiated",t),e.subscribeToEvent("tokenRevoked",t),e.subscribeToEvent("tokenRevokeFailed",t)];c.setContext(T.STRIVACITY_SDK,{sdk:e,state:s,login:async n=>{if(e.options.mode==="native")return e.login(n);await e.login(n),await t()},register:async n=>{if(e.options.mode==="native")return e.register(n);await e.register(n),await t()},entry:async n=>await e.entry(n),refresh:async()=>{await e.refresh(),await t()},revoke:async()=>{await e.revoke(),await t()},logout:async n=>{await e.logout(n),await t()},handleCallback:async n=>{await e.handleCallback(n),await t()}}),c.onMount(()=>()=>{l.forEach(n=>n.dispose())});var r=a.comment(),u=a.first_child(r);a.snippet(u,()=>i.children??a.noop),a.append(o,r),a.pop()}module.exports=f;
|
|
2
|
+
//# sourceMappingURL=AuthProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthProvider.cjs","sources":["../src/AuthProvider.svelte"],"sourcesContent":["<script lang=\"ts\">\n\timport type { SDKOptions, IdTokenClaims } from '@strivacity/sdk-core';\n\timport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\n\timport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\n\timport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\n\timport { setContext, onMount } from 'svelte';\n\timport { initFlow } from '@strivacity/sdk-core';\n\timport { STRIVACITY_SDK } from './composables';\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tlet { options, children }: { options: SDKOptions; children?: any } = $props();\n\n\t// svelte-ignore state_referenced_locally\n\tconst sdk = initFlow(options);\n\tlet state = $state({\n\t\tloading: true,\n\t\tisAuthenticated: false,\n\t\tidTokenClaims: null as IdTokenClaims | null,\n\t\taccessToken: null as string | null,\n\t\trefreshToken: null as string | null,\n\t\taccessTokenExpired: true,\n\t\taccessTokenExpirationDate: null as number | null,\n\t});\n\n\tconst updateSession = async () => {\n\t\tstate.isAuthenticated = await sdk.isAuthenticated;\n\t\tstate.idTokenClaims = sdk.idTokenClaims || null;\n\t\tstate.accessToken = sdk.accessToken || null;\n\t\tstate.refreshToken = sdk.refreshToken || null;\n\t\tstate.accessTokenExpired = sdk.accessTokenExpired;\n\t\tstate.accessTokenExpirationDate = sdk.accessTokenExpirationDate || null;\n\n\t\tif (state.loading) {\n\t\t\tstate.loading = false;\n\t\t}\n\t};\n\tconst events = [\n\t\tsdk.subscribeToEvent('init', updateSession),\n\t\tsdk.subscribeToEvent('loggedIn', updateSession),\n\t\tsdk.subscribeToEvent('sessionLoaded', updateSession),\n\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession),\n\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession),\n\t\tsdk.subscribeToEvent('logoutInitiated', updateSession),\n\t\tsdk.subscribeToEvent('tokenRevoked', updateSession),\n\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession),\n\t];\n\n\tsetContext(STRIVACITY_SDK, {\n\t\tsdk,\n\t\tstate,\n\n\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\treturn sdk.login(options);\n\t\t\t}\n\n\t\t\tawait sdk.login(options);\n\t\t\tawait updateSession();\n\t\t},\n\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\treturn sdk.register(options);\n\t\t\t}\n\n\t\t\tawait sdk.register(options);\n\t\t\tawait updateSession();\n\t\t},\n\t\tentry: async (url?: string) => {\n\t\t\treturn await sdk.entry(url);\n\t\t},\n\t\trefresh: async () => {\n\t\t\tawait sdk.refresh();\n\t\t\tawait updateSession();\n\t\t},\n\t\trevoke: async () => {\n\t\t\tawait sdk.revoke();\n\t\t\tawait updateSession();\n\t\t},\n\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\tawait sdk.logout(options);\n\t\t\tawait updateSession();\n\t\t},\n\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\tawait sdk.handleCallback(url);\n\t\t\tawait updateSession();\n\t\t},\n\t});\n\n\tonMount(() => {\n\t\treturn () => {\n\t\t\tevents.forEach((event) => event.dispose());\n\t\t};\n\t});\n</script>\n\n{@render children?.()}\n"],"names":["sdk","initFlow","$$props","state","$","updateSession","events","setContext","STRIVACITY_SDK","options","url","onMount","event"],"mappings":"ieAAA,cAaO,MAAAA,EAAMC,EAAAA,SAAQC,EAAA,OAAA,MAChBC,EAAKC,EAAA,MAAA,CACR,QAAS,GACT,gBAAiB,GACjB,cAAe,KACf,YAAa,KACb,aAAc,KACd,mBAAoB,GACpB,0BAA2B,OAGtB,MAAAC,EAAa,SAAe,CACjCF,EAAM,gBAAe,MAASH,EAAI,gBAClCG,EAAM,cAAgBH,EAAI,eAAiB,KAC3CG,EAAM,YAAcH,EAAI,aAAe,KACvCG,EAAM,aAAeH,EAAI,cAAgB,KACzCG,EAAM,mBAAqBH,EAAI,mBAC/BG,EAAM,0BAA4BH,EAAI,2BAA6B,KAE/DG,EAAM,UACTA,EAAM,QAAU,GAElB,EACMG,EAAM,CACXN,EAAI,iBAAiB,OAAQK,CAAa,EAC1CL,EAAI,iBAAiB,WAAYK,CAAa,EAC9CL,EAAI,iBAAiB,gBAAiBK,CAAa,EACnDL,EAAI,iBAAiB,iBAAkBK,CAAa,EACpDL,EAAI,iBAAiB,qBAAsBK,CAAa,EACxDL,EAAI,iBAAiB,kBAAmBK,CAAa,EACrDL,EAAI,iBAAiB,eAAgBK,CAAa,EAClDL,EAAI,iBAAiB,oBAAqBK,CAAa,GAGxDE,EAAAA,WAAWC,EAAAA,eAAc,CACxB,IAAAR,EACA,MAAAG,EAEA,MAAK,MAASM,GAA8F,CACvG,GAAAT,EAAI,QAAQ,OAAS,gBACjBA,EAAI,MAAMS,CAAO,QAGnBT,EAAI,MAAMS,CAAO,QACjBJ,EAAa,CACpB,EACA,SAAQ,MAASI,GAAuG,CACnH,GAAAT,EAAI,QAAQ,OAAS,gBACjBA,EAAI,SAASS,CAAO,QAGtBT,EAAI,SAASS,CAAO,QACpBJ,EAAa,CACpB,EACA,MAAK,MAASK,SACAV,EAAI,MAAMU,CAAG,EAE3B,QAAO,SAAc,CACd,MAAAV,EAAI,QAAO,QACXK,EAAa,CACpB,EACA,OAAM,SAAc,CACb,MAAAL,EAAI,OAAM,QACVK,EAAa,CACpB,EACA,OAAM,MAASI,GAA0E,OAClFT,EAAI,OAAOS,CAAO,QAClBJ,EAAa,CACpB,EACA,eAAc,MAASK,GAAqH,OACrIV,EAAI,eAAeU,CAAG,QACtBL,EAAa,CACpB,IAGDM,EAAAA,QAAO,IACO,IAAA,CACZL,EAAO,QAASM,GAAUA,EAAM,QAAO,CAAA,CACxC,CACA,gGACM"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"svelte/internal/disclose-version";import*as i from"svelte/internal/client";import{setContext as u,onMount as d}from"svelte";import{initFlow as k}from"@strivacity/sdk-core";import{STRIVACITY_SDK as T}from"./composables.mjs";function h(r,o){i.push(o,!0);const e=k(o.options);let a=i.proxy({loading:!0,isAuthenticated:!1,idTokenClaims:null,accessToken:null,refreshToken:null,accessTokenExpired:!0,accessTokenExpirationDate:null});const n=async()=>{a.isAuthenticated=await e.isAuthenticated,a.idTokenClaims=e.idTokenClaims||null,a.accessToken=e.accessToken||null,a.refreshToken=e.refreshToken||null,a.accessTokenExpired=e.accessTokenExpired,a.accessTokenExpirationDate=e.accessTokenExpirationDate||null,a.loading&&(a.loading=!1)},c=[e.subscribeToEvent("init",n),e.subscribeToEvent("loggedIn",n),e.subscribeToEvent("sessionLoaded",n),e.subscribeToEvent("tokenRefreshed",n),e.subscribeToEvent("tokenRefreshFailed",n),e.subscribeToEvent("logoutInitiated",n),e.subscribeToEvent("tokenRevoked",n),e.subscribeToEvent("tokenRevokeFailed",n)];u(T,{sdk:e,state:a,login:async t=>{if(e.options.mode==="native")return e.login(t);await e.login(t),await n()},register:async t=>{if(e.options.mode==="native")return e.register(t);await e.register(t),await n()},entry:async t=>await e.entry(t),refresh:async()=>{await e.refresh(),await n()},revoke:async()=>{await e.revoke(),await n()},logout:async t=>{await e.logout(t),await n()},handleCallback:async t=>{await e.handleCallback(t),await n()}}),d(()=>()=>{c.forEach(t=>t.dispose())});var s=i.comment(),l=i.first_child(s);i.snippet(l,()=>o.children??i.noop),i.append(r,s),i.pop()}export{h as default};
|
|
2
|
+
//# sourceMappingURL=AuthProvider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthProvider.mjs","sources":["../src/AuthProvider.svelte"],"sourcesContent":["<script lang=\"ts\">\n\timport type { SDKOptions, IdTokenClaims } from '@strivacity/sdk-core';\n\timport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\n\timport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\n\timport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\n\timport { setContext, onMount } from 'svelte';\n\timport { initFlow } from '@strivacity/sdk-core';\n\timport { STRIVACITY_SDK } from './composables';\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tlet { options, children }: { options: SDKOptions; children?: any } = $props();\n\n\t// svelte-ignore state_referenced_locally\n\tconst sdk = initFlow(options);\n\tlet state = $state({\n\t\tloading: true,\n\t\tisAuthenticated: false,\n\t\tidTokenClaims: null as IdTokenClaims | null,\n\t\taccessToken: null as string | null,\n\t\trefreshToken: null as string | null,\n\t\taccessTokenExpired: true,\n\t\taccessTokenExpirationDate: null as number | null,\n\t});\n\n\tconst updateSession = async () => {\n\t\tstate.isAuthenticated = await sdk.isAuthenticated;\n\t\tstate.idTokenClaims = sdk.idTokenClaims || null;\n\t\tstate.accessToken = sdk.accessToken || null;\n\t\tstate.refreshToken = sdk.refreshToken || null;\n\t\tstate.accessTokenExpired = sdk.accessTokenExpired;\n\t\tstate.accessTokenExpirationDate = sdk.accessTokenExpirationDate || null;\n\n\t\tif (state.loading) {\n\t\t\tstate.loading = false;\n\t\t}\n\t};\n\tconst events = [\n\t\tsdk.subscribeToEvent('init', updateSession),\n\t\tsdk.subscribeToEvent('loggedIn', updateSession),\n\t\tsdk.subscribeToEvent('sessionLoaded', updateSession),\n\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession),\n\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession),\n\t\tsdk.subscribeToEvent('logoutInitiated', updateSession),\n\t\tsdk.subscribeToEvent('tokenRevoked', updateSession),\n\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession),\n\t];\n\n\tsetContext(STRIVACITY_SDK, {\n\t\tsdk,\n\t\tstate,\n\n\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\treturn sdk.login(options);\n\t\t\t}\n\n\t\t\tawait sdk.login(options);\n\t\t\tawait updateSession();\n\t\t},\n\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\treturn sdk.register(options);\n\t\t\t}\n\n\t\t\tawait sdk.register(options);\n\t\t\tawait updateSession();\n\t\t},\n\t\tentry: async (url?: string) => {\n\t\t\treturn await sdk.entry(url);\n\t\t},\n\t\trefresh: async () => {\n\t\t\tawait sdk.refresh();\n\t\t\tawait updateSession();\n\t\t},\n\t\trevoke: async () => {\n\t\t\tawait sdk.revoke();\n\t\t\tawait updateSession();\n\t\t},\n\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\tawait sdk.logout(options);\n\t\t\tawait updateSession();\n\t\t},\n\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\tawait sdk.handleCallback(url);\n\t\t\tawait updateSession();\n\t\t},\n\t});\n\n\tonMount(() => {\n\t\treturn () => {\n\t\t\tevents.forEach((event) => event.dispose());\n\t\t};\n\t});\n</script>\n\n{@render children?.()}\n"],"names":["sdk","initFlow","$$props","state","$","updateSession","events","setContext","STRIVACITY_SDK","options","url","onMount","event"],"mappings":"qPAAA,cAaO,MAAAA,EAAMC,EAAQC,EAAA,OAAA,MAChBC,EAAKC,EAAA,MAAA,CACR,QAAS,GACT,gBAAiB,GACjB,cAAe,KACf,YAAa,KACb,aAAc,KACd,mBAAoB,GACpB,0BAA2B,OAGtB,MAAAC,EAAa,SAAe,CACjCF,EAAM,gBAAe,MAASH,EAAI,gBAClCG,EAAM,cAAgBH,EAAI,eAAiB,KAC3CG,EAAM,YAAcH,EAAI,aAAe,KACvCG,EAAM,aAAeH,EAAI,cAAgB,KACzCG,EAAM,mBAAqBH,EAAI,mBAC/BG,EAAM,0BAA4BH,EAAI,2BAA6B,KAE/DG,EAAM,UACTA,EAAM,QAAU,GAElB,EACMG,EAAM,CACXN,EAAI,iBAAiB,OAAQK,CAAa,EAC1CL,EAAI,iBAAiB,WAAYK,CAAa,EAC9CL,EAAI,iBAAiB,gBAAiBK,CAAa,EACnDL,EAAI,iBAAiB,iBAAkBK,CAAa,EACpDL,EAAI,iBAAiB,qBAAsBK,CAAa,EACxDL,EAAI,iBAAiB,kBAAmBK,CAAa,EACrDL,EAAI,iBAAiB,eAAgBK,CAAa,EAClDL,EAAI,iBAAiB,oBAAqBK,CAAa,GAGxDE,EAAWC,EAAc,CACxB,IAAAR,EACA,MAAAG,EAEA,MAAK,MAASM,GAA8F,CACvG,GAAAT,EAAI,QAAQ,OAAS,gBACjBA,EAAI,MAAMS,CAAO,QAGnBT,EAAI,MAAMS,CAAO,QACjBJ,EAAa,CACpB,EACA,SAAQ,MAASI,GAAuG,CACnH,GAAAT,EAAI,QAAQ,OAAS,gBACjBA,EAAI,SAASS,CAAO,QAGtBT,EAAI,SAASS,CAAO,QACpBJ,EAAa,CACpB,EACA,MAAK,MAASK,SACAV,EAAI,MAAMU,CAAG,EAE3B,QAAO,SAAc,CACd,MAAAV,EAAI,QAAO,QACXK,EAAa,CACpB,EACA,OAAM,SAAc,CACb,MAAAL,EAAI,OAAM,QACVK,EAAa,CACpB,EACA,OAAM,MAASI,GAA0E,OAClFT,EAAI,OAAOS,CAAO,QAClBJ,EAAa,CACpB,EACA,eAAc,MAASK,GAAqH,OACrIV,EAAI,eAAeU,CAAG,QACtBL,EAAa,CACpB,IAGDM,EAAO,IACO,IAAA,CACZL,EAAO,QAASM,GAAUA,EAAM,QAAO,CAAA,CACxC,CACA,gGACM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SvelteComponent as default } from 'svelte';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";require("svelte/internal/disclose-version");const x=require("svelte/internal/client"),N=require("svelte"),S=require("@strivacity/sdk-core"),L=require("@strivacity/sdk-core/utils/object"),z=require("./composables.cjs");function E(d){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const c in d)if(c!=="default"){const i=Object.getOwnPropertyDescriptor(d,c);Object.defineProperty(s,c,i.get?i:{enumerable:!0,get:()=>d[c]})}}return s.default=d,Object.freeze(s)}const e=E(x),j=(d,s=e.noop)=>{var c=e.comment(),i=e.first_child(c);e.each(i,17,s,p=>p?.key,(p,t)=>{var g=e.comment(),C=e.first_child(g);{var w=v=>{const _=e.derived(()=>e.get(t).component);var k=e.comment(),F=e.first_child(k);{var U=f=>{var u=e.comment(),h=e.first_child(u);e.component(h,()=>e.get(_),(n,r)=>{r(n,e.spread_props(()=>e.get(t).props,{children:(o,a)=>{j(o,()=>e.get(t).children)},$$slots:{default:!0}}))}),e.append(f,u)},b=f=>{var u=e.comment(),h=e.first_child(u);e.component(h,()=>e.get(_),(n,r)=>{r(n,e.spread_props(()=>e.get(t).props))}),e.append(f,u)};e.if(F,f=>{e.get(t).children?f(U):f(b,!1)})}e.append(v,k)};e.if(C,v=>{e.get(t)&&v(w)})}e.append(p,g)}),e.append(d,c)};var M=e.from_html('<div class="login-renderer"><!></div>');function T(d,s){e.push(s,!0);let c=e.prop(s,"sessionId",3,null);const{sdk:i}=z.useStrivacity(),p=i.login(s.params),t=e.proxy({loading:!1,forms:{},messages:{},state:{},submitForm:async()=>{},triggerFallback:()=>{},triggerClose:()=>{},setFormValue:()=>{},setMessage:()=>{}}),g=(n,r)=>{const o=n||t.state.hostedUrl;if(i.logging?.warn(r?`Triggering fallback due to: ${r}`:"Triggering fallback"),!o){const a=new Error("No hosted URL provided");throw i.logging?.error("Fallback error",a),a}s.onfallback?.(new S.FallbackError(new URL(o)))},C=()=>{s.onclose?.()},w=n=>n.map((r,o)=>{if(r.type==="widget"){const a=t.state.forms?.find(m=>m.id===r.formId),l=a?.widgets.find(m=>m.id===r.widgetId);if(!a||!l)return g(void 0,`Unable to find form or widget for item: formId=${r.formId}, widgetId=${r.widgetId}`),null;const y=s.widgets?.[l.type];return y?{component:y,props:{formId:a.id,config:l},key:`${a.id}.${l.id}`}:(g(void 0,`No component found for widget type ${l.type}`),null)}else if(r.type==="vertical"||r.type==="horizontal"){const a=s.widgets?.layout;return a?{component:a,props:{formId:r.items[0].formId,type:r.type,tag:"div"},children:w(r.items),key:`layout-${o}`}:(g(void 0,"No layout component provided"),null)}else return g(void 0,"Unknown item type in layout"),null}),v=(n,r,o)=>{o===""&&(o=null),t.forms={...t.forms,[n]:{...t.forms[n]||{},[r]:o===""?null:o}}},_=(n,r,o)=>{t.messages={...t.messages,[n]:{...t.messages[n]||{},[r]:o}}},k=async n=>{try{t.loading=!0;const r=await p?.submitForm(n,L.unflattenObject(t.forms[n]));await F(r),t.loading=!1}catch(r){r instanceof S.FallbackError?s.onfallback?.(r):s.onerror?.(r)}},F=async n=>{if(await i.isAuthenticated)s.onlogin?.(i.idTokenClaims);else{const r=JSON.parse(JSON.stringify(t.state)),o={hostedUrl:n?.hostedUrl??t.state.hostedUrl,finalizeUrl:n?.finalizeUrl??t.state.finalizeUrl,screen:n?.screen??t.state.screen,forms:n?.forms??t.state.forms,layout:n?.layout??t.state.layout,messages:n?.messages??{},branding:n?.branding??t.state.branding};if(o.screen!==t.state.screen){t.forms={},t.messages={};for(const a of o.forms??[])t.forms[a.id]={},t.messages[a.id]={}}else i.logging?.info(`Updating screen: ${o.screen}`);Object.keys(o.messages??{}).forEach(a=>{a==="global"?s.onglobalmessage?.(o.messages?.global?.text??""):t.messages[a]=o.messages[a]}),t.state=o,setTimeout(()=>{s.onblockready?.({previousState:r,state:JSON.parse(JSON.stringify(o))})},1)}};t.submitForm=k,t.triggerFallback=g,t.triggerClose=C,t.setFormValue=v,t.setMessage=_,N.setContext("nativeFlowContext",t),N.onMount(async()=>{try{const n=await p?.startSession(c());n&&await F(n)}catch(n){n instanceof S.FallbackError?s.onfallback?.(n):s.onerror?.(n)}});let U=e.derived(()=>t.state.screen&&s.widgets?.layout?w(t.state.layout?.items??[]):[]);var b=M(),f=e.child(b);{var u=n=>{const r=e.derived(()=>s.widgets?.layout);var o=e.comment(),a=e.first_child(o);{let l=e.derived(()=>t.state.layout?.type);e.component(a,()=>e.get(r),(y,m)=>{m(y,{get formId(){return t.state.layout?.items[0].formId},get type(){return e.get(l)},tag:"form",children:(O,I)=>{j(O,()=>e.get(U))},$$slots:{default:!0}})})}e.append(n,o)},h=n=>{var r=e.comment(),o=e.first_child(r);{var a=l=>{const y=e.derived(()=>s.widgets?.loading);var m=e.comment(),O=e.first_child(m);e.component(O,()=>e.get(y),(I,q)=>{q(I,{})}),e.append(l,m)};e.if(o,l=>{s.widgets?.loading&&l(a)},!0)}e.append(n,r)};e.if(f,n=>{t.state.screen&&s.widgets?.layout?n(u):n(h,!1)})}e.reset(b),e.append(d,b),e.pop()}module.exports=T;
|
|
2
|
+
//# sourceMappingURL=LoginRenderer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoginRenderer.cjs","sources":["../src/LoginRenderer.svelte"],"sourcesContent":["<script lang=\"ts\">\n\t/* eslint-disable @typescript-eslint/no-explicit-any */\n\timport type {\n\t\tNativeParams,\n\t\tPartialRecord,\n\t\tWidgetType,\n\t\tLayoutWidget,\n\t\tLoginFlowState,\n\t\tWidget,\n\t\tIdTokenClaims,\n\t\tLoginFlowMessage,\n\t} from '@strivacity/sdk-core';\n\timport type { NativeContext, NativeFlowContextValue } from './types';\n\timport type { Component } from 'svelte';\n\timport { setContext, onMount } from 'svelte';\n\timport { FallbackError } from '@strivacity/sdk-core';\n\timport { unflattenObject } from '@strivacity/sdk-core/utils/object';\n\timport { useStrivacity } from './composables';\n\n\tlet {\n\t\tparams,\n\t\twidgets,\n\t\tsessionId = null,\n\t\tonlogin,\n\t\tonfallback,\n\t\tonclose,\n\t\tonerror,\n\t\tonglobalmessage,\n\t\tonblockready,\n\t}: {\n\t\tparams?: NativeParams;\n\t\twidgets?: PartialRecord<WidgetType, Component>;\n\t\tsessionId?: string | null;\n\t\tonlogin?: (claims?: IdTokenClaims | null) => void;\n\t\tonfallback?: (error: FallbackError) => void;\n\t\tonclose?: () => void;\n\t\tonerror?: (error: any) => void;\n\t\tonglobalmessage?: (message: string) => void;\n\t\tonblockready?: ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => void;\n\t} = $props();\n\n\tconst { sdk } = useStrivacity<NativeContext>();\n\t// svelte-ignore state_referenced_locally\n\tconst loginHandler = sdk.login(params);\n\tconst context = $state<NativeFlowContextValue>({\n\t\tloading: false,\n\t\tforms: {},\n\t\tmessages: {},\n\t\tstate: {},\n\t\tsubmitForm: async () => {},\n\t\ttriggerFallback: () => {},\n\t\ttriggerClose: () => {},\n\t\tsetFormValue: () => {},\n\t\tsetMessage: () => {},\n\t});\n\n\tconst triggerFallback = (hostedUrl?: string, message?: string) => {\n\t\tconst url = hostedUrl || context.state.hostedUrl;\n\n\t\tsdk.logging?.warn(message ? `Triggering fallback due to: ${message}` : 'Triggering fallback');\n\n\t\tif (!url) {\n\t\t\tconst error = new Error('No hosted URL provided');\n\t\t\tsdk.logging?.error('Fallback error', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tonfallback?.(new FallbackError(new URL(url)));\n\t};\n\n\tconst triggerClose = () => {\n\t\tonclose?.();\n\t};\n\n\tconst renderWidgets = (items: LayoutWidget['items']): Array<any> => {\n\t\treturn items.map((item, idx) => {\n\t\t\tif (item.type === 'widget') {\n\t\t\t\tconst form = context.state.forms?.find((f: any) => f.id === item.formId);\n\t\t\t\tconst widget = form?.widgets.find((w: any) => w.id === item.widgetId);\n\n\t\t\t\tif (!form || !widget) {\n\t\t\t\t\ttriggerFallback(undefined, `Unable to find form or widget for item: formId=${item.formId}, widgetId=${item.widgetId}`);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst WidgetComponent = widgets?.[widget.type as keyof typeof widgets];\n\n\t\t\t\tif (!WidgetComponent) {\n\t\t\t\t\ttriggerFallback(undefined, `No component found for widget type ${widget.type}`);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcomponent: WidgetComponent,\n\t\t\t\t\tprops: { formId: form.id, config: widget },\n\t\t\t\t\tkey: `${form.id}.${widget.id}`,\n\t\t\t\t};\n\t\t\t} else if (item.type === 'vertical' || item.type === 'horizontal') {\n\t\t\t\tconst LayoutComponent = widgets?.layout;\n\n\t\t\t\tif (!LayoutComponent) {\n\t\t\t\t\ttriggerFallback(undefined, 'No layout component provided');\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcomponent: LayoutComponent,\n\t\t\t\t\tprops: { formId: (item.items[0] as Widget).formId, type: item.type, tag: 'div' },\n\t\t\t\t\tchildren: renderWidgets(item.items),\n\t\t\t\t\tkey: `layout-${idx}`,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\ttriggerFallback(undefined, 'Unknown item type in layout');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t});\n\t};\n\n\tconst setFormValue = (formId: string, widgetId: string, value: unknown) => {\n\t\tif (value === '') {\n\t\t\tvalue = null;\n\t\t}\n\n\t\tcontext.forms = {\n\t\t\t...context.forms,\n\t\t\t[formId]: { ...(context.forms[formId] || {}), [widgetId]: value === '' ? null : value },\n\t\t};\n\t};\n\n\tconst setMessage = (formId: string, widgetId: string, value: LoginFlowMessage) => {\n\t\tcontext.messages = {\n\t\t\t...context.messages,\n\t\t\t[formId]: { ...(context.messages[formId] || {}), [widgetId]: value },\n\t\t};\n\t};\n\n\tconst submitForm = async (formId: string) => {\n\t\ttry {\n\t\t\tcontext.loading = true;\n\n\t\t\tconst data = await loginHandler?.submitForm(formId, unflattenObject(context.forms[formId]));\n\t\t\tawait handleResponse(data);\n\n\t\t\tcontext.loading = false;\n\t\t} catch (error) {\n\t\t\tif (error instanceof FallbackError) {\n\t\t\t\tonfallback?.(error);\n\t\t\t} else {\n\t\t\t\tonerror?.(error);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleResponse = async (data?: LoginFlowState) => {\n\t\tif (await sdk.isAuthenticated) {\n\t\t\tonlogin?.(sdk.idTokenClaims);\n\t\t} else {\n\t\t\tconst previousState = JSON.parse(JSON.stringify(context.state));\n\t\t\tconst newState: LoginFlowState = {\n\t\t\t\thostedUrl: data?.hostedUrl ?? context.state.hostedUrl,\n\t\t\t\tfinalizeUrl: data?.finalizeUrl ?? context.state.finalizeUrl,\n\t\t\t\tscreen: data?.screen ?? context.state.screen,\n\t\t\t\tforms: data?.forms ?? context.state.forms,\n\t\t\t\tlayout: data?.layout ?? context.state.layout,\n\t\t\t\tmessages: data?.messages ?? {},\n\t\t\t\tbranding: data?.branding ?? context.state.branding,\n\t\t\t};\n\n\t\t\tif (newState.screen !== context.state.screen) {\n\t\t\t\tcontext.forms = {};\n\t\t\t\tcontext.messages = {};\n\n\t\t\t\tfor (const form of newState.forms ?? []) {\n\t\t\t\t\tcontext.forms[form.id] = {};\n\t\t\t\t\tcontext.messages[form.id] = {};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsdk.logging?.info(`Updating screen: ${newState.screen}`);\n\t\t\t}\n\n\t\t\tObject.keys(newState.messages ?? {}).forEach((formId) => {\n\t\t\t\tif (formId === 'global') {\n\t\t\t\t\tonglobalmessage?.(newState.messages?.global?.text ?? '');\n\t\t\t\t} else {\n\t\t\t\t\tcontext.messages[formId] = newState.messages![formId];\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tcontext.state = newState;\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tonblockready?.({ previousState, state: JSON.parse(JSON.stringify(newState)) });\n\t\t\t}, 1);\n\t\t}\n\t};\n\n\tcontext.submitForm = submitForm;\n\tcontext.triggerFallback = triggerFallback;\n\tcontext.triggerClose = triggerClose;\n\tcontext.setFormValue = setFormValue;\n\tcontext.setMessage = setMessage;\n\n\tsetContext('nativeFlowContext', context);\n\n\tonMount(async () => {\n\t\ttry {\n\t\t\tconst data = await loginHandler?.startSession(sessionId);\n\n\t\t\tif (data) {\n\t\t\t\tawait handleResponse(data);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof FallbackError) {\n\t\t\t\tonfallback?.(error);\n\t\t\t} else {\n\t\t\t\tonerror?.(error);\n\t\t\t}\n\t\t}\n\t});\n\n\tlet renderedWidgets = $derived(context.state.screen && widgets?.layout ? renderWidgets(context.state.layout?.items ?? []) : []);\n</script>\n\n{#snippet renderItems(items: any[])}\n\t{#each items as item (item?.key)}\n\t\t{#if item}\n\t\t\t{@const Component = item.component}\n\t\t\t{#if item.children}\n\t\t\t\t<Component {...item.props}>\n\t\t\t\t\t{@render renderItems(item.children)}\n\t\t\t\t</Component>\n\t\t\t{:else}\n\t\t\t\t<Component {...item.props} />\n\t\t\t{/if}\n\t\t{/if}\n\t{/each}\n{/snippet}\n\n<div class=\"login-renderer\">\n\t{#if context.state.screen && widgets?.layout}\n\t\t{@const LayoutComponent = widgets?.layout}\n\t\t<LayoutComponent formId={(context.state.layout?.items[0] as Widget).formId} type={context.state.layout?.type} tag=\"form\">\n\t\t\t{@render renderItems(renderedWidgets)}\n\t\t</LayoutComponent>\n\t{:else if widgets?.loading}\n\t\t{@const LoadingComponent = widgets?.loading}\n\t\t<LoadingComponent />\n\t{/if}\n</div>\n"],"names":["renderItems","items","$","node","item","Component","Component_1","$$anchor","Component_2","$$render","consequent","alternate","consequent_1","sessionId","sdk","useStrivacity","loginHandler","$$props","context","triggerFallback","hostedUrl","message","url","error","FallbackError","triggerClose","renderWidgets","idx","form","f","widget","w","WidgetComponent","LayoutComponent","setFormValue","formId","widgetId","value","setMessage","submitForm","data","unflattenObject","handleResponse","previousState","newState","setContext","onMount","renderedWidgets","div","root","$0","LayoutComponent_1","LoadingComponent","LoadingComponent_1","consequent_3","consequent_2","alternate_1"],"mappings":"igBA+NUA,KAAYC,EAAYC,EAAA,OAAA,sCAC1BA,EAAA,KAAAC,EAAA,GAAAF,EAASG,GAAMA,GAAM,OAAZA,IAAI,uDAEVC,EAASH,EAAA,QAAA,IAAAA,EAAA,IAAGE,CAAI,EAAC,SAAS,0HAEhCE,EAASC,EAAAL,EAAA,aAAA,IAAAA,EAAA,IAAKE,CAAI,EAAC,MAAK,kBACfJ,EAAWO,EAAA,IAAAL,EAAA,IAACE,CAAI,EAAC,QAAQ,0HAGlCI,EAASD,EAAAL,EAAA,aAAA,IAAAA,EAAA,IAAKE,CAAI,EAAC,KAAK,CAAA,8BALrBF,EAAA,IAAAE,CAAI,EAAC,SAAQK,EAAAC,CAAA,EAAAD,EAAAE,EAAA,EAAA,oCAFdP,CAAI,GAAAK,EAAAG,CAAA,6GAjOX,cAsBE,IAAAC,yBAAY,IAAI,EAmBT,KAAA,CAAA,IAAAC,CAAG,EAAKC,gBAAa,EAEvBC,EAAeF,EAAI,MAAKG,EAAA,MAAA,EACxBC,EAAOhB,EAAA,MAAA,CACZ,QAAS,GACT,MAAK,CAAA,EACL,SAAQ,CAAA,EACR,MAAK,CAAA,EACL,WAAU,SAAc,CAAC,EACzB,gBAAe,IAAQ,CAAC,EACxB,aAAY,IAAQ,CAAC,E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EAAe5C,EAAA,qBAAUW,EAAQ,MAAM,QAAQ,MAAM,CAAC,EAAa,gEAC1DlB,cAAY+C,CAAe,CAAA,iGAG7B,MAAAK,2BAA4B,OAAO,0EAC1CC,EAAgB9C,EAAA,EAAA,yCAFC,SAAOE,EAAA6C,CAAA,iCALrBpC,EAAQ,MAAM,mBAAmB,OAAMT,EAAA8C,CAAA,EAAA9C,EAAA+C,EAAA,EAAA,YAD5CR,CAAG,aAAHA,CAAG,SAjBI"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"svelte/internal/disclose-version";import*as e from"svelte/internal/client";import{setContext as O,onMount as z}from"svelte";import{FallbackError as S}from"@strivacity/sdk-core";import{unflattenObject as J}from"@strivacity/sdk-core/utils/object";import{useStrivacity as M}from"./composables.mjs";const x=(F,a=e.noop)=>{var h=e.comment(),l=e.first_child(h);e.each(l,17,a,m=>m?.key,(m,t)=>{var d=e.comment(),U=e.first_child(d);{var w=p=>{const _=e.derived(()=>e.get(t).component);var b=e.comment(),k=e.first_child(b);{var C=g=>{var f=e.comment(),v=e.first_child(f);e.component(v,()=>e.get(_),(n,o)=>{o(n,e.spread_props(()=>e.get(t).props,{children:(r,s)=>{x(r,()=>e.get(t).children)},$$slots:{default:!0}}))}),e.append(g,f)},y=g=>{var f=e.comment(),v=e.first_child(f);e.component(v,()=>e.get(_),(n,o)=>{o(n,e.spread_props(()=>e.get(t).props))}),e.append(g,f)};e.if(k,g=>{e.get(t).children?g(C):g(y,!1)})}e.append(p,b)};e.if(U,p=>{e.get(t)&&p(w)})}e.append(m,d)}),e.append(F,h)};var R=e.from_html('<div class="login-renderer"><!></div>');function P(F,a){e.push(a,!0);let h=e.prop(a,"sessionId",3,null);const{sdk:l}=M(),m=l.login(a.params),t=e.proxy({loading:!1,forms:{},messages:{},state:{},submitForm:async()=>{},triggerFallback:()=>{},triggerClose:()=>{},setFormValue:()=>{},setMessage:()=>{}}),d=(n,o)=>{const r=n||t.state.hostedUrl;if(l.logging?.warn(o?`Triggering fallback due to: ${o}`:"Triggering fallback"),!r){const s=new Error("No hosted URL provided");throw l.logging?.error("Fallback error",s),s}a.onfallback?.(new S(new URL(r)))},U=()=>{a.onclose?.()},w=n=>n.map((o,r)=>{if(o.type==="widget"){const s=t.state.forms?.find(c=>c.id===o.formId),i=s?.widgets.find(c=>c.id===o.widgetId);if(!s||!i)return d(void 0,`Unable to find form or widget for item: formId=${o.formId}, widgetId=${o.widgetId}`),null;const u=a.widgets?.[i.type];return u?{component:u,props:{formId:s.id,config:i},key:`${s.id}.${i.id}`}:(d(void 0,`No component found for widget type ${i.type}`),null)}else if(o.type==="vertical"||o.type==="horizontal"){const s=a.widgets?.layout;return s?{component:s,props:{formId:o.items[0].formId,type:o.type,tag:"div"},children:w(o.items),key:`layout-${r}`}:(d(void 0,"No layout component provided"),null)}else return d(void 0,"Unknown item type in layout"),null}),p=(n,o,r)=>{r===""&&(r=null),t.forms={...t.forms,[n]:{...t.forms[n]||{},[o]:r===""?null:r}}},_=(n,o,r)=>{t.messages={...t.messages,[n]:{...t.messages[n]||{},[o]:r}}},b=async n=>{try{t.loading=!0;const o=await m?.submitForm(n,J(t.forms[n]));await k(o),t.loading=!1}catch(o){o instanceof S?a.onfallback?.(o):a.onerror?.(o)}},k=async n=>{if(await l.isAuthenticated)a.onlogin?.(l.idTokenClaims);else{const o=JSON.parse(JSON.stringify(t.state)),r={hostedUrl:n?.hostedUrl??t.state.hostedUrl,finalizeUrl:n?.finalizeUrl??t.state.finalizeUrl,screen:n?.screen??t.state.screen,forms:n?.forms??t.state.forms,layout:n?.layout??t.state.layout,messages:n?.messages??{},branding:n?.branding??t.state.branding};if(r.screen!==t.state.screen){t.forms={},t.messages={};for(const s of r.forms??[])t.forms[s.id]={},t.messages[s.id]={}}else l.logging?.info(`Updating screen: ${r.screen}`);Object.keys(r.messages??{}).forEach(s=>{s==="global"?a.onglobalmessage?.(r.messages?.global?.text??""):t.messages[s]=r.messages[s]}),t.state=r,setTimeout(()=>{a.onblockready?.({previousState:o,state:JSON.parse(JSON.stringify(r))})},1)}};t.submitForm=b,t.triggerFallback=d,t.triggerClose=U,t.setFormValue=p,t.setMessage=_,O("nativeFlowContext",t),z(async()=>{try{const n=await m?.startSession(h());n&&await k(n)}catch(n){n instanceof S?a.onfallback?.(n):a.onerror?.(n)}});let C=e.derived(()=>t.state.screen&&a.widgets?.layout?w(t.state.layout?.items??[]):[]);var y=R(),g=e.child(y);{var f=n=>{const o=e.derived(()=>a.widgets?.layout);var r=e.comment(),s=e.first_child(r);{let i=e.derived(()=>t.state.layout?.type);e.component(s,()=>e.get(o),(u,c)=>{c(u,{get formId(){return t.state.layout?.items[0].formId},get type(){return e.get(i)},tag:"form",children:(I,N)=>{x(I,()=>e.get(C))},$$slots:{default:!0}})})}e.append(n,r)},v=n=>{var o=e.comment(),r=e.first_child(o);{var s=i=>{const u=e.derived(()=>a.widgets?.loading);var c=e.comment(),I=e.first_child(c);e.component(I,()=>e.get(u),(N,L)=>{L(N,{})}),e.append(i,c)};e.if(r,i=>{a.widgets?.loading&&i(s)},!0)}e.append(n,o)};e.if(g,n=>{t.state.screen&&a.widgets?.layout?n(f):n(v,!1)})}e.reset(y),e.append(F,y),e.pop()}export{P as default};
|
|
2
|
+
//# sourceMappingURL=LoginRenderer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoginRenderer.mjs","sources":["../src/LoginRenderer.svelte"],"sourcesContent":["<script lang=\"ts\">\n\t/* eslint-disable @typescript-eslint/no-explicit-any */\n\timport type {\n\t\tNativeParams,\n\t\tPartialRecord,\n\t\tWidgetType,\n\t\tLayoutWidget,\n\t\tLoginFlowState,\n\t\tWidget,\n\t\tIdTokenClaims,\n\t\tLoginFlowMessage,\n\t} from '@strivacity/sdk-core';\n\timport type { NativeContext, NativeFlowContextValue } from './types';\n\timport type { Component } from 'svelte';\n\timport { setContext, onMount } from 'svelte';\n\timport { FallbackError } from '@strivacity/sdk-core';\n\timport { unflattenObject } from '@strivacity/sdk-core/utils/object';\n\timport { useStrivacity } from './composables';\n\n\tlet {\n\t\tparams,\n\t\twidgets,\n\t\tsessionId = null,\n\t\tonlogin,\n\t\tonfallback,\n\t\tonclose,\n\t\tonerror,\n\t\tonglobalmessage,\n\t\tonblockready,\n\t}: {\n\t\tparams?: NativeParams;\n\t\twidgets?: PartialRecord<WidgetType, Component>;\n\t\tsessionId?: string | null;\n\t\tonlogin?: (claims?: IdTokenClaims | null) => void;\n\t\tonfallback?: (error: FallbackError) => void;\n\t\tonclose?: () => void;\n\t\tonerror?: (error: any) => void;\n\t\tonglobalmessage?: (message: string) => void;\n\t\tonblockready?: ({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }) => void;\n\t} = $props();\n\n\tconst { sdk } = useStrivacity<NativeContext>();\n\t// svelte-ignore state_referenced_locally\n\tconst loginHandler = sdk.login(params);\n\tconst context = $state<NativeFlowContextValue>({\n\t\tloading: false,\n\t\tforms: {},\n\t\tmessages: {},\n\t\tstate: {},\n\t\tsubmitForm: async () => {},\n\t\ttriggerFallback: () => {},\n\t\ttriggerClose: () => {},\n\t\tsetFormValue: () => {},\n\t\tsetMessage: () => {},\n\t});\n\n\tconst triggerFallback = (hostedUrl?: string, message?: string) => {\n\t\tconst url = hostedUrl || context.state.hostedUrl;\n\n\t\tsdk.logging?.warn(message ? `Triggering fallback due to: ${message}` : 'Triggering fallback');\n\n\t\tif (!url) {\n\t\t\tconst error = new Error('No hosted URL provided');\n\t\t\tsdk.logging?.error('Fallback error', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tonfallback?.(new FallbackError(new URL(url)));\n\t};\n\n\tconst triggerClose = () => {\n\t\tonclose?.();\n\t};\n\n\tconst renderWidgets = (items: LayoutWidget['items']): Array<any> => {\n\t\treturn items.map((item, idx) => {\n\t\t\tif (item.type === 'widget') {\n\t\t\t\tconst form = context.state.forms?.find((f: any) => f.id === item.formId);\n\t\t\t\tconst widget = form?.widgets.find((w: any) => w.id === item.widgetId);\n\n\t\t\t\tif (!form || !widget) {\n\t\t\t\t\ttriggerFallback(undefined, `Unable to find form or widget for item: formId=${item.formId}, widgetId=${item.widgetId}`);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst WidgetComponent = widgets?.[widget.type as keyof typeof widgets];\n\n\t\t\t\tif (!WidgetComponent) {\n\t\t\t\t\ttriggerFallback(undefined, `No component found for widget type ${widget.type}`);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcomponent: WidgetComponent,\n\t\t\t\t\tprops: { formId: form.id, config: widget },\n\t\t\t\t\tkey: `${form.id}.${widget.id}`,\n\t\t\t\t};\n\t\t\t} else if (item.type === 'vertical' || item.type === 'horizontal') {\n\t\t\t\tconst LayoutComponent = widgets?.layout;\n\n\t\t\t\tif (!LayoutComponent) {\n\t\t\t\t\ttriggerFallback(undefined, 'No layout component provided');\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcomponent: LayoutComponent,\n\t\t\t\t\tprops: { formId: (item.items[0] as Widget).formId, type: item.type, tag: 'div' },\n\t\t\t\t\tchildren: renderWidgets(item.items),\n\t\t\t\t\tkey: `layout-${idx}`,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\ttriggerFallback(undefined, 'Unknown item type in layout');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t});\n\t};\n\n\tconst setFormValue = (formId: string, widgetId: string, value: unknown) => {\n\t\tif (value === '') {\n\t\t\tvalue = null;\n\t\t}\n\n\t\tcontext.forms = {\n\t\t\t...context.forms,\n\t\t\t[formId]: { ...(context.forms[formId] || {}), [widgetId]: value === '' ? null : value },\n\t\t};\n\t};\n\n\tconst setMessage = (formId: string, widgetId: string, value: LoginFlowMessage) => {\n\t\tcontext.messages = {\n\t\t\t...context.messages,\n\t\t\t[formId]: { ...(context.messages[formId] || {}), [widgetId]: value },\n\t\t};\n\t};\n\n\tconst submitForm = async (formId: string) => {\n\t\ttry {\n\t\t\tcontext.loading = true;\n\n\t\t\tconst data = await loginHandler?.submitForm(formId, unflattenObject(context.forms[formId]));\n\t\t\tawait handleResponse(data);\n\n\t\t\tcontext.loading = false;\n\t\t} catch (error) {\n\t\t\tif (error instanceof FallbackError) {\n\t\t\t\tonfallback?.(error);\n\t\t\t} else {\n\t\t\t\tonerror?.(error);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleResponse = async (data?: LoginFlowState) => {\n\t\tif (await sdk.isAuthenticated) {\n\t\t\tonlogin?.(sdk.idTokenClaims);\n\t\t} else {\n\t\t\tconst previousState = JSON.parse(JSON.stringify(context.state));\n\t\t\tconst newState: LoginFlowState = {\n\t\t\t\thostedUrl: data?.hostedUrl ?? context.state.hostedUrl,\n\t\t\t\tfinalizeUrl: data?.finalizeUrl ?? context.state.finalizeUrl,\n\t\t\t\tscreen: data?.screen ?? context.state.screen,\n\t\t\t\tforms: data?.forms ?? context.state.forms,\n\t\t\t\tlayout: data?.layout ?? context.state.layout,\n\t\t\t\tmessages: data?.messages ?? {},\n\t\t\t\tbranding: data?.branding ?? context.state.branding,\n\t\t\t};\n\n\t\t\tif (newState.screen !== context.state.screen) {\n\t\t\t\tcontext.forms = {};\n\t\t\t\tcontext.messages = {};\n\n\t\t\t\tfor (const form of newState.forms ?? []) {\n\t\t\t\t\tcontext.forms[form.id] = {};\n\t\t\t\t\tcontext.messages[form.id] = {};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsdk.logging?.info(`Updating screen: ${newState.screen}`);\n\t\t\t}\n\n\t\t\tObject.keys(newState.messages ?? {}).forEach((formId) => {\n\t\t\t\tif (formId === 'global') {\n\t\t\t\t\tonglobalmessage?.(newState.messages?.global?.text ?? '');\n\t\t\t\t} else {\n\t\t\t\t\tcontext.messages[formId] = newState.messages![formId];\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tcontext.state = newState;\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tonblockready?.({ previousState, state: JSON.parse(JSON.stringify(newState)) });\n\t\t\t}, 1);\n\t\t}\n\t};\n\n\tcontext.submitForm = submitForm;\n\tcontext.triggerFallback = triggerFallback;\n\tcontext.triggerClose = triggerClose;\n\tcontext.setFormValue = setFormValue;\n\tcontext.setMessage = setMessage;\n\n\tsetContext('nativeFlowContext', context);\n\n\tonMount(async () => {\n\t\ttry {\n\t\t\tconst data = await loginHandler?.startSession(sessionId);\n\n\t\t\tif (data) {\n\t\t\t\tawait handleResponse(data);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof FallbackError) {\n\t\t\t\tonfallback?.(error);\n\t\t\t} else {\n\t\t\t\tonerror?.(error);\n\t\t\t}\n\t\t}\n\t});\n\n\tlet renderedWidgets = $derived(context.state.screen && widgets?.layout ? renderWidgets(context.state.layout?.items ?? []) : []);\n</script>\n\n{#snippet renderItems(items: any[])}\n\t{#each items as item (item?.key)}\n\t\t{#if item}\n\t\t\t{@const Component = item.component}\n\t\t\t{#if item.children}\n\t\t\t\t<Component {...item.props}>\n\t\t\t\t\t{@render renderItems(item.children)}\n\t\t\t\t</Component>\n\t\t\t{:else}\n\t\t\t\t<Component {...item.props} />\n\t\t\t{/if}\n\t\t{/if}\n\t{/each}\n{/snippet}\n\n<div class=\"login-renderer\">\n\t{#if context.state.screen && widgets?.layout}\n\t\t{@const LayoutComponent = widgets?.layout}\n\t\t<LayoutComponent formId={(context.state.layout?.items[0] as Widget).formId} type={context.state.layout?.type} tag=\"form\">\n\t\t\t{@render renderItems(renderedWidgets)}\n\t\t</LayoutComponent>\n\t{:else if widgets?.loading}\n\t\t{@const LoadingComponent = widgets?.loading}\n\t\t<LoadingComponent />\n\t{/if}\n</div>\n"],"names":["renderItems","items","$","node","item","Component","Component_1","$$anchor","Component_2","$$render","consequent","alternate","consequent_1","sessionId","sdk","useStrivacity","loginHandler","$$props","context","triggerFallback","hostedUrl","message","url","error","FallbackError","triggerClose","renderWidgets","idx","form","f","widget","w","WidgetComponent","LayoutComponent","setFormValue","formId","widgetId","value","setMessage","submitForm","data","unflattenObject","handleResponse","previousState","newState","setContext","onMount","renderedWidgets","div","root","$0","LayoutComponent_1","LoadingComponent","LoadingComponent_1","consequent_3","consequent_2","alternate_1"],"mappings":"8SA+NU,MAAAA,KAAYC,EAAYC,EAAA,OAAA,sCAC1BA,EAAA,KAAAC,EAAA,GAAAF,EAASG,GAAMA,GAAM,OAAZA,IAAI,uDAEVC,EAASH,EAAA,QAAA,IAAAA,EAAA,IAAGE,CAAI,EAAC,SAAS,0HAEhCE,EAASC,EAAAL,EAAA,aAAA,IAAAA,EAAA,IAAKE,CAAI,EAAC,MAAK,kBACfJ,EAAWO,EAAA,IAAAL,EAAA,IAACE,CAAI,EAAC,QAAQ,0HAGlCI,EAASD,EAAAL,EAAA,aAAA,IAAAA,EAAA,IAAKE,CAAI,EAAC,KAAK,CAAA,8BALrBF,EAAA,IAAAE,CAAI,EAAC,SAAQK,EAAAC,CAAA,EAAAD,EAAAE,EAAA,EAAA,oCAFdP,CAAI,GAAAK,EAAAG,CAAA,6GAjOX,cAsBE,IAAAC,yBAAY,IAAI,EAmBT,KAAA,CAAA,IAAAC,CAAG,EAAKC,EAAa,EAEvBC,EAAeF,EAAI,MAAKG,EAAA,MAAA,EACxBC,EAAOhB,EAAA,MAAA,CACZ,QAAS,GACT,MAAK,CAAA,EACL,SAAQ,CAAA,EACR,MAAK,CAAA,EACL,WAAU,SAAc,CAAC,EACzB,gBAAe,IAAQ,CAAC,EACxB,aAAY,IAAQ,CAAC,EACrB,aAAY,IAAQ,CAAC,EACrB,WAAU,IAAQ,CAAC,IAGdiB,EAAe,CAAIC,EAAoBC,IAAqB,CAC3D,MAAAC,EAAMF,GAAaF,EAAQ,MAAM,UAIlC,GAFLJ,EAAI,SAAS,KAAKO,iCAAyCA,CAAO,GAAK,qBAAqB,EAEvF,CAAAC,EAAK,OACHC,EAAK,IAAO,MAAM,wBAAwB,EAChD,MAAAT,EAAI,SAAS,MAAM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@
|
|
|
1
|
+
export { SvelteComponent as default } from 'svelte';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("svelte"),e=Symbol("sty"),o=()=>{const t=r.getContext(e);if(!t)throw new Error("Missing Strivacity SDK context");return t};exports.STRIVACITY_SDK=e;exports.useStrivacity=o;
|
|
2
|
+
//# sourceMappingURL=composables.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables.cjs","sources":["../src/composables.ts"],"sourcesContent":["import { getContext } from 'svelte';\nimport type { PopupContext, RedirectContext, NativeContext } from './types';\n\nexport const STRIVACITY_SDK = Symbol('sty');\n\n/**\n * Hook to access the Strivacity SDK context\n *\n * @template T Extends either PopupContext, RedirectContext or NativeContext.\n *\n * @returns {T} The current Strivacity SDK context.\n *\n * @throws {Error} If the context is not provided by an AuthProvider.\n */\nexport const useStrivacity = <T extends PopupContext | RedirectContext | NativeContext>() => {\n\tconst context = getContext<T>(STRIVACITY_SDK);\n\n\tif (!context) {\n\t\tthrow new Error('Missing Strivacity SDK context');\n\t}\n\n\treturn context;\n};\n"],"names":["STRIVACITY_SDK","useStrivacity","context","getContext"],"mappings":"0GAGaA,EAAiB,OAAO,KAAK,EAW7BC,EAAgB,IAAgE,CAC5F,MAAMC,EAAUC,EAAAA,WAAcH,CAAc,EAE5C,GAAI,CAACE,EACJ,MAAM,IAAI,MAAM,gCAAgC,EAGjD,OAAOA,CACR"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PopupContext, RedirectContext, NativeContext } from './types';
|
|
2
|
+
export declare const STRIVACITY_SDK: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* Hook to access the Strivacity SDK context
|
|
5
|
+
*
|
|
6
|
+
* @template T Extends either PopupContext, RedirectContext or NativeContext.
|
|
7
|
+
*
|
|
8
|
+
* @returns {T} The current Strivacity SDK context.
|
|
9
|
+
*
|
|
10
|
+
* @throws {Error} If the context is not provided by an AuthProvider.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useStrivacity: <T extends PopupContext | RedirectContext | NativeContext>() => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables.mjs","sources":["../src/composables.ts"],"sourcesContent":["import { getContext } from 'svelte';\nimport type { PopupContext, RedirectContext, NativeContext } from './types';\n\nexport const STRIVACITY_SDK = Symbol('sty');\n\n/**\n * Hook to access the Strivacity SDK context\n *\n * @template T Extends either PopupContext, RedirectContext or NativeContext.\n *\n * @returns {T} The current Strivacity SDK context.\n *\n * @throws {Error} If the context is not provided by an AuthProvider.\n */\nexport const useStrivacity = <T extends PopupContext | RedirectContext | NativeContext>() => {\n\tconst context = getContext<T>(STRIVACITY_SDK);\n\n\tif (!context) {\n\t\tthrow new Error('Missing Strivacity SDK context');\n\t}\n\n\treturn context;\n};\n"],"names":["STRIVACITY_SDK","useStrivacity","context","getContext"],"mappings":"oCAGO,MAAMA,EAAiB,OAAO,KAAK,EAW7BC,EAAgB,IAAgE,CAC5F,MAAMC,EAAUC,EAAcH,CAAc,EAE5C,GAAI,CAACE,EACJ,MAAM,IAAI,MAAM,gCAAgC,EAGjD,OAAOA,CACR"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@strivacity/sdk-core"),i=require("@strivacity/sdk-core/utils/HttpClient"),o=require("@strivacity/sdk-core/utils/Logging"),n=require("@strivacity/sdk-core/storages/LocalStorage"),u=require("@strivacity/sdk-core/storages/SessionStorage"),t=require("@strivacity/sdk-core/utils/credentials"),a=require("./composables.cjs"),c=require("./AuthProvider.cjs"),g=require("./LoginRenderer.cjs");require("svelte");require("svelte/internal/disclose-version");require("svelte/internal/client");require("@strivacity/sdk-core/utils/object");Object.defineProperty(exports,"HttpClient",{enumerable:!0,get:()=>i.HttpClient});Object.defineProperty(exports,"DefaultLogging",{enumerable:!0,get:()=>o.DefaultLogging});Object.defineProperty(exports,"LocalStorage",{enumerable:!0,get:()=>n.LocalStorage});Object.defineProperty(exports,"SessionStorage",{enumerable:!0,get:()=>u.SessionStorage});Object.defineProperty(exports,"createCredential",{enumerable:!0,get:()=>t.createCredential});Object.defineProperty(exports,"getCredential",{enumerable:!0,get:()=>t.getCredential});exports.useStrivacity=a.useStrivacity;exports.StyAuthProvider=c;exports.StyLoginRenderer=g;Object.keys(r).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from '@strivacity/sdk-core';
|
|
2
|
+
export type * from './types';
|
|
3
|
+
export type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';
|
|
4
|
+
export type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';
|
|
5
|
+
export type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';
|
|
6
|
+
export { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';
|
|
7
|
+
export { DefaultLogging } from '@strivacity/sdk-core/utils/Logging';
|
|
8
|
+
export { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';
|
|
9
|
+
export { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';
|
|
10
|
+
export { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';
|
|
11
|
+
export { useStrivacity } from './composables';
|
|
12
|
+
export { default as StyAuthProvider } from './AuthProvider.svelte';
|
|
13
|
+
export { default as StyLoginRenderer } from './LoginRenderer.svelte';
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export*from"@strivacity/sdk-core";import{HttpClient as a}from"@strivacity/sdk-core/utils/HttpClient";import{DefaultLogging as x}from"@strivacity/sdk-core/utils/Logging";import{LocalStorage as l}from"@strivacity/sdk-core/storages/LocalStorage";import{SessionStorage as d}from"@strivacity/sdk-core/storages/SessionStorage";import{createCredential as s,getCredential as u}from"@strivacity/sdk-core/utils/credentials";import{useStrivacity as y}from"./composables.mjs";import{default as L}from"./AuthProvider.mjs";import{default as h}from"./LoginRenderer.mjs";import"svelte";import"svelte/internal/disclose-version";import"svelte/internal/client";import"@strivacity/sdk-core/utils/object";export{x as DefaultLogging,a as HttpClient,l as LocalStorage,d as SessionStorage,L as StyAuthProvider,h as StyLoginRenderer,s as createCredential,u as getCredential,y as useStrivacity};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { IdTokenClaims, LoginFlowMessage, LoginFlowState, SDKOptions } from '@strivacity/sdk-core';
|
|
2
|
+
import { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';
|
|
3
|
+
import { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';
|
|
4
|
+
import { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';
|
|
5
|
+
/**
|
|
6
|
+
* Represents the session state, including authentication details and token information.
|
|
7
|
+
*/
|
|
8
|
+
export type State = {
|
|
9
|
+
/**
|
|
10
|
+
* Indicates if the session is being loaded.
|
|
11
|
+
*/
|
|
12
|
+
loading: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The SDK options used to configure the session.
|
|
15
|
+
*/
|
|
16
|
+
options: SDKOptions;
|
|
17
|
+
/**
|
|
18
|
+
* Indicates whether the user is authenticated.
|
|
19
|
+
*/
|
|
20
|
+
isAuthenticated: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Claims from the ID token or `null` if not available.
|
|
23
|
+
*/
|
|
24
|
+
idTokenClaims: IdTokenClaims | null;
|
|
25
|
+
/**
|
|
26
|
+
* The access token or `null` if not available.
|
|
27
|
+
*/
|
|
28
|
+
accessToken: string | null;
|
|
29
|
+
/**
|
|
30
|
+
* The refresh token or `null` if not available.
|
|
31
|
+
*/
|
|
32
|
+
refreshToken: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Indicates if the access token has expired.
|
|
35
|
+
*/
|
|
36
|
+
accessTokenExpired: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Expiration date of the access token or `null` if not set.
|
|
39
|
+
*/
|
|
40
|
+
accessTokenExpirationDate: number | null;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Represents the available authentication flows and operations for Popup-based interactions.
|
|
44
|
+
*/
|
|
45
|
+
export type PopupSDK = {
|
|
46
|
+
/**
|
|
47
|
+
* Represents the SDK instance.
|
|
48
|
+
*/
|
|
49
|
+
sdk: InstanceType<typeof PopupFlow>;
|
|
50
|
+
/**
|
|
51
|
+
* Initiates the login process.
|
|
52
|
+
*/
|
|
53
|
+
login: InstanceType<typeof PopupFlow>['login'];
|
|
54
|
+
/**
|
|
55
|
+
* Registers a new user.
|
|
56
|
+
*/
|
|
57
|
+
register: InstanceType<typeof PopupFlow>['register'];
|
|
58
|
+
/**
|
|
59
|
+
* Initiates the entry process.
|
|
60
|
+
*/
|
|
61
|
+
entry: InstanceType<typeof PopupFlow>['entry'];
|
|
62
|
+
/**
|
|
63
|
+
* Refreshes the user's session.
|
|
64
|
+
*/
|
|
65
|
+
refresh: InstanceType<typeof PopupFlow>['refresh'];
|
|
66
|
+
/**
|
|
67
|
+
* Revokes the current session tokens.
|
|
68
|
+
*/
|
|
69
|
+
revoke: InstanceType<typeof PopupFlow>['revoke'];
|
|
70
|
+
/**
|
|
71
|
+
* Logs out the user.
|
|
72
|
+
*/
|
|
73
|
+
logout: InstanceType<typeof PopupFlow>['logout'];
|
|
74
|
+
/**
|
|
75
|
+
* Handles the callback after authentication or token exchange.
|
|
76
|
+
*/
|
|
77
|
+
handleCallback: InstanceType<typeof PopupFlow>['handleCallback'];
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Represents the available authentication flows and operations for Redirect-based interactions.
|
|
81
|
+
*/
|
|
82
|
+
export type RedirectSDK = {
|
|
83
|
+
/**
|
|
84
|
+
* Represents the SDK instance.
|
|
85
|
+
*/
|
|
86
|
+
sdk: InstanceType<typeof RedirectFlow>;
|
|
87
|
+
/**
|
|
88
|
+
* Initiates the login process.
|
|
89
|
+
*/
|
|
90
|
+
login: InstanceType<typeof RedirectFlow>['login'];
|
|
91
|
+
/**
|
|
92
|
+
* Registers a new user.
|
|
93
|
+
*/
|
|
94
|
+
register: InstanceType<typeof RedirectFlow>['register'];
|
|
95
|
+
/**
|
|
96
|
+
* Initiates the entry process.
|
|
97
|
+
*/
|
|
98
|
+
entry: InstanceType<typeof RedirectFlow>['entry'];
|
|
99
|
+
/**
|
|
100
|
+
* Refreshes the user's session.
|
|
101
|
+
*/
|
|
102
|
+
refresh: InstanceType<typeof RedirectFlow>['refresh'];
|
|
103
|
+
/**
|
|
104
|
+
* Revokes the current session tokens.
|
|
105
|
+
*/
|
|
106
|
+
revoke: InstanceType<typeof RedirectFlow>['revoke'];
|
|
107
|
+
/**
|
|
108
|
+
* Logs out the user.
|
|
109
|
+
*/
|
|
110
|
+
logout: InstanceType<typeof RedirectFlow>['logout'];
|
|
111
|
+
/**
|
|
112
|
+
* Handles the callback after authentication or token exchange.
|
|
113
|
+
*/
|
|
114
|
+
handleCallback: InstanceType<typeof RedirectFlow>['handleCallback'];
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Represents the available authentication flows and operations for Native-based interactions.
|
|
118
|
+
*/
|
|
119
|
+
export type NativeSDK = {
|
|
120
|
+
/**
|
|
121
|
+
* Represents the SDK instance.
|
|
122
|
+
*/
|
|
123
|
+
sdk: InstanceType<typeof NativeFlow>;
|
|
124
|
+
/**
|
|
125
|
+
* Initiates the login process.
|
|
126
|
+
*/
|
|
127
|
+
login: InstanceType<typeof NativeFlow>['login'];
|
|
128
|
+
/**
|
|
129
|
+
* Registers a new user.
|
|
130
|
+
*/
|
|
131
|
+
register: InstanceType<typeof NativeFlow>['register'];
|
|
132
|
+
/**
|
|
133
|
+
* Initiates the entry process.
|
|
134
|
+
*/
|
|
135
|
+
entry: InstanceType<typeof NativeFlow>['entry'];
|
|
136
|
+
/**
|
|
137
|
+
* Refreshes the user's session.
|
|
138
|
+
*/
|
|
139
|
+
refresh: InstanceType<typeof NativeFlow>['refresh'];
|
|
140
|
+
/**
|
|
141
|
+
* Revokes the current session tokens.
|
|
142
|
+
*/
|
|
143
|
+
revoke: InstanceType<typeof NativeFlow>['revoke'];
|
|
144
|
+
/**
|
|
145
|
+
* Logs out the user.
|
|
146
|
+
*/
|
|
147
|
+
logout: InstanceType<typeof NativeFlow>['logout'];
|
|
148
|
+
/**
|
|
149
|
+
* Handles the callback after authentication or token exchange.
|
|
150
|
+
*/
|
|
151
|
+
handleCallback: InstanceType<typeof NativeFlow>['handleCallback'];
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Represents a combined context for Popup-based flows, containing both the Popup SDK and the session state.
|
|
155
|
+
*/
|
|
156
|
+
export type PopupContext = PopupSDK & {
|
|
157
|
+
state: State;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Represents a combined context for Redirect-based flows, containing both the Redirect SDK and the session state.
|
|
161
|
+
*/
|
|
162
|
+
export type RedirectContext = RedirectSDK & {
|
|
163
|
+
state: State;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Represents a combined context for Native-based flows, containing both the Native SDK and the session state.
|
|
167
|
+
*/
|
|
168
|
+
export type NativeContext = NativeSDK & {
|
|
169
|
+
state: State;
|
|
170
|
+
};
|
|
171
|
+
export type NativeFlowContextValue = {
|
|
172
|
+
loading: boolean;
|
|
173
|
+
forms: Record<string, Record<string, unknown>>;
|
|
174
|
+
messages: Record<string, Record<string, LoginFlowMessage>>;
|
|
175
|
+
state: Partial<LoginFlowState>;
|
|
176
|
+
submitForm: (formId: string) => Promise<void>;
|
|
177
|
+
triggerFallback: (hostedUrl?: string) => void;
|
|
178
|
+
triggerClose: () => void;
|
|
179
|
+
setFormValue: (formId: string, widgetId: string, value: unknown) => void;
|
|
180
|
+
setMessage: (formId: string, widgetId: string, value: LoginFlowMessage) => void;
|
|
181
|
+
};
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@strivacity/sdk-svelte",
|
|
3
|
+
"version": "2.1.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Strivacity Svelte SDK client",
|
|
6
|
+
"author": "strivacity <opensource@strivacity.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/Strivacity/sdk-js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@strivacity/sdk-core": "2.1.2"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"svelte": ">=5"
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/index.cjs",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.mjs",
|
|
23
|
+
"require": "./dist/index.cjs",
|
|
24
|
+
"default": "./dist/index.mjs"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|