@getstrata/core 2.2.60 → 3.0.3
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 +22 -0
- package/dist/core/audit/exportAuditLogs.d.ts +12 -3
- package/dist/core/audit/exportStore.d.ts +6 -2
- package/dist/core/audit/siemFormatter.d.ts +2 -2
- package/dist/core/auth/abilityCatalog.d.ts +1 -9
- package/dist/core/auth/authContext.d.ts +2 -0
- package/dist/core/auth/authOutcome.d.ts +32 -0
- package/dist/core/auth/authReader.d.ts +22 -0
- package/dist/core/auth/basicAuthGuard.d.ts +19 -3
- package/dist/core/auth/emailVerification.d.ts +1 -1
- package/dist/core/auth/guard.d.ts +27 -6
- package/dist/core/auth/intendedUrlCookie.d.ts +13 -7
- package/dist/core/auth/jwt.d.ts +5 -4
- package/dist/core/auth/jwtGuard.d.ts +7 -6
- package/dist/core/auth/membershipContext.d.ts +10 -7
- package/dist/core/auth/membershipContextMiddleware.d.ts +3 -3
- package/dist/core/auth/membershipMiddleware.d.ts +1 -2
- package/dist/core/auth/membershipServiceImplementation.d.ts +1 -1
- package/dist/core/auth/oauth/oidcIdToken.d.ts +25 -16
- package/dist/core/auth/oauth/oidcProvider.d.ts +6 -4
- package/dist/core/auth/oauth/providers.d.ts +3 -1
- package/dist/core/auth/oneTimeToken.d.ts +2 -3
- package/dist/core/auth/passwordConfirmCookie.d.ts +15 -6
- package/dist/core/auth/passwordLogin.d.ts +5 -5
- package/dist/core/auth/pendingMfaCookie.d.ts +2 -2
- package/dist/core/auth/policy.d.ts +23 -10
- package/dist/core/auth/requireAuthCapability.d.ts +3 -0
- package/dist/core/auth/resolveMembershipService.d.ts +3 -2
- package/dist/core/auth/saml/samlAssertionReplay.d.ts +4 -4
- package/dist/core/auth/saml/samlServiceProvider.d.ts +11 -7
- package/dist/core/auth/scimAuthMiddleware.d.ts +10 -3
- package/dist/core/auth/sessionCookie.d.ts +20 -9
- package/dist/core/auth/sessionGuard.d.ts +14 -3
- package/dist/core/cache/createCacheStore.d.ts +6 -3
- package/dist/core/cache/redisCacheStore.d.ts +5 -1
- package/dist/core/cache/repository.d.ts +5 -1
- package/dist/core/cache/simpleCache.d.ts +2 -1
- package/dist/core/cache/tokens.d.ts +8 -0
- package/dist/core/config/applicationConfig.d.ts +21 -0
- package/dist/core/config/configSnapshot.d.ts +3 -0
- package/dist/core/config/envSchema.d.ts +3 -2
- package/dist/core/contracts/application.d.ts +153 -0
- package/dist/core/contracts/authUserDirectory.d.ts +24 -7
- package/dist/core/contracts/container.d.ts +20 -23
- package/dist/core/contracts/di.d.ts +4 -2
- package/dist/core/contracts/executionContext.d.ts +5 -0
- package/dist/core/contracts/executionOperations.d.ts +10 -0
- package/dist/core/contracts/executionOwnership.d.ts +38 -0
- package/dist/core/contracts/persistence.d.ts +20 -0
- package/dist/core/contracts/serviceTokens.d.ts +32 -18
- package/dist/core/contracts/services.d.ts +63 -0
- package/dist/core/contracts/token.d.ts +19 -0
- package/dist/core/crypto/fieldEncryption.d.ts +19 -7
- package/dist/core/crypto/fieldEncryptionRotation.d.ts +21 -5
- package/dist/core/crypto/mfaSecret.d.ts +10 -3
- package/dist/core/database/baseRepository.d.ts +14 -10
- package/dist/core/database/bindings.d.ts +6 -0
- package/dist/core/database/bunSql.d.ts +3 -12
- package/dist/core/database/definitions.d.ts +209 -0
- package/dist/core/database/dialect.d.ts +5 -24
- package/dist/core/database/driverPorts.d.ts +116 -0
- package/dist/core/database/errors.d.ts +47 -7
- package/dist/core/database/factory.d.ts +51 -31
- package/dist/core/database/index.d.ts +9 -10
- package/dist/core/database/keyset.d.ts +2 -1
- package/dist/core/database/legacyNativeTransaction.d.ts +5 -0
- package/dist/core/database/manager.d.ts +12 -0
- package/dist/core/database/model.d.ts +91 -97
- package/dist/core/database/modelQuery.d.ts +9 -5
- package/dist/core/database/modelRegistry.d.ts +52 -33
- package/dist/core/database/mysqlConnection.d.ts +1 -19
- package/dist/core/database/mysqlNative.d.ts +38 -0
- package/dist/core/database/nativeTransactions.d.ts +16 -0
- package/dist/core/database/ormInternal.d.ts +85 -0
- package/dist/core/database/ormRuntime.d.ts +4 -0
- package/dist/core/database/ownedReadOnlyObservation.d.ts +16 -0
- package/dist/core/database/postgresNative.d.ts +11 -0
- package/dist/core/database/query.d.ts +24 -23
- package/dist/core/database/queryPlanSnapshot.d.ts +7 -0
- package/dist/core/database/rawMysql.d.ts +7 -0
- package/dist/core/database/rawPostgres.d.ts +23 -0
- package/dist/core/database/rawSqlite.d.ts +6 -0
- package/dist/core/database/relationQueries.d.ts +3 -2
- package/dist/core/database/relationQuery.d.ts +24 -6
- package/dist/core/database/repositoryQuery.d.ts +6 -1
- package/dist/core/database/schema/driver.d.ts +1 -1
- package/dist/core/database/seeders/types.d.ts +1 -1
- package/dist/core/database/session.d.ts +13 -0
- package/dist/core/database/sessionFactory.d.ts +9 -0
- package/dist/core/database/sqlDialects.d.ts +22 -0
- package/dist/core/database/tokens.d.ts +7 -0
- package/dist/core/database/transactionSession.d.ts +43 -0
- package/dist/core/errors/http.d.ts +4 -1
- package/dist/core/events/{eventBus.d.ts → eventBusClass.d.ts} +1 -3
- package/dist/core/events/index.d.ts +2 -3
- package/dist/core/events/outbox/index.d.ts +44 -13
- package/dist/core/events/outbox/metrics.d.ts +4 -4
- package/dist/core/events/outbox/workerTransport.d.ts +17 -0
- package/dist/core/http/authMiddleware.d.ts +2 -2
- package/dist/core/http/authorizeMiddleware.d.ts +2 -2
- package/dist/core/http/bodySizeLimitMiddleware.d.ts +1 -1
- package/dist/core/http/conditionalResponse.d.ts +7 -2
- package/dist/core/http/contentSecurityPolicy.d.ts +4 -3
- package/dist/core/http/corsMiddleware.d.ts +2 -1
- package/dist/core/http/csrfMiddleware.d.ts +6 -1
- package/dist/core/http/csrfToken.d.ts +17 -7
- package/dist/core/http/databaseError.d.ts +4 -0
- package/dist/core/http/etag.d.ts +5 -2
- package/dist/core/http/flashMiddleware.d.ts +1 -1
- package/dist/core/http/flashSession.d.ts +13 -7
- package/dist/core/http/index.d.ts +1 -1
- package/dist/core/http/loginThrottleMiddleware.d.ts +3 -3
- package/dist/core/http/memoryThrottleMiddleware.d.ts +2 -2
- package/dist/core/http/parseMultipartUpload.d.ts +3 -2
- package/dist/core/http/requestMetaContext.d.ts +5 -0
- package/dist/core/http/requireAbilityMiddleware.d.ts +1 -1
- package/dist/core/http/requireAuthMiddleware.d.ts +2 -2
- package/dist/core/http/requirePasswordConfirmMiddleware.d.ts +2 -1
- package/dist/core/http/requireVerifiedMiddleware.d.ts +2 -2
- package/dist/core/http/requireWebAuthMiddleware.d.ts +2 -2
- package/dist/core/http/response.d.ts +4 -3
- package/dist/core/http/scimThrottleMiddleware.d.ts +4 -3
- package/dist/core/http/securedRouteModelBinding.d.ts +10 -3
- package/dist/core/http/securityHeadersMiddleware.d.ts +1 -2
- package/dist/core/http/signedUrl.d.ts +8 -6
- package/dist/core/http/throttleMiddleware.d.ts +9 -5
- package/dist/core/http/uploads.d.ts +9 -3
- package/dist/core/http/webErrorResponse.d.ts +8 -2
- package/dist/core/jobs/exportAuditLogsJob.d.ts +5 -2
- package/dist/core/jobs/invalidateCacheTagsJob.d.ts +5 -4
- package/dist/core/lifecycle/gracefulShutdown.d.ts +2 -5
- package/dist/core/logging/requestLoggingMiddleware.d.ts +1 -1
- package/dist/core/mail/mailer.d.ts +7 -5
- package/dist/core/openapi/generator.d.ts +12 -4
- package/dist/core/openapi/registeredRoute.d.ts +4 -4
- package/dist/core/queue/createAppQueue.d.ts +9 -4
- package/dist/core/queue/failedJobMetrics.d.ts +11 -2
- package/dist/core/queue/failedJobRepository.d.ts +6 -3
- package/dist/core/queue/failedJobService.d.ts +1 -0
- package/dist/core/queue/index.d.ts +16 -6
- package/dist/core/queue/jobRegistry.d.ts +3 -2
- package/dist/core/queue/jobRunner.d.ts +10 -4
- package/dist/core/queue/publicQueue.d.ts +18 -9
- package/dist/core/queue/queueConfig.d.ts +20 -10
- package/dist/core/queue/queueHandoff.d.ts +31 -0
- package/dist/core/queue/queueMetrics.d.ts +10 -3
- package/dist/core/queue/queueServices.d.ts +28 -0
- package/dist/core/queue/queueWorkerTransport.d.ts +28 -0
- package/dist/core/queue/redisQueue.d.ts +19 -10
- package/dist/core/queue/redisQueueKeys.d.ts +5 -5
- package/dist/core/queue/redisStreams.d.ts +17 -10
- package/dist/core/queue/resilientQueue.d.ts +10 -4
- package/dist/core/queue/types.d.ts +1 -0
- package/dist/core/runtime/appKeyPrefix.d.ts +5 -5
- package/dist/core/runtime/application.d.ts +7 -0
- package/dist/core/runtime/executionContext.d.ts +9 -0
- package/dist/core/runtime/executionTasks.d.ts +49 -0
- package/dist/core/runtime/resourceJournal.d.ts +67 -0
- package/dist/core/runtime/serviceGraph.d.ts +14 -0
- package/dist/core/security/oauthState.d.ts +13 -9
- package/dist/core/security/publicReads.d.ts +2 -2
- package/dist/core/security/safeFetch.d.ts +1 -0
- package/dist/core/security/safeUrl.d.ts +3 -0
- package/dist/core/security/scimTenantTokens.d.ts +1 -1
- package/dist/core/security/tokenExpiry.d.ts +1 -1
- package/dist/core/security/webhookSignature.d.ts +1 -1
- package/dist/core/storage/storage.d.ts +24 -16
- package/dist/core/tenant/databaseTenantContext.d.ts +5 -7
- package/dist/core/tenant/resolveTenant.d.ts +2 -2
- package/dist/core/tenant/scopedDatabasePolicy.d.ts +8 -0
- package/dist/core/tenant/tenantDatabaseScope.d.ts +3 -7
- package/dist/core/tenant/tenantMiddleware.d.ts +15 -4
- package/dist/core/tracing/otel.d.ts +4 -6
- package/dist/core/tracing/tracingMiddleware.d.ts +3 -3
- package/dist/core/view/etaViewEngine.d.ts +1 -1
- package/dist/core/view/index.d.ts +5 -4
- package/dist/core/view/tokens.d.ts +8 -0
- package/dist/core/view/viewRenderer.d.ts +2 -2
- package/dist/core/view/webErrorView.d.ts +8 -7
- package/dist/core/view/webLayoutData.d.ts +6 -4
- package/dist/entries/audit/exportAuditLogs.js +87 -1024
- package/dist/entries/audit/siemFormatter.js +4 -90
- package/dist/entries/auth/abilityCatalog.js +28 -0
- package/dist/entries/auth/accessControl.js +5 -16
- package/dist/entries/auth/accountStateMigration.js +216 -236
- package/dist/entries/auth/authOutcome.js +80 -0
- package/dist/entries/auth/authReader.js +68 -0
- package/dist/entries/auth/basicAuthGuard.js +144 -1249
- package/dist/entries/auth/emailVerification.js +2 -2
- package/dist/entries/auth/intendedUrlCookie.js +35 -59
- package/dist/entries/auth/jwt.js +22 -47
- package/dist/entries/auth/jwtGuard.js +99 -231
- package/dist/entries/auth/membershipMiddleware.js +71 -10
- package/dist/entries/auth/membershipScope.js +16 -22
- package/dist/entries/auth/membershipService.js +11 -28
- package/dist/entries/auth/oauth/oidcProvider.js +59 -64
- package/dist/entries/auth/oauth/providers.js +12 -95
- package/dist/entries/auth/oauth/samlProvider.js +53 -1080
- package/dist/entries/auth/oneTimeToken.js +27 -289
- package/dist/entries/auth/passwordConfirmCookie.js +40 -63
- package/dist/entries/auth/passwordLogin.js +94 -399
- package/dist/entries/auth/pendingMfaCookie.js +6 -6
- package/dist/entries/auth/policy.js +22 -56
- package/dist/entries/auth/saml/samlServiceProvider.js +55 -1084
- package/dist/entries/auth/scimAuthMiddleware.js +16 -3358
- package/dist/entries/auth/sessionCookie.js +58 -73
- package/dist/entries/auth/sessionGuard.js +95 -248
- package/dist/entries/auth/tokenHash.js +11 -43
- package/dist/entries/cache/createCacheStore.js +126 -117
- package/dist/entries/cache/repository.js +25 -0
- package/dist/entries/cache/simpleCache.js +12 -7
- package/dist/entries/cache/tokens.js +9 -0
- package/dist/entries/config/applicationConfig.js +163 -0
- package/dist/entries/config/envSchema.js +21 -4
- package/dist/entries/contracts/application.js +1 -0
- package/dist/entries/contracts/authUserDirectory.js +10 -0
- package/dist/entries/contracts/container.js +99 -26
- package/dist/entries/contracts/di.js +3 -0
- package/dist/entries/contracts/executionContext.js +7 -0
- package/dist/entries/contracts/executionOperations.js +7 -0
- package/dist/entries/contracts/executionOwnership.js +7 -0
- package/dist/entries/contracts/membership.js +1 -0
- package/dist/entries/contracts/persistence.js +1 -0
- package/dist/entries/contracts/serviceTokens.js +26 -116
- package/dist/entries/contracts/services.js +98 -0
- package/dist/entries/contracts/token.js +41 -0
- package/dist/entries/crypto/fieldEncryption.js +49 -50
- package/dist/entries/crypto/mfaSecret.js +86 -82
- package/dist/entries/database/acquisitionMetrics.js +107 -0
- package/dist/entries/database/baseRepository.d.ts +2 -0
- package/dist/entries/database/bindings.js +2082 -0
- package/dist/entries/database/definitions.js +175 -0
- package/dist/entries/database/errors.js +114 -89
- package/dist/entries/database/factory.js +67 -28
- package/dist/entries/database/migrations.js +172 -224
- package/dist/entries/database/model.d.ts +1 -0
- package/dist/entries/database/ownedReadOnlyObservation.js +1282 -0
- package/dist/entries/database/query.js +159 -161
- package/dist/entries/database/repositoryQuery.d.ts +1 -0
- package/dist/entries/database/repositoryQuery.js +1 -1373
- package/dist/entries/database/schema.js +216 -236
- package/dist/entries/database/session.js +1 -0
- package/dist/entries/database/sqliteConnection.js +525 -83
- package/dist/entries/database/tokens.js +9 -0
- package/dist/entries/errors/http.js +118 -1
- package/dist/entries/http/authMiddleware.js +8 -5
- package/dist/entries/http/authorizeMiddleware.js +1 -1
- package/dist/entries/http/bodySizeLimitMiddleware.js +2 -2
- package/dist/entries/http/clientIp.js +2 -2
- package/dist/entries/http/conditionalResponse.js +19 -7
- package/dist/entries/http/corsMiddleware.js +6 -101
- package/dist/entries/http/csrfMiddleware.js +92 -106
- package/dist/entries/http/csrfToken.js +58 -94
- package/dist/entries/http/etag.js +7 -4
- package/dist/entries/http/flashMiddleware.js +57 -99
- package/dist/entries/http/flashSession.js +41 -68
- package/dist/entries/http/memoryThrottleMiddleware.js +43 -186
- package/dist/entries/http/metricsMiddleware.js +2 -16
- package/dist/entries/http/parseMultipartUpload.js +15 -29
- package/dist/entries/http/requireAbilityMiddleware.js +2 -2
- package/dist/entries/http/requirePasswordConfirmMiddleware.js +19 -31
- package/dist/entries/http/requireVerifiedMiddleware.js +4 -7
- package/dist/entries/http/requireWebAuthMiddleware.js +2 -2
- package/dist/entries/http/response.js +67 -233
- package/dist/entries/http/routeMiddleware.js +0 -14
- package/dist/entries/http/scimThrottleMiddleware.js +43 -237
- package/dist/entries/http/securedRouteModelBinding.js +37 -25
- package/dist/entries/http/securityHeadersMiddleware.js +8 -25
- package/dist/entries/http/signedUrl.js +20 -110
- package/dist/entries/http/throttleMiddleware.js +41 -185
- package/dist/entries/http/uploads.js +9 -24
- package/dist/entries/jobs/exportAuditLogsJob.js +17 -1498
- package/dist/entries/jobs/invalidateCacheTagsJob.js +12 -47
- package/dist/entries/logging/requestLoggingMiddleware.js +4 -4
- package/dist/entries/mail/mailer.js +68 -78
- package/dist/entries/openapi/generator.js +33 -100
- package/dist/entries/queue/createAppQueue.js +416 -256
- package/dist/entries/queue/failedJobRepository.js +17 -8
- package/dist/entries/queue/failedJobService.js +1 -0
- package/dist/entries/queue/jobRunner.js +141 -66
- package/dist/entries/queue/publicQueue.js +411 -257
- package/dist/entries/queue/queueConfig.js +61 -0
- package/dist/entries/queue/queueHandoff.js +318 -0
- package/dist/entries/queue/queueMetrics.js +989 -1386
- package/dist/entries/queue/queueServices.js +133 -0
- package/dist/entries/queue/queueWorkerTransport.js +1703 -0
- package/dist/entries/queue/redisQueue.js +282 -180
- package/dist/entries/queue.js +6 -45
- package/dist/entries/runtime/application.js +1585 -0
- package/dist/entries/runtime/asyncContextStore.js +0 -16
- package/dist/entries/security/oauthState.js +35 -67
- package/dist/entries/security/publicReads.js +4 -4
- package/dist/entries/security/safeFetch.js +1 -0
- package/dist/entries/security/scimTenantTokens.js +3 -3
- package/dist/entries/security/tokenExpiry.js +2 -2
- package/dist/entries/security/totp.js +1 -87
- package/dist/entries/security/webhookSignature.js +2 -90
- package/dist/entries/storage/storage.js +120 -45
- package/dist/entries/tenant/databaseTenantContext.js +6 -907
- package/dist/entries/tenant/publicTenantHost.js +78 -0
- package/dist/entries/tenant/resolveTenant.js +14 -0
- package/dist/entries/tenant/scopedDatabasePolicy.js +75 -0
- package/dist/entries/tenant/tenancyConfig.js +1 -19
- package/dist/entries/tenant/tenantDatabaseScope.js +3 -892
- package/dist/entries/tracing/tracingMiddleware.js +104 -173
- package/dist/entries/view/tokens.js +11 -0
- package/dist/framework/public-api.d.ts +62 -44
- package/dist/index.js +10435 -11351
- package/dist/internal/ormInternal.js +117 -0
- package/dist/internal/ormRuntime.js +5000 -0
- package/package.json +158 -46
- package/dist/core/database/bindConnection.d.ts +0 -1
- package/dist/core/database/boundConnection.d.ts +0 -5
- package/dist/core/database/defaultConnection.d.ts +0 -7
- package/dist/core/database/namedConnections.d.ts +0 -15
- package/dist/core/database/readOnlyCollector.d.ts +0 -7
- package/dist/core/database/repositoryConnection.d.ts +0 -4
- package/dist/core/database/transaction.d.ts +0 -23
- package/dist/core/database/transactionControl.d.ts +0 -6
- package/dist/core/events/deferredModelEvents.d.ts +0 -7
- package/dist/core/facades/index.d.ts +0 -10
- package/dist/core/runtime/applicationRegistry.d.ts +0 -18
- package/dist/entries/database/bindConnection.js +0 -1
- package/dist/entries/database/boundConnection.js +0 -1
- package/dist/entries/database/defaultConnection.js +0 -1
- package/dist/entries/database/namedConnections.js +0 -1
- package/dist/entries/database/repositoryConnection.js +0 -1
- package/dist/entries/database/transaction.js +0 -1
- package/dist/entries/facades.js +0 -711
- package/dist/entries/runtime/applicationRegistry.js +0 -1
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __esm = (fn, res, err) => () => {
|
|
3
|
-
if (fn)
|
|
4
|
-
try {
|
|
5
|
-
res = fn(fn = 0);
|
|
6
|
-
} catch (e) {
|
|
7
|
-
err = [e];
|
|
8
|
-
}
|
|
9
|
-
if (err)
|
|
10
|
-
throw err[0];
|
|
11
|
-
return res;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
2
|
// ../../src/core/runtime/asyncContextStore.ts
|
|
15
3
|
import { AsyncLocalStorage } from "async_hooks";
|
|
16
4
|
function createAsyncContextStore(key) {
|
|
@@ -24,10 +12,6 @@ function createAsyncContextStore(key) {
|
|
|
24
12
|
globalRecord[symbol] = store;
|
|
25
13
|
return store;
|
|
26
14
|
}
|
|
27
|
-
var init_asyncContextStore = () => {};
|
|
28
|
-
|
|
29
|
-
// entries/runtime/asyncContextStore.ts
|
|
30
|
-
init_asyncContextStore();
|
|
31
15
|
export {
|
|
32
16
|
createAsyncContextStore
|
|
33
17
|
};
|
|
@@ -23,14 +23,14 @@ function envFlagEnabled(value) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// ../../src/core/runtime/appKeyPrefix.ts
|
|
26
|
-
function appKeyPrefix() {
|
|
27
|
-
return
|
|
26
|
+
function appKeyPrefix(env = process.env) {
|
|
27
|
+
return env.APP_KEY_PREFIX?.trim() || "strata";
|
|
28
28
|
}
|
|
29
|
-
function appCookieName(kind) {
|
|
30
|
-
return `${appKeyPrefix()}_${kind}`;
|
|
29
|
+
function appCookieName(kind, env = process.env) {
|
|
30
|
+
return `${appKeyPrefix(env)}_${kind}`;
|
|
31
31
|
}
|
|
32
|
-
function appDevSecret(kind) {
|
|
33
|
-
return `${appKeyPrefix()}-dev-${kind}`;
|
|
32
|
+
function appDevSecret(kind, env = process.env) {
|
|
33
|
+
return `${appKeyPrefix(env)}-dev-${kind}`;
|
|
34
34
|
}
|
|
35
35
|
function requireConfiguredSecret(names, devKind, env = process.env) {
|
|
36
36
|
for (const name of names) {
|
|
@@ -42,50 +42,18 @@ function requireConfiguredSecret(names, devKind, env = process.env) {
|
|
|
42
42
|
if (isProductionEnv(env)) {
|
|
43
43
|
throw new Error(`${names[0]} must be set outside development. Do not derive secrets from the app name.`);
|
|
44
44
|
}
|
|
45
|
-
return appDevSecret(devKind);
|
|
45
|
+
return appDevSecret(devKind, env);
|
|
46
46
|
}
|
|
47
47
|
function namespacedRedisKey(kind) {
|
|
48
48
|
return `${appKeyPrefix()}:${kind}`;
|
|
49
49
|
}
|
|
50
|
-
function smtpEhloHost() {
|
|
51
|
-
const raw =
|
|
50
|
+
function smtpEhloHost(env = process.env) {
|
|
51
|
+
const raw = env.MAIL_EHLO?.trim() || `${appKeyPrefix(env)}.local`;
|
|
52
52
|
const safe = raw.replace(/[^a-zA-Z0-9.-]/g, "");
|
|
53
53
|
return safe || "strata.local";
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
function appUserAgent() {
|
|
59
|
-
return process.env.APP_USER_AGENT?.trim() || appKeyPrefix();
|
|
60
|
-
}
|
|
61
|
-
function otelServiceName() {
|
|
62
|
-
return process.env.OTEL_SERVICE_NAME?.trim() || `${appKeyPrefix()}-api`;
|
|
63
|
-
}
|
|
64
|
-
function webhookSignatureHeader() {
|
|
65
|
-
return process.env.WEBHOOK_SIGNATURE_HEADER?.trim() || `x-${appKeyPrefix()}-signature`;
|
|
66
|
-
}
|
|
67
|
-
function appDisplayName() {
|
|
68
|
-
return process.env.APP_NAME?.trim() || "Strata";
|
|
69
|
-
}
|
|
70
|
-
function appEnv() {
|
|
71
|
-
return process.env.APP_ENV?.trim() || "local";
|
|
72
|
-
}
|
|
73
|
-
function appUrl() {
|
|
74
|
-
return (process.env.APP_URL?.trim() || "http://localhost:3000").replace(/\/$/, "");
|
|
75
|
-
}
|
|
76
|
-
function apiPrefix() {
|
|
77
|
-
const raw = process.env.API_PREFIX?.trim() || "/api/v1";
|
|
78
|
-
const withSlash = raw.startsWith("/") ? raw : `/${raw}`;
|
|
79
|
-
const trimmed = withSlash.replace(/\/+$/, "");
|
|
80
|
-
return trimmed || "/api/v1";
|
|
81
|
-
}
|
|
82
|
-
function sdkClientClassName() {
|
|
83
|
-
const override = process.env.APP_SDK_CLASS?.trim();
|
|
84
|
-
if (override && /^[A-Za-z_][A-Za-z0-9_]*$/.test(override)) {
|
|
85
|
-
return override;
|
|
86
|
-
}
|
|
87
|
-
const fromName = appDisplayName().replace(/[^A-Za-z0-9]/g, "");
|
|
88
|
-
return fromName ? `${fromName}Client` : "AppClient";
|
|
55
|
+
function otelServiceName(env = process.env) {
|
|
56
|
+
return env.OTEL_SERVICE_NAME?.trim() || `${appKeyPrefix(env)}-api`;
|
|
89
57
|
}
|
|
90
58
|
|
|
91
59
|
// ../../src/core/security/oauthState.ts
|
|
@@ -95,12 +63,12 @@ var OAUTH_STATE_TTL_MS = 10 * 60 * 1000;
|
|
|
95
63
|
function resolveOAuthStateSecret() {
|
|
96
64
|
return requireConfiguredSecret(["OAUTH_STATE_SECRET", "SESSION_SECRET"], "oauth-state-secret");
|
|
97
65
|
}
|
|
98
|
-
function signOAuthState(state, issuedAt) {
|
|
66
|
+
function signOAuthState(state, issuedAt, options) {
|
|
99
67
|
const payload = `${state}.${issuedAt}`;
|
|
100
|
-
const signature = createHmac("sha256", resolveOAuthStateSecret()).update(payload).digest("hex");
|
|
68
|
+
const signature = createHmac("sha256", options?.secret ?? resolveOAuthStateSecret()).update(payload).digest("hex");
|
|
101
69
|
return `${payload}.${signature}`;
|
|
102
70
|
}
|
|
103
|
-
function verifySignedOAuthStateValue(value) {
|
|
71
|
+
function verifySignedOAuthStateValue(value, options) {
|
|
104
72
|
const parts = value.split(".");
|
|
105
73
|
if (parts.length !== 3) {
|
|
106
74
|
return false;
|
|
@@ -116,7 +84,7 @@ function verifySignedOAuthStateValue(value) {
|
|
|
116
84
|
if (Date.now() - issuedAt > OAUTH_STATE_TTL_MS) {
|
|
117
85
|
return false;
|
|
118
86
|
}
|
|
119
|
-
const expectedSignature = signOAuthState(nonce, issuedAt).split(".").at(-1) ?? "";
|
|
87
|
+
const expectedSignature = signOAuthState(nonce, issuedAt, options).split(".").at(-1) ?? "";
|
|
120
88
|
const expectedBuffer = Buffer.from(expectedSignature);
|
|
121
89
|
const actualBuffer = Buffer.from(signature);
|
|
122
90
|
if (expectedBuffer.length !== actualBuffer.length) {
|
|
@@ -124,45 +92,45 @@ function verifySignedOAuthStateValue(value) {
|
|
|
124
92
|
}
|
|
125
93
|
return timingSafeEqual(expectedBuffer, actualBuffer);
|
|
126
94
|
}
|
|
127
|
-
function createOAuthState() {
|
|
95
|
+
function createOAuthState(options) {
|
|
128
96
|
const nonce = randomBytes(24).toString("hex");
|
|
129
97
|
const issuedAt = Date.now();
|
|
130
|
-
return { state: signOAuthState(nonce, issuedAt) };
|
|
98
|
+
return { state: signOAuthState(nonce, issuedAt, options) };
|
|
131
99
|
}
|
|
132
|
-
function createOAuthStateCookie() {
|
|
133
|
-
const { state } = createOAuthState();
|
|
100
|
+
function createOAuthStateCookie(options) {
|
|
101
|
+
const { state } = createOAuthState(options);
|
|
134
102
|
return {
|
|
135
103
|
state,
|
|
136
|
-
cookie: `${OAUTH_STATE_COOKIE}=${encodeURIComponent(state)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=600${isProductionEnv() ? "; Secure" : ""}`
|
|
104
|
+
cookie: `${OAUTH_STATE_COOKIE}=${encodeURIComponent(state)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=600${options?.production ?? isProductionEnv() ? "; Secure" : ""}`
|
|
137
105
|
};
|
|
138
106
|
}
|
|
139
|
-
function verifyOAuthState(_request, returnedState) {
|
|
107
|
+
function verifyOAuthState(_request, returnedState, options) {
|
|
140
108
|
if (!returnedState || returnedState.trim().length === 0) {
|
|
141
109
|
return false;
|
|
142
110
|
}
|
|
143
|
-
return verifySignedOAuthStateValue(returnedState.trim());
|
|
111
|
+
return verifySignedOAuthStateValue(returnedState.trim(), options);
|
|
144
112
|
}
|
|
145
|
-
function clearOAuthStateCookie() {
|
|
146
|
-
return `${OAUTH_STATE_COOKIE}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0${isProductionEnv() ? "; Secure" : ""}`;
|
|
113
|
+
function clearOAuthStateCookie(options) {
|
|
114
|
+
return `${OAUTH_STATE_COOKIE}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0${options?.production ?? isProductionEnv() ? "; Secure" : ""}`;
|
|
147
115
|
}
|
|
148
|
-
function oauthCookieSuffix() {
|
|
149
|
-
return `Path=/; HttpOnly; SameSite=Lax${isProductionEnv() ? "; Secure" : ""}`;
|
|
116
|
+
function oauthCookieSuffix(options) {
|
|
117
|
+
return `Path=/; HttpOnly; SameSite=Lax${options?.production ?? isProductionEnv() ? "; Secure" : ""}`;
|
|
150
118
|
}
|
|
151
|
-
function sealOidcPkceCookie(payload) {
|
|
119
|
+
function sealOidcPkceCookie(payload, options) {
|
|
152
120
|
const body = Buffer.from(JSON.stringify({
|
|
153
121
|
state: payload.state,
|
|
154
122
|
nonce: payload.nonce,
|
|
155
123
|
codeVerifier: payload.codeVerifier,
|
|
156
124
|
iat: Date.now()
|
|
157
125
|
})).toString("base64url");
|
|
158
|
-
const signature = createHmac("sha256", resolveOAuthStateSecret()).update(body).digest("base64url");
|
|
126
|
+
const signature = createHmac("sha256", options?.secret ?? resolveOAuthStateSecret()).update(body).digest("base64url");
|
|
159
127
|
const value = encodeURIComponent(`${body}.${signature}`);
|
|
160
|
-
return `${OIDC_PKCE_COOKIE}=${value}; ${oauthCookieSuffix()}; Max-Age=600`;
|
|
128
|
+
return `${OIDC_PKCE_COOKIE}=${value}; ${oauthCookieSuffix(options)}; Max-Age=600`;
|
|
161
129
|
}
|
|
162
|
-
function clearOidcPkceCookie() {
|
|
163
|
-
return `${OIDC_PKCE_COOKIE}=; ${oauthCookieSuffix()}; Max-Age=0`;
|
|
130
|
+
function clearOidcPkceCookie(options) {
|
|
131
|
+
return `${OIDC_PKCE_COOKIE}=; ${oauthCookieSuffix(options)}; Max-Age=0`;
|
|
164
132
|
}
|
|
165
|
-
function readOidcPkceCookie(request, returnedState) {
|
|
133
|
+
function readOidcPkceCookie(request, returnedState, options) {
|
|
166
134
|
const state = returnedState?.trim() ?? "";
|
|
167
135
|
if (!state) {
|
|
168
136
|
return null;
|
|
@@ -173,11 +141,11 @@ function readOidcPkceCookie(request, returnedState) {
|
|
|
173
141
|
if (name !== OIDC_PKCE_COOKIE) {
|
|
174
142
|
continue;
|
|
175
143
|
}
|
|
176
|
-
return unsealOidcPkceValue(rest.join("="), state);
|
|
144
|
+
return unsealOidcPkceValue(rest.join("="), state, options);
|
|
177
145
|
}
|
|
178
146
|
return null;
|
|
179
147
|
}
|
|
180
|
-
function unsealOidcPkceValue(rawValue, returnedState) {
|
|
148
|
+
function unsealOidcPkceValue(rawValue, returnedState, options) {
|
|
181
149
|
let decoded = rawValue;
|
|
182
150
|
try {
|
|
183
151
|
decoded = decodeURIComponent(rawValue);
|
|
@@ -190,7 +158,7 @@ function unsealOidcPkceValue(rawValue, returnedState) {
|
|
|
190
158
|
}
|
|
191
159
|
const body = decoded.slice(0, splitAt);
|
|
192
160
|
const signature = decoded.slice(splitAt + 1);
|
|
193
|
-
const expected = createHmac("sha256", resolveOAuthStateSecret()).update(body).digest("base64url");
|
|
161
|
+
const expected = createHmac("sha256", options?.secret ?? resolveOAuthStateSecret()).update(body).digest("base64url");
|
|
194
162
|
const expectedBuffer = Buffer.from(expected);
|
|
195
163
|
const actualBuffer = Buffer.from(signature);
|
|
196
164
|
if (expectedBuffer.length !== actualBuffer.length || !timingSafeEqual(expectedBuffer, actualBuffer)) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// ../../src/core/security/publicReads.ts
|
|
3
|
-
function isPublicReadsEnabled() {
|
|
4
|
-
return
|
|
3
|
+
function isPublicReadsEnabled(enabled = false) {
|
|
4
|
+
return enabled;
|
|
5
5
|
}
|
|
6
|
-
function guestCanViewResource() {
|
|
7
|
-
return isPublicReadsEnabled();
|
|
6
|
+
function guestCanViewResource(enabled = false) {
|
|
7
|
+
return isPublicReadsEnabled(enabled);
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
10
10
|
guestCanViewResource,
|
|
@@ -82,6 +82,7 @@ async function safeFetch(input, init = {}, options = {}) {
|
|
|
82
82
|
}
|
|
83
83
|
const maxRedirects = options.maxRedirects ?? 0;
|
|
84
84
|
const urlOptions = {
|
|
85
|
+
production: options.production,
|
|
85
86
|
allowHttp: options.allowHttp,
|
|
86
87
|
resolveDns: options.resolveDns ?? true,
|
|
87
88
|
allowPrivate: options.allowPrivate
|
|
@@ -29,18 +29,18 @@ function parseScimTenantTokens(raw) {
|
|
|
29
29
|
}
|
|
30
30
|
return tokens;
|
|
31
31
|
}
|
|
32
|
-
function resolveScimTenantFromToken(token) {
|
|
32
|
+
function resolveScimTenantFromToken(token, env) {
|
|
33
33
|
const presented = token.trim();
|
|
34
34
|
if (presented.length === 0) {
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
|
-
const tenantTokens = parseScimTenantTokens(
|
|
37
|
+
const tenantTokens = parseScimTenantTokens(env.SCIM_TENANT_TOKENS);
|
|
38
38
|
for (const [tenantId, expectedToken] of tenantTokens) {
|
|
39
39
|
if (timingSafeCompareString(presented, expectedToken)) {
|
|
40
40
|
return tenantId;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
const fallbackToken =
|
|
43
|
+
const fallbackToken = env.SCIM_BEARER_TOKEN?.trim() ?? "";
|
|
44
44
|
if (fallbackToken.length === 0) {
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// ../../src/core/security/tokenExpiry.ts
|
|
3
|
-
function resolveDefaultTokenExpiryDays() {
|
|
4
|
-
const raw =
|
|
3
|
+
function resolveDefaultTokenExpiryDays(value) {
|
|
4
|
+
const raw = value?.trim();
|
|
5
5
|
if (!raw) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
@@ -2,92 +2,6 @@
|
|
|
2
2
|
// ../../src/core/security/totp.ts
|
|
3
3
|
import { createHmac, randomBytes } from "crypto";
|
|
4
4
|
|
|
5
|
-
// ../../src/core/runtime/appEnv.ts
|
|
6
|
-
var NON_PRODUCTION_APP_ENVS = new Set(["local", "development", "dev", "test", "testing", "ci"]);
|
|
7
|
-
function normalizeEnvValue(value) {
|
|
8
|
-
return (value ?? "").trim().toLowerCase();
|
|
9
|
-
}
|
|
10
|
-
function isProductionEnv(env = process.env) {
|
|
11
|
-
const appEnv = normalizeEnvValue(env.APP_ENV);
|
|
12
|
-
const nodeEnv = normalizeEnvValue(env.NODE_ENV);
|
|
13
|
-
if (appEnv === "production" || nodeEnv === "production") {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
if (appEnv === "") {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return !NON_PRODUCTION_APP_ENVS.has(appEnv);
|
|
20
|
-
}
|
|
21
|
-
function envFlagEnabled(value) {
|
|
22
|
-
return value === "true";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// ../../src/core/runtime/appKeyPrefix.ts
|
|
26
|
-
function appKeyPrefix() {
|
|
27
|
-
return process.env.APP_KEY_PREFIX?.trim() || "strata";
|
|
28
|
-
}
|
|
29
|
-
function appCookieName(kind) {
|
|
30
|
-
return `${appKeyPrefix()}_${kind}`;
|
|
31
|
-
}
|
|
32
|
-
function appDevSecret(kind) {
|
|
33
|
-
return `${appKeyPrefix()}-dev-${kind}`;
|
|
34
|
-
}
|
|
35
|
-
function requireConfiguredSecret(names, devKind, env = process.env) {
|
|
36
|
-
for (const name of names) {
|
|
37
|
-
const value = env[name]?.trim();
|
|
38
|
-
if (value) {
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (isProductionEnv(env)) {
|
|
43
|
-
throw new Error(`${names[0]} must be set outside development. Do not derive secrets from the app name.`);
|
|
44
|
-
}
|
|
45
|
-
return appDevSecret(devKind);
|
|
46
|
-
}
|
|
47
|
-
function namespacedRedisKey(kind) {
|
|
48
|
-
return `${appKeyPrefix()}:${kind}`;
|
|
49
|
-
}
|
|
50
|
-
function smtpEhloHost() {
|
|
51
|
-
const raw = process.env.MAIL_EHLO?.trim() || `${appKeyPrefix()}.local`;
|
|
52
|
-
const safe = raw.replace(/[^a-zA-Z0-9.-]/g, "");
|
|
53
|
-
return safe || "strata.local";
|
|
54
|
-
}
|
|
55
|
-
function siemEventType() {
|
|
56
|
-
return process.env.SIEM_EVENT_TYPE?.trim() || `${appKeyPrefix()}.audit`;
|
|
57
|
-
}
|
|
58
|
-
function appUserAgent() {
|
|
59
|
-
return process.env.APP_USER_AGENT?.trim() || appKeyPrefix();
|
|
60
|
-
}
|
|
61
|
-
function otelServiceName() {
|
|
62
|
-
return process.env.OTEL_SERVICE_NAME?.trim() || `${appKeyPrefix()}-api`;
|
|
63
|
-
}
|
|
64
|
-
function webhookSignatureHeader() {
|
|
65
|
-
return process.env.WEBHOOK_SIGNATURE_HEADER?.trim() || `x-${appKeyPrefix()}-signature`;
|
|
66
|
-
}
|
|
67
|
-
function appDisplayName() {
|
|
68
|
-
return process.env.APP_NAME?.trim() || "Strata";
|
|
69
|
-
}
|
|
70
|
-
function appEnv() {
|
|
71
|
-
return process.env.APP_ENV?.trim() || "local";
|
|
72
|
-
}
|
|
73
|
-
function appUrl() {
|
|
74
|
-
return (process.env.APP_URL?.trim() || "http://localhost:3000").replace(/\/$/, "");
|
|
75
|
-
}
|
|
76
|
-
function apiPrefix() {
|
|
77
|
-
const raw = process.env.API_PREFIX?.trim() || "/api/v1";
|
|
78
|
-
const withSlash = raw.startsWith("/") ? raw : `/${raw}`;
|
|
79
|
-
const trimmed = withSlash.replace(/\/+$/, "");
|
|
80
|
-
return trimmed || "/api/v1";
|
|
81
|
-
}
|
|
82
|
-
function sdkClientClassName() {
|
|
83
|
-
const override = process.env.APP_SDK_CLASS?.trim();
|
|
84
|
-
if (override && /^[A-Za-z_][A-Za-z0-9_]*$/.test(override)) {
|
|
85
|
-
return override;
|
|
86
|
-
}
|
|
87
|
-
const fromName = appDisplayName().replace(/[^A-Za-z0-9]/g, "");
|
|
88
|
-
return fromName ? `${fromName}Client` : "AppClient";
|
|
89
|
-
}
|
|
90
|
-
|
|
91
5
|
// ../../src/core/security/timingSafeCompare.ts
|
|
92
6
|
import { timingSafeEqual } from "crypto";
|
|
93
7
|
function timingSafeCompareString(left, right) {
|
|
@@ -134,7 +48,7 @@ function generateTotpSecret(byteLength = 20) {
|
|
|
134
48
|
return encodeBase32(randomBytes(byteLength));
|
|
135
49
|
}
|
|
136
50
|
function buildOtpauthUrl(options) {
|
|
137
|
-
const issuer = options.issuer?.trim() ||
|
|
51
|
+
const issuer = options.issuer?.trim() || "Strata";
|
|
138
52
|
const label = `${issuer}:${options.account}`;
|
|
139
53
|
const params = new URLSearchParams({
|
|
140
54
|
secret: options.secret,
|
|
@@ -1,100 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// ../../src/core/security/webhookSignature.ts
|
|
3
3
|
import { createHmac } from "crypto";
|
|
4
|
-
|
|
5
|
-
// ../../src/core/runtime/appEnv.ts
|
|
6
|
-
var NON_PRODUCTION_APP_ENVS = new Set(["local", "development", "dev", "test", "testing", "ci"]);
|
|
7
|
-
function normalizeEnvValue(value) {
|
|
8
|
-
return (value ?? "").trim().toLowerCase();
|
|
9
|
-
}
|
|
10
|
-
function isProductionEnv(env = process.env) {
|
|
11
|
-
const appEnv = normalizeEnvValue(env.APP_ENV);
|
|
12
|
-
const nodeEnv = normalizeEnvValue(env.NODE_ENV);
|
|
13
|
-
if (appEnv === "production" || nodeEnv === "production") {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
if (appEnv === "") {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return !NON_PRODUCTION_APP_ENVS.has(appEnv);
|
|
20
|
-
}
|
|
21
|
-
function envFlagEnabled(value) {
|
|
22
|
-
return value === "true";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// ../../src/core/runtime/appKeyPrefix.ts
|
|
26
|
-
function appKeyPrefix() {
|
|
27
|
-
return process.env.APP_KEY_PREFIX?.trim() || "strata";
|
|
28
|
-
}
|
|
29
|
-
function appCookieName(kind) {
|
|
30
|
-
return `${appKeyPrefix()}_${kind}`;
|
|
31
|
-
}
|
|
32
|
-
function appDevSecret(kind) {
|
|
33
|
-
return `${appKeyPrefix()}-dev-${kind}`;
|
|
34
|
-
}
|
|
35
|
-
function requireConfiguredSecret(names, devKind, env = process.env) {
|
|
36
|
-
for (const name of names) {
|
|
37
|
-
const value = env[name]?.trim();
|
|
38
|
-
if (value) {
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (isProductionEnv(env)) {
|
|
43
|
-
throw new Error(`${names[0]} must be set outside development. Do not derive secrets from the app name.`);
|
|
44
|
-
}
|
|
45
|
-
return appDevSecret(devKind);
|
|
46
|
-
}
|
|
47
|
-
function namespacedRedisKey(kind) {
|
|
48
|
-
return `${appKeyPrefix()}:${kind}`;
|
|
49
|
-
}
|
|
50
|
-
function smtpEhloHost() {
|
|
51
|
-
const raw = process.env.MAIL_EHLO?.trim() || `${appKeyPrefix()}.local`;
|
|
52
|
-
const safe = raw.replace(/[^a-zA-Z0-9.-]/g, "");
|
|
53
|
-
return safe || "strata.local";
|
|
54
|
-
}
|
|
55
|
-
function siemEventType() {
|
|
56
|
-
return process.env.SIEM_EVENT_TYPE?.trim() || `${appKeyPrefix()}.audit`;
|
|
57
|
-
}
|
|
58
|
-
function appUserAgent() {
|
|
59
|
-
return process.env.APP_USER_AGENT?.trim() || appKeyPrefix();
|
|
60
|
-
}
|
|
61
|
-
function otelServiceName() {
|
|
62
|
-
return process.env.OTEL_SERVICE_NAME?.trim() || `${appKeyPrefix()}-api`;
|
|
63
|
-
}
|
|
64
|
-
function webhookSignatureHeader() {
|
|
65
|
-
return process.env.WEBHOOK_SIGNATURE_HEADER?.trim() || `x-${appKeyPrefix()}-signature`;
|
|
66
|
-
}
|
|
67
|
-
function appDisplayName() {
|
|
68
|
-
return process.env.APP_NAME?.trim() || "Strata";
|
|
69
|
-
}
|
|
70
|
-
function appEnv() {
|
|
71
|
-
return process.env.APP_ENV?.trim() || "local";
|
|
72
|
-
}
|
|
73
|
-
function appUrl() {
|
|
74
|
-
return (process.env.APP_URL?.trim() || "http://localhost:3000").replace(/\/$/, "");
|
|
75
|
-
}
|
|
76
|
-
function apiPrefix() {
|
|
77
|
-
const raw = process.env.API_PREFIX?.trim() || "/api/v1";
|
|
78
|
-
const withSlash = raw.startsWith("/") ? raw : `/${raw}`;
|
|
79
|
-
const trimmed = withSlash.replace(/\/+$/, "");
|
|
80
|
-
return trimmed || "/api/v1";
|
|
81
|
-
}
|
|
82
|
-
function sdkClientClassName() {
|
|
83
|
-
const override = process.env.APP_SDK_CLASS?.trim();
|
|
84
|
-
if (override && /^[A-Za-z_][A-Za-z0-9_]*$/.test(override)) {
|
|
85
|
-
return override;
|
|
86
|
-
}
|
|
87
|
-
const fromName = appDisplayName().replace(/[^A-Za-z0-9]/g, "");
|
|
88
|
-
return fromName ? `${fromName}Client` : "AppClient";
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// ../../src/core/security/webhookSignature.ts
|
|
92
4
|
function signWebhookBody(secret, body) {
|
|
93
5
|
return createHmac("sha256", secret).update(body).digest("hex");
|
|
94
6
|
}
|
|
95
|
-
function signedWebhookHeaders(secret, body) {
|
|
7
|
+
function signedWebhookHeaders(secret, body, headerName = "x-strata-signature") {
|
|
96
8
|
return {
|
|
97
|
-
[
|
|
9
|
+
[headerName]: signWebhookBody(secret, body)
|
|
98
10
|
};
|
|
99
11
|
}
|
|
100
12
|
export {
|