@jayfong/x-server 2.45.0 → 2.45.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/lib/_cjs/cli/env_util.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.EnvUtil = void 0;
|
|
6
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
7
6
|
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
7
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
8
8
|
var _vtils = require("vtils");
|
|
9
9
|
var _yaml = require("yaml");
|
|
10
10
|
class EnvUtil {
|
|
@@ -85,7 +85,7 @@ class EnvUtil {
|
|
|
85
85
|
await _fsExtra.default.outputFile(outFile, types);
|
|
86
86
|
}
|
|
87
87
|
static getTypesFromValue(value) {
|
|
88
|
-
return Array.isArray(value) ? `Array<${value[0] ? EnvUtil.getTypesFromValue(value[0]) : 'any'}>` : (0, _vtils.isPlainObject)(value) ? Object.keys(value).length ? `
|
|
88
|
+
return Array.isArray(value) ? `Array<${value[0] ? EnvUtil.getTypesFromValue(value[0]) : 'any'}>` : (0, _vtils.isPlainObject)(value) ? Object.keys(value).length ? `{${Object.keys(value).map(key => `'${key}':${EnvUtil.getTypesFromValue(value[key])}`).join(',')}}` : `Record<any, any>` : typeof value;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
exports.EnvUtil = EnvUtil;
|
package/lib/_cjs/services/jwt.js
CHANGED
|
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.JwtService = void 0;
|
|
6
6
|
var _jsonwebtoken = _interopRequireDefault(require("jsonwebtoken"));
|
|
7
|
-
var _date = require("vtils/date");
|
|
8
|
-
var _http_error = require("../core/http_error");
|
|
9
7
|
var _lruCache = require("lru-cache");
|
|
10
8
|
var _vtils = require("vtils");
|
|
9
|
+
var _date = require("vtils/date");
|
|
10
|
+
var _http_error = require("../core/http_error");
|
|
11
11
|
class JwtService {
|
|
12
12
|
constructor(options) {
|
|
13
13
|
this.options = options;
|
package/lib/cli/env_util.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
1
|
import path from 'node:path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
3
|
import { dedent, escapeRegExp, isPlainObject } from 'vtils';
|
|
4
4
|
import { parse as yamlParse } from 'yaml';
|
|
5
5
|
export class EnvUtil {
|
|
@@ -80,7 +80,7 @@ export class EnvUtil {
|
|
|
80
80
|
await fs.outputFile(outFile, types);
|
|
81
81
|
}
|
|
82
82
|
static getTypesFromValue(value) {
|
|
83
|
-
return Array.isArray(value) ? `Array<${value[0] ? EnvUtil.getTypesFromValue(value[0]) : 'any'}>` : isPlainObject(value) ? Object.keys(value).length ? `
|
|
83
|
+
return Array.isArray(value) ? `Array<${value[0] ? EnvUtil.getTypesFromValue(value[0]) : 'any'}>` : isPlainObject(value) ? Object.keys(value).length ? `{${Object.keys(value).map(key => `'${key}':${EnvUtil.getTypesFromValue(value[key])}`).join(',')}}` : `Record<any, any>` : typeof value;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
EnvUtil.NEWLINE = '\n';
|
package/lib/services/jwt.d.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node/http" />
|
|
3
3
|
/// <reference types="got/dist/source/core/utils/timed-out" />
|
|
4
|
+
import type { IncomingHttpHeaders } from 'http';
|
|
4
5
|
import jwt from 'jsonwebtoken';
|
|
5
|
-
import { BaseService } from './base';
|
|
6
6
|
import { LRUCache } from 'lru-cache';
|
|
7
7
|
import { MsValue } from 'vtils';
|
|
8
|
-
import type { IncomingHttpHeaders } from 'http';
|
|
9
8
|
import type { RequiredBy } from 'vtils/types';
|
|
9
|
+
import { BaseService } from './base';
|
|
10
|
+
export interface JwtServiceJwtPayload extends Record<string, any> {
|
|
11
|
+
}
|
|
10
12
|
export interface JwtServiceOptions {
|
|
11
13
|
secret: string;
|
|
12
14
|
ttl: MsValue;
|
|
13
|
-
cache?: LRUCache.Options<string,
|
|
14
|
-
onVerify?: (payload: RequiredBy<jwt.JwtPayload, 'iat' | 'exp'>) => any;
|
|
15
|
+
cache?: LRUCache.Options<string, JwtServiceJwtPayload, any>;
|
|
16
|
+
onVerify?: (payload: JwtServiceJwtPayload & RequiredBy<jwt.JwtPayload, 'iat' | 'exp'>) => any;
|
|
15
17
|
}
|
|
16
18
|
export declare class JwtService implements BaseService {
|
|
17
19
|
private options;
|
|
18
20
|
serviceName: string;
|
|
19
21
|
private cache;
|
|
20
22
|
constructor(options: JwtServiceOptions);
|
|
21
|
-
sign<T extends
|
|
22
|
-
verify<T extends
|
|
23
|
-
verifyFromHttpHeaders<T extends
|
|
23
|
+
sign<T extends JwtServiceJwtPayload>(payload: T, ttl?: MsValue): string;
|
|
24
|
+
verify<T extends JwtServiceJwtPayload>(token: string): Promise<T>;
|
|
25
|
+
verifyFromHttpHeaders<T extends JwtServiceJwtPayload>(headers: IncomingHttpHeaders): Promise<T>;
|
|
24
26
|
}
|
|
25
27
|
declare module '../x' {
|
|
26
28
|
interface X {
|
package/lib/services/jwt.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import jwt from 'jsonwebtoken';
|
|
2
|
-
import { differenceInMilliseconds, fromUnixTime } from 'vtils/date';
|
|
3
|
-
import { HttpError } from "../core/http_error";
|
|
4
2
|
import { LRUCache } from 'lru-cache';
|
|
5
3
|
import { ms } from 'vtils';
|
|
4
|
+
import { differenceInMilliseconds, fromUnixTime } from 'vtils/date';
|
|
5
|
+
import { HttpError } from "../core/http_error";
|
|
6
6
|
export class JwtService {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
this.options = options;
|