@getstrata/core 3.0.5 → 3.0.7
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/CHANGELOG.md +18 -9
- package/README.md +17 -9
- package/dist/core/auth/policy.d.ts +4 -1
- package/dist/core/auth/saml/samlServiceProvider.d.ts +2 -3
- package/dist/core/cache/store.d.ts +2 -2
- package/dist/core/cache/tokens.d.ts +1 -1
- package/dist/core/config/envSchema.d.ts +13 -0
- package/dist/core/contracts/application.d.ts +4 -0
- package/dist/core/contracts/di.d.ts +2 -2
- package/dist/core/contracts/provider.d.ts +13 -0
- package/dist/core/contracts/serviceTokens.d.ts +12 -11
- package/dist/core/database/factory.d.ts +3 -0
- package/dist/core/database/index.d.ts +1 -1
- package/dist/core/database/migrations/declaration.d.ts +11 -0
- package/dist/core/database/migrations/runner.d.ts +2 -0
- package/dist/core/database/model.d.ts +16 -3
- package/dist/core/database/modelQuery.d.ts +1 -10
- package/dist/core/database/modelRelationLoader.d.ts +31 -0
- package/dist/core/database/mysqlConnection.d.ts +2 -2
- package/dist/core/database/mysqlNative.d.ts +2 -0
- package/dist/core/database/ormRuntime.d.ts +1 -1
- package/dist/core/database/rawMysql.d.ts +1 -1
- package/dist/core/events/eventBusClass.d.ts +6 -3
- package/dist/core/events/index.d.ts +1 -1
- package/dist/core/http/formRequest.d.ts +2 -0
- package/dist/core/http/loginThrottleMiddleware.d.ts +1 -2
- package/dist/core/http/memoryThrottleMiddleware.d.ts +1 -3
- package/dist/core/http/webFormRequest.d.ts +3 -5
- package/dist/core/mail/mailer.d.ts +6 -3
- package/dist/core/mail/markdownMailable.d.ts +2 -2
- package/dist/core/notifications/dispatcher.d.ts +5 -5
- package/dist/core/notifications/index.d.ts +1 -1
- package/dist/core/notifications/types.d.ts +9 -2
- package/dist/core/queue/index.d.ts +8 -3
- package/dist/core/queue/queueHandoff.d.ts +2 -2
- package/dist/core/runtime/application.d.ts +2 -0
- package/dist/core/security/oauthState.d.ts +12 -2
- package/dist/core/security/safeUrl.d.ts +1 -11
- package/dist/core/storage/storage.d.ts +23 -6
- package/dist/core/testing.d.ts +5 -0
- package/dist/core/testingState.d.ts +22 -0
- package/dist/entries/audit/exportAuditLogs.js +1 -0
- package/dist/entries/auth/intendedUrlCookie.js +68 -2
- package/dist/entries/auth/jwt.js +68 -6
- package/dist/entries/auth/jwtGuard.js +76 -12
- package/dist/entries/auth/oauth/samlProvider.js +4 -5
- package/dist/entries/auth/passwordConfirmCookie.js +69 -3
- package/dist/entries/auth/saml/samlServiceProvider.js +5 -7
- package/dist/entries/auth/sessionCookie.js +69 -6
- package/dist/entries/auth/sessionGuard.js +69 -6
- package/dist/entries/cache/repository.js +4 -5
- package/dist/entries/config/envSchema.js +13 -0
- package/dist/entries/contracts/serviceTokens.js +2 -0
- package/dist/entries/database/bindings.js +18 -90
- package/dist/entries/database/factory.js +4 -0
- package/dist/entries/database/migrations.js +714 -1
- package/dist/entries/http/formRequest.js +12 -6
- package/dist/entries/http/memoryThrottleMiddleware.js +7 -9
- package/dist/entries/http/pagination.js +4 -4
- package/dist/entries/http/parseMultipartUpload.js +62 -9
- package/dist/entries/http/routeModelBinding.js +4 -4
- package/dist/entries/http/securedRouteModelBinding.js +4 -4
- package/dist/entries/http/uploads.js +62 -9
- package/dist/entries/http/validation.js +4 -4
- package/dist/entries/http/webFormRequest.js +74 -95
- package/dist/entries/jobs/exportAuditLogsJob.js +9 -4
- package/dist/entries/jobs/invalidateCacheTagsJob.js +9 -4
- package/dist/entries/queue/createAppQueue.js +10 -5
- package/dist/entries/queue/publicQueue.js +10 -5
- package/dist/entries/queue/queueWorkerTransport.js +10 -5
- package/dist/entries/queue.js +9 -4
- package/dist/entries/runtime/application.js +50 -3
- package/dist/entries/security/oauthState.js +61 -2
- package/dist/entries/security/tokenExpiry.js +62 -9
- package/dist/entries/storage/storage.js +102 -1
- package/dist/entries/testing.js +18 -0
- package/dist/framework/public-api.d.ts +16 -13
- package/dist/index.js +316 -222
- package/dist/internal/mysqlNative.js +97 -0
- package/dist/internal/ormRuntime.js +41 -4
- package/dist/internal/testingState.js +31 -0
- package/dist/types/services.d.ts +4 -1
- package/package.json +17 -4
|
@@ -25,11 +25,14 @@ interface QueueDispatchOptions {
|
|
|
25
25
|
/** Opaque authenticated identity snapshot created by application composition. */
|
|
26
26
|
readonly handoff?: string;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
/** Dispatch capability for application consumers, without replay or shutdown ownership. */
|
|
29
|
+
interface QueueDispatcher {
|
|
30
|
+
dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
interface Queue extends QueueDispatcher {
|
|
29
33
|
close?(): void | Promise<void>;
|
|
30
34
|
/** Preserve a stored logical identity on deliberate replay; reset execution controls. */
|
|
31
35
|
replay?<TPayload extends object>(job: Job<TPayload>, payload: TPayload, jobId: string, options?: QueueDispatchOptions): Promise<void>;
|
|
32
|
-
dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
|
|
33
36
|
}
|
|
34
37
|
declare class SyncQueue implements Queue {
|
|
35
38
|
dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
|
|
@@ -39,10 +42,12 @@ declare class AsyncQueue implements Queue {
|
|
|
39
42
|
private closing?;
|
|
40
43
|
private closed;
|
|
41
44
|
protected assertOpen(): void;
|
|
45
|
+
/** Join admitted work without consuming the dispatch caller's failure. */
|
|
46
|
+
protected track(running: Promise<void>): Promise<void>;
|
|
42
47
|
protected enqueue(task: () => Promise<void>, onError: (error: unknown) => void): void;
|
|
43
48
|
dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
|
|
44
49
|
close(): Promise<void>;
|
|
45
50
|
}
|
|
46
51
|
declare function createQueue(driver: "sync" | "async"): Queue;
|
|
47
|
-
export type { JobContext, Queue, QueueDispatchOptions, QueuePriority };
|
|
52
|
+
export type { JobContext, Queue, QueueDispatcher, QueueDispatchOptions, QueuePriority };
|
|
48
53
|
export { AsyncQueue, createQueue, Job, SyncQueue };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApplicationConfig, ExecutionActor } from "../contracts/application";
|
|
2
|
-
import type {
|
|
2
|
+
import type { QueueDispatcher } from "./index";
|
|
3
3
|
import type { JobRegistry } from "./jobRegistry";
|
|
4
4
|
import type { QueueJobEnvelope } from "./jobRunner";
|
|
5
5
|
interface QueueIdentity {
|
|
@@ -26,6 +26,6 @@ declare function createQueueHandoff(options: {
|
|
|
26
26
|
readonly audience: string;
|
|
27
27
|
}): QueueHandoff;
|
|
28
28
|
/** Capture identity data only; no request scope, signal, database session or resolver survives dispatch. */
|
|
29
|
-
declare function createIdentityQueue(queue:
|
|
29
|
+
declare function createIdentityQueue(queue: QueueDispatcher, registry: JobRegistry, handoff: QueueHandoff, identity: QueueIdentity): QueueDispatcher;
|
|
30
30
|
export type { QueueHandoff, QueueIdentity };
|
|
31
31
|
export { createIdentityQueue, createQueueHandoff, QueueHandoffError };
|
|
@@ -3,5 +3,7 @@ import type { Application, ApplicationDefinition } from "../contracts/applicatio
|
|
|
3
3
|
declare function createApplication(definition: ApplicationDefinition): Application;
|
|
4
4
|
export { aliasService, resourceService, service, valueService, } from "@getstrata/core/contracts/services";
|
|
5
5
|
export type * from "../contracts/application";
|
|
6
|
+
export type * from "../contracts/provider";
|
|
7
|
+
export { defineProvider } from "../contracts/provider";
|
|
6
8
|
export type * from "../contracts/services";
|
|
7
9
|
export { CORE_EXECUTION_CONTEXT_TOKEN, createApplication };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const OAUTH_STATE_COOKIE = "oauth_state";
|
|
2
|
+
declare const SAML_STATE_COOKIE = "saml_state";
|
|
2
3
|
declare const OIDC_PKCE_COOKIE = "oidc_pkce";
|
|
3
4
|
interface OAuthStateOptions {
|
|
4
5
|
readonly secret: string;
|
|
@@ -9,6 +10,7 @@ interface OidcPkceSeal {
|
|
|
9
10
|
nonce: string;
|
|
10
11
|
codeVerifier: string;
|
|
11
12
|
}
|
|
13
|
+
/** Validate the signature and lifetime only; browser binding must be supplied separately. */
|
|
12
14
|
declare function verifySignedOAuthStateValue(value: string, options?: OAuthStateOptions): boolean;
|
|
13
15
|
declare function createOAuthState(options?: OAuthStateOptions): {
|
|
14
16
|
state: string;
|
|
@@ -17,7 +19,15 @@ declare function createOAuthStateCookie(options?: OAuthStateOptions): {
|
|
|
17
19
|
state: string;
|
|
18
20
|
cookie: string;
|
|
19
21
|
};
|
|
20
|
-
|
|
22
|
+
/** Require signed state to match the initiating browser's OAuth state cookie. */
|
|
23
|
+
declare function verifyOAuthState(request: Request, returnedState: string | null, options?: OAuthStateOptions): boolean;
|
|
24
|
+
/** Cross-site IdP POSTs require SameSite=None; browsers require Secure and HTTPS. */
|
|
25
|
+
declare function createSamlStateCookie(options?: OAuthStateOptions): {
|
|
26
|
+
state: string;
|
|
27
|
+
cookie: string;
|
|
28
|
+
};
|
|
29
|
+
declare function verifySamlState(request: Request, returnedState: string | null, options?: OAuthStateOptions): boolean;
|
|
30
|
+
declare function clearSamlStateCookie(): string;
|
|
21
31
|
declare function clearOAuthStateCookie(options?: OAuthStateOptions): string;
|
|
22
32
|
declare function sealOidcPkceCookie(payload: OidcPkceSeal, options?: OAuthStateOptions): string;
|
|
23
33
|
declare function clearOidcPkceCookie(options?: OAuthStateOptions): string;
|
|
@@ -26,4 +36,4 @@ declare function readOidcPkceCookie(request: Request, returnedState: string | nu
|
|
|
26
36
|
codeVerifier: string;
|
|
27
37
|
} | null;
|
|
28
38
|
export type { OAuthStateOptions, OidcPkceSeal };
|
|
29
|
-
export { clearOAuthStateCookie, clearOidcPkceCookie, createOAuthState, createOAuthStateCookie, OAUTH_STATE_COOKIE, OIDC_PKCE_COOKIE, readOidcPkceCookie, sealOidcPkceCookie, verifyOAuthState, verifySignedOAuthStateValue, };
|
|
39
|
+
export { clearOAuthStateCookie, clearOidcPkceCookie, clearSamlStateCookie, createOAuthState, createOAuthStateCookie, createSamlStateCookie, OAUTH_STATE_COOKIE, OIDC_PKCE_COOKIE, readOidcPkceCookie, SAML_STATE_COOKIE, sealOidcPkceCookie, verifyOAuthState, verifySamlState, verifySignedOAuthStateValue, };
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
type DnsLookupResult = {
|
|
2
|
-
address: string;
|
|
3
|
-
family: number;
|
|
4
|
-
};
|
|
5
|
-
type DnsLookup = (hostname: string, options: {
|
|
6
|
-
all: true;
|
|
7
|
-
verbatim: true;
|
|
8
|
-
}) => Promise<DnsLookupResult[]>;
|
|
9
1
|
declare function isBlockedHostname(hostname: string): boolean;
|
|
10
2
|
declare function assertSafeOutboundUrl(rawUrl: string, options?: {
|
|
11
3
|
allowHttp?: boolean;
|
|
@@ -30,7 +22,5 @@ declare function assertSafeOutboundUrlResolved(rawUrl: string, options?: {
|
|
|
30
22
|
production?: boolean;
|
|
31
23
|
allowPrivate?: boolean;
|
|
32
24
|
}): Promise<URL>;
|
|
33
|
-
declare function setDnsLookupForTests(lookupFn: DnsLookup): void;
|
|
34
|
-
declare function resetDnsLookupForTests(): void;
|
|
35
25
|
export type { ResolvedOutboundUrl };
|
|
36
|
-
export { assertSafeOutboundUrl, assertSafeOutboundUrlResolved, isBlockedHostname, isBlockedIpAddress, pinUrlToAddress,
|
|
26
|
+
export { assertSafeOutboundUrl, assertSafeOutboundUrlResolved, isBlockedHostname, isBlockedIpAddress, pinUrlToAddress, resolveSafeOutboundTarget, };
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { CORE_STORAGE_TOKEN } from "@getstrata/core/contracts/serviceTokens";
|
|
2
2
|
import { S3Client } from "bun";
|
|
3
3
|
/** Missing reads return null; deletion is idempotent. All other failures reject. */
|
|
4
|
-
interface
|
|
4
|
+
interface Storage {
|
|
5
5
|
put(path: string, contents: string | Uint8Array): Promise<string>;
|
|
6
6
|
get(path: string): Promise<Uint8Array | null>;
|
|
7
7
|
delete(path: string): Promise<void>;
|
|
8
8
|
}
|
|
9
|
+
/** Buffered consumers need no streaming or concrete manager dependency. */
|
|
10
|
+
interface StorageDriver extends Storage {
|
|
11
|
+
}
|
|
12
|
+
/** Streams are single-use. Late read errors reject reader.read(); cancellation closes the source. */
|
|
13
|
+
interface StreamingStorage extends Storage {
|
|
14
|
+
readStream(path: string): Promise<ReadableStream<Uint8Array> | null>;
|
|
15
|
+
writeStream(path: string, contents: ReadableStream<Uint8Array> | Blob): Promise<string>;
|
|
16
|
+
}
|
|
17
|
+
/** Narrow a consumer port when an operation requires native streaming support. */
|
|
18
|
+
declare function requireStreamingStorage(storage: Storage): StreamingStorage;
|
|
9
19
|
interface S3StorageConfig {
|
|
10
20
|
accessKeyId: string;
|
|
11
21
|
secretAccessKey: string;
|
|
@@ -14,26 +24,33 @@ interface S3StorageConfig {
|
|
|
14
24
|
endpoint?: string;
|
|
15
25
|
sessionToken?: string;
|
|
16
26
|
}
|
|
17
|
-
declare class LocalStorageDriver implements
|
|
27
|
+
declare class LocalStorageDriver implements StreamingStorage {
|
|
18
28
|
private readonly rootDirectory;
|
|
19
29
|
constructor(rootDirectory?: string);
|
|
20
30
|
private resolvePath;
|
|
21
31
|
put(path: string, contents: string | Uint8Array): Promise<string>;
|
|
22
32
|
get(path: string): Promise<Uint8Array | null>;
|
|
33
|
+
readStream(path: string): Promise<ReadableStream<Uint8Array> | null>;
|
|
34
|
+
writeStream(path: string, contents: ReadableStream<Uint8Array> | Blob): Promise<string>;
|
|
23
35
|
delete(path: string): Promise<void>;
|
|
24
36
|
}
|
|
25
|
-
declare class S3StorageDriver implements
|
|
37
|
+
declare class S3StorageDriver implements StreamingStorage {
|
|
26
38
|
private readonly client;
|
|
27
39
|
constructor(client: S3Client);
|
|
28
40
|
put(path: string, contents: string | Uint8Array): Promise<string>;
|
|
29
41
|
get(path: string): Promise<Uint8Array | null>;
|
|
42
|
+
readStream(path: string): Promise<ReadableStream<Uint8Array> | null>;
|
|
43
|
+
writeStream(path: string, contents: ReadableStream<Uint8Array> | Blob): Promise<string>;
|
|
30
44
|
delete(path: string): Promise<void>;
|
|
31
45
|
}
|
|
32
|
-
declare class StorageManager {
|
|
46
|
+
declare class StorageManager implements StreamingStorage {
|
|
33
47
|
private readonly driver;
|
|
34
48
|
constructor(driver: StorageDriver);
|
|
35
49
|
put(path: string, contents: string | Uint8Array): Promise<string>;
|
|
36
50
|
get(path: string): Promise<Uint8Array | null>;
|
|
51
|
+
streamingDriver(): StreamingStorage;
|
|
52
|
+
readStream(path: string): Promise<ReadableStream<Uint8Array> | null>;
|
|
53
|
+
writeStream(path: string, contents: ReadableStream<Uint8Array> | Blob): Promise<string>;
|
|
37
54
|
delete(path: string): Promise<void>;
|
|
38
55
|
}
|
|
39
56
|
type StorageConfig = {
|
|
@@ -49,5 +66,5 @@ declare function resolveS3Config(env?: Readonly<Record<string, string | undefine
|
|
|
49
66
|
declare function resolveStorageConfig(env?: Readonly<Record<string, string | undefined>>): StorageConfig;
|
|
50
67
|
declare function createS3Client(config: Readonly<S3StorageConfig>): S3Client;
|
|
51
68
|
declare function createStorageDriver(config: StorageConfig): StorageDriver;
|
|
52
|
-
export type { S3StorageConfig, StorageConfig, StorageDriver };
|
|
53
|
-
export { CORE_STORAGE_TOKEN, createS3Client, createStorageDriver, LocalStorageDriver, resolveS3Config, resolveStorageConfig, S3StorageDriver, StorageManager, snapshotStorageConfig, };
|
|
69
|
+
export type { S3StorageConfig, Storage, StorageConfig, StorageDriver, StreamingStorage };
|
|
70
|
+
export { CORE_STORAGE_TOKEN, createS3Client, createStorageDriver, LocalStorageDriver, requireStreamingStorage, resolveS3Config, resolveStorageConfig, S3StorageDriver, StorageManager, snapshotStorageConfig, };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Test controls share the same package-private state as every production entry.
|
|
2
|
+
* Production imports expose no test controls; this entry shares their private state.
|
|
3
|
+
*/
|
|
4
|
+
export { resetMysqlLoaderForTests } from "#strata-mysql-native";
|
|
5
|
+
export { resetDnsLookupForTests, resetMemoryLoginThrottleForTests, resetMemoryThrottleForTests, setDnsLookupForTests, setNodeSamlLoaderForTests, } from "#strata-test-state";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { NodeSamlModule } from "./auth/saml/samlServiceProvider";
|
|
2
|
+
type DnsLookup = (hostname: string, options: {
|
|
3
|
+
all: true;
|
|
4
|
+
verbatim: true;
|
|
5
|
+
}) => Promise<{
|
|
6
|
+
address: string;
|
|
7
|
+
family: number;
|
|
8
|
+
}[]>;
|
|
9
|
+
/** Package-private test controls. Production resource ownership stays with each adapter. */
|
|
10
|
+
declare const testState: {
|
|
11
|
+
throttleGeneration: number;
|
|
12
|
+
loginThrottleGeneration: number;
|
|
13
|
+
dnsLookup: DnsLookup | undefined;
|
|
14
|
+
nodeSamlLoader: (() => Promise<NodeSamlModule>) | null;
|
|
15
|
+
};
|
|
16
|
+
/** Generations avoid retaining middleware instances in a global test registry. */
|
|
17
|
+
declare function resetMemoryThrottleForTests(): void;
|
|
18
|
+
declare function resetMemoryLoginThrottleForTests(): void;
|
|
19
|
+
declare function setDnsLookupForTests(lookupFn: NonNullable<typeof testState.dnsLookup>): void;
|
|
20
|
+
declare function resetDnsLookupForTests(): void;
|
|
21
|
+
declare function setNodeSamlLoaderForTests(loader: typeof testState.nodeSamlLoader): void;
|
|
22
|
+
export { resetDnsLookupForTests, resetMemoryLoginThrottleForTests, resetMemoryThrottleForTests, setDnsLookupForTests, setNodeSamlLoaderForTests, testState, };
|
|
@@ -189,6 +189,7 @@ async function safeFetch(input, init = {}, options = {}) {
|
|
|
189
189
|
|
|
190
190
|
// ../../src/core/security/safeUrl.ts
|
|
191
191
|
import { BadRequestError } from "@getstrata/core/errors/http";
|
|
192
|
+
import { testState } from "#strata-test-state";
|
|
192
193
|
var BLOCKED_HOSTNAMES = new Set([
|
|
193
194
|
"localhost",
|
|
194
195
|
"127.0.0.1",
|
|
@@ -1,4 +1,65 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// ../../src/core/config/envSchema.ts
|
|
3
|
+
function defineEnvSchema(schema) {
|
|
4
|
+
return schema;
|
|
5
|
+
}
|
|
6
|
+
function validateEnv(schema, env = process.env) {
|
|
7
|
+
const resolved = {};
|
|
8
|
+
for (const [name, rule] of Object.entries(schema)) {
|
|
9
|
+
if (rule.integer) {
|
|
10
|
+
if (rule.minimum !== undefined && !Number.isSafeInteger(rule.minimum) || rule.maximum !== undefined && !Number.isSafeInteger(rule.maximum) || rule.minimum !== undefined && rule.maximum !== undefined && rule.minimum > rule.maximum) {
|
|
11
|
+
throw new TypeError(`Environment integer rule for "${name}" has invalid bounds.`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const rawValue = env[name];
|
|
15
|
+
if (rawValue !== undefined && typeof rawValue !== "string") {
|
|
16
|
+
throw new TypeError(`Environment variable "${name}" must be a string.`);
|
|
17
|
+
}
|
|
18
|
+
const value = rawValue === undefined || rawValue.trim() === "" ? rule.default : rawValue;
|
|
19
|
+
if (value !== undefined && typeof value !== "string") {
|
|
20
|
+
throw new TypeError(`Environment variable "${name}" must resolve to a string.`);
|
|
21
|
+
}
|
|
22
|
+
if (value === undefined || value.trim() === "") {
|
|
23
|
+
if (rule.required) {
|
|
24
|
+
throw new Error(`Missing required environment variable "${name}".`);
|
|
25
|
+
}
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (rule.integer) {
|
|
29
|
+
const completeInteger = /^[+-]?\d+$/.test(value.trim());
|
|
30
|
+
const parsed = Number.parseInt(value, 10);
|
|
31
|
+
const minimum = rule.minimum ?? Number.NEGATIVE_INFINITY;
|
|
32
|
+
const maximum = rule.maximum ?? Number.POSITIVE_INFINITY;
|
|
33
|
+
if (!completeInteger || !Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
|
|
34
|
+
const comparison = minimum !== Number.NEGATIVE_INFINITY && maximum !== Number.POSITIVE_INFINITY ? `an integer between ${minimum} and ${maximum}` : maximum !== Number.POSITIVE_INFINITY ? `an integer <= ${maximum}` : minimum === Number.NEGATIVE_INFINITY ? "an integer" : `an integer >= ${minimum}`;
|
|
35
|
+
throw new Error(`Environment variable "${name}" must be ${comparison}.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (rule.pattern && !new RegExp(rule.pattern.source, rule.pattern.flags).test(value)) {
|
|
39
|
+
throw new Error(`Environment variable "${name}" has an invalid format.`);
|
|
40
|
+
}
|
|
41
|
+
Object.defineProperty(resolved, name, {
|
|
42
|
+
value,
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return resolved;
|
|
49
|
+
}
|
|
50
|
+
function resolveEnv(schema, env = process.env) {
|
|
51
|
+
const validated = validateEnv(schema, env);
|
|
52
|
+
const resolved = {};
|
|
53
|
+
for (const [name, rule] of Object.entries(schema)) {
|
|
54
|
+
const value = validated[name];
|
|
55
|
+
Object.defineProperty(resolved, name, {
|
|
56
|
+
value: value === undefined ? undefined : rule.integer ? Number(value) : value,
|
|
57
|
+
enumerable: true
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return Object.freeze(resolved);
|
|
61
|
+
}
|
|
62
|
+
|
|
2
63
|
// ../../src/core/http/cookies.ts
|
|
3
64
|
function readRequestCookie(request, name) {
|
|
4
65
|
const cookies = request.cookies;
|
|
@@ -177,8 +238,13 @@ function intendedUrlCookieName(env) {
|
|
|
177
238
|
return env.INTENDED_URL_COOKIE_NAME?.trim() || appCookieName("intended", env);
|
|
178
239
|
}
|
|
179
240
|
function intendedUrlTtlSeconds(env) {
|
|
180
|
-
|
|
181
|
-
|
|
241
|
+
return resolveEnv({
|
|
242
|
+
INTENDED_URL_TTL_SECONDS: {
|
|
243
|
+
integer: true,
|
|
244
|
+
minimum: 1,
|
|
245
|
+
default: String(DEFAULT_INTENDED_URL_TTL_SECONDS)
|
|
246
|
+
}
|
|
247
|
+
}, env).INTENDED_URL_TTL_SECONDS;
|
|
182
248
|
}
|
|
183
249
|
function cookieSecureFlag(options) {
|
|
184
250
|
return options.production ? "; Secure" : "";
|
package/dist/entries/auth/jwt.js
CHANGED
|
@@ -2,6 +2,67 @@
|
|
|
2
2
|
// ../../src/core/auth/jwt.ts
|
|
3
3
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
4
4
|
|
|
5
|
+
// ../../src/core/config/envSchema.ts
|
|
6
|
+
function defineEnvSchema(schema) {
|
|
7
|
+
return schema;
|
|
8
|
+
}
|
|
9
|
+
function validateEnv(schema, env = process.env) {
|
|
10
|
+
const resolved = {};
|
|
11
|
+
for (const [name, rule] of Object.entries(schema)) {
|
|
12
|
+
if (rule.integer) {
|
|
13
|
+
if (rule.minimum !== undefined && !Number.isSafeInteger(rule.minimum) || rule.maximum !== undefined && !Number.isSafeInteger(rule.maximum) || rule.minimum !== undefined && rule.maximum !== undefined && rule.minimum > rule.maximum) {
|
|
14
|
+
throw new TypeError(`Environment integer rule for "${name}" has invalid bounds.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const rawValue = env[name];
|
|
18
|
+
if (rawValue !== undefined && typeof rawValue !== "string") {
|
|
19
|
+
throw new TypeError(`Environment variable "${name}" must be a string.`);
|
|
20
|
+
}
|
|
21
|
+
const value = rawValue === undefined || rawValue.trim() === "" ? rule.default : rawValue;
|
|
22
|
+
if (value !== undefined && typeof value !== "string") {
|
|
23
|
+
throw new TypeError(`Environment variable "${name}" must resolve to a string.`);
|
|
24
|
+
}
|
|
25
|
+
if (value === undefined || value.trim() === "") {
|
|
26
|
+
if (rule.required) {
|
|
27
|
+
throw new Error(`Missing required environment variable "${name}".`);
|
|
28
|
+
}
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (rule.integer) {
|
|
32
|
+
const completeInteger = /^[+-]?\d+$/.test(value.trim());
|
|
33
|
+
const parsed = Number.parseInt(value, 10);
|
|
34
|
+
const minimum = rule.minimum ?? Number.NEGATIVE_INFINITY;
|
|
35
|
+
const maximum = rule.maximum ?? Number.POSITIVE_INFINITY;
|
|
36
|
+
if (!completeInteger || !Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
|
|
37
|
+
const comparison = minimum !== Number.NEGATIVE_INFINITY && maximum !== Number.POSITIVE_INFINITY ? `an integer between ${minimum} and ${maximum}` : maximum !== Number.POSITIVE_INFINITY ? `an integer <= ${maximum}` : minimum === Number.NEGATIVE_INFINITY ? "an integer" : `an integer >= ${minimum}`;
|
|
38
|
+
throw new Error(`Environment variable "${name}" must be ${comparison}.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (rule.pattern && !new RegExp(rule.pattern.source, rule.pattern.flags).test(value)) {
|
|
42
|
+
throw new Error(`Environment variable "${name}" has an invalid format.`);
|
|
43
|
+
}
|
|
44
|
+
Object.defineProperty(resolved, name, {
|
|
45
|
+
value,
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return resolved;
|
|
52
|
+
}
|
|
53
|
+
function resolveEnv(schema, env = process.env) {
|
|
54
|
+
const validated = validateEnv(schema, env);
|
|
55
|
+
const resolved = {};
|
|
56
|
+
for (const [name, rule] of Object.entries(schema)) {
|
|
57
|
+
const value = validated[name];
|
|
58
|
+
Object.defineProperty(resolved, name, {
|
|
59
|
+
value: value === undefined ? undefined : rule.integer ? Number(value) : value,
|
|
60
|
+
enumerable: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return Object.freeze(resolved);
|
|
64
|
+
}
|
|
65
|
+
|
|
5
66
|
// ../../src/core/runtime/appEnv.ts
|
|
6
67
|
var NON_PRODUCTION_APP_ENVS = new Set(["local", "development", "dev", "test", "testing", "ci"]);
|
|
7
68
|
function normalizeEnvValue(value) {
|
|
@@ -58,10 +119,10 @@ function otelServiceName(env = process.env) {
|
|
|
58
119
|
|
|
59
120
|
// ../../src/core/auth/jwt.ts
|
|
60
121
|
function jwtOptionsFromEnvironment(env) {
|
|
61
|
-
const
|
|
122
|
+
const ttl = resolveEnv({ JWT_TTL_SECONDS: { integer: true, minimum: 1, default: "3600" } }, env);
|
|
62
123
|
return Object.freeze({
|
|
63
124
|
secret: requireConfiguredSecret(["JWT_SECRET", "SESSION_SECRET"], "jwt-secret", env),
|
|
64
|
-
ttlSeconds:
|
|
125
|
+
ttlSeconds: ttl.JWT_TTL_SECONDS
|
|
65
126
|
});
|
|
66
127
|
}
|
|
67
128
|
function resolveJwtSecret(secret) {
|
|
@@ -71,10 +132,11 @@ function resolveJwtSecret(secret) {
|
|
|
71
132
|
throw new TypeError("Explicit JWT secret is required.");
|
|
72
133
|
}
|
|
73
134
|
function jwtTtlSeconds(override) {
|
|
74
|
-
if (
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
135
|
+
if (override === undefined)
|
|
136
|
+
return 3600;
|
|
137
|
+
if (!Number.isSafeInteger(override) || override <= 0)
|
|
138
|
+
throw new TypeError("JWT ttlSeconds must be a positive safe integer.");
|
|
139
|
+
return override;
|
|
78
140
|
}
|
|
79
141
|
function encodeJson(value) {
|
|
80
142
|
return Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
@@ -63,6 +63,67 @@ function matchesAuthVersion(issued, current) {
|
|
|
63
63
|
// ../../src/core/auth/jwt.ts
|
|
64
64
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
65
65
|
|
|
66
|
+
// ../../src/core/config/envSchema.ts
|
|
67
|
+
function defineEnvSchema(schema) {
|
|
68
|
+
return schema;
|
|
69
|
+
}
|
|
70
|
+
function validateEnv(schema, env = process.env) {
|
|
71
|
+
const resolved = {};
|
|
72
|
+
for (const [name, rule] of Object.entries(schema)) {
|
|
73
|
+
if (rule.integer) {
|
|
74
|
+
if (rule.minimum !== undefined && !Number.isSafeInteger(rule.minimum) || rule.maximum !== undefined && !Number.isSafeInteger(rule.maximum) || rule.minimum !== undefined && rule.maximum !== undefined && rule.minimum > rule.maximum) {
|
|
75
|
+
throw new TypeError(`Environment integer rule for "${name}" has invalid bounds.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const rawValue = env[name];
|
|
79
|
+
if (rawValue !== undefined && typeof rawValue !== "string") {
|
|
80
|
+
throw new TypeError(`Environment variable "${name}" must be a string.`);
|
|
81
|
+
}
|
|
82
|
+
const value = rawValue === undefined || rawValue.trim() === "" ? rule.default : rawValue;
|
|
83
|
+
if (value !== undefined && typeof value !== "string") {
|
|
84
|
+
throw new TypeError(`Environment variable "${name}" must resolve to a string.`);
|
|
85
|
+
}
|
|
86
|
+
if (value === undefined || value.trim() === "") {
|
|
87
|
+
if (rule.required) {
|
|
88
|
+
throw new Error(`Missing required environment variable "${name}".`);
|
|
89
|
+
}
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (rule.integer) {
|
|
93
|
+
const completeInteger = /^[+-]?\d+$/.test(value.trim());
|
|
94
|
+
const parsed = Number.parseInt(value, 10);
|
|
95
|
+
const minimum = rule.minimum ?? Number.NEGATIVE_INFINITY;
|
|
96
|
+
const maximum = rule.maximum ?? Number.POSITIVE_INFINITY;
|
|
97
|
+
if (!completeInteger || !Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
|
|
98
|
+
const comparison = minimum !== Number.NEGATIVE_INFINITY && maximum !== Number.POSITIVE_INFINITY ? `an integer between ${minimum} and ${maximum}` : maximum !== Number.POSITIVE_INFINITY ? `an integer <= ${maximum}` : minimum === Number.NEGATIVE_INFINITY ? "an integer" : `an integer >= ${minimum}`;
|
|
99
|
+
throw new Error(`Environment variable "${name}" must be ${comparison}.`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (rule.pattern && !new RegExp(rule.pattern.source, rule.pattern.flags).test(value)) {
|
|
103
|
+
throw new Error(`Environment variable "${name}" has an invalid format.`);
|
|
104
|
+
}
|
|
105
|
+
Object.defineProperty(resolved, name, {
|
|
106
|
+
value,
|
|
107
|
+
enumerable: true,
|
|
108
|
+
configurable: true,
|
|
109
|
+
writable: true
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return resolved;
|
|
113
|
+
}
|
|
114
|
+
function resolveEnv(schema, env = process.env) {
|
|
115
|
+
const validated = validateEnv(schema, env);
|
|
116
|
+
const resolved = {};
|
|
117
|
+
for (const [name, rule] of Object.entries(schema)) {
|
|
118
|
+
const value = validated[name];
|
|
119
|
+
Object.defineProperty(resolved, name, {
|
|
120
|
+
value: value === undefined ? undefined : rule.integer ? Number(value) : value,
|
|
121
|
+
enumerable: true
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return Object.freeze(resolved);
|
|
125
|
+
}
|
|
126
|
+
|
|
66
127
|
// ../../src/core/runtime/appEnv.ts
|
|
67
128
|
var NON_PRODUCTION_APP_ENVS = new Set(["local", "development", "dev", "test", "testing", "ci"]);
|
|
68
129
|
function normalizeEnvValue(value) {
|
|
@@ -119,10 +180,10 @@ function otelServiceName(env = process.env) {
|
|
|
119
180
|
|
|
120
181
|
// ../../src/core/auth/jwt.ts
|
|
121
182
|
function jwtOptionsFromEnvironment(env) {
|
|
122
|
-
const
|
|
183
|
+
const ttl = resolveEnv({ JWT_TTL_SECONDS: { integer: true, minimum: 1, default: "3600" } }, env);
|
|
123
184
|
return Object.freeze({
|
|
124
185
|
secret: requireConfiguredSecret(["JWT_SECRET", "SESSION_SECRET"], "jwt-secret", env),
|
|
125
|
-
ttlSeconds:
|
|
186
|
+
ttlSeconds: ttl.JWT_TTL_SECONDS
|
|
126
187
|
});
|
|
127
188
|
}
|
|
128
189
|
function resolveJwtSecret(secret) {
|
|
@@ -132,10 +193,11 @@ function resolveJwtSecret(secret) {
|
|
|
132
193
|
throw new TypeError("Explicit JWT secret is required.");
|
|
133
194
|
}
|
|
134
195
|
function jwtTtlSeconds(override) {
|
|
135
|
-
if (
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
|
|
196
|
+
if (override === undefined)
|
|
197
|
+
return 3600;
|
|
198
|
+
if (!Number.isSafeInteger(override) || override <= 0)
|
|
199
|
+
throw new TypeError("JWT ttlSeconds must be a positive safe integer.");
|
|
200
|
+
return override;
|
|
139
201
|
}
|
|
140
202
|
function encodeJson(value) {
|
|
141
203
|
return Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
@@ -263,15 +325,17 @@ function createSessionReader(options) {
|
|
|
263
325
|
function sessionCookieName(env) {
|
|
264
326
|
return env.SESSION_COOKIE_NAME?.trim() || appCookieName("session", env);
|
|
265
327
|
}
|
|
266
|
-
function parsePositiveSeconds(raw, fallback) {
|
|
267
|
-
const parsed = Number.parseInt(raw ?? "", 10);
|
|
268
|
-
return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;
|
|
269
|
-
}
|
|
270
328
|
function sessionTtlSeconds(env) {
|
|
271
|
-
return
|
|
329
|
+
return resolveEnv({ SESSION_TTL_SECONDS: { integer: true, minimum: 1, default: String(SESSION_TTL_SECONDS) } }, env).SESSION_TTL_SECONDS;
|
|
272
330
|
}
|
|
273
331
|
function sessionRememberTtlSeconds(env) {
|
|
274
|
-
return
|
|
332
|
+
return resolveEnv({
|
|
333
|
+
SESSION_REMEMBER_TTL_SECONDS: {
|
|
334
|
+
integer: true,
|
|
335
|
+
minimum: 1,
|
|
336
|
+
default: String(SESSION_REMEMBER_TTL_SECONDS)
|
|
337
|
+
}
|
|
338
|
+
}, env).SESSION_REMEMBER_TTL_SECONDS;
|
|
275
339
|
}
|
|
276
340
|
function missingSessionSecret() {
|
|
277
341
|
throw new TypeError("Explicit session secret is required.");
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// ../../src/core/auth/saml/samlServiceProvider.ts
|
|
3
|
+
import { testState } from "#strata-test-state";
|
|
4
|
+
|
|
2
5
|
// ../../src/core/runtime/optionalPeer.ts
|
|
3
6
|
function missingOptionalPeer(packageName, reason, error) {
|
|
4
7
|
return new Error(`Install ${packageName} ${reason} (\`bun add ${packageName}\`).`, {
|
|
@@ -140,20 +143,16 @@ function readSamlEnvOptions(env = process.env) {
|
|
|
140
143
|
disableRequestedAuthnContext: env.SAML_DISABLE_REQUESTED_AUTHN_CONTEXT === "true"
|
|
141
144
|
};
|
|
142
145
|
}
|
|
143
|
-
var nodeSamlLoader = null;
|
|
144
146
|
async function defaultLoadNodeSaml() {
|
|
145
147
|
return await import("@node-saml/node-saml");
|
|
146
148
|
}
|
|
147
149
|
async function loadNodeSaml() {
|
|
148
150
|
try {
|
|
149
|
-
return await (nodeSamlLoader ?? defaultLoadNodeSaml)();
|
|
151
|
+
return await (testState.nodeSamlLoader ?? defaultLoadNodeSaml)();
|
|
150
152
|
} catch (error) {
|
|
151
153
|
throw missingOptionalPeer("@node-saml/node-saml", "to verify SAML assertions", error);
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
|
-
function setNodeSamlLoaderForTests(loader) {
|
|
155
|
-
nodeSamlLoader = loader;
|
|
156
|
-
}
|
|
157
156
|
|
|
158
157
|
class SamlServiceProvider {
|
|
159
158
|
client = null;
|
|
@@ -2,6 +2,67 @@
|
|
|
2
2
|
// ../../src/core/auth/passwordConfirmCookie.ts
|
|
3
3
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
4
4
|
|
|
5
|
+
// ../../src/core/config/envSchema.ts
|
|
6
|
+
function defineEnvSchema(schema) {
|
|
7
|
+
return schema;
|
|
8
|
+
}
|
|
9
|
+
function validateEnv(schema, env = process.env) {
|
|
10
|
+
const resolved = {};
|
|
11
|
+
for (const [name, rule] of Object.entries(schema)) {
|
|
12
|
+
if (rule.integer) {
|
|
13
|
+
if (rule.minimum !== undefined && !Number.isSafeInteger(rule.minimum) || rule.maximum !== undefined && !Number.isSafeInteger(rule.maximum) || rule.minimum !== undefined && rule.maximum !== undefined && rule.minimum > rule.maximum) {
|
|
14
|
+
throw new TypeError(`Environment integer rule for "${name}" has invalid bounds.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const rawValue = env[name];
|
|
18
|
+
if (rawValue !== undefined && typeof rawValue !== "string") {
|
|
19
|
+
throw new TypeError(`Environment variable "${name}" must be a string.`);
|
|
20
|
+
}
|
|
21
|
+
const value = rawValue === undefined || rawValue.trim() === "" ? rule.default : rawValue;
|
|
22
|
+
if (value !== undefined && typeof value !== "string") {
|
|
23
|
+
throw new TypeError(`Environment variable "${name}" must resolve to a string.`);
|
|
24
|
+
}
|
|
25
|
+
if (value === undefined || value.trim() === "") {
|
|
26
|
+
if (rule.required) {
|
|
27
|
+
throw new Error(`Missing required environment variable "${name}".`);
|
|
28
|
+
}
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (rule.integer) {
|
|
32
|
+
const completeInteger = /^[+-]?\d+$/.test(value.trim());
|
|
33
|
+
const parsed = Number.parseInt(value, 10);
|
|
34
|
+
const minimum = rule.minimum ?? Number.NEGATIVE_INFINITY;
|
|
35
|
+
const maximum = rule.maximum ?? Number.POSITIVE_INFINITY;
|
|
36
|
+
if (!completeInteger || !Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
|
|
37
|
+
const comparison = minimum !== Number.NEGATIVE_INFINITY && maximum !== Number.POSITIVE_INFINITY ? `an integer between ${minimum} and ${maximum}` : maximum !== Number.POSITIVE_INFINITY ? `an integer <= ${maximum}` : minimum === Number.NEGATIVE_INFINITY ? "an integer" : `an integer >= ${minimum}`;
|
|
38
|
+
throw new Error(`Environment variable "${name}" must be ${comparison}.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (rule.pattern && !new RegExp(rule.pattern.source, rule.pattern.flags).test(value)) {
|
|
42
|
+
throw new Error(`Environment variable "${name}" has an invalid format.`);
|
|
43
|
+
}
|
|
44
|
+
Object.defineProperty(resolved, name, {
|
|
45
|
+
value,
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return resolved;
|
|
52
|
+
}
|
|
53
|
+
function resolveEnv(schema, env = process.env) {
|
|
54
|
+
const validated = validateEnv(schema, env);
|
|
55
|
+
const resolved = {};
|
|
56
|
+
for (const [name, rule] of Object.entries(schema)) {
|
|
57
|
+
const value = validated[name];
|
|
58
|
+
Object.defineProperty(resolved, name, {
|
|
59
|
+
value: value === undefined ? undefined : rule.integer ? Number(value) : value,
|
|
60
|
+
enumerable: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return Object.freeze(resolved);
|
|
64
|
+
}
|
|
65
|
+
|
|
5
66
|
// ../../src/core/http/cookies.ts
|
|
6
67
|
function readRequestCookie(request, name) {
|
|
7
68
|
const cookies = request.cookies;
|
|
@@ -108,8 +169,13 @@ function passwordConfirmCookieName(env) {
|
|
|
108
169
|
return env.PASSWORD_CONFIRM_COOKIE_NAME?.trim() || appCookieName("password_confirmed", env);
|
|
109
170
|
}
|
|
110
171
|
function passwordConfirmTtlSeconds(env) {
|
|
111
|
-
|
|
112
|
-
|
|
172
|
+
return resolveEnv({
|
|
173
|
+
PASSWORD_CONFIRM_TIMEOUT: {
|
|
174
|
+
integer: true,
|
|
175
|
+
minimum: 1,
|
|
176
|
+
default: String(DEFAULT_PASSWORD_CONFIRM_TTL_SECONDS)
|
|
177
|
+
}
|
|
178
|
+
}, env).PASSWORD_CONFIRM_TIMEOUT;
|
|
113
179
|
}
|
|
114
180
|
function passwordConfirmOptionsFromEnvironment(env) {
|
|
115
181
|
return Object.freeze({
|
|
@@ -124,7 +190,7 @@ function missingPasswordConfirmSecret() {
|
|
|
124
190
|
}
|
|
125
191
|
function signPasswordConfirm(userId, confirmedAt, authVersion, secret) {
|
|
126
192
|
const payload = authVersion === undefined ? `${userId}.${confirmedAt}` : `v2.${userId}.${confirmedAt}.${authVersion}`;
|
|
127
|
-
const signature = createHmac("sha256", secret ?? missingPasswordConfirmSecret()).update(payload).digest("hex");
|
|
193
|
+
const signature = createHmac("sha256", secret ?? missingPasswordConfirmSecret()).update(`password-confirm:${payload}`).digest("hex");
|
|
128
194
|
return `${payload}.${signature}`;
|
|
129
195
|
}
|
|
130
196
|
function hasFreshPasswordConfirmation(request, userId, authVersion, options) {
|