miqro 6.2.13 → 7.0.1
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/README.md +9 -17
- package/build/editor.bundle.js +11601 -10129
- package/build/esm/src/bin/types.js +10 -5
- package/build/esm/src/cluster.js +1 -1
- package/build/esm/src/common/arguments.d.ts +2 -1
- package/build/esm/src/common/arguments.js +42 -18
- package/build/esm/src/common/assets.d.ts +1 -1
- package/build/esm/src/common/assets.js +34 -13
- package/build/esm/src/common/esbuild.d.ts +4 -1
- package/build/esm/src/common/esbuild.js +31 -26
- package/build/esm/src/common/exit.js +4 -4
- package/build/esm/src/common/help.d.ts +1 -1
- package/build/esm/src/common/help.js +2 -2
- package/build/esm/src/common/jsx.d.ts +2 -3
- package/build/esm/src/common/jsx.js +70 -75
- package/build/esm/src/common/paths.d.ts +0 -1
- package/build/esm/src/common/paths.js +3 -3
- package/build/esm/src/common/watch.d.ts +0 -1
- package/build/esm/src/common/watch.js +4 -1
- package/build/esm/src/inflate/inflate-sea.js +35 -24
- package/build/esm/src/inflate/inflate.js +4 -4
- package/build/esm/src/inflate/setup-auth.js +1 -1
- package/build/esm/src/inflate/setup-cors.js +1 -1
- package/build/esm/src/inflate/setup-db.js +2 -2
- package/build/esm/src/inflate/setup-error.js +1 -1
- package/build/esm/src/inflate/setup-http.js +16 -16
- package/build/esm/src/inflate/setup-log.js +1 -1
- package/build/esm/src/inflate/setup-middleware.js +1 -1
- package/build/esm/src/inflate/setup-server-config.js +1 -1
- package/build/esm/src/inflate/setup-ws.js +1 -1
- package/build/esm/src/inflate/setup.doc.d.ts +2 -2
- package/build/esm/src/inflate/setup.doc.js +23 -2
- package/build/esm/src/inflate/utils/sea-utils.js +2 -2
- package/build/esm/src/lib.d.ts +10 -1
- package/build/esm/src/lib.js +16 -1
- package/build/esm/src/main.js +2 -1
- package/build/esm/src/services/app.d.ts +1 -0
- package/build/esm/src/services/app.js +4 -5
- package/build/esm/src/services/migrations.js +2 -2
- package/build/esm/src/services/utils/jwt.d.ts +2 -0
- package/build/esm/src/services/utils/jwt.js +23 -0
- package/build/esm/src/services/utils/middleware.d.ts +9 -0
- package/build/esm/src/services/utils/middleware.js +9 -0
- package/build/esm/src/services/utils/server-interface.js +33 -4
- package/build/esm/src/types.d.ts +50 -83
- package/build/lib.cjs +15694 -15619
- package/package.json +6 -8
- package/sea/basic-compile.base64.sh +1 -1
- package/sea/basic-compile.sh +1 -1
- package/sea/install-nodejs.sh +1 -1
- package/sea/node.version.tag +1 -1
- package/.eslintrc +0 -15
- package/build/esm/editor/auth.d.ts +0 -6
- package/build/esm/editor/auth.js +0 -41
- package/build/esm/editor/common/admin-interface.d.ts +0 -36
- package/build/esm/editor/common/admin-interface.js +0 -44
- package/build/esm/editor/common/constants.d.ts +0 -4
- package/build/esm/editor/common/constants.js +0 -20
- package/build/esm/editor/common/constants.server.d.ts +0 -2
- package/build/esm/editor/common/constants.server.js +0 -4
- package/build/esm/editor/common/editor-index.d.ts +0 -2
- package/build/esm/editor/common/editor-index.js +0 -14
- package/build/esm/editor/common/html-encode.d.ts +0 -1
- package/build/esm/editor/common/html-encode.js +0 -14
- package/build/esm/editor/common/log-socket.d.ts +0 -15
- package/build/esm/editor/common/log-socket.js +0 -70
- package/build/esm/editor/common/templates.d.ts +0 -11
- package/build/esm/editor/common/templates.js +0 -477
- package/build/esm/editor/components/api-preview.d.ts +0 -11
- package/build/esm/editor/components/api-preview.js +0 -90
- package/build/esm/editor/components/editor.d.ts +0 -16
- package/build/esm/editor/components/editor.js +0 -365
- package/build/esm/editor/components/file-browser.d.ts +0 -37
- package/build/esm/editor/components/file-browser.js +0 -126
- package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
- package/build/esm/editor/components/file-editor-toolbar.js +0 -93
- package/build/esm/editor/components/file-editor.d.ts +0 -32
- package/build/esm/editor/components/file-editor.js +0 -59
- package/build/esm/editor/components/filter-query.d.ts +0 -1
- package/build/esm/editor/components/filter-query.js +0 -22
- package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
- package/build/esm/editor/components/highlight-text-area.js +0 -125
- package/build/esm/editor/components/log-viewer.d.ts +0 -6
- package/build/esm/editor/components/log-viewer.js +0 -69
- package/build/esm/editor/components/new-file.d.ts +0 -10
- package/build/esm/editor/components/new-file.js +0 -117
- package/build/esm/editor/components/scroll-query.d.ts +0 -7
- package/build/esm/editor/components/scroll-query.js +0 -21
- package/build/esm/editor/components/start-page.d.ts +0 -13
- package/build/esm/editor/components/start-page.js +0 -30
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -29
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -5
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -49
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -4
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -39
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -149
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -38
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -46
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -45
- package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
- package/build/esm/editor/http/admin/editor/editor.js +0 -7
- package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/index.api.js +0 -21
- package/build/esm/editor/server.d.ts +0 -3
- package/build/esm/editor/server.js +0 -49
- package/build/esm/editor/ws.d.ts +0 -3
- package/build/esm/editor/ws.js +0 -11
- package/build/esm/src/services/globals.d.ts +0 -3
- package/build/esm/src/services/globals.js +0 -182
- package/build/jsx.dom.js +0 -1587
- package/build/postject.base64.cjs +0 -1
- package/editor/auth.ts +0 -51
- package/editor/common/admin-interface.ts +0 -84
- package/editor/common/constants.server.ts +0 -5
- package/editor/common/constants.ts +0 -21
- package/editor/common/editor-index.tsx +0 -17
- package/editor/common/html-encode.ts +0 -14
- package/editor/common/log-socket.tsx +0 -85
- package/editor/common/templates.ts +0 -481
- package/editor/components/api-preview.tsx +0 -116
- package/editor/components/editor.tsx +0 -494
- package/editor/components/file-browser.tsx +0 -308
- package/editor/components/file-editor-toolbar.tsx +0 -191
- package/editor/components/file-editor.tsx +0 -122
- package/editor/components/filter-query.tsx +0 -22
- package/editor/components/highlight-text-area.tsx +0 -145
- package/editor/components/log-viewer.tsx +0 -110
- package/editor/components/new-file.tsx +0 -169
- package/editor/components/scroll-query.tsx +0 -22
- package/editor/components/start-page.tsx +0 -49
- package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
- package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
- package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
- package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
- package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
- package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
- package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
- package/editor/http/admin/editor/editor.tsx +0 -8
- package/editor/http/admin/editor/index.api.tsx +0 -39
- package/editor/server.ts +0 -57
- package/editor/ws.ts +0 -15
- package/sea/types.json +0 -1
- package/src/bin/compile.ts +0 -35
- package/src/bin/doc-md.ts +0 -210
- package/src/bin/generate-doc.ts +0 -64
- package/src/bin/test.ts +0 -92
- package/src/bin/types.ts +0 -29
- package/src/cluster.ts +0 -27
- package/src/common/arguments.ts +0 -733
- package/src/common/assets.ts +0 -128
- package/src/common/checksum.ts +0 -58
- package/src/common/constants.ts +0 -18
- package/src/common/content-type.ts +0 -84
- package/src/common/esbuild.ts +0 -94
- package/src/common/exit.ts +0 -91
- package/src/common/fs.ts +0 -82
- package/src/common/help.ts +0 -60
- package/src/common/jsx.ts +0 -547
- package/src/common/jwt.ts +0 -85
- package/src/common/paths.ts +0 -107
- package/src/common/watch.ts +0 -85
- package/src/inflate/inflate-sea.ts +0 -226
- package/src/inflate/inflate.ts +0 -101
- package/src/inflate/md.ts +0 -25
- package/src/inflate/setup-auth.ts +0 -41
- package/src/inflate/setup-cors.ts +0 -41
- package/src/inflate/setup-db.ts +0 -117
- package/src/inflate/setup-error.ts +0 -44
- package/src/inflate/setup-http.ts +0 -704
- package/src/inflate/setup-log.ts +0 -45
- package/src/inflate/setup-middleware.ts +0 -47
- package/src/inflate/setup-server-config.ts +0 -48
- package/src/inflate/setup-test.ts +0 -23
- package/src/inflate/setup-ws.ts +0 -50
- package/src/inflate/setup.doc.ts +0 -68
- package/src/inflate/utils/sea-utils.ts +0 -14
- package/src/lib.ts +0 -19
- package/src/main.ts +0 -100
- package/src/services/app.ts +0 -698
- package/src/services/editor.tsx +0 -101
- package/src/services/globals.ts +0 -186
- package/src/services/hot-reload.ts +0 -51
- package/src/services/migrations.ts +0 -68
- package/src/services/utils/admin-interface.ts +0 -37
- package/src/services/utils/cache.ts +0 -88
- package/src/services/utils/cluster-cache.ts +0 -230
- package/src/services/utils/cluster-ws.ts +0 -202
- package/src/services/utils/db-manager.ts +0 -92
- package/src/services/utils/get-route.ts +0 -70
- package/src/services/utils/log-transport.ts +0 -81
- package/src/services/utils/log.ts +0 -92
- package/src/services/utils/server-interface.ts +0 -92
- package/src/services/utils/websocketmanager.ts +0 -157
- package/src/types/@esbuild.d.ts +0 -1
- package/src/types/@miqro/core.d.ts +0 -2
- package/src/types/@miqro/jsx.d.ts +0 -2
- package/src/types/@miqro/parser.d.ts +0 -2
- package/src/types/@miqro/query.d.ts +0 -2
- package/src/types/@miqro/request.d.ts +0 -2
- package/src/types/@miqro/test.d.ts +0 -2
- package/src/types/@miqro.d.ts +0 -1
- package/src/types/@types.d.ts +0 -1
- package/src/types/browser.globals.d.ts +0 -1
- package/src/types/cookie.d.ts +0 -2
- package/src/types/globals.d.ts +0 -2
- package/src/types/jose.d.ts +0 -2
- package/src/types/jsx.globals.d.ts +0 -38
- package/src/types/miqro.d.ts +0 -228
- package/src/types/postject.d.ts +0 -1
- package/src/types/server.globals.d.ts +0 -47
- package/src/types.ts +0 -304
- package/tsconfig.json +0 -35
package/src/common/jsx.ts
DELETED
|
@@ -1,547 +0,0 @@
|
|
|
1
|
-
import { Runtime } from "@miqro/jsx";
|
|
2
|
-
import { createNodeRuntime } from "@miqro/jsx-node";
|
|
3
|
-
import { basename, dirname, extname, relative, resolve } from "node:path";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
5
|
-
import { Request, Response, CORSOptions, Logger, APIRoute } from "@miqro/core";
|
|
6
|
-
import { Parser, Schema } from "@miqro/parser";
|
|
7
|
-
import { APIRouteSchema, SessionHandlerOptionsSchema } from "@miqro/core";
|
|
8
|
-
import { cwd } from "node:process";
|
|
9
|
-
|
|
10
|
-
import { esBuild } from "./esbuild.js";
|
|
11
|
-
import { assertGlobalTampered, browserJSXGlobals } from "../services/globals.js";
|
|
12
|
-
import { APIOptions, ServerConfig, WSConfig, AuthConfig, DBConfig, LogConfig, MiddlewareConfig, ErrorConfig, DocConfig } from "../types.js";
|
|
13
|
-
import { getJSXJSPath, JSX_TMP_DIR } from "./paths.js";
|
|
14
|
-
import { CLEAR_JSX_CACHE } from "./constants.js";
|
|
15
|
-
import { getAsset, initAsset, validateAsset } from "./assets.js";
|
|
16
|
-
import { calculateChecksumFromBuffer } from "./checksum.js";
|
|
17
|
-
import { HandlerWithOptionsSchema, RouteOptionsSchema } from "@miqro/core/build/types.js";
|
|
18
|
-
import { Migration } from "@miqro/query";
|
|
19
|
-
import { mkdirASync, rmdirASync, unlinkASync, writeFileASync } from "./fs.js";
|
|
20
|
-
|
|
21
|
-
let jsxJSBuffer: null | Buffer = null; // Buffer.from(getAsset("jsx.dom.js"));
|
|
22
|
-
let jsxJSBufferChecksumPromise: null | Promise<string> = null; // calculateChecksumFromBuffer(jsxJSBuffer);
|
|
23
|
-
|
|
24
|
-
export async function initJSXJS(logger: Logger) {
|
|
25
|
-
jsxJSBuffer = jsxJSBuffer ? jsxJSBuffer : Buffer.from(getAsset("jsx.dom.js"));
|
|
26
|
-
jsxJSBufferChecksumPromise = jsxJSBufferChecksumPromise ? jsxJSBufferChecksumPromise : calculateChecksumFromBuffer(jsxJSBuffer);
|
|
27
|
-
return initAsset(logger, getJSXJSPath(), jsxJSBuffer, true, jsxJSBufferChecksumPromise, false);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function validateJSXJS(logger: Logger) {
|
|
31
|
-
const checksum = await jsxJSBufferChecksumPromise;
|
|
32
|
-
if (!checksum) {
|
|
33
|
-
throw new Error("error calculating checksum");
|
|
34
|
-
}
|
|
35
|
-
return validateAsset(logger, getJSXJSPath(), checksum);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface Dict<T> {
|
|
39
|
-
[key: string]: T | Dict<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const parser = new Parser();
|
|
43
|
-
|
|
44
|
-
export interface InflateError {
|
|
45
|
-
filePath: string;
|
|
46
|
-
error: Error;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface InflateOptions {
|
|
50
|
-
embemedJSX: boolean;
|
|
51
|
-
minify: boolean;
|
|
52
|
-
useExport: boolean;
|
|
53
|
-
platform?: string;
|
|
54
|
-
logger?: Logger | Console;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const DEFAULT_ESOPTION = {
|
|
58
|
-
platform: "neutral",
|
|
59
|
-
bundle: true,
|
|
60
|
-
jsxFactory: "JSX.createElement",
|
|
61
|
-
jsxFragment: "JSX.Fragment"
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export async function inflateJSX(inFile: string, options: InflateOptions): Promise<string> {
|
|
65
|
-
const tmpBuildDir = resolve(JSX_TMP_DIR, String(process.pid), "build", Date.now() + "-" + randomUUID());
|
|
66
|
-
const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
67
|
-
const jsxJSPath = getJSXJSPath();//resolve(tmpBuildDir, "jsx.js");
|
|
68
|
-
const logger = options.logger; //getLogger(`${SERVER_IDENTIFIER}_JSX`);
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
|
|
72
|
-
if (!options.embemedJSX) {
|
|
73
|
-
await mkdirASync(tmpBuildDir, {
|
|
74
|
-
recursive: true
|
|
75
|
-
});
|
|
76
|
-
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, false, options.useExport));
|
|
77
|
-
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), false));
|
|
78
|
-
logger?.trace("inflating [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
79
|
-
const { outputFiles: [{ contents }] } = await esBuild({
|
|
80
|
-
...DEFAULT_ESOPTION,
|
|
81
|
-
entryPoints: [inFileTmp],
|
|
82
|
-
minify: options.minify,
|
|
83
|
-
platform: options.platform ? options.platform : DEFAULT_ESOPTION.platform
|
|
84
|
-
});
|
|
85
|
-
if (CLEAR_JSX_CACHE) {
|
|
86
|
-
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
87
|
-
await unlinkASync(inFileTmp);
|
|
88
|
-
await rmdirASync(tmpBuildDir);
|
|
89
|
-
}
|
|
90
|
-
return contents;
|
|
91
|
-
} else {
|
|
92
|
-
await mkdirASync(tmpBuildDir, {
|
|
93
|
-
recursive: true
|
|
94
|
-
});
|
|
95
|
-
//await writeFileASync(jsxJSPath, Buffer.from(getAsset("jsx-dom-bundle")));
|
|
96
|
-
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, jsxJSPath));
|
|
97
|
-
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), relative(tmpBuildDir, jsxJSPath)));
|
|
98
|
-
logger?.trace("inflating [%s] from [%s] with jsx.js embedded. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
99
|
-
const { outputFiles: [{ contents }] } = await esBuild({
|
|
100
|
-
...DEFAULT_ESOPTION,
|
|
101
|
-
entryPoints: [inFileTmp],
|
|
102
|
-
minify: options.minify,
|
|
103
|
-
platform: options.platform ? options.platform : DEFAULT_ESOPTION.platform
|
|
104
|
-
});
|
|
105
|
-
if (CLEAR_JSX_CACHE) {
|
|
106
|
-
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
107
|
-
await unlinkASync(inFileTmp);
|
|
108
|
-
//await unlinkASync(jsxJSPath);
|
|
109
|
-
await rmdirASync(tmpBuildDir);
|
|
110
|
-
}
|
|
111
|
-
return contents;
|
|
112
|
-
}
|
|
113
|
-
} catch (e) {
|
|
114
|
-
logger?.error("error with: " + inFile);
|
|
115
|
-
logger?.error(e);
|
|
116
|
-
if (options.embemedJSX) {
|
|
117
|
-
if (CLEAR_JSX_CACHE) {
|
|
118
|
-
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
119
|
-
await unlinkASync(inFileTmp);
|
|
120
|
-
//await unlinkASync(jsxJSPath);
|
|
121
|
-
await rmdirASync(tmpBuildDir);
|
|
122
|
-
} else {
|
|
123
|
-
//console.error("errors on: " + tmpBuildDir);
|
|
124
|
-
logger?.error("error with: %s", inFileTmp);
|
|
125
|
-
logger?.trace("NOT clearing cache. to change this behaivor set CLEAR_JSX_CACHE to 1", tmpBuildDir);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
throw e;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export const APIOptionsSchema: Schema<APIOptions> = {
|
|
133
|
-
type: "object?",
|
|
134
|
-
properties: {
|
|
135
|
-
basePath: "string?",
|
|
136
|
-
path: "string?|string[]?",
|
|
137
|
-
method: "string?|string[]?",
|
|
138
|
-
parser: {
|
|
139
|
-
type: "object?",
|
|
140
|
-
properties: {
|
|
141
|
-
parse: "function"
|
|
142
|
-
},
|
|
143
|
-
mode: "add_extra"
|
|
144
|
-
},
|
|
145
|
-
middleware: "function[]!?",
|
|
146
|
-
session: {
|
|
147
|
-
type: "object?|function?",
|
|
148
|
-
properties: SessionHandlerOptionsSchema.properties
|
|
149
|
-
},
|
|
150
|
-
...RouteOptionsSchema.properties
|
|
151
|
-
},
|
|
152
|
-
//mode:"add_extra"
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export interface HTMLModule {
|
|
156
|
-
default: JSX.Element | ((req: Request | null, res: Response | null) => (Promise<JSX.Element> | JSX.Element));
|
|
157
|
-
apiOptions?: APIOptions;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export const HTMLModuleSchema: Schema<HTMLModule> = {
|
|
161
|
-
type: "object",
|
|
162
|
-
properties: {
|
|
163
|
-
default: {
|
|
164
|
-
type: "function|object"
|
|
165
|
-
},
|
|
166
|
-
apiOptions: APIOptionsSchema
|
|
167
|
-
},
|
|
168
|
-
//mode:"add_extra"
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export type JSONModuleValue = string | object;
|
|
172
|
-
|
|
173
|
-
export interface JSONModule {
|
|
174
|
-
default: JSONModuleValue | ((req: Request | null, res: Response | null) => (Promise<JSONModuleValue> | JSONModuleValue));
|
|
175
|
-
apiOptions?: APIOptions;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export const JSONModuleSchema: Schema<JSONModule> = {
|
|
179
|
-
type: "object",
|
|
180
|
-
properties: {
|
|
181
|
-
default: {
|
|
182
|
-
type: "function|object|string"
|
|
183
|
-
},
|
|
184
|
-
apiOptions: APIOptionsSchema
|
|
185
|
-
},
|
|
186
|
-
//mode:"add_extra"
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export const MigrationSchema: Schema<Migration> = {
|
|
190
|
-
type: "object",
|
|
191
|
-
properties: {
|
|
192
|
-
up: "function",
|
|
193
|
-
down: "function"
|
|
194
|
-
},
|
|
195
|
-
mode: "add_extra"
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export const CORSOptionsSchema: Schema<CORSOptions> = {
|
|
199
|
-
type: "object",
|
|
200
|
-
properties: {
|
|
201
|
-
origins: "string[]?|string?",
|
|
202
|
-
validate: "function?",
|
|
203
|
-
methods: "string?",
|
|
204
|
-
preflightContinue: "boolean?"
|
|
205
|
-
},
|
|
206
|
-
//mode:"add_extra"
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export const WSConfigSchema: Schema<WSConfig> = {
|
|
210
|
-
type: "object",
|
|
211
|
-
properties: {
|
|
212
|
-
path: "string",
|
|
213
|
-
disabled: "boolean?",
|
|
214
|
-
maxConnections: "number?",
|
|
215
|
-
validate: "function?",
|
|
216
|
-
onConnection: "function?",
|
|
217
|
-
onMessage: "function?",
|
|
218
|
-
onDisconnect: "function?"
|
|
219
|
-
},
|
|
220
|
-
//mode:"add_extra"
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
export const DBConfigSchema: Schema<DBConfig> = {
|
|
224
|
-
type: "object",
|
|
225
|
-
properties: {
|
|
226
|
-
url: "string?",
|
|
227
|
-
disabled: "boolean?",
|
|
228
|
-
storage: "string?",
|
|
229
|
-
dialect: "string?",
|
|
230
|
-
name: "string"
|
|
231
|
-
},
|
|
232
|
-
//mode:"add_extra"
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export const ServerConfigSchema: Schema<ServerConfig> = {
|
|
236
|
-
type: "object",
|
|
237
|
-
properties: {
|
|
238
|
-
preload: "function?",
|
|
239
|
-
unload: "function?",
|
|
240
|
-
stop: "function?",
|
|
241
|
-
start: "function?",
|
|
242
|
-
load: "function?"
|
|
243
|
-
},
|
|
244
|
-
//mode:"add_extra"
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
export const LogConfigSchema: Schema<LogConfig> = {
|
|
248
|
-
type: "object",
|
|
249
|
-
properties: {
|
|
250
|
-
level: {
|
|
251
|
-
type: "enum?",
|
|
252
|
-
enumValues: ["error", "warn", "info", "debug", "trace", "none"]
|
|
253
|
-
},
|
|
254
|
-
replaceConsoleTransport: "boolean?",
|
|
255
|
-
replaceFileTransport: "boolean?",
|
|
256
|
-
write: "function"
|
|
257
|
-
},
|
|
258
|
-
//mode:"add_extra"
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
export const AuthConfigSchema: Schema<AuthConfig> = {
|
|
262
|
-
type: "object",
|
|
263
|
-
properties: {
|
|
264
|
-
...SessionHandlerOptionsSchema.properties
|
|
265
|
-
},
|
|
266
|
-
//mode:"add_extra"
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
export const MiddlewareConfigSchema: Schema<MiddlewareConfig> = {
|
|
270
|
-
type: "object",
|
|
271
|
-
properties: {
|
|
272
|
-
middleware: {
|
|
273
|
-
type: "Array",
|
|
274
|
-
arrayType: "function|object",
|
|
275
|
-
required: false,
|
|
276
|
-
properties: {
|
|
277
|
-
...HandlerWithOptionsSchema.properties
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
post: {
|
|
281
|
-
type: "Array",
|
|
282
|
-
arrayType: "function|object",
|
|
283
|
-
required: false,
|
|
284
|
-
properties: {
|
|
285
|
-
...HandlerWithOptionsSchema.properties
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
export const ErrorConfigSchema: Schema<ErrorConfig> = {
|
|
292
|
-
type: "object",
|
|
293
|
-
properties: {
|
|
294
|
-
catch: {
|
|
295
|
-
type: "Array",
|
|
296
|
-
required: false,
|
|
297
|
-
arrayType: "function"
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export const DocConfigSchema: Schema<DocConfig> = {
|
|
303
|
-
type: "object",
|
|
304
|
-
properties: {
|
|
305
|
-
publish: {
|
|
306
|
-
type: "dict?",
|
|
307
|
-
dictType: "object",
|
|
308
|
-
properties: {
|
|
309
|
-
type: {
|
|
310
|
-
type: "enum?",
|
|
311
|
-
enumValues: ["HTML", "MD", "JSON"]
|
|
312
|
-
},
|
|
313
|
-
all: "boolean?"
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export async function importAPIRoute(inFile: string, logger?: Logger) {
|
|
320
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
321
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
322
|
-
const module = typeof mod === "function" ? { handler: mod } : parser.parse(mod, APIRouteSchema, basename(inFile));
|
|
323
|
-
if (module !== undefined) {
|
|
324
|
-
return module as APIRoute;
|
|
325
|
-
} else {
|
|
326
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
export async function importMigrationModule(inFile: string, logger?: Logger) {
|
|
331
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
332
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
333
|
-
const module = parser.parse(mod, MigrationSchema, basename(inFile));
|
|
334
|
-
if (module !== undefined) {
|
|
335
|
-
return module;
|
|
336
|
-
} else {
|
|
337
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
export async function importHTMLModule(inFile: string, logger?: Logger) {
|
|
342
|
-
const module = (await importJSXFile(inFile, logger));
|
|
343
|
-
parser.parse(module.default, HTMLModuleSchema.properties.default, `${basename(inFile)}.default`);
|
|
344
|
-
parser.parse(module.apiOptions, APIOptionsSchema, `${basename(inFile)}.apiOptions`);
|
|
345
|
-
if (module !== undefined) {
|
|
346
|
-
return module;
|
|
347
|
-
} else {
|
|
348
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export async function importJSONModule(inFile: string, logger?: Logger) {
|
|
353
|
-
const module = (await importJSXFile(inFile, logger));
|
|
354
|
-
parser.parse(module.default, JSONModuleSchema.properties.default, `${basename(inFile)}.default`);
|
|
355
|
-
parser.parse(module.apiOptions, APIOptionsSchema, `${basename(inFile)}.apiOptions`);
|
|
356
|
-
if (module !== undefined) {
|
|
357
|
-
return module;
|
|
358
|
-
} else {
|
|
359
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
export async function importAuthModule(inFile: string, logger?: Logger) {
|
|
364
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
365
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
366
|
-
|
|
367
|
-
const module = parser.parse(mod, AuthConfigSchema, basename(inFile));
|
|
368
|
-
if (module !== undefined) {
|
|
369
|
-
return module;
|
|
370
|
-
} else {
|
|
371
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
export async function importMiddlewareConfigModule(inFile: string, logger?: Logger) {
|
|
376
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
377
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
378
|
-
|
|
379
|
-
const module = parser.parse(mod, MiddlewareConfigSchema, basename(inFile));
|
|
380
|
-
if (module !== undefined) {
|
|
381
|
-
return module;
|
|
382
|
-
} else {
|
|
383
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export async function importErrorConfigModule(inFile: string, logger?: Logger) {
|
|
388
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
389
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
390
|
-
|
|
391
|
-
const module = parser.parse(mod, ErrorConfigSchema, basename(inFile));
|
|
392
|
-
if (module !== undefined) {
|
|
393
|
-
return module;
|
|
394
|
-
} else {
|
|
395
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
export async function importDocConfigModule(inFile: string, logger?: Logger) {
|
|
400
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
401
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
402
|
-
|
|
403
|
-
const module = parser.parse(mod, DocConfigSchema, basename(inFile));
|
|
404
|
-
if (module !== undefined) {
|
|
405
|
-
return module;
|
|
406
|
-
} else {
|
|
407
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
export async function importConfigConfigModule(inFile: string, logger?: Logger) {
|
|
412
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
413
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
414
|
-
|
|
415
|
-
const module = parser.parse(mod, MiddlewareConfigSchema, basename(inFile));
|
|
416
|
-
if (module !== undefined) {
|
|
417
|
-
return module;
|
|
418
|
-
} else {
|
|
419
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
export async function importCORSModule(inFile: string, logger?: Logger) {
|
|
424
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
425
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
426
|
-
|
|
427
|
-
const module = parser.parse(mod, CORSOptionsSchema, basename(inFile));
|
|
428
|
-
if (module !== undefined) {
|
|
429
|
-
return module;
|
|
430
|
-
} else {
|
|
431
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export async function importWSConfigModule(inFile: string, logger?: Logger) {
|
|
436
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
437
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
438
|
-
|
|
439
|
-
const module = parser.parse(mod, WSConfigSchema, basename(inFile));
|
|
440
|
-
if (module !== undefined) {
|
|
441
|
-
return module;
|
|
442
|
-
} else {
|
|
443
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
export async function importDBConfigModule(inFile: string, logger?: Logger) {
|
|
448
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
449
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
450
|
-
|
|
451
|
-
const module = parser.parse(mod, DBConfigSchema, basename(inFile));
|
|
452
|
-
if (module !== undefined) {
|
|
453
|
-
return module;
|
|
454
|
-
} else {
|
|
455
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
export async function importLogConfigModule(inFile: string, logger?: Logger) {
|
|
460
|
-
const module = parser.parse((await importJSXFile(inFile, logger)).default, LogConfigSchema, basename(inFile));
|
|
461
|
-
if (module !== undefined) {
|
|
462
|
-
return module;
|
|
463
|
-
} else {
|
|
464
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
export async function importServerConfigModule(inFile: string, logger?: Logger) {
|
|
469
|
-
const isCJS = extname(inFile) === ".cjs";
|
|
470
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
471
|
-
|
|
472
|
-
const module = parser.parse(mod, ServerConfigSchema, basename(inFile));
|
|
473
|
-
if (module !== undefined) {
|
|
474
|
-
return module;
|
|
475
|
-
} else {
|
|
476
|
-
throw new Error(`error with module [${inFile}] undefined`);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
export async function importJSXFile(inFile: string, logger?: Logger | Console): Promise<any> {
|
|
481
|
-
const inflatedCode = await inflateJSX(inFile, {
|
|
482
|
-
embemedJSX: false,
|
|
483
|
-
minify: false,
|
|
484
|
-
useExport: true,
|
|
485
|
-
platform: "node",
|
|
486
|
-
logger
|
|
487
|
-
});
|
|
488
|
-
const tmpBuildDir = resolve(JSX_TMP_DIR, String(process.pid), "import", Date.now() + "-" + randomUUID());
|
|
489
|
-
//const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
490
|
-
const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".cjs");
|
|
491
|
-
//const logger = getLogger(`${SERVER_IDENTIFIER}_JSX`);
|
|
492
|
-
await mkdirASync(tmpBuildDir, {
|
|
493
|
-
recursive: true
|
|
494
|
-
});
|
|
495
|
-
try {
|
|
496
|
-
await writeFileASync(inFileTmp, inflatedCode);
|
|
497
|
-
assertGlobalTampered();
|
|
498
|
-
logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
499
|
-
logger?.debug("importing [%s]", relative(cwd(), inFile));
|
|
500
|
-
const module = await import(resolve(inFileTmp));
|
|
501
|
-
assertGlobalTampered();
|
|
502
|
-
if (CLEAR_JSX_CACHE) {
|
|
503
|
-
logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
504
|
-
await unlinkASync(inFileTmp);
|
|
505
|
-
await rmdirASync(tmpBuildDir);
|
|
506
|
-
}
|
|
507
|
-
return module.default;
|
|
508
|
-
} catch (e) {
|
|
509
|
-
logger?.error(e);
|
|
510
|
-
logger?.error("error with2: " + inFile);
|
|
511
|
-
if (CLEAR_JSX_CACHE) {
|
|
512
|
-
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
513
|
-
await unlinkASync(inFileTmp);
|
|
514
|
-
await rmdirASync(tmpBuildDir);
|
|
515
|
-
} else {
|
|
516
|
-
//console.error("errors on: " + tmpBuildDir);
|
|
517
|
-
logger?.error("error with: %s", inFileTmp);
|
|
518
|
-
logger?.trace("NOT clearing cache. to change this behaivor set CLEAR_JSX_CACHE to 1", tmpBuildDir);
|
|
519
|
-
}
|
|
520
|
-
throw e;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
export function jsx2HTML(out: JSX.Element, runtime?: Runtime): string {
|
|
525
|
-
runtime = runtime ? runtime : createNodeRuntime();
|
|
526
|
-
const element = runtime.createElement("root");
|
|
527
|
-
const container = runtime.createContainer(element, {
|
|
528
|
-
shadowInit: false, runtimeOptions: {
|
|
529
|
-
disableEffects: true,
|
|
530
|
-
disableEvents: true,
|
|
531
|
-
disableRefListener: true,
|
|
532
|
-
disableRefresh: true
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
container.render(out);
|
|
536
|
-
//console.log("jsx2HTML [%s]", element);
|
|
537
|
-
let HTML = "";
|
|
538
|
-
for (let i = 0; i < element.childNodes.length; i++) {
|
|
539
|
-
const child = element.childNodes[i];
|
|
540
|
-
//console.log("jsx2HTML child [%s]", child);
|
|
541
|
-
//console.log("jsx2HTML child [%s]", (child as any).toString(" ", -1));
|
|
542
|
-
HTML += (child as any).toString(" ", -1);
|
|
543
|
-
}
|
|
544
|
-
container.disconnect();
|
|
545
|
-
//console.log("jsx2HTML [%s]", HTML);
|
|
546
|
-
return HTML;
|
|
547
|
-
}
|
package/src/common/jwt.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { EncryptJWT, EncryptOptions, JWTDecryptOptions, JWTDecryptResult, JWTPayload, JWTVerifyOptions, JWTVerifyResult, ProtectedHeaderParameters, SignJWT, SignOptions, decodeJwt, decodeProtectedHeader, jwtDecrypt as joseJWTDecrypt, jwtVerify } from "jose";
|
|
2
|
-
import { KeyObject } from "node:crypto";
|
|
3
|
-
import { EncryptJWTOptions, JWTSignOptions } from "../types.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* creates a JWT encrypted token with jose
|
|
7
|
-
*
|
|
8
|
-
* @param payload the payload to encrypt
|
|
9
|
-
* @param secret the secret example. const secret = createSecretKey(process.env.JWT_SECRET, 'utf-8');
|
|
10
|
-
* @param options options like expiratation date, issuer and audience
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
export async function encryptJWT(payload: JWTPayload, secret: KeyObject, options?: Partial<EncryptJWTOptions>): Promise<string> {
|
|
14
|
-
const en = new EncryptJWT(payload)
|
|
15
|
-
.setProtectedHeader({
|
|
16
|
-
alg: options?.alg ? options?.alg : 'dir',
|
|
17
|
-
enc: options?.enc ? options?.enc : 'A128CBC-HS256'
|
|
18
|
-
})
|
|
19
|
-
.setIssuedAt(options?.iat)
|
|
20
|
-
.setIssuer(options?.iss ? options?.iss : 'urn:example:issuer')
|
|
21
|
-
.setAudience(options?.aud ? options?.aud : 'urn:example:audience')
|
|
22
|
-
.setExpirationTime(options?.exp ? options?.exp : '2h');
|
|
23
|
-
|
|
24
|
-
return await en.encrypt(secret, options?.options);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* decrypts a JWT token with jose
|
|
29
|
-
* @param jwt the JWT token
|
|
30
|
-
* @param secret the secret example. const secret = createSecretKey(process.env.JWT_SECRET, 'utf-8');
|
|
31
|
-
* @param options options like issuer and audience
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
export async function decryptJWT<PayloadType = JWTPayload>(jwt: string, secret: KeyObject, options?: Partial<JWTDecryptOptions>): Promise<JWTDecryptResult<PayloadType>> {
|
|
35
|
-
return await joseJWTDecrypt(jwt, secret, options)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* verify a JWT token with jose
|
|
40
|
-
* @param jwt the JWT token
|
|
41
|
-
* @param secret the secret example. const secret = createSecretKey(process.env.JWT_SECRET, 'utf-8');
|
|
42
|
-
* @param options options like issuer and audience
|
|
43
|
-
* @returns
|
|
44
|
-
*/
|
|
45
|
-
export async function verifyJWT<PayloadType = JWTPayload>(jwt: string, secret: KeyObject, options?: Partial<JWTVerifyOptions>): Promise<JWTVerifyResult<PayloadType>> {
|
|
46
|
-
return await jwtVerify(jwt, secret, options)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* creates a signed JWT with jose
|
|
51
|
-
*
|
|
52
|
-
* @param payload the payload to encrypt
|
|
53
|
-
* @param secret the secret example. const secret = createSecretKey(process.env.JWT_SECRET, 'utf-8');
|
|
54
|
-
* @param options options like expiratation date, issuer and audience
|
|
55
|
-
* @returns
|
|
56
|
-
*/
|
|
57
|
-
export async function signJWT(payload: JWTPayload, secret: KeyObject, options?: Partial<JWTSignOptions>): Promise<string> {
|
|
58
|
-
const sign = new SignJWT(payload)
|
|
59
|
-
.setProtectedHeader({
|
|
60
|
-
alg: options?.alg ? options?.alg : 'HS256',
|
|
61
|
-
})
|
|
62
|
-
.setIssuedAt(options?.iat)
|
|
63
|
-
.setIssuer(options?.iss ? options?.iss : 'urn:example:issuer')
|
|
64
|
-
.setAudience(options?.aud ? options?.aud : 'urn:example:audience')
|
|
65
|
-
.setExpirationTime(options?.exp ? options?.exp : '2h');
|
|
66
|
-
return sign.sign(secret, options?.options);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* decodes a protected header with jose
|
|
71
|
-
* @param token
|
|
72
|
-
* @returns
|
|
73
|
-
*/
|
|
74
|
-
export function decodeProtectedHeaderJWT(token: string | object): ProtectedHeaderParameters {
|
|
75
|
-
return decodeProtectedHeader(token);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* decodes a jwt token
|
|
80
|
-
* @param jwt
|
|
81
|
-
* @returns
|
|
82
|
-
*/
|
|
83
|
-
export function decodeJWT<PayloadType = JWTPayload>(jwt: string): PayloadType & JWTPayload {
|
|
84
|
-
return decodeJwt<PayloadType>(jwt)
|
|
85
|
-
}
|