@harperfast/harper 5.2.10 → 5.3.0-alpha.1
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/agent/mcpTools.ts +1 -1
- package/agent/session.ts +25 -14
- package/bin/cliOperations.ts +46 -9
- package/bin/copyDb.ts +282 -59
- package/bin/deploySetup.ts +16 -5
- package/bin/harper.ts +1 -1
- package/bin/help.ts +4 -1
- package/bin/lite.ts +4 -1
- package/bin/restart.ts +59 -3
- package/bin/run.ts +6 -11
- package/bin/upgrade.js +7 -3
- package/bin/workloadIdentity.ts +119 -0
- package/components/Application.ts +2414 -242
- package/components/ApplicationScope.ts +8 -0
- package/components/EntryHandler.ts +59 -39
- package/components/OptionsWatcher.ts +150 -74
- package/components/RuntimeModuleTracker.ts +38 -7
- package/components/Scope.ts +37 -15
- package/components/awaitRestart.ts +84 -0
- package/components/componentLoader.ts +340 -30
- package/components/componentPreparationLock.ts +16 -5
- package/components/mcp/adapters/harperHttp.ts +4 -0
- package/components/mcp/listChanged.ts +4 -0
- package/components/mcp/toolRegistry.ts +2 -0
- package/components/mcp/tools/operations.ts +9 -0
- package/components/mcp/tools/schemas/operationDescriptions.ts +2 -2
- package/components/operations.js +270 -78
- package/components/operationsValidation.js +49 -1
- package/components/status/ComponentStatusRegistry.ts +59 -0
- package/config/RootConfigWatcher.ts +80 -34
- package/config/configUtils.ts +291 -34
- package/config/harperConfigEnvVars.ts +170 -27
- package/config-root.schema.json +29 -0
- package/dataLayer/blobBackup.ts +160 -50
- package/dataLayer/delete.ts +6 -1
- package/dataLayer/harperBridge/ResourceBridge.ts +52 -8
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js +3 -1
- package/dataLayer/hdbInfoController.ts +34 -1
- package/dataLayer/insert.ts +44 -1
- package/dataLayer/rocksdbBackup.ts +53 -10
- package/dataLayer/schema.ts +11 -1
- package/dataLayer/schemaDescribe.ts +8 -1
- package/dist/agent/mcpTools.js +1 -1
- package/dist/agent/mcpTools.js.map +1 -1
- package/dist/agent/session.d.ts +22 -0
- package/dist/agent/session.js +26 -15
- package/dist/agent/session.js.map +1 -1
- package/dist/bin/cliOperations.js +48 -9
- package/dist/bin/cliOperations.js.map +1 -1
- package/dist/bin/copyDb.d.ts +12 -1
- package/dist/bin/copyDb.js +248 -60
- package/dist/bin/copyDb.js.map +1 -1
- package/dist/bin/deploySetup.d.ts +2 -0
- package/dist/bin/deploySetup.js +11 -3
- package/dist/bin/deploySetup.js.map +1 -1
- package/dist/bin/harper.js +1 -1
- package/dist/bin/harper.js.map +1 -1
- package/dist/bin/help.js +4 -1
- package/dist/bin/help.js.map +1 -1
- package/dist/bin/lite.js +4 -1
- package/dist/bin/lite.js.map +1 -1
- package/dist/bin/restart.js +54 -5
- package/dist/bin/restart.js.map +1 -1
- package/dist/bin/run.js +4 -10
- package/dist/bin/run.js.map +1 -1
- package/dist/bin/upgrade.js +4 -3
- package/dist/bin/upgrade.js.map +1 -1
- package/dist/bin/workloadIdentity.d.ts +18 -0
- package/dist/bin/workloadIdentity.js +100 -0
- package/dist/bin/workloadIdentity.js.map +1 -0
- package/dist/components/Application.d.ts +139 -16
- package/dist/components/Application.js +2215 -267
- package/dist/components/Application.js.map +1 -1
- package/dist/components/ApplicationScope.d.ts +8 -0
- package/dist/components/ApplicationScope.js +7 -0
- package/dist/components/ApplicationScope.js.map +1 -1
- package/dist/components/EntryHandler.js +26 -10
- package/dist/components/EntryHandler.js.map +1 -1
- package/dist/components/OptionsWatcher.d.ts +1 -0
- package/dist/components/OptionsWatcher.js +141 -74
- package/dist/components/OptionsWatcher.js.map +1 -1
- package/dist/components/RuntimeModuleTracker.js +40 -6
- package/dist/components/RuntimeModuleTracker.js.map +1 -1
- package/dist/components/Scope.js +38 -13
- package/dist/components/Scope.js.map +1 -1
- package/dist/components/awaitRestart.d.ts +33 -0
- package/dist/components/awaitRestart.js +61 -0
- package/dist/components/awaitRestart.js.map +1 -0
- package/dist/components/componentLoader.d.ts +38 -1
- package/dist/components/componentLoader.js +279 -22
- package/dist/components/componentLoader.js.map +1 -1
- package/dist/components/componentPreparationLock.d.ts +5 -0
- package/dist/components/componentPreparationLock.js +14 -6
- package/dist/components/componentPreparationLock.js.map +1 -1
- package/dist/components/mcp/adapters/harperHttp.js +4 -0
- package/dist/components/mcp/adapters/harperHttp.js.map +1 -1
- package/dist/components/mcp/listChanged.js +5 -0
- package/dist/components/mcp/listChanged.js.map +1 -1
- package/dist/components/mcp/toolRegistry.d.ts +1 -0
- package/dist/components/mcp/toolRegistry.js.map +1 -1
- package/dist/components/mcp/tools/operations.d.ts +5 -0
- package/dist/components/mcp/tools/operations.js +9 -0
- package/dist/components/mcp/tools/operations.js.map +1 -1
- package/dist/components/mcp/tools/schemas/operationDescriptions.js +2 -2
- package/dist/components/mcp/tools/schemas/operationDescriptions.js.map +1 -1
- package/dist/components/operations.js +231 -77
- package/dist/components/operations.js.map +1 -1
- package/dist/components/operationsValidation.js +49 -1
- package/dist/components/operationsValidation.js.map +1 -1
- package/dist/components/status/ComponentStatusRegistry.d.ts +0 -4
- package/dist/components/status/ComponentStatusRegistry.js +63 -0
- package/dist/components/status/ComponentStatusRegistry.js.map +1 -1
- package/dist/config/RootConfigWatcher.d.ts +7 -1
- package/dist/config/RootConfigWatcher.js +64 -27
- package/dist/config/RootConfigWatcher.js.map +1 -1
- package/dist/config/configUtils.d.ts +9 -1
- package/dist/config/configUtils.js +254 -33
- package/dist/config/configUtils.js.map +1 -1
- package/dist/config/harperConfigEnvVars.d.ts +16 -0
- package/dist/config/harperConfigEnvVars.js +162 -25
- package/dist/config/harperConfigEnvVars.js.map +1 -1
- package/dist/dataLayer/blobBackup.d.ts +49 -20
- package/dist/dataLayer/blobBackup.js +139 -50
- package/dist/dataLayer/blobBackup.js.map +1 -1
- package/dist/dataLayer/delete.js +1 -1
- package/dist/dataLayer/delete.js.map +1 -1
- package/dist/dataLayer/harperBridge/ResourceBridge.d.ts +14 -1
- package/dist/dataLayer/harperBridge/ResourceBridge.js +51 -10
- package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.d.ts +3 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js +3 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js.map +1 -1
- package/dist/dataLayer/hdbInfoController.d.ts +10 -0
- package/dist/dataLayer/hdbInfoController.js +30 -1
- package/dist/dataLayer/hdbInfoController.js.map +1 -1
- package/dist/dataLayer/insert.d.ts +9 -1
- package/dist/dataLayer/insert.js +30 -0
- package/dist/dataLayer/insert.js.map +1 -1
- package/dist/dataLayer/rocksdbBackup.d.ts +2 -2
- package/dist/dataLayer/rocksdbBackup.js +45 -8
- package/dist/dataLayer/rocksdbBackup.js.map +1 -1
- package/dist/dataLayer/schema.js +8 -0
- package/dist/dataLayer/schema.js.map +1 -1
- package/dist/dataLayer/schemaDescribe.js +8 -1
- package/dist/dataLayer/schemaDescribe.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/json/systemSchema.json +52 -0
- package/dist/resources/DatabaseTransaction.d.ts +55 -3
- package/dist/resources/DatabaseTransaction.js +460 -134
- package/dist/resources/DatabaseTransaction.js.map +1 -1
- package/dist/resources/LMDBTransaction.js +22 -4
- package/dist/resources/LMDBTransaction.js.map +1 -1
- package/dist/resources/PrimaryRocksDatabase.d.ts +1 -0
- package/dist/resources/PrimaryRocksDatabase.js +30 -2
- package/dist/resources/PrimaryRocksDatabase.js.map +1 -1
- package/dist/resources/RecordEncoder.d.ts +20 -0
- package/dist/resources/RecordEncoder.js +94 -9
- package/dist/resources/RecordEncoder.js.map +1 -1
- package/dist/resources/RequestTarget.d.ts +2 -0
- package/dist/resources/RequestTarget.js.map +1 -1
- package/dist/resources/Resource.js +20 -11
- package/dist/resources/Resource.js.map +1 -1
- package/dist/resources/ResourceInterface.d.ts +20 -1
- package/dist/resources/ResourceInterface.js.map +1 -1
- package/dist/resources/RocksIndexStore.d.ts +6 -1
- package/dist/resources/RocksIndexStore.js +24 -10
- package/dist/resources/RocksIndexStore.js.map +1 -1
- package/dist/resources/RocksTransactionLogStore.d.ts +14 -1
- package/dist/resources/RocksTransactionLogStore.js +57 -17
- package/dist/resources/RocksTransactionLogStore.js.map +1 -1
- package/dist/resources/Table.d.ts +112 -8
- package/dist/resources/Table.js +1071 -197
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/auditStore.d.ts +11 -2
- package/dist/resources/auditStore.js +183 -18
- package/dist/resources/auditStore.js.map +1 -1
- package/dist/resources/blob.d.ts +129 -9
- package/dist/resources/blob.js +992 -114
- package/dist/resources/blob.js.map +1 -1
- package/dist/resources/branchDatabase.d.ts +48 -0
- package/dist/resources/branchDatabase.js +892 -0
- package/dist/resources/branchDatabase.js.map +1 -0
- package/dist/resources/crdt.js +50 -12
- package/dist/resources/crdt.js.map +1 -1
- package/dist/resources/databases.d.ts +150 -9
- package/dist/resources/databases.js +1247 -525
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/defineTable.d.ts +10 -2
- package/dist/resources/defineTable.js +9 -1
- package/dist/resources/defineTable.js.map +1 -1
- package/dist/resources/graphql.d.ts +1 -1
- package/dist/resources/graphql.js +50 -15
- package/dist/resources/graphql.js.map +1 -1
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +1 -0
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +6 -2
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
- package/dist/resources/longLivedTransactions.d.ts +71 -0
- package/dist/resources/longLivedTransactions.js +358 -0
- package/dist/resources/longLivedTransactions.js.map +1 -0
- package/dist/resources/models/backendRegistry.d.ts +26 -0
- package/dist/resources/models/backendRegistry.js +60 -2
- package/dist/resources/models/backendRegistry.js.map +1 -1
- package/dist/resources/models/bootstrap.d.ts +33 -1
- package/dist/resources/models/bootstrap.js +416 -31
- package/dist/resources/models/bootstrap.js.map +1 -1
- package/dist/resources/recordLock.d.ts +80 -0
- package/dist/resources/recordLock.js +184 -0
- package/dist/resources/recordLock.js.map +1 -0
- package/dist/resources/replayLogs.d.ts +14 -1
- package/dist/resources/replayLogs.js +152 -24
- package/dist/resources/replayLogs.js.map +1 -1
- package/dist/resources/replayLogsGuards.d.ts +94 -7
- package/dist/resources/replayLogsGuards.js +111 -7
- package/dist/resources/replayLogsGuards.js.map +1 -1
- package/dist/resources/search.js +158 -32
- package/dist/resources/search.js.map +1 -1
- package/dist/resources/transactionBroadcast.d.ts +1 -1
- package/dist/resources/transactionBroadcast.js +2 -2
- package/dist/resources/transactionBroadcast.js.map +1 -1
- package/dist/security/auth.js +61 -30
- package/dist/security/auth.js.map +1 -1
- package/dist/security/authn/oidc/claims.d.ts +22 -0
- package/dist/security/authn/oidc/claims.js +71 -0
- package/dist/security/authn/oidc/claims.js.map +1 -0
- package/dist/security/authn/oidc/identityToken.d.ts +27 -0
- package/dist/security/authn/oidc/identityToken.js +111 -0
- package/dist/security/authn/oidc/identityToken.js.map +1 -0
- package/dist/security/authn/oidc/jwks.d.ts +25 -0
- package/dist/security/authn/oidc/jwks.js +261 -0
- package/dist/security/authn/oidc/jwks.js.map +1 -0
- package/dist/security/authn/oidc/providers/generic.d.ts +13 -0
- package/dist/security/authn/oidc/providers/generic.js +34 -0
- package/dist/security/authn/oidc/providers/generic.js.map +1 -0
- package/dist/security/authn/oidc/providers/githubActions.d.ts +11 -0
- package/dist/security/authn/oidc/providers/githubActions.js +129 -0
- package/dist/security/authn/oidc/providers/githubActions.js.map +1 -0
- package/dist/security/authn/oidc/providers/index.d.ts +37 -0
- package/dist/security/authn/oidc/providers/index.js +24 -0
- package/dist/security/authn/oidc/providers/index.js.map +1 -0
- package/dist/security/authn/oidc/tokenExchange.d.ts +12 -0
- package/dist/security/authn/oidc/tokenExchange.js +306 -0
- package/dist/security/authn/oidc/tokenExchange.js.map +1 -0
- package/dist/security/authn/oidc/trustPolicyOperations.d.ts +49 -0
- package/dist/security/authn/oidc/trustPolicyOperations.js +358 -0
- package/dist/security/authn/oidc/trustPolicyOperations.js.map +1 -0
- package/dist/security/authn/oidc/types.d.ts +38 -0
- package/dist/security/authn/oidc/types.js +6 -0
- package/dist/security/authn/oidc/types.js.map +1 -0
- package/dist/security/certificateVerification/index.js +40 -11
- package/dist/security/certificateVerification/index.js.map +1 -1
- package/dist/security/certificateVerification/trustedIssuers.d.ts +24 -0
- package/dist/security/certificateVerification/trustedIssuers.js +79 -0
- package/dist/security/certificateVerification/trustedIssuers.js.map +1 -0
- package/dist/security/certificateVerification/types.d.ts +1 -0
- package/dist/security/credentialProvenance.d.ts +35 -0
- package/dist/security/credentialProvenance.js +51 -0
- package/dist/security/credentialProvenance.js.map +1 -0
- package/dist/security/credentialRejection.d.ts +4 -0
- package/dist/security/credentialRejection.js +24 -0
- package/dist/security/credentialRejection.js.map +1 -0
- package/dist/security/deferredAuthentication.d.ts +36 -0
- package/dist/security/deferredAuthentication.js +70 -0
- package/dist/security/deferredAuthentication.js.map +1 -0
- package/dist/security/impersonation.d.ts +21 -0
- package/dist/security/impersonation.js +108 -9
- package/dist/security/impersonation.js.map +1 -1
- package/dist/security/jsLoader.d.ts +6 -0
- package/dist/security/jsLoader.js +75 -15
- package/dist/security/jsLoader.js.map +1 -1
- package/dist/security/keys.js +301 -71
- package/dist/security/keys.js.map +1 -1
- package/dist/security/operationScope.d.ts +21 -0
- package/dist/security/operationScope.js +36 -0
- package/dist/security/operationScope.js.map +1 -0
- package/dist/security/permissionsTranslator.js +21 -0
- package/dist/security/permissionsTranslator.js.map +1 -1
- package/dist/security/tokenAuthentication.d.ts +19 -1
- package/dist/security/tokenAuthentication.js +191 -10
- package/dist/security/tokenAuthentication.js.map +1 -1
- package/dist/security/user.js +4 -3
- package/dist/security/user.js.map +1 -1
- package/dist/server/DurableSubscriptionsSession.d.ts +2 -2
- package/dist/server/DurableSubscriptionsSession.js +67 -10
- package/dist/server/DurableSubscriptionsSession.js.map +1 -1
- package/dist/server/REST.js +73 -0
- package/dist/server/REST.js.map +1 -1
- package/dist/server/graphqlQuerying.js +4 -0
- package/dist/server/graphqlQuerying.js.map +1 -1
- package/dist/server/http.d.ts +11 -0
- package/dist/server/http.js +88 -15
- package/dist/server/http.js.map +1 -1
- package/dist/server/itc/serverHandlers.js +8 -1
- package/dist/server/itc/serverHandlers.js.map +1 -1
- package/dist/server/jobs/jobProcess.js +6 -2
- package/dist/server/jobs/jobProcess.js.map +1 -1
- package/dist/server/jobs/jobs.js +4 -1
- package/dist/server/jobs/jobs.js.map +1 -1
- package/dist/server/liveSubscriptionAuth.d.ts +26 -4
- package/dist/server/liveSubscriptionAuth.js +105 -39
- package/dist/server/liveSubscriptionAuth.js.map +1 -1
- package/dist/server/loadRootComponents.js +49 -10
- package/dist/server/loadRootComponents.js.map +1 -1
- package/dist/server/mqtt.d.ts +2 -0
- package/dist/server/mqtt.js +165 -30
- package/dist/server/mqtt.js.map +1 -1
- package/dist/server/nodeName.d.ts +2 -0
- package/dist/server/nodeName.js +107 -23
- package/dist/server/nodeName.js.map +1 -1
- package/dist/server/serverHelpers/Headers.d.ts +25 -0
- package/dist/server/serverHelpers/Headers.js +139 -1
- package/dist/server/serverHelpers/Headers.js.map +1 -1
- package/dist/server/serverHelpers/contentTypes.d.ts +9 -0
- package/dist/server/serverHelpers/contentTypes.js +32 -25
- package/dist/server/serverHelpers/contentTypes.js.map +1 -1
- package/dist/server/serverHelpers/deployValidationState.d.ts +3 -0
- package/dist/server/serverHelpers/deployValidationState.js +9 -19
- package/dist/server/serverHelpers/deployValidationState.js.map +1 -1
- package/dist/server/serverHelpers/operationAuthorizationState.d.ts +12 -0
- package/dist/server/serverHelpers/operationAuthorizationState.js +24 -2
- package/dist/server/serverHelpers/operationAuthorizationState.js.map +1 -1
- package/dist/server/serverHelpers/registeredOperations.d.ts +5 -4
- package/dist/server/serverHelpers/registeredOperations.js +74 -21
- package/dist/server/serverHelpers/registeredOperations.js.map +1 -1
- package/dist/server/serverHelpers/requestSanitization.d.ts +11 -0
- package/dist/server/serverHelpers/requestSanitization.js +20 -0
- package/dist/server/serverHelpers/requestSanitization.js.map +1 -0
- package/dist/server/serverHelpers/serverHandlers.js +6 -3
- package/dist/server/serverHelpers/serverHandlers.js.map +1 -1
- package/dist/server/serverHelpers/serverUtilities.d.ts +18 -0
- package/dist/server/serverHelpers/serverUtilities.js +90 -20
- package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/server/serverHelpers/sharedMessageEncoding.d.ts +67 -0
- package/dist/server/serverHelpers/sharedMessageEncoding.js +280 -0
- package/dist/server/serverHelpers/sharedMessageEncoding.js.map +1 -0
- package/dist/server/serverHelpers/uwsServer.js +19 -1
- package/dist/server/serverHelpers/uwsServer.js.map +1 -1
- package/dist/server/static.js +24 -28
- package/dist/server/static.js.map +1 -1
- package/dist/server/storageReclamation.d.ts +5 -0
- package/dist/server/storageReclamation.js +16 -0
- package/dist/server/storageReclamation.js.map +1 -1
- package/dist/server/threads/itc.d.ts +7 -2
- package/dist/server/threads/itc.js +5 -1
- package/dist/server/threads/itc.js.map +1 -1
- package/dist/server/threads/manageThreads.d.ts +26 -4
- package/dist/server/threads/manageThreads.js +517 -72
- package/dist/server/threads/manageThreads.js.map +1 -1
- package/dist/server/threads/socketRouter.js +89 -26
- package/dist/server/threads/socketRouter.js.map +1 -1
- package/dist/server/threads/threadHeapMemory.d.ts +2 -0
- package/dist/server/threads/threadHeapMemory.js +31 -0
- package/dist/server/threads/threadHeapMemory.js.map +1 -0
- package/dist/server/threads/threadServer.js +46 -15
- package/dist/server/threads/threadServer.js.map +1 -1
- package/dist/sqlEngine/config.d.ts +1 -3
- package/dist/sqlEngine/config.js +19 -16
- package/dist/sqlEngine/config.js.map +1 -1
- package/dist/sqlTranslator/index.d.ts +1 -1
- package/dist/sqlTranslator/index.js +30 -7
- package/dist/sqlTranslator/index.js.map +1 -1
- package/dist/upgrade/directives/5-3-0.d.ts +7 -0
- package/dist/upgrade/directives/5-3-0.js +148 -0
- package/dist/upgrade/directives/5-3-0.js.map +1 -0
- package/dist/upgrade/directives/directivesController.js +2 -1
- package/dist/upgrade/directives/directivesController.js.map +1 -1
- package/dist/utility/OperationFunctionCaller.js +2 -1
- package/dist/utility/OperationFunctionCaller.js.map +1 -1
- package/dist/utility/common_utils.d.ts +16 -0
- package/dist/utility/common_utils.js +32 -6
- package/dist/utility/common_utils.js.map +1 -1
- package/dist/utility/componentNames.d.ts +8 -0
- package/dist/utility/componentNames.js +12 -1
- package/dist/utility/componentNames.js.map +1 -1
- package/dist/utility/environment/environmentManager.js +3 -6
- package/dist/utility/environment/environmentManager.js.map +1 -1
- package/dist/utility/environment/systemInformation.d.ts +1 -0
- package/dist/utility/environment/systemInformation.js +1 -0
- package/dist/utility/environment/systemInformation.js.map +1 -1
- package/dist/utility/errors/commonErrors.d.ts +2 -0
- package/dist/utility/errors/commonErrors.js +2 -0
- package/dist/utility/errors/commonErrors.js.map +1 -1
- package/dist/utility/errors/hdbError.d.ts +17 -0
- package/dist/utility/errors/hdbError.js +30 -1
- package/dist/utility/errors/hdbError.js.map +1 -1
- package/dist/utility/globalSchema.d.ts +18 -0
- package/dist/utility/hdbTerms.d.ts +16 -0
- package/dist/utility/hdbTerms.js +18 -2
- package/dist/utility/hdbTerms.js.map +1 -1
- package/dist/utility/logging/harper_logger.d.ts +2 -0
- package/dist/utility/logging/harper_logger.js +91 -14
- package/dist/utility/logging/harper_logger.js.map +1 -1
- package/dist/utility/logging/logRotator.js +76 -49
- package/dist/utility/logging/logRotator.js.map +1 -1
- package/dist/utility/nodeIdentity.d.ts +9 -0
- package/dist/utility/nodeIdentity.js +58 -0
- package/dist/utility/nodeIdentity.js.map +1 -0
- package/dist/utility/npmUtilities.js +9 -7
- package/dist/utility/npmUtilities.js.map +1 -1
- package/dist/utility/operationPermissions.d.ts +3 -1
- package/dist/utility/operationPermissions.js +16 -1
- package/dist/utility/operationPermissions.js.map +1 -1
- package/dist/utility/operation_authorization.d.ts +10 -7
- package/dist/utility/operation_authorization.js +212 -41
- package/dist/utility/operation_authorization.js.map +1 -1
- package/dist/utility/watchPath.d.ts +29 -0
- package/dist/utility/watchPath.js +68 -0
- package/dist/utility/watchPath.js.map +1 -0
- package/dist/utility/watcherFallback.d.ts +86 -0
- package/dist/utility/watcherFallback.js +278 -1
- package/dist/utility/watcherFallback.js.map +1 -1
- package/dist/validation/configValidator.d.ts +12 -0
- package/dist/validation/configValidator.js +199 -72
- package/dist/validation/configValidator.js.map +1 -1
- package/dist/validation/installValidator.js +12 -0
- package/dist/validation/installValidator.js.map +1 -1
- package/dist/validation/validationWrapper.d.ts +11 -0
- package/dist/validation/validationWrapper.js +16 -3
- package/dist/validation/validationWrapper.js.map +1 -1
- package/index.ts +2 -0
- package/json/systemSchema.json +52 -0
- package/npm-shrinkwrap.json +235 -233
- package/package.json +8 -7
- package/resources/DESIGN.md +114 -52
- package/resources/DatabaseTransaction.ts +522 -130
- package/resources/LMDBTransaction.ts +26 -4
- package/resources/PrimaryRocksDatabase.ts +29 -3
- package/resources/RecordEncoder.ts +103 -8
- package/resources/RequestTarget.ts +2 -0
- package/resources/Resource.ts +17 -9
- package/resources/ResourceInterface.ts +23 -0
- package/resources/RocksIndexStore.ts +30 -10
- package/resources/RocksTransactionLogStore.ts +78 -21
- package/resources/Table.ts +1107 -164
- package/resources/auditStore.ts +187 -21
- package/resources/blob.ts +1029 -110
- package/resources/branchDatabase.ts +941 -0
- package/resources/crdt.ts +76 -12
- package/resources/databases.ts +1354 -522
- package/resources/defineTable.ts +18 -2
- package/resources/graphql.ts +70 -16
- package/resources/indexes/HierarchicalNavigableSmallWorld.ts +6 -2
- package/resources/longLivedTransactions.ts +360 -0
- package/resources/models/backendRegistry.ts +84 -2
- package/resources/models/bootstrap.ts +473 -28
- package/resources/recordLock.ts +253 -0
- package/resources/replayLogs.ts +147 -26
- package/resources/replayLogsGuards.ts +171 -8
- package/resources/search.ts +154 -32
- package/resources/transactionBroadcast.ts +3 -3
- package/security/auth.ts +68 -29
- package/security/authn/oidc/claims.ts +72 -0
- package/security/authn/oidc/identityToken.ts +129 -0
- package/security/authn/oidc/jwks.ts +260 -0
- package/security/authn/oidc/providers/generic.ts +40 -0
- package/security/authn/oidc/providers/githubActions.ts +137 -0
- package/security/authn/oidc/providers/index.ts +52 -0
- package/security/authn/oidc/tokenExchange.ts +300 -0
- package/security/authn/oidc/trustPolicyOperations.ts +343 -0
- package/security/authn/oidc/types.ts +41 -0
- package/security/certificateVerification/index.ts +54 -13
- package/security/certificateVerification/trustedIssuers.ts +76 -0
- package/security/certificateVerification/types.ts +1 -0
- package/security/credentialProvenance.ts +47 -0
- package/security/credentialRejection.ts +22 -0
- package/security/deferredAuthentication.ts +71 -0
- package/security/impersonation.ts +117 -12
- package/security/jsLoader.ts +81 -18
- package/security/keys.ts +298 -72
- package/security/operationScope.ts +33 -0
- package/security/permissionsTranslator.js +23 -0
- package/security/tokenAuthentication.ts +233 -12
- package/security/user.ts +4 -3
- package/server/DESIGN.md +183 -16
- package/server/DurableSubscriptionsSession.ts +71 -11
- package/server/REST.ts +79 -1
- package/server/graphqlQuerying.ts +4 -0
- package/server/http.ts +99 -18
- package/server/itc/serverHandlers.js +8 -1
- package/server/jobs/jobProcess.ts +8 -2
- package/server/jobs/jobs.ts +4 -1
- package/server/liveSubscriptionAuth.ts +129 -46
- package/server/loadRootComponents.js +50 -8
- package/server/mqtt.ts +179 -38
- package/server/nodeName.ts +103 -21
- package/server/serverHelpers/Headers.ts +131 -0
- package/server/serverHelpers/contentTypes.ts +29 -21
- package/server/serverHelpers/deployValidationState.ts +24 -13
- package/server/serverHelpers/operationAuthorizationState.ts +34 -3
- package/server/serverHelpers/registeredOperations.ts +79 -22
- package/server/serverHelpers/requestSanitization.ts +15 -0
- package/server/serverHelpers/serverHandlers.js +6 -3
- package/server/serverHelpers/serverUtilities.ts +104 -31
- package/server/serverHelpers/sharedMessageEncoding.ts +307 -0
- package/server/serverHelpers/uwsServer.ts +17 -2
- package/server/static.ts +23 -29
- package/server/storageReclamation.ts +13 -0
- package/server/threads/itc.js +11 -1
- package/server/threads/manageThreads.js +526 -63
- package/server/threads/socketRouter.ts +81 -26
- package/server/threads/threadHeapMemory.ts +26 -0
- package/server/threads/threadServer.js +43 -15
- package/sqlTranslator/index.ts +31 -8
- package/studio/web/assets/{Chat-Br06zdMA.js → Chat-BnCBegQz.js} +1 -1
- package/studio/web/assets/{FloatingChat-BWImX5fA.js → FloatingChat-CoDW1ySS.js} +3 -3
- package/studio/web/assets/{apiToken-DN0nmDsq.js → apiToken-Bwk5BLXW.js} +1 -1
- package/studio/web/assets/{applications-kSxVoyeU.js → applications-DHxGi7JH.js} +1 -1
- package/studio/web/assets/{cssMode-C1JeufH5.js → cssMode-s0cWI-_M.js} +1 -1
- package/studio/web/assets/{editor-qoo9CrGO.js → editor-DNcRHK54.js} +1 -1
- package/studio/web/assets/{html-Dt4IIy04.js → html-Bdssedlg.js} +1 -1
- package/studio/web/assets/{htmlMode-DXgKKr4C.js → htmlMode-CoDlJ3fw.js} +1 -1
- package/studio/web/assets/{index-6onkYFOG.js → index-D6sxmFLR.js} +5 -5
- package/studio/web/assets/{index.lazy-BrCFnpNJ.js → index.lazy-tmU5BS8s.js} +1 -1
- package/studio/web/assets/{javascript-DNCQGUBc.js → javascript-B8meVSTH.js} +1 -1
- package/studio/web/assets/{jsonMode-CR6HWruP.js → jsonMode-DpIPd35T.js} +1 -1
- package/studio/web/assets/{languageServices-BM4fI4rS.js → languageServices-C_5FMJzQ.js} +1 -1
- package/studio/web/assets/{lspLanguageFeatures-DSa1ttcD.js → lspLanguageFeatures-BIzNBzPK.js} +1 -1
- package/studio/web/assets/{notifications-BHXLnh6x.js → notifications-CQf18QKb.js} +1 -1
- package/studio/web/assets/{notifications-CUmtIA6z.js → notifications-CvZivSbh.js} +1 -1
- package/studio/web/assets/{profile-8BeFSF3j.js → profile-DdOwtntb.js} +1 -1
- package/studio/web/assets/{regions-C8qR0HhD.js → regions-n69fwagr.js} +1 -1
- package/studio/web/assets/{register-B4n5i0SD.js → register-PfWTCXWB.js} +2 -2
- package/studio/web/assets/{setComponentFile-g0_B0lgX.js → setComponentFile-Bg6O7X0S.js} +1 -1
- package/studio/web/assets/{setup-B0CTj_Q5.js → setup-CUx_aUDl.js} +2 -2
- package/studio/web/assets/{status-C6Yib7-K.js → status-D7BVKqX9.js} +1 -1
- package/studio/web/assets/{toggleHighContrast-Dgta7bVi.js → toggleHighContrast-DBSyXzMr.js} +1 -1
- package/studio/web/assets/{tsMode-CH_jHvU-.js → tsMode-BByKCjBS.js} +1 -1
- package/studio/web/assets/{typescript-Co9LCXd5.js → typescript-DDLnLpw9.js} +1 -1
- package/studio/web/assets/{useEntityRestURL-wKC8NsC_.js → useEntityRestURL-31CHGaHk.js} +1 -1
- package/studio/web/assets/{workers-CWeLxCXA.js → workers-pR3jRY9D.js} +1 -1
- package/studio/web/assets/{xml-BadC-0Rk.js → xml-2iRnMhQO.js} +1 -1
- package/studio/web/assets/{yaml-BiUfxPbC.js → yaml-Bf92gJpd.js} +1 -1
- package/studio/web/index.html +1 -1
- package/upgrade/directives/5-3-0.ts +132 -0
- package/upgrade/directives/directivesController.ts +2 -1
- package/utility/OperationFunctionCaller.ts +2 -1
- package/utility/common_utils.ts +30 -5
- package/utility/componentNames.ts +12 -0
- package/utility/environment/environmentManager.ts +3 -7
- package/utility/environment/systemInformation.ts +7 -0
- package/utility/errors/commonErrors.ts +4 -0
- package/utility/errors/hdbError.ts +29 -0
- package/utility/hdbTerms.ts +17 -0
- package/utility/logging/harper_logger.ts +87 -14
- package/utility/logging/logRotator.ts +72 -45
- package/utility/nodeIdentity.ts +45 -0
- package/utility/npmUtilities.ts +10 -8
- package/utility/operationPermissions.ts +18 -1
- package/utility/operation_authorization.ts +231 -42
- package/utility/watchPath.ts +63 -0
- package/utility/watcherFallback.ts +270 -0
- package/validation/configValidator.ts +209 -72
- package/validation/installValidator.ts +15 -0
- package/validation/validationWrapper.ts +18 -4
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Actions provider profile (#2171).
|
|
3
|
+
*
|
|
4
|
+
* The only module that should know anything about GitHub. Its rules are deliberately stricter than
|
|
5
|
+
* npm's trusted-publishing model, and scoping them here means that strictness never constrains
|
|
6
|
+
* another issuer.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ClientError } from '../../../../utility/errors/hdbError.ts';
|
|
10
|
+
import type { ClaimConstraint, TokenClaims } from '../types.ts';
|
|
11
|
+
import type { IdentityProviderProfile } from './index.ts';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Workflow references are `<owner>/<repo>/<path>@<ref>` and the ref is always a full `refs/...` name.
|
|
15
|
+
* Splitting on `@refs/` rather than the first or last `@` is exact, because a path segment cannot
|
|
16
|
+
* contain `/` — so this cannot occur inside the path, and a branch named `release@2` cannot fool it.
|
|
17
|
+
*/
|
|
18
|
+
const REF_QUALIFIER = '@refs/';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* GitHub's default audience is the repository owner's URL, shared by every repository under that
|
|
22
|
+
* owner, so accepting it would make a token minted by any repo in the org valid here — the one
|
|
23
|
+
* mistake the audience field exists to prevent.
|
|
24
|
+
*/
|
|
25
|
+
const SHARED_DEFAULT_AUDIENCE = /^https:\/\/github\.com\/[^/]+\/?$/i;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Structural requirements on a policy's claim set, each guarding a distinct way a policy can be
|
|
29
|
+
* accidentally broad. Satisfying none of a row's claims admits, in order: any repository, any
|
|
30
|
+
* workflow in that repository, any branch that can be pushed to it.
|
|
31
|
+
*
|
|
32
|
+
* `repository_owner` is absent from the first row on purpose — it identifies an org, not a
|
|
33
|
+
* repository, so it would admit every repo in the org. `ref_type` is absent from the third for the
|
|
34
|
+
* same shape of reason: `ref_type: tag` still admits any tag, and anyone with push access can create
|
|
35
|
+
* one. A tag-triggered release pins `environment` and leans on GitHub's environment protection.
|
|
36
|
+
*
|
|
37
|
+
* `job_workflow_ref` pins the workflow (second row) but deliberately does NOT gate the ref (third).
|
|
38
|
+
* For a reusable workflow it names the workflow that RAN, not the caller that invoked it — the
|
|
39
|
+
* caller's ref lives in `workflow_ref`/`ref`. Its `@ref` suffix therefore describes the reusable
|
|
40
|
+
* workflow's own branch, which is constant however it is called, so accepting it as a ref gate would
|
|
41
|
+
* admit any branch of any caller repository that references that reusable workflow: precisely the
|
|
42
|
+
* hole the third row exists to close.
|
|
43
|
+
*
|
|
44
|
+
* `sub` is deliberately not accepted as a pin: it varies by trigger, and its format changed for
|
|
45
|
+
* repositories created after 2026-07-15 (immutable subjects embed owner and repo ids).
|
|
46
|
+
*/
|
|
47
|
+
const STRUCTURAL_REQUIREMENTS = [
|
|
48
|
+
{
|
|
49
|
+
requirement: 'pin the repository',
|
|
50
|
+
claims: ['repository_id', 'repository'],
|
|
51
|
+
because: ' (repository_id is immutable and survives renames)',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
requirement: 'pin the workflow',
|
|
55
|
+
claims: ['workflow_ref', 'workflow_path', 'job_workflow_ref', 'job_workflow_path'],
|
|
56
|
+
because: '',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
requirement: 'gate the ref',
|
|
60
|
+
claims: ['workflow_ref', 'ref', 'environment'],
|
|
61
|
+
because: ' — otherwise any branch that can be pushed to the repository can run the workflow and mint a token',
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
/** Returns undefined rather than guessing when the value is not a ref-qualified reference. */
|
|
66
|
+
export function splitWorkflowPath(workflowRef: unknown): string | undefined {
|
|
67
|
+
if (typeof workflowRef !== 'string') return undefined;
|
|
68
|
+
const qualifierIndex = workflowRef.indexOf(REF_QUALIFIER);
|
|
69
|
+
return qualifierIndex === -1 ? undefined : workflowRef.slice(0, qualifierIndex);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const githubActionsProfile: IdentityProviderProfile = {
|
|
73
|
+
name: 'GitHub Actions',
|
|
74
|
+
|
|
75
|
+
assertPolicyIsSpecific(policyClaims: Record<string, ClaimConstraint>): void {
|
|
76
|
+
const constrained = new Set(Object.keys(policyClaims));
|
|
77
|
+
for (const { requirement, claims, because } of STRUCTURAL_REQUIREMENTS) {
|
|
78
|
+
if (!claims.some((claimName) => constrained.has(claimName))) {
|
|
79
|
+
throw new ClientError(`claims must ${requirement} with one of: ${claims.join(', ')}${because}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
assertAudienceIsSpecific(audience: string): void {
|
|
85
|
+
if (SHARED_DEFAULT_AUDIENCE.test(audience)) {
|
|
86
|
+
throw new ClientError(
|
|
87
|
+
`'audience' must identify this instance, not '${audience}' — GitHub's default audience is shared ` +
|
|
88
|
+
`by every repository under an owner, so a token minted for any of them would be accepted here. ` +
|
|
89
|
+
`Use the instance URL the CI client targets.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Adds `workflow_path` / `job_workflow_path` — the workflow reference with the ref removed — so a
|
|
96
|
+
* policy can pin the workflow *file* while gating the ref some other way. A tag-triggered release
|
|
97
|
+
* cannot pin `workflow_ref`, because the tag is unknown when the policy is written.
|
|
98
|
+
*
|
|
99
|
+
* A claim the token actually carries is never displaced by one we synthesized.
|
|
100
|
+
*/
|
|
101
|
+
normalizeClaims(payload: TokenClaims): TokenClaims {
|
|
102
|
+
const claims: TokenClaims = { ...payload };
|
|
103
|
+
for (const [source, derived] of [
|
|
104
|
+
['workflow_ref', 'workflow_path'],
|
|
105
|
+
['job_workflow_ref', 'job_workflow_path'],
|
|
106
|
+
]) {
|
|
107
|
+
const path = splitWorkflowPath(payload[source]);
|
|
108
|
+
if (path !== undefined && claims[derived] === undefined) claims[derived] = path;
|
|
109
|
+
}
|
|
110
|
+
return claims;
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A `pull_request_target` run executes the base repository's workflow with its secrets while a
|
|
115
|
+
* fork controls the checked-out code. A plain `pull_request` run from a fork gets no
|
|
116
|
+
* `id-token: write` and so cannot mint at all, but `pull_request_target` can — so it is denied
|
|
117
|
+
* unless a policy constrains `event_name`, which is the explicit opt-in.
|
|
118
|
+
*/
|
|
119
|
+
vetoClaims(claims: TokenClaims, policyClaims: Record<string, ClaimConstraint>): string | undefined {
|
|
120
|
+
if (claims.event_name === 'pull_request_target' && policyClaims.event_name === undefined) {
|
|
121
|
+
return 'pull_request_target is denied unless the policy constrains event_name';
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
describePrincipal(claims: TokenClaims): string {
|
|
127
|
+
return [
|
|
128
|
+
claims.repository,
|
|
129
|
+
claims.workflow_ref ?? claims.workflow_path,
|
|
130
|
+
claims.environment && `environment=${claims.environment}`,
|
|
131
|
+
claims.run_id && `run=${claims.run_id}`,
|
|
132
|
+
claims.actor && `actor=${claims.actor}`,
|
|
133
|
+
]
|
|
134
|
+
.filter(Boolean)
|
|
135
|
+
.join(' ');
|
|
136
|
+
},
|
|
137
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider profiles for OIDC trusted publishing (#2171).
|
|
3
|
+
*
|
|
4
|
+
* Everything issuer-specific lives behind this interface, resolved by normalized issuer, so the core
|
|
5
|
+
* stays generic: a new workload-identity issuer is a profile, not a change to verification, matching,
|
|
6
|
+
* or storage. Issuers with no registered profile fall back to `generic`, which is strict rather than
|
|
7
|
+
* permissive — see its `assertPolicyIsSpecific`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ClaimConstraint, TokenClaims } from '../types.ts';
|
|
11
|
+
import { genericProfile } from './generic.ts';
|
|
12
|
+
import { githubActionsProfile } from './githubActions.ts';
|
|
13
|
+
|
|
14
|
+
export interface IdentityProviderProfile {
|
|
15
|
+
/** Shown in policy-validation errors and the audit trail. */
|
|
16
|
+
name: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Rejects a claim set too broad to be a safe policy for this issuer. Called at write time, when
|
|
20
|
+
* the reader is an administrator who can act on the message.
|
|
21
|
+
*/
|
|
22
|
+
assertPolicyIsSpecific(policyClaims: Record<string, ClaimConstraint>): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Rejects an audience the issuer shares across principals — the mistake that makes an audience
|
|
26
|
+
* check meaningless. A no-op for issuers with no such default.
|
|
27
|
+
*/
|
|
28
|
+
assertAudienceIsSpecific(audience: string): void;
|
|
29
|
+
|
|
30
|
+
/** Adds issuer-specific derived claims. Must never displace a claim the token actually carries. */
|
|
31
|
+
normalizeClaims(payload: TokenClaims): TokenClaims;
|
|
32
|
+
|
|
33
|
+
/** One-line principal description for the audit trail. */
|
|
34
|
+
describePrincipal(claims: TokenClaims): string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A match-time veto applied after the policy's own constraints pass, for runs this issuer should
|
|
38
|
+
* refuse unless a policy opts in explicitly. Returns a reason to deny, or undefined to allow.
|
|
39
|
+
*/
|
|
40
|
+
vetoClaims?(claims: TokenClaims, policyClaims: Record<string, ClaimConstraint>): string | undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const PROFILES_BY_ISSUER = new Map<string, IdentityProviderProfile>([
|
|
44
|
+
['https://token.actions.githubusercontent.com', githubActionsProfile],
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
/** Never returns undefined: an unregistered issuer gets the strict generic profile. */
|
|
48
|
+
export function profileForIssuer(issuer: string): IdentityProviderProfile {
|
|
49
|
+
return PROFILES_BY_ISSUER.get(issuer) ?? genericProfile;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { genericProfile, githubActionsProfile };
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// exchange_oidc_token — the unauthenticated half of OIDC trusted publishing (#2171).
|
|
4
|
+
//
|
|
5
|
+
// A CI runner presents an identity token minted by its provider. If it verifies against a stored
|
|
6
|
+
// trust policy, Harper mints a short-lived operation token for the user that policy names. This is
|
|
7
|
+
// the only unauthenticated operation that yields a credential, so it fails closed throughout and
|
|
8
|
+
// refuses through rejectToken, which tells the caller nothing beyond "no".
|
|
9
|
+
|
|
10
|
+
import jwt from 'jsonwebtoken';
|
|
11
|
+
import Joi from 'joi';
|
|
12
|
+
import { createHash } from 'node:crypto';
|
|
13
|
+
import { table, type Table } from '../../../resources/databases.ts';
|
|
14
|
+
import { ClientError } from '../../../utility/errors/hdbError.ts';
|
|
15
|
+
import { validateBySchema } from '../../../validation/validationWrapper.ts';
|
|
16
|
+
import { loggerWithTag } from '../../../utility/logging/logger.ts';
|
|
17
|
+
import harperLogger from '../../../utility/logging/harper_logger.ts';
|
|
18
|
+
import * as env from '../../../utility/environment/environmentManager.ts';
|
|
19
|
+
import { AUTH_AUDIT_STATUS, AUTH_AUDIT_TYPES, CONFIG_PARAMS } from '../../../utility/hdbTerms.ts';
|
|
20
|
+
import { getUsersWithRolesCache } from '../../user.ts';
|
|
21
|
+
import { createOperationToken } from '../../tokenAuthentication.ts';
|
|
22
|
+
import { rejectToken, verifyIdentityToken } from './identityToken.ts';
|
|
23
|
+
import { matchTrustPolicyClaims } from './claims.ts';
|
|
24
|
+
import { normalizeIssuer } from './jwks.ts';
|
|
25
|
+
import { profileForIssuer, type IdentityProviderProfile } from './providers/index.ts';
|
|
26
|
+
import { loadEnabledPolicies } from './trustPolicyOperations.ts';
|
|
27
|
+
import type { OidcTrustPolicy, TokenClaims } from './types.ts';
|
|
28
|
+
|
|
29
|
+
const logger = loggerWithTag('oidc-trust');
|
|
30
|
+
const { AuthAuditLog } = harperLogger;
|
|
31
|
+
// Same stream and same switches as every other authentication event (security/auth.ts), so an
|
|
32
|
+
// operator who turns on auth auditing sees OIDC exchanges alongside Basic, Bearer, and mTLS.
|
|
33
|
+
const authEventLog = harperLogger.forComponent('authentication').withTag('auth-event');
|
|
34
|
+
|
|
35
|
+
/** Long enough to cover a slow deploy, short enough to be worthless by the time it reaches a log. */
|
|
36
|
+
const EXCHANGED_TOKEN_LIFETIME_SECONDS = 3600;
|
|
37
|
+
|
|
38
|
+
/** Keeps the replay record alive past the token's expiry by more than the verifier's clock leeway. */
|
|
39
|
+
const REPLAY_RECORD_PADDING_MS = 120_000;
|
|
40
|
+
|
|
41
|
+
/** Real identity tokens are ~1-2 KB; this bounds what we are willing to even parse. */
|
|
42
|
+
const MAX_TOKEN_LENGTH = 8192;
|
|
43
|
+
|
|
44
|
+
const TOKEN_USE_TABLE = 'hdb_oidc_token_use';
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Spent identity tokens, keyed by the fingerprint below and expiring with the token, so the table
|
|
48
|
+
* stays proportional to in-flight tokens rather than to deploy history and never holds a credential.
|
|
49
|
+
*
|
|
50
|
+
* Replicated like other system tables, which extends the check across the cluster — but replication
|
|
51
|
+
* is asynchronous, so two simultaneous replays against different nodes can both land. That race is
|
|
52
|
+
* not a privilege escalation: whoever holds the token could obtain one operation token regardless.
|
|
53
|
+
* What it stops is the realistic case, a token that leaks after a legitimate run and is reused
|
|
54
|
+
* inside its window.
|
|
55
|
+
*
|
|
56
|
+
* table() also registers into `databases.system`, so the lookup finds it after the first call.
|
|
57
|
+
*/
|
|
58
|
+
let tokenUseTable: any;
|
|
59
|
+
|
|
60
|
+
/** Drops the memo below so a test can install a different table. Not used in production. */
|
|
61
|
+
export function clearTokenUseTableCache(): void {
|
|
62
|
+
tokenUseTable = undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getTokenUseTable(): any {
|
|
66
|
+
// Memoized per process, but `table()` is NOT skipped merely because the table already exists.
|
|
67
|
+
// The systemSchema stub and the 5.3.0 directive declare only the primary key — the `expiresAt`
|
|
68
|
+
// TTL is not expressible through CreateTableObject — so this call is what actually installs the
|
|
69
|
+
// TTL, layered on top of the bootstrap. Short-circuiting on existence would mean a table that
|
|
70
|
+
// arrived any other way (bootstrap, replication, restore, a manual create_table) never gets it,
|
|
71
|
+
// and replay records would then accumulate in a system table forever. hdb_certificate_cache
|
|
72
|
+
// does the same two-step for the same reason.
|
|
73
|
+
tokenUseTable ??= table<Table>({
|
|
74
|
+
table: TOKEN_USE_TABLE,
|
|
75
|
+
database: 'system',
|
|
76
|
+
// `audit: true` explicitly, NOT the default (which follows logging.auditLog). Auditing is the
|
|
77
|
+
// replication change feed (databases.ts: "auditing must be enabled for replication"), and
|
|
78
|
+
// replay records MUST replicate so a token spent on one node cannot be re-spent on another
|
|
79
|
+
// inside its window. Without this, an operator with logging.auditLog:false would silently lose
|
|
80
|
+
// cross-node replay protection. Its sibling hdb_oidc_trust is audited for the same reason.
|
|
81
|
+
audit: true,
|
|
82
|
+
attributes: [
|
|
83
|
+
{ name: 'id', isPrimaryKey: true },
|
|
84
|
+
{ name: 'policy_id' },
|
|
85
|
+
{ name: 'used_at' },
|
|
86
|
+
{ name: 'expiresAt', expiresAt: true, indexed: true },
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
return tokenUseTable;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Records the exchange in the authentication audit stream. Emitted for failures as well as successes:
|
|
94
|
+
* a run repeatedly failing to authenticate is exactly what an audit trail is for.
|
|
95
|
+
*/
|
|
96
|
+
function auditExchange(req: any, username: string | undefined, status: string, detail: Record<string, unknown>) {
|
|
97
|
+
const logSuccessful = env.get(CONFIG_PARAMS.LOGGING_AUDITAUTHEVENTS_LOGSUCCESSFUL) ?? false;
|
|
98
|
+
const logFailed = env.get(CONFIG_PARAMS.LOGGING_AUDITAUTHEVENTS_LOGFAILED) ?? false;
|
|
99
|
+
if (status === AUTH_AUDIT_STATUS.SUCCESS ? !logSuccessful : !logFailed) return;
|
|
100
|
+
|
|
101
|
+
// serverHandlers injects baseRequest for NO_AUTH_OPERATIONS, so the transport details are here;
|
|
102
|
+
// they stay optional because an in-process caller (server.operation) has none.
|
|
103
|
+
const baseRequest = req?.baseRequest;
|
|
104
|
+
const log: any = new (AuthAuditLog as any)(
|
|
105
|
+
username,
|
|
106
|
+
status,
|
|
107
|
+
AUTH_AUDIT_TYPES.AUTHENTICATION,
|
|
108
|
+
// Same precedence as every other auth event (security/auth.ts): behind a load balancer —
|
|
109
|
+
// which is every Fabric and cloud deployment — `ip` is the proxy, so an audit trail for the
|
|
110
|
+
// one unauthenticated credential-minting operation would record the proxy, not the runner.
|
|
111
|
+
baseRequest?.headers?.['x-forwarded-for'] ?? baseRequest?.ip,
|
|
112
|
+
baseRequest?.method,
|
|
113
|
+
baseRequest?.pathname
|
|
114
|
+
);
|
|
115
|
+
log.auth_strategy = 'oidc';
|
|
116
|
+
Object.assign(log, detail);
|
|
117
|
+
if (status === AUTH_AUDIT_STATUS.SUCCESS) authEventLog.info?.(log);
|
|
118
|
+
else authEventLog.error?.(log);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Auditing must never change the outcome it is recording. The success emit sits inside the
|
|
123
|
+
* exchange's try, so a throw there would be caught and re-reported as a FAILURE for a request that
|
|
124
|
+
* actually succeeded; on the failure path a throw would replace the original error with the audit's.
|
|
125
|
+
* Swallowing here fixes both, and keeps the two call sites free of defensive wrapping.
|
|
126
|
+
*/
|
|
127
|
+
function auditExchangeSafely(req: any, username: string | undefined, status: string, detail: Record<string, unknown>) {
|
|
128
|
+
try {
|
|
129
|
+
auditExchange(req, username, status, detail);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
logger.warn?.(`Failed to emit OIDC exchange audit record: ${(error as Error).message}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Verifies each distinct audience at most once, so N policies sharing one cost one verification. */
|
|
136
|
+
async function findMatchingPolicy(
|
|
137
|
+
token: string,
|
|
138
|
+
issuer: string,
|
|
139
|
+
policies: OidcTrustPolicy[],
|
|
140
|
+
profile: IdentityProviderProfile
|
|
141
|
+
): Promise<{ policy: OidcTrustPolicy; claims: TokenClaims } | undefined> {
|
|
142
|
+
const claimsByAudience = new Map<string, TokenClaims | undefined>();
|
|
143
|
+
|
|
144
|
+
for (const policy of policies) {
|
|
145
|
+
// Re-validate specificity at exchange time. add_oidc_trust enforces these, but a stored row can
|
|
146
|
+
// arrive another way — replication from an older node that predates a check, or a restored/older
|
|
147
|
+
// system-DB backup — and the exchange must not trust that every row was validated when written.
|
|
148
|
+
// Skip (don't honor) any row that would be rejected for writing, so an under-specified policy
|
|
149
|
+
// (e.g. a repository pinned but no workflow/ref gate) can't mint a token. Fail closed.
|
|
150
|
+
try {
|
|
151
|
+
profile.assertAudienceIsSpecific(policy.audience);
|
|
152
|
+
profile.assertPolicyIsSpecific(policy.claims);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
logger.warn?.(`Ignoring trust policy '${policy.id}': ${(error as Error).message}`);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!claimsByAudience.has(policy.audience)) {
|
|
159
|
+
// verifyIdentityToken logs its own reason via rejectToken, but everything jwks.ts throws
|
|
160
|
+
// (unknown kid, unreachable host, non-2xx, oversized body, bad JSON, no usable keys) is
|
|
161
|
+
// thrown directly and would otherwise vanish here — the request then falls through to
|
|
162
|
+
// "no trust policy matched", which is actively misleading when a policy DID match and the
|
|
163
|
+
// failure was operational. Log every swallowed reason so an issuer outage is
|
|
164
|
+
// distinguishable from a misconfigured policy in the log.
|
|
165
|
+
const verified = await verifyIdentityToken(token, { issuer, audience: policy.audience }).catch((error) => {
|
|
166
|
+
logger.warn?.(
|
|
167
|
+
`Verification failed for policy '${policy.id}' (audience '${policy.audience}'): ${(error as Error).message}`
|
|
168
|
+
);
|
|
169
|
+
return undefined;
|
|
170
|
+
});
|
|
171
|
+
claimsByAudience.set(policy.audience, verified);
|
|
172
|
+
}
|
|
173
|
+
const claims = claimsByAudience.get(policy.audience);
|
|
174
|
+
if (!claims) continue;
|
|
175
|
+
|
|
176
|
+
const mismatch = matchTrustPolicyClaims(claims, policy.claims) ?? profile.vetoClaims?.(claims, policy.claims);
|
|
177
|
+
if (!mismatch) return { policy, claims };
|
|
178
|
+
logger.debug?.(`Trust policy '${policy.id}' did not match: ${mismatch}`);
|
|
179
|
+
}
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Identifies a token for replay purposes: a hash of its SIGNED INPUT (`header.payload`), not of the
|
|
185
|
+
* whole token string. Keyed this way rather than on `issuer|jti` because not every issuer emits
|
|
186
|
+
* `jti` (Azure uses `uti`, others omit it), so this is strictly more general.
|
|
187
|
+
*
|
|
188
|
+
* Hashing the raw token instead would be bypassable, because the signature segment is covered by
|
|
189
|
+
* nothing. Base64url decoding ignores the surplus low bits of the final character, so for an RS256
|
|
190
|
+
* signature there are 16 distinct spellings of that segment that decode to identical bytes — every
|
|
191
|
+
* one of them passes `jwt.verify`, and every one hashes differently. One leaked identity token would
|
|
192
|
+
* buy 16 operation tokens. ES* issuers add a second, independent vector, since `s → n−s` is a
|
|
193
|
+
* different valid signature over the same input.
|
|
194
|
+
*
|
|
195
|
+
* The signed input has neither problem: it is exactly what the issuer asserted and what the
|
|
196
|
+
* signature covers, so every variant spelling and every malleable re-signing of one assertion
|
|
197
|
+
* collapses to one fingerprint. Hashed rather than stored so the table never holds a credential.
|
|
198
|
+
*/
|
|
199
|
+
function tokenFingerprint(token: string): string {
|
|
200
|
+
// Not `slice(0, 2).join('.')` on a split of the whole token: lastIndexOf keeps this O(1) in the
|
|
201
|
+
// signature length and cannot silently succeed on a malformed token with too few segments —
|
|
202
|
+
// verifyIdentityToken has already established this is a well-formed three-segment JWT.
|
|
203
|
+
const signedInput = token.slice(0, token.lastIndexOf('.'));
|
|
204
|
+
return createHash('sha256').update(signedInput).digest('base64url');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Marks an identity token as spent, refusing one already recorded.
|
|
209
|
+
*
|
|
210
|
+
* Recorded before the token is minted: if minting then fails the credential is burned, costing a CI
|
|
211
|
+
* re-run, where the reverse ordering would leave a spendable token behind. The get-then-put is not
|
|
212
|
+
* atomic and deliberately does not depend on Harper's optimistic concurrency to make it so — see
|
|
213
|
+
* getTokenUseTable for why the race is tolerable.
|
|
214
|
+
*/
|
|
215
|
+
async function recordTokenUse(fingerprint: string, claims: TokenClaims, policyId: string): Promise<void> {
|
|
216
|
+
const useTable = getTokenUseTable();
|
|
217
|
+
if (await useTable.get(fingerprint)) rejectToken(`token ${fingerprint.slice(0, 12)} has already been exchanged`);
|
|
218
|
+
|
|
219
|
+
await useTable.put({
|
|
220
|
+
id: fingerprint,
|
|
221
|
+
policy_id: policyId,
|
|
222
|
+
used_at: Date.now(),
|
|
223
|
+
expiresAt: (claims.exp as number) * 1000 + REPLAY_RECORD_PADDING_MS,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Exchanges a CI identity token for a short-lived Harper operation token. Unauthenticated by design —
|
|
229
|
+
* this operation *is* the authentication, the way create_authentication_tokens is against a password.
|
|
230
|
+
*/
|
|
231
|
+
export async function exchangeOidcToken(req: any) {
|
|
232
|
+
const validation = validateBySchema(
|
|
233
|
+
req,
|
|
234
|
+
Joi.object({ token: Joi.string().min(1).max(MAX_TOKEN_LENGTH).required() }).unknown(true)
|
|
235
|
+
);
|
|
236
|
+
if (validation) throw new ClientError(validation.message);
|
|
237
|
+
|
|
238
|
+
// Populated as identification progresses so a failure audits with whatever was established.
|
|
239
|
+
const audit: Record<string, unknown> = {};
|
|
240
|
+
let username: string | undefined;
|
|
241
|
+
try {
|
|
242
|
+
// Nothing is trusted from this decode; it only selects candidate policies, and the signature
|
|
243
|
+
// is then checked against the issuer those policies declare.
|
|
244
|
+
const unverified = jwt.decode(req.token, { complete: true });
|
|
245
|
+
let issuer: string;
|
|
246
|
+
try {
|
|
247
|
+
issuer = normalizeIssuer((unverified?.payload as any)?.iss);
|
|
248
|
+
} catch {
|
|
249
|
+
rejectToken('token has no usable iss claim');
|
|
250
|
+
}
|
|
251
|
+
audit.issuer = issuer;
|
|
252
|
+
|
|
253
|
+
const profile = profileForIssuer(issuer);
|
|
254
|
+
audit.provider = profile.name;
|
|
255
|
+
|
|
256
|
+
const policies = await loadEnabledPolicies(issuer);
|
|
257
|
+
if (policies.length === 0) rejectToken(`no enabled trust policy for issuer ${issuer}`);
|
|
258
|
+
|
|
259
|
+
const matched = await findMatchingPolicy(req.token, issuer, policies, profile);
|
|
260
|
+
if (!matched) rejectToken(`no trust policy matched a token from ${issuer}`);
|
|
261
|
+
const { policy, claims } = matched;
|
|
262
|
+
audit.oidc_policy = policy.id;
|
|
263
|
+
audit.principal = profile.describePrincipal(claims);
|
|
264
|
+
|
|
265
|
+
// Resolved before the token is spent, so a policy naming a deleted or deactivated user fails
|
|
266
|
+
// without burning a token the runner cannot re-mint.
|
|
267
|
+
const users = await getUsersWithRolesCache();
|
|
268
|
+
const user = users?.get(policy.user);
|
|
269
|
+
if (!user) rejectToken(`trust policy '${policy.id}' names user '${policy.user}', which does not exist`);
|
|
270
|
+
if (user.active === false) rejectToken(`trust policy '${policy.id}' names inactive user '${policy.user}'`);
|
|
271
|
+
username = user.username;
|
|
272
|
+
|
|
273
|
+
const fingerprint = tokenFingerprint(req.token);
|
|
274
|
+
audit.token_fingerprint = fingerprint.slice(0, 12);
|
|
275
|
+
await recordTokenUse(fingerprint, claims, policy.id);
|
|
276
|
+
|
|
277
|
+
const operationToken = await createOperationToken(
|
|
278
|
+
{
|
|
279
|
+
username: user.username,
|
|
280
|
+
super_user: user.role?.permission?.super_user === true,
|
|
281
|
+
operations: policy.operations,
|
|
282
|
+
},
|
|
283
|
+
EXCHANGED_TOKEN_LIFETIME_SECONDS
|
|
284
|
+
);
|
|
285
|
+
if (policy.operations?.length) audit.scoped_operations = policy.operations;
|
|
286
|
+
|
|
287
|
+
logger.info?.(`OIDC exchange: policy '${policy.id}' authenticated '${user.username}' for ${audit.principal}`);
|
|
288
|
+
auditExchangeSafely(req, username, AUTH_AUDIT_STATUS.SUCCESS, audit);
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
operation_token: operationToken,
|
|
292
|
+
expires_in: EXCHANGED_TOKEN_LIFETIME_SECONDS,
|
|
293
|
+
username: user.username,
|
|
294
|
+
policy: policy.id,
|
|
295
|
+
};
|
|
296
|
+
} catch (error) {
|
|
297
|
+
auditExchangeSafely(req, username, AUTH_AUDIT_STATUS.FAILURE, audit);
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
}
|