@tstdl/base 0.84.13 → 0.84.15
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/authentication/server/authentication.service.d.ts +15 -2
- package/authentication/server/authentication.service.js +2 -0
- package/package.json +1 -1
- package/process-shutdown.js +1 -1
- package/schema/coercers/uint8-array.coercer.d.ts +3 -1
- package/schema/coercers/uint8-array.coercer.js +7 -3
- package/schema/schemas/number.js +2 -2
|
@@ -39,6 +39,16 @@ export type TokenResult<AdditionalTokenPayload extends Record = Record<never>> =
|
|
|
39
39
|
jsonToken: Token<AdditionalTokenPayload>;
|
|
40
40
|
refreshToken: string;
|
|
41
41
|
};
|
|
42
|
+
type CreateTokenResult<AdditionalTokenPayload extends Record> = {
|
|
43
|
+
token: string;
|
|
44
|
+
jsonToken: Token<AdditionalTokenPayload>;
|
|
45
|
+
};
|
|
46
|
+
type CreateRefreshTokenResult = {
|
|
47
|
+
token: string;
|
|
48
|
+
jsonToken: RefreshToken;
|
|
49
|
+
salt: Uint8Array;
|
|
50
|
+
hash: Uint8Array;
|
|
51
|
+
};
|
|
42
52
|
export declare class AuthenticationService<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void> implements AfterResolve {
|
|
43
53
|
private readonly credentialsRepository;
|
|
44
54
|
private readonly sessionRepository;
|
|
@@ -70,9 +80,12 @@ export declare class AuthenticationService<AdditionalTokenPayload extends Record
|
|
|
70
80
|
validateRefreshToken(token: string): Promise<RefreshToken>;
|
|
71
81
|
validateSecretResetToken(token: string): Promise<SecretResetToken>;
|
|
72
82
|
resolveSubject(subject: string): Promise<string>;
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
/** Creates a token without session or refresh token and is not saved in database */
|
|
84
|
+
createToken(additionalTokenPayload: AdditionalTokenPayload, subject: string, sessionId: string, refreshTokenExpiration: number, timestamp: number): Promise<CreateTokenResult<AdditionalTokenPayload>>;
|
|
85
|
+
/** Creates a refresh token without session or something else. */
|
|
86
|
+
createRefreshToken(subject: string, sessionId: string, expirationTimestamp: number): Promise<CreateRefreshTokenResult>;
|
|
75
87
|
private createSecretResetToken;
|
|
76
88
|
private deriveSigningSecrets;
|
|
77
89
|
private getHash;
|
|
78
90
|
}
|
|
91
|
+
export {};
|
|
@@ -224,6 +224,7 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
224
224
|
async resolveSubject(subject) {
|
|
225
225
|
return this.subjectResolver?.resolveSubject(subject) ?? subject;
|
|
226
226
|
}
|
|
227
|
+
/** Creates a token without session or refresh token and is not saved in database */
|
|
227
228
|
async createToken(additionalTokenPayload, subject, sessionId, refreshTokenExpiration, timestamp) {
|
|
228
229
|
const header = {
|
|
229
230
|
v: this.tokenVersion,
|
|
@@ -246,6 +247,7 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
246
247
|
const token = await (0, import_jwt.createJwtTokenString)(jsonToken, this.derivedTokenSigningSecret);
|
|
247
248
|
return { token, jsonToken };
|
|
248
249
|
}
|
|
250
|
+
/** Creates a refresh token without session or something else. */
|
|
249
251
|
async createRefreshToken(subject, sessionId, expirationTimestamp) {
|
|
250
252
|
const secret = (0, import_random.getRandomString)(64, import_alphabet.Alphabet.LowerUpperCaseNumbers);
|
|
251
253
|
const salt = (0, import_random.getRandomBytes)(32);
|
package/package.json
CHANGED
package/process-shutdown.js
CHANGED
|
@@ -63,7 +63,7 @@ function initializeSignals() {
|
|
|
63
63
|
let quitReason;
|
|
64
64
|
process.on("beforeExit", () => {
|
|
65
65
|
if ((0, import_type_guards.isDefined)(quitReason)) {
|
|
66
|
-
console.info("
|
|
66
|
+
console.info("\nquit reason:", ...quitReason);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
for (const event of quitEvents) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { JsonPath } from '../../json-path/json-path.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Schema } from '../schema.js';
|
|
3
|
+
import type { CoerceResult, CoercerContext } from '../types/index.js';
|
|
3
4
|
import { SchemaValueCoercer } from '../types/index.js';
|
|
4
5
|
export declare class Uint8ArrayCoercer extends SchemaValueCoercer {
|
|
6
|
+
static readonly byteNumberArraySchema: Schema<number[]>;
|
|
5
7
|
readonly sourceType: ArrayConstructor;
|
|
6
8
|
readonly targetType: Uint8ArrayConstructor;
|
|
7
9
|
coerce(value: any[], path: JsonPath, { options }: CoercerContext): CoerceResult;
|
|
@@ -22,17 +22,21 @@ __export(uint8_array_coercer_exports, {
|
|
|
22
22
|
uint8ArrayCoercer: () => uint8ArrayCoercer
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(uint8_array_coercer_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_lazy_property = require("../../utils/object/lazy-property.js");
|
|
26
26
|
var import_schema_error = require("../schema.error.js");
|
|
27
|
+
var import_schema = require("../schema.js");
|
|
27
28
|
var import_array = require("../schemas/array.js");
|
|
28
29
|
var import_number = require("../schemas/number.js");
|
|
29
30
|
var import_types = require("../types/index.js");
|
|
30
|
-
const byteNumberArraySchema = (0, import_array.array)((0, import_number.number)({ integer: true, minimum: 0, maximum: 255 }));
|
|
31
31
|
class Uint8ArrayCoercer extends import_types.SchemaValueCoercer {
|
|
32
|
+
static byteNumberArraySchema;
|
|
33
|
+
static {
|
|
34
|
+
(0, import_lazy_property.lazyProperty)(this, "byteNumberArraySchema", () => (0, import_array.array)((0, import_number.number)({ integer: true, minimum: 0, maximum: 255 })));
|
|
35
|
+
}
|
|
32
36
|
sourceType = Array;
|
|
33
37
|
targetType = Uint8Array;
|
|
34
38
|
coerce(value, path, { options }) {
|
|
35
|
-
const testResult = (0, import_schema.testSchema)(byteNumberArraySchema, value, options, path);
|
|
39
|
+
const testResult = (0, import_schema.testSchema)(Uint8ArrayCoercer.byteNumberArraySchema, value, options, path);
|
|
36
40
|
if (!testResult.valid) {
|
|
37
41
|
return { success: false, error: import_schema_error.SchemaError.couldNotCoerce(Uint8Array, Array, path, { inner: testResult.error, fast: options.fastErrors }) };
|
|
38
42
|
}
|
package/schema/schemas/number.js
CHANGED
|
@@ -27,7 +27,7 @@ var import_type_guards = require("../../utils/type-guards.js");
|
|
|
27
27
|
var import_integer = require("../constraints/integer.js");
|
|
28
28
|
var import_maximum = require("../constraints/maximum.js");
|
|
29
29
|
var import_minimum = require("../constraints/minimum.js");
|
|
30
|
-
var
|
|
30
|
+
var import_utils = require("../decorators/utils.js");
|
|
31
31
|
var import_types = require("../types/types.js");
|
|
32
32
|
function number(options = {}) {
|
|
33
33
|
const valueConstraints = (0, import_array.toArrayCopy)(options.valueConstraints ?? []);
|
|
@@ -46,5 +46,5 @@ function number(options = {}) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
function NumberProperty(options) {
|
|
49
|
-
return (0,
|
|
49
|
+
return (0, import_utils.createSchemaPropertyDecoratorFromSchema)(number(options));
|
|
50
50
|
}
|