@tstdl/base 0.84.17 → 0.84.19
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.
|
@@ -10,14 +10,14 @@ import { AuthenticationSubjectResolver } from './authentication-subject.resolver
|
|
|
10
10
|
import { AuthenticationTokenPayloadProvider } from './authentication-token-payload.provider.js';
|
|
11
11
|
export type CreateTokenData<AdditionalTokenPayload extends Record> = {
|
|
12
12
|
tokenVersion?: number;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
jwtId?: string;
|
|
14
|
+
issuedAt?: number;
|
|
15
|
+
expiration?: number;
|
|
16
16
|
additionalTokenPayload: AdditionalTokenPayload;
|
|
17
17
|
subject: string;
|
|
18
18
|
sessionId: string;
|
|
19
19
|
refreshTokenExpiration: number;
|
|
20
|
-
timestamp
|
|
20
|
+
timestamp?: number;
|
|
21
21
|
};
|
|
22
22
|
export declare class AuthenticationServiceOptions {
|
|
23
23
|
/**
|
|
@@ -92,7 +92,7 @@ export declare class AuthenticationService<AdditionalTokenPayload extends Record
|
|
|
92
92
|
validateSecretResetToken(token: string): Promise<SecretResetToken>;
|
|
93
93
|
resolveSubject(subject: string): Promise<string>;
|
|
94
94
|
/** Creates a token without session or refresh token and is not saved in database */
|
|
95
|
-
createToken({ tokenVersion,
|
|
95
|
+
createToken({ tokenVersion, jwtId, issuedAt, expiration, additionalTokenPayload, subject, sessionId, refreshTokenExpiration, timestamp }: CreateTokenData<AdditionalTokenPayload>): Promise<CreateTokenResult<AdditionalTokenPayload>>;
|
|
96
96
|
/** Creates a refresh token without session or something else. */
|
|
97
97
|
createRefreshToken(subject: string, sessionId: string, expirationTimestamp: number): Promise<CreateRefreshTokenResult>;
|
|
98
98
|
private createSecretResetToken;
|
|
@@ -225,16 +225,16 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
225
225
|
return this.subjectResolver?.resolveSubject(subject) ?? subject;
|
|
226
226
|
}
|
|
227
227
|
/** Creates a token without session or refresh token and is not saved in database */
|
|
228
|
-
async createToken({ tokenVersion,
|
|
228
|
+
async createToken({ tokenVersion, jwtId, issuedAt, expiration, additionalTokenPayload, subject, sessionId, refreshTokenExpiration, timestamp = (0, import_date_time.currentTimestamp)() }) {
|
|
229
229
|
const header = {
|
|
230
230
|
v: tokenVersion ?? this.tokenVersion,
|
|
231
231
|
alg: "HS256",
|
|
232
232
|
typ: "JWT"
|
|
233
233
|
};
|
|
234
234
|
const payload = {
|
|
235
|
-
jti:
|
|
236
|
-
iat:
|
|
237
|
-
exp:
|
|
235
|
+
jti: jwtId ?? (0, import_random.getRandomString)(24, import_alphabet.Alphabet.LowerUpperCaseNumbers),
|
|
236
|
+
iat: issuedAt ?? (0, import_date_time.timestampToTimestampSeconds)(timestamp),
|
|
237
|
+
exp: expiration ?? (0, import_date_time.timestampToTimestampSeconds)(timestamp + this.tokenTimeToLive),
|
|
238
238
|
refreshTokenExp: (0, import_date_time.timestampToTimestampSeconds)(refreshTokenExpiration),
|
|
239
239
|
sessionId,
|
|
240
240
|
subject,
|
|
@@ -69,7 +69,7 @@ let BrowserService = class BrowserService2 {
|
|
|
69
69
|
async [import_disposable.disposeAsync]() {
|
|
70
70
|
return this.dispose();
|
|
71
71
|
}
|
|
72
|
-
async newBrowser(options
|
|
72
|
+
async newBrowser(options) {
|
|
73
73
|
const mergedOptions = { ...this.options?.defaultNewBrowserOptions, ...options };
|
|
74
74
|
const launchOptions = (0, import_utils.getLaunchOptions)(mergedOptions);
|
|
75
75
|
const browser = await (0, import_module.getBrowserType)(mergedOptions.browser).launch(launchOptions);
|
package/core.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { LogLevel, Logger } from './logger/index.js';
|
|
|
5
5
|
export declare const CORE_LOGGER: InjectionToken<Logger, any>;
|
|
6
6
|
export declare const disposer: AsyncDisposer;
|
|
7
7
|
export declare function isDevMode(): boolean;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function isProdMode(): boolean;
|
|
9
|
+
export declare function enableProdMode(): void;
|
|
9
10
|
export declare function connect(name: string, connectFunction: (() => Promise<any>), logger: Logger, maxTries?: number): Promise<void>;
|
|
10
11
|
export declare function disposeInstances(): Promise<void>;
|
|
11
12
|
export type CoreConfiguration = {
|
package/core.js
CHANGED
|
@@ -23,8 +23,9 @@ __export(core_exports, {
|
|
|
23
23
|
connect: () => connect,
|
|
24
24
|
disposeInstances: () => disposeInstances,
|
|
25
25
|
disposer: () => disposer,
|
|
26
|
-
|
|
27
|
-
isDevMode: () => isDevMode
|
|
26
|
+
enableProdMode: () => enableProdMode,
|
|
27
|
+
isDevMode: () => isDevMode,
|
|
28
|
+
isProdMode: () => isProdMode
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(core_exports);
|
|
30
31
|
var import_container = require("./container/index.js");
|
|
@@ -39,7 +40,10 @@ let _isDevMode = true;
|
|
|
39
40
|
function isDevMode() {
|
|
40
41
|
return _isDevMode;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function isProdMode() {
|
|
44
|
+
return _isDevMode;
|
|
45
|
+
}
|
|
46
|
+
function enableProdMode() {
|
|
43
47
|
_isDevMode = false;
|
|
44
48
|
}
|
|
45
49
|
async function connect(name, connectFunction, logger, maxTries = 5) {
|
|
@@ -67,7 +71,7 @@ async function disposeInstances() {
|
|
|
67
71
|
let coreLogPrefix;
|
|
68
72
|
function configureTstdl(config = {}) {
|
|
69
73
|
if (config.production == true) {
|
|
70
|
-
|
|
74
|
+
enableProdMode();
|
|
71
75
|
}
|
|
72
76
|
import_container.container.register(import_logger2.Logger, { useToken: config.logger ?? import_logger.ConsoleLogger });
|
|
73
77
|
import_container.container.registerSingleton(import_logger2.LogLevel, { useFactory: (level) => (0, import_type_guards.assertDefinedPass)(level, "LogLevel argument not provided") }, { defaultArgumentProvider: () => config.logLevel ?? import_logger2.LogLevel.Trace });
|