@gadicc/loom 1.37.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.loom-source-manifest.json +97 -0
- package/README.md +113 -31
- package/db/databaseTls.js +6 -3
- package/db/databaseUrl.js +3 -2
- package/db/drizzle-config.js +14 -16
- package/db/fixtures.d.ts +1 -3
- package/db/fixtures.js +4 -7
- package/esm/bin/loom.d.ts +2 -1
- package/esm/bin/loom.d.ts.map +1 -1
- package/esm/bin/loom.js +37 -10
- package/esm/bin/loom.js.map +1 -0
- package/esm/mod.d.ts +0 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/esm/mod.js.map +1 -0
- package/esm/src/apiKeys/authorize.d.ts.map +1 -1
- package/esm/src/apiKeys/authorize.js +15 -14
- package/esm/src/apiKeys/authorize.js.map +1 -0
- package/esm/src/apiKeys/betterAuth.d.ts.map +1 -1
- package/esm/src/apiKeys/betterAuth.js +1 -0
- package/esm/src/apiKeys/betterAuth.js.map +1 -0
- package/esm/src/apiKeys/country.d.ts.map +1 -1
- package/esm/src/apiKeys/country.js +1 -0
- package/esm/src/apiKeys/country.js.map +1 -0
- package/esm/src/apiKeys/credentials.d.ts.map +1 -1
- package/esm/src/apiKeys/credentials.js +3 -1
- package/esm/src/apiKeys/credentials.js.map +1 -0
- package/esm/src/apiKeys/fingerprint.d.ts.map +1 -1
- package/esm/src/apiKeys/fingerprint.js +1 -0
- package/esm/src/apiKeys/fingerprint.js.map +1 -0
- package/esm/src/apiKeys/lifecycle.d.ts.map +1 -1
- package/esm/src/apiKeys/lifecycle.js +1 -0
- package/esm/src/apiKeys/lifecycle.js.map +1 -0
- package/esm/src/apiKeys/limits.d.ts.map +1 -1
- package/esm/src/apiKeys/limits.js +10 -10
- package/esm/src/apiKeys/limits.js.map +1 -0
- package/esm/src/apiKeys/mod.d.ts +0 -1
- package/esm/src/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/apiKeys/mod.js +1 -1
- package/esm/src/apiKeys/mod.js.map +1 -0
- package/esm/src/apiKeys/permissions.d.ts.map +1 -1
- package/esm/src/apiKeys/permissions.js +1 -0
- package/esm/src/apiKeys/permissions.js.map +1 -0
- package/esm/src/apiKeys/policy.d.ts.map +1 -1
- package/esm/src/apiKeys/policy.js +1 -0
- package/esm/src/apiKeys/policy.js.map +1 -0
- package/esm/src/apiKeys/retention.d.ts.map +1 -1
- package/esm/src/apiKeys/retention.js +1 -0
- package/esm/src/apiKeys/retention.js.map +1 -0
- package/esm/src/apiKeys/types.d.ts.map +1 -1
- package/esm/src/apiKeys/types.js +1 -0
- package/esm/src/apiKeys/types.js.map +1 -0
- package/esm/src/cli/atomicText.d.ts +3 -0
- package/esm/src/cli/atomicText.d.ts.map +1 -0
- package/esm/src/cli/atomicText.js +33 -0
- package/esm/src/cli/atomicText.js.map +1 -0
- package/esm/src/cli/bunLocalDev.d.ts +65 -0
- package/esm/src/cli/bunLocalDev.d.ts.map +1 -0
- package/esm/src/cli/bunLocalDev.js +459 -0
- package/esm/src/cli/bunLocalDev.js.map +1 -0
- package/esm/src/cli/bunProject.d.ts +30 -0
- package/esm/src/cli/bunProject.d.ts.map +1 -0
- package/esm/src/cli/bunProject.js +309 -0
- package/esm/src/cli/bunProject.js.map +1 -0
- package/esm/src/cli/cliBootstrap.d.ts +83 -0
- package/esm/src/cli/cliBootstrap.d.ts.map +1 -0
- package/esm/src/cli/cliBootstrap.js +186 -0
- package/esm/src/cli/cliBootstrap.js.map +1 -0
- package/esm/src/cli/externalSkills.d.ts.map +1 -1
- package/esm/src/cli/externalSkills.js +9 -5
- package/esm/src/cli/externalSkills.js.map +1 -0
- package/esm/src/cli/filesR2Policy.d.ts.map +1 -1
- package/esm/src/cli/filesR2Policy.js +18 -11
- package/esm/src/cli/filesR2Policy.js.map +1 -0
- package/esm/src/cli/generatedBuild.d.ts +42 -0
- package/esm/src/cli/generatedBuild.d.ts.map +1 -0
- package/esm/src/cli/generatedBuild.js +259 -0
- package/esm/src/cli/generatedBuild.js.map +1 -0
- package/esm/src/cli/generatedCleanup.d.ts +7 -0
- package/esm/src/cli/generatedCleanup.d.ts.map +1 -0
- package/esm/src/cli/generatedCleanup.js +67 -0
- package/esm/src/cli/generatedCleanup.js.map +1 -0
- package/esm/src/cli/generatedDevLease.d.ts +8 -0
- package/esm/src/cli/generatedDevLease.d.ts.map +1 -0
- package/esm/src/cli/generatedDevLease.js +39 -0
- package/esm/src/cli/generatedDevLease.js.map +1 -0
- package/esm/src/cli/generatedInstall.d.ts +64 -0
- package/esm/src/cli/generatedInstall.d.ts.map +1 -0
- package/esm/src/cli/generatedInstall.js +466 -0
- package/esm/src/cli/generatedInstall.js.map +1 -0
- package/esm/src/cli/generatedWorkflow.d.ts +34 -0
- package/esm/src/cli/generatedWorkflow.d.ts.map +1 -0
- package/esm/src/cli/generatedWorkflow.js +85 -0
- package/esm/src/cli/generatedWorkflow.js.map +1 -0
- package/esm/src/cli/legacyManagedOutputs.d.ts.map +1 -1
- package/esm/src/cli/legacyManagedOutputs.js +1 -0
- package/esm/src/cli/legacyManagedOutputs.js.map +1 -0
- package/esm/src/cli/localDb.d.ts.map +1 -1
- package/esm/src/cli/localDb.js +35 -30
- package/esm/src/cli/localDb.js.map +1 -0
- package/esm/src/cli/localDevLock.d.ts +9 -0
- package/esm/src/cli/localDevLock.d.ts.map +1 -1
- package/esm/src/cli/localDevLock.js +54 -13
- package/esm/src/cli/localDevLock.js.map +1 -0
- package/esm/src/cli/localDevPackage.d.ts +6 -11
- package/esm/src/cli/localDevPackage.d.ts.map +1 -1
- package/esm/src/cli/localDevPackage.js +51 -48
- package/esm/src/cli/localDevPackage.js.map +1 -0
- package/esm/src/cli/managedFiles.d.ts.map +1 -1
- package/esm/src/cli/managedFiles.js +34 -18
- package/esm/src/cli/managedFiles.js.map +1 -0
- package/esm/src/cli/migrationEnv.d.ts +16 -3
- package/esm/src/cli/migrationEnv.d.ts.map +1 -1
- package/esm/src/cli/migrationEnv.js +9 -6
- package/esm/src/cli/migrationEnv.js.map +1 -0
- package/esm/src/cli/mod.d.ts +20 -7
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +2148 -730
- package/esm/src/cli/mod.js.map +1 -0
- package/esm/src/cli/packageTreeSignature.d.ts +8 -0
- package/esm/src/cli/packageTreeSignature.d.ts.map +1 -0
- package/esm/src/cli/packageTreeSignature.js +60 -0
- package/esm/src/cli/packageTreeSignature.js.map +1 -0
- package/esm/src/cli/processIdentity.d.ts +7 -0
- package/esm/src/cli/processIdentity.d.ts.map +1 -0
- package/esm/src/cli/processIdentity.js +39 -0
- package/esm/src/cli/processIdentity.js.map +1 -0
- package/esm/src/cli/projectSkills.d.ts +1 -1
- package/esm/src/cli/projectSkills.d.ts.map +1 -1
- package/esm/src/cli/projectSkills.js +31 -23
- package/esm/src/cli/projectSkills.js.map +1 -0
- package/esm/src/cli/projectTooling.d.ts +6 -3
- package/esm/src/cli/projectTooling.d.ts.map +1 -1
- package/esm/src/cli/projectTooling.js +86 -41
- package/esm/src/cli/projectTooling.js.map +1 -0
- package/esm/src/cli/releaseConfig.d.ts.map +1 -1
- package/esm/src/cli/releaseConfig.js +5 -3
- package/esm/src/cli/releaseConfig.js.map +1 -0
- package/esm/src/cli/releaseCredentials.d.ts.map +1 -1
- package/esm/src/cli/releaseCredentials.js +19 -31
- package/esm/src/cli/releaseCredentials.js.map +1 -0
- package/esm/src/cli/releaseTrust.d.ts.map +1 -1
- package/esm/src/cli/releaseTrust.js +11 -4
- package/esm/src/cli/releaseTrust.js.map +1 -0
- package/esm/src/cli/releaseTrustCommand.d.ts.map +1 -1
- package/esm/src/cli/releaseTrustCommand.js +6 -4
- package/esm/src/cli/releaseTrustCommand.js.map +1 -0
- package/esm/src/cli/sourceConfig.d.ts +3 -0
- package/esm/src/cli/sourceConfig.d.ts.map +1 -0
- package/esm/src/cli/sourceConfig.js +91 -0
- package/esm/src/cli/sourceConfig.js.map +1 -0
- package/esm/src/cli/sourceDev.d.ts +77 -0
- package/esm/src/cli/sourceDev.d.ts.map +1 -0
- package/esm/src/cli/sourceDev.js +974 -0
- package/esm/src/cli/sourceDev.js.map +1 -0
- package/esm/src/cli/vercelBuildEnv.d.ts.map +1 -1
- package/esm/src/cli/vercelBuildEnv.js +44 -21
- package/esm/src/cli/vercelBuildEnv.js.map +1 -0
- package/esm/src/cli/vercelEnvMask.d.ts +38 -0
- package/esm/src/cli/vercelEnvMask.d.ts.map +1 -0
- package/esm/src/cli/vercelEnvMask.js +140 -0
- package/esm/src/cli/vercelEnvMask.js.map +1 -0
- package/esm/src/cli/vercelProjectRelease.d.ts.map +1 -1
- package/esm/src/cli/vercelProjectRelease.js +47 -24
- package/esm/src/cli/vercelProjectRelease.js.map +1 -0
- package/esm/src/cli/vercelPulledEnv.d.ts +65 -0
- package/esm/src/cli/vercelPulledEnv.d.ts.map +1 -0
- package/esm/src/cli/vercelPulledEnv.js +133 -0
- package/esm/src/cli/vercelPulledEnv.js.map +1 -0
- package/esm/src/clientData/identity.d.ts.map +1 -1
- package/esm/src/clientData/identity.js +1 -0
- package/esm/src/clientData/identity.js.map +1 -0
- package/esm/src/clientData/mod.d.ts +0 -1
- package/esm/src/clientData/mod.d.ts.map +1 -1
- package/esm/src/clientData/mod.js +1 -0
- package/esm/src/clientData/mod.js.map +1 -0
- package/esm/src/files/client.d.ts +1 -1
- package/esm/src/files/client.d.ts.map +1 -1
- package/esm/src/files/client.js +3 -4
- package/esm/src/files/client.js.map +1 -0
- package/esm/src/files/errors.d.ts.map +1 -1
- package/esm/src/files/errors.js +3 -12
- package/esm/src/files/errors.js.map +1 -0
- package/esm/src/files/hash.d.ts +1 -1
- package/esm/src/files/hash.d.ts.map +1 -1
- package/esm/src/files/hash.js +1 -0
- package/esm/src/files/hash.js.map +1 -0
- package/esm/src/files/memory.d.ts.map +1 -1
- package/esm/src/files/memory.js +2 -1
- package/esm/src/files/memory.js.map +1 -0
- package/esm/src/files/metadata.d.ts.map +1 -1
- package/esm/src/files/metadata.js +11 -18
- package/esm/src/files/metadata.js.map +1 -0
- package/esm/src/files/mod.d.ts +0 -1
- package/esm/src/files/mod.d.ts.map +1 -1
- package/esm/src/files/mod.js +1 -1
- package/esm/src/files/mod.js.map +1 -0
- package/esm/src/files/s3.d.ts.map +1 -1
- package/esm/src/files/s3.js +6 -4
- package/esm/src/files/s3.js.map +1 -0
- package/esm/src/files/service.d.ts.map +1 -1
- package/esm/src/files/service.js +3 -4
- package/esm/src/files/service.js.map +1 -0
- package/esm/src/files/types.d.ts.map +1 -1
- package/esm/src/files/types.js +1 -0
- package/esm/src/files/types.js.map +1 -0
- package/esm/src/jobs/catalog.d.ts.map +1 -1
- package/esm/src/jobs/catalog.js +5 -1
- package/esm/src/jobs/catalog.js.map +1 -0
- package/esm/src/jobs/controller.d.ts +1 -1
- package/esm/src/jobs/controller.d.ts.map +1 -1
- package/esm/src/jobs/controller.js +11 -55
- package/esm/src/jobs/controller.js.map +1 -0
- package/esm/src/jobs/direct.d.ts.map +1 -1
- package/esm/src/jobs/direct.js +3 -3
- package/esm/src/jobs/direct.js.map +1 -0
- package/esm/src/jobs/events.d.ts.map +1 -1
- package/esm/src/jobs/events.js +1 -0
- package/esm/src/jobs/events.js.map +1 -0
- package/esm/src/jobs/format.d.ts +5 -5
- package/esm/src/jobs/format.d.ts.map +1 -1
- package/esm/src/jobs/format.js +2 -1
- package/esm/src/jobs/format.js.map +1 -0
- package/esm/src/jobs/http.d.ts +3 -3
- package/esm/src/jobs/http.d.ts.map +1 -1
- package/esm/src/jobs/http.js +1 -0
- package/esm/src/jobs/http.js.map +1 -0
- package/esm/src/jobs/log.d.ts.map +1 -1
- package/esm/src/jobs/log.js +1 -0
- package/esm/src/jobs/log.js.map +1 -0
- package/esm/src/jobs/mod.d.ts.map +1 -1
- package/esm/src/jobs/mod.js +1 -0
- package/esm/src/jobs/mod.js.map +1 -0
- package/esm/src/jobs/run.d.ts.map +1 -1
- package/esm/src/jobs/run.js +1 -0
- package/esm/src/jobs/run.js.map +1 -0
- package/esm/src/jobs/sanitize.d.ts.map +1 -1
- package/esm/src/jobs/sanitize.js +1 -0
- package/esm/src/jobs/sanitize.js.map +1 -0
- package/esm/src/jobs/types.d.ts +1 -0
- package/esm/src/jobs/types.d.ts.map +1 -1
- package/esm/src/jobs/types.js +1 -0
- package/esm/src/jobs/types.js.map +1 -0
- package/esm/src/mail/errors.d.ts.map +1 -1
- package/esm/src/mail/errors.js +8 -42
- package/esm/src/mail/errors.js.map +1 -0
- package/esm/src/mail/memory.d.ts +1 -1
- package/esm/src/mail/memory.d.ts.map +1 -1
- package/esm/src/mail/memory.js +10 -14
- package/esm/src/mail/memory.js.map +1 -0
- package/esm/src/mail/mod.d.ts +0 -1
- package/esm/src/mail/mod.d.ts.map +1 -1
- package/esm/src/mail/mod.js +1 -1
- package/esm/src/mail/mod.js.map +1 -0
- package/esm/src/mail/postal.d.ts +1 -2
- package/esm/src/mail/postal.d.ts.map +1 -1
- package/esm/src/mail/postal.js +22 -18
- package/esm/src/mail/postal.js.map +1 -0
- package/esm/src/mail/retry.d.ts.map +1 -1
- package/esm/src/mail/retry.js +1 -0
- package/esm/src/mail/retry.js.map +1 -0
- package/esm/src/mail/sender.d.ts.map +1 -1
- package/esm/src/mail/sender.js +1 -0
- package/esm/src/mail/sender.js.map +1 -0
- package/esm/src/mail/service.d.ts.map +1 -1
- package/esm/src/mail/service.js +6 -7
- package/esm/src/mail/service.js.map +1 -0
- package/esm/src/mail/types.d.ts.map +1 -1
- package/esm/src/mail/types.js +1 -0
- package/esm/src/mail/types.js.map +1 -0
- package/esm/src/mui/apiKeys.d.ts +10 -11
- package/esm/src/mui/apiKeys.d.ts.map +1 -1
- package/esm/src/mui/apiKeys.js +83 -214
- package/esm/src/mui/apiKeys.js.map +1 -0
- package/esm/src/mui/apiKeysView.d.ts +1 -1
- package/esm/src/mui/apiKeysView.d.ts.map +1 -1
- package/esm/src/mui/apiKeysView.js +11 -9
- package/esm/src/mui/apiKeysView.js.map +1 -0
- package/esm/src/mui/confirm.d.ts +2 -2
- package/esm/src/mui/confirm.d.ts.map +1 -1
- package/esm/src/mui/confirm.js +3 -7
- package/esm/src/mui/confirm.js.map +1 -0
- package/esm/src/mui/mail.d.ts +4 -4
- package/esm/src/mui/mail.d.ts.map +1 -1
- package/esm/src/mui/mail.js +11 -71
- package/esm/src/mui/mail.js.map +1 -0
- package/esm/src/mui/mailView.d.ts +1 -1
- package/esm/src/mui/mailView.d.ts.map +1 -1
- package/esm/src/mui/mailView.js +1 -0
- package/esm/src/mui/mailView.js.map +1 -0
- package/esm/src/mui/mod.d.ts +0 -1
- package/esm/src/mui/mod.d.ts.map +1 -1
- package/esm/src/mui/mod.js +1 -0
- package/esm/src/mui/mod.js.map +1 -0
- package/esm/src/next/apiKeys/mod.d.ts +2 -3
- package/esm/src/next/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/next/apiKeys/mod.js +6 -5
- package/esm/src/next/apiKeys/mod.js.map +1 -0
- package/esm/src/next/auth/client.d.ts +0 -1
- package/esm/src/next/auth/client.d.ts.map +1 -1
- package/esm/src/next/auth/client.js +1 -0
- package/esm/src/next/auth/client.js.map +1 -0
- package/esm/src/next/auth/config.d.ts.map +1 -1
- package/esm/src/next/auth/config.js +11 -17
- package/esm/src/next/auth/config.js.map +1 -0
- package/esm/src/next/auth/localTestLogin.d.ts.map +1 -1
- package/esm/src/next/auth/localTestLogin.js +13 -9
- package/esm/src/next/auth/localTestLogin.js.map +1 -0
- package/esm/src/next/auth/mod.d.ts.map +1 -1
- package/esm/src/next/auth/mod.js +1 -0
- package/esm/src/next/auth/mod.js.map +1 -0
- package/esm/src/next/auth/server.d.ts +2 -2
- package/esm/src/next/auth/server.d.ts.map +1 -1
- package/esm/src/next/auth/server.js +1 -0
- package/esm/src/next/auth/server.js.map +1 -0
- package/esm/src/next/files/mod.d.ts +0 -1
- package/esm/src/next/files/mod.d.ts.map +1 -1
- package/esm/src/next/files/mod.js +1 -1
- package/esm/src/next/files/mod.js.map +1 -0
- package/esm/src/next/files/route.d.ts +1 -1
- package/esm/src/next/files/route.d.ts.map +1 -1
- package/esm/src/next/files/route.js +11 -11
- package/esm/src/next/files/route.js.map +1 -0
- package/esm/src/next/jobs/list.d.ts +5 -5
- package/esm/src/next/jobs/list.d.ts.map +1 -1
- package/esm/src/next/jobs/list.js +15 -19
- package/esm/src/next/jobs/list.js.map +1 -0
- package/esm/src/next/jobs/mod.d.ts.map +1 -1
- package/esm/src/next/jobs/mod.js +1 -0
- package/esm/src/next/jobs/mod.js.map +1 -0
- package/esm/src/next/jobs/paths.d.ts +2 -2
- package/esm/src/next/jobs/paths.d.ts.map +1 -1
- package/esm/src/next/jobs/paths.js +1 -0
- package/esm/src/next/jobs/paths.js.map +1 -0
- package/esm/src/next/jobs/route.d.ts +2 -2
- package/esm/src/next/jobs/route.d.ts.map +1 -1
- package/esm/src/next/jobs/route.js +4 -4
- package/esm/src/next/jobs/route.js.map +1 -0
- package/esm/src/next/jobs/run.d.ts +2 -2
- package/esm/src/next/jobs/run.d.ts.map +1 -1
- package/esm/src/next/jobs/run.js +68 -132
- package/esm/src/next/jobs/run.js.map +1 -0
- package/esm/src/next/jobs/runRequest.d.ts +1 -1
- package/esm/src/next/jobs/runRequest.d.ts.map +1 -1
- package/esm/src/next/jobs/runRequest.js +3 -4
- package/esm/src/next/jobs/runRequest.js.map +1 -0
- package/esm/src/next/jobs/stream.d.ts.map +1 -1
- package/esm/src/next/jobs/stream.js +1 -0
- package/esm/src/next/jobs/stream.js.map +1 -0
- package/esm/src/next/mail/mod.d.ts +0 -1
- package/esm/src/next/mail/mod.d.ts.map +1 -1
- package/esm/src/next/mail/mod.js +1 -1
- package/esm/src/next/mail/mod.js.map +1 -0
- package/esm/src/next/mail/route.d.ts +2 -2
- package/esm/src/next/mail/route.d.ts.map +1 -1
- package/esm/src/next/mail/route.js +1 -0
- package/esm/src/next/mail/route.js.map +1 -0
- package/esm/src/next/pwa/mod.d.ts +0 -4
- package/esm/src/next/pwa/mod.d.ts.map +1 -1
- package/esm/src/next/pwa/mod.js +32 -16
- package/esm/src/next/pwa/mod.js.map +1 -0
- package/esm/src/next/pwa/worker.d.ts +0 -1
- package/esm/src/next/pwa/worker.d.ts.map +1 -1
- package/esm/src/next/pwa/worker.js +1 -0
- package/esm/src/next/pwa/worker.js.map +1 -0
- package/esm/src/next/secrets/constants.d.ts +3 -0
- package/esm/src/next/secrets/constants.d.ts.map +1 -0
- package/esm/src/next/secrets/constants.js +3 -0
- package/esm/src/next/secrets/constants.js.map +1 -0
- package/esm/src/next/secrets/mod.d.ts +1 -3
- package/esm/src/next/secrets/mod.d.ts.map +1 -1
- package/esm/src/next/secrets/mod.js +6 -7
- package/esm/src/next/secrets/mod.js.map +1 -0
- package/esm/src/next/sourceDev.d.ts +6 -0
- package/esm/src/next/sourceDev.d.ts.map +1 -0
- package/esm/src/next/sourceDev.js +41 -0
- package/esm/src/next/sourceDev.js.map +1 -0
- package/esm/src/secrets/encoding.d.ts.map +1 -1
- package/esm/src/secrets/encoding.js +1 -0
- package/esm/src/secrets/encoding.js.map +1 -0
- package/esm/src/secrets/errors.d.ts.map +1 -1
- package/esm/src/secrets/errors.js +3 -7
- package/esm/src/secrets/errors.js.map +1 -0
- package/esm/src/secrets/fingerprint.d.ts.map +1 -1
- package/esm/src/secrets/fingerprint.js +1 -0
- package/esm/src/secrets/fingerprint.js.map +1 -0
- package/esm/src/secrets/frame.d.ts.map +1 -1
- package/esm/src/secrets/frame.js +4 -3
- package/esm/src/secrets/frame.js.map +1 -0
- package/esm/src/secrets/keyring.d.ts.map +1 -1
- package/esm/src/secrets/keyring.js +6 -6
- package/esm/src/secrets/keyring.js.map +1 -0
- package/esm/src/secrets/legacy.d.ts +0 -1
- package/esm/src/secrets/legacy.d.ts.map +1 -1
- package/esm/src/secrets/legacy.js +13 -10
- package/esm/src/secrets/legacy.js.map +1 -0
- package/esm/src/secrets/maintenance.d.ts +0 -1
- package/esm/src/secrets/maintenance.d.ts.map +1 -1
- package/esm/src/secrets/maintenance.js +9 -24
- package/esm/src/secrets/maintenance.js.map +1 -0
- package/esm/src/secrets/mod.d.ts +0 -1
- package/esm/src/secrets/mod.d.ts.map +1 -1
- package/esm/src/secrets/mod.js +1 -1
- package/esm/src/secrets/mod.js.map +1 -0
- package/esm/src/secrets/secrets.d.ts.map +1 -1
- package/esm/src/secrets/secrets.js +38 -30
- package/esm/src/secrets/secrets.js.map +1 -0
- package/package.json +111 -135
- package/skills/loom/SKILL.md +40 -5
- package/skills/loom/references/dependency-upgrades.md +4 -0
- package/skills/loom/references/esm-package.md +35 -0
- package/skills/loom/references/local-development.md +261 -29
- package/skills/loom/references/release-safety.md +10 -3
- package/skills/loom-auth/references/secrets-and-rotation.md +2 -1
- package/skills/loom-mail/SKILL.md +1 -0
- package/skills/loom-scaffold/references/greenfield-workflow.md +2 -1
- package/skills/upgrade-deps/SKILL.md +4 -2
- package/source/bin/loom.ts +50 -0
- package/source/mod.ts +10 -0
- package/source/src/apiKeys/authorize.ts +294 -0
- package/source/src/apiKeys/betterAuth.ts +253 -0
- package/source/src/apiKeys/country.ts +7 -0
- package/source/src/apiKeys/credentials.ts +171 -0
- package/source/src/apiKeys/fingerprint.ts +10 -0
- package/{script/src/apiKeys/lifecycle.d.ts → source/src/apiKeys/lifecycle.ts} +21 -23
- package/source/src/apiKeys/limits.ts +372 -0
- package/source/src/apiKeys/mod.ts +11 -0
- package/source/src/apiKeys/permissions.ts +153 -0
- package/source/src/apiKeys/policy.ts +189 -0
- package/source/src/apiKeys/retention.ts +136 -0
- package/source/src/apiKeys/types.ts +288 -0
- package/source/src/cli/atomicText.ts +38 -0
- package/source/src/cli/bunLocalDev.ts +646 -0
- package/source/src/cli/bunProject.ts +433 -0
- package/source/src/cli/cliBootstrap.ts +313 -0
- package/source/src/cli/externalSkills.ts +315 -0
- package/source/src/cli/filesR2Policy.ts +212 -0
- package/source/src/cli/generatedBuild.ts +380 -0
- package/source/src/cli/generatedCleanup.ts +87 -0
- package/source/src/cli/generatedDevLease.ts +52 -0
- package/source/src/cli/generatedInstall.ts +630 -0
- package/source/src/cli/generatedWorkflow.ts +135 -0
- package/{script/src/cli/legacyManagedOutputs.js → source/src/cli/legacyManagedOutputs.ts} +36 -30
- package/source/src/cli/localDb.ts +548 -0
- package/source/src/cli/localDevLock.ts +462 -0
- package/source/src/cli/localDevPackage.ts +754 -0
- package/source/src/cli/managedFiles.ts +688 -0
- package/source/src/cli/migrationEnv.ts +267 -0
- package/source/src/cli/mod.ts +26788 -0
- package/source/src/cli/packageTreeSignature.ts +65 -0
- package/source/src/cli/processIdentity.ts +38 -0
- package/source/src/cli/projectSkills.ts +1102 -0
- package/source/src/cli/projectTooling.ts +1140 -0
- package/source/src/cli/releaseConfig.ts +36 -0
- package/source/src/cli/releaseCredentials.ts +642 -0
- package/source/src/cli/releaseTrust.ts +194 -0
- package/source/src/cli/releaseTrustCommand.ts +210 -0
- package/source/src/cli/sourceConfig.ts +106 -0
- package/source/src/cli/sourceDev.ts +1279 -0
- package/source/src/cli/vercelBuildEnv.ts +714 -0
- package/source/src/cli/vercelEnvMask.ts +182 -0
- package/source/src/cli/vercelProjectRelease.ts +807 -0
- package/source/src/cli/vercelPulledEnv.ts +174 -0
- package/source/src/clientData/identity.ts +229 -0
- package/source/src/clientData/mod.ts +1 -0
- package/source/src/files/client.ts +75 -0
- package/source/src/files/errors.ts +69 -0
- package/source/src/files/hash.ts +109 -0
- package/source/src/files/memory.ts +158 -0
- package/source/src/files/metadata.ts +251 -0
- package/source/src/files/mod.ts +8 -0
- package/source/src/files/s3.ts +182 -0
- package/source/src/files/service.ts +210 -0
- package/source/src/files/types.ts +171 -0
- package/source/src/jobs/catalog.ts +303 -0
- package/source/src/jobs/controller.ts +156 -0
- package/source/src/jobs/direct.ts +177 -0
- package/source/src/jobs/events.ts +74 -0
- package/source/src/jobs/format.ts +233 -0
- package/source/src/jobs/http.ts +83 -0
- package/source/src/jobs/log.ts +10 -0
- package/source/src/jobs/mod.ts +10 -0
- package/source/src/jobs/run.ts +141 -0
- package/source/src/jobs/sanitize.ts +142 -0
- package/source/src/jobs/types.ts +43 -0
- package/source/src/mail/errors.ts +77 -0
- package/source/src/mail/memory.ts +451 -0
- package/source/src/mail/mod.ts +5 -0
- package/source/src/mail/postal.ts +363 -0
- package/source/src/mail/retry.ts +30 -0
- package/source/src/mail/sender.ts +57 -0
- package/source/src/mail/service.ts +252 -0
- package/source/src/mail/types.ts +229 -0
- package/source/src/mui/apiKeys.tsx +1044 -0
- package/source/src/mui/apiKeysView.ts +535 -0
- package/source/src/mui/confirm.tsx +138 -0
- package/source/src/mui/mail.tsx +279 -0
- package/source/src/mui/mailView.ts +50 -0
- package/source/src/mui/mod.ts +3 -0
- package/source/src/next/apiKeys/mod.ts +393 -0
- package/{script/src/next/auth/client.d.ts → source/src/next/auth/client.ts} +19 -5
- package/source/src/next/auth/config.ts +207 -0
- package/source/src/next/auth/localTestLogin.ts +412 -0
- package/source/src/next/auth/mod.ts +3 -0
- package/source/src/next/auth/server.ts +94 -0
- package/source/src/next/files/mod.ts +1 -0
- package/source/src/next/files/route.ts +621 -0
- package/source/src/next/jobs/list.tsx +90 -0
- package/source/src/next/jobs/mod.ts +5 -0
- package/source/src/next/jobs/paths.ts +70 -0
- package/source/src/next/jobs/route.ts +207 -0
- package/source/src/next/jobs/run.tsx +888 -0
- package/source/src/next/jobs/runRequest.ts +92 -0
- package/source/src/next/jobs/stream.ts +33 -0
- package/source/src/next/mail/mod.ts +1 -0
- package/source/src/next/mail/route.ts +75 -0
- package/source/src/next/pwa/mod.tsx +453 -0
- package/source/src/next/pwa/worker.ts +59 -0
- package/source/src/next/secrets/constants.ts +2 -0
- package/source/src/next/secrets/mod.ts +319 -0
- package/source/src/next/sourceDev.ts +50 -0
- package/source/src/secrets/encoding.ts +102 -0
- package/source/src/secrets/errors.ts +58 -0
- package/source/src/secrets/fingerprint.ts +132 -0
- package/source/src/secrets/frame.ts +119 -0
- package/source/src/secrets/keyring.ts +225 -0
- package/source/src/secrets/legacy.ts +244 -0
- package/source/src/secrets/maintenance.ts +517 -0
- package/source/src/secrets/mod.ts +38 -0
- package/source/src/secrets/secrets.ts +926 -0
- package/db/databaseTls.test.ts +0 -171
- package/db/databaseUrl.test.ts +0 -72
- package/db/neonEndpoint.test.ts +0 -51
- package/db/testing.test.ts +0 -28
- package/deno.json +0 -3
- package/esm/_dnt.polyfills.d.ts +0 -166
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -177
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/package.json +0 -3
- package/script/_dnt.polyfills.d.ts +0 -166
- package/script/_dnt.polyfills.d.ts.map +0 -1
- package/script/_dnt.polyfills.js +0 -180
- package/script/_dnt.shims.d.ts +0 -2
- package/script/_dnt.shims.d.ts.map +0 -1
- package/script/_dnt.shims.js +0 -60
- package/script/bin/loom.d.ts +0 -2
- package/script/bin/loom.d.ts.map +0 -1
- package/script/bin/loom.js +0 -17
- package/script/mod.d.ts +0 -12
- package/script/mod.d.ts.map +0 -1
- package/script/mod.js +0 -27
- package/script/package.json +0 -3
- package/script/src/apiKeys/authorize.d.ts +0 -4
- package/script/src/apiKeys/authorize.d.ts.map +0 -1
- package/script/src/apiKeys/authorize.js +0 -258
- package/script/src/apiKeys/betterAuth.d.ts +0 -123
- package/script/src/apiKeys/betterAuth.d.ts.map +0 -1
- package/script/src/apiKeys/betterAuth.js +0 -169
- package/script/src/apiKeys/country.d.ts +0 -3
- package/script/src/apiKeys/country.d.ts.map +0 -1
- package/script/src/apiKeys/country.js +0 -10
- package/script/src/apiKeys/credentials.d.ts +0 -39
- package/script/src/apiKeys/credentials.d.ts.map +0 -1
- package/script/src/apiKeys/credentials.js +0 -121
- package/script/src/apiKeys/fingerprint.d.ts +0 -3
- package/script/src/apiKeys/fingerprint.d.ts.map +0 -1
- package/script/src/apiKeys/fingerprint.js +0 -8
- package/script/src/apiKeys/lifecycle.d.ts.map +0 -1
- package/script/src/apiKeys/lifecycle.js +0 -7
- package/script/src/apiKeys/limits.d.ts +0 -132
- package/script/src/apiKeys/limits.d.ts.map +0 -1
- package/script/src/apiKeys/limits.js +0 -254
- package/script/src/apiKeys/mod.d.ts +0 -13
- package/script/src/apiKeys/mod.d.ts.map +0 -1
- package/script/src/apiKeys/mod.js +0 -28
- package/script/src/apiKeys/permissions.d.ts +0 -56
- package/script/src/apiKeys/permissions.d.ts.map +0 -1
- package/script/src/apiKeys/permissions.js +0 -136
- package/script/src/apiKeys/policy.d.ts +0 -61
- package/script/src/apiKeys/policy.d.ts.map +0 -1
- package/script/src/apiKeys/policy.js +0 -94
- package/script/src/apiKeys/retention.d.ts +0 -55
- package/script/src/apiKeys/retention.d.ts.map +0 -1
- package/script/src/apiKeys/retention.js +0 -70
- package/script/src/apiKeys/types.d.ts +0 -242
- package/script/src/apiKeys/types.d.ts.map +0 -1
- package/script/src/apiKeys/types.js +0 -2
- package/script/src/cli/externalSkills.d.ts +0 -39
- package/script/src/cli/externalSkills.d.ts.map +0 -1
- package/script/src/cli/externalSkills.js +0 -204
- package/script/src/cli/filesR2Policy.d.ts +0 -33
- package/script/src/cli/filesR2Policy.d.ts.map +0 -1
- package/script/src/cli/filesR2Policy.js +0 -135
- package/script/src/cli/legacyManagedOutputs.d.ts +0 -33
- package/script/src/cli/legacyManagedOutputs.d.ts.map +0 -1
- package/script/src/cli/localDb.d.ts +0 -28
- package/script/src/cli/localDb.d.ts.map +0 -1
- package/script/src/cli/localDb.js +0 -370
- package/script/src/cli/localDevLock.d.ts +0 -97
- package/script/src/cli/localDevLock.d.ts.map +0 -1
- package/script/src/cli/localDevLock.js +0 -320
- package/script/src/cli/localDevPackage.d.ts +0 -172
- package/script/src/cli/localDevPackage.d.ts.map +0 -1
- package/script/src/cli/localDevPackage.js +0 -635
- package/script/src/cli/managedFiles.d.ts +0 -131
- package/script/src/cli/managedFiles.d.ts.map +0 -1
- package/script/src/cli/managedFiles.js +0 -536
- package/script/src/cli/migrationEnv.d.ts +0 -63
- package/script/src/cli/migrationEnv.d.ts.map +0 -1
- package/script/src/cli/migrationEnv.js +0 -217
- package/script/src/cli/mod.d.ts +0 -581
- package/script/src/cli/mod.d.ts.map +0 -1
- package/script/src/cli/mod.js +0 -16850
- package/script/src/cli/projectSkills.d.ts +0 -109
- package/script/src/cli/projectSkills.d.ts.map +0 -1
- package/script/src/cli/projectSkills.js +0 -749
- package/script/src/cli/projectTooling.d.ts +0 -164
- package/script/src/cli/projectTooling.d.ts.map +0 -1
- package/script/src/cli/projectTooling.js +0 -847
- package/script/src/cli/releaseConfig.d.ts +0 -10
- package/script/src/cli/releaseConfig.d.ts.map +0 -1
- package/script/src/cli/releaseConfig.js +0 -26
- package/script/src/cli/releaseCredentials.d.ts +0 -32
- package/script/src/cli/releaseCredentials.d.ts.map +0 -1
- package/script/src/cli/releaseCredentials.js +0 -392
- package/script/src/cli/releaseTrust.d.ts +0 -39
- package/script/src/cli/releaseTrust.d.ts.map +0 -1
- package/script/src/cli/releaseTrust.js +0 -130
- package/script/src/cli/releaseTrustCommand.d.ts +0 -18
- package/script/src/cli/releaseTrustCommand.d.ts.map +0 -1
- package/script/src/cli/releaseTrustCommand.js +0 -145
- package/script/src/cli/vercelBuildEnv.d.ts +0 -62
- package/script/src/cli/vercelBuildEnv.d.ts.map +0 -1
- package/script/src/cli/vercelBuildEnv.js +0 -401
- package/script/src/cli/vercelProjectRelease.d.ts +0 -38
- package/script/src/cli/vercelProjectRelease.d.ts.map +0 -1
- package/script/src/cli/vercelProjectRelease.js +0 -607
- package/script/src/clientData/identity.d.ts +0 -89
- package/script/src/clientData/identity.d.ts.map +0 -1
- package/script/src/clientData/identity.js +0 -134
- package/script/src/clientData/mod.d.ts +0 -3
- package/script/src/clientData/mod.d.ts.map +0 -1
- package/script/src/clientData/mod.js +0 -18
- package/script/src/files/client.d.ts +0 -29
- package/script/src/files/client.d.ts.map +0 -1
- package/script/src/files/client.js +0 -45
- package/script/src/files/errors.d.ts +0 -37
- package/script/src/files/errors.d.ts.map +0 -1
- package/script/src/files/errors.js +0 -76
- package/script/src/files/hash.d.ts +0 -15
- package/script/src/files/hash.d.ts.map +0 -1
- package/script/src/files/hash.js +0 -89
- package/script/src/files/memory.d.ts +0 -29
- package/script/src/files/memory.d.ts.map +0 -1
- package/script/src/files/memory.js +0 -113
- package/script/src/files/metadata.d.ts +0 -10
- package/script/src/files/metadata.d.ts.map +0 -1
- package/script/src/files/metadata.js +0 -189
- package/script/src/files/mod.d.ts +0 -10
- package/script/src/files/mod.d.ts.map +0 -1
- package/script/src/files/mod.js +0 -25
- package/script/src/files/s3.d.ts +0 -29
- package/script/src/files/s3.d.ts.map +0 -1
- package/script/src/files/s3.js +0 -110
- package/script/src/files/service.d.ts +0 -27
- package/script/src/files/service.d.ts.map +0 -1
- package/script/src/files/service.js +0 -139
- package/script/src/files/types.d.ts +0 -134
- package/script/src/files/types.d.ts.map +0 -1
- package/script/src/files/types.js +0 -2
- package/script/src/jobs/catalog.d.ts +0 -32
- package/script/src/jobs/catalog.d.ts.map +0 -1
- package/script/src/jobs/catalog.js +0 -223
- package/script/src/jobs/controller.d.ts +0 -41
- package/script/src/jobs/controller.d.ts.map +0 -1
- package/script/src/jobs/controller.js +0 -151
- package/script/src/jobs/direct.d.ts +0 -36
- package/script/src/jobs/direct.d.ts.map +0 -1
- package/script/src/jobs/direct.js +0 -128
- package/script/src/jobs/events.d.ts +0 -23
- package/script/src/jobs/events.d.ts.map +0 -1
- package/script/src/jobs/events.js +0 -50
- package/script/src/jobs/format.d.ts +0 -16
- package/script/src/jobs/format.d.ts.map +0 -1
- package/script/src/jobs/format.js +0 -193
- package/script/src/jobs/http.d.ts +0 -22
- package/script/src/jobs/http.d.ts.map +0 -1
- package/script/src/jobs/http.js +0 -50
- package/script/src/jobs/log.d.ts +0 -2
- package/script/src/jobs/log.d.ts.map +0 -1
- package/script/src/jobs/log.js +0 -13
- package/script/src/jobs/mod.d.ts +0 -11
- package/script/src/jobs/mod.d.ts.map +0 -1
- package/script/src/jobs/mod.js +0 -26
- package/script/src/jobs/run.d.ts +0 -39
- package/script/src/jobs/run.d.ts.map +0 -1
- package/script/src/jobs/run.js +0 -86
- package/script/src/jobs/sanitize.d.ts +0 -30
- package/script/src/jobs/sanitize.d.ts.map +0 -1
- package/script/src/jobs/sanitize.js +0 -97
- package/script/src/jobs/types.d.ts +0 -31
- package/script/src/jobs/types.d.ts.map +0 -1
- package/script/src/jobs/types.js +0 -2
- package/script/src/mail/errors.d.ts +0 -33
- package/script/src/mail/errors.d.ts.map +0 -1
- package/script/src/mail/errors.js +0 -97
- package/script/src/mail/memory.d.ts +0 -30
- package/script/src/mail/memory.d.ts.map +0 -1
- package/script/src/mail/memory.js +0 -345
- package/script/src/mail/mod.d.ts +0 -7
- package/script/src/mail/mod.d.ts.map +0 -1
- package/script/src/mail/mod.js +0 -22
- package/script/src/mail/postal.d.ts +0 -57
- package/script/src/mail/postal.d.ts.map +0 -1
- package/script/src/mail/postal.js +0 -251
- package/script/src/mail/retry.d.ts +0 -9
- package/script/src/mail/retry.d.ts.map +0 -1
- package/script/src/mail/retry.js +0 -22
- package/script/src/mail/sender.d.ts +0 -5
- package/script/src/mail/sender.d.ts.map +0 -1
- package/script/src/mail/sender.js +0 -52
- package/script/src/mail/service.d.ts +0 -23
- package/script/src/mail/service.d.ts.map +0 -1
- package/script/src/mail/service.js +0 -191
- package/script/src/mail/types.d.ts +0 -176
- package/script/src/mail/types.d.ts.map +0 -1
- package/script/src/mail/types.js +0 -2
- package/script/src/mui/apiKeys.d.ts +0 -171
- package/script/src/mui/apiKeys.d.ts.map +0 -1
- package/script/src/mui/apiKeys.js +0 -470
- package/script/src/mui/apiKeysView.d.ts +0 -193
- package/script/src/mui/apiKeysView.d.ts.map +0 -1
- package/script/src/mui/apiKeysView.js +0 -331
- package/script/src/mui/confirm.d.ts +0 -12
- package/script/src/mui/confirm.d.ts.map +0 -1
- package/script/src/mui/confirm.js +0 -85
- package/script/src/mui/mail.d.ts +0 -29
- package/script/src/mui/mail.d.ts.map +0 -1
- package/script/src/mui/mail.js +0 -159
- package/script/src/mui/mailView.d.ts +0 -20
- package/script/src/mui/mailView.d.ts.map +0 -1
- package/script/src/mui/mailView.js +0 -32
- package/script/src/mui/mod.d.ts +0 -5
- package/script/src/mui/mod.d.ts.map +0 -1
- package/script/src/mui/mod.js +0 -20
- package/script/src/next/apiKeys/mod.d.ts +0 -71
- package/script/src/next/apiKeys/mod.d.ts.map +0 -1
- package/script/src/next/apiKeys/mod.js +0 -227
- package/script/src/next/auth/client.d.ts.map +0 -1
- package/script/src/next/auth/client.js +0 -39
- package/script/src/next/auth/config.d.ts +0 -62
- package/script/src/next/auth/config.d.ts.map +0 -1
- package/script/src/next/auth/config.js +0 -178
- package/script/src/next/auth/localTestLogin.d.ts +0 -75
- package/script/src/next/auth/localTestLogin.d.ts.map +0 -1
- package/script/src/next/auth/localTestLogin.js +0 -291
- package/script/src/next/auth/mod.d.ts +0 -4
- package/script/src/next/auth/mod.d.ts.map +0 -1
- package/script/src/next/auth/mod.js +0 -19
- package/script/src/next/auth/server.d.ts +0 -44
- package/script/src/next/auth/server.d.ts.map +0 -1
- package/script/src/next/auth/server.js +0 -39
- package/script/src/next/files/mod.d.ts +0 -3
- package/script/src/next/files/mod.d.ts.map +0 -1
- package/script/src/next/files/mod.js +0 -18
- package/script/src/next/files/route.d.ts +0 -99
- package/script/src/next/files/route.d.ts.map +0 -1
- package/script/src/next/files/route.js +0 -353
- package/script/src/next/jobs/list.d.ts +0 -25
- package/script/src/next/jobs/list.d.ts.map +0 -1
- package/script/src/next/jobs/list.js +0 -48
- package/script/src/next/jobs/mod.d.ts +0 -6
- package/script/src/next/jobs/mod.d.ts.map +0 -1
- package/script/src/next/jobs/mod.js +0 -21
- package/script/src/next/jobs/paths.d.ts +0 -14
- package/script/src/next/jobs/paths.d.ts.map +0 -1
- package/script/src/next/jobs/paths.js +0 -47
- package/script/src/next/jobs/route.d.ts +0 -48
- package/script/src/next/jobs/route.d.ts.map +0 -1
- package/script/src/next/jobs/route.js +0 -105
- package/script/src/next/jobs/run.d.ts +0 -58
- package/script/src/next/jobs/run.d.ts.map +0 -1
- package/script/src/next/jobs/run.js +0 -592
- package/script/src/next/jobs/runRequest.d.ts +0 -19
- package/script/src/next/jobs/runRequest.d.ts.map +0 -1
- package/script/src/next/jobs/runRequest.js +0 -81
- package/script/src/next/jobs/stream.d.ts +0 -3
- package/script/src/next/jobs/stream.d.ts.map +0 -1
- package/script/src/next/jobs/stream.js +0 -28
- package/script/src/next/mail/mod.d.ts +0 -3
- package/script/src/next/mail/mod.d.ts.map +0 -1
- package/script/src/next/mail/mod.js +0 -18
- package/script/src/next/mail/route.d.ts +0 -12
- package/script/src/next/mail/route.d.ts.map +0 -1
- package/script/src/next/mail/route.js +0 -46
- package/script/src/next/pwa/mod.d.ts +0 -112
- package/script/src/next/pwa/mod.d.ts.map +0 -1
- package/script/src/next/pwa/mod.js +0 -303
- package/script/src/next/pwa/worker.d.ts +0 -27
- package/script/src/next/pwa/worker.d.ts.map +0 -1
- package/script/src/next/pwa/worker.js +0 -33
- package/script/src/next/secrets/mod.d.ts +0 -108
- package/script/src/next/secrets/mod.d.ts.map +0 -1
- package/script/src/next/secrets/mod.js +0 -218
- package/script/src/secrets/encoding.d.ts +0 -32
- package/script/src/secrets/encoding.d.ts.map +0 -1
- package/script/src/secrets/encoding.js +0 -95
- package/script/src/secrets/errors.d.ts +0 -45
- package/script/src/secrets/errors.d.ts.map +0 -1
- package/script/src/secrets/errors.js +0 -45
- package/script/src/secrets/fingerprint.d.ts +0 -43
- package/script/src/secrets/fingerprint.d.ts.map +0 -1
- package/script/src/secrets/fingerprint.js +0 -92
- package/script/src/secrets/frame.d.ts +0 -34
- package/script/src/secrets/frame.d.ts.map +0 -1
- package/script/src/secrets/frame.js +0 -91
- package/script/src/secrets/keyring.d.ts +0 -62
- package/script/src/secrets/keyring.d.ts.map +0 -1
- package/script/src/secrets/keyring.js +0 -202
- package/script/src/secrets/legacy.d.ts +0 -60
- package/script/src/secrets/legacy.d.ts.map +0 -1
- package/script/src/secrets/legacy.js +0 -186
- package/script/src/secrets/maintenance.d.ts +0 -173
- package/script/src/secrets/maintenance.d.ts.map +0 -1
- package/script/src/secrets/maintenance.js +0 -323
- package/script/src/secrets/mod.d.ts +0 -6
- package/script/src/secrets/mod.d.ts.map +0 -1
- package/script/src/secrets/mod.js +0 -24
- package/script/src/secrets/secrets.d.ts +0 -192
- package/script/src/secrets/secrets.d.ts.map +0 -1
- package/script/src/secrets/secrets.js +0 -532
|
@@ -0,0 +1,926 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertWellFormed,
|
|
3
|
+
decodeUtf8,
|
|
4
|
+
encodeUtf8,
|
|
5
|
+
fromBase64Url,
|
|
6
|
+
pae,
|
|
7
|
+
toBase64Url,
|
|
8
|
+
} from "./encoding.ts";
|
|
9
|
+
import {
|
|
10
|
+
type SecretFailureReason,
|
|
11
|
+
SecretsKeyError,
|
|
12
|
+
SecretsKeyMismatchError,
|
|
13
|
+
SecretUnreadableError,
|
|
14
|
+
} from "./errors.ts";
|
|
15
|
+
import {
|
|
16
|
+
type ExpectedSecretKey,
|
|
17
|
+
parseExpectedSecretKeys,
|
|
18
|
+
secretKeyFingerprint,
|
|
19
|
+
} from "./fingerprint.ts";
|
|
20
|
+
import {
|
|
21
|
+
decodeFrame,
|
|
22
|
+
encodeFrame,
|
|
23
|
+
FRAME_BLOCK_BYTES,
|
|
24
|
+
type SecretFrame,
|
|
25
|
+
type SecretPayloadKind,
|
|
26
|
+
} from "./frame.ts";
|
|
27
|
+
import {
|
|
28
|
+
isSecretKeyId,
|
|
29
|
+
parseSecretKeyId,
|
|
30
|
+
type SecretKeyring,
|
|
31
|
+
SECRETS_KEY_BYTES,
|
|
32
|
+
} from "./keyring.ts";
|
|
33
|
+
|
|
34
|
+
/** Prefix and version of the sealed string format. */
|
|
35
|
+
export const SEALED_FORMAT = "ls1";
|
|
36
|
+
/** Prefix and version of the keyed fingerprint format. */
|
|
37
|
+
export const KEYED_FINGERPRINT_FORMAT = "lm1";
|
|
38
|
+
|
|
39
|
+
const DOMAIN = "loom-secrets";
|
|
40
|
+
const NONCE_BYTES = 12;
|
|
41
|
+
const TAG_BYTES = 16;
|
|
42
|
+
const MAC_BYTES = 32;
|
|
43
|
+
// 32 bytes in unpadded base64url.
|
|
44
|
+
const MAC_TEXT_LENGTH = 43;
|
|
45
|
+
const PURPOSE_PATTERN = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;
|
|
46
|
+
const MAX_PURPOSE_LENGTH = 64;
|
|
47
|
+
const MAX_KEY_ID_DIGITS = 9;
|
|
48
|
+
// Characters, not bytes: room for a payload a little over 1.5 MiB.
|
|
49
|
+
const DEFAULT_MAX_LENGTH = 2_097_152;
|
|
50
|
+
const DEFAULT_SKEW_SECONDS = 60;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Non-secret context a sealed value is tied to, such as its owner and the
|
|
54
|
+
* destination it may be sent to. It is not stored: the caller supplies the
|
|
55
|
+
* same entries to `seal` and to `open`, and opening fails if any differ.
|
|
56
|
+
*
|
|
57
|
+
* Use stable identifiers the app never transforms. Changing how a purpose is
|
|
58
|
+
* bound makes its existing values unreadable, so a new binding scheme is a new
|
|
59
|
+
* purpose name.
|
|
60
|
+
*/
|
|
61
|
+
export type SecretBinding = Readonly<Record<string, string>>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Reported to `onFailure` for every value that could not be opened, and for
|
|
65
|
+
* every stored fingerprint that could not be checked.
|
|
66
|
+
*/
|
|
67
|
+
export interface SecretFailureEvent {
|
|
68
|
+
purpose: string;
|
|
69
|
+
/** Key version named in the string; `null` when the string is malformed. */
|
|
70
|
+
keyId: number | null;
|
|
71
|
+
reason: SecretFailureReason;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Options for {@link createSecrets}. */
|
|
75
|
+
export interface CreateSecretsOptions {
|
|
76
|
+
keys: SecretKeyring;
|
|
77
|
+
/**
|
|
78
|
+
* The keys this environment is expected to hold. When given, a key is used
|
|
79
|
+
* only if it is listed, not retired and matches its recorded fingerprint,
|
|
80
|
+
* and values are sealed only under the one marked `active`. Omit it where
|
|
81
|
+
* no fingerprints are recorded, such as local development.
|
|
82
|
+
*/
|
|
83
|
+
expectedKeys?: readonly ExpectedSecretKey[] | undefined;
|
|
84
|
+
/** Milliseconds since the Unix epoch. Defaults to `Date.now`. */
|
|
85
|
+
now?: (() => number) | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Clock difference, in seconds, tolerated when bounding a future expiry.
|
|
88
|
+
* Defaults to 60.
|
|
89
|
+
*/
|
|
90
|
+
skewSeconds?: number | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Called for every failed open, for logging and metrics. It receives no
|
|
93
|
+
* plaintext, ciphertext or binding. Anything it throws, or a promise it
|
|
94
|
+
* returns that rejects, is ignored.
|
|
95
|
+
*/
|
|
96
|
+
onFailure?: ((event: SecretFailureEvent) => unknown) | undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Options for one purpose. */
|
|
100
|
+
export interface SecretPurposeOptions {
|
|
101
|
+
/** Allow an empty binding. Off by default so a binding is never forgotten. */
|
|
102
|
+
unbound?: boolean | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Lifetime of every value sealed under this purpose. A caller may shorten
|
|
105
|
+
* it per call but not extend it, and `open` rejects a value with no expiry.
|
|
106
|
+
* Reducing it later makes values sealed under the longer lifetime unreadable
|
|
107
|
+
* until they are within the new lifetime of their expiry.
|
|
108
|
+
*/
|
|
109
|
+
ttlSeconds?: number | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Longest sealed string accepted, in characters. Set a small value for
|
|
112
|
+
* purposes whose strings come back from a caller. Defaults to 2 MiB.
|
|
113
|
+
*/
|
|
114
|
+
maxLength?: number | undefined;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Per-call options for sealing. */
|
|
118
|
+
export interface SealOptions {
|
|
119
|
+
/** Lifetime for this value. With a purpose lifetime it may only be shorter. */
|
|
120
|
+
ttlSeconds?: number | undefined;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Per-call options for {@link SecretPurpose.mac}. */
|
|
124
|
+
export interface MacOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Compute under this key version instead of the active one. Needed to look
|
|
127
|
+
* a value up by fingerprint after a rotation, when stored fingerprints are
|
|
128
|
+
* still under an older key. Throws if that version is not configured.
|
|
129
|
+
*/
|
|
130
|
+
keyId?: number | undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** A named use of the keyring, with its own derived encryption key. */
|
|
134
|
+
export interface SecretPurpose {
|
|
135
|
+
readonly name: string;
|
|
136
|
+
seal(
|
|
137
|
+
value: string,
|
|
138
|
+
binding: SecretBinding,
|
|
139
|
+
options?: SealOptions,
|
|
140
|
+
): Promise<string>;
|
|
141
|
+
sealJson(
|
|
142
|
+
value: unknown,
|
|
143
|
+
binding: SecretBinding,
|
|
144
|
+
options?: SealOptions,
|
|
145
|
+
): Promise<string>;
|
|
146
|
+
sealBytes(
|
|
147
|
+
value: Uint8Array,
|
|
148
|
+
binding: SecretBinding,
|
|
149
|
+
options?: SealOptions,
|
|
150
|
+
): Promise<string>;
|
|
151
|
+
/** Throws {@link SecretUnreadableError} on any failure. */
|
|
152
|
+
open(sealed: string, binding: SecretBinding): Promise<string>;
|
|
153
|
+
openJson(sealed: string, binding: SecretBinding): Promise<unknown>;
|
|
154
|
+
openBytes(sealed: string, binding: SecretBinding): Promise<Uint8Array>;
|
|
155
|
+
/** Like `open`, but `null` when the value cannot be read. */
|
|
156
|
+
tryOpen(sealed: string, binding: SecretBinding): Promise<string | null>;
|
|
157
|
+
/** Wrapped in an object so that a sealed JSON `null` differs from a failure. */
|
|
158
|
+
tryOpenJson(
|
|
159
|
+
sealed: string,
|
|
160
|
+
binding: SecretBinding,
|
|
161
|
+
): Promise<{ value: unknown } | null>;
|
|
162
|
+
tryOpenBytes(
|
|
163
|
+
sealed: string,
|
|
164
|
+
binding: SecretBinding,
|
|
165
|
+
): Promise<Uint8Array | null>;
|
|
166
|
+
/** Key version named in a sealed string, or `null` when it does not parse. */
|
|
167
|
+
keyId(sealed: string): number | null;
|
|
168
|
+
/**
|
|
169
|
+
* Whether a sealed string is under a key other than the active one. `false`
|
|
170
|
+
* for a string that does not parse: there is nothing `reseal` could do.
|
|
171
|
+
* Rejects with {@link SecretsKeyError} when the active key cannot be
|
|
172
|
+
* determined, so do not call it on a path that only needs to read.
|
|
173
|
+
*/
|
|
174
|
+
needsReseal(sealed: string): Promise<boolean>;
|
|
175
|
+
/**
|
|
176
|
+
* Re-encrypts under the active key. The frame is carried over unchanged, so
|
|
177
|
+
* the kind and any expiry survive; an expired value is refused. Returns the
|
|
178
|
+
* input when it is already under the active key.
|
|
179
|
+
*/
|
|
180
|
+
reseal(sealed: string, binding: SecretBinding): Promise<string>;
|
|
181
|
+
/**
|
|
182
|
+
* A keyed fingerprint of `text`, for matching a value without storing it:
|
|
183
|
+
* `lm1.<key id>.<HMAC-SHA-256>`. Equal inputs give equal strings under one
|
|
184
|
+
* key, purpose and binding, and nothing about the text can be recovered
|
|
185
|
+
* from it without the key.
|
|
186
|
+
*
|
|
187
|
+
* The text is used exactly as given: no trimming, case folding or Unicode
|
|
188
|
+
* normalisation. Equal text under an equal binding is visibly equal to
|
|
189
|
+
* anyone who can read where the fingerprints are stored, so include an
|
|
190
|
+
* owner in the binding where that matters.
|
|
191
|
+
*
|
|
192
|
+
* A fingerprint cannot be recomputed without its input, so it moves to a new
|
|
193
|
+
* key only when the input is seen again, and it is not a stable lookup key
|
|
194
|
+
* across a rotation: look up under each key version still in use (see
|
|
195
|
+
* {@link MacOptions.keyId}). An app that wants to retire a key must keep a
|
|
196
|
+
* way to recover the input, for example by sealing it beside the value the
|
|
197
|
+
* fingerprint indexes.
|
|
198
|
+
*/
|
|
199
|
+
mac(
|
|
200
|
+
text: string,
|
|
201
|
+
binding: SecretBinding,
|
|
202
|
+
options?: MacOptions,
|
|
203
|
+
): Promise<string>;
|
|
204
|
+
/**
|
|
205
|
+
* Whether `stored` is the fingerprint of `text`, under whichever key version
|
|
206
|
+
* `stored` names. `false` when it does not parse or its key version is not
|
|
207
|
+
* configured; both are also reported to `onFailure`, since a missing key
|
|
208
|
+
* otherwise looks like an ordinary mismatch. Throws {@link SecretsKeyError}
|
|
209
|
+
* when that key is configured but unusable.
|
|
210
|
+
*/
|
|
211
|
+
macMatches(
|
|
212
|
+
stored: string,
|
|
213
|
+
text: string,
|
|
214
|
+
binding: SecretBinding,
|
|
215
|
+
): Promise<boolean>;
|
|
216
|
+
/**
|
|
217
|
+
* Whether a fingerprint is under a key other than the active one, so the
|
|
218
|
+
* caller should replace it the next time it sees the input. Like
|
|
219
|
+
* `needsReseal`, it rejects when the active key cannot be determined.
|
|
220
|
+
*/
|
|
221
|
+
macNeedsRefresh(stored: string): Promise<boolean>;
|
|
222
|
+
/**
|
|
223
|
+
* {@link Secrets.assertReady} for the instance this purpose belongs to, so
|
|
224
|
+
* that code holding only a purpose checks the keys that purpose will use.
|
|
225
|
+
*/
|
|
226
|
+
assertReady(): Promise<SecretsReadiness>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** What {@link Secrets.assertReady} found. Nothing in it is secret. */
|
|
230
|
+
export interface SecretsReadiness {
|
|
231
|
+
/**
|
|
232
|
+
* Whether an expected-key list was applied, so every key below was shown to
|
|
233
|
+
* match its recorded fingerprint. `false` means only that the pointer names
|
|
234
|
+
* a usable key: nothing says it is the key the operator saved. A production
|
|
235
|
+
* health check should require `true`.
|
|
236
|
+
*/
|
|
237
|
+
verified: boolean;
|
|
238
|
+
activeKeyId: number;
|
|
239
|
+
/** Every key that was checked, with the fingerprint computed from it. */
|
|
240
|
+
keys: { id: number; fingerprint: string }[];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** What {@link createSecrets} returns. */
|
|
244
|
+
export interface Secrets {
|
|
245
|
+
purpose(name: string, options?: SecretPurposeOptions): SecretPurpose;
|
|
246
|
+
/**
|
|
247
|
+
* Checks the keys without sealing or opening anything, for a health route
|
|
248
|
+
* or a post-deploy smoke test: the pointer names a usable key, and, when an
|
|
249
|
+
* expected-key list was given, every listed key that is not retired exists
|
|
250
|
+
* and matches its fingerprint and the pointer names the active one.
|
|
251
|
+
*
|
|
252
|
+
* Throws {@link SecretsKeyError} naming the first problem. Without it, a bad
|
|
253
|
+
* pointer shows only when the first write fails.
|
|
254
|
+
*/
|
|
255
|
+
assertReady(): Promise<SecretsReadiness>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
interface ParsedSealed {
|
|
259
|
+
keyId: number;
|
|
260
|
+
nonce: Uint8Array<ArrayBuffer>;
|
|
261
|
+
ciphertext: Uint8Array<ArrayBuffer>;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function parseSealed(sealed: unknown, maxLength: number): ParsedSealed | null {
|
|
265
|
+
if (typeof sealed !== "string" || sealed.length > maxLength) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
const parts = sealed.split(".");
|
|
269
|
+
if (parts.length !== 4 || parts[0] !== SEALED_FORMAT) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
const keyId = parseSecretKeyId(parts[1]);
|
|
273
|
+
const nonce = fromBase64Url(parts[2]);
|
|
274
|
+
const ciphertext = fromBase64Url(parts[3]);
|
|
275
|
+
if (
|
|
276
|
+
keyId === null ||
|
|
277
|
+
nonce === null ||
|
|
278
|
+
nonce.length !== NONCE_BYTES ||
|
|
279
|
+
ciphertext === null ||
|
|
280
|
+
ciphertext.length < FRAME_BLOCK_BYTES + TAG_BYTES ||
|
|
281
|
+
(ciphertext.length - TAG_BYTES) % FRAME_BLOCK_BYTES !== 0
|
|
282
|
+
) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
return { keyId, nonce, ciphertext };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function parseFingerprint(
|
|
289
|
+
stored: unknown,
|
|
290
|
+
): { keyId: number; tag: Uint8Array<ArrayBuffer> } | null {
|
|
291
|
+
// Bounded before splitting: the string may come from an untrusted row.
|
|
292
|
+
if (typeof stored !== "string" || stored.length > 64) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
const parts = stored.split(".");
|
|
296
|
+
if (parts.length !== 3 || parts[0] !== KEYED_FINGERPRINT_FORMAT) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
const keyId = parseSecretKeyId(parts[1]);
|
|
300
|
+
const tag =
|
|
301
|
+
parts[2].length === MAC_TEXT_LENGTH ? fromBase64Url(parts[2]) : null;
|
|
302
|
+
if (keyId === null || tag === null || tag.length !== MAC_BYTES) {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
return { keyId, tag };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Validates a binding and flattens it to sorted `key, value` pieces.
|
|
310
|
+
*
|
|
311
|
+
* Callers do this once, before any `await`, so that a binding object mutated
|
|
312
|
+
* while an operation is pending cannot change what is authenticated.
|
|
313
|
+
*/
|
|
314
|
+
function bindingPieces(binding: SecretBinding, unbound: boolean): string[] {
|
|
315
|
+
const prototype =
|
|
316
|
+
binding !== null && typeof binding === "object"
|
|
317
|
+
? Object.getPrototypeOf(binding)
|
|
318
|
+
: undefined;
|
|
319
|
+
// A Map, Date or class instance has no own enumerable entries and would
|
|
320
|
+
// otherwise pass for an empty binding.
|
|
321
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
322
|
+
throw new TypeError("A secret binding must be a plain object of strings.");
|
|
323
|
+
}
|
|
324
|
+
const keys = Object.keys(binding).sort();
|
|
325
|
+
if (keys.length === 0 && !unbound) {
|
|
326
|
+
throw new TypeError(
|
|
327
|
+
"A secret binding is required. Declare the purpose `unbound` to seal without one.",
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
return keys.flatMap((key) => {
|
|
331
|
+
if (key === "") {
|
|
332
|
+
throw new TypeError("A secret binding key must not be empty.");
|
|
333
|
+
}
|
|
334
|
+
return [
|
|
335
|
+
assertWellFormed(key, "A secret binding key"),
|
|
336
|
+
assertWellFormed(binding[key], `Secret binding "${key}"`),
|
|
337
|
+
];
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function positiveSeconds(value: unknown, what: string): number {
|
|
342
|
+
if (!Number.isSafeInteger(value) || (value as number) <= 0) {
|
|
343
|
+
throw new RangeError(`${what} must be a positive whole number of seconds.`);
|
|
344
|
+
}
|
|
345
|
+
return value as number;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Creates the sealing and opening operations over a keyring.
|
|
350
|
+
*
|
|
351
|
+
* Each purpose encrypts with its own key, derived with HKDF from the keyring's
|
|
352
|
+
* key, so a value sealed for one purpose cannot be opened as another. The
|
|
353
|
+
* format version, key version, purpose and binding are all authenticated.
|
|
354
|
+
*/
|
|
355
|
+
export function createSecrets(options: CreateSecretsOptions): Secrets {
|
|
356
|
+
const { keys } = options;
|
|
357
|
+
const now = options.now ?? Date.now;
|
|
358
|
+
const skewSeconds = options.skewSeconds ?? DEFAULT_SKEW_SECONDS;
|
|
359
|
+
if (!Number.isSafeInteger(skewSeconds) || skewSeconds < 0) {
|
|
360
|
+
throw new RangeError("skewSeconds must be a non-negative whole number.");
|
|
361
|
+
}
|
|
362
|
+
const subtle = globalThis.crypto.subtle;
|
|
363
|
+
const baseKeys = new Map<number, Promise<CryptoKey | null>>();
|
|
364
|
+
// Copied and validated once, so later changes to the caller's array cannot
|
|
365
|
+
// loosen what was checked.
|
|
366
|
+
const expected =
|
|
367
|
+
options.expectedKeys === undefined
|
|
368
|
+
? undefined
|
|
369
|
+
: new Map(
|
|
370
|
+
parseExpectedSecretKeys(options.expectedKeys).map((entry) => [
|
|
371
|
+
entry.id,
|
|
372
|
+
entry,
|
|
373
|
+
]),
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
/** The raw key for a version, checked against the expected-key list. */
|
|
377
|
+
async function checkedKey(keyId: number): Promise<Uint8Array | null> {
|
|
378
|
+
const entry = expected?.get(keyId);
|
|
379
|
+
if (expected && entry === undefined) {
|
|
380
|
+
// An undeclared variable may be a reused number or a stray paste.
|
|
381
|
+
if ((await keys.key(keyId)) === null) {
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
throw new SecretsKeyError(
|
|
385
|
+
`Key version ${keyId} is configured but not in the expected key list.`,
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
if (entry?.state === "retired") {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
const raw = await keys.key(keyId);
|
|
392
|
+
if (raw === null) {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
// A custom keyring is trusted for where a key comes from, not for its
|
|
396
|
+
// shape: a short key would seal and open without complaint.
|
|
397
|
+
if (!(raw instanceof Uint8Array) || raw.length !== SECRETS_KEY_BYTES) {
|
|
398
|
+
throw new SecretsKeyError(
|
|
399
|
+
`Key version ${keyId} must be exactly ${SECRETS_KEY_BYTES} bytes.`,
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
if (entry && (await secretKeyFingerprint(raw)) !== entry.fingerprint) {
|
|
403
|
+
throw new SecretsKeyMismatchError(
|
|
404
|
+
`Key version ${keyId} does not match its recorded fingerprint.`,
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
return raw;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** HKDF input for a key version, imported once and kept non-extractable. */
|
|
411
|
+
function baseKey(keyId: number): Promise<CryptoKey | null> {
|
|
412
|
+
let pending = baseKeys.get(keyId);
|
|
413
|
+
if (!pending) {
|
|
414
|
+
pending = checkedKey(keyId).then((raw) =>
|
|
415
|
+
raw === null
|
|
416
|
+
? null
|
|
417
|
+
: subtle.importKey("raw", new Uint8Array(raw), "HKDF", false, [
|
|
418
|
+
"deriveKey",
|
|
419
|
+
]),
|
|
420
|
+
);
|
|
421
|
+
baseKeys.set(keyId, pending);
|
|
422
|
+
// A failed or absent key is looked up again next time.
|
|
423
|
+
pending.then(
|
|
424
|
+
(key) => key === null && baseKeys.delete(keyId),
|
|
425
|
+
() => baseKeys.delete(keyId),
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
return pending;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
async function activeKeyId(): Promise<number> {
|
|
432
|
+
const keyId = await keys.activeKeyId();
|
|
433
|
+
if (!isSecretKeyId(keyId)) {
|
|
434
|
+
throw new SecretsKeyError(
|
|
435
|
+
"The keyring's active key version is not a valid key version.",
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
// With a list, only the key recorded as active may encrypt, so a pointer
|
|
439
|
+
// left on, or moved to, a decrypt-only key is caught before it is used.
|
|
440
|
+
if (expected && expected.get(keyId)?.state !== "active") {
|
|
441
|
+
throw new SecretsKeyError(
|
|
442
|
+
`Key version ${keyId} is the active pointer but is not the key recorded as active.`,
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
return keyId;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function report(event: SecretFailureEvent): void {
|
|
449
|
+
try {
|
|
450
|
+
// A logging hook must not turn a failed open into a different error, or
|
|
451
|
+
// into an unhandled rejection that can end the process.
|
|
452
|
+
Promise.resolve(options.onFailure?.(event)).catch(() => {});
|
|
453
|
+
} catch {
|
|
454
|
+
// Ignored for the same reason.
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const secrets: Secrets = {
|
|
459
|
+
async assertReady() {
|
|
460
|
+
const active = await activeKeyId();
|
|
461
|
+
const ids = expected
|
|
462
|
+
? [...expected]
|
|
463
|
+
.filter(([, entry]) => entry.state !== "retired")
|
|
464
|
+
.map(([id]) => id)
|
|
465
|
+
: [active];
|
|
466
|
+
const checked: SecretsReadiness["keys"] = [];
|
|
467
|
+
for (const id of ids) {
|
|
468
|
+
const raw = await checkedKey(id);
|
|
469
|
+
if (raw === null) {
|
|
470
|
+
throw new SecretsKeyError(`Key version ${id} is not configured.`);
|
|
471
|
+
}
|
|
472
|
+
checked.push({
|
|
473
|
+
id,
|
|
474
|
+
// Already compared with the recorded value when there is one.
|
|
475
|
+
fingerprint:
|
|
476
|
+
expected?.get(id)?.fingerprint ?? (await secretKeyFingerprint(raw)),
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
verified: expected !== undefined,
|
|
481
|
+
activeKeyId: active,
|
|
482
|
+
keys: checked,
|
|
483
|
+
};
|
|
484
|
+
},
|
|
485
|
+
purpose(name, purposeOptions = {}) {
|
|
486
|
+
if (
|
|
487
|
+
typeof name !== "string" ||
|
|
488
|
+
name.length > MAX_PURPOSE_LENGTH ||
|
|
489
|
+
!PURPOSE_PATTERN.test(name)
|
|
490
|
+
) {
|
|
491
|
+
throw new TypeError(
|
|
492
|
+
"A secret purpose is lowercase letters and digits separated by dots or dashes, at most 64 characters.",
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
const unbound = purposeOptions.unbound === true;
|
|
496
|
+
const purposeTtl =
|
|
497
|
+
purposeOptions.ttlSeconds === undefined
|
|
498
|
+
? undefined
|
|
499
|
+
: positiveSeconds(purposeOptions.ttlSeconds, "A purpose ttlSeconds");
|
|
500
|
+
const maxLength = purposeOptions.maxLength ?? DEFAULT_MAX_LENGTH;
|
|
501
|
+
if (!Number.isSafeInteger(maxLength) || maxLength <= 0) {
|
|
502
|
+
throw new RangeError("A purpose maxLength must be a positive integer.");
|
|
503
|
+
}
|
|
504
|
+
const cipherKeys = new Map<number, Promise<CryptoKey | null>>();
|
|
505
|
+
|
|
506
|
+
/** This purpose's AES-256-GCM key under one key version. */
|
|
507
|
+
function cipherKey(keyId: number): Promise<CryptoKey | null> {
|
|
508
|
+
let pending = cipherKeys.get(keyId);
|
|
509
|
+
if (!pending) {
|
|
510
|
+
pending = baseKey(keyId).then((base) =>
|
|
511
|
+
base === null
|
|
512
|
+
? null
|
|
513
|
+
: subtle.deriveKey(
|
|
514
|
+
{
|
|
515
|
+
name: "HKDF",
|
|
516
|
+
hash: "SHA-256",
|
|
517
|
+
salt: new Uint8Array(0),
|
|
518
|
+
info: pae([DOMAIN, SEALED_FORMAT, "key", name]),
|
|
519
|
+
},
|
|
520
|
+
base,
|
|
521
|
+
{ name: "AES-GCM", length: 256 },
|
|
522
|
+
false,
|
|
523
|
+
["encrypt", "decrypt"],
|
|
524
|
+
),
|
|
525
|
+
);
|
|
526
|
+
cipherKeys.set(keyId, pending);
|
|
527
|
+
pending.then(
|
|
528
|
+
(key) => key === null && cipherKeys.delete(keyId),
|
|
529
|
+
() => cipherKeys.delete(keyId),
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
return pending;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const macKeys = new Map<number, Promise<CryptoKey | null>>();
|
|
536
|
+
|
|
537
|
+
/** This purpose's HMAC-SHA-256 key under one key version. */
|
|
538
|
+
function macKey(keyId: number): Promise<CryptoKey | null> {
|
|
539
|
+
let pending = macKeys.get(keyId);
|
|
540
|
+
if (!pending) {
|
|
541
|
+
pending = baseKey(keyId).then((base) =>
|
|
542
|
+
base === null
|
|
543
|
+
? null
|
|
544
|
+
: subtle.deriveKey(
|
|
545
|
+
{
|
|
546
|
+
name: "HKDF",
|
|
547
|
+
hash: "SHA-256",
|
|
548
|
+
salt: new Uint8Array(0),
|
|
549
|
+
// A different label from the encryption key, so the two keys
|
|
550
|
+
// are independent although they share a source.
|
|
551
|
+
info: pae([DOMAIN, SEALED_FORMAT, "mac", name]),
|
|
552
|
+
},
|
|
553
|
+
base,
|
|
554
|
+
{ name: "HMAC", hash: "SHA-256", length: MAC_BYTES * 8 },
|
|
555
|
+
false,
|
|
556
|
+
["sign", "verify"],
|
|
557
|
+
),
|
|
558
|
+
);
|
|
559
|
+
macKeys.set(keyId, pending);
|
|
560
|
+
pending.then(
|
|
561
|
+
(key) => key === null && macKeys.delete(keyId),
|
|
562
|
+
() => macKeys.delete(keyId),
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
return pending;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function macInput(text: string, binding: SecretBinding) {
|
|
569
|
+
return pae([
|
|
570
|
+
DOMAIN,
|
|
571
|
+
SEALED_FORMAT,
|
|
572
|
+
"mac-input",
|
|
573
|
+
name,
|
|
574
|
+
assertWellFormed(text, "Fingerprint input"),
|
|
575
|
+
...bindingPieces(binding, unbound),
|
|
576
|
+
]);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function associatedData(keyId: number, pieces: readonly string[]) {
|
|
580
|
+
return pae([
|
|
581
|
+
DOMAIN,
|
|
582
|
+
SEALED_FORMAT,
|
|
583
|
+
"aad",
|
|
584
|
+
String(keyId),
|
|
585
|
+
name,
|
|
586
|
+
...pieces,
|
|
587
|
+
]);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
async function encryptFrame(
|
|
591
|
+
frame: Uint8Array<ArrayBuffer>,
|
|
592
|
+
pieces: readonly string[],
|
|
593
|
+
): Promise<string> {
|
|
594
|
+
const keyId = await activeKeyId();
|
|
595
|
+
const key = await cipherKey(keyId);
|
|
596
|
+
if (key === null) {
|
|
597
|
+
throw new SecretsKeyError(
|
|
598
|
+
`Active key version ${keyId} is not configured.`,
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
const nonce = globalThis.crypto.getRandomValues(
|
|
602
|
+
new Uint8Array(NONCE_BYTES),
|
|
603
|
+
);
|
|
604
|
+
const ciphertext = await subtle.encrypt(
|
|
605
|
+
{
|
|
606
|
+
name: "AES-GCM",
|
|
607
|
+
iv: nonce,
|
|
608
|
+
additionalData: associatedData(keyId, pieces),
|
|
609
|
+
tagLength: TAG_BYTES * 8,
|
|
610
|
+
},
|
|
611
|
+
key,
|
|
612
|
+
frame,
|
|
613
|
+
);
|
|
614
|
+
const sealed = `${SEALED_FORMAT}.${keyId}.${toBase64Url(nonce)}.${toBase64Url(
|
|
615
|
+
new Uint8Array(ciphertext),
|
|
616
|
+
)}`;
|
|
617
|
+
// Measured as if the key version had the most digits it can have, so
|
|
618
|
+
// that a value sealed today can still be resealed under any later key.
|
|
619
|
+
const worstCase =
|
|
620
|
+
sealed.length - String(keyId).length + MAX_KEY_ID_DIGITS;
|
|
621
|
+
if (worstCase > maxLength) {
|
|
622
|
+
throw new RangeError(
|
|
623
|
+
`The sealed value would exceed this purpose's maxLength of ${maxLength}.`,
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
return sealed;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function expiryFor(sealOptions: SealOptions | undefined) {
|
|
630
|
+
const requested =
|
|
631
|
+
sealOptions?.ttlSeconds === undefined
|
|
632
|
+
? undefined
|
|
633
|
+
: positiveSeconds(sealOptions.ttlSeconds, "ttlSeconds");
|
|
634
|
+
if (
|
|
635
|
+
requested !== undefined &&
|
|
636
|
+
purposeTtl !== undefined &&
|
|
637
|
+
requested > purposeTtl
|
|
638
|
+
) {
|
|
639
|
+
throw new RangeError(
|
|
640
|
+
"ttlSeconds may shorten the purpose lifetime, not extend it.",
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
const ttl = requested ?? purposeTtl;
|
|
644
|
+
if (ttl === undefined) {
|
|
645
|
+
return undefined;
|
|
646
|
+
}
|
|
647
|
+
// Rounded up so a value never lives less than the lifetime asked for.
|
|
648
|
+
const expiresAt = Math.ceil(now() / 1000) + ttl;
|
|
649
|
+
if (!Number.isSafeInteger(expiresAt)) {
|
|
650
|
+
throw new RangeError("The clock did not return a usable time.");
|
|
651
|
+
}
|
|
652
|
+
return expiresAt;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
async function sealPayload(
|
|
656
|
+
kind: SecretPayloadKind,
|
|
657
|
+
payload: () => Uint8Array,
|
|
658
|
+
binding: SecretBinding,
|
|
659
|
+
sealOptions: SealOptions | undefined,
|
|
660
|
+
) {
|
|
661
|
+
// Everything taken from the caller is read here, before the first
|
|
662
|
+
// await, so later mutation of their objects cannot change the result.
|
|
663
|
+
const pieces = bindingPieces(binding, unbound);
|
|
664
|
+
const frame = encodeFrame({
|
|
665
|
+
kind,
|
|
666
|
+
payload: payload(),
|
|
667
|
+
expiresAt: expiryFor(sealOptions),
|
|
668
|
+
});
|
|
669
|
+
return await encryptFrame(frame, pieces);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/** Decrypts and checks a sealed string, returning the raw and parsed frame. */
|
|
673
|
+
async function openFrame(
|
|
674
|
+
sealed: string,
|
|
675
|
+
binding: SecretBinding,
|
|
676
|
+
): Promise<{
|
|
677
|
+
parsed: ParsedSealed;
|
|
678
|
+
raw: Uint8Array;
|
|
679
|
+
frame: SecretFrame;
|
|
680
|
+
pieces: readonly string[];
|
|
681
|
+
}> {
|
|
682
|
+
// An invalid binding is a programming error, not an unreadable value.
|
|
683
|
+
const pieces = bindingPieces(binding, unbound);
|
|
684
|
+
const parsed = parseSealed(sealed, maxLength);
|
|
685
|
+
const fail = (reason: SecretFailureReason): never => {
|
|
686
|
+
report({ purpose: name, keyId: parsed?.keyId ?? null, reason });
|
|
687
|
+
throw new SecretUnreadableError(reason);
|
|
688
|
+
};
|
|
689
|
+
if (parsed === null) {
|
|
690
|
+
return fail("malformed");
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
let key: CryptoKey | null;
|
|
694
|
+
try {
|
|
695
|
+
key = await cipherKey(parsed.keyId);
|
|
696
|
+
} catch (error) {
|
|
697
|
+
return fail(
|
|
698
|
+
error instanceof SecretsKeyMismatchError
|
|
699
|
+
? "key-mismatch"
|
|
700
|
+
: "key-unavailable",
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
if (key === null) {
|
|
704
|
+
return fail("unknown-key");
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
let raw: Uint8Array;
|
|
708
|
+
try {
|
|
709
|
+
raw = new Uint8Array(
|
|
710
|
+
await subtle.decrypt(
|
|
711
|
+
{
|
|
712
|
+
name: "AES-GCM",
|
|
713
|
+
iv: parsed.nonce,
|
|
714
|
+
additionalData: associatedData(parsed.keyId, pieces),
|
|
715
|
+
tagLength: TAG_BYTES * 8,
|
|
716
|
+
},
|
|
717
|
+
key,
|
|
718
|
+
parsed.ciphertext,
|
|
719
|
+
),
|
|
720
|
+
);
|
|
721
|
+
} catch {
|
|
722
|
+
return fail("authentication");
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const frame = decodeFrame(raw);
|
|
726
|
+
if (frame === null) {
|
|
727
|
+
return fail("malformed");
|
|
728
|
+
}
|
|
729
|
+
if (frame.expiresAt === undefined) {
|
|
730
|
+
if (purposeTtl !== undefined) {
|
|
731
|
+
return fail("malformed");
|
|
732
|
+
}
|
|
733
|
+
} else {
|
|
734
|
+
const nowSeconds = Math.floor(now() / 1000);
|
|
735
|
+
// Written so that a clock returning NaN fails closed.
|
|
736
|
+
if (!(nowSeconds < frame.expiresAt)) {
|
|
737
|
+
return fail("expired");
|
|
738
|
+
}
|
|
739
|
+
// Nothing this purpose seals can expire later than this, so a later
|
|
740
|
+
// expiry means a wrong clock when sealing, or a different purpose
|
|
741
|
+
// configuration. Either way it must not be honoured.
|
|
742
|
+
if (
|
|
743
|
+
purposeTtl !== undefined &&
|
|
744
|
+
frame.expiresAt > nowSeconds + purposeTtl + skewSeconds
|
|
745
|
+
) {
|
|
746
|
+
return fail("malformed");
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
return { parsed, raw, frame, pieces };
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
async function openPayload(
|
|
753
|
+
kind: SecretPayloadKind,
|
|
754
|
+
sealed: string,
|
|
755
|
+
binding: SecretBinding,
|
|
756
|
+
): Promise<{ parsed: ParsedSealed; payload: Uint8Array<ArrayBuffer> }> {
|
|
757
|
+
const { parsed, frame } = await openFrame(sealed, binding);
|
|
758
|
+
if (frame.kind !== kind) {
|
|
759
|
+
report({ purpose: name, keyId: parsed.keyId, reason: "malformed" });
|
|
760
|
+
throw new SecretUnreadableError("malformed");
|
|
761
|
+
}
|
|
762
|
+
return { parsed, payload: frame.payload };
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function decodeText(parsed: ParsedSealed, payload: Uint8Array): string {
|
|
766
|
+
try {
|
|
767
|
+
return decodeUtf8(payload);
|
|
768
|
+
} catch {
|
|
769
|
+
report({ purpose: name, keyId: parsed.keyId, reason: "malformed" });
|
|
770
|
+
throw new SecretUnreadableError("malformed");
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/** `null` for an unreadable value; programming errors still throw. */
|
|
775
|
+
async function orNull<T>(opening: Promise<T>): Promise<T | null> {
|
|
776
|
+
try {
|
|
777
|
+
return await opening;
|
|
778
|
+
} catch (error) {
|
|
779
|
+
if (error instanceof SecretUnreadableError) {
|
|
780
|
+
return null;
|
|
781
|
+
}
|
|
782
|
+
throw error;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const purpose: SecretPurpose = {
|
|
787
|
+
name,
|
|
788
|
+
seal(value, binding, sealOptions) {
|
|
789
|
+
return sealPayload(
|
|
790
|
+
"text",
|
|
791
|
+
() => encodeUtf8(value, "A sealed value"),
|
|
792
|
+
binding,
|
|
793
|
+
sealOptions,
|
|
794
|
+
);
|
|
795
|
+
},
|
|
796
|
+
sealJson(value, binding, sealOptions) {
|
|
797
|
+
return sealPayload(
|
|
798
|
+
"json",
|
|
799
|
+
() => {
|
|
800
|
+
const json = JSON.stringify(value);
|
|
801
|
+
if (json === undefined) {
|
|
802
|
+
throw new TypeError("The value cannot be represented as JSON.");
|
|
803
|
+
}
|
|
804
|
+
return encodeUtf8(json, "A sealed JSON value");
|
|
805
|
+
},
|
|
806
|
+
binding,
|
|
807
|
+
sealOptions,
|
|
808
|
+
);
|
|
809
|
+
},
|
|
810
|
+
sealBytes(value, binding, sealOptions) {
|
|
811
|
+
return sealPayload(
|
|
812
|
+
"bytes",
|
|
813
|
+
() => {
|
|
814
|
+
// `new Uint8Array(x)` accepts numbers, strings and other typed
|
|
815
|
+
// arrays and would silently seal something else.
|
|
816
|
+
if (!(value instanceof Uint8Array)) {
|
|
817
|
+
throw new TypeError("sealBytes needs a Uint8Array.");
|
|
818
|
+
}
|
|
819
|
+
return value;
|
|
820
|
+
},
|
|
821
|
+
binding,
|
|
822
|
+
sealOptions,
|
|
823
|
+
);
|
|
824
|
+
},
|
|
825
|
+
async open(sealed, binding) {
|
|
826
|
+
const { parsed, payload } = await openPayload(
|
|
827
|
+
"text",
|
|
828
|
+
sealed,
|
|
829
|
+
binding,
|
|
830
|
+
);
|
|
831
|
+
return decodeText(parsed, payload);
|
|
832
|
+
},
|
|
833
|
+
async openJson(sealed, binding) {
|
|
834
|
+
const { parsed, payload } = await openPayload(
|
|
835
|
+
"json",
|
|
836
|
+
sealed,
|
|
837
|
+
binding,
|
|
838
|
+
);
|
|
839
|
+
const text = decodeText(parsed, payload);
|
|
840
|
+
try {
|
|
841
|
+
return JSON.parse(text) as unknown;
|
|
842
|
+
} catch {
|
|
843
|
+
// A SyntaxError message quotes its input, which is the plaintext.
|
|
844
|
+
report({ purpose: name, keyId: parsed.keyId, reason: "malformed" });
|
|
845
|
+
throw new SecretUnreadableError("malformed");
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
async openBytes(sealed, binding) {
|
|
849
|
+
return (await openPayload("bytes", sealed, binding)).payload;
|
|
850
|
+
},
|
|
851
|
+
tryOpen(sealed, binding) {
|
|
852
|
+
return orNull(purpose.open(sealed, binding));
|
|
853
|
+
},
|
|
854
|
+
tryOpenJson(sealed, binding) {
|
|
855
|
+
return orNull(
|
|
856
|
+
purpose.openJson(sealed, binding).then((value) => ({ value })),
|
|
857
|
+
);
|
|
858
|
+
},
|
|
859
|
+
tryOpenBytes(sealed, binding) {
|
|
860
|
+
return orNull(purpose.openBytes(sealed, binding));
|
|
861
|
+
},
|
|
862
|
+
keyId(sealed) {
|
|
863
|
+
return parseSealed(sealed, maxLength)?.keyId ?? null;
|
|
864
|
+
},
|
|
865
|
+
async needsReseal(sealed) {
|
|
866
|
+
const keyId = parseSealed(sealed, maxLength)?.keyId;
|
|
867
|
+
return keyId !== undefined && keyId !== (await activeKeyId());
|
|
868
|
+
},
|
|
869
|
+
async reseal(sealed, binding) {
|
|
870
|
+
const { parsed, raw, pieces } = await openFrame(sealed, binding);
|
|
871
|
+
if (parsed.keyId === (await activeKeyId())) {
|
|
872
|
+
return sealed;
|
|
873
|
+
}
|
|
874
|
+
// The decrypted frame is encrypted again as it is, so the payload
|
|
875
|
+
// kind and the original expiry are preserved rather than renewed.
|
|
876
|
+
return await encryptFrame(new Uint8Array(raw), pieces);
|
|
877
|
+
},
|
|
878
|
+
async mac(text, binding, macOptions) {
|
|
879
|
+
// Read from the caller before the first await, as in `seal`.
|
|
880
|
+
const input = macInput(text, binding);
|
|
881
|
+
const requested = macOptions?.keyId;
|
|
882
|
+
if (requested !== undefined && !isSecretKeyId(requested)) {
|
|
883
|
+
throw new TypeError("keyId must be a key version.");
|
|
884
|
+
}
|
|
885
|
+
const keyId = requested ?? (await activeKeyId());
|
|
886
|
+
const key = await macKey(keyId);
|
|
887
|
+
if (key === null) {
|
|
888
|
+
throw new SecretsKeyError(
|
|
889
|
+
`Key version ${keyId} is not configured.`,
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
const tag = await subtle.sign("HMAC", key, input);
|
|
893
|
+
return `${KEYED_FINGERPRINT_FORMAT}.${keyId}.${toBase64Url(
|
|
894
|
+
new Uint8Array(tag),
|
|
895
|
+
)}`;
|
|
896
|
+
},
|
|
897
|
+
async macMatches(stored, text, binding) {
|
|
898
|
+
const input = macInput(text, binding);
|
|
899
|
+
const parsed = parseFingerprint(stored);
|
|
900
|
+
if (parsed === null) {
|
|
901
|
+
report({ purpose: name, keyId: null, reason: "malformed" });
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
const key = await macKey(parsed.keyId);
|
|
905
|
+
if (key === null) {
|
|
906
|
+
report({
|
|
907
|
+
purpose: name,
|
|
908
|
+
keyId: parsed.keyId,
|
|
909
|
+
reason: "unknown-key",
|
|
910
|
+
});
|
|
911
|
+
return false;
|
|
912
|
+
}
|
|
913
|
+
// `verify` compares the tags without an early exit.
|
|
914
|
+
return await subtle.verify("HMAC", key, parsed.tag, input);
|
|
915
|
+
},
|
|
916
|
+
async macNeedsRefresh(stored) {
|
|
917
|
+
const keyId = parseFingerprint(stored)?.keyId;
|
|
918
|
+
return keyId !== undefined && keyId !== (await activeKeyId());
|
|
919
|
+
},
|
|
920
|
+
assertReady: () => secrets.assertReady(),
|
|
921
|
+
};
|
|
922
|
+
return purpose;
|
|
923
|
+
},
|
|
924
|
+
};
|
|
925
|
+
return secrets;
|
|
926
|
+
}
|