@crossauth/sveltekit 0.0.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/LICENSE +203 -0
- package/README.md +12 -0
- package/dist/index.cjs +7018 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +7018 -0
- package/dist/sveltekitadminclientendpoints.d.ts +150 -0
- package/dist/sveltekitadminendpoints.d.ts +369 -0
- package/dist/sveltekitapikey.d.ts +48 -0
- package/dist/sveltekitoauthclient.d.ts +704 -0
- package/dist/sveltekitoauthserver.d.ts +406 -0
- package/dist/sveltekitresserver.d.ts +101 -0
- package/dist/sveltekitserver.d.ts +286 -0
- package/dist/sveltekitsession.d.ts +629 -0
- package/dist/sveltekitsessionadapter.d.ts +48 -0
- package/dist/sveltekitsharedclientendpoints.d.ts +289 -0
- package/dist/sveltekituserclientendpoints.d.ts +151 -0
- package/dist/sveltekituserendpoints.d.ts +730 -0
- package/dist/tests/sveltekitadminclientendpoints.test.d.ts +6 -0
- package/dist/tests/sveltekitadminendpoints.test.d.ts +6 -0
- package/dist/tests/sveltekitapikeyserver.test.d.ts +1 -0
- package/dist/tests/sveltekitoauthclient.test.d.ts +11 -0
- package/dist/tests/sveltekitoauthresserver.test.d.ts +10 -0
- package/dist/tests/sveltekitoauthserver.test.d.ts +6 -0
- package/dist/tests/sveltekituserclientendpoints.test.d.ts +6 -0
- package/dist/tests/sveltekituserendpoints.test.d.ts +6 -0
- package/dist/tests/sveltemock.test.d.ts +1 -0
- package/dist/tests/sveltemocks.d.ts +77 -0
- package/dist/tests/sveltesessionhooks.test.d.ts +1 -0
- package/dist/tests/testshared.d.ts +79 -0
- package/dist/utils.d.ts +38 -0
- package/package.json +52 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function oauthLogin(): Promise<{
|
|
2
|
+
server: import('..').SvelteKitServer;
|
|
3
|
+
authServer: import('@crossauth/backend').OAuthAuthorizationServer;
|
|
4
|
+
sessionCookieValue: string | undefined;
|
|
5
|
+
sessionId: string | undefined;
|
|
6
|
+
access_token: any;
|
|
7
|
+
refresh_token: any;
|
|
8
|
+
keyStorage: import('@crossauth/backend').InMemoryKeyStorage;
|
|
9
|
+
userStorage: import('@crossauth/backend').InMemoryUserStorage;
|
|
10
|
+
clientStorage: import('@crossauth/backend').InMemoryOAuthClientStorage;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function oauthLogin(): Promise<{
|
|
2
|
+
server: import('..').SvelteKitServer;
|
|
3
|
+
authServer: import('@crossauth/backend').OAuthAuthorizationServer;
|
|
4
|
+
sessionCookieValue: string | undefined;
|
|
5
|
+
sessionId: string | undefined;
|
|
6
|
+
access_token: any;
|
|
7
|
+
refresh_token: any;
|
|
8
|
+
keyStorage: import('@crossauth/backend').InMemoryKeyStorage;
|
|
9
|
+
userStorage: import('@crossauth/backend').InMemoryUserStorage;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Cookies, RequestEvent, MaybePromise, ResolveOptions } from '@sveltejs/kit';
|
|
2
|
+
import { CookieParseOptions, CookieSerializeOptions } from 'cookie';
|
|
3
|
+
|
|
4
|
+
export declare class MockCookies implements Cookies {
|
|
5
|
+
cookies: {
|
|
6
|
+
[key: string]: {
|
|
7
|
+
value: string;
|
|
8
|
+
opts?: CookieSerializeOptions;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
constructor(cookies: {
|
|
12
|
+
[key: string]: {
|
|
13
|
+
value: string;
|
|
14
|
+
opts?: CookieSerializeOptions;
|
|
15
|
+
};
|
|
16
|
+
}, req?: Request);
|
|
17
|
+
get(name: string, opts?: CookieParseOptions): string | undefined;
|
|
18
|
+
getAll(opts?: CookieParseOptions): Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}>;
|
|
22
|
+
set(name: string, value: string, opts: CookieSerializeOptions & {
|
|
23
|
+
path: string;
|
|
24
|
+
}): void;
|
|
25
|
+
delete(name: string, _opts: CookieSerializeOptions & {
|
|
26
|
+
path: string;
|
|
27
|
+
}): void;
|
|
28
|
+
serialize(name: string, value: string, opts: CookieSerializeOptions & {
|
|
29
|
+
path: string;
|
|
30
|
+
}): string;
|
|
31
|
+
}
|
|
32
|
+
export declare class MockRequestEvent<Params extends Partial<Record<string, string>> = {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
}, RouteId extends string | null = string> implements RequestEvent<Params, RouteId> {
|
|
35
|
+
constructor(id: RouteId, request: Request, params: Params, { isDataRequest, isSubRequest, cookies, baseUrl }?: {
|
|
36
|
+
isDataRequest?: boolean;
|
|
37
|
+
isSubRequest?: boolean;
|
|
38
|
+
cookies?: {
|
|
39
|
+
[key: string]: {
|
|
40
|
+
value: string;
|
|
41
|
+
opts?: CookieSerializeOptions;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
baseUrl?: string;
|
|
45
|
+
});
|
|
46
|
+
cookies: Cookies;
|
|
47
|
+
fetch: typeof fetch;
|
|
48
|
+
getClientAddress(): string;
|
|
49
|
+
locals: App.Locals;
|
|
50
|
+
params: Params;
|
|
51
|
+
platform: Readonly<App.Platform> | undefined;
|
|
52
|
+
request: Request;
|
|
53
|
+
route: {
|
|
54
|
+
id: RouteId;
|
|
55
|
+
};
|
|
56
|
+
headers: {
|
|
57
|
+
[key: string]: string;
|
|
58
|
+
} | undefined;
|
|
59
|
+
setHeaders(headers: Record<string, string>): void;
|
|
60
|
+
url: URL;
|
|
61
|
+
isDataRequest: boolean;
|
|
62
|
+
isSubRequest: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface MockResolveOptions extends ResolveOptions {
|
|
65
|
+
body?: string;
|
|
66
|
+
status?: number;
|
|
67
|
+
statusText?: string;
|
|
68
|
+
}
|
|
69
|
+
type MockResolve = (event: MockRequestEvent, _opts?: ResolveOptions) => MaybePromise<Response>;
|
|
70
|
+
export declare class MockResolver {
|
|
71
|
+
body: string | undefined;
|
|
72
|
+
status: number;
|
|
73
|
+
statusText: string;
|
|
74
|
+
constructor(body: string | undefined, status?: number, statusText?: string);
|
|
75
|
+
mockResolve: MockResolve;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { MockResolver, MockRequestEvent } from './sveltemocks';
|
|
2
|
+
import { SvelteKitServer } from '../sveltekitserver';
|
|
3
|
+
import { OAuthAuthorizationServer, InMemoryKeyStorage, InMemoryUserStorage, InMemoryOAuthClientStorage, LocalPasswordAuthenticator, ApiKeyManager } from '@crossauth/backend';
|
|
4
|
+
import { OpenIdConfiguration, OAuthClient } from '@crossauth/common';
|
|
5
|
+
import { Handle } from '@sveltejs/kit';
|
|
6
|
+
|
|
7
|
+
export declare const oidcConfiguration: OpenIdConfiguration;
|
|
8
|
+
export declare function createUsers(userStorage: InMemoryUserStorage): Promise<void>;
|
|
9
|
+
export declare function createSession(userid: string, userStorage: InMemoryUserStorage, keyStorage: InMemoryKeyStorage, options?: {}): Promise<{
|
|
10
|
+
key: import('@crossauth/common').Key;
|
|
11
|
+
cookie: import('@crossauth/backend').Cookie;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function createClients(clientStorage: InMemoryOAuthClientStorage, secretRequired?: boolean): Promise<OAuthClient>;
|
|
14
|
+
export declare function makeServer(makeSession?: boolean, makeApiKey?: boolean, makeOAuthServer?: boolean, makeOAuthClient?: boolean, options?: {}): Promise<{
|
|
15
|
+
server: SvelteKitServer;
|
|
16
|
+
resolver: MockResolver;
|
|
17
|
+
handle: Handle;
|
|
18
|
+
keyStorage: InMemoryKeyStorage;
|
|
19
|
+
userStorage: InMemoryUserStorage;
|
|
20
|
+
authenticator: LocalPasswordAuthenticator;
|
|
21
|
+
apiKeyManager: ApiKeyManager | undefined;
|
|
22
|
+
clientStorage: InMemoryOAuthClientStorage;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function getCookies(resp: Response): {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function getCsrfToken(server: SvelteKitServer, resolver: MockResolver, handle: Handle): Promise<{
|
|
28
|
+
csrfToken: string | undefined;
|
|
29
|
+
csrfCookieValue: string;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function login(server: SvelteKitServer, resolver: MockResolver, handle: Handle, user?: string, password?: string): Promise<{
|
|
32
|
+
event: MockRequestEvent<{
|
|
33
|
+
param1: string;
|
|
34
|
+
}, "1">;
|
|
35
|
+
ret: import('..').LoginReturn | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export declare function loginFactor2(server: SvelteKitServer, resolver: MockResolver, handle: Handle, sessionCookieValue: string, sessionId: string): Promise<{
|
|
38
|
+
event: MockRequestEvent<{
|
|
39
|
+
param1: string;
|
|
40
|
+
}, "1">;
|
|
41
|
+
ret: import('..').LoginReturn | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
export declare function getAuthServer({ aud, persistAccessToken, emptyScopeIsValid, secretRequired, rollingRefreshToken, }?: {
|
|
44
|
+
challenge?: boolean;
|
|
45
|
+
aud?: string;
|
|
46
|
+
persistAccessToken?: boolean;
|
|
47
|
+
emptyScopeIsValid?: boolean;
|
|
48
|
+
secretRequired?: boolean;
|
|
49
|
+
rollingRefreshToken?: boolean;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
client: OAuthClient;
|
|
52
|
+
clientStorage: InMemoryOAuthClientStorage;
|
|
53
|
+
authServer: OAuthAuthorizationServer;
|
|
54
|
+
keyStorage: InMemoryKeyStorage;
|
|
55
|
+
userStorage: InMemoryUserStorage;
|
|
56
|
+
}>;
|
|
57
|
+
export declare function getAuthorizationCode({ challenge, aud, persistAccessToken, rollingRefreshToken, }?: {
|
|
58
|
+
challenge?: boolean;
|
|
59
|
+
aud?: string;
|
|
60
|
+
persistAccessToken?: boolean;
|
|
61
|
+
rollingRefreshToken?: boolean;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
code: string | undefined;
|
|
64
|
+
client: OAuthClient;
|
|
65
|
+
clientStorage: InMemoryOAuthClientStorage;
|
|
66
|
+
authServer: OAuthAuthorizationServer;
|
|
67
|
+
keyStorage: InMemoryKeyStorage;
|
|
68
|
+
}>;
|
|
69
|
+
export declare function getAccessToken(): Promise<{
|
|
70
|
+
authServer: OAuthAuthorizationServer;
|
|
71
|
+
client: OAuthClient;
|
|
72
|
+
code: string | undefined;
|
|
73
|
+
clientStorage: InMemoryOAuthClientStorage;
|
|
74
|
+
access_token: string | undefined;
|
|
75
|
+
error: string | undefined;
|
|
76
|
+
error_description: string | undefined;
|
|
77
|
+
refresh_token: string | undefined;
|
|
78
|
+
expires_in: number | undefined;
|
|
79
|
+
}>;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
|
|
3
|
+
export declare class ObjectIterator implements IterableIterator<[string, string]> {
|
|
4
|
+
values: string[];
|
|
5
|
+
keys: string[];
|
|
6
|
+
i: number;
|
|
7
|
+
constructor(values: {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
});
|
|
10
|
+
next(): IteratorResult<[string, string]>;
|
|
11
|
+
[Symbol.iterator](): this;
|
|
12
|
+
}
|
|
13
|
+
export declare class KeyIterator implements IterableIterator<string> {
|
|
14
|
+
values: string[];
|
|
15
|
+
keys: string[];
|
|
16
|
+
i: number;
|
|
17
|
+
constructor(values: {
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
});
|
|
20
|
+
next(): IteratorResult<string>;
|
|
21
|
+
[Symbol.iterator](): this;
|
|
22
|
+
}
|
|
23
|
+
export declare class JsonOrFormData {
|
|
24
|
+
private formData;
|
|
25
|
+
private jsonData;
|
|
26
|
+
private clone;
|
|
27
|
+
constructor(clone?: boolean);
|
|
28
|
+
loadData(event: RequestEvent): Promise<void>;
|
|
29
|
+
get(param: string): string | undefined;
|
|
30
|
+
getAsString(param: string): string | undefined;
|
|
31
|
+
getAsBoolean(param: string): boolean | undefined;
|
|
32
|
+
getAsNumber(param: string): number | undefined;
|
|
33
|
+
has(param: string): boolean;
|
|
34
|
+
keys(): IterableIterator<string>;
|
|
35
|
+
toObject(): {
|
|
36
|
+
[key: string]: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crossauth/sveltekit",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"typings": "./dist/index.d.ts",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/*"
|
|
12
|
+
],
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@sveltejs/adapter-auto": "^3.0.0",
|
|
15
|
+
"@sveltejs/kit": "^2.0.0",
|
|
16
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
|
17
|
+
"@types/web": "^0.0.154",
|
|
18
|
+
"autoprefixer": "^10.4.18",
|
|
19
|
+
"daisyui": "^4.7.2",
|
|
20
|
+
"dotenv": "^16.3.1",
|
|
21
|
+
"dotenv-cli": "^7.3.0",
|
|
22
|
+
"svelte": "^4.2.7",
|
|
23
|
+
"svelte-check": "^3.6.0",
|
|
24
|
+
"tslib": "^2.4.1",
|
|
25
|
+
"tsx": "^4.7.0",
|
|
26
|
+
"typescript": "^5.0.0 <=5.3.3",
|
|
27
|
+
"vite": "^5.0.3",
|
|
28
|
+
"vitest": "^1.2.0",
|
|
29
|
+
"vitest-fetch-mock": "^0.2.2"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@types/cookie": "^0.6.0",
|
|
33
|
+
"@types/qrcode": "^1.5.5",
|
|
34
|
+
"cookie": "^0.6.0",
|
|
35
|
+
"formidable": "^3.5.1",
|
|
36
|
+
"jwt-decode": "^4.0.0",
|
|
37
|
+
"minimatch": "^10.0.1",
|
|
38
|
+
"qrcode": "^1.5.4",
|
|
39
|
+
"vite-plugin-dts": "^3.6.4",
|
|
40
|
+
"@crossauth/backend": "^0.0.2",
|
|
41
|
+
"@crossauth/common": "^0.0.2"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"dev": "vite dev",
|
|
45
|
+
"build": "vite build",
|
|
46
|
+
"preview": "vite preview",
|
|
47
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
48
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
49
|
+
"test": "dotenv -e .env.unittest vitest",
|
|
50
|
+
"testonce": "dotenv -e .env.unittest vitest run"
|
|
51
|
+
}
|
|
52
|
+
}
|