@lastshotlabs/bunshot 0.0.27 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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/{lib → packages/bunshot-auth/src/lib}/breachedPassword.d.ts +8 -2
- package/dist/{lib → packages/bunshot-auth/src/lib}/breachedPassword.js +22 -9
- 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 +211 -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/{lib → packages/bunshot-auth/src/lib}/logger.js +3 -3
- package/dist/{lib → packages/bunshot-auth/src/lib}/m2m.d.ts +5 -4
- package/dist/{lib → packages/bunshot-auth/src/lib}/m2m.js +6 -10
- 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/{lib → packages/bunshot-auth/src/lib}/scim.d.ts +7 -7
- package/dist/{lib → packages/bunshot-auth/src/lib}/scim.js +15 -13
- 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/{lib → packages/bunshot-auth/src/lib}/suspension.d.ts +3 -2
- package/dist/{lib → packages/bunshot-auth/src/lib}/suspension.js +2 -5
- 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 -8
- 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/{middleware → packages/bunshot-auth/src/middleware}/requireScope.d.ts +2 -2
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/requireScope.js +6 -6
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/requireStepUp.d.ts +2 -2
- package/dist/{middleware → packages/bunshot-auth/src/middleware}/requireStepUp.js +8 -7
- 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 +12 -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/{models → packages/bunshot-auth/src/models}/M2MClient.d.ts +1 -1
- package/dist/{models → packages/bunshot-auth/src/models}/M2MClient.js +5 -5
- 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 +277 -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/{lib → packages/bunshot-core/src}/captcha.d.ts +1 -10
- 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/{lib/HttpError.d.ts → packages/bunshot-core/src/errors.d.ts} +4 -1
- package/dist/{lib/HttpError.js → packages/bunshot-core/src/errors.js} +7 -1
- 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 +10 -10
- 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/{lib → src/framework/lib}/captcha.js +13 -10
- 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 +11 -10
- 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/{middleware → src/framework/middleware}/captcha.d.ts +2 -3
- package/dist/src/framework/middleware/captcha.js +37 -0
- package/dist/{middleware → src/framework/middleware}/errorHandler.d.ts +1 -1
- package/dist/{middleware → src/framework/middleware}/errorHandler.js +2 -2
- 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 -20
- 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 -12
- 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 +64 -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/{routes → src/framework/routes}/jobs.js +128 -103
- package/dist/src/framework/routes/metrics.d.ts +10 -0
- package/dist/src/framework/routes/metrics.js +57 -0
- package/dist/{routes → src/framework/routes}/uploads.d.ts +3 -3
- 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/{lib/appConfig.js → src/lib/authConfig.js} +75 -17
- package/dist/{lib → src/lib}/context.d.ts +6 -12
- 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 +35 -8
- package/dist/src/testing.d.ts +34 -0
- package/dist/src/testing.js +93 -0
- package/package.json +100 -26
- package/dist/adapters/memoryAuth.d.ts +0 -52
- package/dist/adapters/memoryAuth.js +0 -749
- 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 -403
- package/dist/adapters/sqliteAuth.d.ts +0 -72
- package/dist/adapters/sqliteAuth.js +0 -858
- package/dist/app.d.ts +0 -559
- package/dist/app.js +0 -651
- 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 -117
- package/dist/index.js +0 -88
- package/dist/lib/appConfig.d.ts +0 -275
- package/dist/lib/auditLog.d.ts +0 -58
- package/dist/lib/auditLog.js +0 -218
- package/dist/lib/authAdapter.d.ts +0 -246
- package/dist/lib/authAdapter.js +0 -7
- package/dist/lib/authRateLimit.d.ts +0 -13
- package/dist/lib/authRateLimit.js +0 -117
- package/dist/lib/clientIp.d.ts +0 -14
- package/dist/lib/credentialStuffing.d.ts +0 -31
- package/dist/lib/credentialStuffing.js +0 -77
- 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 -19
- package/dist/lib/emailVerification.js +0 -129
- package/dist/lib/fingerprint.js +0 -36
- package/dist/lib/idempotency.js +0 -182
- package/dist/lib/jwks.d.ts +0 -25
- package/dist/lib/jwks.js +0 -51
- package/dist/lib/jwt.d.ts +0 -15
- package/dist/lib/jwt.js +0 -111
- package/dist/lib/metrics.d.ts +0 -14
- package/dist/lib/mfaChallenge.d.ts +0 -55
- package/dist/lib/mfaChallenge.js +0 -398
- 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 -95
- 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 -93
- package/dist/lib/roles.d.ts +0 -7
- package/dist/lib/roles.js +0 -49
- package/dist/lib/saml.d.ts +0 -25
- package/dist/lib/saml.js +0 -64
- package/dist/lib/securityEvents.d.ts +0 -28
- package/dist/lib/securityEvents.js +0 -26
- package/dist/lib/session.d.ts +0 -49
- package/dist/lib/session.js +0 -597
- package/dist/lib/tenant.d.ts +0 -15
- package/dist/lib/tenant.js +0 -65
- package/dist/lib/upload.js +0 -112
- package/dist/lib/uploadRegistry.d.ts +0 -18
- package/dist/lib/uploadRegistry.js +0 -83
- package/dist/lib/ws.d.ts +0 -22
- package/dist/lib/ws.js +0 -96
- 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/captcha.js +0 -36
- package/dist/middleware/csrf.js +0 -129
- package/dist/middleware/identify.d.ts +0 -3
- package/dist/middleware/identify.js +0 -122
- 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/scimAuth.d.ts +0 -8
- package/dist/middleware/scimAuth.js +0 -29
- 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 -55
- 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 -12
- package/dist/routes/auth.js +0 -744
- 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/m2m.d.ts +0 -2
- package/dist/routes/m2m.js +0 -72
- package/dist/routes/metrics.d.ts +0 -8
- package/dist/routes/metrics.js +0 -55
- package/dist/routes/mfa.d.ts +0 -5
- package/dist/routes/mfa.js +0 -628
- package/dist/routes/oauth.d.ts +0 -2
- package/dist/routes/oauth.js +0 -520
- package/dist/routes/oidc.d.ts +0 -2
- package/dist/routes/oidc.js +0 -29
- package/dist/routes/passkey.d.ts +0 -1
- package/dist/routes/passkey.js +0 -157
- package/dist/routes/saml.d.ts +0 -2
- package/dist/routes/saml.js +0 -86
- package/dist/routes/scim.d.ts +0 -2
- package/dist/routes/scim.js +0 -255
- package/dist/routes/uploads.js +0 -227
- 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 -29
- package/dist/services/auth.js +0 -238
- package/dist/ws/index.d.ts +0 -10
- package/dist/ws/index.js +0 -39
- 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 -790
- package/docs/sections/auth-flow/overview.md +0 -10
- package/docs/sections/auth-security-examples/full.md +0 -388
- 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 -131
- 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/passkey-login/full.md +0 -90
- package/docs/sections/passkey-login/overview.md +0 -1
- 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 -208
- package/docs/sections/versioning/full.md +0 -85
- package/docs/sections/webhook-auth/full.md +0 -100
- package/docs/sections/websocket/full.md +0 -196
- 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-auth/src/lib}/logger.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,709 @@
|
|
|
1
|
+
import { Args, Command } from '@oclif/core';
|
|
2
|
+
import { spawnSync } from 'child_process';
|
|
3
|
+
import { existsSync, mkdirSync, readSync, rmSync, writeFileSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
function ask(question) {
|
|
6
|
+
process.stdout.write(question);
|
|
7
|
+
const buf = Buffer.alloc(1024);
|
|
8
|
+
const n = readSync(0, buf, 0, buf.length, null);
|
|
9
|
+
return buf.subarray(0, n).toString().trim().replace(/\r/g, '');
|
|
10
|
+
}
|
|
11
|
+
function choose(question, options, defaultIndex = 0) {
|
|
12
|
+
let selected = defaultIndex;
|
|
13
|
+
function render(initial = false) {
|
|
14
|
+
if (!initial) {
|
|
15
|
+
process.stdout.write(`\x1B[${options.length}A`);
|
|
16
|
+
}
|
|
17
|
+
for (let i = 0; i < options.length; i++) {
|
|
18
|
+
const active = i === selected;
|
|
19
|
+
const marker = active ? '\x1B[36m>\x1B[0m' : ' ';
|
|
20
|
+
const label = active ? `\x1B[1m${options[i]}\x1B[0m` : `\x1B[2m${options[i]}\x1B[0m`;
|
|
21
|
+
process.stdout.write(`\x1B[2K ${marker} ${label}\n`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Non-TTY fallback (piped input, CI, etc.)
|
|
25
|
+
if (!process.stdin.isTTY) {
|
|
26
|
+
console.log(question);
|
|
27
|
+
options.forEach((opt, i) => console.log(` ${i + 1}) ${opt}`));
|
|
28
|
+
const raw = ask(` Choose [${defaultIndex + 1}]: `);
|
|
29
|
+
if (!raw)
|
|
30
|
+
return defaultIndex;
|
|
31
|
+
const num = parseInt(raw);
|
|
32
|
+
if (num >= 1 && num <= options.length)
|
|
33
|
+
return num - 1;
|
|
34
|
+
return defaultIndex;
|
|
35
|
+
}
|
|
36
|
+
console.log(question);
|
|
37
|
+
process.stdout.write('\x1B[?25l'); // hide cursor
|
|
38
|
+
render(true);
|
|
39
|
+
process.stdin.setRawMode(true);
|
|
40
|
+
const buf = Buffer.alloc(16);
|
|
41
|
+
try {
|
|
42
|
+
while (true) {
|
|
43
|
+
const n = readSync(0, buf, 0, buf.length, null);
|
|
44
|
+
const key = buf.subarray(0, n).toString();
|
|
45
|
+
if (key === '\r' || key === '\n') {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
else if (key === '\x1B[A' || key === '\x1BOA') {
|
|
49
|
+
// Up arrow
|
|
50
|
+
selected = (selected - 1 + options.length) % options.length;
|
|
51
|
+
render();
|
|
52
|
+
}
|
|
53
|
+
else if (key === '\x1B[B' || key === '\x1BOB') {
|
|
54
|
+
// Down arrow
|
|
55
|
+
selected = (selected + 1) % options.length;
|
|
56
|
+
render();
|
|
57
|
+
}
|
|
58
|
+
else if (key === '\x03') {
|
|
59
|
+
// Ctrl+C
|
|
60
|
+
process.stdout.write('\x1B[?25h\n');
|
|
61
|
+
process.stdin.setRawMode(false);
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Number key quick-select
|
|
66
|
+
const num = parseInt(key);
|
|
67
|
+
if (num >= 1 && num <= options.length) {
|
|
68
|
+
selected = num - 1;
|
|
69
|
+
render();
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
process.stdin.setRawMode(false);
|
|
77
|
+
process.stdout.write('\x1B[?25h'); // show cursor
|
|
78
|
+
}
|
|
79
|
+
return selected;
|
|
80
|
+
}
|
|
81
|
+
export default class Init extends Command {
|
|
82
|
+
static description = 'Scaffold a new Bunshot application';
|
|
83
|
+
static examples = [
|
|
84
|
+
'<%= config.bin %> init my-app',
|
|
85
|
+
'<%= config.bin %> init my-app ./apps/my-app',
|
|
86
|
+
];
|
|
87
|
+
static args = {
|
|
88
|
+
name: Args.string({ description: 'App name' }),
|
|
89
|
+
dir: Args.string({ description: 'Output directory' }),
|
|
90
|
+
};
|
|
91
|
+
async run() {
|
|
92
|
+
const { args } = await this.parse(Init);
|
|
93
|
+
const argTitle = args.name;
|
|
94
|
+
const argDir = args.dir;
|
|
95
|
+
const appTitle = argTitle || ask('App name: ');
|
|
96
|
+
if (!appTitle) {
|
|
97
|
+
console.error('App name is required.');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
const dirDefault = appTitle
|
|
101
|
+
.toLowerCase()
|
|
102
|
+
.replace(/\s+/g, '-')
|
|
103
|
+
.replace(/[^a-z0-9-]/g, '');
|
|
104
|
+
const dirName = argDir || (argTitle ? dirDefault : ask(`Directory (${dirDefault}): `)) || dirDefault;
|
|
105
|
+
let mongoMode = false;
|
|
106
|
+
let useRedis = false;
|
|
107
|
+
let authStore = 'mongo';
|
|
108
|
+
let sessionStore = 'redis';
|
|
109
|
+
let cacheStore = 'redis';
|
|
110
|
+
let oauthStateStore = 'redis';
|
|
111
|
+
console.log('');
|
|
112
|
+
const presetChoice = choose('Database setup:', [
|
|
113
|
+
'Full stack (MongoDB + Redis — production ready)',
|
|
114
|
+
'SQLite (single file, no external services)',
|
|
115
|
+
'Memory (ephemeral, great for prototyping/tests)',
|
|
116
|
+
'Custom (choose each store individually)',
|
|
117
|
+
]);
|
|
118
|
+
if (presetChoice === 0) {
|
|
119
|
+
// Full stack
|
|
120
|
+
const mongoChoice = choose('MongoDB connection mode:', [
|
|
121
|
+
'Single (auth + app data share one connection)',
|
|
122
|
+
'Separate (auth on its own cluster)',
|
|
123
|
+
]);
|
|
124
|
+
mongoMode = mongoChoice === 0 ? 'single' : 'separate';
|
|
125
|
+
useRedis = true;
|
|
126
|
+
authStore = 'mongo';
|
|
127
|
+
sessionStore = 'redis';
|
|
128
|
+
cacheStore = 'redis';
|
|
129
|
+
oauthStateStore = 'redis';
|
|
130
|
+
}
|
|
131
|
+
else if (presetChoice === 1) {
|
|
132
|
+
// SQLite
|
|
133
|
+
mongoMode = false;
|
|
134
|
+
useRedis = false;
|
|
135
|
+
authStore = 'sqlite';
|
|
136
|
+
sessionStore = 'sqlite';
|
|
137
|
+
cacheStore = 'sqlite';
|
|
138
|
+
oauthStateStore = 'sqlite';
|
|
139
|
+
}
|
|
140
|
+
else if (presetChoice === 2) {
|
|
141
|
+
// Memory
|
|
142
|
+
mongoMode = false;
|
|
143
|
+
useRedis = false;
|
|
144
|
+
authStore = 'memory';
|
|
145
|
+
sessionStore = 'memory';
|
|
146
|
+
cacheStore = 'memory';
|
|
147
|
+
oauthStateStore = 'memory';
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Custom — prompt each store individually
|
|
151
|
+
console.log('\n Configure each store:\n');
|
|
152
|
+
// MongoDB
|
|
153
|
+
const mongoChoice = choose('MongoDB:', [
|
|
154
|
+
'Single (one connection for auth + app data)',
|
|
155
|
+
'Separate (auth on its own cluster)',
|
|
156
|
+
'None (no MongoDB)',
|
|
157
|
+
]);
|
|
158
|
+
if (mongoChoice === 0)
|
|
159
|
+
mongoMode = 'single';
|
|
160
|
+
else if (mongoChoice === 1)
|
|
161
|
+
mongoMode = 'separate';
|
|
162
|
+
else
|
|
163
|
+
mongoMode = false;
|
|
164
|
+
// Redis
|
|
165
|
+
const redisChoice = choose('Redis:', ['Yes', 'No']);
|
|
166
|
+
useRedis = redisChoice === 0;
|
|
167
|
+
// Build available store options based on what's enabled
|
|
168
|
+
const storeOptions = [];
|
|
169
|
+
const storeLabels = [];
|
|
170
|
+
if (useRedis) {
|
|
171
|
+
storeOptions.push('redis');
|
|
172
|
+
storeLabels.push('Redis');
|
|
173
|
+
}
|
|
174
|
+
if (mongoMode) {
|
|
175
|
+
storeOptions.push('mongo');
|
|
176
|
+
storeLabels.push('MongoDB');
|
|
177
|
+
}
|
|
178
|
+
storeOptions.push('sqlite', 'memory');
|
|
179
|
+
storeLabels.push('SQLite', 'Memory');
|
|
180
|
+
// Auth store (no redis option)
|
|
181
|
+
const authOptions = [];
|
|
182
|
+
const authLabels = [];
|
|
183
|
+
if (mongoMode) {
|
|
184
|
+
authOptions.push('mongo');
|
|
185
|
+
authLabels.push('MongoDB');
|
|
186
|
+
}
|
|
187
|
+
authOptions.push('sqlite', 'memory');
|
|
188
|
+
authLabels.push('SQLite', 'Memory');
|
|
189
|
+
const authChoice = choose('Auth store:', authLabels);
|
|
190
|
+
authStore = authOptions[authChoice];
|
|
191
|
+
const sessChoice = choose('Sessions store:', storeLabels);
|
|
192
|
+
sessionStore = storeOptions[sessChoice];
|
|
193
|
+
const cacheChoice = choose('Cache store:', storeLabels);
|
|
194
|
+
cacheStore = storeOptions[cacheChoice];
|
|
195
|
+
const oauthChoice = choose('OAuth state store:', storeLabels);
|
|
196
|
+
oauthStateStore = storeOptions[oauthChoice];
|
|
197
|
+
}
|
|
198
|
+
// If any store uses sqlite, we need the sqlite path
|
|
199
|
+
const usesSqlite = authStore === 'sqlite' ||
|
|
200
|
+
sessionStore === 'sqlite' ||
|
|
201
|
+
cacheStore === 'sqlite' ||
|
|
202
|
+
oauthStateStore === 'sqlite';
|
|
203
|
+
// --- auth config ---
|
|
204
|
+
console.log('');
|
|
205
|
+
let authPosture = 'web-saas';
|
|
206
|
+
let stepByStep = null;
|
|
207
|
+
const authConfigMode = choose('How would you like to configure auth?', [
|
|
208
|
+
'Use a preset (pick a security posture, get sensible defaults)',
|
|
209
|
+
'Step by step (choose features individually)',
|
|
210
|
+
]);
|
|
211
|
+
if (authConfigMode === 0) {
|
|
212
|
+
// Preset path
|
|
213
|
+
const presetIndex = choose('Which best describes your app?', [
|
|
214
|
+
`Web app / SaaS (CSRF, refresh tokens, botProtection)`,
|
|
215
|
+
`Internal / admin (MFA required, no refresh tokens, tight limits)`,
|
|
216
|
+
`Mobile / API only (no CSRF, cors: "*", header auth)`,
|
|
217
|
+
`Dev / prototype (permissive — iterate fast, no rate limits)`,
|
|
218
|
+
]);
|
|
219
|
+
const presets = ['web-saas', 'internal', 'mobile-api', 'dev'];
|
|
220
|
+
authPosture = presets[presetIndex];
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
// Step-by-step path
|
|
224
|
+
authPosture = 'custom';
|
|
225
|
+
const pwPolicyIndex = choose('Password policy:', [
|
|
226
|
+
'Relaxed (8 chars)',
|
|
227
|
+
'Strong (12+ chars, special required)',
|
|
228
|
+
'Minimal (dev only)',
|
|
229
|
+
]);
|
|
230
|
+
const passwordPolicy = ['relaxed', 'strong', 'minimal'][pwPolicyIndex];
|
|
231
|
+
const emailVerifIndex = choose('Email verification:', ['Yes', 'No']);
|
|
232
|
+
const emailVerification = emailVerifIndex === 0;
|
|
233
|
+
const pwResetIndex = choose('Password reset:', ['Yes', 'No']);
|
|
234
|
+
const passwordReset = pwResetIndex === 0;
|
|
235
|
+
const refreshIndex = choose('Refresh tokens:', ['Yes', 'No']);
|
|
236
|
+
const refreshTokens = refreshIndex === 0;
|
|
237
|
+
const mfaIndex = choose('MFA:', ['None', 'Optional (users opt in)', 'Required (all users)']);
|
|
238
|
+
const mfa = ['none', 'optional', 'required'][mfaIndex];
|
|
239
|
+
const csrfIndex = choose('CSRF protection:', ['Yes', 'No']);
|
|
240
|
+
const csrf = csrfIndex === 0;
|
|
241
|
+
const oauthProviders = [];
|
|
242
|
+
const allProviders = ['Google', 'GitHub', 'Apple', 'Microsoft'];
|
|
243
|
+
while (true) {
|
|
244
|
+
const remaining = [...allProviders.filter(p => !oauthProviders.includes(p)), 'None (done)'];
|
|
245
|
+
const pIdx = choose('OAuth providers (select all that apply):', remaining);
|
|
246
|
+
const picked = remaining[pIdx];
|
|
247
|
+
if (picked === 'None (done)')
|
|
248
|
+
break;
|
|
249
|
+
oauthProviders.push(picked);
|
|
250
|
+
}
|
|
251
|
+
stepByStep = {
|
|
252
|
+
passwordPolicy,
|
|
253
|
+
emailVerification,
|
|
254
|
+
passwordReset,
|
|
255
|
+
refreshTokens,
|
|
256
|
+
mfa,
|
|
257
|
+
csrf,
|
|
258
|
+
oauthProviders,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
// --- paths ---
|
|
262
|
+
const projectDir = join(process.cwd(), dirName);
|
|
263
|
+
const srcDir = join(projectDir, 'src');
|
|
264
|
+
const configDir = join(srcDir, 'config');
|
|
265
|
+
const libDir = join(srcDir, 'lib');
|
|
266
|
+
const routesDir = join(srcDir, 'routes');
|
|
267
|
+
const workersDir = join(srcDir, 'workers');
|
|
268
|
+
const queuesDir = join(srcDir, 'queues');
|
|
269
|
+
const wsDir = join(srcDir, 'ws');
|
|
270
|
+
const servicesDir = join(srcDir, 'services');
|
|
271
|
+
const middlewareDir = join(srcDir, 'middleware');
|
|
272
|
+
const modelsDir = join(srcDir, 'models');
|
|
273
|
+
if (existsSync(projectDir)) {
|
|
274
|
+
console.error(`Directory "${dirName}" already exists.`);
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
// --- build db config string ---
|
|
278
|
+
function buildDbConfig() {
|
|
279
|
+
const lines = [];
|
|
280
|
+
if (mongoMode) {
|
|
281
|
+
lines.push(` mongo: "${mongoMode}",`);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
lines.push(` mongo: false,`);
|
|
285
|
+
}
|
|
286
|
+
lines.push(` redis: ${useRedis},`);
|
|
287
|
+
lines.push(` auth: "${authStore}",`);
|
|
288
|
+
lines.push(` sessions: "${sessionStore}",`);
|
|
289
|
+
lines.push(` oauthState: "${oauthStateStore}",`);
|
|
290
|
+
lines.push(` cache: "${cacheStore}",`);
|
|
291
|
+
if (usesSqlite) {
|
|
292
|
+
lines.push(` sqlite: path.join(import.meta.dir, "../../data.db"),`);
|
|
293
|
+
}
|
|
294
|
+
return `{\n${lines.join('\n')}\n}`;
|
|
295
|
+
}
|
|
296
|
+
// --- build auth + security config string ---
|
|
297
|
+
function buildAuthSecurityConfig() {
|
|
298
|
+
if (authPosture === 'web-saas') {
|
|
299
|
+
return `export const auth: AuthConfig = {
|
|
300
|
+
roles: Object.values(USER_ROLES),
|
|
301
|
+
defaultRole: USER_ROLES.USER,
|
|
302
|
+
passwordPolicy: { minLength: 8, requireLetter: true, requireDigit: true },
|
|
303
|
+
// Uncomment to require email verification before login:
|
|
304
|
+
// emailVerification: {
|
|
305
|
+
// required: true,
|
|
306
|
+
// // Listen to auth:delivery.email_verification bus event to send the email
|
|
307
|
+
// },
|
|
308
|
+
// Uncomment to enable password reset:
|
|
309
|
+
// passwordReset: {
|
|
310
|
+
// // Listen to auth:delivery.password_reset bus event to send the reset email
|
|
311
|
+
// },
|
|
312
|
+
refreshTokens: { accessTokenExpiry: 900, refreshTokenExpiry: 2_592_000 },
|
|
313
|
+
sessionPolicy: { trackLastActive: true },
|
|
314
|
+
// Uncomment to enable opt-in MFA (TOTP + email OTP):
|
|
315
|
+
// mfa: { issuer: APP_NAME },
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export const security: SecurityConfig = {
|
|
319
|
+
cors: ["https://myapp.com"], // TODO: replace with your domain
|
|
320
|
+
trustProxy: 1,
|
|
321
|
+
csrf: { enabled: true },
|
|
322
|
+
botProtection: { fingerprintRateLimit: true },
|
|
323
|
+
};`;
|
|
324
|
+
}
|
|
325
|
+
if (authPosture === 'internal') {
|
|
326
|
+
return `export const auth: AuthConfig = {
|
|
327
|
+
roles: ["superadmin", "admin", "viewer"],
|
|
328
|
+
defaultRole: "viewer",
|
|
329
|
+
passwordPolicy: { minLength: 14, requireLetter: true, requireDigit: true, requireSpecial: true },
|
|
330
|
+
mfa: { issuer: APP_NAME, required: true },
|
|
331
|
+
sessionPolicy: {
|
|
332
|
+
maxSessions: 2,
|
|
333
|
+
trackLastActive: true,
|
|
334
|
+
persistSessionMetadata: true,
|
|
335
|
+
includeInactiveSessions: true,
|
|
336
|
+
},
|
|
337
|
+
rateLimit: { login: { windowMs: 15 * 60 * 1000, max: 5 } },
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export const security: SecurityConfig = {
|
|
341
|
+
cors: ["https://admin.myapp.com"], // TODO: replace with your domain
|
|
342
|
+
trustProxy: 1,
|
|
343
|
+
csrf: { enabled: true },
|
|
344
|
+
rateLimit: { windowMs: 60_000, max: 30 },
|
|
345
|
+
};`;
|
|
346
|
+
}
|
|
347
|
+
if (authPosture === 'mobile-api') {
|
|
348
|
+
return `export const auth: AuthConfig = {
|
|
349
|
+
roles: Object.values(USER_ROLES),
|
|
350
|
+
defaultRole: USER_ROLES.USER,
|
|
351
|
+
refreshTokens: { accessTokenExpiry: 900, refreshTokenExpiry: 2_592_000, rotationGraceSeconds: 60 },
|
|
352
|
+
sessionPolicy: { maxSessions: 5 },
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export const security: SecurityConfig = {
|
|
356
|
+
cors: "*",
|
|
357
|
+
trustProxy: 1,
|
|
358
|
+
botProtection: { fingerprintRateLimit: true },
|
|
359
|
+
};`;
|
|
360
|
+
}
|
|
361
|
+
if (authPosture === 'dev') {
|
|
362
|
+
return `export const auth: AuthConfig = {
|
|
363
|
+
roles: Object.values(USER_ROLES),
|
|
364
|
+
defaultRole: USER_ROLES.USER,
|
|
365
|
+
passwordPolicy: { minLength: 1, requireLetter: false, requireDigit: false, requireSpecial: false },
|
|
366
|
+
rateLimit: {
|
|
367
|
+
login: { windowMs: 60_000, max: 10_000 },
|
|
368
|
+
register: { windowMs: 60_000, max: 10_000 },
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
export const security: SecurityConfig = {
|
|
373
|
+
cors: "*",
|
|
374
|
+
bearerAuth: false,
|
|
375
|
+
};`;
|
|
376
|
+
}
|
|
377
|
+
// Custom / step-by-step
|
|
378
|
+
const c = stepByStep;
|
|
379
|
+
const authLines = [
|
|
380
|
+
` roles: Object.values(USER_ROLES),`,
|
|
381
|
+
` defaultRole: USER_ROLES.USER,`,
|
|
382
|
+
];
|
|
383
|
+
if (c.passwordPolicy === 'relaxed') {
|
|
384
|
+
authLines.push(` passwordPolicy: { minLength: 8, requireLetter: true, requireDigit: true },`);
|
|
385
|
+
}
|
|
386
|
+
else if (c.passwordPolicy === 'strong') {
|
|
387
|
+
authLines.push(` passwordPolicy: { minLength: 12, requireLetter: true, requireDigit: true, requireSpecial: true },`);
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
authLines.push(` passwordPolicy: { minLength: 1, requireLetter: false, requireDigit: false, requireSpecial: false },`);
|
|
391
|
+
}
|
|
392
|
+
if (c.emailVerification) {
|
|
393
|
+
authLines.push(` emailVerification: {`);
|
|
394
|
+
authLines.push(` required: true,`);
|
|
395
|
+
authLines.push(` // Listen to auth:delivery.email_verification bus event to send the email`);
|
|
396
|
+
authLines.push(` },`);
|
|
397
|
+
}
|
|
398
|
+
if (c.passwordReset) {
|
|
399
|
+
authLines.push(` passwordReset: {`);
|
|
400
|
+
authLines.push(` // Listen to auth:delivery.password_reset bus event to send the reset email`);
|
|
401
|
+
authLines.push(` },`);
|
|
402
|
+
}
|
|
403
|
+
if (c.refreshTokens) {
|
|
404
|
+
authLines.push(` refreshTokens: { accessTokenExpiry: 900, refreshTokenExpiry: 2_592_000 },`);
|
|
405
|
+
}
|
|
406
|
+
if (c.mfa === 'optional') {
|
|
407
|
+
authLines.push(` mfa: { issuer: APP_NAME },`);
|
|
408
|
+
}
|
|
409
|
+
else if (c.mfa === 'required') {
|
|
410
|
+
authLines.push(` mfa: { issuer: APP_NAME, required: true },`);
|
|
411
|
+
}
|
|
412
|
+
authLines.push(` sessionPolicy: { trackLastActive: true },`);
|
|
413
|
+
const authBlock = `export const auth: AuthConfig = {\n${authLines.join('\n')}\n};`;
|
|
414
|
+
const secLines = [` cors: "*",`];
|
|
415
|
+
if (c.csrf) {
|
|
416
|
+
secLines.push(` csrf: { enabled: true },`);
|
|
417
|
+
}
|
|
418
|
+
const secBlock = `export const security: SecurityConfig = {\n${secLines.join('\n')}\n};`;
|
|
419
|
+
return `${authBlock}\n\n${secBlock}`;
|
|
420
|
+
}
|
|
421
|
+
// --- templates ---
|
|
422
|
+
const constantsContent = `export const APP_NAME = "${appTitle}";
|
|
423
|
+
export const APP_VERSION = "1.0.0";
|
|
424
|
+
|
|
425
|
+
export const USER_ROLES = {
|
|
426
|
+
ADMIN: "admin",
|
|
427
|
+
USER: "user",
|
|
428
|
+
};
|
|
429
|
+
`;
|
|
430
|
+
const configContent = `import path from "path";
|
|
431
|
+
import {
|
|
432
|
+
type AppMeta,
|
|
433
|
+
type AuthConfig,
|
|
434
|
+
type CreateServerConfig,
|
|
435
|
+
type DbConfig,
|
|
436
|
+
type SecurityConfig,
|
|
437
|
+
} from "@lastshotlabs/bunshot";
|
|
438
|
+
import { APP_NAME, APP_VERSION, USER_ROLES } from "@shared/constants";
|
|
439
|
+
|
|
440
|
+
export const app: AppMeta = {
|
|
441
|
+
name: APP_NAME,
|
|
442
|
+
version: APP_VERSION,
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
export const routesDir = path.join(import.meta.dir, "../routes");
|
|
446
|
+
|
|
447
|
+
export const workersDir = path.join(import.meta.dir, "../workers");
|
|
448
|
+
|
|
449
|
+
export const port = process.env.PORT ? parseInt(process.env.PORT) : 3000;
|
|
450
|
+
|
|
451
|
+
export const db: DbConfig = ${buildDbConfig()};
|
|
452
|
+
|
|
453
|
+
${buildAuthSecurityConfig()}
|
|
454
|
+
|
|
455
|
+
export const appConfig: CreateServerConfig = {
|
|
456
|
+
app,
|
|
457
|
+
routesDir,
|
|
458
|
+
workersDir,
|
|
459
|
+
port,
|
|
460
|
+
db,
|
|
461
|
+
auth,
|
|
462
|
+
security,
|
|
463
|
+
};
|
|
464
|
+
`;
|
|
465
|
+
const indexContent = `import { createServer } from "@lastshotlabs/bunshot";
|
|
466
|
+
import { appConfig } from "@config/index";
|
|
467
|
+
|
|
468
|
+
await createServer(appConfig);
|
|
469
|
+
`;
|
|
470
|
+
const readmeContent = `# ${appTitle}
|
|
471
|
+
|
|
472
|
+
Built with [@lastshotlabs/bunshot](https://github.com/Last-Shot-Labs/bunshot).
|
|
473
|
+
|
|
474
|
+
## Getting started
|
|
475
|
+
|
|
476
|
+
\`\`\`bash
|
|
477
|
+
# fill in .env with your values
|
|
478
|
+
bun dev
|
|
479
|
+
\`\`\`
|
|
480
|
+
|
|
481
|
+
| Endpoint | Description |
|
|
482
|
+
|---|---|
|
|
483
|
+
| \`POST /auth/register\` | Create account |
|
|
484
|
+
| \`POST /auth/login\` | Sign in, returns JWT |
|
|
485
|
+
| \`GET /docs\` | OpenAPI docs (Scalar) |
|
|
486
|
+
| \`GET /health\` | Health check |
|
|
487
|
+
|
|
488
|
+
## Project structure
|
|
489
|
+
|
|
490
|
+
\`\`\`
|
|
491
|
+
src/
|
|
492
|
+
index.ts # server entry point
|
|
493
|
+
config/index.ts # centralized app configuration
|
|
494
|
+
lib/constants.ts # app name, version, roles
|
|
495
|
+
routes/ # file-based routing (each file = a router)
|
|
496
|
+
workers/ # BullMQ workers (auto-imported on start)
|
|
497
|
+
middleware/ # custom middleware
|
|
498
|
+
models/ # data models
|
|
499
|
+
services/ # business logic
|
|
500
|
+
\`\`\`
|
|
501
|
+
|
|
502
|
+
## Adding routes
|
|
503
|
+
|
|
504
|
+
Create a file in \`src/routes/\`:
|
|
505
|
+
|
|
506
|
+
\`\`\`ts
|
|
507
|
+
// src/routes/products.ts
|
|
508
|
+
import { createRouter } from "@lastshotlabs/bunshot";
|
|
509
|
+
import { z } from "zod";
|
|
510
|
+
|
|
511
|
+
export const router = createRouter();
|
|
512
|
+
|
|
513
|
+
router.get("/products", (c) => c.json({ products: [] }));
|
|
514
|
+
\`\`\`
|
|
515
|
+
${mongoMode
|
|
516
|
+
? `
|
|
517
|
+
## Adding models
|
|
518
|
+
|
|
519
|
+
\`\`\`ts
|
|
520
|
+
// src/models/Product.ts
|
|
521
|
+
import { getMongooseModule, getMongoFromApp } from "@lastshotlabs/bunshot";
|
|
522
|
+
|
|
523
|
+
const mongoose = getMongooseModule();
|
|
524
|
+
|
|
525
|
+
const ProductSchema = new mongoose.Schema({
|
|
526
|
+
name: { type: String, required: true },
|
|
527
|
+
price: { type: Number, required: true },
|
|
528
|
+
}, { timestamps: true });
|
|
529
|
+
|
|
530
|
+
// Use getMongoFromApp(app) to get connections from context
|
|
531
|
+
// export const Product = appConn.model("Product", ProductSchema);
|
|
532
|
+
\`\`\`
|
|
533
|
+
`
|
|
534
|
+
: ''}
|
|
535
|
+
## Environment variables
|
|
536
|
+
|
|
537
|
+
See \`.env\` — fill in the values before running.
|
|
538
|
+
`;
|
|
539
|
+
// --- build .env based on choices ---
|
|
540
|
+
function buildEnv() {
|
|
541
|
+
const sections = [`NODE_ENV=development`, `PORT=3000`];
|
|
542
|
+
if (mongoMode === 'single') {
|
|
543
|
+
sections.push(`
|
|
544
|
+
# MongoDB
|
|
545
|
+
MONGO_USER=
|
|
546
|
+
MONGO_PASSWORD=
|
|
547
|
+
MONGO_HOST=
|
|
548
|
+
MONGO_DB=`);
|
|
549
|
+
}
|
|
550
|
+
else if (mongoMode === 'separate') {
|
|
551
|
+
sections.push(`
|
|
552
|
+
# MongoDB (app data)
|
|
553
|
+
MONGO_USER=
|
|
554
|
+
MONGO_PASSWORD=
|
|
555
|
+
MONGO_HOST=
|
|
556
|
+
MONGO_DB=
|
|
557
|
+
|
|
558
|
+
# MongoDB (auth — separate cluster)
|
|
559
|
+
MONGO_AUTH_USER=
|
|
560
|
+
MONGO_AUTH_PASSWORD=
|
|
561
|
+
MONGO_AUTH_HOST=
|
|
562
|
+
MONGO_AUTH_DB=`);
|
|
563
|
+
}
|
|
564
|
+
if (useRedis) {
|
|
565
|
+
sections.push(`
|
|
566
|
+
# Redis
|
|
567
|
+
REDIS_HOST=
|
|
568
|
+
REDIS_USER=
|
|
569
|
+
REDIS_PASSWORD=`);
|
|
570
|
+
}
|
|
571
|
+
sections.push(`
|
|
572
|
+
# JWT
|
|
573
|
+
JWT_SECRET=
|
|
574
|
+
|
|
575
|
+
# Bearer API key
|
|
576
|
+
BEARER_TOKEN=
|
|
577
|
+
|
|
578
|
+
# OAuth — Google (optional)
|
|
579
|
+
# GOOGLE_CLIENT_ID=
|
|
580
|
+
# GOOGLE_CLIENT_SECRET=
|
|
581
|
+
# GOOGLE_REDIRECT_URI=
|
|
582
|
+
|
|
583
|
+
# OAuth — Apple (optional)
|
|
584
|
+
# APPLE_CLIENT_ID=
|
|
585
|
+
# APPLE_TEAM_ID=
|
|
586
|
+
# APPLE_KEY_ID=
|
|
587
|
+
# APPLE_PRIVATE_KEY=
|
|
588
|
+
# APPLE_REDIRECT_URI=
|
|
589
|
+
|
|
590
|
+
# OAuth — GitHub (optional)
|
|
591
|
+
# GITHUB_CLIENT_ID=
|
|
592
|
+
# GITHUB_CLIENT_SECRET=
|
|
593
|
+
# GITHUB_REDIRECT_URI=
|
|
594
|
+
|
|
595
|
+
# OAuth — Microsoft (optional)
|
|
596
|
+
# MICROSOFT_TENANT_ID=
|
|
597
|
+
# MICROSOFT_CLIENT_ID=
|
|
598
|
+
# MICROSOFT_CLIENT_SECRET=
|
|
599
|
+
# MICROSOFT_REDIRECT_URI=`);
|
|
600
|
+
return sections.join('\n') + '\n';
|
|
601
|
+
}
|
|
602
|
+
// --- scaffold ---
|
|
603
|
+
console.log(`\n@lastshotlabs/bunshot — creating ${dirName}\n`);
|
|
604
|
+
mkdirSync(projectDir, { recursive: true });
|
|
605
|
+
// bun init -y (handles package.json, tsconfig.json, .gitignore)
|
|
606
|
+
console.log(' Running bun init...');
|
|
607
|
+
spawnSync('bun', ['init', '-y'], { cwd: projectDir, stdio: 'inherit' });
|
|
608
|
+
// Remove the root index.ts bun init creates — we use src/index.ts
|
|
609
|
+
const rootIndex = join(projectDir, 'index.ts');
|
|
610
|
+
if (existsSync(rootIndex))
|
|
611
|
+
rmSync(rootIndex);
|
|
612
|
+
// Patch package.json: add dependency + fix scripts + module entry
|
|
613
|
+
const pkgPath = join(projectDir, 'package.json');
|
|
614
|
+
const pkg = JSON.parse(require('fs').readFileSync(pkgPath, 'utf-8'));
|
|
615
|
+
pkg.module = 'src/index.ts';
|
|
616
|
+
pkg.scripts = { dev: 'bun --watch src/index.ts', start: 'bun src/index.ts' };
|
|
617
|
+
pkg.dependencies = { ...pkg.dependencies, '@lastshotlabs/bunshot': '*' };
|
|
618
|
+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8');
|
|
619
|
+
// Write tsconfig.json with full compiler options and path aliases
|
|
620
|
+
const tsconfigPath = join(projectDir, 'tsconfig.json');
|
|
621
|
+
const tsconfigContent = {
|
|
622
|
+
compilerOptions: {
|
|
623
|
+
lib: ['ESNext'],
|
|
624
|
+
target: 'ESNext',
|
|
625
|
+
module: 'Preserve',
|
|
626
|
+
moduleDetection: 'force',
|
|
627
|
+
jsx: 'react-jsx',
|
|
628
|
+
allowJs: true,
|
|
629
|
+
moduleResolution: 'bundler',
|
|
630
|
+
allowImportingTsExtensions: true,
|
|
631
|
+
verbatimModuleSyntax: true,
|
|
632
|
+
noEmit: true,
|
|
633
|
+
strict: true,
|
|
634
|
+
skipLibCheck: true,
|
|
635
|
+
noFallthroughCasesInSwitch: true,
|
|
636
|
+
noUncheckedIndexedAccess: true,
|
|
637
|
+
noImplicitOverride: true,
|
|
638
|
+
noUnusedLocals: false,
|
|
639
|
+
noUnusedParameters: false,
|
|
640
|
+
noPropertyAccessFromIndexSignature: false,
|
|
641
|
+
paths: {
|
|
642
|
+
'@lib/*': ['./src/lib/*'],
|
|
643
|
+
'@middleware/*': ['./src/middleware/*'],
|
|
644
|
+
'@models/*': ['./src/models/*'],
|
|
645
|
+
'@queues/*': ['./src/queues/*'],
|
|
646
|
+
'@routes/*': ['./src/routes/*'],
|
|
647
|
+
'@scripts/*': ['./src/scripts/*'],
|
|
648
|
+
'@services/*': ['./src/services/*'],
|
|
649
|
+
'@workers/*': ['./src/workers/*'],
|
|
650
|
+
'@service-facades/*': ['./src/service-facades/*'],
|
|
651
|
+
'@config/*': ['./src/config/*'],
|
|
652
|
+
'@constants/*': ['./src/lib/constants/*'],
|
|
653
|
+
},
|
|
654
|
+
},
|
|
655
|
+
};
|
|
656
|
+
writeFileSync(tsconfigPath, JSON.stringify(tsconfigContent, null, 2) + '\n', 'utf-8');
|
|
657
|
+
// Create src structure
|
|
658
|
+
mkdirSync(configDir, { recursive: true });
|
|
659
|
+
mkdirSync(libDir, { recursive: true });
|
|
660
|
+
mkdirSync(routesDir, { recursive: true });
|
|
661
|
+
mkdirSync(workersDir, { recursive: true });
|
|
662
|
+
mkdirSync(queuesDir, { recursive: true });
|
|
663
|
+
mkdirSync(wsDir, { recursive: true });
|
|
664
|
+
mkdirSync(servicesDir, { recursive: true });
|
|
665
|
+
mkdirSync(middlewareDir, { recursive: true });
|
|
666
|
+
mkdirSync(modelsDir, { recursive: true });
|
|
667
|
+
writeFileSync(join(libDir, 'constants.ts'), constantsContent, 'utf-8');
|
|
668
|
+
writeFileSync(join(configDir, 'index.ts'), configContent, 'utf-8');
|
|
669
|
+
writeFileSync(join(srcDir, 'index.ts'), indexContent, 'utf-8');
|
|
670
|
+
writeFileSync(join(projectDir, '.env'), buildEnv(), 'utf-8');
|
|
671
|
+
writeFileSync(join(projectDir, 'README.md'), readmeContent, 'utf-8');
|
|
672
|
+
// --- summary ---
|
|
673
|
+
console.log(' Created:');
|
|
674
|
+
console.log(` + ${dirName}/src/index.ts`);
|
|
675
|
+
console.log(` + ${dirName}/src/config/index.ts`);
|
|
676
|
+
console.log(` + ${dirName}/src/lib/constants.ts`);
|
|
677
|
+
console.log(` + ${dirName}/src/routes/`);
|
|
678
|
+
console.log(` + ${dirName}/src/workers/`);
|
|
679
|
+
console.log(` + ${dirName}/src/queues/`);
|
|
680
|
+
console.log(` + ${dirName}/src/ws/`);
|
|
681
|
+
console.log(` + ${dirName}/src/services/`);
|
|
682
|
+
console.log(` + ${dirName}/src/middleware/`);
|
|
683
|
+
console.log(` + ${dirName}/src/models/`);
|
|
684
|
+
console.log(` + ${dirName}/.env`);
|
|
685
|
+
console.log(` + ${dirName}/README.md`);
|
|
686
|
+
console.log(`\n DB config:`);
|
|
687
|
+
console.log(` mongo: ${mongoMode || 'none'} | redis: ${useRedis}`);
|
|
688
|
+
console.log(` auth: ${authStore} | sessions: ${sessionStore} | cache: ${cacheStore} | oauthState: ${oauthStateStore}`);
|
|
689
|
+
console.log(`\n Auth config:`);
|
|
690
|
+
console.log(` posture: ${authPosture}`);
|
|
691
|
+
// --- git init ---
|
|
692
|
+
console.log('\n Initializing git...');
|
|
693
|
+
const git = spawnSync('git', ['init'], { cwd: projectDir, stdio: 'inherit' });
|
|
694
|
+
if (git.status !== 0) {
|
|
695
|
+
console.error(' git init failed — skipping.');
|
|
696
|
+
}
|
|
697
|
+
// --- bun install ---
|
|
698
|
+
console.log('\n Installing dependencies...');
|
|
699
|
+
const install = spawnSync('bun', ['install'], { cwd: projectDir, stdio: 'inherit' });
|
|
700
|
+
if (install.status !== 0) {
|
|
701
|
+
console.error('\n bun install failed. Run it manually inside the directory.');
|
|
702
|
+
process.exit(1);
|
|
703
|
+
}
|
|
704
|
+
console.log(`\nDone! Next steps:\n`);
|
|
705
|
+
console.log(` cd ${dirName}`);
|
|
706
|
+
console.log(` # fill in .env`);
|
|
707
|
+
console.log(` bun dev\n`);
|
|
708
|
+
}
|
|
709
|
+
}
|