@nekm/svelte-core 1.7.8 → 1.7.10
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/protect/contracts.d.ts +8 -8
- package/dist/protect/protect.js +1 -1
- package/dist/protect/routes/login.d.ts +1 -1
- package/dist/protect/routes/login.js +1 -1
- package/dist/protect/routes/logout.d.ts +1 -1
- package/dist/protect/routes/logout.js +1 -1
- package/dist/protect/routes/redirect-login.d.ts +1 -1
- package/dist/protect/routes/redirect-login.js +1 -1
- package/dist/protect/routes/redirect-logout.d.ts +1 -1
- package/dist/protect/routes/redirect-logout.js +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Handle, RequestEvent } from "@sveltejs/kit";
|
|
2
|
-
export interface ProtectTokens
|
|
3
|
-
readonly auth:
|
|
4
|
-
readonly id:
|
|
5
|
-
readonly access:
|
|
2
|
+
export interface ProtectTokens {
|
|
3
|
+
readonly auth: unknown;
|
|
4
|
+
readonly id: unknown;
|
|
5
|
+
readonly access: unknown;
|
|
6
6
|
}
|
|
7
|
-
export interface ProtectConfig
|
|
7
|
+
export interface ProtectConfig {
|
|
8
8
|
readonly protect?: (event: RequestEvent) => Promise<boolean> | boolean;
|
|
9
|
-
readonly jwtDecodeAndVerifyIdToken: (token: string) => Promise<
|
|
10
|
-
readonly jwtDecodeAndVerifyAccessToken: (token: string) => Promise<
|
|
9
|
+
readonly jwtDecodeAndVerifyIdToken: (token: string) => Promise<unknown> | unknown;
|
|
10
|
+
readonly jwtDecodeAndVerifyAccessToken: (token: string) => Promise<unknown> | unknown;
|
|
11
11
|
readonly session: {
|
|
12
12
|
readonly exists: (event: RequestEvent) => Promise<boolean> | boolean;
|
|
13
13
|
readonly stateGenerate: (event: RequestEvent) => Promise<string> | string;
|
|
@@ -15,7 +15,7 @@ export interface ProtectConfig<TAuthToken = unknown, TIdToken = unknown, TAccess
|
|
|
15
15
|
};
|
|
16
16
|
readonly hooks?: {
|
|
17
17
|
readonly onLogout?: (event: RequestEvent) => Promise<void> | void;
|
|
18
|
-
readonly onLogin?: (event: RequestEvent, tokens: ProtectTokens
|
|
18
|
+
readonly onLogin?: (event: RequestEvent, tokens: ProtectTokens) => Promise<void> | void;
|
|
19
19
|
};
|
|
20
20
|
readonly oauth: {
|
|
21
21
|
readonly clientId: string;
|
package/dist/protect/protect.js
CHANGED
|
@@ -15,7 +15,7 @@ export function protect(config) {
|
|
|
15
15
|
.map(routeFactory => routeFactory(config))
|
|
16
16
|
.filter(route => Boolean(route))
|
|
17
17
|
// @ts-expect-error Incorrect typing error.
|
|
18
|
-
.map(route => [route.path
|
|
18
|
+
.map(route => [`/${route.path}`, route.handle]));
|
|
19
19
|
return async ({ event, resolve }) => {
|
|
20
20
|
const routeHandle = routes.get(event.url.pathname);
|
|
21
21
|
if (routeHandle) {
|
|
@@ -2,7 +2,7 @@ import { redirect } from "@sveltejs/kit";
|
|
|
2
2
|
import { queryParamsCreate } from "@nekm/core";
|
|
3
3
|
import { getRedirectUri } from "../helper.js";
|
|
4
4
|
import { ROUTE_PATH_REDIRECT_LOGIN } from "./redirect-login.js";
|
|
5
|
-
export const ROUTE_PATH_LOGIN = "
|
|
5
|
+
export const ROUTE_PATH_LOGIN = "_auth/login";
|
|
6
6
|
export const routeLoginFactory = (config) => {
|
|
7
7
|
const authorizeUrl = `${config.oauth.baseUrl}/${config.oauth.authorizePath ?? "/oauth2/authorize"}`;
|
|
8
8
|
return {
|
|
@@ -2,7 +2,7 @@ import { redirect } from "@sveltejs/kit";
|
|
|
2
2
|
import { queryParamsCreate } from "@nekm/core";
|
|
3
3
|
import { getRedirectUri } from "../helper.js";
|
|
4
4
|
import { ROUTE_PATH_REDIRECT_LOGOUT } from "./redirect-logout.js";
|
|
5
|
-
export const ROUTE_PATH_LOGOUT = "
|
|
5
|
+
export const ROUTE_PATH_LOGOUT = "_auth/logout";
|
|
6
6
|
export const routeLogoutFactory = (config) => {
|
|
7
7
|
// Check if the oauth provider supports a logout path.
|
|
8
8
|
if (!config.oauth.logoutPath) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { redirect } from "@sveltejs/kit";
|
|
2
2
|
import { noop, throwIfUndefined } from "@nekm/core";
|
|
3
3
|
import { getRedirectUri } from "../helper.js";
|
|
4
|
-
export const ROUTE_PATH_REDIRECT_LOGIN = "
|
|
4
|
+
export const ROUTE_PATH_REDIRECT_LOGIN = "_auth/redirect/login";
|
|
5
5
|
export const routeRedirectLoginFactory = (config) => {
|
|
6
6
|
const onLogin = config.hooks?.onLogin ?? noop;
|
|
7
7
|
async function exchangeCodeForToken(fetch, origin, code) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { redirect } from "@sveltejs/kit";
|
|
2
2
|
import { noop } from "@nekm/core";
|
|
3
|
-
export const ROUTE_PATH_REDIRECT_LOGOUT = "
|
|
3
|
+
export const ROUTE_PATH_REDIRECT_LOGOUT = "_auth/redirect/logout";
|
|
4
4
|
export const routeRedirectLogoutFactory = (config) => {
|
|
5
5
|
// Check if the oauth provider supports a logout path.
|
|
6
6
|
if (!config.oauth.logoutPath) {
|
package/package.json
CHANGED