@shipfox/api-auth 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-type$colon$emit.log +1 -0
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +116 -0
- package/LICENSE +21 -0
- package/README.md +336 -0
- package/dist/config.d.ts +22 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +95 -0
- package/dist/config.js.map +1 -0
- package/dist/core/auth.d.ts +108 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +476 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/entities/email-verification.d.ts +9 -0
- package/dist/core/entities/email-verification.d.ts.map +1 -0
- package/dist/core/entities/email-verification.js +3 -0
- package/dist/core/entities/email-verification.js.map +1 -0
- package/dist/core/entities/password-reset.d.ts +9 -0
- package/dist/core/entities/password-reset.d.ts.map +1 -0
- package/dist/core/entities/password-reset.js +3 -0
- package/dist/core/entities/password-reset.js.map +1 -0
- package/dist/core/entities/refresh-token.d.ts +12 -0
- package/dist/core/entities/refresh-token.d.ts.map +1 -0
- package/dist/core/entities/refresh-token.js +3 -0
- package/dist/core/entities/refresh-token.js.map +1 -0
- package/dist/core/entities/user.d.ts +12 -0
- package/dist/core/entities/user.d.ts.map +1 -0
- package/dist/core/entities/user.js +3 -0
- package/dist/core/entities/user.js.map +1 -0
- package/dist/core/errors.d.ts +54 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +106 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/job-lease-token.d.ts +12 -0
- package/dist/core/job-lease-token.d.ts.map +1 -0
- package/dist/core/job-lease-token.js +58 -0
- package/dist/core/job-lease-token.js.map +1 -0
- package/dist/core/jwt.d.ts +37 -0
- package/dist/core/jwt.d.ts.map +1 -0
- package/dist/core/jwt.js +46 -0
- package/dist/core/jwt.js.map +1 -0
- package/dist/core/password.d.ts +10 -0
- package/dist/core/password.d.ts.map +1 -0
- package/dist/core/password.js +13 -0
- package/dist/core/password.js.map +1 -0
- package/dist/core/rate-limit.d.ts +34 -0
- package/dist/core/rate-limit.d.ts.map +1 -0
- package/dist/core/rate-limit.js +76 -0
- package/dist/core/rate-limit.js.map +1 -0
- package/dist/core/runner-session-token.d.ts +6 -0
- package/dist/core/runner-session-token.d.ts.map +1 -0
- package/dist/core/runner-session-token.js +37 -0
- package/dist/core/runner-session-token.js.map +1 -0
- package/dist/db/db.d.ts +1723 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +28 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/email-verifications.d.ts +39 -0
- package/dist/db/email-verifications.d.ts.map +1 -0
- package/dist/db/email-verifications.js +95 -0
- package/dist/db/email-verifications.js.map +1 -0
- package/dist/db/migrations.d.ts +2 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +5 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/password-resets.d.ts +23 -0
- package/dist/db/password-resets.d.ts.map +1 -0
- package/dist/db/password-resets.js +37 -0
- package/dist/db/password-resets.js.map +1 -0
- package/dist/db/rate-limits.d.ts +18 -0
- package/dist/db/rate-limits.d.ts.map +1 -0
- package/dist/db/rate-limits.js +44 -0
- package/dist/db/rate-limits.js.map +1 -0
- package/dist/db/refresh-tokens.d.ts +44 -0
- package/dist/db/refresh-tokens.d.ts.map +1 -0
- package/dist/db/refresh-tokens.js +71 -0
- package/dist/db/refresh-tokens.js.map +1 -0
- package/dist/db/schema/common.d.ts +2 -0
- package/dist/db/schema/common.d.ts.map +1 -0
- package/dist/db/schema/common.js +4 -0
- package/dist/db/schema/common.js.map +1 -0
- package/dist/db/schema/email-verifications.d.ts +114 -0
- package/dist/db/schema/email-verifications.d.ts.map +1 -0
- package/dist/db/schema/email-verifications.js +35 -0
- package/dist/db/schema/email-verifications.js.map +1 -0
- package/dist/db/schema/outbox.d.ts +195 -0
- package/dist/db/schema/outbox.d.ts.map +1 -0
- package/dist/db/schema/outbox.js +5 -0
- package/dist/db/schema/outbox.js.map +1 -0
- package/dist/db/schema/password-resets.d.ts +114 -0
- package/dist/db/schema/password-resets.d.ts.map +1 -0
- package/dist/db/schema/password-resets.js +35 -0
- package/dist/db/schema/password-resets.js.map +1 -0
- package/dist/db/schema/rate-limits.d.ts +145 -0
- package/dist/db/schema/rate-limits.d.ts.map +1 -0
- package/dist/db/schema/rate-limits.js +25 -0
- package/dist/db/schema/rate-limits.js.map +1 -0
- package/dist/db/schema/refresh-tokens.d.ts +165 -0
- package/dist/db/schema/refresh-tokens.d.ts.map +1 -0
- package/dist/db/schema/refresh-tokens.js +47 -0
- package/dist/db/schema/refresh-tokens.js.map +1 -0
- package/dist/db/schema/users.d.ts +149 -0
- package/dist/db/schema/users.d.ts.map +1 -0
- package/dist/db/schema/users.js +40 -0
- package/dist/db/schema/users.js.map +1 -0
- package/dist/db/users.d.ts +28 -0
- package/dist/db/users.d.ts.map +1 -0
- package/dist/db/users.js +83 -0
- package/dist/db/users.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +3 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instance.d.ts +16 -0
- package/dist/metrics/instance.d.ts.map +1 -0
- package/dist/metrics/instance.js +52 -0
- package/dist/metrics/instance.js.map +1 -0
- package/dist/presentation/auth/bearer-token-auth.d.ts +15 -0
- package/dist/presentation/auth/bearer-token-auth.d.ts.map +1 -0
- package/dist/presentation/auth/bearer-token-auth.js +31 -0
- package/dist/presentation/auth/bearer-token-auth.js.map +1 -0
- package/dist/presentation/auth/jwt-auth.d.ts +10 -0
- package/dist/presentation/auth/jwt-auth.d.ts.map +1 -0
- package/dist/presentation/auth/jwt-auth.js +31 -0
- package/dist/presentation/auth/jwt-auth.js.map +1 -0
- package/dist/presentation/auth/lease-token-auth.d.ts +15 -0
- package/dist/presentation/auth/lease-token-auth.d.ts.map +1 -0
- package/dist/presentation/auth/lease-token-auth.js +27 -0
- package/dist/presentation/auth/lease-token-auth.js.map +1 -0
- package/dist/presentation/auth/refresh-cookie.d.ts +7 -0
- package/dist/presentation/auth/refresh-cookie.d.ts.map +1 -0
- package/dist/presentation/auth/refresh-cookie.js +29 -0
- package/dist/presentation/auth/refresh-cookie.js.map +1 -0
- package/dist/presentation/auth/runner-session-auth.d.ts +3 -0
- package/dist/presentation/auth/runner-session-auth.d.ts.map +1 -0
- package/dist/presentation/auth/runner-session-auth.js +16 -0
- package/dist/presentation/auth/runner-session-auth.js.map +1 -0
- package/dist/presentation/dto/user.d.ts +8 -0
- package/dist/presentation/dto/user.d.ts.map +1 -0
- package/dist/presentation/dto/user.js +19 -0
- package/dist/presentation/dto/user.js.map +1 -0
- package/dist/presentation/e2eRoutes/create-session.d.ts +2 -0
- package/dist/presentation/e2eRoutes/create-session.d.ts.map +1 -0
- package/dist/presentation/e2eRoutes/create-session.js +49 -0
- package/dist/presentation/e2eRoutes/create-session.js.map +1 -0
- package/dist/presentation/e2eRoutes/create-user.d.ts +2 -0
- package/dist/presentation/e2eRoutes/create-user.d.ts.map +1 -0
- package/dist/presentation/e2eRoutes/create-user.js +42 -0
- package/dist/presentation/e2eRoutes/create-user.js.map +1 -0
- package/dist/presentation/e2eRoutes/index.d.ts +3 -0
- package/dist/presentation/e2eRoutes/index.d.ts.map +1 -0
- package/dist/presentation/e2eRoutes/index.js +15 -0
- package/dist/presentation/e2eRoutes/index.js.map +1 -0
- package/dist/presentation/routes/email-verification/verify-email-confirm.d.ts +2 -0
- package/dist/presentation/routes/email-verification/verify-email-confirm.d.ts.map +1 -0
- package/dist/presentation/routes/email-verification/verify-email-confirm.js +35 -0
- package/dist/presentation/routes/email-verification/verify-email-confirm.js.map +1 -0
- package/dist/presentation/routes/email-verification/verify-email-resend.d.ts +2 -0
- package/dist/presentation/routes/email-verification/verify-email-resend.d.ts.map +1 -0
- package/dist/presentation/routes/email-verification/verify-email-resend.js +27 -0
- package/dist/presentation/routes/email-verification/verify-email-resend.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +3 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +31 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/password/change-password.d.ts +2 -0
- package/dist/presentation/routes/password/change-password.d.ts.map +1 -0
- package/dist/presentation/routes/password/change-password.js +50 -0
- package/dist/presentation/routes/password/change-password.js.map +1 -0
- package/dist/presentation/routes/password/password-reset-confirm.d.ts +2 -0
- package/dist/presentation/routes/password/password-reset-confirm.d.ts.map +1 -0
- package/dist/presentation/routes/password/password-reset-confirm.js +36 -0
- package/dist/presentation/routes/password/password-reset-confirm.js.map +1 -0
- package/dist/presentation/routes/password/password-reset-request.d.ts +2 -0
- package/dist/presentation/routes/password/password-reset-request.d.ts.map +1 -0
- package/dist/presentation/routes/password/password-reset-request.js +26 -0
- package/dist/presentation/routes/password/password-reset-request.js.map +1 -0
- package/dist/presentation/routes/rate-limit.d.ts +10 -0
- package/dist/presentation/routes/rate-limit.d.ts.map +1 -0
- package/dist/presentation/routes/rate-limit.js +101 -0
- package/dist/presentation/routes/rate-limit.js.map +1 -0
- package/dist/presentation/routes/registration/signup.d.ts +2 -0
- package/dist/presentation/routes/registration/signup.d.ts.map +1 -0
- package/dist/presentation/routes/registration/signup.js +82 -0
- package/dist/presentation/routes/registration/signup.js.map +1 -0
- package/dist/presentation/routes/session/login.d.ts +2 -0
- package/dist/presentation/routes/session/login.d.ts.map +1 -0
- package/dist/presentation/routes/session/login.js +48 -0
- package/dist/presentation/routes/session/login.js.map +1 -0
- package/dist/presentation/routes/session/logout.d.ts +2 -0
- package/dist/presentation/routes/session/logout.d.ts.map +1 -0
- package/dist/presentation/routes/session/logout.js +25 -0
- package/dist/presentation/routes/session/logout.js.map +1 -0
- package/dist/presentation/routes/session/me.d.ts +2 -0
- package/dist/presentation/routes/session/me.d.ts.map +1 -0
- package/dist/presentation/routes/session/me.js +42 -0
- package/dist/presentation/routes/session/me.js.map +1 -0
- package/dist/presentation/routes/session/refresh.d.ts +2 -0
- package/dist/presentation/routes/session/refresh.d.ts.map +1 -0
- package/dist/presentation/routes/session/refresh.js +49 -0
- package/dist/presentation/routes/session/refresh.js.map +1 -0
- package/dist/presentation/subscribers/index.d.ts +3 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -0
- package/dist/presentation/subscribers/index.js +4 -0
- package/dist/presentation/subscribers/index.js.map +1 -0
- package/dist/presentation/subscribers/on-email-verification-send-requested.d.ts +3 -0
- package/dist/presentation/subscribers/on-email-verification-send-requested.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-email-verification-send-requested.js +13 -0
- package/dist/presentation/subscribers/on-email-verification-send-requested.js.map +1 -0
- package/dist/presentation/subscribers/on-password-reset-send-requested.d.ts +3 -0
- package/dist/presentation/subscribers/on-password-reset-send-requested.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-password-reset-send-requested.js +14 -0
- package/dist/presentation/subscribers/on-password-reset-send-requested.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +81 -0
- package/drizzle/meta/0000_snapshot.json +643 -0
- package/drizzle/meta/_journal.json +13 -0
- package/drizzle.config.ts +7 -0
- package/package.json +88 -0
- package/src/config.ts +88 -0
- package/src/core/auth.test.ts +675 -0
- package/src/core/auth.ts +560 -0
- package/src/core/entities/email-verification.ts +8 -0
- package/src/core/entities/password-reset.ts +8 -0
- package/src/core/entities/refresh-token.ts +11 -0
- package/src/core/entities/user.ts +12 -0
- package/src/core/errors.ts +123 -0
- package/src/core/job-lease-token.test.ts +201 -0
- package/src/core/job-lease-token.ts +83 -0
- package/src/core/jwt.test.ts +180 -0
- package/src/core/jwt.ts +66 -0
- package/src/core/password.test.ts +28 -0
- package/src/core/password.ts +21 -0
- package/src/core/rate-limit.test.ts +462 -0
- package/src/core/rate-limit.ts +130 -0
- package/src/core/runner-session-token.test.ts +126 -0
- package/src/core/runner-session-token.ts +49 -0
- package/src/db/db.ts +28 -0
- package/src/db/email-verifications.test.ts +61 -0
- package/src/db/email-verifications.ts +160 -0
- package/src/db/migrations.ts +4 -0
- package/src/db/password-resets.test.ts +61 -0
- package/src/db/password-resets.ts +69 -0
- package/src/db/rate-limits.ts +69 -0
- package/src/db/refresh-tokens.test.ts +164 -0
- package/src/db/refresh-tokens.ts +149 -0
- package/src/db/schema/common.ts +3 -0
- package/src/db/schema/email-verifications.ts +37 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/password-resets.ts +37 -0
- package/src/db/schema/rate-limits.ts +27 -0
- package/src/db/schema/refresh-tokens.ts +43 -0
- package/src/db/schema/users.ts +37 -0
- package/src/db/users.test.ts +75 -0
- package/src/db/users.ts +121 -0
- package/src/index.test.ts +39 -0
- package/src/index.ts +69 -0
- package/src/metrics/index.ts +13 -0
- package/src/metrics/instance.test.ts +69 -0
- package/src/metrics/instance.ts +77 -0
- package/src/presentation/auth/bearer-token-auth.test.ts +99 -0
- package/src/presentation/auth/bearer-token-auth.ts +51 -0
- package/src/presentation/auth/jwt-auth.test.ts +136 -0
- package/src/presentation/auth/jwt-auth.ts +39 -0
- package/src/presentation/auth/lease-token-auth.test.ts +56 -0
- package/src/presentation/auth/lease-token-auth.ts +25 -0
- package/src/presentation/auth/refresh-cookie.test.ts +39 -0
- package/src/presentation/auth/refresh-cookie.ts +34 -0
- package/src/presentation/auth/runner-session-auth.test.ts +54 -0
- package/src/presentation/auth/runner-session-auth.ts +13 -0
- package/src/presentation/dto/user.ts +21 -0
- package/src/presentation/e2eRoutes/create-session.ts +39 -0
- package/src/presentation/e2eRoutes/create-user.ts +38 -0
- package/src/presentation/e2eRoutes/index.test.ts +102 -0
- package/src/presentation/e2eRoutes/index.ts +10 -0
- package/src/presentation/routes/email-verification/verify-email-confirm.test.ts +66 -0
- package/src/presentation/routes/email-verification/verify-email-confirm.ts +37 -0
- package/src/presentation/routes/email-verification/verify-email-resend.test.ts +100 -0
- package/src/presentation/routes/email-verification/verify-email-resend.ts +26 -0
- package/src/presentation/routes/index.ts +29 -0
- package/src/presentation/routes/password/change-password.test.ts +106 -0
- package/src/presentation/routes/password/change-password.ts +45 -0
- package/src/presentation/routes/password/password-reset-confirm.test.ts +63 -0
- package/src/presentation/routes/password/password-reset-confirm.ts +35 -0
- package/src/presentation/routes/password/password-reset-request.test.ts +56 -0
- package/src/presentation/routes/password/password-reset-request.ts +25 -0
- package/src/presentation/routes/rate-limit.test.ts +341 -0
- package/src/presentation/routes/rate-limit.ts +119 -0
- package/src/presentation/routes/registration/signup.test.ts +284 -0
- package/src/presentation/routes/registration/signup.ts +81 -0
- package/src/presentation/routes/session/login.test.ts +77 -0
- package/src/presentation/routes/session/login.ts +50 -0
- package/src/presentation/routes/session/logout.test.ts +55 -0
- package/src/presentation/routes/session/logout.ts +23 -0
- package/src/presentation/routes/session/me.test.ts +56 -0
- package/src/presentation/routes/session/me.ts +35 -0
- package/src/presentation/routes/session/refresh.test.ts +89 -0
- package/src/presentation/routes/session/refresh.ts +54 -0
- package/src/presentation/subscribers/email-send-requested.test.ts +77 -0
- package/src/presentation/subscribers/index.ts +2 -0
- package/src/presentation/subscribers/on-email-verification-send-requested.ts +10 -0
- package/src/presentation/subscribers/on-password-reset-send-requested.ts +13 -0
- package/test/env.ts +10 -0
- package/test/factories/index.ts +1 -0
- package/test/factories/user.ts +36 -0
- package/test/globalSetup.ts +18 -0
- package/test/index.ts +1 -0
- package/test/routes.ts +275 -0
- package/test/setup.ts +17 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +4 -0
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { index, integer, text, timestamp, uniqueIndex } from 'drizzle-orm/pg-core';
|
|
2
|
+
import { pgTable } from './common.js';
|
|
3
|
+
export const authRateLimits = pgTable('rate_limits', {
|
|
4
|
+
action: text('action').notNull(),
|
|
5
|
+
scope: text('scope').notNull(),
|
|
6
|
+
identifierHmac: text('identifier_hmac').notNull(),
|
|
7
|
+
windowStart: timestamp('window_start', {
|
|
8
|
+
withTimezone: true
|
|
9
|
+
}).notNull(),
|
|
10
|
+
count: integer('count').notNull().default(1),
|
|
11
|
+
expiresAt: timestamp('expires_at', {
|
|
12
|
+
withTimezone: true
|
|
13
|
+
}).notNull(),
|
|
14
|
+
createdAt: timestamp('created_at', {
|
|
15
|
+
withTimezone: true
|
|
16
|
+
}).notNull().defaultNow(),
|
|
17
|
+
updatedAt: timestamp('updated_at', {
|
|
18
|
+
withTimezone: true
|
|
19
|
+
}).notNull().defaultNow()
|
|
20
|
+
}, (table)=>[
|
|
21
|
+
uniqueIndex('auth_rate_limits_window_unique').on(table.action, table.scope, table.identifierHmac, table.windowStart),
|
|
22
|
+
index('auth_rate_limits_expires_at_idx').on(table.expiresAt)
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=rate-limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/rate-limits.ts"],"sourcesContent":["import {index, integer, text, timestamp, uniqueIndex} from 'drizzle-orm/pg-core';\nimport {pgTable} from './common.js';\n\nexport const authRateLimits = pgTable(\n 'rate_limits',\n {\n action: text('action').notNull(),\n scope: text('scope').notNull(),\n identifierHmac: text('identifier_hmac').notNull(),\n windowStart: timestamp('window_start', {withTimezone: true}).notNull(),\n count: integer('count').notNull().default(1),\n expiresAt: timestamp('expires_at', {withTimezone: true}).notNull(),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [\n uniqueIndex('auth_rate_limits_window_unique').on(\n table.action,\n table.scope,\n table.identifierHmac,\n table.windowStart,\n ),\n index('auth_rate_limits_expires_at_idx').on(table.expiresAt),\n ],\n);\n\nexport type AuthRateLimitDb = typeof authRateLimits.$inferSelect;\n"],"names":["index","integer","text","timestamp","uniqueIndex","pgTable","authRateLimits","action","notNull","scope","identifierHmac","windowStart","withTimezone","count","default","expiresAt","createdAt","defaultNow","updatedAt","table","on"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,OAAO,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,QAAO,sBAAsB;AACjF,SAAQC,OAAO,QAAO,cAAc;AAEpC,OAAO,MAAMC,iBAAiBD,QAC5B,eACA;IACEE,QAAQL,KAAK,UAAUM,OAAO;IAC9BC,OAAOP,KAAK,SAASM,OAAO;IAC5BE,gBAAgBR,KAAK,mBAAmBM,OAAO;IAC/CG,aAAaR,UAAU,gBAAgB;QAACS,cAAc;IAAI,GAAGJ,OAAO;IACpEK,OAAOZ,QAAQ,SAASO,OAAO,GAAGM,OAAO,CAAC;IAC1CC,WAAWZ,UAAU,cAAc;QAACS,cAAc;IAAI,GAAGJ,OAAO;IAChEQ,WAAWb,UAAU,cAAc;QAACS,cAAc;IAAI,GAAGJ,OAAO,GAAGS,UAAU;IAC7EC,WAAWf,UAAU,cAAc;QAACS,cAAc;IAAI,GAAGJ,OAAO,GAAGS,UAAU;AAC/E,GACA,CAACE,QAAU;QACTf,YAAY,kCAAkCgB,EAAE,CAC9CD,MAAMZ,MAAM,EACZY,MAAMV,KAAK,EACXU,MAAMT,cAAc,EACpBS,MAAMR,WAAW;QAEnBX,MAAM,mCAAmCoB,EAAE,CAACD,MAAMJ,SAAS;KAC5D,EACD"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { RefreshToken } from '#core/entities/refresh-token.js';
|
|
2
|
+
export declare const refreshTokens: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
3
|
+
name: "refresh_tokens";
|
|
4
|
+
schema: undefined;
|
|
5
|
+
columns: {
|
|
6
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
7
|
+
name: "id";
|
|
8
|
+
tableName: "refresh_tokens";
|
|
9
|
+
dataType: "string";
|
|
10
|
+
columnType: "PgUUID";
|
|
11
|
+
data: string;
|
|
12
|
+
driverParam: string;
|
|
13
|
+
notNull: true;
|
|
14
|
+
hasDefault: true;
|
|
15
|
+
isPrimaryKey: true;
|
|
16
|
+
isAutoincrement: false;
|
|
17
|
+
hasRuntimeDefault: false;
|
|
18
|
+
enumValues: undefined;
|
|
19
|
+
baseColumn: never;
|
|
20
|
+
identity: undefined;
|
|
21
|
+
generated: undefined;
|
|
22
|
+
}, {}, {}>;
|
|
23
|
+
userId: import("drizzle-orm/pg-core").PgColumn<{
|
|
24
|
+
name: "user_id";
|
|
25
|
+
tableName: "refresh_tokens";
|
|
26
|
+
dataType: "string";
|
|
27
|
+
columnType: "PgUUID";
|
|
28
|
+
data: string;
|
|
29
|
+
driverParam: string;
|
|
30
|
+
notNull: true;
|
|
31
|
+
hasDefault: false;
|
|
32
|
+
isPrimaryKey: false;
|
|
33
|
+
isAutoincrement: false;
|
|
34
|
+
hasRuntimeDefault: false;
|
|
35
|
+
enumValues: undefined;
|
|
36
|
+
baseColumn: never;
|
|
37
|
+
identity: undefined;
|
|
38
|
+
generated: undefined;
|
|
39
|
+
}, {}, {}>;
|
|
40
|
+
hashedToken: import("drizzle-orm/pg-core").PgColumn<{
|
|
41
|
+
name: "hashed_token";
|
|
42
|
+
tableName: "refresh_tokens";
|
|
43
|
+
dataType: "string";
|
|
44
|
+
columnType: "PgText";
|
|
45
|
+
data: string;
|
|
46
|
+
driverParam: string;
|
|
47
|
+
notNull: true;
|
|
48
|
+
hasDefault: false;
|
|
49
|
+
isPrimaryKey: false;
|
|
50
|
+
isAutoincrement: false;
|
|
51
|
+
hasRuntimeDefault: false;
|
|
52
|
+
enumValues: [string, ...string[]];
|
|
53
|
+
baseColumn: never;
|
|
54
|
+
identity: undefined;
|
|
55
|
+
generated: undefined;
|
|
56
|
+
}, {}, {}>;
|
|
57
|
+
expiresAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
58
|
+
name: "expires_at";
|
|
59
|
+
tableName: "refresh_tokens";
|
|
60
|
+
dataType: "date";
|
|
61
|
+
columnType: "PgTimestamp";
|
|
62
|
+
data: Date;
|
|
63
|
+
driverParam: string;
|
|
64
|
+
notNull: true;
|
|
65
|
+
hasDefault: false;
|
|
66
|
+
isPrimaryKey: false;
|
|
67
|
+
isAutoincrement: false;
|
|
68
|
+
hasRuntimeDefault: false;
|
|
69
|
+
enumValues: undefined;
|
|
70
|
+
baseColumn: never;
|
|
71
|
+
identity: undefined;
|
|
72
|
+
generated: undefined;
|
|
73
|
+
}, {}, {}>;
|
|
74
|
+
revokedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
75
|
+
name: "revoked_at";
|
|
76
|
+
tableName: "refresh_tokens";
|
|
77
|
+
dataType: "date";
|
|
78
|
+
columnType: "PgTimestamp";
|
|
79
|
+
data: Date;
|
|
80
|
+
driverParam: string;
|
|
81
|
+
notNull: false;
|
|
82
|
+
hasDefault: false;
|
|
83
|
+
isPrimaryKey: false;
|
|
84
|
+
isAutoincrement: false;
|
|
85
|
+
hasRuntimeDefault: false;
|
|
86
|
+
enumValues: undefined;
|
|
87
|
+
baseColumn: never;
|
|
88
|
+
identity: undefined;
|
|
89
|
+
generated: undefined;
|
|
90
|
+
}, {}, {}>;
|
|
91
|
+
rotatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
92
|
+
name: "rotated_at";
|
|
93
|
+
tableName: "refresh_tokens";
|
|
94
|
+
dataType: "date";
|
|
95
|
+
columnType: "PgTimestamp";
|
|
96
|
+
data: Date;
|
|
97
|
+
driverParam: string;
|
|
98
|
+
notNull: false;
|
|
99
|
+
hasDefault: false;
|
|
100
|
+
isPrimaryKey: false;
|
|
101
|
+
isAutoincrement: false;
|
|
102
|
+
hasRuntimeDefault: false;
|
|
103
|
+
enumValues: undefined;
|
|
104
|
+
baseColumn: never;
|
|
105
|
+
identity: undefined;
|
|
106
|
+
generated: undefined;
|
|
107
|
+
}, {}, {}>;
|
|
108
|
+
lastUsedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
109
|
+
name: "last_used_at";
|
|
110
|
+
tableName: "refresh_tokens";
|
|
111
|
+
dataType: "date";
|
|
112
|
+
columnType: "PgTimestamp";
|
|
113
|
+
data: Date;
|
|
114
|
+
driverParam: string;
|
|
115
|
+
notNull: false;
|
|
116
|
+
hasDefault: false;
|
|
117
|
+
isPrimaryKey: false;
|
|
118
|
+
isAutoincrement: false;
|
|
119
|
+
hasRuntimeDefault: false;
|
|
120
|
+
enumValues: undefined;
|
|
121
|
+
baseColumn: never;
|
|
122
|
+
identity: undefined;
|
|
123
|
+
generated: undefined;
|
|
124
|
+
}, {}, {}>;
|
|
125
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
126
|
+
name: "created_at";
|
|
127
|
+
tableName: "refresh_tokens";
|
|
128
|
+
dataType: "date";
|
|
129
|
+
columnType: "PgTimestamp";
|
|
130
|
+
data: Date;
|
|
131
|
+
driverParam: string;
|
|
132
|
+
notNull: true;
|
|
133
|
+
hasDefault: true;
|
|
134
|
+
isPrimaryKey: false;
|
|
135
|
+
isAutoincrement: false;
|
|
136
|
+
hasRuntimeDefault: false;
|
|
137
|
+
enumValues: undefined;
|
|
138
|
+
baseColumn: never;
|
|
139
|
+
identity: undefined;
|
|
140
|
+
generated: undefined;
|
|
141
|
+
}, {}, {}>;
|
|
142
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
143
|
+
name: "updated_at";
|
|
144
|
+
tableName: "refresh_tokens";
|
|
145
|
+
dataType: "date";
|
|
146
|
+
columnType: "PgTimestamp";
|
|
147
|
+
data: Date;
|
|
148
|
+
driverParam: string;
|
|
149
|
+
notNull: true;
|
|
150
|
+
hasDefault: true;
|
|
151
|
+
isPrimaryKey: false;
|
|
152
|
+
isAutoincrement: false;
|
|
153
|
+
hasRuntimeDefault: false;
|
|
154
|
+
enumValues: undefined;
|
|
155
|
+
baseColumn: never;
|
|
156
|
+
identity: undefined;
|
|
157
|
+
generated: undefined;
|
|
158
|
+
}, {}, {}>;
|
|
159
|
+
};
|
|
160
|
+
dialect: "pg";
|
|
161
|
+
}>;
|
|
162
|
+
export type RefreshTokenDb = typeof refreshTokens.$inferSelect;
|
|
163
|
+
export type RefreshTokenCreateDb = typeof refreshTokens.$inferInsert;
|
|
164
|
+
export declare function toRefreshToken(row: RefreshTokenDb): RefreshToken;
|
|
165
|
+
//# sourceMappingURL=refresh-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh-tokens.d.ts","sourceRoot":"","sources":["../../../src/db/schema/refresh-tokens.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAIlE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBzB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,aAAa,CAAC,YAAY,CAAC;AAC/D,MAAM,MAAM,oBAAoB,GAAG,OAAO,aAAa,CAAC,YAAY,CAAC;AAErE,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,CAYhE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { uuidv7PrimaryKey } from '@shipfox/node-drizzle';
|
|
2
|
+
import { index, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { pgTable } from './common.js';
|
|
4
|
+
import { users } from './users.js';
|
|
5
|
+
export const refreshTokens = pgTable('refresh_tokens', {
|
|
6
|
+
id: uuidv7PrimaryKey(),
|
|
7
|
+
userId: uuid('user_id').notNull().references(()=>users.id, {
|
|
8
|
+
onDelete: 'cascade'
|
|
9
|
+
}),
|
|
10
|
+
hashedToken: text('hashed_token').notNull(),
|
|
11
|
+
expiresAt: timestamp('expires_at', {
|
|
12
|
+
withTimezone: true
|
|
13
|
+
}).notNull(),
|
|
14
|
+
revokedAt: timestamp('revoked_at', {
|
|
15
|
+
withTimezone: true
|
|
16
|
+
}),
|
|
17
|
+
rotatedAt: timestamp('rotated_at', {
|
|
18
|
+
withTimezone: true
|
|
19
|
+
}),
|
|
20
|
+
lastUsedAt: timestamp('last_used_at', {
|
|
21
|
+
withTimezone: true
|
|
22
|
+
}),
|
|
23
|
+
createdAt: timestamp('created_at', {
|
|
24
|
+
withTimezone: true
|
|
25
|
+
}).notNull().defaultNow(),
|
|
26
|
+
updatedAt: timestamp('updated_at', {
|
|
27
|
+
withTimezone: true
|
|
28
|
+
}).notNull().defaultNow()
|
|
29
|
+
}, (table)=>[
|
|
30
|
+
uniqueIndex('auth_refresh_tokens_hashed_token_unique').on(table.hashedToken),
|
|
31
|
+
index('auth_refresh_tokens_user_id_idx').on(table.userId)
|
|
32
|
+
]);
|
|
33
|
+
export function toRefreshToken(row) {
|
|
34
|
+
return {
|
|
35
|
+
id: row.id,
|
|
36
|
+
userId: row.userId,
|
|
37
|
+
hashedToken: row.hashedToken,
|
|
38
|
+
expiresAt: row.expiresAt,
|
|
39
|
+
revokedAt: row.revokedAt,
|
|
40
|
+
rotatedAt: row.rotatedAt,
|
|
41
|
+
lastUsedAt: row.lastUsedAt,
|
|
42
|
+
createdAt: row.createdAt,
|
|
43
|
+
updatedAt: row.updatedAt
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=refresh-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/refresh-tokens.ts"],"sourcesContent":["import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {index, text, timestamp, uniqueIndex, uuid} from 'drizzle-orm/pg-core';\nimport type {RefreshToken} from '#core/entities/refresh-token.js';\nimport {pgTable} from './common.js';\nimport {users} from './users.js';\n\nexport const refreshTokens = pgTable(\n 'refresh_tokens',\n {\n id: uuidv7PrimaryKey(),\n userId: uuid('user_id')\n .notNull()\n .references(() => users.id, {onDelete: 'cascade'}),\n hashedToken: text('hashed_token').notNull(),\n expiresAt: timestamp('expires_at', {withTimezone: true}).notNull(),\n revokedAt: timestamp('revoked_at', {withTimezone: true}),\n rotatedAt: timestamp('rotated_at', {withTimezone: true}),\n lastUsedAt: timestamp('last_used_at', {withTimezone: true}),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [\n uniqueIndex('auth_refresh_tokens_hashed_token_unique').on(table.hashedToken),\n index('auth_refresh_tokens_user_id_idx').on(table.userId),\n ],\n);\n\nexport type RefreshTokenDb = typeof refreshTokens.$inferSelect;\nexport type RefreshTokenCreateDb = typeof refreshTokens.$inferInsert;\n\nexport function toRefreshToken(row: RefreshTokenDb): RefreshToken {\n return {\n id: row.id,\n userId: row.userId,\n hashedToken: row.hashedToken,\n expiresAt: row.expiresAt,\n revokedAt: row.revokedAt,\n rotatedAt: row.rotatedAt,\n lastUsedAt: row.lastUsedAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n"],"names":["uuidv7PrimaryKey","index","text","timestamp","uniqueIndex","uuid","pgTable","users","refreshTokens","id","userId","notNull","references","onDelete","hashedToken","expiresAt","withTimezone","revokedAt","rotatedAt","lastUsedAt","createdAt","defaultNow","updatedAt","table","on","toRefreshToken","row"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,KAAK,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,EAAEC,IAAI,QAAO,sBAAsB;AAE9E,SAAQC,OAAO,QAAO,cAAc;AACpC,SAAQC,KAAK,QAAO,aAAa;AAEjC,OAAO,MAAMC,gBAAgBF,QAC3B,kBACA;IACEG,IAAIT;IACJU,QAAQL,KAAK,WACVM,OAAO,GACPC,UAAU,CAAC,IAAML,MAAME,EAAE,EAAE;QAACI,UAAU;IAAS;IAClDC,aAAaZ,KAAK,gBAAgBS,OAAO;IACzCI,WAAWZ,UAAU,cAAc;QAACa,cAAc;IAAI,GAAGL,OAAO;IAChEM,WAAWd,UAAU,cAAc;QAACa,cAAc;IAAI;IACtDE,WAAWf,UAAU,cAAc;QAACa,cAAc;IAAI;IACtDG,YAAYhB,UAAU,gBAAgB;QAACa,cAAc;IAAI;IACzDI,WAAWjB,UAAU,cAAc;QAACa,cAAc;IAAI,GAAGL,OAAO,GAAGU,UAAU;IAC7EC,WAAWnB,UAAU,cAAc;QAACa,cAAc;IAAI,GAAGL,OAAO,GAAGU,UAAU;AAC/E,GACA,CAACE,QAAU;QACTnB,YAAY,2CAA2CoB,EAAE,CAACD,MAAMT,WAAW;QAC3Eb,MAAM,mCAAmCuB,EAAE,CAACD,MAAMb,MAAM;KACzD,EACD;AAKF,OAAO,SAASe,eAAeC,GAAmB;IAChD,OAAO;QACLjB,IAAIiB,IAAIjB,EAAE;QACVC,QAAQgB,IAAIhB,MAAM;QAClBI,aAAaY,IAAIZ,WAAW;QAC5BC,WAAWW,IAAIX,SAAS;QACxBE,WAAWS,IAAIT,SAAS;QACxBC,WAAWQ,IAAIR,SAAS;QACxBC,YAAYO,IAAIP,UAAU;QAC1BC,WAAWM,IAAIN,SAAS;QACxBE,WAAWI,IAAIJ,SAAS;IAC1B;AACF"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { User } from '#core/entities/user.js';
|
|
2
|
+
export declare const userStatusEnum: import("drizzle-orm/pg-core").PgEnum<["active", "suspended", "deleted"]>;
|
|
3
|
+
export declare const users: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4
|
+
name: "users";
|
|
5
|
+
schema: undefined;
|
|
6
|
+
columns: {
|
|
7
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
8
|
+
name: "id";
|
|
9
|
+
tableName: "users";
|
|
10
|
+
dataType: "string";
|
|
11
|
+
columnType: "PgUUID";
|
|
12
|
+
data: string;
|
|
13
|
+
driverParam: string;
|
|
14
|
+
notNull: true;
|
|
15
|
+
hasDefault: true;
|
|
16
|
+
isPrimaryKey: true;
|
|
17
|
+
isAutoincrement: false;
|
|
18
|
+
hasRuntimeDefault: false;
|
|
19
|
+
enumValues: undefined;
|
|
20
|
+
baseColumn: never;
|
|
21
|
+
identity: undefined;
|
|
22
|
+
generated: undefined;
|
|
23
|
+
}, {}, {}>;
|
|
24
|
+
email: import("drizzle-orm/pg-core").PgColumn<{
|
|
25
|
+
name: "email";
|
|
26
|
+
tableName: "users";
|
|
27
|
+
dataType: "string";
|
|
28
|
+
columnType: "PgText";
|
|
29
|
+
data: string;
|
|
30
|
+
driverParam: string;
|
|
31
|
+
notNull: true;
|
|
32
|
+
hasDefault: false;
|
|
33
|
+
isPrimaryKey: false;
|
|
34
|
+
isAutoincrement: false;
|
|
35
|
+
hasRuntimeDefault: false;
|
|
36
|
+
enumValues: [string, ...string[]];
|
|
37
|
+
baseColumn: never;
|
|
38
|
+
identity: undefined;
|
|
39
|
+
generated: undefined;
|
|
40
|
+
}, {}, {}>;
|
|
41
|
+
hashedPassword: import("drizzle-orm/pg-core").PgColumn<{
|
|
42
|
+
name: "hashed_password";
|
|
43
|
+
tableName: "users";
|
|
44
|
+
dataType: "string";
|
|
45
|
+
columnType: "PgText";
|
|
46
|
+
data: string;
|
|
47
|
+
driverParam: string;
|
|
48
|
+
notNull: false;
|
|
49
|
+
hasDefault: false;
|
|
50
|
+
isPrimaryKey: false;
|
|
51
|
+
isAutoincrement: false;
|
|
52
|
+
hasRuntimeDefault: false;
|
|
53
|
+
enumValues: [string, ...string[]];
|
|
54
|
+
baseColumn: never;
|
|
55
|
+
identity: undefined;
|
|
56
|
+
generated: undefined;
|
|
57
|
+
}, {}, {}>;
|
|
58
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
59
|
+
name: "name";
|
|
60
|
+
tableName: "users";
|
|
61
|
+
dataType: "string";
|
|
62
|
+
columnType: "PgText";
|
|
63
|
+
data: string;
|
|
64
|
+
driverParam: string;
|
|
65
|
+
notNull: false;
|
|
66
|
+
hasDefault: false;
|
|
67
|
+
isPrimaryKey: false;
|
|
68
|
+
isAutoincrement: false;
|
|
69
|
+
hasRuntimeDefault: false;
|
|
70
|
+
enumValues: [string, ...string[]];
|
|
71
|
+
baseColumn: never;
|
|
72
|
+
identity: undefined;
|
|
73
|
+
generated: undefined;
|
|
74
|
+
}, {}, {}>;
|
|
75
|
+
emailVerifiedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
76
|
+
name: "email_verified_at";
|
|
77
|
+
tableName: "users";
|
|
78
|
+
dataType: "date";
|
|
79
|
+
columnType: "PgTimestamp";
|
|
80
|
+
data: Date;
|
|
81
|
+
driverParam: string;
|
|
82
|
+
notNull: false;
|
|
83
|
+
hasDefault: false;
|
|
84
|
+
isPrimaryKey: false;
|
|
85
|
+
isAutoincrement: false;
|
|
86
|
+
hasRuntimeDefault: false;
|
|
87
|
+
enumValues: undefined;
|
|
88
|
+
baseColumn: never;
|
|
89
|
+
identity: undefined;
|
|
90
|
+
generated: undefined;
|
|
91
|
+
}, {}, {}>;
|
|
92
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
93
|
+
name: "status";
|
|
94
|
+
tableName: "users";
|
|
95
|
+
dataType: "string";
|
|
96
|
+
columnType: "PgEnumColumn";
|
|
97
|
+
data: "active" | "suspended" | "deleted";
|
|
98
|
+
driverParam: string;
|
|
99
|
+
notNull: true;
|
|
100
|
+
hasDefault: true;
|
|
101
|
+
isPrimaryKey: false;
|
|
102
|
+
isAutoincrement: false;
|
|
103
|
+
hasRuntimeDefault: false;
|
|
104
|
+
enumValues: ["active", "suspended", "deleted"];
|
|
105
|
+
baseColumn: never;
|
|
106
|
+
identity: undefined;
|
|
107
|
+
generated: undefined;
|
|
108
|
+
}, {}, {}>;
|
|
109
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
110
|
+
name: "created_at";
|
|
111
|
+
tableName: "users";
|
|
112
|
+
dataType: "date";
|
|
113
|
+
columnType: "PgTimestamp";
|
|
114
|
+
data: Date;
|
|
115
|
+
driverParam: string;
|
|
116
|
+
notNull: true;
|
|
117
|
+
hasDefault: true;
|
|
118
|
+
isPrimaryKey: false;
|
|
119
|
+
isAutoincrement: false;
|
|
120
|
+
hasRuntimeDefault: false;
|
|
121
|
+
enumValues: undefined;
|
|
122
|
+
baseColumn: never;
|
|
123
|
+
identity: undefined;
|
|
124
|
+
generated: undefined;
|
|
125
|
+
}, {}, {}>;
|
|
126
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
127
|
+
name: "updated_at";
|
|
128
|
+
tableName: "users";
|
|
129
|
+
dataType: "date";
|
|
130
|
+
columnType: "PgTimestamp";
|
|
131
|
+
data: Date;
|
|
132
|
+
driverParam: string;
|
|
133
|
+
notNull: true;
|
|
134
|
+
hasDefault: true;
|
|
135
|
+
isPrimaryKey: false;
|
|
136
|
+
isAutoincrement: false;
|
|
137
|
+
hasRuntimeDefault: false;
|
|
138
|
+
enumValues: undefined;
|
|
139
|
+
baseColumn: never;
|
|
140
|
+
identity: undefined;
|
|
141
|
+
generated: undefined;
|
|
142
|
+
}, {}, {}>;
|
|
143
|
+
};
|
|
144
|
+
dialect: "pg";
|
|
145
|
+
}>;
|
|
146
|
+
export type UserDb = typeof users.$inferSelect;
|
|
147
|
+
export type UserCreateDb = typeof users.$inferInsert;
|
|
148
|
+
export declare function toUser(row: UserDb): User;
|
|
149
|
+
//# sourceMappingURL=users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/db/schema/users.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAa,MAAM,wBAAwB,CAAC;AAG7D,eAAO,MAAM,cAAc,0EAAiE,CAAC;AAE7F,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAajB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,OAAO,KAAK,CAAC,YAAY,CAAC;AAC/C,MAAM,MAAM,YAAY,GAAG,OAAO,KAAK,CAAC,YAAY,CAAC;AAErD,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAWxC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { uuidv7PrimaryKey } from '@shipfox/node-drizzle';
|
|
2
|
+
import { pgEnum, text, timestamp, uniqueIndex } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { pgTable } from './common.js';
|
|
4
|
+
export const userStatusEnum = pgEnum('auth_user_status', [
|
|
5
|
+
'active',
|
|
6
|
+
'suspended',
|
|
7
|
+
'deleted'
|
|
8
|
+
]);
|
|
9
|
+
export const users = pgTable('users', {
|
|
10
|
+
id: uuidv7PrimaryKey(),
|
|
11
|
+
email: text('email').notNull(),
|
|
12
|
+
hashedPassword: text('hashed_password'),
|
|
13
|
+
name: text('name'),
|
|
14
|
+
emailVerifiedAt: timestamp('email_verified_at', {
|
|
15
|
+
withTimezone: true
|
|
16
|
+
}),
|
|
17
|
+
status: userStatusEnum('status').notNull().default('active'),
|
|
18
|
+
createdAt: timestamp('created_at', {
|
|
19
|
+
withTimezone: true
|
|
20
|
+
}).notNull().defaultNow(),
|
|
21
|
+
updatedAt: timestamp('updated_at', {
|
|
22
|
+
withTimezone: true
|
|
23
|
+
}).notNull().defaultNow()
|
|
24
|
+
}, (table)=>[
|
|
25
|
+
uniqueIndex('auth_users_email_unique').on(table.email)
|
|
26
|
+
]);
|
|
27
|
+
export function toUser(row) {
|
|
28
|
+
return {
|
|
29
|
+
id: row.id,
|
|
30
|
+
email: row.email,
|
|
31
|
+
hashedPassword: row.hashedPassword,
|
|
32
|
+
name: row.name,
|
|
33
|
+
emailVerifiedAt: row.emailVerifiedAt,
|
|
34
|
+
status: row.status,
|
|
35
|
+
createdAt: row.createdAt,
|
|
36
|
+
updatedAt: row.updatedAt
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/users.ts"],"sourcesContent":["import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {pgEnum, text, timestamp, uniqueIndex} from 'drizzle-orm/pg-core';\nimport type {User, UserStatus} from '#core/entities/user.js';\nimport {pgTable} from './common.js';\n\nexport const userStatusEnum = pgEnum('auth_user_status', ['active', 'suspended', 'deleted']);\n\nexport const users = pgTable(\n 'users',\n {\n id: uuidv7PrimaryKey(),\n email: text('email').notNull(),\n hashedPassword: text('hashed_password'),\n name: text('name'),\n emailVerifiedAt: timestamp('email_verified_at', {withTimezone: true}),\n status: userStatusEnum('status').notNull().default('active'),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [uniqueIndex('auth_users_email_unique').on(table.email)],\n);\n\nexport type UserDb = typeof users.$inferSelect;\nexport type UserCreateDb = typeof users.$inferInsert;\n\nexport function toUser(row: UserDb): User {\n return {\n id: row.id,\n email: row.email,\n hashedPassword: row.hashedPassword,\n name: row.name,\n emailVerifiedAt: row.emailVerifiedAt,\n status: row.status as UserStatus,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n"],"names":["uuidv7PrimaryKey","pgEnum","text","timestamp","uniqueIndex","pgTable","userStatusEnum","users","id","email","notNull","hashedPassword","name","emailVerifiedAt","withTimezone","status","default","createdAt","defaultNow","updatedAt","table","on","toUser","row"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,QAAO,sBAAsB;AAEzE,SAAQC,OAAO,QAAO,cAAc;AAEpC,OAAO,MAAMC,iBAAiBL,OAAO,oBAAoB;IAAC;IAAU;IAAa;CAAU,EAAE;AAE7F,OAAO,MAAMM,QAAQF,QACnB,SACA;IACEG,IAAIR;IACJS,OAAOP,KAAK,SAASQ,OAAO;IAC5BC,gBAAgBT,KAAK;IACrBU,MAAMV,KAAK;IACXW,iBAAiBV,UAAU,qBAAqB;QAACW,cAAc;IAAI;IACnEC,QAAQT,eAAe,UAAUI,OAAO,GAAGM,OAAO,CAAC;IACnDC,WAAWd,UAAU,cAAc;QAACW,cAAc;IAAI,GAAGJ,OAAO,GAAGQ,UAAU;IAC7EC,WAAWhB,UAAU,cAAc;QAACW,cAAc;IAAI,GAAGJ,OAAO,GAAGQ,UAAU;AAC/E,GACA,CAACE,QAAU;QAAChB,YAAY,2BAA2BiB,EAAE,CAACD,MAAMX,KAAK;KAAE,EACnE;AAKF,OAAO,SAASa,OAAOC,GAAW;IAChC,OAAO;QACLf,IAAIe,IAAIf,EAAE;QACVC,OAAOc,IAAId,KAAK;QAChBE,gBAAgBY,IAAIZ,cAAc;QAClCC,MAAMW,IAAIX,IAAI;QACdC,iBAAiBU,IAAIV,eAAe;QACpCE,QAAQQ,IAAIR,MAAM;QAClBE,WAAWM,IAAIN,SAAS;QACxBE,WAAWI,IAAIJ,SAAS;IAC1B;AACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { User } from '#core/entities/user.js';
|
|
2
|
+
export interface CreateUserParams {
|
|
3
|
+
email: string;
|
|
4
|
+
hashedPassword: string | null;
|
|
5
|
+
name?: string | null;
|
|
6
|
+
emailVerifiedAt?: Date | null;
|
|
7
|
+
}
|
|
8
|
+
export interface ProvisionUserParams {
|
|
9
|
+
email: string;
|
|
10
|
+
name?: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function createUser(params: CreateUserParams): Promise<User>;
|
|
13
|
+
export declare function provisionUser(params: ProvisionUserParams): Promise<User>;
|
|
14
|
+
export declare function findUserByEmail(params: {
|
|
15
|
+
email: string;
|
|
16
|
+
}): Promise<User | undefined>;
|
|
17
|
+
export declare function findUserById(params: {
|
|
18
|
+
id: string;
|
|
19
|
+
}): Promise<User | undefined>;
|
|
20
|
+
export interface UpdateUserPasswordParams {
|
|
21
|
+
userId: string;
|
|
22
|
+
hashedPassword: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function updateUserPassword(params: UpdateUserPasswordParams): Promise<User | undefined>;
|
|
25
|
+
export declare function markEmailVerified(params: {
|
|
26
|
+
userId: string;
|
|
27
|
+
}): Promise<User | undefined>;
|
|
28
|
+
//# sourceMappingURL=users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/db/users.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAKjD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,eAAe,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAcD,wBAAsB,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBxE;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB9E;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAKxF;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAKlF;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAa3B;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAU3F"}
|
package/dist/db/users.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { eq } from 'drizzle-orm';
|
|
2
|
+
import { EmailTakenError } from '#core/errors.js';
|
|
3
|
+
import { db } from './db.js';
|
|
4
|
+
import { toUser, users } from './schema/users.js';
|
|
5
|
+
// Drizzle wraps the underlying Postgres error; walk `.cause` to reach it.
|
|
6
|
+
function isAuthUsersEmailUniqueViolation(error) {
|
|
7
|
+
let current = error;
|
|
8
|
+
for(let depth = 0; depth < 5 && current != null; depth += 1){
|
|
9
|
+
if (typeof current !== 'object') return false;
|
|
10
|
+
const { code, constraint } = current;
|
|
11
|
+
if (code === '23505' && constraint === 'auth_users_email_unique') return true;
|
|
12
|
+
current = current.cause;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
export async function createUser(params) {
|
|
17
|
+
let rows;
|
|
18
|
+
try {
|
|
19
|
+
rows = await db().insert(users).values({
|
|
20
|
+
email: params.email,
|
|
21
|
+
hashedPassword: params.hashedPassword,
|
|
22
|
+
name: params.name ?? null,
|
|
23
|
+
emailVerifiedAt: params.emailVerifiedAt ?? null
|
|
24
|
+
}).returning();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (isAuthUsersEmailUniqueViolation(error)) {
|
|
27
|
+
throw new EmailTakenError(params.email);
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
const row = rows[0];
|
|
32
|
+
if (!row) throw new Error('Insert returned no rows');
|
|
33
|
+
return toUser(row);
|
|
34
|
+
}
|
|
35
|
+
export async function provisionUser(params) {
|
|
36
|
+
const rows = await db().insert(users).values({
|
|
37
|
+
email: params.email,
|
|
38
|
+
hashedPassword: null,
|
|
39
|
+
name: params.name ?? null,
|
|
40
|
+
emailVerifiedAt: new Date()
|
|
41
|
+
}).onConflictDoNothing({
|
|
42
|
+
target: users.email
|
|
43
|
+
}).returning();
|
|
44
|
+
const row = rows[0];
|
|
45
|
+
if (row) return toUser(row);
|
|
46
|
+
const existing = await findUserByEmail({
|
|
47
|
+
email: params.email
|
|
48
|
+
});
|
|
49
|
+
if (existing) return existing;
|
|
50
|
+
throw new Error('Provisioning user conflict returned no user');
|
|
51
|
+
}
|
|
52
|
+
export async function findUserByEmail(params) {
|
|
53
|
+
const rows = await db().select().from(users).where(eq(users.email, params.email)).limit(1);
|
|
54
|
+
const row = rows[0];
|
|
55
|
+
if (!row) return undefined;
|
|
56
|
+
return toUser(row);
|
|
57
|
+
}
|
|
58
|
+
export async function findUserById(params) {
|
|
59
|
+
const rows = await db().select().from(users).where(eq(users.id, params.id)).limit(1);
|
|
60
|
+
const row = rows[0];
|
|
61
|
+
if (!row) return undefined;
|
|
62
|
+
return toUser(row);
|
|
63
|
+
}
|
|
64
|
+
export async function updateUserPassword(params) {
|
|
65
|
+
const rows = await db().update(users).set({
|
|
66
|
+
hashedPassword: params.hashedPassword,
|
|
67
|
+
updatedAt: new Date()
|
|
68
|
+
}).where(eq(users.id, params.userId)).returning();
|
|
69
|
+
const row = rows[0];
|
|
70
|
+
if (!row) return undefined;
|
|
71
|
+
return toUser(row);
|
|
72
|
+
}
|
|
73
|
+
export async function markEmailVerified(params) {
|
|
74
|
+
const rows = await db().update(users).set({
|
|
75
|
+
emailVerifiedAt: new Date(),
|
|
76
|
+
updatedAt: new Date()
|
|
77
|
+
}).where(eq(users.id, params.userId)).returning();
|
|
78
|
+
const row = rows[0];
|
|
79
|
+
if (!row) return undefined;
|
|
80
|
+
return toUser(row);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/db/users.ts"],"sourcesContent":["import {eq} from 'drizzle-orm';\nimport type {User} from '#core/entities/user.js';\nimport {EmailTakenError} from '#core/errors.js';\nimport {db} from './db.js';\nimport {toUser, type UserDb, users} from './schema/users.js';\n\nexport interface CreateUserParams {\n email: string;\n hashedPassword: string | null;\n name?: string | null;\n emailVerifiedAt?: Date | null;\n}\n\nexport interface ProvisionUserParams {\n email: string;\n name?: string | null;\n}\n\n// Drizzle wraps the underlying Postgres error; walk `.cause` to reach it.\nfunction isAuthUsersEmailUniqueViolation(error: unknown): boolean {\n let current: unknown = error;\n for (let depth = 0; depth < 5 && current != null; depth += 1) {\n if (typeof current !== 'object') return false;\n const {code, constraint} = current as {code?: unknown; constraint?: unknown};\n if (code === '23505' && constraint === 'auth_users_email_unique') return true;\n current = (current as {cause?: unknown}).cause;\n }\n return false;\n}\n\nexport async function createUser(params: CreateUserParams): Promise<User> {\n let rows: UserDb[];\n try {\n rows = await db()\n .insert(users)\n .values({\n email: params.email,\n hashedPassword: params.hashedPassword,\n name: params.name ?? null,\n emailVerifiedAt: params.emailVerifiedAt ?? null,\n })\n .returning();\n } catch (error) {\n if (isAuthUsersEmailUniqueViolation(error)) {\n throw new EmailTakenError(params.email);\n }\n throw error;\n }\n\n const row = rows[0];\n if (!row) throw new Error('Insert returned no rows');\n return toUser(row);\n}\n\nexport async function provisionUser(params: ProvisionUserParams): Promise<User> {\n const rows = await db()\n .insert(users)\n .values({\n email: params.email,\n hashedPassword: null,\n name: params.name ?? null,\n emailVerifiedAt: new Date(),\n })\n .onConflictDoNothing({target: users.email})\n .returning();\n\n const row = rows[0];\n if (row) return toUser(row);\n\n const existing = await findUserByEmail({email: params.email});\n if (existing) return existing;\n throw new Error('Provisioning user conflict returned no user');\n}\n\nexport async function findUserByEmail(params: {email: string}): Promise<User | undefined> {\n const rows = await db().select().from(users).where(eq(users.email, params.email)).limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return toUser(row);\n}\n\nexport async function findUserById(params: {id: string}): Promise<User | undefined> {\n const rows = await db().select().from(users).where(eq(users.id, params.id)).limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return toUser(row);\n}\n\nexport interface UpdateUserPasswordParams {\n userId: string;\n hashedPassword: string;\n}\n\nexport async function updateUserPassword(\n params: UpdateUserPasswordParams,\n): Promise<User | undefined> {\n const rows = await db()\n .update(users)\n .set({\n hashedPassword: params.hashedPassword,\n updatedAt: new Date(),\n })\n .where(eq(users.id, params.userId))\n .returning();\n\n const row = rows[0];\n if (!row) return undefined;\n return toUser(row);\n}\n\nexport async function markEmailVerified(params: {userId: string}): Promise<User | undefined> {\n const rows = await db()\n .update(users)\n .set({emailVerifiedAt: new Date(), updatedAt: new Date()})\n .where(eq(users.id, params.userId))\n .returning();\n\n const row = rows[0];\n if (!row) return undefined;\n return toUser(row);\n}\n"],"names":["eq","EmailTakenError","db","toUser","users","isAuthUsersEmailUniqueViolation","error","current","depth","code","constraint","cause","createUser","params","rows","insert","values","email","hashedPassword","name","emailVerifiedAt","returning","row","Error","provisionUser","Date","onConflictDoNothing","target","existing","findUserByEmail","select","from","where","limit","undefined","findUserById","id","updateUserPassword","update","set","updatedAt","userId","markEmailVerified"],"mappings":"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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ShipfoxModule } from '@shipfox/node-module';
|
|
2
|
+
export type { JobLeaseTokenClaims, RunnerSessionTokenClaims } from '@shipfox/api-auth-dto';
|
|
3
|
+
export type { CreateSessionForUserError, CreateSessionForUserParams, CreateSessionForUserResult, ProvisionUserParams, } from '#core/auth.js';
|
|
4
|
+
export { createSessionForUser, provisionUser } from '#core/auth.js';
|
|
5
|
+
export type { User, UserStatus } from '#core/entities/user.js';
|
|
6
|
+
export { AuthDependencyUnavailableError, EmailNotVerifiedError, InvalidCredentialsError, UserNotFoundError, } from '#core/errors.js';
|
|
7
|
+
export { issueJobLeaseToken, jobLeaseParamsFrom, verifyJobLeaseToken, } from '#core/job-lease-token.js';
|
|
8
|
+
export { issueRunnerSessionToken, verifyRunnerSessionToken, } from '#core/runner-session-token.js';
|
|
9
|
+
export { createJwtAuthMethod } from '#presentation/auth/jwt-auth.js';
|
|
10
|
+
export { createLeaseTokenAuthMethod } from '#presentation/auth/lease-token-auth.js';
|
|
11
|
+
export { authCookiePlugin, clearRefreshTokenCookie, getRefreshTokenCookie, setRefreshTokenCookie, } from '#presentation/auth/refresh-cookie.js';
|
|
12
|
+
export { createRunnerSessionAuthMethod } from '#presentation/auth/runner-session-auth.js';
|
|
13
|
+
export declare const authModule: ShipfoxModule;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAexD,YAAY,EAAC,mBAAmB,EAAE,wBAAwB,EAAC,MAAM,uBAAuB,CAAC;AACzF,YAAY,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,oBAAoB,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAClE,YAAY,EAAC,IAAI,EAAE,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAC;AAClF,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAC,6BAA6B,EAAC,MAAM,2CAA2C,CAAC;AAIxF,eAAO,MAAM,UAAU,EAAE,aAWxB,CAAC"}
|