@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
package/bin/deploySetup.ts
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
normalizeGitHost,
|
|
37
37
|
projectNameFromPackage,
|
|
38
38
|
GIT_HOST_PATTERN,
|
|
39
|
+
isReservedComponentName,
|
|
39
40
|
PROJECT_NAME_PATTERN,
|
|
40
41
|
} from '../utility/componentNames.ts';
|
|
41
42
|
|
|
@@ -74,6 +75,20 @@ export function resolveComponentName(req: any): string | undefined {
|
|
|
74
75
|
return undefined;
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
/** A credential sealed and granted to a name no deploy can run as is a secret nobody can ever use. */
|
|
79
|
+
export function assertUsableComponentName(component: string): void {
|
|
80
|
+
if (!PROJECT_NAME_PATTERN.test(component)) {
|
|
81
|
+
throw cliError(
|
|
82
|
+
`"${component}" is not a usable component name — a deploy accepts letters, numbers, dashes and underscores.`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (isReservedComponentName(component)) {
|
|
86
|
+
throw cliError(
|
|
87
|
+
`"${component}" is reserved for Harper's "${component}" configuration section — deploying a component under that name is refused.`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
77
92
|
/**
|
|
78
93
|
* The canonical bare host for a git credential — `https://github.com/owner/repo` and
|
|
79
94
|
* `git@github.com` both identify `github.com`. Resolved once and then used for everything the host
|
|
@@ -185,11 +200,7 @@ export async function deploySetup(req: any): Promise<void> {
|
|
|
185
200
|
})
|
|
186
201
|
).project ?? ''
|
|
187
202
|
);
|
|
188
|
-
|
|
189
|
-
throw cliError(
|
|
190
|
-
`"${component}" is not a usable component name — a deploy accepts letters, numbers, dashes and underscores.`
|
|
191
|
-
);
|
|
192
|
-
}
|
|
203
|
+
assertUsableComponentName(component);
|
|
193
204
|
|
|
194
205
|
let credentialKey: string; // host (github) or registry (npm) — the credentials-entry discriminator
|
|
195
206
|
let credentialEntry: Record<string, string>;
|
package/bin/harper.ts
CHANGED
|
@@ -119,7 +119,7 @@ async function harper() {
|
|
|
119
119
|
case SERVICE_ACTIONS_ENUM.COPYDB: {
|
|
120
120
|
let sourceDb = process.argv[3];
|
|
121
121
|
let targetDbPath = process.argv[4];
|
|
122
|
-
return require('./copyDb').copyDb(sourceDb, targetDbPath);
|
|
122
|
+
return require('./copyDb').copyDb(sourceDb, targetDbPath, { blobs: 'copy' });
|
|
123
123
|
}
|
|
124
124
|
case OPERATIONS_ENUM.CREATE_BACKUP:
|
|
125
125
|
case OPERATIONS_ENUM.LIST_BACKUPS:
|
package/bin/help.ts
CHANGED
|
@@ -86,7 +86,10 @@ const SECTIONS: Section[] = [
|
|
|
86
86
|
['upgrade', 'Upgrade harperdb'],
|
|
87
87
|
['register', 'Register harperdb'],
|
|
88
88
|
['renew-certs', 'Generate a new set of self-signed certificates'],
|
|
89
|
-
[
|
|
89
|
+
[
|
|
90
|
+
'copy-db <source> <target>',
|
|
91
|
+
'Copies the database named <source> to the <target> environment path. File-backed blobs are copied to <target>-blobs; see its README before restoring.',
|
|
92
|
+
],
|
|
90
93
|
['version', 'Print the version'],
|
|
91
94
|
['help', 'Display this output'],
|
|
92
95
|
],
|
package/bin/lite.ts
CHANGED
package/bin/restart.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { compactOnStart } from './copyDb.ts';
|
|
|
9
9
|
import {
|
|
10
10
|
beginProcessShutdown,
|
|
11
11
|
restartWorkers,
|
|
12
|
+
isThreadRunning,
|
|
12
13
|
onMessageByType,
|
|
13
14
|
shutdownWorkersNow,
|
|
14
15
|
} from '../server/threads/manageThreads.js';
|
|
@@ -16,6 +17,8 @@ import { handleHDBError, hdbErrors } from '../utility/errors/hdbError.ts';
|
|
|
16
17
|
const { HTTP_STATUS_CODES } = hdbErrors;
|
|
17
18
|
import * as envMgr from '../utility/environment/environmentManager.ts';
|
|
18
19
|
import * as path from 'node:path';
|
|
20
|
+
import { getConfigObj, getConfigPath } from '../config/configUtils.ts';
|
|
21
|
+
import { withComponentPreparationLock } from '../components/componentPreparationLock.ts';
|
|
19
22
|
import { rmSync } from 'node:fs';
|
|
20
23
|
import { getThisNodeName } from '../server/nodeName.ts';
|
|
21
24
|
import { armRestartExitWatchdog } from './restartExitWatchdog.ts';
|
|
@@ -31,12 +34,65 @@ export { restart, restartService };
|
|
|
31
34
|
// Add ITC event listener to main thread which will be called from child that receives restart request.
|
|
32
35
|
if (isMainThread) {
|
|
33
36
|
onMessageByType(hdbTerms.ITC_EVENT_TYPES.RESTART, async (message, port) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
try {
|
|
38
|
+
if (message.removeBranchesFor) await restartThenRemoveBranches(message.workerType, message.removeBranchesFor);
|
|
39
|
+
else if (message.workerType) await restartService({ service: message.workerType });
|
|
40
|
+
else restart({ operation: 'restart' });
|
|
41
|
+
} finally {
|
|
42
|
+
port.postMessage({ type: 'restart-complete' });
|
|
43
|
+
}
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Restart, then remove the branches of an application dropped on a worker (which cannot outlive the
|
|
49
|
+
* restart it asked for). The restart happens even if the component lock cannot be taken.
|
|
50
|
+
*/
|
|
51
|
+
async function restartThenRemoveBranches(service: string, project: string): Promise<void> {
|
|
52
|
+
let restarted = false;
|
|
53
|
+
const restartHttpWorkers = async () => {
|
|
54
|
+
restarted = true;
|
|
55
|
+
processMan.expectedRestartOfChildren();
|
|
56
|
+
hdbLogger.notify('Restarting http_workers');
|
|
57
|
+
return restartWorkers('http');
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
const componentPath = path.join(getConfigPath(hdbTerms.CONFIG_PARAMS.COMPONENTSROOT) as string, project);
|
|
61
|
+
await withComponentPreparationLock(
|
|
62
|
+
componentPath,
|
|
63
|
+
async () => {
|
|
64
|
+
const outcome: any = await restartHttpWorkers();
|
|
65
|
+
if (!outcome || outcome.declined || outcome.workersKeptOnOldCode) {
|
|
66
|
+
hdbLogger.warn(
|
|
67
|
+
`Branched database storage of ${project} was left in place: the restart did not replace every worker`
|
|
68
|
+
);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// The worker's drop lock was released before this one was taken; a same-name deploy that landed
|
|
72
|
+
// in between owns these branches now.
|
|
73
|
+
if (getConfigObj()?.[project]) {
|
|
74
|
+
hdbLogger.warn(`${project} was deployed again since it was dropped; leaving its branched databases in place`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const { removeBranchesForApplication } = await import('../resources/branchDatabase.ts');
|
|
78
|
+
await removeBranchesForApplication(project);
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
timeoutMs: 5 * 60 * 1000,
|
|
82
|
+
onWait: (owner) =>
|
|
83
|
+
hdbLogger.debug?.(
|
|
84
|
+
`Waiting to restart after dropping ${project}` +
|
|
85
|
+
(owner ? ` behind process ${owner.pid}, thread ${owner.threadId}` : '')
|
|
86
|
+
),
|
|
87
|
+
isOwnerAlive: (owner) => owner.pid !== process.pid || isThreadRunning(owner.threadId),
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
hdbLogger.error(`Could not remove the branched database storage of ${project}`, error);
|
|
92
|
+
if (!restarted) await restartService({ service });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
40
96
|
/**
|
|
41
97
|
* Restart Harper.
|
|
42
98
|
* It will restart all the child threads and the hub and leaf server processes.
|
package/bin/run.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { startHTTPThreads } from '../server/threads/socketRouter.ts';
|
|
|
26
26
|
import { beginProcessShutdown } from '../server/threads/manageThreads.js';
|
|
27
27
|
import * as hdbInfoController from '../dataLayer/hdbInfoController.ts';
|
|
28
28
|
import { isReadOnlyMode } from '../resources/databases.ts';
|
|
29
|
-
import { getThisNodeName } from '../server/nodeName.ts';
|
|
29
|
+
import { getThisNodeName, getThisNodeHostname } from '../server/nodeName.ts';
|
|
30
30
|
import * as hdbTerms from '../utility/hdbTerms.ts';
|
|
31
31
|
import { getHdbPid, isProcessRunning } from '../utility/processManagement/processManagement.js';
|
|
32
32
|
import { PACKAGE_ROOT } from '../utility/packageUtils.js';
|
|
@@ -287,6 +287,8 @@ function startupLog(portResolutions: any) {
|
|
|
287
287
|
logMsg += `${pad('Mode:')}${chalk.yellow('READ-ONLY')}\n`;
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
logMsg += `${pad('Version:')}${packageJson.version}\n`;
|
|
291
|
+
|
|
290
292
|
logMsg += `${pad('Hostname:')}${getThisNodeName()}\n`;
|
|
291
293
|
|
|
292
294
|
logMsg += `${pad('Worker Threads:')}${env.get(CONFIG_PARAMS.THREADS_COUNT)}\n`;
|
|
@@ -327,17 +329,10 @@ function startupLog(portResolutions: any) {
|
|
|
327
329
|
}`;
|
|
328
330
|
logMsg += `, unix socket: ${configUtils.getConfigPath(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_DOMAINSOCKET)}\n`;
|
|
329
331
|
if (env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_PORT)) {
|
|
330
|
-
logMsg += pad('')
|
|
332
|
+
logMsg += `${pad('')}http://${getThisNodeHostname()}:${env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_PORT)}/\n`;
|
|
331
333
|
}
|
|
332
334
|
if (env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_SECUREPORT)) {
|
|
333
|
-
logMsg +=
|
|
334
|
-
'\n' +
|
|
335
|
-
pad('') +
|
|
336
|
-
'https://' +
|
|
337
|
-
getThisNodeName() +
|
|
338
|
-
':' +
|
|
339
|
-
env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_SECUREPORT) +
|
|
340
|
-
'/\n';
|
|
335
|
+
logMsg += `\n${pad('')}https://${getThisNodeHostname()}:${env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_SECUREPORT)}/\n`;
|
|
341
336
|
}
|
|
342
337
|
|
|
343
338
|
// MQTT Log
|
|
@@ -389,7 +384,7 @@ function startupLog(portResolutions: any) {
|
|
|
389
384
|
if (!restLog.includes(pair) && name === 'rest') {
|
|
390
385
|
restLog += pair;
|
|
391
386
|
if (value.protocol_name === 'HTTP' || value.protocol_name === 'HTTPS') {
|
|
392
|
-
restHostnames.push(`${value.protocol_name.toLowerCase()}://${
|
|
387
|
+
restHostnames.push(`${value.protocol_name.toLowerCase()}://${getThisNodeHostname()}:${key}/`);
|
|
393
388
|
}
|
|
394
389
|
}
|
|
395
390
|
|
package/bin/upgrade.js
CHANGED
|
@@ -110,11 +110,15 @@ async function runUpgrade(upgradeObj) {
|
|
|
110
110
|
throw err;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
// The stamp is what stops these directives running again on data they have already migrated.
|
|
113
114
|
try {
|
|
114
|
-
await hdbInfoController.insertHdbUpgradeInfo(upgradeObj[UPGRADE_VERSION]);
|
|
115
|
+
await hdbInfoController.insertHdbUpgradeInfo(upgradeObj[UPGRADE_VERSION] ?? packageJson.version);
|
|
115
116
|
} catch (err) {
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
printToLogAndConsole(
|
|
118
|
+
`The data upgrade completed, but the new data version could not be recorded in the '${hdbTerms.SYSTEM_TABLE_NAMES.INFO_TABLE_NAME}' table, so Harper will not start. Every restart re-runs the upgrade directives against already-upgraded data, so stop any process supervisor that restarts Harper automatically, then check the logs and contact ${hdbTerms.HDB_SUPPORT_ADDRESS}.`,
|
|
119
|
+
hdbTerms.LOG_LEVELS.ERROR
|
|
120
|
+
);
|
|
121
|
+
throw err;
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client half of OIDC trusted publishing (#2171): ask the runtime for a workload identity token
|
|
3
|
+
* addressed to this instance, trade it for a short-lived operation token via `exchange_oidc_token`.
|
|
4
|
+
*
|
|
5
|
+
* Structured as a provider list because the runtimes differ only in how the token is obtained.
|
|
6
|
+
* GitHub Actions is entry one; a Kubernetes entry is `available()` testing for a projected
|
|
7
|
+
* service-account token path and `requestToken()` reading that file. A runtime none of them
|
|
8
|
+
* recognizes falls through to the CLI's other credential sources.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { httpRequest } from '../utility/common_utils.ts';
|
|
12
|
+
|
|
13
|
+
interface WorkloadIdentityProvider {
|
|
14
|
+
name: string;
|
|
15
|
+
/** True when this process can obtain a token from this runtime. */
|
|
16
|
+
available(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Obtains an identity token bound to `audience`. Binding it is what makes the token unusable
|
|
19
|
+
* anywhere else — see SHARED_DEFAULT_AUDIENCE in security/authn/oidc/providers/githubActions.ts
|
|
20
|
+
* for what an unbound one costs.
|
|
21
|
+
*/
|
|
22
|
+
requestToken(audience: string): Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** GitHub sets both of these on a job that declares `permissions: id-token: write`. */
|
|
26
|
+
const GITHUB_TOKEN_REQUEST_URL = 'ACTIONS_ID_TOKEN_REQUEST_URL';
|
|
27
|
+
const GITHUB_TOKEN_REQUEST_TOKEN = 'ACTIONS_ID_TOKEN_REQUEST_TOKEN';
|
|
28
|
+
|
|
29
|
+
const IDENTITY_REQUEST_TIMEOUT_MS = 10_000;
|
|
30
|
+
|
|
31
|
+
const githubActions: WorkloadIdentityProvider = {
|
|
32
|
+
name: 'GitHub Actions',
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Both variables are required: GitHub sets them together, so their absence means the workflow did
|
|
36
|
+
* not grant `id-token: write` — a configuration answer, not a failure to report here.
|
|
37
|
+
*/
|
|
38
|
+
available(): boolean {
|
|
39
|
+
return Boolean(process.env[GITHUB_TOKEN_REQUEST_URL] && process.env[GITHUB_TOKEN_REQUEST_TOKEN]);
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
async requestToken(audience: string): Promise<string> {
|
|
43
|
+
const requestUrl = new URL(process.env[GITHUB_TOKEN_REQUEST_URL] as string);
|
|
44
|
+
requestUrl.searchParams.set('audience', audience);
|
|
45
|
+
|
|
46
|
+
const response = await fetch(requestUrl, {
|
|
47
|
+
headers: {
|
|
48
|
+
authorization: `Bearer ${process.env[GITHUB_TOKEN_REQUEST_TOKEN]}`,
|
|
49
|
+
accept: 'application/json',
|
|
50
|
+
},
|
|
51
|
+
signal: AbortSignal.timeout(IDENTITY_REQUEST_TIMEOUT_MS),
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) throw new Error(`GitHub returned ${response.status} for an identity token`);
|
|
54
|
+
|
|
55
|
+
const body: any = await response.json();
|
|
56
|
+
if (typeof body?.value !== 'string' || body.value === '') {
|
|
57
|
+
throw new Error('GitHub returned no identity token value');
|
|
58
|
+
}
|
|
59
|
+
return body.value;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const PROVIDERS: WorkloadIdentityProvider[] = [githubActions];
|
|
64
|
+
|
|
65
|
+
function activeProvider(): WorkloadIdentityProvider | undefined {
|
|
66
|
+
return PROVIDERS.find((provider) => provider.available());
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** True when this runtime can prove its own identity to the cluster. */
|
|
70
|
+
export function workloadIdentityAvailable(): boolean {
|
|
71
|
+
return activeProvider() !== undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Trades a workload identity token for a Harper operation token, or undefined when this runtime has
|
|
76
|
+
* no identity to offer. Failures are reported and swallowed: this is the last credential source
|
|
77
|
+
* before the request goes out unauthenticated, and the resulting 401 says nothing useful, so the
|
|
78
|
+
* reason is worth printing even though it is not by itself fatal.
|
|
79
|
+
*/
|
|
80
|
+
export async function exchangeWorkloadIdentityForToken(options: any, audience: string): Promise<string | undefined> {
|
|
81
|
+
const provider = activeProvider();
|
|
82
|
+
if (!provider) return undefined;
|
|
83
|
+
|
|
84
|
+
console.error(`Requesting a ${provider.name} identity token for ${audience}...`);
|
|
85
|
+
let identityToken: string;
|
|
86
|
+
try {
|
|
87
|
+
identityToken = await provider.requestToken(audience);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error(`Could not obtain a ${provider.name} identity token: ${(error as Error).message}`);
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
const response = await httpRequest(options, { operation: 'exchange_oidc_token', token: identityToken });
|
|
95
|
+
if (response.statusCode === 200) {
|
|
96
|
+
const data = JSON.parse(response.body);
|
|
97
|
+
if (data.operation_token) {
|
|
98
|
+
console.error(`Authenticated as '${data.username}' via OIDC trust policy '${data.policy}'.`);
|
|
99
|
+
return data.operation_token;
|
|
100
|
+
}
|
|
101
|
+
console.error('The OIDC exchange returned no operation token.');
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
if (response.statusCode === 401) {
|
|
105
|
+
// The server deliberately does not say which check failed, so point at the two things the
|
|
106
|
+
// operator can actually inspect rather than inventing a cause.
|
|
107
|
+
console.error(
|
|
108
|
+
'Harper rejected the identity token. Check that a trust policy matches this workload ' +
|
|
109
|
+
'(list_oidc_trust) and that its audience is this instance; the server log records the reason.'
|
|
110
|
+
);
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
console.error(`OIDC exchange failed: ${response.statusCode}`);
|
|
114
|
+
return undefined;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error(`Error exchanging the identity token: ${(error as Error).message}`);
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
}
|