@axiumine/koa-utils 7.2.0 → 8.1.0
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/README.md +40 -13
- package/dist/dataSources/MariaDB.mjs +3 -3
- package/dist/dataSources/MongoDB.mjs +2 -2
- package/dist/dataSources/PostgreSQL.mjs +3 -3
- package/dist/dataSources/Redis.mjs +3 -3
- package/dist/email/ISocketLabsClient.d.mts +8 -0
- package/dist/email/ISocketLabsClient.mjs +2 -0
- package/dist/email/ISocketLabsMessage.d.mts +20 -0
- package/dist/email/ISocketLabsMessage.mjs +4 -0
- package/dist/email/ISocketLabsSendResult.d.mts +12 -0
- package/dist/email/ISocketLabsSendResult.mjs +2 -0
- package/dist/email/ISocketLabsSenderOptions.d.mts +30 -0
- package/dist/email/ISocketLabsSenderOptions.mjs +3 -0
- package/dist/email/SocketLabsLib.d.mts +1 -0
- package/dist/email/SocketLabsLib.mjs +30 -21
- package/dist/email/createSocketLabsSender.d.mts +20 -0
- package/dist/email/createSocketLabsSender.mjs +66 -0
- package/dist/files/scanVirus.mjs +1 -1
- package/dist/files/storeUploadAsTemp.mjs +2 -2
- package/dist/graphQL/schema/mutations/login4Ever.mjs +1 -1
- package/dist/graphQL/schema/mutations/loginAdmin.mjs +1 -1
- package/dist/graphQL/schema/mutations/loginRememberme.mjs +1 -1
- package/dist/graphQL/schema/mutations/logout.mjs +3 -3
- package/dist/graphQL/schema/mutations/refresh.mjs +3 -3
- package/dist/graphQL/schema/mutations/resetPwd.mjs +1 -1
- package/dist/graphQL/schema/mutations/updatePassword.mjs +1 -1
- package/dist/koa/IKoaErrorHandlerContext.d.mts +11 -0
- package/dist/koa/IKoaErrorHandlerContext.mjs +2 -0
- package/dist/koa/IKoaErrorHandlerOptions.d.mts +28 -0
- package/dist/koa/IKoaErrorHandlerOptions.mjs +3 -0
- package/dist/koa/createKoaErrorHandler.d.mts +11 -0
- package/dist/koa/createKoaErrorHandler.mjs +37 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/index.mjs +2 -2
- package/dist/koa/middleware/authenticatedLogoutHandler/index.mjs +2 -2
- package/dist/koa/middleware/authenticatedResourceHandler/index.mjs +2 -2
- package/dist/koa/tdwKoaErrorHandler.mjs +15 -23
- package/dist/lib/Constants.d.mts +0 -2
- package/dist/lib/Constants.mjs +0 -2
- package/dist/lib/MongoDB/throwMongoErrors.mjs +1 -1
- package/dist/lib/OBJECTID_0_OBJ.d.mts +6 -0
- package/dist/lib/OBJECTID_0_OBJ.mjs +8 -0
- package/dist/lib/PostgreSQL/clock/CLOCK_SQL.d.mts +7 -0
- package/dist/lib/PostgreSQL/clock/CLOCK_SQL.mjs +8 -0
- package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.d.mts +5 -0
- package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.mjs +6 -0
- package/dist/lib/PostgreSQL/clock/IClock.d.mts +4 -0
- package/dist/lib/PostgreSQL/clock/IClock.mjs +2 -0
- package/dist/lib/PostgreSQL/clock/IDbClock.d.mts +11 -0
- package/dist/lib/PostgreSQL/clock/IDbClock.mjs +2 -0
- package/dist/lib/PostgreSQL/clock/IDbClockOptions.d.mts +11 -0
- package/dist/lib/PostgreSQL/clock/IDbClockOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/clock/IDbClockSeam.d.mts +10 -0
- package/dist/lib/PostgreSQL/clock/IDbClockSeam.mjs +2 -0
- package/dist/lib/PostgreSQL/clock/createDbClock.d.mts +23 -0
- package/dist/lib/PostgreSQL/clock/createDbClock.mjs +54 -0
- package/dist/lib/PostgreSQL/clock/lockTaken.d.mts +11 -0
- package/dist/lib/PostgreSQL/clock/lockTaken.mjs +17 -0
- package/dist/lib/PostgreSQL/counter/IDbCounter.d.mts +9 -0
- package/dist/lib/PostgreSQL/counter/IDbCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.d.mts +12 -0
- package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.mjs +20 -0
- package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.d.mts +11 -0
- package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.mjs +12 -0
- package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.d.mts +23 -0
- package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.mjs +35 -0
- package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.d.mts +13 -0
- package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.mjs +14 -0
- package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.d.mts +7 -0
- package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.mjs +8 -0
- package/dist/lib/PostgreSQL/error/DB_TX_REASONS.d.mts +9 -0
- package/dist/lib/PostgreSQL/error/DB_TX_REASONS.mjs +10 -0
- package/dist/lib/PostgreSQL/error/DbClockError.d.mts +6 -0
- package/dist/lib/PostgreSQL/error/DbClockError.mjs +27 -0
- package/dist/lib/PostgreSQL/error/DbConnectError.d.mts +11 -0
- package/dist/lib/PostgreSQL/error/DbConnectError.mjs +18 -0
- package/dist/lib/PostgreSQL/error/DbParseError.d.mts +11 -0
- package/dist/lib/PostgreSQL/error/DbParseError.mjs +16 -0
- package/dist/lib/PostgreSQL/error/DbStateError.d.mts +10 -0
- package/dist/lib/PostgreSQL/error/DbStateError.mjs +14 -0
- package/dist/lib/PostgreSQL/error/DbTxError.d.mts +6 -0
- package/dist/lib/PostgreSQL/error/DbTxError.mjs +10 -0
- package/dist/lib/PostgreSQL/error/IConstraintEntry.d.mts +17 -0
- package/dist/lib/PostgreSQL/error/IConstraintEntry.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.d.mts +20 -0
- package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IConstraintTable.d.mts +7 -0
- package/dist/lib/PostgreSQL/error/IConstraintTable.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbClockReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbClockReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbConnectReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbConnectReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbErrorCounter.d.mts +4 -0
- package/dist/lib/PostgreSQL/error/IDbErrorCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbErrorCounterName.d.mts +7 -0
- package/dist/lib/PostgreSQL/error/IDbErrorCounterName.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbErrorFactory.d.mts +16 -0
- package/dist/lib/PostgreSQL/error/IDbErrorFactory.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbInternalReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbInternalReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbParseReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbParseReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbStateReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbStateReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbTxReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbTxReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/ILockOrderReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/ILockOrderReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.d.mts +22 -0
- package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IRoleAssertionReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IRoleAssertionReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.d.mts +12 -0
- package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.mjs +2 -0
- package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.d.mts +11 -0
- package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.mjs +12 -0
- package/dist/lib/PostgreSQL/error/LockOrderError.d.mts +6 -0
- package/dist/lib/PostgreSQL/error/LockOrderError.mjs +10 -0
- package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.d.mts +21 -0
- package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.mjs +35 -0
- package/dist/lib/PostgreSQL/error/RoleAssertionError.d.mts +19 -0
- package/dist/lib/PostgreSQL/error/RoleAssertionError.mjs +58 -0
- package/dist/lib/PostgreSQL/error/buildConstraintEntry.d.mts +15 -0
- package/dist/lib/PostgreSQL/error/buildConstraintEntry.mjs +16 -0
- package/dist/lib/PostgreSQL/error/constraintNameOf.d.mts +6 -0
- package/dist/lib/PostgreSQL/error/constraintNameOf.mjs +17 -0
- package/dist/lib/PostgreSQL/error/errorNameOf.d.mts +5 -0
- package/dist/lib/PostgreSQL/error/errorNameOf.mjs +12 -0
- package/dist/lib/PostgreSQL/error/lookupConstraint.d.mts +7 -0
- package/dist/lib/PostgreSQL/error/lookupConstraint.mjs +8 -0
- package/dist/lib/PostgreSQL/error/mapDbError.d.mts +28 -0
- package/dist/lib/PostgreSQL/error/mapDbError.mjs +52 -0
- package/dist/lib/PostgreSQL/error/sqlstateField.d.mts +4 -0
- package/dist/lib/PostgreSQL/error/sqlstateField.mjs +5 -0
- package/dist/lib/PostgreSQL/error/sqlstateOf.d.mts +5 -0
- package/dist/lib/PostgreSQL/error/sqlstateOf.mjs +12 -0
- package/dist/lib/PostgreSQL/guard/IAffectedResult.d.mts +4 -0
- package/dist/lib/PostgreSQL/guard/IAffectedResult.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/IGuardCounter.d.mts +3 -0
- package/dist/lib/PostgreSQL/guard/IGuardCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardCode.d.mts +5 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardCode.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardField.d.mts +3 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardField.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardInput.d.mts +29 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardInput.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.d.mts +2 -0
- package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.mjs +3 -0
- package/dist/lib/PostgreSQL/guard/assertAffected.d.mts +10 -0
- package/dist/lib/PostgreSQL/guard/assertAffected.mjs +17 -0
- package/dist/lib/PostgreSQL/guard/guardVersion.d.mts +21 -0
- package/dist/lib/PostgreSQL/guard/guardVersion.mjs +47 -0
- package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.d.mts +2 -0
- package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.mjs +3 -0
- package/dist/lib/PostgreSQL/lock/IClaimRegistry.d.mts +6 -0
- package/dist/lib/PostgreSQL/lock/IClaimRegistry.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/IClaimRequest.d.mts +7 -0
- package/dist/lib/PostgreSQL/lock/IClaimRequest.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockAdmission.d.mts +4 -0
- package/dist/lib/PostgreSQL/lock/ILockAdmission.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockOrderSpec.d.mts +19 -0
- package/dist/lib/PostgreSQL/lock/ILockOrderSpec.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockOrderTracker.d.mts +41 -0
- package/dist/lib/PostgreSQL/lock/ILockOrderTracker.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.d.mts +5 -0
- package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.d.mts +7 -0
- package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/IRowLockMode.d.mts +3 -0
- package/dist/lib/PostgreSQL/lock/IRowLockMode.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.d.mts +2 -0
- package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.mjs +3 -0
- package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.d.mts +16 -0
- package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.mjs +32 -0
- package/dist/lib/PostgreSQL/lock/createLockOrderTracker.d.mts +14 -0
- package/dist/lib/PostgreSQL/lock/createLockOrderTracker.mjs +60 -0
- package/dist/lib/PostgreSQL/lock/lockedRow.d.mts +7 -0
- package/dist/lib/PostgreSQL/lock/lockedRow.mjs +12 -0
- package/dist/lib/PostgreSQL/lock/lockedRows.d.mts +3 -0
- package/dist/lib/PostgreSQL/lock/lockedRows.mjs +8 -0
- package/dist/lib/PostgreSQL/lock/rowLockModeOf.d.mts +3 -0
- package/dist/lib/PostgreSQL/lock/rowLockModeOf.mjs +9 -0
- package/dist/lib/PostgreSQL/lock/uuidOf.d.mts +2 -0
- package/dist/lib/PostgreSQL/lock/uuidOf.mjs +10 -0
- package/dist/lib/PostgreSQL/lock/uuidsOf.d.mts +5 -0
- package/dist/lib/PostgreSQL/lock/uuidsOf.mjs +13 -0
- package/dist/lib/PostgreSQL/parse/IArrayParser.d.mts +2 -0
- package/dist/lib/PostgreSQL/parse/IArrayParser.mjs +2 -0
- package/dist/lib/PostgreSQL/parse/IDriverTypes.d.mts +4 -0
- package/dist/lib/PostgreSQL/parse/IDriverTypes.mjs +2 -0
- package/dist/lib/PostgreSQL/parse/IStringParser.d.mts +2 -0
- package/dist/lib/PostgreSQL/parse/IStringParser.mjs +2 -0
- package/dist/lib/PostgreSQL/parse/ITypeParserEntry.d.mts +9 -0
- package/dist/lib/PostgreSQL/parse/ITypeParserEntry.mjs +2 -0
- package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.d.mts +12 -0
- package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.mjs +38 -0
- package/dist/lib/PostgreSQL/parse/arrayOf.d.mts +7 -0
- package/dist/lib/PostgreSQL/parse/arrayOf.mjs +50 -0
- package/dist/lib/PostgreSQL/parse/createTypeRegistry.d.mts +13 -0
- package/dist/lib/PostgreSQL/parse/createTypeRegistry.mjs +26 -0
- package/dist/lib/PostgreSQL/parse/parseDate.d.mts +7 -0
- package/dist/lib/PostgreSQL/parse/parseDate.mjs +19 -0
- package/dist/lib/PostgreSQL/parse/parseInt8.d.mts +6 -0
- package/dist/lib/PostgreSQL/parse/parseInt8.mjs +17 -0
- package/dist/lib/PostgreSQL/parse/parseTime.d.mts +7 -0
- package/dist/lib/PostgreSQL/parse/parseTime.mjs +24 -0
- package/dist/lib/PostgreSQL/parse/parseTimestamptz.d.mts +17 -0
- package/dist/lib/PostgreSQL/parse/parseTimestamptz.mjs +79 -0
- package/dist/lib/PostgreSQL/parse/parseUuid.d.mts +3 -0
- package/dist/lib/PostgreSQL/parse/parseUuid.mjs +9 -0
- package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.d.mts +28 -0
- package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IDbDriver.d.mts +12 -0
- package/dist/lib/PostgreSQL/pool/IDbDriver.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IPoolCounter.d.mts +4 -0
- package/dist/lib/PostgreSQL/pool/IPoolCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IPoolCounterName.d.mts +7 -0
- package/dist/lib/PostgreSQL/pool/IPoolCounterName.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IPoolEvents.d.mts +4 -0
- package/dist/lib/PostgreSQL/pool/IPoolEvents.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IPoolLogger.d.mts +8 -0
- package/dist/lib/PostgreSQL/pool/IPoolLogger.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.d.mts +2 -0
- package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.mjs +3 -0
- package/dist/lib/PostgreSQL/pool/createPool.d.mts +31 -0
- package/dist/lib/PostgreSQL/pool/createPool.mjs +67 -0
- package/dist/lib/PostgreSQL/role/IAssertRoleOptions.d.mts +10 -0
- package/dist/lib/PostgreSQL/role/IAssertRoleOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/role/IRoleAssertion.d.mts +6 -0
- package/dist/lib/PostgreSQL/role/IRoleAssertion.mjs +2 -0
- package/dist/lib/PostgreSQL/role/IRoleGrant.d.mts +19 -0
- package/dist/lib/PostgreSQL/role/IRoleGrant.mjs +2 -0
- package/dist/lib/PostgreSQL/role/IRolePool.d.mts +6 -0
- package/dist/lib/PostgreSQL/role/IRolePool.mjs +2 -0
- package/dist/lib/PostgreSQL/role/assertRole.d.mts +36 -0
- package/dist/lib/PostgreSQL/role/assertRole.mjs +54 -0
- package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/IRetryDelay.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/IRetryDelay.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITx.d.mts +9 -0
- package/dist/lib/PostgreSQL/tx/ITx.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxClient.d.mts +12 -0
- package/dist/lib/PostgreSQL/tx/ITxClient.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxCounter.d.mts +4 -0
- package/dist/lib/PostgreSQL/tx/ITxCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxCounterName.d.mts +10 -0
- package/dist/lib/PostgreSQL/tx/ITxCounterName.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxFailureReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/tx/ITxFailureReason.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxIsolation.d.mts +3 -0
- package/dist/lib/PostgreSQL/tx/ITxIsolation.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxOptions.d.mts +27 -0
- package/dist/lib/PostgreSQL/tx/ITxOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxPool.d.mts +5 -0
- package/dist/lib/PostgreSQL/tx/ITxPool.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxResult.d.mts +6 -0
- package/dist/lib/PostgreSQL/tx/ITxResult.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.d.mts +7 -0
- package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.mjs +8 -0
- package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/defaultRetryDelay.d.mts +3 -0
- package/dist/lib/PostgreSQL/tx/defaultRetryDelay.mjs +4 -0
- package/dist/lib/PostgreSQL/tx/jitteredDelay.d.mts +7 -0
- package/dist/lib/PostgreSQL/tx/jitteredDelay.mjs +16 -0
- package/dist/lib/PostgreSQL/tx/withTx.d.mts +39 -0
- package/dist/lib/PostgreSQL/tx/withTx.mjs +41 -0
- package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.d.mts +10 -0
- package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.d.mts +14 -0
- package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.mjs +2 -0
- package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.d.mts +2 -0
- package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.mjs +3 -0
- package/dist/lib/PostgreSQL/url/databaseUrlReason.d.mts +20 -0
- package/dist/lib/PostgreSQL/url/databaseUrlReason.mjs +99 -0
- package/dist/lib/PostgreSQL/url/isAbsolutePath.d.mts +2 -0
- package/dist/lib/PostgreSQL/url/isAbsolutePath.mjs +14 -0
- package/dist/lib/PostgreSQL/url/isValidHost.d.mts +6 -0
- package/dist/lib/PostgreSQL/url/isValidHost.mjs +20 -0
- package/dist/lib/tokenOptions.mjs +2 -2
- package/dist/lib/tokens.mjs +3 -2
- package/dist/lib/tryCatchRethrow.mjs +1 -1
- package/dist/private/email/orFalse.mjs +1 -1
- package/dist/private/files/reEncode.mjs +1 -1
- package/dist/private/graphQL/schema/mutations/setLastLoginSQL.mjs +1 -1
- package/dist/private/graphQL/schema/mutations/setRedisLoginSession.mjs +3 -3
- package/dist/private/lib/ISentryClient.d.mts +10 -0
- package/dist/private/lib/ISentryClient.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ICivilDate.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/ICivilDate.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IClientConstructor.d.mts +3 -0
- package/dist/private/lib/PostgreSQL/IClientConstructor.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IClientShape.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/IClientShape.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IClockSlot.d.mts +11 -0
- package/dist/private/lib/PostgreSQL/IClockSlot.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IConnectCallback.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/IConnectCallback.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IConnectSettings.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/IConnectSettings.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IHelperRank.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/IHelperRank.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IInternalSink.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/IInternalSink.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ILockOrderPlan.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/ILockOrderPlan.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IModeOrder.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/IModeOrder.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IPostgresState.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/IPostgresState.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRoleCheck.d.mts +4 -0
- package/dist/private/lib/PostgreSQL/IRoleCheck.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRoleColumnCheck.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/IRoleColumnCheck.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRoleObjectCheck.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/IRoleObjectCheck.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRolePlan.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/IRolePlan.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRoleRow.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/IRoleRow.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ITrackerState.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/ITrackerState.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ITxHandleState.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/ITxHandleState.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ITxSettings.d.mts +14 -0
- package/dist/private/lib/PostgreSQL/ITxSettings.mjs +2 -0
- package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.mjs +6 -0
- package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.mjs +7 -0
- package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.mjs +9 -0
- package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.d.mts +26 -0
- package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.mjs +84 -0
- package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.mjs +7 -0
- package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.mjs +11 -0
- package/dist/private/lib/PostgreSQL/admitLock.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/admitLock.mjs +33 -0
- package/dist/private/lib/PostgreSQL/assertPoolOptions.d.mts +12 -0
- package/dist/private/lib/PostgreSQL/assertPoolOptions.mjs +19 -0
- package/dist/private/lib/PostgreSQL/assertVersionGuardInput.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/assertVersionGuardInput.mjs +14 -0
- package/dist/private/lib/PostgreSQL/catalogFlag.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/catalogFlag.mjs +7 -0
- package/dist/private/lib/PostgreSQL/catalogRow.d.mts +4 -0
- package/dist/private/lib/PostgreSQL/catalogRow.mjs +11 -0
- package/dist/private/lib/PostgreSQL/catalogRows.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/catalogRows.mjs +12 -0
- package/dist/private/lib/PostgreSQL/catalogText.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/catalogText.mjs +7 -0
- package/dist/private/lib/PostgreSQL/checkRoleOnClient.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/checkRoleOnClient.mjs +31 -0
- package/dist/private/lib/PostgreSQL/checkedClient.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/checkedClient.mjs +22 -0
- package/dist/private/lib/PostgreSQL/civilCalendar.d.mts +13 -0
- package/dist/private/lib/PostgreSQL/civilCalendar.mjs +48 -0
- package/dist/private/lib/PostgreSQL/clockInstant.d.mts +11 -0
- package/dist/private/lib/PostgreSQL/clockInstant.mjs +18 -0
- package/dist/private/lib/PostgreSQL/clockSlot.d.mts +3 -0
- package/dist/private/lib/PostgreSQL/clockSlot.mjs +11 -0
- package/dist/private/lib/PostgreSQL/clockStatement.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/clockStatement.mjs +22 -0
- package/dist/private/lib/PostgreSQL/connectAndCheck.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/connectAndCheck.mjs +47 -0
- package/dist/private/lib/PostgreSQL/constraintDetails.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/constraintDetails.mjs +21 -0
- package/dist/private/lib/PostgreSQL/constraintField.d.mts +4 -0
- package/dist/private/lib/PostgreSQL/constraintField.mjs +5 -0
- package/dist/private/lib/PostgreSQL/errorCodeOf.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/errorCodeOf.mjs +7 -0
- package/dist/private/lib/PostgreSQL/internalFailure.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/internalFailure.mjs +10 -0
- package/dist/private/lib/PostgreSQL/isNameList.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/isNameList.mjs +6 -0
- package/dist/private/lib/PostgreSQL/isOneOf.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/isOneOf.mjs +5 -0
- package/dist/private/lib/PostgreSQL/isQualifiedName.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/isQualifiedName.mjs +7 -0
- package/dist/private/lib/PostgreSQL/isRoleName.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/isRoleName.mjs +7 -0
- package/dist/private/lib/PostgreSQL/lockOrderPlan.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/lockOrderPlan.mjs +66 -0
- package/dist/private/lib/PostgreSQL/mapTypedError.d.mts +3 -0
- package/dist/private/lib/PostgreSQL/mapTypedError.mjs +28 -0
- package/dist/private/lib/PostgreSQL/mapViolation.d.mts +3 -0
- package/dist/private/lib/PostgreSQL/mapViolation.mjs +32 -0
- package/dist/private/lib/PostgreSQL/membershipOutsider.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/membershipOutsider.mjs +17 -0
- package/dist/private/lib/PostgreSQL/missingColumn.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/missingColumn.mjs +15 -0
- package/dist/private/lib/PostgreSQL/missingGrant.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/missingGrant.mjs +7 -0
- package/dist/private/lib/PostgreSQL/missingObject.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/missingObject.mjs +14 -0
- package/dist/private/lib/PostgreSQL/poolUrlSecrets.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/poolUrlSecrets.mjs +41 -0
- package/dist/private/lib/PostgreSQL/postgresState.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/postgresState.mjs +32 -0
- package/dist/private/lib/PostgreSQL/rankCheckOption.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/rankCheckOption.mjs +7 -0
- package/dist/private/lib/PostgreSQL/readField.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/readField.mjs +10 -0
- package/dist/private/lib/PostgreSQL/roleCheckOf.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/roleCheckOf.mjs +39 -0
- package/dist/private/lib/PostgreSQL/roleFailureSubject.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/roleFailureSubject.mjs +12 -0
- package/dist/private/lib/PostgreSQL/rolePlan.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/rolePlan.mjs +26 -0
- package/dist/private/lib/PostgreSQL/runRoleChecks.d.mts +17 -0
- package/dist/private/lib/PostgreSQL/runRoleChecks.mjs +48 -0
- package/dist/private/lib/PostgreSQL/runTxAttempt.d.mts +12 -0
- package/dist/private/lib/PostgreSQL/runTxAttempt.mjs +50 -0
- package/dist/private/lib/PostgreSQL/runTxBody.d.mts +11 -0
- package/dist/private/lib/PostgreSQL/runTxBody.mjs +19 -0
- package/dist/private/lib/PostgreSQL/runTxWithRetries.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/runTxWithRetries.mjs +31 -0
- package/dist/private/lib/PostgreSQL/scrubSecrets.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/scrubSecrets.mjs +6 -0
- package/dist/private/lib/PostgreSQL/txFailure.d.mts +4 -0
- package/dist/private/lib/PostgreSQL/txFailure.mjs +7 -0
- package/dist/private/lib/PostgreSQL/txHandle.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/txHandle.mjs +26 -0
- package/dist/private/lib/PostgreSQL/txSettings.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/txSettings.mjs +48 -0
- package/dist/private/lib/PostgreSQL/versionText.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/versionText.mjs +12 -0
- package/dist/private/lib/access/assertResetAllowed.mjs +1 -1
- package/dist/private/lib/access/db/deleteUserByEmail.mjs +1 -1
- package/dist/private/lib/access/db/enableEmailAccess.mjs +1 -1
- package/dist/private/lib/access/db/userData4VerifyEmail.mjs +1 -1
- package/dist/private/lib/access/handleBadDB.mjs +1 -1
- package/dist/private/lib/createSentryClient.d.mts +7 -0
- package/dist/private/lib/createSentryClient.mjs +20 -0
- package/dist/private/lib/importOptional.d.mts +7 -0
- package/dist/private/lib/importOptional.mjs +27 -0
- package/dist/private/lib/loadEnv.d.mts +12 -0
- package/dist/private/lib/loadEnv.mjs +14 -0
- package/dist/private/lib/sentry.d.mts +3 -0
- package/dist/private/lib/sentry.mjs +12 -0
- package/package.json +563 -7
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { runTxWithRetries } from "../../../private/lib/PostgreSQL/runTxWithRetries.mjs";
|
|
2
|
+
import { txSettings } from "../../../private/lib/PostgreSQL/txSettings.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Runs `fn` in a transaction and answers what it answers. It is the one transaction wrapper, so that no caller writes
|
|
5
|
+
* its own isolation, lock timeout or retry loop.
|
|
6
|
+
*
|
|
7
|
+
* What one attempt does, in order:
|
|
8
|
+
*
|
|
9
|
+
* 1. Checks a connection out of the pool and listens to its `error` event while it holds it.
|
|
10
|
+
* 2. `BEGIN ISOLATION LEVEL <level> [READ ONLY]`, the text taken from a closed table (never built), then
|
|
11
|
+
* `SET LOCAL lock_timeout = <ms>`. `SET LOCAL` is the only form of `SET` here: the value ends with the transaction,
|
|
12
|
+
* so the role-level value is back for the next user of the connection, and a transaction pooler stays usable.
|
|
13
|
+
* 3. Runs `fn` with a handle that has one member, `query`. The pool and the connection are not reachable from the
|
|
14
|
+
* handle, and the handle stops working when the transaction ends, so a statement cannot run outside the
|
|
15
|
+
* transaction, not even through a handle that `fn` kept.
|
|
16
|
+
* 4. `COMMIT` when `fn` resolved; `ROLLBACK` when anything threw. A rollback that fails does not hide the error that
|
|
17
|
+
* caused it: the original error is thrown, and the connection is destroyed instead of returned to the pool.
|
|
18
|
+
*
|
|
19
|
+
* What the loop does with a failure of an attempt, by SQLSTATE:
|
|
20
|
+
*
|
|
21
|
+
* - `40001` (serialisation failure) and `40P01` (deadlock detected): the whole attempt was rolled back; `fn` runs again
|
|
22
|
+
* in a fresh transaction on a fresh checkout, after the injected delay, up to `retryMax` times (default
|
|
23
|
+
* `TX_RETRY_MAX`). After the last one fails too the caller gets `options.errors.internal('TX_RETRY_EXHAUSTED')`.
|
|
24
|
+
* - `55P03` (lock not available, the lock timeout): no retry; `options.errors.internal('LOCK_TIMEOUT')`.
|
|
25
|
+
* - anything else: rethrown unchanged (the same object) after the rollback.
|
|
26
|
+
*
|
|
27
|
+
* The two errors of the factory are asked for a reason and nothing else: no `cause`, no driver message, no constraint
|
|
28
|
+
* name. The reason goes to the log and to a counter, with the SQLSTATE and the number of attempts and nothing the
|
|
29
|
+
* driver wrote.
|
|
30
|
+
*
|
|
31
|
+
* A swallowed failure is not a success: if `fn` catches the error of a statement and resolves, the server answers
|
|
32
|
+
* `COMMIT` with the tag `ROLLBACK` (the transaction is aborted). The wrapper reads the tag and throws the first failed
|
|
33
|
+
* statement, which then goes through the classification above.
|
|
34
|
+
*
|
|
35
|
+
* Rejects with `TypeError` for an option out of range (before a connection is taken). `fn` may run more than once, so it
|
|
36
|
+
* must hold no state that a failed run leaves behind.
|
|
37
|
+
*/
|
|
38
|
+
export async function withTx(pool, options, fn) {
|
|
39
|
+
return runTxWithRetries(pool, txSettings(options), fn, 0);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=withTx.mjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** What {@link databaseUrlReason} needs besides the URL. */
|
|
2
|
+
export interface IDatabaseUrlOptions {
|
|
3
|
+
/** The role the service must connect as; the user of the URL must equal it exactly. */
|
|
4
|
+
readonly expectedRole: string;
|
|
5
|
+
/**
|
|
6
|
+
* True when a loopback host may be reached without TLS (a disposable local database, a CI service container). The
|
|
7
|
+
* caller decides, from whatever environment signal it has: this function reads no environment variable.
|
|
8
|
+
*/
|
|
9
|
+
readonly allowPlainLoopback: boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed words {@link databaseUrlReason} answers with; none contains a part of the URL:
|
|
3
|
+
*
|
|
4
|
+
* - `url_syntax`: whitespace, a control character or a backslash; not parseable; a fragment.
|
|
5
|
+
* - `url_scheme`: not `postgres://` or `postgresql://`.
|
|
6
|
+
* - `url_user`: no user, or a user that is not a plain identifier.
|
|
7
|
+
* - `url_role`: the user is not the expected role.
|
|
8
|
+
* - `url_host`: not a host name or an IP address.
|
|
9
|
+
* - `url_port`: no explicit port, or a port outside 1 to 65535.
|
|
10
|
+
* - `url_database`: no database name, or one that is not a plain identifier.
|
|
11
|
+
* - `url_query`: a query parameter other than `sslmode` and an absolute `sslrootcert`, or one given twice.
|
|
12
|
+
* - `url_tls`: no `sslmode=verify-full`, and not a loopback host the caller exempted.
|
|
13
|
+
*/
|
|
14
|
+
export type IDatabaseUrlReason = 'url_syntax' | 'url_scheme' | 'url_user' | 'url_role' | 'url_host' | 'url_port' | 'url_database' | 'url_query' | 'url_tls';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IDatabaseUrlOptions } from "./IDatabaseUrlOptions.mjs";
|
|
2
|
+
import type { IDatabaseUrlReason } from "./IDatabaseUrlReason.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Checks a database URL. Answers `undefined` when it is acceptable, otherwise the first reason it is not, in this order:
|
|
5
|
+
* syntax, scheme, user, role, host, port, database name, query, TLS. The reason is a closed word; it never contains a
|
|
6
|
+
* part of the URL.
|
|
7
|
+
*
|
|
8
|
+
* A URL is accepted only when it has a user equal to `expectedRole`, a host, an explicit port and one database name, and
|
|
9
|
+
* only when it asks for TLS with certificate and name verification (`sslmode=verify-full`), except for a loopback
|
|
10
|
+
* host when `allowPlainLoopback` is true.
|
|
11
|
+
*
|
|
12
|
+
* Why the URL is read so strictly. node-postgres reads a connection string with the WHATWG `URL` parser, then copies
|
|
13
|
+
* every query parameter over the parsed parts: `?host=`, `?port=`, `?user=` and `?password=` replace the host, the
|
|
14
|
+
* port, the user and the password of the URL itself, `?ssl=0` and `?sslmode=` change TLS, and `?uselibpqcompat=true`
|
|
15
|
+
* changes what `sslmode` means. A check that looked only at the authority would pass a URL that connects somewhere
|
|
16
|
+
* else, under another login, without TLS. So the query is an allow-list (`sslmode`, `sslrootcert`, each at most once),
|
|
17
|
+
* the user and the database name are plain identifiers (no percent-escape whose decoding two parsers could disagree
|
|
18
|
+
* about), and this function uses the same `URL` parser as the driver.
|
|
19
|
+
*/
|
|
20
|
+
export declare function databaseUrlReason(text: string, options: IDatabaseUrlOptions): IDatabaseUrlReason | undefined;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { isAbsolutePath } from "./isAbsolutePath.mjs";
|
|
2
|
+
import { isValidHost } from "./isValidHost.mjs";
|
|
3
|
+
import { LOOPBACK_HOSTS } from "./LOOPBACK_HOSTS.mjs";
|
|
4
|
+
/** The only query parameters a URL may carry. */
|
|
5
|
+
const ALLOWED_QUERY = ['sslmode', 'sslrootcert'];
|
|
6
|
+
const IDENTIFIER = /^\w[\w-]*$/;
|
|
7
|
+
const SCHEME = /^postgres(?:ql)?:\/\//;
|
|
8
|
+
/** The host of a parsed URL without the brackets of an IPv6 literal. */
|
|
9
|
+
const hostOf = (url) => (url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname);
|
|
10
|
+
/** True when a character is whitespace, a control character or a backslash. */
|
|
11
|
+
function hasForbiddenChar(text) {
|
|
12
|
+
for (const char of text) {
|
|
13
|
+
const code = char.charCodeAt(0);
|
|
14
|
+
if (code <= 0x20 || code === 0x7f || code === 0x5c)
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
/** The reason the text cannot be a URL at all, before it is parsed, or `undefined`. */
|
|
20
|
+
function syntaxReason(text) {
|
|
21
|
+
if (hasForbiddenChar(text))
|
|
22
|
+
return 'url_syntax';
|
|
23
|
+
return SCHEME.test(text) ? undefined : 'url_scheme';
|
|
24
|
+
}
|
|
25
|
+
/** The URL, parsed with the same `URL` parser the driver uses; `undefined` when it cannot be parsed or has a fragment. */
|
|
26
|
+
function parseUrl(text) {
|
|
27
|
+
try {
|
|
28
|
+
const url = new URL(text);
|
|
29
|
+
return url.hash === '' ? url : undefined;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function roleReason(url, expectedRole) {
|
|
36
|
+
// nosemgrep: ajinabraham.njsscan.dos.regex_dos.regex_dos -- IDENTIFIER is anchored with one quantifier per class, so it matches in linear time
|
|
37
|
+
if (!IDENTIFIER.test(url.username))
|
|
38
|
+
return 'url_user';
|
|
39
|
+
return url.username === expectedRole ? undefined : 'url_role';
|
|
40
|
+
}
|
|
41
|
+
function locationReason(url) {
|
|
42
|
+
if (!isValidHost(hostOf(url)))
|
|
43
|
+
return 'url_host';
|
|
44
|
+
// An absent port reads as 0 here, which the lower bound refuses; the parser has already refused a port above 65535
|
|
45
|
+
// and has written the digits without leading zeros.
|
|
46
|
+
const port = Number(url.port);
|
|
47
|
+
if (port < 1)
|
|
48
|
+
return 'url_port';
|
|
49
|
+
// The identifier has no `/`, so `/a/b` and a missing name both fail here.
|
|
50
|
+
return IDENTIFIER.test(url.pathname.slice(1)) ? undefined : 'url_database';
|
|
51
|
+
}
|
|
52
|
+
function queryReason(url) {
|
|
53
|
+
const seen = new Set();
|
|
54
|
+
for (const [key, value] of url.searchParams) {
|
|
55
|
+
if (!ALLOWED_QUERY.includes(key) || seen.has(key))
|
|
56
|
+
return 'url_query';
|
|
57
|
+
seen.add(key);
|
|
58
|
+
if (key === 'sslrootcert' && !isAbsolutePath(value))
|
|
59
|
+
return 'url_query';
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
/** The TLS rule: `verify-full`, or a loopback host when the caller allows plain loopback. */
|
|
64
|
+
function tlsReason(url, allowPlainLoopback) {
|
|
65
|
+
if (url.searchParams.get('sslmode') === 'verify-full')
|
|
66
|
+
return undefined;
|
|
67
|
+
const loopback = LOOPBACK_HOSTS.includes(hostOf(url).toLowerCase());
|
|
68
|
+
return loopback && allowPlainLoopback ? undefined : 'url_tls';
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks a database URL. Answers `undefined` when it is acceptable, otherwise the first reason it is not, in this order:
|
|
72
|
+
* syntax, scheme, user, role, host, port, database name, query, TLS. The reason is a closed word; it never contains a
|
|
73
|
+
* part of the URL.
|
|
74
|
+
*
|
|
75
|
+
* A URL is accepted only when it has a user equal to `expectedRole`, a host, an explicit port and one database name, and
|
|
76
|
+
* only when it asks for TLS with certificate and name verification (`sslmode=verify-full`), except for a loopback
|
|
77
|
+
* host when `allowPlainLoopback` is true.
|
|
78
|
+
*
|
|
79
|
+
* Why the URL is read so strictly. node-postgres reads a connection string with the WHATWG `URL` parser, then copies
|
|
80
|
+
* every query parameter over the parsed parts: `?host=`, `?port=`, `?user=` and `?password=` replace the host, the
|
|
81
|
+
* port, the user and the password of the URL itself, `?ssl=0` and `?sslmode=` change TLS, and `?uselibpqcompat=true`
|
|
82
|
+
* changes what `sslmode` means. A check that looked only at the authority would pass a URL that connects somewhere
|
|
83
|
+
* else, under another login, without TLS. So the query is an allow-list (`sslmode`, `sslrootcert`, each at most once),
|
|
84
|
+
* the user and the database name are plain identifiers (no percent-escape whose decoding two parsers could disagree
|
|
85
|
+
* about), and this function uses the same `URL` parser as the driver.
|
|
86
|
+
*/
|
|
87
|
+
export function databaseUrlReason(text, options) {
|
|
88
|
+
const early = syntaxReason(text);
|
|
89
|
+
if (early !== undefined)
|
|
90
|
+
return early;
|
|
91
|
+
const url = parseUrl(text);
|
|
92
|
+
if (url === undefined)
|
|
93
|
+
return 'url_syntax';
|
|
94
|
+
return (roleReason(url, options.expectedRole) ??
|
|
95
|
+
locationReason(url) ??
|
|
96
|
+
queryReason(url) ??
|
|
97
|
+
tlsReason(url, options.allowPlainLoopback));
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=databaseUrlReason.mjs.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** True when the text holds an ASCII control character (code below 0x20, or 0x7f). */
|
|
2
|
+
function hasControlChar(text) {
|
|
3
|
+
for (const char of text) {
|
|
4
|
+
const code = char.charCodeAt(0);
|
|
5
|
+
if (code < 0x20 || code === 0x7f)
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
/** True for an absolute POSIX path: starts with `/`, no `..` segment, no control character. */
|
|
11
|
+
export function isAbsolutePath(text) {
|
|
12
|
+
return text.startsWith('/') && !hasControlChar(text) && !text.split('/').includes('..');
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=isAbsolutePath.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True for a host name, an IPv4 address or an IPv6 address. A scheme, a port, a path, a user, a bracket, a zone id, an
|
|
3
|
+
* underscore and a trailing dot are all refused. A name whose last label is all digits is refused too: it is how
|
|
4
|
+
* `127.1` and `999.1.1.1` look, and a resolver may read them as addresses.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isValidHost(text: string): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isIP } from 'node:net';
|
|
2
|
+
// eslint-disable-next-line security/detect-unsafe-regex -- nested quantifier is the bounded {0,61} inside an optional group, no backtracking blow-up
|
|
3
|
+
const DNS_LABEL = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/;
|
|
4
|
+
/** The last label is all digits: `127.1`, `999.1.1.1`, `8080`. */
|
|
5
|
+
const NUMERIC_TAIL = /(?:^|\.)\d+$/;
|
|
6
|
+
/**
|
|
7
|
+
* True for a host name, an IPv4 address or an IPv6 address. A scheme, a port, a path, a user, a bracket, a zone id, an
|
|
8
|
+
* underscore and a trailing dot are all refused. A name whose last label is all digits is refused too: it is how
|
|
9
|
+
* `127.1` and `999.1.1.1` look, and a resolver may read them as addresses.
|
|
10
|
+
*/
|
|
11
|
+
export function isValidHost(text) {
|
|
12
|
+
if (text.length > 253)
|
|
13
|
+
return false;
|
|
14
|
+
if (isIP(text) !== 0)
|
|
15
|
+
return !text.includes('%');
|
|
16
|
+
if (!text.split('.').every((label) => DNS_LABEL.test(label)))
|
|
17
|
+
return false;
|
|
18
|
+
return !NUMERIC_TAIL.test(text);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=isValidHost.mjs.map
|
package/dist/lib/tokens.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
2
|
export const REFRESH_TOKEN_EXPIRY = 90 * 24 * 60 * 60; // 90 days
|
|
3
|
+
// typed `string`, as uuid v4() was: randomUUID() returns a template literal type that would narrow every caller
|
|
3
4
|
function generateToken() {
|
|
4
|
-
return
|
|
5
|
+
return randomUUID();
|
|
5
6
|
}
|
|
6
7
|
export function generateAccessToken() {
|
|
7
8
|
return generateToken();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as Sentry from
|
|
1
|
+
import * as Sentry from "../private/lib/sentry.mjs";
|
|
2
2
|
import { throwGraphQLError } from "../graphQL/throw/throwGraphQLError.mjs";
|
|
3
3
|
import { throwInternalError } from "../graphQL/throw/throwInternalError.mjs";
|
|
4
4
|
import { GraphQLError } from 'graphql';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sequelize } from "../../../../dataSources/MariaDB.mjs";
|
|
2
|
-
import * as Sentry from
|
|
2
|
+
import * as Sentry from "../../../lib/sentry.mjs";
|
|
3
3
|
import { QueryTypes } from 'sequelize';
|
|
4
4
|
export async function setLastLoginSQL(id) {
|
|
5
5
|
// Get the current time in milliseconds since the Unix Epoch
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { redisClient } from "../../../../dataSources/Redis.mjs";
|
|
2
2
|
import { REFRESH_TOKEN_EXPIRY } from "../../../../lib/tokens.mjs";
|
|
3
|
-
import
|
|
3
|
+
import { loadEnv } from "../../../lib/loadEnv.mjs";
|
|
4
|
+
import * as Sentry from "../../../lib/sentry.mjs";
|
|
4
5
|
import { throwInternalError } from "../../../../graphQL/throw/throwInternalError.mjs";
|
|
5
|
-
|
|
6
|
-
dotenv.config();
|
|
6
|
+
loadEnv();
|
|
7
7
|
export async function setRedisLoginSession(id, accessToken, accTokenExp, refreshToken) {
|
|
8
8
|
const keyDataAccess = { id: id.toString() };
|
|
9
9
|
const keyDataRefresh = { ...keyDataAccess, access: accessToken };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { captureException, captureMessage, Scope } from '@sentry/node';
|
|
2
|
+
/**
|
|
3
|
+
* The three Sentry calls this package makes, with the signatures of `@sentry/node`. The real module satisfies it as is
|
|
4
|
+
* (its `withScope` has a second overload this package never uses); the no-op client in `createSentryClient` too.
|
|
5
|
+
*/
|
|
6
|
+
export interface ISentryClient {
|
|
7
|
+
captureException: typeof captureException;
|
|
8
|
+
captureMessage: typeof captureMessage;
|
|
9
|
+
withScope: <T>(callback: (scope: Scope) => T) => T;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IConnectCallback } from './IConnectCallback.mjs';
|
|
2
|
+
/** The members of the driver's client that the checked subclass uses. */
|
|
3
|
+
export interface IClientShape {
|
|
4
|
+
connect(): Promise<unknown>;
|
|
5
|
+
connect(callback: IConnectCallback): void;
|
|
6
|
+
query(text: string): Promise<{
|
|
7
|
+
rows: Record<string, unknown>[];
|
|
8
|
+
}>;
|
|
9
|
+
end(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** What is known about the clock of one transaction. */
|
|
2
|
+
export interface IClockSlot {
|
|
3
|
+
/** True once a lock helper has taken a lock in this transaction. */
|
|
4
|
+
locked: boolean;
|
|
5
|
+
/** The instant, in epoch milliseconds, once it was read. */
|
|
6
|
+
instant: number | undefined;
|
|
7
|
+
/** The read that is under way, so that concurrent callers share one statement. */
|
|
8
|
+
pending: Promise<number> | undefined;
|
|
9
|
+
/** Set by `createDbClock`: reads the instant (once) with the statement of that clock. */
|
|
10
|
+
read: (() => Promise<number>) | undefined;
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IPoolCounter } from "../../../lib/PostgreSQL/pool/IPoolCounter.mjs";
|
|
2
|
+
import type { IPoolLogger } from "../../../lib/PostgreSQL/pool/IPoolLogger.mjs";
|
|
3
|
+
/** What the connect of one client needs besides the client. */
|
|
4
|
+
export interface IConnectSettings {
|
|
5
|
+
readonly connectTimeoutMs: number;
|
|
6
|
+
readonly logger: IPoolLogger;
|
|
7
|
+
readonly count: IPoolCounter;
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IDbCounter } from "../../../lib/PostgreSQL/counter/IDbCounter.mjs";
|
|
2
|
+
import type { IDbErrorFactory } from "../../../lib/PostgreSQL/error/IDbErrorFactory.mjs";
|
|
3
|
+
import type { IPoolLogger } from "../../../lib/PostgreSQL/pool/IPoolLogger.mjs";
|
|
4
|
+
/** What `internalFailure` needs: the factory's `internal`, a logger with `error`, and an optional counter over the names it emits. */
|
|
5
|
+
export interface IInternalSink<TError extends Error, TName extends string> {
|
|
6
|
+
readonly errors: Pick<IDbErrorFactory<TError>, 'internal'>;
|
|
7
|
+
readonly logger: Pick<IPoolLogger, 'error'>;
|
|
8
|
+
readonly counter?: IDbCounter<TName>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IModeOrder } from './IModeOrder.mjs';
|
|
2
|
+
/** A lock-order spec after the check and the copy: what a tracker reads, and no more. */
|
|
3
|
+
export interface ILockOrderPlan {
|
|
4
|
+
readonly defaultOrder: IModeOrder;
|
|
5
|
+
readonly orders: ReadonlyMap<string, IModeOrder>;
|
|
6
|
+
/** The helpers the spec names. */
|
|
7
|
+
readonly helpers: ReadonlySet<string>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IHelperRank } from './IHelperRank.mjs';
|
|
2
|
+
/** The order of one mode, after the spec was checked: the ranks lowest first, and the rank each helper takes in it. */
|
|
3
|
+
export interface IModeOrder {
|
|
4
|
+
readonly mode: string;
|
|
5
|
+
readonly names: readonly string[];
|
|
6
|
+
readonly ranks: Map<string, IHelperRank>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IClockSlot } from './IClockSlot.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* What every copy of the package shares: the per-transaction clock slots, keyed by the transaction handle. The registry
|
|
4
|
+
* is frozen and holds no secret and no driver object: a flag, an epoch number, a promise and a function per handle.
|
|
5
|
+
*/
|
|
6
|
+
export interface IPostgresState {
|
|
7
|
+
readonly layout: number;
|
|
8
|
+
readonly slots: WeakMap<object, IClockSlot>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IRoleCheck } from './IRoleCheck.mjs';
|
|
2
|
+
/** The options of `assertRole` after validation: nothing in it needs another look at the caller's input. */
|
|
3
|
+
export interface IRolePlan {
|
|
4
|
+
readonly role: string;
|
|
5
|
+
readonly allowed: ReadonlySet<string>;
|
|
6
|
+
readonly checks: readonly IRoleCheck[];
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IModeOrder } from './IModeOrder.mjs';
|
|
2
|
+
/** What a tracker knows about one transaction. */
|
|
3
|
+
export interface ITrackerState {
|
|
4
|
+
order: IModeOrder;
|
|
5
|
+
rankCheck: boolean;
|
|
6
|
+
/** The highest rank recorded in this transaction, 0 when none. */
|
|
7
|
+
rank: number;
|
|
8
|
+
/** The strength of the locks recorded with `hold`, by key. */
|
|
9
|
+
held: Map<string, number>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IDbErrorFactory } from "../../../lib/PostgreSQL/error/IDbErrorFactory.mjs";
|
|
2
|
+
import type { IPoolLogger } from "../../../lib/PostgreSQL/pool/IPoolLogger.mjs";
|
|
3
|
+
import type { IRetryDelay } from "../../../lib/PostgreSQL/tx/IRetryDelay.mjs";
|
|
4
|
+
import type { ITxCounter } from "../../../lib/PostgreSQL/tx/ITxCounter.mjs";
|
|
5
|
+
/** The options of `withTx` after the checks: every default applied and the two opening statements built. */
|
|
6
|
+
export interface ITxSettings {
|
|
7
|
+
readonly logger: IPoolLogger;
|
|
8
|
+
readonly errors: Pick<IDbErrorFactory, 'internal'>;
|
|
9
|
+
readonly count: ITxCounter;
|
|
10
|
+
readonly begin: string;
|
|
11
|
+
readonly setLockTimeout: string;
|
|
12
|
+
readonly retryMax: number;
|
|
13
|
+
readonly retryDelay: IRetryDelay;
|
|
14
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The key under which every copy of this package finds the registry of the PostgreSQL kit on `globalThis`. A registry
|
|
3
|
+
* symbol, so two copies loaded from two places agree on it without sharing a module.
|
|
4
|
+
*/
|
|
5
|
+
export declare const POSTGRES_STATE_KEY: unique symbol;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The key under which every copy of this package finds the registry of the PostgreSQL kit on `globalThis`. A registry
|
|
3
|
+
* symbol, so two copies loaded from two places agree on it without sharing a module.
|
|
4
|
+
*/
|
|
5
|
+
export const POSTGRES_STATE_KEY = Symbol.for('@axiumine/koa-utils/postgres-state');
|
|
6
|
+
//# sourceMappingURL=POSTGRES_STATE_KEY.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The layout of the shared registry. It changes only when the shape of {@link IPostgresState} or of a slot changes in a
|
|
3
|
+
* way that an older copy cannot read: copies with the same layout share one registry, copies with another refuse each
|
|
4
|
+
* other with `DbStateError` instead of splitting the state.
|
|
5
|
+
*/
|
|
6
|
+
export declare const POSTGRES_STATE_LAYOUT = 1;
|