@nekm/svelte-core 1.7.7 → 1.7.9

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.
@@ -1,13 +1,13 @@
1
1
  import type { Handle, RequestEvent } from "@sveltejs/kit";
2
- export interface ProtectTokens<TAuthToken = unknown, TIdToken = unknown, TAccessToken = unknown> {
3
- readonly auth: TAuthToken;
4
- readonly id: TIdToken;
5
- readonly access: TAccessToken;
2
+ export interface ProtectTokens {
3
+ readonly auth: unknown;
4
+ readonly id: unknown;
5
+ readonly access: unknown;
6
6
  }
7
- export interface ProtectConfig<TAuthToken = unknown, TIdToken = unknown, TAccessToken = unknown> {
7
+ export interface ProtectConfig {
8
8
  readonly protect?: (event: RequestEvent) => Promise<boolean> | boolean;
9
- readonly jwtDecodeAndVerifyIdToken: (token: string) => Promise<TIdToken> | TIdToken;
10
- readonly jwtDecodeAndVerifyAccessToken: (token: string) => Promise<TAccessToken> | TAccessToken;
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<TAuthToken, TIdToken, TAccessToken>) => Promise<void> | void;
18
+ readonly onLogin?: (event: RequestEvent, tokens: ProtectTokens) => Promise<void> | void;
19
19
  };
20
20
  readonly oauth: {
21
21
  readonly clientId: string;
@@ -1,3 +1,3 @@
1
1
  import { type Handle } from "@sveltejs/kit";
2
- import type { ProtectConfig } from "./contracts.ts";
2
+ import type { ProtectConfig } from "./contracts.js";
3
3
  export declare function protect(config: ProtectConfig): Handle;
@@ -1,8 +1,8 @@
1
1
  import { error, redirect } from "@sveltejs/kit";
2
- import { ROUTE_PATH_LOGIN, routeLoginFactory } from "./routes/login.ts";
3
- import { routeLogoutFactory } from "./routes/logout.ts";
4
- import { routeRedirectLoginFactory } from "./routes/redirect-login.ts";
5
- import { routeRedirectLogoutFactory } from "./routes/redirect-logout.ts";
2
+ import { ROUTE_PATH_LOGIN, routeLoginFactory } from "./routes/login.js";
3
+ import { routeLogoutFactory } from "./routes/logout.js";
4
+ import { routeRedirectLoginFactory } from "./routes/redirect-login.js";
5
+ import { routeRedirectLogoutFactory } from "./routes/redirect-logout.js";
6
6
  const routeFactories = Object.freeze([
7
7
  routeLoginFactory,
8
8
  routeLogoutFactory,
@@ -1,3 +1,3 @@
1
- import type { RouteFactory } from "../contracts.ts";
1
+ import type { RouteFactory } from "../contracts.js";
2
2
  export declare const ROUTE_PATH_LOGIN = "/_auth/login";
3
3
  export declare const routeLoginFactory: RouteFactory;
@@ -1,7 +1,7 @@
1
1
  import { redirect } from "@sveltejs/kit";
2
2
  import { queryParamsCreate } from "@nekm/core";
3
- import { getRedirectUri } from "../helper.ts";
4
- import { ROUTE_PATH_REDIRECT_LOGIN } from "./redirect-login.ts";
3
+ import { getRedirectUri } from "../helper.js";
4
+ import { ROUTE_PATH_REDIRECT_LOGIN } from "./redirect-login.js";
5
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"}`;
@@ -1,3 +1,3 @@
1
- import type { RouteFactory } from "../contracts.ts";
1
+ import type { RouteFactory } from "../contracts.js";
2
2
  export declare const ROUTE_PATH_LOGOUT = "/_auth/logout";
3
3
  export declare const routeLogoutFactory: RouteFactory;
@@ -1,7 +1,7 @@
1
1
  import { redirect } from "@sveltejs/kit";
2
2
  import { queryParamsCreate } from "@nekm/core";
3
- import { getRedirectUri } from "../helper.ts";
4
- import { ROUTE_PATH_REDIRECT_LOGOUT } from "./redirect-logout.ts";
3
+ import { getRedirectUri } from "../helper.js";
4
+ import { ROUTE_PATH_REDIRECT_LOGOUT } from "./redirect-logout.js";
5
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.
@@ -1,3 +1,3 @@
1
- import type { RouteFactory } from "../contracts.ts";
1
+ import type { RouteFactory } from "../contracts.js";
2
2
  export declare const ROUTE_PATH_REDIRECT_LOGIN = "/_auth/redirect/login";
3
3
  export declare const routeRedirectLoginFactory: RouteFactory;
@@ -1,6 +1,6 @@
1
1
  import { redirect } from "@sveltejs/kit";
2
2
  import { noop, throwIfUndefined } from "@nekm/core";
3
- import { getRedirectUri } from "../helper.ts";
3
+ import { getRedirectUri } from "../helper.js";
4
4
  export const ROUTE_PATH_REDIRECT_LOGIN = "/_auth/redirect/login";
5
5
  export const routeRedirectLoginFactory = (config) => {
6
6
  const onLogin = config.hooks?.onLogin ?? noop;
@@ -1,3 +1,3 @@
1
- import type { RouteFactory } from "../contracts.ts";
1
+ import type { RouteFactory } from "../contracts.js";
2
2
  export declare const ROUTE_PATH_REDIRECT_LOGOUT = "/_auth/redirect/logout";
3
3
  export declare const routeRedirectLogoutFactory: RouteFactory;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@nekm/svelte-core",
3
3
  "description": "Code I find myself re-writing over-and-over, Svelte edition.",
4
4
  "license": "MIT",
5
- "version": "1.7.7",
5
+ "version": "1.7.9",
6
6
  "scripts": {
7
7
  "dev": "vite dev",
8
8
  "build": "vite build && npm run prepack",