@crossauth/sveltekit 0.0.15 → 0.0.16
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/dist/index.cjs +1 -1
- package/dist/index.js +259 -147
- package/dist/sveltekitoauthclient.d.ts +49 -3
- package/dist/tests/sveltekitoauthclient.test.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CrossauthError, ErrorCode, OAuthTokenResponse, OAuthDeviceAuthorizationResponse } from '@crossauth/common';
|
|
1
|
+
import { CrossauthError, ErrorCode, OAuthTokenResponse, OAuthDeviceAuthorizationResponse, User } from '@crossauth/common';
|
|
2
2
|
import { OAuthClientBackend, OAuthClientOptions } from '@crossauth/backend';
|
|
3
3
|
import { SvelteKitServer } from './sveltekitserver';
|
|
4
4
|
import { RequestEvent, MaybePromise } from '@sveltejs/kit';
|
|
@@ -54,9 +54,13 @@ export interface SvelteKitOAuthClientOptions extends OAuthClientOptions {
|
|
|
54
54
|
* @param client the OAuth client
|
|
55
55
|
* @param event the SvelteKit request event
|
|
56
56
|
* @param silent if true, don't return a Response, only JSON or undefined.
|
|
57
|
+
* @param setUserFn if implementing this function you should call this
|
|
58
|
+
* when you receive a valid ID token
|
|
57
59
|
* @returns a Response, JSON or undefined
|
|
58
60
|
*/
|
|
59
|
-
receiveTokenFn?: (oauthResponse: OAuthTokenResponse, client: SvelteKitOAuthClient, event: RequestEvent, silent: boolean
|
|
61
|
+
receiveTokenFn?: (oauthResponse: OAuthTokenResponse, client: SvelteKitOAuthClient, event: RequestEvent, silent: boolean, setUserFn: (event: RequestEvent, token: {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
}) => Promise<void>) => Promise<Response | TokenReturn | undefined>;
|
|
60
64
|
/**
|
|
61
65
|
* The function to call when there is an OAuth error and
|
|
62
66
|
* {@link SvelteKitOAuthClientOptions.errorResponseType}
|
|
@@ -354,6 +358,15 @@ export declare class SvelteKitOAuthClient extends OAuthClientBackend {
|
|
|
354
358
|
* @param options See {@link SvelteKitOAuthClientOptions}
|
|
355
359
|
*/
|
|
356
360
|
constructor(server: SvelteKitServer, authServerBaseUrl: string, options: SvelteKitOAuthClientOptions);
|
|
361
|
+
/**
|
|
362
|
+
* If you implement your own function to receive tokens and you use BFF,
|
|
363
|
+
* use this function to set `event.locals.user`.
|
|
364
|
+
* @param event the Sveltekit request event
|
|
365
|
+
* @param token the ID token
|
|
366
|
+
*/
|
|
367
|
+
setEventLocalsUser(event: RequestEvent, token: {
|
|
368
|
+
[key: string]: any;
|
|
369
|
+
}): Promise<void>;
|
|
357
370
|
private passwordPost;
|
|
358
371
|
private passwordMfa;
|
|
359
372
|
private passwordOtp;
|
|
@@ -470,6 +483,17 @@ export declare class SvelteKitOAuthClient extends OAuthClientBackend {
|
|
|
470
483
|
access_token?: string | undefined;
|
|
471
484
|
refresh_token?: string | undefined;
|
|
472
485
|
id_token?: string | undefined;
|
|
486
|
+
/**
|
|
487
|
+
* This function is called after successful authorization to pass the
|
|
488
|
+
* new tokens to.
|
|
489
|
+
* @param oauthResponse the response from the OAuth `token` endpoint.
|
|
490
|
+
* @param client the OAuth client
|
|
491
|
+
* @param event the SvelteKit request event
|
|
492
|
+
* @param silent if true, don't return a Response, only JSON or undefined.
|
|
493
|
+
* @param setUserFn if implementing this function you should call this
|
|
494
|
+
* when you receive a valid ID token
|
|
495
|
+
* @returns a Response, JSON or undefined
|
|
496
|
+
*/
|
|
473
497
|
token_type?: string | undefined;
|
|
474
498
|
expires_in?: number | undefined;
|
|
475
499
|
error?: string | undefined;
|
|
@@ -494,6 +518,17 @@ export declare class SvelteKitOAuthClient extends OAuthClientBackend {
|
|
|
494
518
|
access_token?: string | undefined;
|
|
495
519
|
refresh_token?: string | undefined;
|
|
496
520
|
id_token?: string | undefined;
|
|
521
|
+
/**
|
|
522
|
+
* This function is called after successful authorization to pass the
|
|
523
|
+
* new tokens to.
|
|
524
|
+
* @param oauthResponse the response from the OAuth `token` endpoint.
|
|
525
|
+
* @param client the OAuth client
|
|
526
|
+
* @param event the SvelteKit request event
|
|
527
|
+
* @param silent if true, don't return a Response, only JSON or undefined.
|
|
528
|
+
* @param setUserFn if implementing this function you should call this
|
|
529
|
+
* when you receive a valid ID token
|
|
530
|
+
* @returns a Response, JSON or undefined
|
|
531
|
+
*/
|
|
497
532
|
token_type?: string | undefined;
|
|
498
533
|
expires_in?: number | undefined;
|
|
499
534
|
error?: string | undefined;
|
|
@@ -516,6 +551,17 @@ export declare class SvelteKitOAuthClient extends OAuthClientBackend {
|
|
|
516
551
|
access_token?: string | undefined;
|
|
517
552
|
refresh_token?: string | undefined;
|
|
518
553
|
id_token?: string | undefined;
|
|
554
|
+
/**
|
|
555
|
+
* This function is called after successful authorization to pass the
|
|
556
|
+
* new tokens to.
|
|
557
|
+
* @param oauthResponse the response from the OAuth `token` endpoint.
|
|
558
|
+
* @param client the OAuth client
|
|
559
|
+
* @param event the SvelteKit request event
|
|
560
|
+
* @param silent if true, don't return a Response, only JSON or undefined.
|
|
561
|
+
* @param setUserFn if implementing this function you should call this
|
|
562
|
+
* when you receive a valid ID token
|
|
563
|
+
* @returns a Response, JSON or undefined
|
|
564
|
+
*/
|
|
519
565
|
token_type?: string | undefined;
|
|
520
566
|
expires_in?: number | undefined;
|
|
521
567
|
error?: string | undefined;
|
|
@@ -545,7 +591,7 @@ export declare class SvelteKitOAuthClient extends OAuthClientBackend {
|
|
|
545
591
|
errorMessage?: undefined;
|
|
546
592
|
} | {
|
|
547
593
|
ok: boolean;
|
|
548
|
-
user:
|
|
594
|
+
user: User | undefined;
|
|
549
595
|
csrfToken: string | undefined;
|
|
550
596
|
errorCode: ErrorCode;
|
|
551
597
|
errorCodeName: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossauth/sveltekit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"minimatch": "^10.0.1",
|
|
47
47
|
"qrcode": "^1.5.4",
|
|
48
48
|
"vite-plugin-dts": "^3.6.4",
|
|
49
|
-
"@crossauth/common": "^0.0.
|
|
50
|
-
"@crossauth/backend": "^0.0.
|
|
49
|
+
"@crossauth/common": "^0.0.16",
|
|
50
|
+
"@crossauth/backend": "^0.0.16"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"dev": "vite dev",
|