@crossauth/sveltekit 1.1.0 → 1.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/dist/index.d.ts +5 -5
- package/dist/index.js +16 -6181
- package/dist/sveltekitadminclientendpoints.d.ts +31 -30
- package/dist/sveltekitadminclientendpoints.js +187 -0
- package/dist/sveltekitadminendpoints.d.ts +106 -77
- package/dist/sveltekitadminendpoints.js +776 -0
- package/dist/sveltekitapikey.d.ts +4 -4
- package/dist/sveltekitapikey.js +81 -0
- package/dist/sveltekitoauthclient.d.ts +6 -5
- package/dist/sveltekitoauthclient.js +2309 -0
- package/dist/sveltekitoauthserver.d.ts +11 -11
- package/dist/sveltekitoauthserver.js +1350 -0
- package/dist/sveltekitresserver.d.ts +6 -5
- package/dist/sveltekitresserver.js +286 -0
- package/dist/sveltekitserver.d.ts +11 -10
- package/dist/sveltekitserver.js +393 -0
- package/dist/sveltekitsession.d.ts +5 -5
- package/dist/sveltekitsession.js +1112 -0
- package/dist/sveltekitsessionadapter.d.ts +2 -3
- package/dist/sveltekitsessionadapter.js +2 -0
- package/dist/sveltekitsharedclientendpoints.d.ts +38 -30
- package/dist/sveltekitsharedclientendpoints.js +635 -0
- package/dist/sveltekituserclientendpoints.d.ts +31 -30
- package/dist/sveltekituserclientendpoints.js +270 -0
- package/dist/sveltekituserendpoints.d.ts +220 -113
- package/dist/sveltekituserendpoints.js +1836 -0
- package/dist/tests/sveltekitadminclientendpoints.test.js +330 -0
- package/dist/tests/sveltekitadminendpoints.test.js +242 -0
- package/dist/tests/sveltekitapikeyserver.test.js +44 -0
- package/dist/tests/sveltekitoauthclient.test.d.ts +5 -5
- package/dist/tests/sveltekitoauthclient.test.js +1016 -0
- package/dist/tests/sveltekitoauthresserver.test.d.ts +4 -4
- package/dist/tests/sveltekitoauthresserver.test.js +185 -0
- package/dist/tests/sveltekitoauthserver.test.js +673 -0
- package/dist/tests/sveltekituserclientendpoints.test.js +244 -0
- package/dist/tests/sveltekituserendpoints.test.js +152 -0
- package/dist/tests/sveltemock.test.js +36 -0
- package/dist/tests/sveltemocks.d.ts +2 -3
- package/dist/tests/sveltemocks.js +114 -0
- package/dist/tests/sveltesessionhooks.test.js +224 -0
- package/dist/tests/testshared.d.ts +8 -8
- package/dist/tests/testshared.js +344 -0
- package/dist/utils.d.ts +1 -2
- package/dist/utils.js +123 -0
- package/package.json +6 -4
- package/dist/index.cjs +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { RequestEvent } from '@sveltejs/kit';
|
|
2
|
-
import { User } from '@crossauth/common';
|
|
3
|
-
|
|
1
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import type { User } from '@crossauth/common';
|
|
4
3
|
export declare abstract class SvelteKitSessionAdapter {
|
|
5
4
|
abstract csrfProtectionEnabled(): boolean;
|
|
6
5
|
abstract getCsrfToken(event: RequestEvent): string | undefined;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { SvelteKitSessionServer
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { SvelteKitSessionServer } from './sveltekitsession';
|
|
2
|
+
import type { SvelteKitSessionServerOptions } from './sveltekitsession';
|
|
3
|
+
import { OAuthClientManager } from '@crossauth/backend';
|
|
4
|
+
import type { OAuthClientStorage } from '@crossauth/backend';
|
|
5
|
+
import type { User, OAuthClient } from '@crossauth/common';
|
|
6
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
7
|
+
/**
|
|
8
|
+
* Base class for all PageData
|
|
9
|
+
*/
|
|
10
|
+
export interface BasePageData {
|
|
11
|
+
user?: User;
|
|
12
|
+
csrfToken?: string;
|
|
13
|
+
}
|
|
6
14
|
/**
|
|
7
15
|
* Return type for {@link SvelteKitUserClientEndpoints.searchClients}
|
|
8
16
|
* {@link SvelteKitAdminClientEndpoints.searchClients} load.
|
|
9
17
|
*
|
|
10
18
|
* See class documentation for {@link SvelteKitSharedClientEndpoints} for more details.
|
|
11
19
|
*/
|
|
12
|
-
export
|
|
20
|
+
export interface SearchClientsPageData extends BasePageData {
|
|
13
21
|
ok: boolean;
|
|
14
22
|
clients?: OAuthClient[];
|
|
15
23
|
skip: number;
|
|
@@ -21,34 +29,34 @@ export type SearchClientsPageData = {
|
|
|
21
29
|
hasPrevious: boolean;
|
|
22
30
|
hasNext: boolean;
|
|
23
31
|
clientUserId?: string | number;
|
|
24
|
-
}
|
|
32
|
+
}
|
|
25
33
|
/**
|
|
26
34
|
* Return type for {@link SvelteKitUserClientEndpoints.updateClientEndpoint}
|
|
27
35
|
* {@link SvelteKitAdminClientEndpoints.updateClientEndpoint} load.
|
|
28
36
|
*
|
|
29
37
|
* See class documentation for {@link SvelteKitSharedClientEndpoints} for more details.
|
|
30
38
|
*/
|
|
31
|
-
export
|
|
32
|
-
ok
|
|
39
|
+
export interface UpdateClientPageData extends BasePageData {
|
|
40
|
+
ok?: boolean;
|
|
33
41
|
client?: OAuthClient;
|
|
34
42
|
client_id?: string;
|
|
35
43
|
clientUsername?: string;
|
|
36
44
|
error?: string;
|
|
37
45
|
errorCode?: number;
|
|
38
46
|
errorCodeName?: string;
|
|
39
|
-
validFlows
|
|
40
|
-
valid_flowNames
|
|
47
|
+
validFlows?: string[];
|
|
48
|
+
valid_flowNames?: {
|
|
41
49
|
[key: string]: string;
|
|
42
50
|
};
|
|
43
|
-
}
|
|
51
|
+
}
|
|
44
52
|
/**
|
|
45
53
|
* Return type for {@link SvelteKitUserClientEndpoints.updateClientEndpoint}
|
|
46
54
|
* {@link SvelteKitAdminClientEndpoints.updateClientEndpoint} actions.
|
|
47
55
|
*
|
|
48
56
|
* See class documentation for {@link SvelteKitSharedClientEndpoints} for more details.
|
|
49
57
|
*/
|
|
50
|
-
export
|
|
51
|
-
ok
|
|
58
|
+
export interface UpdateClientActionData {
|
|
59
|
+
ok?: boolean;
|
|
52
60
|
client?: OAuthClient;
|
|
53
61
|
error?: string;
|
|
54
62
|
errorCode?: number;
|
|
@@ -57,14 +65,14 @@ export type UpdateClientFormData = {
|
|
|
57
65
|
[key: string]: string;
|
|
58
66
|
};
|
|
59
67
|
plaintextSecret?: string;
|
|
60
|
-
}
|
|
68
|
+
}
|
|
61
69
|
/**
|
|
62
70
|
* Return type for {@link SvelteKitUserClientEndpoints.createClientEndpoint}
|
|
63
71
|
* {@link SvelteKitAdminClientEndpoints.createClient} load.
|
|
64
72
|
*
|
|
65
73
|
* See class documentation for {@link SvelteKitSharedClientEndpoints} for more details.
|
|
66
74
|
*/
|
|
67
|
-
export
|
|
75
|
+
export interface CreateClientPageData extends BasePageData {
|
|
68
76
|
ok: boolean;
|
|
69
77
|
clientUserId?: string | number;
|
|
70
78
|
clientUsername?: string;
|
|
@@ -75,14 +83,14 @@ export type CreateClientPageData = {
|
|
|
75
83
|
valid_flowNames: {
|
|
76
84
|
[key: string]: string;
|
|
77
85
|
};
|
|
78
|
-
}
|
|
86
|
+
}
|
|
79
87
|
/**
|
|
80
88
|
* Return type for {@link SvelteKitUserClientEndpoints.createClientEndpoint}
|
|
81
89
|
* {@link SvelteKitAdminClientEndpoints.createClientEndpoint} actions.
|
|
82
90
|
*
|
|
83
91
|
* See class documentation for {@link SvelteKitSharedClientEndpoints} for more details.
|
|
84
92
|
*/
|
|
85
|
-
export type
|
|
93
|
+
export type CreateClientActionData = {
|
|
86
94
|
ok: boolean;
|
|
87
95
|
client?: OAuthClient;
|
|
88
96
|
error?: string;
|
|
@@ -98,23 +106,23 @@ export type CreateClientFormData = {
|
|
|
98
106
|
*
|
|
99
107
|
* See class documentation for {@link SvelteKitSharedClientEndpoints} for more details.
|
|
100
108
|
*/
|
|
101
|
-
export
|
|
102
|
-
ok
|
|
109
|
+
export interface DeleteClientPageData extends BasePageData {
|
|
110
|
+
ok?: boolean;
|
|
103
111
|
client?: OAuthClient;
|
|
104
112
|
client_id?: string;
|
|
105
113
|
clientUsername?: string;
|
|
106
114
|
error?: string;
|
|
107
115
|
errorCode?: number;
|
|
108
116
|
errorCodeName?: string;
|
|
109
|
-
}
|
|
117
|
+
}
|
|
110
118
|
/**
|
|
111
119
|
* Return type for {@link SvelteKitUserClientEndpoints.deleteClientEndpoint}
|
|
112
120
|
* {@link SvelteKitAdminClientEndpoints.deleteClientEndpoint} actions.
|
|
113
121
|
*
|
|
114
122
|
* See class documentation for {@link SvelteKitSharedClientEndpoints} for more details.
|
|
115
123
|
*/
|
|
116
|
-
export type
|
|
117
|
-
ok
|
|
124
|
+
export type DeleteClientActionData = {
|
|
125
|
+
ok?: boolean;
|
|
118
126
|
error?: string;
|
|
119
127
|
errorCode?: number;
|
|
120
128
|
errorCodeName?: string;
|
|
@@ -242,9 +250,9 @@ export declare class SvelteKitSharedClientEndpoints {
|
|
|
242
250
|
* - `confidential` from the body form data: 1, `on`, `yes` or `true` are true
|
|
243
251
|
* _ `resetSecret` if true (1, `on`, `yes` or `true`), create and return a new secret. Ignored if not confidential
|
|
244
252
|
* - Flow names from {@link @crossauth/common!OAuthFlows} taken from the body form data. 1, `on`, `yes` or `true` are true
|
|
245
|
-
* @returns {@link
|
|
253
|
+
* @returns {@link UpdateClientActionData}. If a new secret was created, it will be placed as plaintext in the client that is returned.
|
|
246
254
|
*/
|
|
247
|
-
protected updateClient_internal(event: RequestEvent, isAdmin: boolean): Promise<
|
|
255
|
+
protected updateClient_internal(event: RequestEvent, isAdmin: boolean): Promise<UpdateClientActionData>;
|
|
248
256
|
/**
|
|
249
257
|
* The base class of the load function for creating an OAuth client.
|
|
250
258
|
*
|
|
@@ -263,9 +271,9 @@ export declare class SvelteKitSharedClientEndpoints {
|
|
|
263
271
|
* - `redirect_uri` from the body form data (space-separated)
|
|
264
272
|
* - `confidential` from the body form data: 1, `on`, `yes` or `true` are true
|
|
265
273
|
* - Flow names from {@link @crossauth/common!OAuthFlows} taken from the body form data. 1, `on`, `yes` or `true` are true
|
|
266
|
-
* @returns {@link
|
|
274
|
+
* @returns {@link UpdateClientActionData}. If a secret was created, it will be placed as plaintext in the client that is returned. A random `client_id` is created.
|
|
267
275
|
*/
|
|
268
|
-
protected createClient_internal(event: RequestEvent, isAdmin: boolean): Promise<
|
|
276
|
+
protected createClient_internal(event: RequestEvent, isAdmin: boolean): Promise<CreateClientActionData>;
|
|
269
277
|
/**
|
|
270
278
|
* The base class of the load function for deleting an OAuth client.
|
|
271
279
|
*
|
|
@@ -279,9 +287,9 @@ export declare class SvelteKitSharedClientEndpoints {
|
|
|
279
287
|
*
|
|
280
288
|
* @param event the Sveltekit request event. The following are taken:
|
|
281
289
|
* - `client_id` from the URL path parameters
|
|
282
|
-
* @returns {@link
|
|
290
|
+
* @returns {@link DeleteClientActionData}
|
|
283
291
|
*/
|
|
284
|
-
protected deleteClient_internal(event: RequestEvent, isAdmin: boolean): Promise<
|
|
292
|
+
protected deleteClient_internal(event: RequestEvent, isAdmin: boolean): Promise<DeleteClientActionData>;
|
|
285
293
|
/**
|
|
286
294
|
* Returned by all endpoitns
|
|
287
295
|
* @param event the sveltekit request event
|
|
@@ -290,7 +298,7 @@ export declare class SvelteKitSharedClientEndpoints {
|
|
|
290
298
|
* - `csrfToken` the CSRF token if using
|
|
291
299
|
*/
|
|
292
300
|
baseEndpoint(event: RequestEvent): {
|
|
293
|
-
user:
|
|
301
|
+
user: User | undefined;
|
|
294
302
|
csrfToken: string | undefined;
|
|
295
303
|
};
|
|
296
304
|
}
|