@lastshotlabs/bunshot 0.0.25 → 0.0.28
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/.oclif.manifest.json +39 -0
- package/README.md +8282 -2147
- package/dist/cli/commands/init.js +690 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli.js +4 -4
- package/dist/packages/bunshot-admin/src/index.d.ts +15 -0
- package/dist/packages/bunshot-admin/src/index.js +11 -0
- package/dist/packages/bunshot-admin/src/lib/resourceTypes.d.ts +8 -0
- package/dist/packages/bunshot-admin/src/lib/resourceTypes.js +33 -0
- package/dist/packages/bunshot-admin/src/lib/typedRoute.d.ts +14 -0
- package/dist/packages/bunshot-admin/src/lib/typedRoute.js +17 -0
- package/dist/packages/bunshot-admin/src/plugin.d.ts +4 -0
- package/dist/packages/bunshot-admin/src/plugin.js +46 -0
- package/dist/packages/bunshot-admin/src/providers/auth0Access.d.ts +6 -0
- package/dist/packages/bunshot-admin/src/providers/auth0Access.js +32 -0
- package/dist/packages/bunshot-admin/src/routes/admin.d.ts +10 -0
- package/dist/packages/bunshot-admin/src/routes/admin.js +923 -0
- package/dist/packages/bunshot-admin/src/routes/mail.d.ts +6 -0
- package/dist/packages/bunshot-admin/src/routes/mail.js +114 -0
- package/dist/packages/bunshot-admin/src/routes/permissions.d.ts +8 -0
- package/dist/packages/bunshot-admin/src/routes/permissions.js +315 -0
- package/dist/packages/bunshot-admin/src/types/config.d.ts +16 -0
- package/dist/packages/bunshot-admin/src/types/config.js +37 -0
- package/dist/packages/bunshot-admin/src/types/env.d.ts +14 -0
- package/dist/packages/bunshot-admin/src/types/provider.d.ts +1 -0
- package/dist/packages/bunshot-admin/src/types/provider.js +4 -0
- package/dist/packages/bunshot-auth/src/adapters/memoryAuth.d.ts +66 -0
- package/dist/packages/bunshot-auth/src/adapters/memoryAuth.js +1063 -0
- package/dist/packages/bunshot-auth/src/adapters/mongoAuth.d.ts +2 -0
- package/dist/packages/bunshot-auth/src/adapters/mongoAuth.js +536 -0
- package/dist/packages/bunshot-auth/src/adapters/sqliteAuth.d.ts +88 -0
- package/dist/packages/bunshot-auth/src/adapters/sqliteAuth.js +1366 -0
- package/dist/packages/bunshot-auth/src/admin/bunshotAccess.d.ts +2 -0
- package/dist/packages/bunshot-auth/src/admin/bunshotAccess.js +23 -0
- package/dist/packages/bunshot-auth/src/admin/bunshotUsers.d.ts +5 -0
- package/dist/packages/bunshot-auth/src/admin/bunshotUsers.js +131 -0
- package/dist/packages/bunshot-auth/src/bootstrap.d.ts +38 -0
- package/dist/packages/bunshot-auth/src/bootstrap.js +384 -0
- package/dist/packages/bunshot-auth/src/config/appConfig.d.ts +3 -0
- package/dist/packages/bunshot-auth/src/config/appConfig.js +4 -0
- package/dist/packages/bunshot-auth/src/config/authConfig.d.ts +478 -0
- package/dist/packages/bunshot-auth/src/config/authConfig.js +46 -0
- package/dist/packages/bunshot-auth/src/config/configLock.d.ts +2 -0
- package/dist/packages/bunshot-auth/src/config/configLock.js +10 -0
- package/dist/packages/bunshot-auth/src/index.d.ts +25 -0
- package/dist/packages/bunshot-auth/src/index.js +23 -0
- package/dist/packages/bunshot-auth/src/infra/mongo.d.ts +15 -0
- package/dist/packages/bunshot-auth/src/infra/mongo.js +44 -0
- package/dist/packages/bunshot-auth/src/infra/queue.d.ts +14 -0
- package/dist/packages/bunshot-auth/src/infra/queue.js +27 -0
- package/dist/packages/bunshot-auth/src/infra/redis.d.ts +5 -0
- package/dist/packages/bunshot-auth/src/infra/redis.js +15 -0
- package/dist/packages/bunshot-auth/src/infra/signing.d.ts +7 -0
- package/dist/packages/bunshot-auth/src/infra/signing.js +8 -0
- package/dist/packages/bunshot-auth/src/lib/accountLockout.d.ts +34 -0
- package/dist/packages/bunshot-auth/src/lib/accountLockout.js +244 -0
- package/dist/packages/bunshot-auth/src/lib/adapterTiers.d.ts +1 -0
- package/dist/packages/bunshot-auth/src/lib/adapterTiers.js +1 -0
- package/dist/packages/bunshot-auth/src/lib/authAdapter.d.ts +1 -0
- package/dist/packages/bunshot-auth/src/lib/authAdapter.js +1 -0
- package/dist/packages/bunshot-auth/src/lib/authContext.d.ts +15 -0
- package/dist/packages/bunshot-auth/src/lib/authContext.js +1 -0
- package/dist/packages/bunshot-auth/src/lib/authEventBus.d.ts +4 -0
- package/dist/packages/bunshot-auth/src/lib/authEventBus.js +15 -0
- package/dist/packages/bunshot-auth/src/lib/authRateLimit.d.ts +28 -0
- package/dist/packages/bunshot-auth/src/lib/authRateLimit.js +205 -0
- package/dist/packages/bunshot-auth/src/lib/breachedPassword.d.ts +19 -0
- package/dist/packages/bunshot-auth/src/lib/breachedPassword.js +61 -0
- package/dist/packages/bunshot-auth/src/lib/cache.d.ts +12 -0
- package/dist/packages/bunshot-auth/src/lib/cache.js +120 -0
- package/dist/packages/bunshot-auth/src/lib/clientIp.d.ts +4 -0
- package/dist/{lib → packages/bunshot-auth/src/lib}/clientIp.js +14 -7
- package/dist/packages/bunshot-auth/src/lib/cookieOptions.d.ts +27 -0
- package/dist/packages/bunshot-auth/src/lib/cookieOptions.js +33 -0
- package/dist/packages/bunshot-auth/src/lib/credentialStuffing.d.ts +40 -0
- package/dist/packages/bunshot-auth/src/lib/credentialStuffing.js +221 -0
- package/dist/packages/bunshot-auth/src/lib/deletionCancelToken.d.ts +19 -0
- package/dist/packages/bunshot-auth/src/lib/deletionCancelToken.js +148 -0
- package/dist/packages/bunshot-auth/src/lib/emailTemplates.d.ts +23 -0
- package/dist/packages/bunshot-auth/src/lib/emailTemplates.js +265 -0
- package/dist/packages/bunshot-auth/src/lib/emailVerification.d.ts +30 -0
- package/dist/packages/bunshot-auth/src/lib/emailVerification.js +200 -0
- package/dist/packages/bunshot-auth/src/lib/env.d.ts +1 -0
- package/dist/packages/bunshot-auth/src/lib/env.js +3 -0
- package/dist/packages/bunshot-auth/src/lib/fingerprint.js +36 -0
- package/dist/{lib → packages/bunshot-auth/src/lib}/groups.d.ts +15 -16
- package/dist/{lib → packages/bunshot-auth/src/lib}/groups.js +22 -34
- package/dist/packages/bunshot-auth/src/lib/jwks.d.ts +28 -0
- package/dist/packages/bunshot-auth/src/lib/jwks.js +79 -0
- package/dist/packages/bunshot-auth/src/lib/jwt.d.ts +12 -0
- package/dist/packages/bunshot-auth/src/lib/jwt.js +86 -0
- package/dist/packages/bunshot-auth/src/lib/logger.d.ts +3 -0
- package/dist/packages/bunshot-auth/src/lib/logger.js +13 -0
- package/dist/packages/bunshot-auth/src/lib/m2m.d.ts +30 -0
- package/dist/packages/bunshot-auth/src/lib/m2m.js +44 -0
- package/dist/packages/bunshot-auth/src/lib/magicLink.d.ts +13 -0
- package/dist/packages/bunshot-auth/src/lib/magicLink.js +145 -0
- package/dist/packages/bunshot-auth/src/lib/mfaChallenge.d.ts +60 -0
- package/dist/packages/bunshot-auth/src/lib/mfaChallenge.js +419 -0
- package/dist/packages/bunshot-auth/src/lib/oauth.d.ts +82 -0
- package/dist/packages/bunshot-auth/src/lib/oauth.js +177 -0
- package/dist/packages/bunshot-auth/src/lib/oauthCode.d.ts +19 -0
- package/dist/packages/bunshot-auth/src/lib/oauthCode.js +182 -0
- package/dist/packages/bunshot-auth/src/lib/oauthReauth.d.ts +19 -0
- package/dist/packages/bunshot-auth/src/lib/oauthReauth.js +255 -0
- package/dist/packages/bunshot-auth/src/lib/organization.d.ts +66 -0
- package/dist/packages/bunshot-auth/src/lib/organization.js +225 -0
- package/dist/packages/bunshot-auth/src/lib/passwordHistory.d.ts +12 -0
- package/dist/packages/bunshot-auth/src/lib/passwordHistory.js +31 -0
- package/dist/packages/bunshot-auth/src/lib/resetPassword.d.ts +20 -0
- package/dist/packages/bunshot-auth/src/lib/resetPassword.js +148 -0
- package/dist/packages/bunshot-auth/src/lib/roles.d.ts +9 -0
- package/dist/packages/bunshot-auth/src/lib/roles.js +93 -0
- package/dist/packages/bunshot-auth/src/lib/saml.d.ts +29 -0
- package/dist/packages/bunshot-auth/src/lib/saml.js +73 -0
- package/dist/packages/bunshot-auth/src/lib/samlRequestId.d.ts +13 -0
- package/dist/packages/bunshot-auth/src/lib/samlRequestId.js +129 -0
- package/dist/packages/bunshot-auth/src/lib/scim.d.ts +44 -0
- package/dist/packages/bunshot-auth/src/lib/scim.js +56 -0
- package/dist/packages/bunshot-auth/src/lib/securityEventWiring.d.ts +22 -0
- package/dist/packages/bunshot-auth/src/lib/securityEventWiring.js +65 -0
- package/dist/packages/bunshot-auth/src/lib/session.d.ts +45 -0
- package/dist/packages/bunshot-auth/src/lib/session.js +1211 -0
- package/dist/packages/bunshot-auth/src/lib/storeInfra.d.ts +26 -0
- package/dist/packages/bunshot-auth/src/lib/storeInfra.js +18 -0
- package/dist/packages/bunshot-auth/src/lib/suspension.d.ts +14 -0
- package/dist/packages/bunshot-auth/src/lib/suspension.js +20 -0
- package/dist/packages/bunshot-auth/src/lib/validateAdapter.d.ts +16 -0
- package/dist/packages/bunshot-auth/src/lib/validateAdapter.js +161 -0
- package/dist/packages/bunshot-auth/src/middleware/bearerAuth.d.ts +13 -0
- package/dist/packages/bunshot-auth/src/middleware/bearerAuth.js +58 -0
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/csrf.d.ts +5 -4
- package/dist/packages/bunshot-auth/src/middleware/csrf.js +138 -0
- package/dist/packages/bunshot-auth/src/middleware/identify.d.ts +4 -0
- package/dist/packages/bunshot-auth/src/middleware/identify.js +124 -0
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/requireMfaSetup.d.ts +2 -2
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/requireMfaSetup.js +10 -7
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/requireRole.d.ts +2 -2
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/requireRole.js +20 -16
- package/dist/packages/bunshot-auth/src/middleware/requireScope.d.ts +10 -0
- package/dist/packages/bunshot-auth/src/middleware/requireScope.js +25 -0
- package/dist/packages/bunshot-auth/src/middleware/requireStepUp.d.ts +18 -0
- package/dist/packages/bunshot-auth/src/middleware/requireStepUp.js +30 -0
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/requireVerifiedEmail.d.ts +2 -2
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/requireVerifiedEmail.js +7 -6
- package/dist/packages/bunshot-auth/src/middleware/scimAuth.d.ts +8 -0
- package/dist/packages/bunshot-auth/src/middleware/scimAuth.js +29 -0
- package/dist/packages/bunshot-auth/src/middleware/userAuth.d.ts +3 -0
- package/dist/packages/bunshot-auth/src/middleware/userAuth.js +6 -0
- package/dist/{models → packages/bunshot-auth/src/models}/AuthUser.d.ts +19 -8
- package/dist/packages/bunshot-auth/src/models/AuthUser.js +53 -0
- package/dist/packages/bunshot-auth/src/models/Group.d.ts +19 -0
- package/dist/packages/bunshot-auth/src/models/Group.js +22 -0
- package/dist/{models → packages/bunshot-auth/src/models}/GroupMembership.d.ts +6 -8
- package/dist/packages/bunshot-auth/src/models/GroupMembership.js +19 -0
- package/dist/packages/bunshot-auth/src/models/M2MClient.d.ts +18 -0
- package/dist/packages/bunshot-auth/src/models/M2MClient.js +18 -0
- package/dist/packages/bunshot-auth/src/models/TenantRole.d.ts +13 -0
- package/dist/packages/bunshot-auth/src/models/TenantRole.js +17 -0
- package/dist/packages/bunshot-auth/src/plugin.d.ts +4 -0
- package/dist/packages/bunshot-auth/src/plugin.js +274 -0
- package/dist/packages/bunshot-auth/src/routes/auth.d.ts +15 -0
- package/dist/packages/bunshot-auth/src/routes/auth.js +1624 -0
- package/dist/packages/bunshot-auth/src/routes/groups.d.ts +4 -0
- package/dist/packages/bunshot-auth/src/routes/groups.js +481 -0
- package/dist/packages/bunshot-auth/src/routes/m2m.d.ts +2 -0
- package/dist/packages/bunshot-auth/src/routes/m2m.js +145 -0
- package/dist/packages/bunshot-auth/src/routes/mfa.d.ts +6 -0
- package/dist/packages/bunshot-auth/src/routes/mfa.js +991 -0
- package/dist/packages/bunshot-auth/src/routes/oauth.d.ts +3 -0
- package/dist/packages/bunshot-auth/src/routes/oauth.js +1727 -0
- package/dist/packages/bunshot-auth/src/routes/oidc.d.ts +2 -0
- package/dist/packages/bunshot-auth/src/routes/oidc.js +84 -0
- package/dist/packages/bunshot-auth/src/routes/organizations.d.ts +3 -0
- package/dist/packages/bunshot-auth/src/routes/organizations.js +741 -0
- package/dist/packages/bunshot-auth/src/routes/passkey.d.ts +2 -0
- package/dist/packages/bunshot-auth/src/routes/passkey.js +199 -0
- package/dist/packages/bunshot-auth/src/routes/saml.d.ts +2 -0
- package/dist/packages/bunshot-auth/src/routes/saml.js +226 -0
- package/dist/packages/bunshot-auth/src/routes/scim.d.ts +3 -0
- package/dist/packages/bunshot-auth/src/routes/scim.js +588 -0
- package/dist/packages/bunshot-auth/src/runtime.d.ts +52 -0
- package/dist/packages/bunshot-auth/src/runtime.js +11 -0
- package/dist/{schemas → packages/bunshot-auth/src/schemas}/auth.d.ts +4 -5
- package/dist/packages/bunshot-auth/src/schemas/auth.js +24 -0
- package/dist/packages/bunshot-auth/src/schemas/error.d.ts +10 -0
- package/dist/packages/bunshot-auth/src/schemas/error.js +10 -0
- package/dist/packages/bunshot-auth/src/schemas/success.d.ts +10 -0
- package/dist/packages/bunshot-auth/src/schemas/success.js +10 -0
- package/dist/packages/bunshot-auth/src/services/auth.d.ts +39 -0
- package/dist/packages/bunshot-auth/src/services/auth.js +378 -0
- package/dist/{services → packages/bunshot-auth/src/services}/mfa.d.ts +41 -17
- package/dist/{services → packages/bunshot-auth/src/services}/mfa.js +259 -183
- package/dist/packages/bunshot-auth/src/testing.d.ts +31 -0
- package/dist/packages/bunshot-auth/src/testing.js +23 -0
- package/dist/packages/bunshot-auth/src/types/adapter.d.ts +1 -0
- package/dist/packages/bunshot-auth/src/types/adapter.js +1 -0
- package/dist/packages/bunshot-auth/src/types/config.d.ts +152 -0
- package/dist/packages/bunshot-auth/src/types/config.js +179 -0
- package/dist/{routes → packages/bunshot-auth/src/types}/groups.d.ts +2 -3
- package/dist/packages/bunshot-auth/src/types/groups.js +1 -0
- package/dist/packages/bunshot-auth/src/types/oauthCode.d.ts +6 -0
- package/dist/packages/bunshot-auth/src/types/oauthCode.js +1 -0
- package/dist/packages/bunshot-auth/src/types/oauthReauth.d.ts +13 -0
- package/dist/packages/bunshot-auth/src/types/oauthReauth.js +1 -0
- package/dist/packages/bunshot-auth/src/types/redis.d.ts +1 -0
- package/dist/packages/bunshot-auth/src/types/redis.js +1 -0
- package/dist/packages/bunshot-auth/src/types/saml.d.ts +10 -0
- package/dist/packages/bunshot-auth/src/types/saml.js +1 -0
- package/dist/packages/bunshot-auth/src/types/session.d.ts +18 -0
- package/dist/packages/bunshot-auth/src/types/session.js +1 -0
- package/dist/packages/bunshot-auth/src/types/store.d.ts +1 -0
- package/dist/packages/bunshot-auth/src/types/store.js +1 -0
- package/dist/packages/bunshot-core/src/adminProvider.d.ts +95 -0
- package/dist/packages/bunshot-core/src/adminProvider.js +1 -0
- package/dist/packages/bunshot-core/src/auditLog.d.ts +34 -0
- package/dist/packages/bunshot-core/src/auditLog.js +1 -0
- package/dist/packages/bunshot-core/src/auth-adapter.d.ts +227 -0
- package/dist/packages/bunshot-core/src/auth-adapter.js +4 -0
- package/dist/packages/bunshot-core/src/authVariables.d.ts +14 -0
- package/dist/packages/bunshot-core/src/authVariables.js +4 -0
- package/dist/packages/bunshot-core/src/cache.d.ts +12 -0
- package/dist/packages/bunshot-core/src/cache.js +21 -0
- package/dist/packages/bunshot-core/src/captcha.d.ts +16 -0
- package/dist/packages/bunshot-core/src/captcha.js +1 -0
- package/dist/packages/bunshot-core/src/clearRegistry.d.ts +6 -0
- package/dist/packages/bunshot-core/src/clearRegistry.js +17 -0
- package/dist/packages/bunshot-core/src/clientIp.d.ts +3 -0
- package/dist/packages/bunshot-core/src/clientIp.js +45 -0
- package/dist/packages/bunshot-core/src/configLock.d.ts +4 -0
- package/dist/packages/bunshot-core/src/configLock.js +7 -0
- package/dist/packages/bunshot-core/src/configValidation.d.ts +22 -0
- package/dist/packages/bunshot-core/src/configValidation.js +39 -0
- package/dist/packages/bunshot-core/src/constants.js +10 -0
- package/dist/packages/bunshot-core/src/context/bunshotContext.d.ts +232 -0
- package/dist/packages/bunshot-core/src/context/bunshotContext.js +1 -0
- package/dist/packages/bunshot-core/src/context/contextAccess.d.ts +3 -0
- package/dist/packages/bunshot-core/src/context/contextAccess.js +16 -0
- package/dist/packages/bunshot-core/src/context/contextStore.d.ts +16 -0
- package/dist/packages/bunshot-core/src/context/contextStore.js +31 -0
- package/dist/packages/bunshot-core/src/context/frameworkConfig.d.ts +38 -0
- package/dist/packages/bunshot-core/src/context/frameworkConfig.js +1 -0
- package/dist/packages/bunshot-core/src/context/index.d.ts +4 -0
- package/dist/packages/bunshot-core/src/context/index.js +2 -0
- package/dist/packages/bunshot-core/src/context.d.ts +40 -0
- package/dist/packages/bunshot-core/src/context.js +35 -0
- package/dist/packages/bunshot-core/src/coreContracts.d.ts +47 -0
- package/dist/packages/bunshot-core/src/coreContracts.js +1 -0
- package/dist/packages/bunshot-core/src/coreRegistrar.d.ts +6 -0
- package/dist/packages/bunshot-core/src/coreRegistrar.js +42 -0
- package/dist/{lib → packages/bunshot-core/src}/createRoute.d.ts +4 -30
- package/dist/{lib → packages/bunshot-core/src}/createRoute.js +39 -88
- package/dist/packages/bunshot-core/src/cronRegistry.d.ts +11 -0
- package/dist/packages/bunshot-core/src/cronRegistry.js +1 -0
- package/dist/packages/bunshot-core/src/crypto.d.ts +43 -0
- package/dist/packages/bunshot-core/src/crypto.js +74 -0
- package/dist/packages/bunshot-core/src/csrf.d.ts +8 -0
- package/dist/packages/bunshot-core/src/csrf.js +1 -0
- package/dist/packages/bunshot-core/src/defaults/defaultFingerprint.d.ts +7 -0
- package/dist/packages/bunshot-core/src/defaults/defaultFingerprint.js +19 -0
- package/dist/packages/bunshot-core/src/defaults/memoryCacheAdapter.d.ts +6 -0
- package/dist/packages/bunshot-core/src/defaults/memoryCacheAdapter.js +40 -0
- package/dist/packages/bunshot-core/src/defaults/memoryRateLimit.d.ts +6 -0
- package/dist/packages/bunshot-core/src/defaults/memoryRateLimit.js +24 -0
- package/dist/packages/bunshot-core/src/emailTemplates.d.ts +5 -0
- package/dist/packages/bunshot-core/src/emailTemplates.js +10 -0
- package/dist/packages/bunshot-core/src/errors.d.ts +13 -0
- package/dist/packages/bunshot-core/src/errors.js +22 -0
- package/dist/packages/bunshot-core/src/eventBus.d.ts +270 -0
- package/dist/packages/bunshot-core/src/eventBus.js +143 -0
- package/dist/packages/bunshot-core/src/idempotency.d.ts +18 -0
- package/dist/packages/bunshot-core/src/idempotency.js +1 -0
- package/dist/packages/bunshot-core/src/index.d.ts +60 -0
- package/dist/packages/bunshot-core/src/index.js +34 -0
- package/dist/packages/bunshot-core/src/mail.d.ts +14 -0
- package/dist/packages/bunshot-core/src/mail.js +8 -0
- package/dist/packages/bunshot-core/src/memoryEviction.d.ts +24 -0
- package/dist/packages/bunshot-core/src/memoryEviction.js +52 -0
- package/dist/packages/bunshot-core/src/pagination.d.ts +45 -0
- package/dist/packages/bunshot-core/src/pagination.js +61 -0
- package/dist/packages/bunshot-core/src/permissions.d.ts +64 -0
- package/dist/packages/bunshot-core/src/permissions.js +27 -0
- package/dist/packages/bunshot-core/src/plugin.d.ts +44 -0
- package/dist/packages/bunshot-core/src/plugin.js +1 -0
- package/dist/packages/bunshot-core/src/rateLimit.d.ts +5 -0
- package/dist/packages/bunshot-core/src/rateLimit.js +18 -0
- package/dist/packages/bunshot-core/src/redis.d.ts +21 -0
- package/dist/packages/bunshot-core/src/redis.js +1 -0
- package/dist/packages/bunshot-core/src/routeAuth.d.ts +5 -0
- package/dist/packages/bunshot-core/src/routeAuth.js +11 -0
- package/dist/packages/bunshot-core/src/routeOverrides.d.ts +24 -0
- package/dist/packages/bunshot-core/src/routeOverrides.js +25 -0
- package/dist/packages/bunshot-core/src/routerAdapter.d.ts +6 -0
- package/dist/packages/bunshot-core/src/routerAdapter.js +56 -0
- package/dist/packages/bunshot-core/src/secrets.d.ts +48 -0
- package/dist/packages/bunshot-core/src/secrets.js +8 -0
- package/dist/packages/bunshot-core/src/signing.d.ts +41 -0
- package/dist/packages/bunshot-core/src/signing.js +1 -0
- package/dist/packages/bunshot-core/src/sse.d.ts +36 -0
- package/dist/packages/bunshot-core/src/sse.js +1 -0
- package/dist/packages/bunshot-core/src/storageAdapter.js +1 -0
- package/dist/packages/bunshot-core/src/storeInfra.d.ts +44 -0
- package/dist/packages/bunshot-core/src/storeInfra.js +18 -0
- package/dist/packages/bunshot-core/src/storeType.d.ts +7 -0
- package/dist/packages/bunshot-core/src/storeType.js +1 -0
- package/dist/packages/bunshot-core/src/testing.d.ts +1 -0
- package/dist/packages/bunshot-core/src/testing.js +1 -0
- package/dist/packages/bunshot-core/src/uploadRegistry.d.ts +23 -0
- package/dist/packages/bunshot-core/src/uploadRegistry.js +4 -0
- package/dist/packages/bunshot-core/src/userResolver.d.ts +5 -0
- package/dist/packages/bunshot-core/src/userResolver.js +14 -0
- package/dist/packages/bunshot-core/src/wsMessages.d.ts +42 -0
- package/dist/packages/bunshot-core/src/wsMessages.js +4 -0
- package/dist/packages/bunshot-permissions/src/adapters/memory.d.ts +7 -0
- package/dist/packages/bunshot-permissions/src/adapters/memory.js +73 -0
- package/dist/packages/bunshot-permissions/src/index.d.ts +10 -0
- package/dist/packages/bunshot-permissions/src/index.js +5 -0
- package/dist/packages/bunshot-permissions/src/lib/bootstrap.d.ts +7 -0
- package/dist/packages/bunshot-permissions/src/lib/bootstrap.js +12 -0
- package/dist/packages/bunshot-permissions/src/lib/evaluator.d.ts +10 -0
- package/dist/packages/bunshot-permissions/src/lib/evaluator.js +165 -0
- package/dist/packages/bunshot-permissions/src/lib/registry.d.ts +2 -0
- package/dist/packages/bunshot-permissions/src/lib/registry.js +31 -0
- package/dist/packages/bunshot-permissions/src/lib/validation.d.ts +1 -0
- package/dist/packages/bunshot-permissions/src/lib/validation.js +1 -0
- package/dist/packages/bunshot-permissions/src/types/adapter.d.ts +1 -0
- package/dist/packages/bunshot-permissions/src/types/adapter.js +1 -0
- package/dist/packages/bunshot-permissions/src/types/evaluator.d.ts +1 -0
- package/dist/packages/bunshot-permissions/src/types/evaluator.js +1 -0
- package/dist/packages/bunshot-permissions/src/types/models.d.ts +1 -0
- package/dist/packages/bunshot-permissions/src/types/models.js +1 -0
- package/dist/packages/bunshot-permissions/src/types/registry.d.ts +1 -0
- package/dist/packages/bunshot-permissions/src/types/registry.js +1 -0
- package/dist/packages/bunshot-postgres/src/adapter.d.ts +6 -0
- package/dist/packages/bunshot-postgres/src/adapter.js +794 -0
- package/dist/packages/bunshot-postgres/src/connection.d.ts +15 -0
- package/dist/packages/bunshot-postgres/src/connection.js +16 -0
- package/dist/packages/bunshot-postgres/src/index.d.ts +4 -0
- package/dist/packages/bunshot-postgres/src/index.js +2 -0
- package/dist/packages/bunshot-postgres/src/schema.d.ts +997 -0
- package/dist/packages/bunshot-postgres/src/schema.js +105 -0
- package/dist/src/app.d.ts +230 -0
- package/dist/src/app.js +182 -0
- package/dist/src/cli/commands/init.d.ts +10 -0
- package/dist/src/cli/commands/init.js +709 -0
- package/dist/src/cli/index.d.ts +1 -0
- package/dist/src/cli/index.js +3 -0
- package/dist/src/entrypoints/mongo.d.ts +6 -0
- package/dist/src/entrypoints/mongo.js +4 -0
- package/dist/src/entrypoints/queue.d.ts +2 -0
- package/dist/src/entrypoints/queue.js +1 -0
- package/dist/src/entrypoints/redis.d.ts +1 -0
- package/dist/src/entrypoints/redis.js +1 -0
- package/dist/{adapters → src/framework/adapters}/localStorage.d.ts +1 -1
- package/dist/{adapters → src/framework/adapters}/localStorage.js +23 -8
- package/dist/src/framework/adapters/memoryStorage.d.ts +2 -0
- package/dist/src/framework/adapters/memoryStorage.js +45 -0
- package/dist/{adapters → src/framework/adapters}/s3Storage.d.ts +1 -1
- package/dist/{adapters → src/framework/adapters}/s3Storage.js +12 -12
- package/dist/src/framework/admin/bunshotAccess.d.ts +2 -0
- package/dist/src/framework/admin/bunshotAccess.js +23 -0
- package/dist/src/framework/admin/bunshotUsers.d.ts +2 -0
- package/dist/src/framework/admin/bunshotUsers.js +103 -0
- package/dist/src/framework/admin/index.d.ts +7 -0
- package/dist/src/framework/admin/index.js +21 -0
- package/dist/src/framework/boundaryAdapters/cacheFactories.d.ts +13 -0
- package/dist/src/framework/boundaryAdapters/cacheFactories.js +86 -0
- package/dist/src/framework/boundaryAdapters/index.d.ts +2 -0
- package/dist/src/framework/boundaryAdapters/index.js +1 -0
- package/dist/src/framework/boundaryAdapters.d.ts +17 -0
- package/dist/src/framework/boundaryAdapters.js +62 -0
- package/dist/src/framework/buildContext.d.ts +33 -0
- package/dist/src/framework/buildContext.js +119 -0
- package/dist/src/framework/config/schema.d.ts +447 -0
- package/dist/src/framework/config/schema.js +528 -0
- package/dist/src/framework/createInfrastructure.d.ts +76 -0
- package/dist/src/framework/createInfrastructure.js +221 -0
- package/dist/src/framework/lib/auditLog.d.ts +23 -0
- package/dist/src/framework/lib/auditLog.js +416 -0
- package/dist/src/framework/lib/captcha.d.ts +11 -0
- package/dist/src/framework/lib/captcha.js +40 -0
- package/dist/{lib → src/framework/lib}/createDtoMapper.js +4 -4
- package/dist/src/framework/lib/createRoute.d.ts +1 -0
- package/dist/src/framework/lib/createRoute.js +2 -0
- package/dist/{lib → src/framework/lib}/idempotency.d.ts +2 -6
- package/dist/src/framework/lib/idempotency.js +74 -0
- package/dist/src/framework/lib/logger.d.ts +3 -0
- package/dist/src/framework/lib/logger.js +14 -0
- package/dist/src/framework/lib/metrics.d.ts +34 -0
- package/dist/{lib → src/framework/lib}/metrics.js +49 -57
- package/dist/src/framework/lib/pagination.d.ts +42 -0
- package/dist/src/framework/lib/pagination.js +51 -0
- package/dist/src/framework/lib/redisTransport.d.ts +38 -0
- package/dist/src/framework/lib/redisTransport.js +107 -0
- package/dist/src/framework/lib/resolveUserId.d.ts +2 -0
- package/dist/src/framework/lib/resolveUserId.js +5 -0
- package/dist/src/framework/lib/sseCollision.d.ts +6 -0
- package/dist/src/framework/lib/sseCollision.js +26 -0
- package/dist/src/framework/lib/storageAdapter.d.ts +1 -0
- package/dist/src/framework/lib/storageAdapter.js +1 -0
- package/dist/{lib → src/framework/lib}/stripUnreferencedSchemas.js +4 -4
- package/dist/src/framework/lib/tenant.d.ts +21 -0
- package/dist/src/framework/lib/tenant.js +70 -0
- package/dist/{lib → src/framework/lib}/upload.d.ts +14 -9
- package/dist/src/framework/lib/upload.js +132 -0
- package/dist/src/framework/lib/uploadRegistry.d.ts +23 -0
- package/dist/src/framework/lib/uploadRegistry.js +34 -0
- package/dist/{lib → src/framework/lib}/validate.d.ts +1 -1
- package/dist/{lib → src/framework/lib}/validate.js +2 -2
- package/dist/src/framework/lib/ws.d.ts +19 -0
- package/dist/src/framework/lib/ws.js +130 -0
- package/dist/src/framework/lib/wsHeartbeat.d.ts +12 -0
- package/dist/src/framework/lib/wsHeartbeat.js +53 -0
- package/dist/src/framework/lib/wsMessages.d.ts +25 -0
- package/dist/src/framework/lib/wsMessages.js +45 -0
- package/dist/src/framework/lib/wsNamespace.d.ts +17 -0
- package/dist/src/framework/lib/wsNamespace.js +19 -0
- package/dist/src/framework/lib/wsPresence.d.ts +17 -0
- package/dist/src/framework/lib/wsPresence.js +84 -0
- package/dist/src/framework/lib/wsTransport.d.ts +38 -0
- package/dist/src/framework/lib/wsTransport.js +9 -0
- package/dist/{lib → src/framework/lib}/zodToMongoose.d.ts +1 -1
- package/dist/{lib → src/framework/lib}/zodToMongoose.js +11 -11
- package/dist/{middleware → src/framework/middleware}/auditLog.d.ts +4 -3
- package/dist/src/framework/middleware/auditLog.js +42 -0
- package/dist/{middleware → src/framework/middleware}/botProtection.d.ts +2 -2
- package/dist/{middleware → src/framework/middleware}/botProtection.js +8 -9
- package/dist/src/framework/middleware/cacheResponse.d.ts +35 -0
- package/dist/src/framework/middleware/cacheResponse.js +126 -0
- package/dist/src/framework/middleware/captcha.d.ts +9 -0
- package/dist/src/framework/middleware/captcha.js +37 -0
- package/dist/{middleware → src/framework/middleware}/errorHandler.d.ts +1 -1
- package/dist/src/framework/middleware/errorHandler.js +16 -0
- package/dist/src/framework/middleware/index.js +1 -0
- package/dist/{middleware → src/framework/middleware}/logger.d.ts +1 -1
- package/dist/src/framework/middleware/metrics.d.ts +12 -0
- package/dist/src/framework/middleware/metrics.js +26 -0
- package/dist/{middleware → src/framework/middleware}/rateLimit.d.ts +2 -2
- package/dist/src/framework/middleware/rateLimit.js +22 -0
- package/dist/src/framework/middleware/requestId.d.ts +3 -0
- package/dist/{middleware → src/framework/middleware}/requestId.js +2 -2
- package/dist/{middleware → src/framework/middleware}/requestLogger.d.ts +3 -3
- package/dist/{middleware → src/framework/middleware}/requestLogger.js +17 -12
- package/dist/{middleware → src/framework/middleware}/requestSigning.d.ts +2 -2
- package/dist/{middleware → src/framework/middleware}/requestSigning.js +18 -19
- package/dist/src/framework/middleware/tenant.d.ts +14 -0
- package/dist/{middleware → src/framework/middleware}/tenant.js +31 -27
- package/dist/src/framework/middleware/upload.d.ts +5 -0
- package/dist/{middleware → src/framework/middleware}/upload.js +4 -4
- package/dist/{middleware → src/framework/middleware}/webhookAuth.d.ts +3 -3
- package/dist/{middleware → src/framework/middleware}/webhookAuth.js +11 -11
- package/dist/src/framework/models/AuditLog.d.ts +21 -0
- package/dist/src/framework/models/AuditLog.js +31 -0
- package/dist/src/framework/mountMiddleware.d.ts +91 -0
- package/dist/src/framework/mountMiddleware.js +128 -0
- package/dist/src/framework/mountOptionalEndpoints.d.ts +103 -0
- package/dist/src/framework/mountOptionalEndpoints.js +47 -0
- package/dist/src/framework/mountRoutes.d.ts +21 -0
- package/dist/src/framework/mountRoutes.js +144 -0
- package/dist/src/framework/persistence/cronRegistry.d.ts +28 -0
- package/dist/src/framework/persistence/cronRegistry.js +139 -0
- package/dist/src/framework/persistence/idempotency.d.ts +26 -0
- package/dist/src/framework/persistence/idempotency.js +178 -0
- package/dist/src/framework/persistence/index.d.ts +6 -0
- package/dist/src/framework/persistence/index.js +8 -0
- package/dist/src/framework/persistence/storeInfra.d.ts +9 -0
- package/dist/src/framework/persistence/storeInfra.js +1 -0
- package/dist/src/framework/persistence/uploadRegistry.d.ts +35 -0
- package/dist/src/framework/persistence/uploadRegistry.js +235 -0
- package/dist/src/framework/persistence/wsMessages.d.ts +22 -0
- package/dist/src/framework/persistence/wsMessages.js +296 -0
- package/dist/src/framework/preloadSchemas.d.ts +24 -0
- package/dist/src/framework/preloadSchemas.js +42 -0
- package/dist/src/framework/registerBoundaryAdapters.d.ts +23 -0
- package/dist/src/framework/registerBoundaryAdapters.js +46 -0
- package/dist/src/framework/routes/admin.d.ts +9 -0
- package/dist/src/framework/routes/admin.js +361 -0
- package/dist/src/framework/routes/health.d.ts +1 -0
- package/dist/src/framework/routes/health.js +21 -0
- package/dist/src/framework/routes/home.d.ts +1 -0
- package/dist/src/framework/routes/home.js +18 -0
- package/dist/src/framework/routes/jobs.d.ts +3 -0
- package/dist/src/framework/routes/jobs.js +315 -0
- package/dist/src/framework/routes/metrics.d.ts +10 -0
- package/dist/src/framework/routes/metrics.js +57 -0
- package/dist/src/framework/routes/uploads.d.ts +14 -0
- package/dist/src/framework/routes/uploads.js +262 -0
- package/dist/src/framework/runPluginLifecycle.d.ts +27 -0
- package/dist/src/framework/runPluginLifecycle.js +121 -0
- package/dist/src/framework/secrets/frameworkSecretSchema.d.ts +58 -0
- package/dist/src/framework/secrets/frameworkSecretSchema.js +20 -0
- package/dist/src/framework/secrets/index.d.ts +9 -0
- package/dist/src/framework/secrets/index.js +7 -0
- package/dist/src/framework/secrets/providers/envProvider.d.ts +15 -0
- package/dist/src/framework/secrets/providers/envProvider.js +18 -0
- package/dist/src/framework/secrets/providers/fileProvider.d.ts +8 -0
- package/dist/src/framework/secrets/providers/fileProvider.js +82 -0
- package/dist/src/framework/secrets/providers/ssmProvider.d.ts +20 -0
- package/dist/src/framework/secrets/providers/ssmProvider.js +127 -0
- package/dist/src/framework/secrets/resolveSecretBundle.d.ts +53 -0
- package/dist/src/framework/secrets/resolveSecretBundle.js +84 -0
- package/dist/src/framework/secrets/resolveSecrets.d.ts +18 -0
- package/dist/src/framework/secrets/resolveSecrets.js +34 -0
- package/dist/src/framework/sse/index.d.ts +21 -0
- package/dist/src/framework/sse/index.js +109 -0
- package/dist/src/framework/ws/index.d.ts +11 -0
- package/dist/src/framework/ws/index.js +8 -0
- package/dist/src/index.d.ts +87 -0
- package/dist/src/index.js +58 -0
- package/dist/src/lib/appConfig.d.ts +7 -0
- package/dist/src/lib/appConfig.js +27 -0
- package/dist/src/lib/appMeta.d.ts +7 -0
- package/dist/src/lib/appMeta.js +3 -0
- package/dist/src/lib/authConfig.d.ts +532 -0
- package/dist/src/lib/authConfig.js +179 -0
- package/dist/{lib → src/lib}/context.d.ts +6 -7
- package/dist/{lib → src/lib}/context.js +5 -5
- package/dist/src/lib/logger.d.ts +1 -0
- package/dist/src/lib/logger.js +1 -0
- package/dist/src/lib/mongo.d.ts +58 -0
- package/dist/src/lib/mongo.js +96 -0
- package/dist/src/lib/queue.d.ts +72 -0
- package/dist/src/lib/queue.js +152 -0
- package/dist/src/lib/redis.d.ts +28 -0
- package/dist/src/lib/redis.js +72 -0
- package/dist/{lib → src/lib}/signing.d.ts +2 -2
- package/dist/src/lib/signing.js +210 -0
- package/dist/src/lib/signingConfig.d.ts +40 -0
- package/dist/src/lib/signingConfig.js +28 -0
- package/dist/src/server.d.ts +146 -0
- package/dist/src/server.js +469 -0
- package/dist/src/shared/lib/HttpError.d.ts +1 -0
- package/dist/src/shared/lib/HttpError.js +2 -0
- package/dist/src/shared/lib/constants.d.ts +10 -0
- package/dist/src/shared/lib/crypto.d.ts +43 -0
- package/dist/src/shared/lib/crypto.js +74 -0
- package/dist/src/shared/lib/signing.d.ts +52 -0
- package/dist/{lib → src/shared/lib}/signing.js +40 -10
- package/dist/src/testing.d.ts +34 -0
- package/dist/src/testing.js +93 -0
- package/package.json +62 -25
- package/dist/adapters/memoryAuth.d.ts +0 -46
- package/dist/adapters/memoryAuth.js +0 -634
- package/dist/adapters/memoryStorage.d.ts +0 -3
- package/dist/adapters/memoryStorage.js +0 -44
- package/dist/adapters/mongoAuth.d.ts +0 -2
- package/dist/adapters/mongoAuth.js +0 -307
- package/dist/adapters/sqliteAuth.d.ts +0 -49
- package/dist/adapters/sqliteAuth.js +0 -707
- package/dist/app.d.ts +0 -456
- package/dist/app.js +0 -548
- package/dist/entrypoints/mongo.d.ts +0 -5
- package/dist/entrypoints/mongo.js +0 -4
- package/dist/entrypoints/queue.d.ts +0 -2
- package/dist/entrypoints/queue.js +0 -1
- package/dist/entrypoints/redis.d.ts +0 -1
- package/dist/entrypoints/redis.js +0 -1
- package/dist/index.d.ts +0 -98
- package/dist/index.js +0 -77
- package/dist/lib/HttpError.d.ts +0 -9
- package/dist/lib/HttpError.js +0 -14
- package/dist/lib/appConfig.d.ts +0 -162
- package/dist/lib/appConfig.js +0 -83
- package/dist/lib/auditLog.d.ts +0 -52
- package/dist/lib/auditLog.js +0 -201
- package/dist/lib/authAdapter.d.ts +0 -176
- package/dist/lib/authAdapter.js +0 -7
- package/dist/lib/authRateLimit.d.ts +0 -13
- package/dist/lib/authRateLimit.js +0 -81
- package/dist/lib/clientIp.d.ts +0 -14
- package/dist/lib/crypto.d.ts +0 -11
- package/dist/lib/crypto.js +0 -22
- package/dist/lib/deletionCancelToken.d.ts +0 -12
- package/dist/lib/deletionCancelToken.js +0 -88
- package/dist/lib/emailVerification.d.ts +0 -13
- package/dist/lib/emailVerification.js +0 -86
- package/dist/lib/fingerprint.js +0 -36
- package/dist/lib/idempotency.js +0 -182
- package/dist/lib/jwt.d.ts +0 -2
- package/dist/lib/jwt.js +0 -24
- package/dist/lib/logger.d.ts +0 -1
- package/dist/lib/logger.js +0 -7
- package/dist/lib/metrics.d.ts +0 -14
- package/dist/lib/mfaChallenge.d.ts +0 -42
- package/dist/lib/mfaChallenge.js +0 -293
- package/dist/lib/mongo.d.ts +0 -39
- package/dist/lib/mongo.js +0 -124
- package/dist/lib/oauth.d.ts +0 -40
- package/dist/lib/oauth.js +0 -101
- package/dist/lib/oauthCode.d.ts +0 -15
- package/dist/lib/oauthCode.js +0 -90
- package/dist/lib/pagination.d.ts +0 -119
- package/dist/lib/pagination.js +0 -166
- package/dist/lib/queue.d.ts +0 -37
- package/dist/lib/queue.js +0 -117
- package/dist/lib/redis.d.ts +0 -9
- package/dist/lib/redis.js +0 -61
- package/dist/lib/resetPassword.d.ts +0 -12
- package/dist/lib/resetPassword.js +0 -91
- package/dist/lib/roles.d.ts +0 -7
- package/dist/lib/roles.js +0 -49
- package/dist/lib/session.d.ts +0 -39
- package/dist/lib/session.js +0 -535
- package/dist/lib/tenant.d.ts +0 -15
- package/dist/lib/tenant.js +0 -65
- package/dist/lib/upload.js +0 -87
- package/dist/lib/ws.d.ts +0 -22
- package/dist/lib/ws.js +0 -89
- package/dist/lib/wsHeartbeat.d.ts +0 -12
- package/dist/lib/wsHeartbeat.js +0 -57
- package/dist/lib/wsMessages.d.ts +0 -40
- package/dist/lib/wsMessages.js +0 -330
- package/dist/lib/wsPresence.d.ts +0 -25
- package/dist/lib/wsPresence.js +0 -99
- package/dist/middleware/auditLog.js +0 -39
- package/dist/middleware/bearerAuth.d.ts +0 -2
- package/dist/middleware/bearerAuth.js +0 -11
- package/dist/middleware/cacheResponse.d.ts +0 -15
- package/dist/middleware/cacheResponse.js +0 -178
- package/dist/middleware/csrf.js +0 -125
- package/dist/middleware/errorHandler.js +0 -13
- package/dist/middleware/identify.d.ts +0 -3
- package/dist/middleware/identify.js +0 -95
- package/dist/middleware/index.js +0 -1
- package/dist/middleware/metrics.d.ts +0 -9
- package/dist/middleware/metrics.js +0 -26
- package/dist/middleware/rateLimit.js +0 -22
- package/dist/middleware/requestId.d.ts +0 -3
- package/dist/middleware/tenant.d.ts +0 -5
- package/dist/middleware/upload.d.ts +0 -5
- package/dist/middleware/userAuth.d.ts +0 -3
- package/dist/middleware/userAuth.js +0 -6
- package/dist/models/AuditLog.d.ts +0 -30
- package/dist/models/AuditLog.js +0 -39
- package/dist/models/AuthUser.js +0 -48
- package/dist/models/Group.d.ts +0 -21
- package/dist/models/Group.js +0 -28
- package/dist/models/GroupMembership.js +0 -25
- package/dist/models/TenantRole.d.ts +0 -15
- package/dist/models/TenantRole.js +0 -23
- package/dist/routes/auth.d.ts +0 -11
- package/dist/routes/auth.js +0 -605
- package/dist/routes/groups.js +0 -346
- package/dist/routes/health.d.ts +0 -1
- package/dist/routes/health.js +0 -22
- package/dist/routes/home.d.ts +0 -1
- package/dist/routes/home.js +0 -16
- package/dist/routes/jobs.d.ts +0 -2
- package/dist/routes/jobs.js +0 -272
- package/dist/routes/metrics.d.ts +0 -7
- package/dist/routes/metrics.js +0 -52
- package/dist/routes/mfa.d.ts +0 -5
- package/dist/routes/mfa.js +0 -620
- package/dist/routes/oauth.d.ts +0 -2
- package/dist/routes/oauth.js +0 -514
- package/dist/routes/uploads.d.ts +0 -2
- package/dist/routes/uploads.js +0 -135
- package/dist/schemas/auth.js +0 -30
- package/dist/server.d.ts +0 -57
- package/dist/server.js +0 -112
- package/dist/services/auth.d.ts +0 -27
- package/dist/services/auth.js +0 -159
- package/dist/ws/index.d.ts +0 -10
- package/dist/ws/index.js +0 -38
- package/docs/sections/adding-middleware/full.md +0 -35
- package/docs/sections/adding-models/full.md +0 -125
- package/docs/sections/adding-models/overview.md +0 -13
- package/docs/sections/adding-routes/full.md +0 -182
- package/docs/sections/adding-routes/overview.md +0 -23
- package/docs/sections/auth-flow/full.md +0 -779
- package/docs/sections/auth-flow/overview.md +0 -10
- package/docs/sections/auth-security-examples/full.md +0 -365
- package/docs/sections/authentication/full.md +0 -130
- package/docs/sections/authentication/overview.md +0 -5
- package/docs/sections/cli/full.md +0 -42
- package/docs/sections/configuration/full.md +0 -172
- package/docs/sections/configuration/overview.md +0 -18
- package/docs/sections/configuration-example/full.md +0 -117
- package/docs/sections/configuration-example/overview.md +0 -30
- package/docs/sections/documentation/full.md +0 -171
- package/docs/sections/environment-variables/full.md +0 -55
- package/docs/sections/exports/full.md +0 -123
- package/docs/sections/extending-context/full.md +0 -59
- package/docs/sections/header.md +0 -3
- package/docs/sections/installation/full.md +0 -6
- package/docs/sections/jobs/full.md +0 -140
- package/docs/sections/jobs/overview.md +0 -15
- package/docs/sections/logging/full.md +0 -83
- package/docs/sections/metrics/full.md +0 -127
- package/docs/sections/mongodb-connections/full.md +0 -45
- package/docs/sections/mongodb-connections/overview.md +0 -7
- package/docs/sections/multi-tenancy/full.md +0 -66
- package/docs/sections/multi-tenancy/overview.md +0 -15
- package/docs/sections/oauth/full.md +0 -189
- package/docs/sections/oauth/overview.md +0 -16
- package/docs/sections/package-development/full.md +0 -7
- package/docs/sections/pagination/full.md +0 -93
- package/docs/sections/peer-dependencies/full.md +0 -47
- package/docs/sections/quick-start/full.md +0 -43
- package/docs/sections/response-caching/full.md +0 -117
- package/docs/sections/response-caching/overview.md +0 -13
- package/docs/sections/roles/full.md +0 -225
- package/docs/sections/roles/overview.md +0 -14
- package/docs/sections/running-without-redis/full.md +0 -16
- package/docs/sections/running-without-redis-or-mongodb/full.md +0 -60
- package/docs/sections/signing/full.md +0 -203
- package/docs/sections/stack/full.md +0 -10
- package/docs/sections/uploads/full.md +0 -199
- package/docs/sections/versioning/full.md +0 -85
- package/docs/sections/webhook-auth/full.md +0 -100
- package/docs/sections/websocket/full.md +0 -184
- package/docs/sections/websocket/overview.md +0 -5
- package/docs/sections/websocket-rooms/full.md +0 -102
- package/docs/sections/websocket-rooms/overview.md +0 -5
- /package/dist/{lib/storageAdapter.js → packages/bunshot-admin/src/types/env.js} +0 -0
- /package/dist/{lib → packages/bunshot-auth/src/lib}/fingerprint.d.ts +0 -0
- /package/dist/{lib → packages/bunshot-core/src}/constants.d.ts +0 -0
- /package/dist/{lib → packages/bunshot-core/src}/storageAdapter.d.ts +0 -0
- /package/dist/{lib → src/framework/lib}/createDtoMapper.d.ts +0 -0
- /package/dist/{lib → src/framework/lib}/stripUnreferencedSchemas.d.ts +0 -0
- /package/dist/{middleware → src/framework/middleware}/cors.d.ts +0 -0
- /package/dist/{middleware → src/framework/middleware}/cors.js +0 -0
- /package/dist/{middleware → src/framework/middleware}/index.d.ts +0 -0
- /package/dist/{middleware → src/framework/middleware}/logger.js +0 -0
- /package/dist/{lib → src/shared/lib}/constants.js +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { registerSchema } from './createRoute';
|
|
3
|
+
export function offsetParams(defaults) {
|
|
4
|
+
const defaultLimit = defaults?.limit ?? 50;
|
|
5
|
+
const defaultOffset = defaults?.offset ?? 0;
|
|
6
|
+
const maxLimit = defaults?.maxLimit ?? 200;
|
|
7
|
+
return z.object({
|
|
8
|
+
limit: z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe(`Number of items to return (1-${maxLimit}, default ${defaultLimit})`),
|
|
12
|
+
offset: z.string().optional().describe(`Number of items to skip (default ${defaultOffset})`),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export function parseOffsetParams(raw, defaults) {
|
|
16
|
+
const defaultLimit = defaults?.limit ?? 50;
|
|
17
|
+
const maxLimit = defaults?.maxLimit ?? 200;
|
|
18
|
+
const defaultOffset = defaults?.offset ?? 0;
|
|
19
|
+
const rawLimit = parseInt(raw.limit ?? '', 10);
|
|
20
|
+
const rawOffset = parseInt(raw.offset ?? '', 10);
|
|
21
|
+
const limit = isNaN(rawLimit) ? defaultLimit : Math.min(Math.max(rawLimit, 1), maxLimit);
|
|
22
|
+
const offset = isNaN(rawOffset) ? defaultOffset : Math.max(rawOffset, 0);
|
|
23
|
+
return { limit, offset };
|
|
24
|
+
}
|
|
25
|
+
export function paginatedResponse(itemSchema, name) {
|
|
26
|
+
const wrapper = z.object({
|
|
27
|
+
items: z.array(itemSchema),
|
|
28
|
+
total: z.number().int().nonnegative(),
|
|
29
|
+
limit: z.number().int().positive(),
|
|
30
|
+
offset: z.number().int().nonnegative(),
|
|
31
|
+
});
|
|
32
|
+
registerSchema(name, wrapper);
|
|
33
|
+
return wrapper;
|
|
34
|
+
}
|
|
35
|
+
export function cursorParams(defaults) {
|
|
36
|
+
const defaultLimit = defaults?.limit ?? 50;
|
|
37
|
+
const maxLimit = defaults?.maxLimit ?? 200;
|
|
38
|
+
return z.object({
|
|
39
|
+
limit: z
|
|
40
|
+
.string()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe(`Number of items to return (1-${maxLimit}, default ${defaultLimit})`),
|
|
43
|
+
cursor: z.string().optional().describe('Opaque pagination cursor from a previous response'),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function parseCursorParams(raw, defaults) {
|
|
47
|
+
const defaultLimit = defaults?.limit ?? 50;
|
|
48
|
+
const maxLimit = defaults?.maxLimit ?? 200;
|
|
49
|
+
const rawLimit = parseInt(raw.limit ?? '', 10);
|
|
50
|
+
const limit = isNaN(rawLimit) ? defaultLimit : Math.min(Math.max(rawLimit, 1), maxLimit);
|
|
51
|
+
const cursor = raw.cursor || undefined;
|
|
52
|
+
return { limit, cursor };
|
|
53
|
+
}
|
|
54
|
+
export function cursorPaginatedResponse(itemSchema, name) {
|
|
55
|
+
const wrapper = z.object({
|
|
56
|
+
items: z.array(itemSchema),
|
|
57
|
+
nextCursor: z.string().optional(),
|
|
58
|
+
});
|
|
59
|
+
registerSchema(name, wrapper);
|
|
60
|
+
return wrapper;
|
|
61
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type SubjectType = 'user' | 'group' | 'service-account';
|
|
2
|
+
export type GrantEffect = 'allow' | 'deny';
|
|
3
|
+
export interface SubjectRef {
|
|
4
|
+
subjectId: string;
|
|
5
|
+
subjectType: SubjectType;
|
|
6
|
+
}
|
|
7
|
+
export interface PermissionGrant {
|
|
8
|
+
id: string;
|
|
9
|
+
subjectId: string;
|
|
10
|
+
subjectType: SubjectType;
|
|
11
|
+
tenantId: string | null;
|
|
12
|
+
resourceType: string | null;
|
|
13
|
+
resourceId: string | null;
|
|
14
|
+
roles: string[];
|
|
15
|
+
effect: GrantEffect;
|
|
16
|
+
grantedBy: string;
|
|
17
|
+
grantedAt: Date;
|
|
18
|
+
reason?: string;
|
|
19
|
+
expiresAt?: Date;
|
|
20
|
+
revokedBy?: string;
|
|
21
|
+
revokedAt?: Date;
|
|
22
|
+
}
|
|
23
|
+
export interface TestablePermissionsAdapter extends PermissionsAdapter {
|
|
24
|
+
clear(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export interface EvaluationScope {
|
|
27
|
+
tenantId?: string;
|
|
28
|
+
resourceType?: string;
|
|
29
|
+
resourceId?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface PermissionsAdapter {
|
|
32
|
+
createGrant(grant: Omit<PermissionGrant, 'id' | 'grantedAt'>): Promise<string>;
|
|
33
|
+
revokeGrant(grantId: string, revokedBy: string, tenantScope?: string): Promise<boolean>;
|
|
34
|
+
getGrantsForSubject(subjectId: string, subjectType?: SubjectType, scope?: Partial<Pick<PermissionGrant, 'tenantId' | 'resourceType' | 'resourceId'>>): Promise<PermissionGrant[]>;
|
|
35
|
+
getEffectiveGrantsForSubject(subjectId: string, subjectType: SubjectType, scope?: EvaluationScope): Promise<PermissionGrant[]>;
|
|
36
|
+
listGrantHistory(subjectId: string, subjectType: SubjectType): Promise<PermissionGrant[]>;
|
|
37
|
+
listGrantsOnResource(resourceType: string, resourceId: string, tenantId?: string | null): Promise<PermissionGrant[]>;
|
|
38
|
+
deleteAllGrantsForSubject(subject: SubjectRef): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export interface ResourceTypeDefinition {
|
|
41
|
+
resourceType: string;
|
|
42
|
+
actions: string[];
|
|
43
|
+
roles: {
|
|
44
|
+
[roleName: string]: string[];
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export interface PermissionRegistry {
|
|
48
|
+
register(definition: ResourceTypeDefinition): void;
|
|
49
|
+
getActionsForRole(resourceType: string, role: string): string[];
|
|
50
|
+
getDefinition(resourceType: string): ResourceTypeDefinition | null;
|
|
51
|
+
listResourceTypes(): ResourceTypeDefinition[];
|
|
52
|
+
}
|
|
53
|
+
export interface GroupResolver {
|
|
54
|
+
getGroupsForUser(userId: string, tenantId: string | null): Promise<string[]>;
|
|
55
|
+
}
|
|
56
|
+
export interface PermissionEvaluator {
|
|
57
|
+
can(subject: SubjectRef, action: string, scope?: {
|
|
58
|
+
tenantId?: string;
|
|
59
|
+
resourceType?: string;
|
|
60
|
+
resourceId?: string;
|
|
61
|
+
}): Promise<boolean>;
|
|
62
|
+
}
|
|
63
|
+
export declare const SUPER_ADMIN_ROLE = "super-admin";
|
|
64
|
+
export declare function validateGrant(grant: Omit<PermissionGrant, 'id' | 'grantedAt'>): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// ── Models ──────────────────────────────────────────────────────────────────
|
|
2
|
+
// ── Constants ───────────────────────────────────────────────────────────────
|
|
3
|
+
export const SUPER_ADMIN_ROLE = 'super-admin';
|
|
4
|
+
// ── Validation ──────────────────────────────────────────────────────────────
|
|
5
|
+
export function validateGrant(grant) {
|
|
6
|
+
if (grant.resourceId !== null && grant.resourceType === null) {
|
|
7
|
+
throw new Error('resourceId requires resourceType to be set');
|
|
8
|
+
}
|
|
9
|
+
if (!grant.roles || grant.roles.length === 0) {
|
|
10
|
+
throw new Error('grant must have at least one role');
|
|
11
|
+
}
|
|
12
|
+
if (grant.effect !== 'allow' && grant.effect !== 'deny') {
|
|
13
|
+
throw new Error("effect must be 'allow' or 'deny'");
|
|
14
|
+
}
|
|
15
|
+
if (grant.expiresAt !== undefined) {
|
|
16
|
+
if (!(grant.expiresAt instanceof Date)) {
|
|
17
|
+
throw new Error('expiresAt must be a Date object');
|
|
18
|
+
}
|
|
19
|
+
if (grant.expiresAt < new Date()) {
|
|
20
|
+
throw new Error('expiresAt must be in the future');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const validSubjectTypes = ['user', 'group', 'service-account'];
|
|
24
|
+
if (!validSubjectTypes.includes(grant.subjectType)) {
|
|
25
|
+
throw new Error('invalid subjectType');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import type { BunshotFrameworkConfig } from './context/frameworkConfig';
|
|
3
|
+
import type { BunshotEventBus } from './eventBus';
|
|
4
|
+
export interface BunshotPlugin {
|
|
5
|
+
name: string;
|
|
6
|
+
dependencies?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Called after framework middleware (requestId, metrics, logger, secureHeaders, cors, bot,
|
|
9
|
+
* rateLimit) and before tenant/custom middleware. Use this for request middleware that must
|
|
10
|
+
* run early in the chain (e.g. auth, CSRF, MFA enforcement).
|
|
11
|
+
*/
|
|
12
|
+
setupMiddleware?(app: Hono<any>, config: BunshotFrameworkConfig, bus: BunshotEventBus): void | Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Called after tenant and custom middleware, before framework route mounting and user route
|
|
15
|
+
* discovery. Use this to mount plugin routes so they receive tenant context.
|
|
16
|
+
*
|
|
17
|
+
* Auth routes receive tenant context because tenant middleware runs before this phase.
|
|
18
|
+
*/
|
|
19
|
+
setupRoutes?(app: Hono<any>, config: BunshotFrameworkConfig, bus: BunshotEventBus): void | Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Called after all routes, OpenAPI docs, and error handlers are registered.
|
|
22
|
+
* Use this for post-assembly inspection, metrics registration, or other post-startup work.
|
|
23
|
+
*
|
|
24
|
+
* NOT for registering routes or request middleware — routes registered here are invisible
|
|
25
|
+
* to OpenAPI and unreachable by app.onError.
|
|
26
|
+
*/
|
|
27
|
+
setupPost?(app: Hono<any>, config: BunshotFrameworkConfig, bus: BunshotEventBus): void | Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Standalone convenience — the framework NEVER calls this method.
|
|
30
|
+
*
|
|
31
|
+
* Plain Hono apps (without the full Bunshot framework orchestrator) call `setup()` directly
|
|
32
|
+
* to register middleware and routes in one call. A typical implementation calls
|
|
33
|
+
* `setupMiddleware` then `setupRoutes` in sequence.
|
|
34
|
+
*
|
|
35
|
+
* Define `setupMiddleware`/`setupRoutes`/`setupPost` for framework integration.
|
|
36
|
+
* Define `setup` for standalone usage. Both can coexist without double-execution risk —
|
|
37
|
+
* the framework calls only the phase methods, never `setup()`.
|
|
38
|
+
*/
|
|
39
|
+
setup?(app: Hono<any>, config: BunshotFrameworkConfig, bus: BunshotEventBus): void | Promise<void>;
|
|
40
|
+
teardown?(): void | Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export interface StandalonePlugin extends BunshotPlugin {
|
|
43
|
+
setup(app: Hono<any>, config: BunshotFrameworkConfig, bus: BunshotEventBus): void | Promise<void>;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ContextCarrier } from './context/contextAccess';
|
|
2
|
+
import type { FingerprintBuilder, RateLimitAdapter } from './coreContracts';
|
|
3
|
+
export type { FingerprintBuilder, RateLimitAdapter };
|
|
4
|
+
export declare function getRateLimitAdapter(input: ContextCarrier): RateLimitAdapter;
|
|
5
|
+
export declare function getFingerprintBuilder(input: ContextCarrier): FingerprintBuilder;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { resolveContext } from './context/contextAccess';
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// RateLimitAdapter + FingerprintBuilder -- rate limiting contracts.
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
export function getRateLimitAdapter(input) {
|
|
6
|
+
const adapter = resolveContext(input).rateLimitAdapter;
|
|
7
|
+
if (adapter === null) {
|
|
8
|
+
throw new Error('No RateLimitAdapter registered for this app instance.');
|
|
9
|
+
}
|
|
10
|
+
return adapter;
|
|
11
|
+
}
|
|
12
|
+
export function getFingerprintBuilder(input) {
|
|
13
|
+
const builder = resolveContext(input).fingerprintBuilder;
|
|
14
|
+
if (builder === null) {
|
|
15
|
+
throw new Error('No FingerprintBuilder registered for this app instance.');
|
|
16
|
+
}
|
|
17
|
+
return builder;
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Redis client interface used across all bunshot packages.
|
|
3
|
+
* Concrete implementations (ioredis, etc.) satisfy this contract.
|
|
4
|
+
*/
|
|
5
|
+
export interface RedisLike {
|
|
6
|
+
get(key: string): Promise<string | null>;
|
|
7
|
+
mget(...keys: string[]): Promise<Array<string | null>>;
|
|
8
|
+
set(key: string, value: string, ...args: unknown[]): Promise<unknown>;
|
|
9
|
+
setex(key: string, seconds: number, value: string): Promise<unknown>;
|
|
10
|
+
del(...keys: string[]): Promise<number>;
|
|
11
|
+
expire(key: string, seconds: number): Promise<number>;
|
|
12
|
+
keys(pattern: string): Promise<string[]>;
|
|
13
|
+
zrange(key: string, start: number, stop: number): Promise<string[]>;
|
|
14
|
+
zadd(key: string, score: number, member: string): Promise<number>;
|
|
15
|
+
zrem(key: string, ...members: string[]): Promise<number>;
|
|
16
|
+
lpush(key: string, value: string): Promise<number>;
|
|
17
|
+
ltrim(key: string, start: number, stop: number): Promise<string>;
|
|
18
|
+
lrange(key: string, start: number, stop: number): Promise<string[]>;
|
|
19
|
+
getdel?(key: string): Promise<string | null>;
|
|
20
|
+
eval(script: string, numkeys: number, ...args: unknown[]): Promise<unknown>;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ContextCarrier } from './context/contextAccess';
|
|
2
|
+
import type { RouteAuthRegistry } from './coreContracts';
|
|
3
|
+
export type { RouteAuthRegistry };
|
|
4
|
+
export declare function getRouteAuth(input: ContextCarrier): RouteAuthRegistry;
|
|
5
|
+
export declare function getRouteAuthOrNull(input: ContextCarrier): RouteAuthRegistry | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { resolveContext } from './context/contextAccess';
|
|
2
|
+
export function getRouteAuth(input) {
|
|
3
|
+
const registry = resolveContext(input).routeAuth;
|
|
4
|
+
if (registry === null) {
|
|
5
|
+
throw new Error('No RouteAuthRegistry registered for this app instance. The auth plugin must be registered when using auth: "userAuth" in jobs, metrics, or uploads config.');
|
|
6
|
+
}
|
|
7
|
+
return registry;
|
|
8
|
+
}
|
|
9
|
+
export function getRouteAuthOrNull(input) {
|
|
10
|
+
return resolveContext(input).routeAuth;
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed route key: "METHOD /path" (method always uppercased).
|
|
3
|
+
* Constructed exclusively via routeKey() — never hand-typed — to prevent drift.
|
|
4
|
+
*/
|
|
5
|
+
export type RouteKey<M extends string, P extends string> = `${Uppercase<M>} ${P}`;
|
|
6
|
+
/**
|
|
7
|
+
* Constructs a typed route key from method and path.
|
|
8
|
+
*
|
|
9
|
+
* Use this to define ROUTES constants and nowhere else:
|
|
10
|
+
* export const MY_ROUTES = [routeKey('GET', '/items'), routeKey('POST', '/items')] as const;
|
|
11
|
+
*
|
|
12
|
+
* shouldMountRoute() calls routeKey() internally with the same arguments, so
|
|
13
|
+
* the constant values and the runtime check are always identical.
|
|
14
|
+
*/
|
|
15
|
+
export declare function routeKey<M extends string, P extends string>(method: M, path: P): RouteKey<M, P>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns true if the route should be mounted (i.e. NOT in disabledRoutes).
|
|
18
|
+
* Pass the same method/path you used when defining the ROUTES constant.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* if (shouldMountRoute('GET', '/items', config.disableRoutes))
|
|
22
|
+
* router.openapi(listRoute, handler);
|
|
23
|
+
*/
|
|
24
|
+
export declare function shouldMountRoute(method: string, path: string, disabledRoutes?: readonly string[]): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs a typed route key from method and path.
|
|
3
|
+
*
|
|
4
|
+
* Use this to define ROUTES constants and nowhere else:
|
|
5
|
+
* export const MY_ROUTES = [routeKey('GET', '/items'), routeKey('POST', '/items')] as const;
|
|
6
|
+
*
|
|
7
|
+
* shouldMountRoute() calls routeKey() internally with the same arguments, so
|
|
8
|
+
* the constant values and the runtime check are always identical.
|
|
9
|
+
*/
|
|
10
|
+
export function routeKey(method, path) {
|
|
11
|
+
return `${method.toUpperCase()} ${path}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns true if the route should be mounted (i.e. NOT in disabledRoutes).
|
|
15
|
+
* Pass the same method/path you used when defining the ROUTES constant.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* if (shouldMountRoute('GET', '/items', config.disableRoutes))
|
|
19
|
+
* router.openapi(listRoute, handler);
|
|
20
|
+
*/
|
|
21
|
+
export function shouldMountRoute(method, path, disabledRoutes) {
|
|
22
|
+
if (!disabledRoutes?.length)
|
|
23
|
+
return true;
|
|
24
|
+
return !disabledRoutes.includes(routeKey(method, path));
|
|
25
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function resolveAdapter(event, opts) {
|
|
2
|
+
if (!opts.namespaces)
|
|
3
|
+
return opts.default;
|
|
4
|
+
// Longest prefix wins
|
|
5
|
+
let bestMatch = '';
|
|
6
|
+
let bestAdapter;
|
|
7
|
+
for (const [prefix, adapter] of Object.entries(opts.namespaces)) {
|
|
8
|
+
if (event.startsWith(prefix) && prefix.length > bestMatch.length) {
|
|
9
|
+
bestMatch = prefix;
|
|
10
|
+
bestAdapter = adapter;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return bestAdapter ?? opts.default;
|
|
14
|
+
}
|
|
15
|
+
export function createRouterAdapter(opts) {
|
|
16
|
+
function allAdapters() {
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
seen.add(opts.default);
|
|
19
|
+
if (opts.namespaces) {
|
|
20
|
+
for (const adapter of Object.values(opts.namespaces)) {
|
|
21
|
+
seen.add(adapter);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return [...seen];
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
emit(event, payload) {
|
|
28
|
+
resolveAdapter(event, opts).emit(event, payload);
|
|
29
|
+
},
|
|
30
|
+
on(event, listener, subscriptionOpts) {
|
|
31
|
+
resolveAdapter(event, opts).on(event, listener, subscriptionOpts);
|
|
32
|
+
},
|
|
33
|
+
off(event, listener) {
|
|
34
|
+
resolveAdapter(event, opts).off(event, listener);
|
|
35
|
+
},
|
|
36
|
+
async shutdown() {
|
|
37
|
+
await Promise.all(allAdapters().map(adapter => adapter.shutdown?.()));
|
|
38
|
+
},
|
|
39
|
+
get clientSafeKeys() {
|
|
40
|
+
const keys = new Set();
|
|
41
|
+
for (const adapter of allAdapters()) {
|
|
42
|
+
for (const key of adapter.clientSafeKeys)
|
|
43
|
+
keys.add(key);
|
|
44
|
+
}
|
|
45
|
+
return keys;
|
|
46
|
+
},
|
|
47
|
+
registerClientSafeEvents(keys) {
|
|
48
|
+
for (const adapter of allAdapters()) {
|
|
49
|
+
adapter.registerClientSafeEvents(keys);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
ensureClientSafeEventKey(key, source) {
|
|
53
|
+
return resolveAdapter(key, opts).ensureClientSafeEventKey(key, source);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret repository contracts — read-only abstraction for resolving
|
|
3
|
+
* credentials, API keys, and signing secrets from any backing store.
|
|
4
|
+
*
|
|
5
|
+
* Resolved at startup BEFORE database connections are established.
|
|
6
|
+
* Implementations must be self-contained (no DB dependencies).
|
|
7
|
+
*/
|
|
8
|
+
export type SecretStoreType = 'env' | 'ssm' | 'file';
|
|
9
|
+
/**
|
|
10
|
+
* Read-only secret repository. Resolved at startup before any DB connections.
|
|
11
|
+
* Implementations must be self-contained (no DB dependencies).
|
|
12
|
+
*/
|
|
13
|
+
export interface ISecretRepository {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
/** Get a single secret by path/key. Returns null if not found. */
|
|
16
|
+
get(key: string): Promise<string | null>;
|
|
17
|
+
/** Get multiple secrets by key list. */
|
|
18
|
+
getMany(keys: string[]): Promise<ReadonlyMap<string, string>>;
|
|
19
|
+
/**
|
|
20
|
+
* Eagerly load all secrets (called once at startup).
|
|
21
|
+
* Implementations that support batch loading (SSM GetParametersByPath)
|
|
22
|
+
* should prefetch here to avoid N+1 latency.
|
|
23
|
+
*/
|
|
24
|
+
initialize?(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Refresh cached secrets from the backing store.
|
|
27
|
+
* Called on rotation events or periodic refresh. No-op for env provider.
|
|
28
|
+
*/
|
|
29
|
+
refresh?(): Promise<void>;
|
|
30
|
+
/** Release resources (close connections, clear caches). */
|
|
31
|
+
destroy?(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export interface SecretDefinition {
|
|
34
|
+
/** The path/key in the secret store (e.g., '/app/prod/db/password' or 'MONGO_PASSWORD') */
|
|
35
|
+
path: string;
|
|
36
|
+
/** Whether startup should fail if this secret is missing. Default: true */
|
|
37
|
+
required?: boolean;
|
|
38
|
+
/** Default value when not found and not required. */
|
|
39
|
+
default?: string;
|
|
40
|
+
}
|
|
41
|
+
export type SecretSchema = Record<string, SecretDefinition>;
|
|
42
|
+
/**
|
|
43
|
+
* Resolved secrets — keys from the schema, values are the secret strings.
|
|
44
|
+
* Returned as a frozen plain object for direct property access.
|
|
45
|
+
*/
|
|
46
|
+
export type ResolvedSecrets<S extends SecretSchema> = {
|
|
47
|
+
readonly [K in keyof S]: string;
|
|
48
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret repository contracts — read-only abstraction for resolving
|
|
3
|
+
* credentials, API keys, and signing secrets from any backing store.
|
|
4
|
+
*
|
|
5
|
+
* Resolved at startup BEFORE database connections are established.
|
|
6
|
+
* Implementations must be self-contained (no DB dependencies).
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface SigningConfig {
|
|
2
|
+
/**
|
|
3
|
+
* HMAC secret. Defaults to JWT_SECRET env var if omitted.
|
|
4
|
+
* Pass string[] to support key rotation - first element signs, all elements verify.
|
|
5
|
+
*/
|
|
6
|
+
secret?: string | string[];
|
|
7
|
+
/** Sign/verify cookie values set via exported helpers. Default: false. */
|
|
8
|
+
cookies?: boolean;
|
|
9
|
+
/** Sign pagination cursor tokens to prevent client tampering. Default: false. */
|
|
10
|
+
cursors?: boolean;
|
|
11
|
+
/** HMAC-based stateless presigned URLs (no DB lookup). Default: false. */
|
|
12
|
+
presignedUrls?: boolean | {
|
|
13
|
+
defaultExpiry?: number;
|
|
14
|
+
};
|
|
15
|
+
/** Require clients to HMAC-sign requests (method+path+timestamp+body). Default: false. */
|
|
16
|
+
requestSigning?: boolean | {
|
|
17
|
+
tolerance?: number;
|
|
18
|
+
header?: string;
|
|
19
|
+
timestampHeader?: string;
|
|
20
|
+
};
|
|
21
|
+
/** Hash idempotency keys before storage. Default: false. */
|
|
22
|
+
idempotencyKeys?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Bind sessions to a client fingerprint so a stolen JWT+session pair cannot
|
|
25
|
+
* be replayed from a different browser or IP.
|
|
26
|
+
*
|
|
27
|
+
* - `true` — bind to IP + User-Agent (strictest; may false-positive on mobile
|
|
28
|
+
* users or deployments that terminate TLS at a CDN/proxy that rewrites IPs).
|
|
29
|
+
* - `{ fields: ['ua'], onMismatch: 'log-only' }` — UA-only binding in
|
|
30
|
+
* observation mode; safe starting point for mobile or CDN-heavy deployments.
|
|
31
|
+
* - `{ fields: ['ip', 'ua'], onMismatch: 'reject' }` — hard reject on mismatch
|
|
32
|
+
* (most aggressive; returns 401 instead of silently unauthenticating).
|
|
33
|
+
*
|
|
34
|
+
* **Not enabled by default.** Production deployments are warned at startup when
|
|
35
|
+
* this is absent. Explicitly set to `false` to silence the warning.
|
|
36
|
+
*/
|
|
37
|
+
sessionBinding?: boolean | {
|
|
38
|
+
fields?: Array<'ip' | 'ua' | 'accept-language'>;
|
|
39
|
+
onMismatch?: 'unauthenticate' | 'reject' | 'log-only';
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ClientSafeEventKey } from './eventBus';
|
|
2
|
+
/**
|
|
3
|
+
* Generic client data attached to each SSE connection.
|
|
4
|
+
* Same pattern as SocketData<T> in ws/index.ts.
|
|
5
|
+
*/
|
|
6
|
+
export type SseClientData<T extends object = object> = {
|
|
7
|
+
id: string;
|
|
8
|
+
userId: string | null;
|
|
9
|
+
endpoint: string;
|
|
10
|
+
} & T;
|
|
11
|
+
/**
|
|
12
|
+
* Per-client, per-event filter for SSE fanout.
|
|
13
|
+
* Return false to suppress delivery to this client.
|
|
14
|
+
*/
|
|
15
|
+
export type SseFilter<T extends object = object> = (client: SseClientData<T>, event: ClientSafeEventKey, payload: unknown) => boolean | Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for a single SSE endpoint.
|
|
18
|
+
* Used in CreateServerConfig.sse.endpoints.
|
|
19
|
+
*/
|
|
20
|
+
export interface SseEndpointConfig<T extends object = object> {
|
|
21
|
+
/** Client-safe event keys this endpoint forwards. */
|
|
22
|
+
events: ClientSafeEventKey[];
|
|
23
|
+
/**
|
|
24
|
+
* Auth hook. Return SseClientData<T> to accept. Return a Response to reject.
|
|
25
|
+
* Default: createSseUpgradeHandler(endpoint) — resolves userId from cookie/token,
|
|
26
|
+
* returns userId: null on auth failure (permissive, mirrors WS default).
|
|
27
|
+
*/
|
|
28
|
+
upgrade?: (req: Request) => Promise<SseClientData<T> | Response>;
|
|
29
|
+
/**
|
|
30
|
+
* Per-client, per-event filter. Return false to suppress.
|
|
31
|
+
* Called async per fanout call — keep it fast.
|
|
32
|
+
*/
|
|
33
|
+
filter?: SseFilter<T>;
|
|
34
|
+
/** Keep-alive heartbeat interval ms. false = disabled. Default: 30_000 */
|
|
35
|
+
heartbeat?: number | false;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical store infrastructure contract shared across all bunshot packages.
|
|
3
|
+
*
|
|
4
|
+
* Plugin authors import these types from `@lastshotlabs/bunshot-core` to declare
|
|
5
|
+
* repository factories without depending on framework or auth internals.
|
|
6
|
+
*
|
|
7
|
+
* The pattern:
|
|
8
|
+
* 1. Declare `RepoFactories<YourRepo>` with one factory per StoreType
|
|
9
|
+
* 2. Call `resolveRepo(factories, storeType, infra)` at startup
|
|
10
|
+
* 3. The framework provides `StoreInfra` — your factory receives it
|
|
11
|
+
*/
|
|
12
|
+
import type { Database } from 'bun:sqlite';
|
|
13
|
+
import type { Connection } from 'mongoose';
|
|
14
|
+
import type { Pool } from 'pg';
|
|
15
|
+
import type { RedisLike } from './redis';
|
|
16
|
+
import type { StoreType } from './storeType';
|
|
17
|
+
/**
|
|
18
|
+
* Postgres bundle passed through StoreInfra.
|
|
19
|
+
* The concrete implementation (`DrizzlePostgresDb`) lives in
|
|
20
|
+
* @lastshotlabs/bunshot-postgres and satisfies this interface.
|
|
21
|
+
* `db` is typed as `unknown` here to avoid pulling drizzle-orm into core;
|
|
22
|
+
* import from bunshot-postgres for the full `NodePgDatabase` type.
|
|
23
|
+
*/
|
|
24
|
+
export interface PostgresBundle {
|
|
25
|
+
readonly pool: Pool;
|
|
26
|
+
readonly db: unknown;
|
|
27
|
+
}
|
|
28
|
+
export interface StoreInfra {
|
|
29
|
+
readonly appName: string;
|
|
30
|
+
readonly getRedis: () => RedisLike;
|
|
31
|
+
readonly getMongo: () => {
|
|
32
|
+
conn: Connection;
|
|
33
|
+
mg: typeof import('mongoose');
|
|
34
|
+
};
|
|
35
|
+
readonly getSqliteDb: () => Database;
|
|
36
|
+
readonly getPostgres: () => PostgresBundle;
|
|
37
|
+
}
|
|
38
|
+
export type RepoFactories<T> = Record<StoreType, (infra: StoreInfra) => T>;
|
|
39
|
+
export declare function resolveRepo<T>(factories: RepoFactories<T>, storeType: StoreType, infra: StoreInfra): T;
|
|
40
|
+
/**
|
|
41
|
+
* Like resolveRepo but supports factories that return a Promise.
|
|
42
|
+
* Use this when the selected adapter requires async initialisation (e.g. migrations).
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveRepoAsync<T>(factories: Record<StoreType, (infra: StoreInfra) => T | Promise<T>>, storeType: StoreType, infra: StoreInfra): Promise<T>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function resolveRepo(factories, storeType, infra) {
|
|
2
|
+
const factory = factories[storeType];
|
|
3
|
+
if (!factory) {
|
|
4
|
+
throw new Error(`[bunshot] Unsupported store type: ${storeType}`);
|
|
5
|
+
}
|
|
6
|
+
return factory(infra);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Like resolveRepo but supports factories that return a Promise.
|
|
10
|
+
* Use this when the selected adapter requires async initialisation (e.g. migrations).
|
|
11
|
+
*/
|
|
12
|
+
export async function resolveRepoAsync(factories, storeType, infra) {
|
|
13
|
+
const factory = factories[storeType];
|
|
14
|
+
if (!factory) {
|
|
15
|
+
throw new Error(`[bunshot] Unsupported store type: ${storeType}`);
|
|
16
|
+
}
|
|
17
|
+
return factory(infra);
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical store-type union shared across bunshot packages.
|
|
3
|
+
*
|
|
4
|
+
* Add new backing stores here — auth and framework both derive from this type,
|
|
5
|
+
* so a single addition keeps them in sync.
|
|
6
|
+
*/
|
|
7
|
+
export type StoreType = 'redis' | 'mongo' | 'sqlite' | 'memory' | 'postgres';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface UploadRecord {
|
|
2
|
+
key: string;
|
|
3
|
+
ownerUserId?: string;
|
|
4
|
+
tenantId?: string;
|
|
5
|
+
mimeType?: string;
|
|
6
|
+
bucket?: string;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* UploadRegistryRepository — storage contract for upload ownership tracking.
|
|
11
|
+
*
|
|
12
|
+
* Implementations store upload metadata keyed by the storage key.
|
|
13
|
+
* Used to verify ownership and tenancy when users request presigned
|
|
14
|
+
* download URLs or delete operations.
|
|
15
|
+
*/
|
|
16
|
+
export interface UploadRegistryRepository {
|
|
17
|
+
/** Store a new upload record. Keyed by record.key. */
|
|
18
|
+
register(record: UploadRecord): Promise<void>;
|
|
19
|
+
/** Retrieve an upload record by key. Returns null if not found. */
|
|
20
|
+
get(key: string): Promise<UploadRecord | null>;
|
|
21
|
+
/** Delete an upload record by key. Returns true if it existed. */
|
|
22
|
+
delete(key: string): Promise<boolean>;
|
|
23
|
+
}
|