@meistrari/data-token 0.0.16 → 0.0.17
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/adapters/elysia.d.mts +4 -2
- package/dist/adapters/elysia.d.ts +4 -2
- package/dist/adapters/elysia.mjs +1 -0
- package/dist/adapters/hono.d.mts +3 -2
- package/dist/adapters/hono.d.ts +3 -2
- package/dist/adapters/hono.mjs +1 -0
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.mjs +5 -1
- package/dist/shared/{data-token.815fae84.d.mts → data-token.1d70cb5e.d.mts} +2 -1
- package/dist/shared/{data-token.815fae84.d.ts → data-token.1d70cb5e.d.ts} +2 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
1
2
|
import Elysia, { Context } from 'elysia';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -18,7 +19,7 @@ import Elysia, { Context } from 'elysia';
|
|
|
18
19
|
* .get('/', ({ authData }) => ({ authData }))
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
|
-
declare function createDataTokenPlugin(url: string, skipOnError?: boolean, getToken?: (c: Context) => string): Elysia<"",
|
|
22
|
+
declare function createDataTokenPlugin(url: string, skipOnError?: boolean, getToken?: (c: Context) => string): Elysia<"", {
|
|
22
23
|
decorator: {};
|
|
23
24
|
store: {};
|
|
24
25
|
derive: {
|
|
@@ -37,12 +38,13 @@ declare function createDataTokenPlugin(url: string, skipOnError?: boolean, getTo
|
|
|
37
38
|
};
|
|
38
39
|
resolve: {};
|
|
39
40
|
}, {
|
|
40
|
-
|
|
41
|
+
typebox: _sinclair_typebox.TModule<{}>;
|
|
41
42
|
error: {};
|
|
42
43
|
}, {
|
|
43
44
|
schema: {};
|
|
44
45
|
macro: {};
|
|
45
46
|
macroFn: {};
|
|
47
|
+
parser: {};
|
|
46
48
|
}, {}, {
|
|
47
49
|
derive: {};
|
|
48
50
|
resolve: {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
1
2
|
import Elysia, { Context } from 'elysia';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -18,7 +19,7 @@ import Elysia, { Context } from 'elysia';
|
|
|
18
19
|
* .get('/', ({ authData }) => ({ authData }))
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
|
-
declare function createDataTokenPlugin(url: string, skipOnError?: boolean, getToken?: (c: Context) => string): Elysia<"",
|
|
22
|
+
declare function createDataTokenPlugin(url: string, skipOnError?: boolean, getToken?: (c: Context) => string): Elysia<"", {
|
|
22
23
|
decorator: {};
|
|
23
24
|
store: {};
|
|
24
25
|
derive: {
|
|
@@ -37,12 +38,13 @@ declare function createDataTokenPlugin(url: string, skipOnError?: boolean, getTo
|
|
|
37
38
|
};
|
|
38
39
|
resolve: {};
|
|
39
40
|
}, {
|
|
40
|
-
|
|
41
|
+
typebox: _sinclair_typebox.TModule<{}>;
|
|
41
42
|
error: {};
|
|
42
43
|
}, {
|
|
43
44
|
schema: {};
|
|
44
45
|
macro: {};
|
|
45
46
|
macroFn: {};
|
|
47
|
+
parser: {};
|
|
46
48
|
}, {}, {
|
|
47
49
|
derive: {};
|
|
48
50
|
resolve: {};
|
package/dist/adapters/elysia.mjs
CHANGED
package/dist/adapters/hono.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as hono from 'hono';
|
|
2
2
|
import { Context } from 'hono';
|
|
3
|
-
import { D as DataToken } from '../shared/data-token.
|
|
3
|
+
import { D as DataToken } from '../shared/data-token.1d70cb5e.mjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
type DataTokenContext = {
|
|
@@ -28,4 +28,5 @@ type DataTokenContext = {
|
|
|
28
28
|
*/
|
|
29
29
|
declare function createDataTokenMiddleware<Env extends DataTokenContext>(url: string | ((c: Context<Env>) => string), skipOnError?: boolean, getToken?: (c: Context<Env>) => string): hono.MiddlewareHandler<Env, string, {}>;
|
|
30
30
|
|
|
31
|
-
export {
|
|
31
|
+
export { createDataTokenMiddleware };
|
|
32
|
+
export type { DataTokenContext };
|
package/dist/adapters/hono.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as hono from 'hono';
|
|
2
2
|
import { Context } from 'hono';
|
|
3
|
-
import { D as DataToken } from '../shared/data-token.
|
|
3
|
+
import { D as DataToken } from '../shared/data-token.1d70cb5e.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
type DataTokenContext = {
|
|
@@ -28,4 +28,5 @@ type DataTokenContext = {
|
|
|
28
28
|
*/
|
|
29
29
|
declare function createDataTokenMiddleware<Env extends DataTokenContext>(url: string | ((c: Context<Env>) => string), skipOnError?: boolean, getToken?: (c: Context<Env>) => string): hono.MiddlewareHandler<Env, string, {}>;
|
|
30
30
|
|
|
31
|
-
export {
|
|
31
|
+
export { createDataTokenMiddleware };
|
|
32
|
+
export type { DataTokenContext };
|
package/dist/adapters/hono.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createMiddleware } from 'hono/factory';
|
|
2
2
|
import { getValidator } from '../index.mjs';
|
|
3
3
|
import 'jose';
|
|
4
|
+
import 'jose/dist/types/util/errors';
|
|
4
5
|
import 'zod';
|
|
5
6
|
|
|
6
7
|
function createDataTokenMiddleware(url, skipOnError = false, getToken = (c) => c.req.header("x-data-token") ?? "") {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { JOSEError } from 'jose/dist/types/util/errors';
|
|
2
|
+
export { D as DataToken, V as ValidatorConfig } from './shared/data-token.1d70cb5e.mjs';
|
|
2
3
|
import 'zod';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -23,5 +24,12 @@ declare function getValidator(jwksUrl: string, { algorithms }?: {
|
|
|
23
24
|
uuid: string | null;
|
|
24
25
|
} | undefined;
|
|
25
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if an error is an authentication error.
|
|
29
|
+
*
|
|
30
|
+
* @param err - The error to check.
|
|
31
|
+
* @returns True if the error is an authentication error, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
declare function isAuthenticationError(err: unknown): err is JOSEError;
|
|
26
34
|
|
|
27
|
-
export { getValidator };
|
|
35
|
+
export { getValidator, isAuthenticationError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { JOSEError } from 'jose/dist/types/util/errors';
|
|
2
|
+
export { D as DataToken, V as ValidatorConfig } from './shared/data-token.1d70cb5e.js';
|
|
2
3
|
import 'zod';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -23,5 +24,12 @@ declare function getValidator(jwksUrl: string, { algorithms }?: {
|
|
|
23
24
|
uuid: string | null;
|
|
24
25
|
} | undefined;
|
|
25
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if an error is an authentication error.
|
|
29
|
+
*
|
|
30
|
+
* @param err - The error to check.
|
|
31
|
+
* @returns True if the error is an authentication error, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
declare function isAuthenticationError(err: unknown): err is JOSEError;
|
|
26
34
|
|
|
27
|
-
export { getValidator };
|
|
35
|
+
export { getValidator, isAuthenticationError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createRemoteJWKSet, jwtVerify, errors } from 'jose';
|
|
2
|
+
import { JOSEError } from 'jose/dist/types/util/errors';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
|
|
4
5
|
const sleep = async (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -69,5 +70,8 @@ function getValidator(jwksUrl, { algorithms } = { algorithms: ["RS256"] }) {
|
|
|
69
70
|
return DataToken.parse(payload);
|
|
70
71
|
};
|
|
71
72
|
}
|
|
73
|
+
function isAuthenticationError(err) {
|
|
74
|
+
return err instanceof JOSEError;
|
|
75
|
+
}
|
|
72
76
|
|
|
73
|
-
export { DataToken, getValidator };
|
|
77
|
+
export { DataToken, getValidator, isAuthenticationError };
|
package/package.json
CHANGED