@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,7 @@
|
|
|
1
|
+
import type { IConstraintEntry } from "../../../lib/PostgreSQL/error/IConstraintEntry.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* The details of a row: the fixed ones, then the keys that the row lists from what the caller supplied. `undefined` for a
|
|
4
|
+
* row without details, and `null` when a listed key is missing. Only own keys of `supplied` count, and a key whose value is
|
|
5
|
+
* `undefined` is missing; an empty array or `false` is a value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function constraintDetails(entry: IConstraintEntry, supplied: Readonly<Record<string, unknown>> | undefined): Record<string, unknown> | null | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readField } from './readField.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* The details of a row: the fixed ones, then the keys that the row lists from what the caller supplied. `undefined` for a
|
|
4
|
+
* row without details, and `null` when a listed key is missing. Only own keys of `supplied` count, and a key whose value is
|
|
5
|
+
* `undefined` is missing; an empty array or `false` is a value.
|
|
6
|
+
*/
|
|
7
|
+
export function constraintDetails(entry, supplied) {
|
|
8
|
+
const keys = entry.supplied ?? [];
|
|
9
|
+
if (entry.fixed === undefined && keys.length === 0)
|
|
10
|
+
return undefined;
|
|
11
|
+
const given = supplied ?? {};
|
|
12
|
+
const pairs = [];
|
|
13
|
+
for (const key of keys) {
|
|
14
|
+
const value = Object.hasOwn(given, key) ? readField(given, key) : undefined;
|
|
15
|
+
if (value === undefined)
|
|
16
|
+
return null;
|
|
17
|
+
pairs.push([key, value]);
|
|
18
|
+
}
|
|
19
|
+
return { ...entry.fixed, ...Object.fromEntries(pairs) };
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=constraintDetails.mjs.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The log field for a constraint name: present only when the error named a plain identifier (see `constraintNameOf`). */
|
|
2
|
+
export function constraintField(name) {
|
|
3
|
+
return name === undefined ? {} : { constraint: name };
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=constraintField.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { readField } from './readField.mjs';
|
|
2
|
+
/** A short code of an error (`ECONNREFUSED`, `28P01`), or `undefined` when it has no string `code`. */
|
|
3
|
+
export function errorCodeOf(error) {
|
|
4
|
+
const code = readField(error, 'code');
|
|
5
|
+
return typeof code === 'string' ? code : undefined;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=errorCodeOf.mjs.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IDbInternalReason } from "../../../lib/PostgreSQL/error/IDbInternalReason.mjs";
|
|
2
|
+
import type { IInternalSink } from './IInternalSink.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Counts, logs and builds the internal error of a closed reason, in that order. `fields` carries the reason and whatever
|
|
5
|
+
* safe fields the caller adds; it is the whole log payload, and only `fields.reason` goes to the factory.
|
|
6
|
+
*/
|
|
7
|
+
export declare function internalFailure<TError extends Error, TName extends string>(sink: IInternalSink<TError, TName>, counterName: TName, message: string, fields: Readonly<Record<string, unknown>> & {
|
|
8
|
+
readonly reason: IDbInternalReason;
|
|
9
|
+
}): TError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counts, logs and builds the internal error of a closed reason, in that order. `fields` carries the reason and whatever
|
|
3
|
+
* safe fields the caller adds; it is the whole log payload, and only `fields.reason` goes to the factory.
|
|
4
|
+
*/
|
|
5
|
+
export function internalFailure(sink, counterName, message, fields) {
|
|
6
|
+
sink.counter?.(counterName);
|
|
7
|
+
sink.logger.error(message, fields);
|
|
8
|
+
return sink.errors.internal(fields.reason);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=internalFailure.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { isRoleName } from './isRoleName.mjs';
|
|
2
|
+
/** True for an array whose every entry is a plain identifier. The empty array is one. */
|
|
3
|
+
export function isNameList(value) {
|
|
4
|
+
return Array.isArray(value) && value.every(isRoleName);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=isNameList.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Two plain identifiers joined by one dot. */
|
|
2
|
+
const QUALIFIED = /^[A-Za-z_][\w$]{0,62}\.[A-Za-z_][\w$]{0,62}$/;
|
|
3
|
+
/** True for a string of the form `schema.name`, each part a plain identifier. Three parts, quotes and spaces are refused. */
|
|
4
|
+
export function isQualifiedName(value) {
|
|
5
|
+
return typeof value === 'string' && QUALIFIED.test(value);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=isQualifiedName.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** A plain unqualified identifier: a letter or `_`, then letters, digits, `_` or `$`, at most 63 characters (the limit of the server). */
|
|
2
|
+
const NAME = /^[A-Za-z_][\w$]{0,62}$/;
|
|
3
|
+
/** True for a string that is a plain identifier. Quotes, dots, spaces and every other character are refused. */
|
|
4
|
+
export function isRoleName(value) {
|
|
5
|
+
return typeof value === 'string' && NAME.test(value);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=isRoleName.mjs.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ILockOrderPlan } from './ILockOrderPlan.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Checks a lock-order spec and copies it into a plan. The checks that keep an order from being silently off: at least one
|
|
4
|
+
* mode, each order a non-empty list of distinct names, the default mode one of the modes, every helper mapped to a rank
|
|
5
|
+
* that exists in the order of a mode that exists, and every helper in at least one order. A `TypeError` names the part
|
|
6
|
+
* that is wrong and never quotes a value other than the name of a mode or a helper.
|
|
7
|
+
*/
|
|
8
|
+
export declare function lockOrderPlan(spec: unknown): ILockOrderPlan;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** True for a non-empty list of distinct, non-empty names. */
|
|
2
|
+
function isRankList(value) {
|
|
3
|
+
return (Array.isArray(value) &&
|
|
4
|
+
value.length > 0 &&
|
|
5
|
+
value.every((name) => typeof name === 'string' && name !== '') &&
|
|
6
|
+
new Set(value).size === value.length);
|
|
7
|
+
}
|
|
8
|
+
/** One empty order per mode of the spec. A `TypeError` for no mode, or a list of ranks that is not one. */
|
|
9
|
+
function modeOrders(orders) {
|
|
10
|
+
if (typeof orders !== 'object' || orders === null)
|
|
11
|
+
throw new TypeError('spec.orders must be an object');
|
|
12
|
+
const entries = Object.entries(orders);
|
|
13
|
+
if (entries.length === 0)
|
|
14
|
+
throw new TypeError('spec.orders must name at least one mode');
|
|
15
|
+
const byMode = new Map();
|
|
16
|
+
for (const [mode, names] of entries) {
|
|
17
|
+
if (!isRankList(names))
|
|
18
|
+
throw new TypeError(`the order of ${mode} must be a non-empty list of distinct names`);
|
|
19
|
+
byMode.set(mode, { mode, names: [...names], ranks: new Map() });
|
|
20
|
+
}
|
|
21
|
+
return byMode;
|
|
22
|
+
}
|
|
23
|
+
/** Puts one helper in the order of each mode it names; answers whether it named any. A `TypeError` for a mode or a rank the spec lacks. */
|
|
24
|
+
function placeHelper(helper, entry, byMode) {
|
|
25
|
+
if (typeof entry !== 'object' || entry === null)
|
|
26
|
+
throw new TypeError(`${helper} must map modes to rank names`);
|
|
27
|
+
let placed = false;
|
|
28
|
+
for (const [mode, name] of Object.entries(entry)) {
|
|
29
|
+
const order = byMode.get(mode);
|
|
30
|
+
if (order === undefined)
|
|
31
|
+
throw new TypeError(`${helper} names a mode that is not in spec.orders`);
|
|
32
|
+
if (name === undefined)
|
|
33
|
+
continue;
|
|
34
|
+
const rank = order.names.indexOf(name) + 1;
|
|
35
|
+
if (rank === 0)
|
|
36
|
+
throw new TypeError(`${helper} names a rank that is not in the ${mode} order`);
|
|
37
|
+
order.ranks.set(helper, { name: name, rank });
|
|
38
|
+
placed = true;
|
|
39
|
+
}
|
|
40
|
+
return placed;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Checks a lock-order spec and copies it into a plan. The checks that keep an order from being silently off: at least one
|
|
44
|
+
* mode, each order a non-empty list of distinct names, the default mode one of the modes, every helper mapped to a rank
|
|
45
|
+
* that exists in the order of a mode that exists, and every helper in at least one order. A `TypeError` names the part
|
|
46
|
+
* that is wrong and never quotes a value other than the name of a mode or a helper.
|
|
47
|
+
*/
|
|
48
|
+
export function lockOrderPlan(spec) {
|
|
49
|
+
if (typeof spec !== 'object' || spec === null)
|
|
50
|
+
throw new TypeError('spec must be an object');
|
|
51
|
+
const { orders, helpers, defaultMode } = spec;
|
|
52
|
+
const byMode = modeOrders(orders);
|
|
53
|
+
const defaultOrder = byMode.get(defaultMode);
|
|
54
|
+
if (defaultOrder === undefined)
|
|
55
|
+
throw new TypeError('spec.defaultMode must be one of the modes');
|
|
56
|
+
if (typeof helpers !== 'object' || helpers === null)
|
|
57
|
+
throw new TypeError('spec.helpers must be an object');
|
|
58
|
+
const names = new Set();
|
|
59
|
+
for (const [helper, entry] of Object.entries(helpers)) {
|
|
60
|
+
if (!placeHelper(helper, entry, byMode))
|
|
61
|
+
throw new TypeError(`${helper} takes no rank in any mode`);
|
|
62
|
+
names.add(helper);
|
|
63
|
+
}
|
|
64
|
+
return { defaultOrder, orders: byMode, helpers: names };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=lockOrderPlan.mjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IMapDbErrorOptions } from "../../../lib/PostgreSQL/error/IMapDbErrorOptions.mjs";
|
|
2
|
+
/** The typed errors of the kit, each with the reason of its own and the closed reason it carries; `undefined` for any other value. */
|
|
3
|
+
export declare function mapTypedError<TError extends Error>(error: unknown, options: IMapDbErrorOptions<TError>): TError | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DbConnectError } from "../../../lib/PostgreSQL/error/DbConnectError.mjs";
|
|
2
|
+
import { DbParseError } from "../../../lib/PostgreSQL/error/DbParseError.mjs";
|
|
3
|
+
import { DbTxError } from "../../../lib/PostgreSQL/error/DbTxError.mjs";
|
|
4
|
+
import { internalFailure } from './internalFailure.mjs';
|
|
5
|
+
/** The typed errors of the kit, each with the reason of its own and the closed reason it carries; `undefined` for any other value. */
|
|
6
|
+
export function mapTypedError(error, options) {
|
|
7
|
+
if (error instanceof DbParseError) {
|
|
8
|
+
return internalFailure(options, 'db_error_internal_total', 'database value cannot be read', {
|
|
9
|
+
reason: 'DB_VALUE_UNREADABLE',
|
|
10
|
+
errorReason: error.reason,
|
|
11
|
+
typeName: error.typeName
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (error instanceof DbConnectError) {
|
|
15
|
+
return internalFailure(options, 'db_error_internal_total', 'database connection refused', {
|
|
16
|
+
reason: 'DB_CONNECTION',
|
|
17
|
+
errorReason: error.reason
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (error instanceof DbTxError) {
|
|
21
|
+
return internalFailure(options, 'db_error_internal_total', 'database transaction misused', {
|
|
22
|
+
reason: 'DB_TX_MISUSE',
|
|
23
|
+
errorReason: error.reason
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=mapTypedError.mjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IMapDbErrorOptions } from "../../../lib/PostgreSQL/error/IMapDbErrorOptions.mjs";
|
|
2
|
+
/** A violation of SQLSTATE 23505, 23514 or 23503: the row of the table built into an error, or the internal error. */
|
|
3
|
+
export declare function mapViolation<TError extends Error>(error: unknown, sqlstate: string, options: IMapDbErrorOptions<TError>): TError;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { constraintNameOf } from "../../../lib/PostgreSQL/error/constraintNameOf.mjs";
|
|
2
|
+
import { lookupConstraint } from "../../../lib/PostgreSQL/error/lookupConstraint.mjs";
|
|
3
|
+
import { constraintDetails } from './constraintDetails.mjs';
|
|
4
|
+
import { constraintField } from './constraintField.mjs';
|
|
5
|
+
import { internalFailure } from './internalFailure.mjs';
|
|
6
|
+
/** A violation of SQLSTATE 23505, 23514 or 23503: the row of the table built into an error, or the internal error. */
|
|
7
|
+
export function mapViolation(error, sqlstate, options) {
|
|
8
|
+
const name = constraintNameOf(error);
|
|
9
|
+
const entry = name === undefined ? undefined : lookupConstraint(options.table, name);
|
|
10
|
+
const fields = { sqlstate, ...constraintField(name) };
|
|
11
|
+
if (entry === undefined) {
|
|
12
|
+
return internalFailure(options, 'db_constraint_unmapped_total', 'database constraint violation is not in the constraint map', {
|
|
13
|
+
reason: 'CONSTRAINT_UNMAPPED',
|
|
14
|
+
...fields
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (entry.code === (options.internalCode ?? 'INTERNAL')) {
|
|
18
|
+
return internalFailure(options, 'db_error_internal_total', 'database constraint violation is a defect', {
|
|
19
|
+
reason: 'CONSTRAINT_INTERNAL',
|
|
20
|
+
...fields
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const details = constraintDetails(entry, options.details);
|
|
24
|
+
if (details === null) {
|
|
25
|
+
return internalFailure(options, 'db_error_internal_total', 'database constraint violation needs details that the caller did not supply', {
|
|
26
|
+
reason: 'DETAILS_NOT_SUPPLIED',
|
|
27
|
+
...fields
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return details === undefined ? options.errors.make(entry.code) : options.errors.make(entry.code, details);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=mapViolation.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ITxClient } from "../../../lib/PostgreSQL/tx/ITxClient.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* The first role, in name order, that `current_user` is a member of and `allowed` does not list; `undefined` when there
|
|
4
|
+
* is none. The names are sorted here, by code unit, and not by a clause of the statement, so the one that is reported
|
|
5
|
+
* does not depend on the collation of the database.
|
|
6
|
+
*/
|
|
7
|
+
export declare function membershipOutsider(client: ITxClient, allowed: ReadonlySet<string>): Promise<string | undefined>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { catalogRows } from './catalogRows.mjs';
|
|
2
|
+
import { catalogText } from './catalogText.mjs';
|
|
3
|
+
import { ROLE_CATALOG_SQL } from './ROLE_CATALOG_SQL.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* The first role, in name order, that `current_user` is a member of and `allowed` does not list; `undefined` when there
|
|
6
|
+
* is none. The names are sorted here, by code unit, and not by a clause of the statement, so the one that is reported
|
|
7
|
+
* does not depend on the collation of the database.
|
|
8
|
+
*/
|
|
9
|
+
export async function membershipOutsider(client, allowed) {
|
|
10
|
+
const rows = await catalogRows(client, ROLE_CATALOG_SQL.memberships);
|
|
11
|
+
return (rows
|
|
12
|
+
.map((row) => catalogText(row['member_of']))
|
|
13
|
+
// eslint-disable-next-line sonarjs/no-alphabetical-sort -- the default order is by UTF-16 code unit, which is the order wanted; localeCompare would depend on the host locale
|
|
14
|
+
.sort()
|
|
15
|
+
.find((name) => !allowed.has(name)));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=membershipOutsider.mjs.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IRoleAssertionSubject } from "../../../lib/PostgreSQL/error/IRoleAssertionSubject.mjs";
|
|
2
|
+
import type { ITxClient } from "../../../lib/PostgreSQL/tx/ITxClient.mjs";
|
|
3
|
+
import type { IRoleColumnCheck } from './IRoleColumnCheck.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* The first column of a column-level check that the role does not hold the privilege on, in the order of the list, named
|
|
6
|
+
* as a subject; `undefined` when it holds all. A column the table does not have is missing too: the statement answers
|
|
7
|
+
* a row only for a column that exists.
|
|
8
|
+
*/
|
|
9
|
+
export declare function missingColumn(client: ITxClient, check: IRoleColumnCheck): Promise<IRoleAssertionSubject | undefined>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { catalogRows } from './catalogRows.mjs';
|
|
2
|
+
import { catalogText } from './catalogText.mjs';
|
|
3
|
+
import { ROLE_CATALOG_SQL } from './ROLE_CATALOG_SQL.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* The first column of a column-level check that the role does not hold the privilege on, in the order of the list, named
|
|
6
|
+
* as a subject; `undefined` when it holds all. A column the table does not have is missing too: the statement answers
|
|
7
|
+
* a row only for a column that exists.
|
|
8
|
+
*/
|
|
9
|
+
export async function missingColumn(client, check) {
|
|
10
|
+
const rows = await catalogRows(client, ROLE_CATALOG_SQL.grant.columns, [check.object, check.privilege, check.columns]);
|
|
11
|
+
const held = new Set(rows.filter((row) => row['held'] === true).map((row) => catalogText(row['name'])));
|
|
12
|
+
const column = check.columns.find((name) => !held.has(name));
|
|
13
|
+
return column === undefined ? undefined : { object: check.object, privilege: check.privilege, column };
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=missingColumn.mjs.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IRoleAssertionSubject } from "../../../lib/PostgreSQL/error/IRoleAssertionSubject.mjs";
|
|
2
|
+
import type { ITxClient } from "../../../lib/PostgreSQL/tx/ITxClient.mjs";
|
|
3
|
+
import type { IRoleCheck } from './IRoleCheck.mjs';
|
|
4
|
+
/** What `check` finds missing, as a subject naming the object, the privilege and for a column the column; `undefined` when it is held. */
|
|
5
|
+
export declare function missingGrant(client: ITxClient, check: IRoleCheck): Promise<IRoleAssertionSubject | undefined>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { missingColumn } from './missingColumn.mjs';
|
|
2
|
+
import { missingObject } from './missingObject.mjs';
|
|
3
|
+
/** What `check` finds missing, as a subject naming the object, the privilege and for a column the column; `undefined` when it is held. */
|
|
4
|
+
export function missingGrant(client, check) {
|
|
5
|
+
return check.kind === 'columns' ? missingColumn(client, check) : missingObject(client, check);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=missingGrant.mjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IRoleAssertionSubject } from "../../../lib/PostgreSQL/error/IRoleAssertionSubject.mjs";
|
|
2
|
+
import type { ITxClient } from "../../../lib/PostgreSQL/tx/ITxClient.mjs";
|
|
3
|
+
import type { IRoleObjectCheck } from './IRoleObjectCheck.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* The object and the privilege of a check on a schema, a function, or a table, view or sequence, as a subject, unless
|
|
6
|
+
* the answer is exactly one row whose `held` is the boolean `true`. A missing object, a `NULL`, a `false`, a second row
|
|
7
|
+
* and a value that is not a boolean are all a missing grant. A function check passes the schema and the function name as
|
|
8
|
+
* two values; the others pass the object and the privilege.
|
|
9
|
+
*/
|
|
10
|
+
export declare function missingObject(client: ITxClient, check: IRoleObjectCheck): Promise<IRoleAssertionSubject | undefined>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { catalogRows } from './catalogRows.mjs';
|
|
2
|
+
import { ROLE_CATALOG_SQL } from './ROLE_CATALOG_SQL.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* The object and the privilege of a check on a schema, a function, or a table, view or sequence, as a subject, unless
|
|
5
|
+
* the answer is exactly one row whose `held` is the boolean `true`. A missing object, a `NULL`, a `false`, a second row
|
|
6
|
+
* and a value that is not a boolean are all a missing grant. A function check passes the schema and the function name as
|
|
7
|
+
* two values; the others pass the object and the privilege.
|
|
8
|
+
*/
|
|
9
|
+
export async function missingObject(client, check) {
|
|
10
|
+
const values = check.kind === 'function' ? check.object.split('.') : [check.object, check.privilege];
|
|
11
|
+
const rows = await catalogRows(client, ROLE_CATALOG_SQL.grant[check.kind], values);
|
|
12
|
+
return rows.length === 1 && rows[0]?.['held'] === true ? undefined : { object: check.object, privilege: check.privilege };
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=missingObject.mjs.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks the URL and answers the strings that must never be written out: the URL and its password, raw and
|
|
3
|
+
* percent-decoded, longest first. The order needs no sort: the URL holds the password, and decoding never makes a
|
|
4
|
+
* password longer. The query may hold `sslmode` and `sslrootcert` and nothing else, because node-postgres
|
|
5
|
+
* lets a parameter of the URL replace a setting of the pool (`application_name`, `host`, `user`). A URL that fails is
|
|
6
|
+
* refused with a `DbConnectError` that holds no part of it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function poolUrlSecrets(url: string): string[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DbConnectError } from "../../../lib/PostgreSQL/error/DbConnectError.mjs";
|
|
2
|
+
/** The only query parameters a pool URL may carry. */
|
|
3
|
+
const ALLOWED_QUERY = ['sslmode', 'sslrootcert'];
|
|
4
|
+
function assertPoolUrl(parsed) {
|
|
5
|
+
if ((parsed.protocol !== 'postgres:' && parsed.protocol !== 'postgresql:') || parsed.hostname === '' || parsed.hash !== '') {
|
|
6
|
+
throw new DbConnectError('URL_INVALID');
|
|
7
|
+
}
|
|
8
|
+
const seen = new Set();
|
|
9
|
+
for (const key of parsed.searchParams.keys()) {
|
|
10
|
+
if (!ALLOWED_QUERY.includes(key) || seen.has(key))
|
|
11
|
+
throw new DbConnectError('URL_INVALID');
|
|
12
|
+
seen.add(key);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Checks the URL and answers the strings that must never be written out: the URL and its password, raw and
|
|
17
|
+
* percent-decoded, longest first. The order needs no sort: the URL holds the password, and decoding never makes a
|
|
18
|
+
* password longer. The query may hold `sslmode` and `sslrootcert` and nothing else, because node-postgres
|
|
19
|
+
* lets a parameter of the URL replace a setting of the pool (`application_name`, `host`, `user`). A URL that fails is
|
|
20
|
+
* refused with a `DbConnectError` that holds no part of it.
|
|
21
|
+
*/
|
|
22
|
+
export function poolUrlSecrets(url) {
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = new URL(url);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
throw new DbConnectError('URL_INVALID');
|
|
29
|
+
}
|
|
30
|
+
assertPoolUrl(parsed);
|
|
31
|
+
const secrets = new Set([url, parsed.password]);
|
|
32
|
+
try {
|
|
33
|
+
secrets.add(decodeURIComponent(parsed.password));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// A password that is not valid percent-encoding is still in the set in its raw form.
|
|
37
|
+
}
|
|
38
|
+
// nosemgrep: ajinabraham.njsscan.crypto.timing_attack_node.node_timing_attack -- drops empty strings; no secret is compared with another value
|
|
39
|
+
return [...secrets].filter((secret) => secret !== '');
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=poolUrlSecrets.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IPostgresState } from './IPostgresState.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* The per-transaction state of the PostgreSQL kit, shared by every copy of the package in the process. It is read once,
|
|
4
|
+
* when this module is loaded, so two copies that cannot share it fail at start. The clock and the lock helpers meet
|
|
5
|
+
* through it: `lockTaken` of one copy reaches the clock that `createDbClock` of another copy bound.
|
|
6
|
+
*/
|
|
7
|
+
export declare const postgresState: IPostgresState;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DbStateError } from "../../../lib/PostgreSQL/error/DbStateError.mjs";
|
|
2
|
+
import { POSTGRES_STATE_KEY } from './POSTGRES_STATE_KEY.mjs';
|
|
3
|
+
import { POSTGRES_STATE_LAYOUT } from './POSTGRES_STATE_LAYOUT.mjs';
|
|
4
|
+
/** True for a registry of this layout. The layout is the contract: a registry that carries it is read as one. */
|
|
5
|
+
function isSharedState(found) {
|
|
6
|
+
return typeof found === 'object' && found !== null && Reflect.get(found, 'layout') === POSTGRES_STATE_LAYOUT;
|
|
7
|
+
}
|
|
8
|
+
/** Makes the registry and puts it on `globalThis`, read-only, not enumerable. Throws if the global object refuses it. */
|
|
9
|
+
function installState() {
|
|
10
|
+
const state = Object.freeze({ layout: POSTGRES_STATE_LAYOUT, slots: new WeakMap() });
|
|
11
|
+
Object.defineProperty(globalThis, POSTGRES_STATE_KEY, { value: state, configurable: true });
|
|
12
|
+
return state;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Finds the registry that an earlier copy of the package put on `globalThis` and uses it, or makes it when this is the
|
|
16
|
+
* first copy. A value of another layout (a copy of another layout, or other code) is `DbStateError` `LAYOUT_MISMATCH`.
|
|
17
|
+
*/
|
|
18
|
+
function sharedState() {
|
|
19
|
+
const found = Reflect.get(globalThis, POSTGRES_STATE_KEY);
|
|
20
|
+
if (found === undefined)
|
|
21
|
+
return installState();
|
|
22
|
+
if (isSharedState(found))
|
|
23
|
+
return found;
|
|
24
|
+
throw new DbStateError('LAYOUT_MISMATCH');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The per-transaction state of the PostgreSQL kit, shared by every copy of the package in the process. It is read once,
|
|
28
|
+
* when this module is loaded, so two copies that cannot share it fail at start. The clock and the lock helpers meet
|
|
29
|
+
* through it: `lockTaken` of one copy reaches the clock that `createDbClock` of another copy bound.
|
|
30
|
+
*/
|
|
31
|
+
export const postgresState = sharedState();
|
|
32
|
+
//# sourceMappingURL=postgresState.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The `rankCheck` option as given, or a `TypeError` when it is neither a boolean nor missing. */
|
|
2
|
+
export function rankCheckOption(value) {
|
|
3
|
+
if (value !== undefined && typeof value !== 'boolean')
|
|
4
|
+
throw new TypeError('rankCheck must be a boolean');
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=rankCheckOption.mjs.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads one property of a value that is an object, or answers `undefined` for anything else (a primitive, `null`).
|
|
3
|
+
* The read is shape-agnostic on purpose: callers check the type of what comes back.
|
|
4
|
+
*/
|
|
5
|
+
export declare function readField(value: unknown, key: string): unknown;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads one property of a value that is an object, or answers `undefined` for anything else (a primitive, `null`).
|
|
3
|
+
* The read is shape-agnostic on purpose: callers check the type of what comes back.
|
|
4
|
+
*/
|
|
5
|
+
export function readField(value, key) {
|
|
6
|
+
if (typeof value !== 'object' || value === null)
|
|
7
|
+
return undefined;
|
|
8
|
+
return Reflect.get(value, key);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=readField.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IRoleCheck } from './IRoleCheck.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Reads one entry of `expectedGrants` into a check, or answers `undefined` when its shape is wrong: not an object, an
|
|
4
|
+
* object that is neither a plain name (a schema) nor `schema.name`, a privilege the kind of object cannot hold, or
|
|
5
|
+
* `columns` on anything but a table privilege that a column can hold.
|
|
6
|
+
*/
|
|
7
|
+
export declare function roleCheckOf(grant: unknown): IRoleCheck | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isNameList } from './isNameList.mjs';
|
|
2
|
+
import { isOneOf } from './isOneOf.mjs';
|
|
3
|
+
import { isQualifiedName } from './isQualifiedName.mjs';
|
|
4
|
+
import { isRoleName } from './isRoleName.mjs';
|
|
5
|
+
import { ROLE_PRIVILEGES } from './ROLE_PRIVILEGES.mjs';
|
|
6
|
+
/** A grant on a schema: `USAGE` or `CREATE`, and no column list. */
|
|
7
|
+
function schemaCheck(object, privilege, columns) {
|
|
8
|
+
return columns === undefined && isOneOf(ROLE_PRIVILEGES.schema, privilege) ? { kind: 'schema', object, privilege } : undefined;
|
|
9
|
+
}
|
|
10
|
+
/** A column-level grant: a privilege a column can hold, on a non-empty list of plain column names. */
|
|
11
|
+
function columnCheck(object, privilege, columns) {
|
|
12
|
+
if (!isOneOf(ROLE_PRIVILEGES.column, privilege))
|
|
13
|
+
return undefined;
|
|
14
|
+
if (!isNameList(columns) || columns.length === 0)
|
|
15
|
+
return undefined;
|
|
16
|
+
return { kind: 'columns', object, privilege, columns };
|
|
17
|
+
}
|
|
18
|
+
/** A grant on `schema.name`: `EXECUTE` on a function, a column-level privilege on a table, or a table or sequence privilege. */
|
|
19
|
+
function qualifiedCheck(object, privilege, columns) {
|
|
20
|
+
if (privilege === 'EXECUTE')
|
|
21
|
+
return columns === undefined ? { kind: 'function', object, privilege } : undefined;
|
|
22
|
+
if (columns !== undefined)
|
|
23
|
+
return columnCheck(object, privilege, columns);
|
|
24
|
+
return isOneOf(ROLE_PRIVILEGES.relation, privilege) ? { kind: 'relation', object, privilege } : undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Reads one entry of `expectedGrants` into a check, or answers `undefined` when its shape is wrong: not an object, an
|
|
28
|
+
* object that is neither a plain name (a schema) nor `schema.name`, a privilege the kind of object cannot hold, or
|
|
29
|
+
* `columns` on anything but a table privilege that a column can hold.
|
|
30
|
+
*/
|
|
31
|
+
export function roleCheckOf(grant) {
|
|
32
|
+
if (typeof grant !== 'object' || grant === null)
|
|
33
|
+
return undefined;
|
|
34
|
+
const { object, privilege, columns } = grant;
|
|
35
|
+
if (isRoleName(object))
|
|
36
|
+
return schemaCheck(object, privilege, columns);
|
|
37
|
+
return isQualifiedName(object) ? qualifiedCheck(object, privilege, columns) : undefined;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=roleCheckOf.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IRoleAssertionSubject } from "../../../lib/PostgreSQL/error/IRoleAssertionSubject.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* What a failure that is not an assertion contributes to the `CHECK_FAILED` error: the closed reason of a refused
|
|
4
|
+
* connection, or the driver's own `code` when it is a string, as the `code` of the subject; an empty subject for
|
|
5
|
+
* anything else. `RoleAssertionError` keeps the code only if it is short and made of letters, digits and underscores.
|
|
6
|
+
*/
|
|
7
|
+
export declare function roleFailureSubject(error: unknown): IRoleAssertionSubject;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DbConnectError } from "../../../lib/PostgreSQL/error/DbConnectError.mjs";
|
|
2
|
+
import { readField } from './readField.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* What a failure that is not an assertion contributes to the `CHECK_FAILED` error: the closed reason of a refused
|
|
5
|
+
* connection, or the driver's own `code` when it is a string, as the `code` of the subject; an empty subject for
|
|
6
|
+
* anything else. `RoleAssertionError` keeps the code only if it is short and made of letters, digits and underscores.
|
|
7
|
+
*/
|
|
8
|
+
export function roleFailureSubject(error) {
|
|
9
|
+
const code = error instanceof DbConnectError ? error.reason : readField(error, 'code');
|
|
10
|
+
return typeof code === 'string' ? { code } : {};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=roleFailureSubject.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IRolePlan } from './IRolePlan.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the options of `assertRole` into a plan, or throws `INVALID_EXPECTATION`. Nothing here touches the pool. A
|
|
4
|
+
* caller from plain JavaScript may pass anything, so every field is checked as it is read. The error is given the role
|
|
5
|
+
* as it came: `RoleAssertionError` prints a role that is not a plain name as `?`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function rolePlan(options: unknown): IRolePlan;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RoleAssertionError } from "../../../lib/PostgreSQL/error/RoleAssertionError.mjs";
|
|
2
|
+
import { isNameList } from './isNameList.mjs';
|
|
3
|
+
import { isRoleName } from './isRoleName.mjs';
|
|
4
|
+
import { roleCheckOf } from './roleCheckOf.mjs';
|
|
5
|
+
/**
|
|
6
|
+
* Reads the options of `assertRole` into a plan, or throws `INVALID_EXPECTATION`. Nothing here touches the pool. A
|
|
7
|
+
* caller from plain JavaScript may pass anything, so every field is checked as it is read. The error is given the role
|
|
8
|
+
* as it came: `RoleAssertionError` prints a role that is not a plain name as `?`.
|
|
9
|
+
*/
|
|
10
|
+
export function rolePlan(options) {
|
|
11
|
+
const { expectedRole, expectedGrants, allowedMemberships = [] } = (options ?? {});
|
|
12
|
+
const invalid = () => new RoleAssertionError('INVALID_EXPECTATION', expectedRole);
|
|
13
|
+
if (!isRoleName(expectedRole))
|
|
14
|
+
throw invalid();
|
|
15
|
+
if (!Array.isArray(expectedGrants) || !isNameList(allowedMemberships))
|
|
16
|
+
throw invalid();
|
|
17
|
+
const checks = [];
|
|
18
|
+
for (const grant of expectedGrants) {
|
|
19
|
+
const check = roleCheckOf(grant);
|
|
20
|
+
if (check === undefined)
|
|
21
|
+
throw invalid();
|
|
22
|
+
checks.push(check);
|
|
23
|
+
}
|
|
24
|
+
return { role: expectedRole, allowed: new Set(allowedMemberships), checks };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=rolePlan.mjs.map
|