@shipfox/api-auth 7.1.0 → 9.0.2

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.
@@ -1,2 +1,2 @@
1
1
  $ shipfox-swc
2
- Successfully compiled: 52 files with swc (564.43ms)
2
+ Successfully compiled: 52 files with swc (602.64ms)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,83 @@
1
1
  # @shipfox/api-auth
2
2
 
3
+ ## 9.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 4b85404: Adds versioned architecture identity to participating package artifacts during publication.
8
+ - Updated dependencies [4b85404]
9
+ - @shipfox/api-auth-context@9.0.2
10
+ - @shipfox/api-auth-dto@9.0.2
11
+ - @shipfox/api-email-challenges@1.1.1
12
+ - @shipfox/api-workspaces-dto@9.0.2
13
+ - @shipfox/config@1.2.4
14
+ - @shipfox/inter-module@0.2.2
15
+ - @shipfox/node-auth-root-key@0.2.3
16
+ - @shipfox/node-drizzle@0.3.4
17
+ - @shipfox/node-email@0.3.3
18
+ - @shipfox/node-fastify@0.3.2
19
+ - @shipfox/node-jwt@0.3.2
20
+ - @shipfox/node-mailer@0.2.3
21
+ - @shipfox/node-module@1.0.1
22
+ - @shipfox/node-opentelemetry@0.6.2
23
+ - @shipfox/node-outbox@0.2.6
24
+ - @shipfox/node-postgres@0.4.4
25
+ - @shipfox/node-rate-limit@0.3.2
26
+ - @shipfox/node-tokens@0.3.2
27
+
28
+ ## 9.0.1
29
+
30
+ ### Patch Changes
31
+
32
+ - 475ce59: Republishes all public packages after restoring release authorization.
33
+ - Updated dependencies [44c15c8]
34
+ - Updated dependencies [475ce59]
35
+ - Updated dependencies [154e03f]
36
+ - @shipfox/api-email-challenges@1.1.0
37
+ - @shipfox/api-auth-context@9.0.1
38
+ - @shipfox/api-auth-dto@9.0.1
39
+ - @shipfox/api-workspaces-dto@9.0.1
40
+ - @shipfox/config@1.2.3
41
+ - @shipfox/inter-module@0.2.1
42
+ - @shipfox/node-auth-root-key@0.2.2
43
+ - @shipfox/node-drizzle@0.3.3
44
+ - @shipfox/node-email@0.3.2
45
+ - @shipfox/node-fastify@0.3.1
46
+ - @shipfox/node-jwt@0.3.1
47
+ - @shipfox/node-mailer@0.2.2
48
+ - @shipfox/node-module@1.0.0
49
+ - @shipfox/node-opentelemetry@0.6.1
50
+ - @shipfox/node-outbox@0.2.5
51
+ - @shipfox/node-postgres@0.4.3
52
+ - @shipfox/node-rate-limit@0.3.1
53
+ - @shipfox/node-tokens@0.3.1
54
+
55
+ ## 9.0.0
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [9c9d266]
60
+ - Updated dependencies [c279061]
61
+ - Updated dependencies [9083d20]
62
+ - @shipfox/api-workspaces-dto@9.0.0
63
+ - @shipfox/api-email-challenges@1.0.0
64
+ - @shipfox/api-auth-context@9.0.0
65
+ - @shipfox/api-auth-dto@7.1.0
66
+ - @shipfox/config@1.2.2
67
+ - @shipfox/inter-module@0.2.0
68
+ - @shipfox/node-auth-root-key@0.2.1
69
+ - @shipfox/node-drizzle@0.3.2
70
+ - @shipfox/node-email@0.3.1
71
+ - @shipfox/node-fastify@0.3.0
72
+ - @shipfox/node-jwt@0.3.0
73
+ - @shipfox/node-mailer@0.2.1
74
+ - @shipfox/node-module@0.5.0
75
+ - @shipfox/node-opentelemetry@0.6.0
76
+ - @shipfox/node-outbox@0.2.4
77
+ - @shipfox/node-postgres@0.4.2
78
+ - @shipfox/node-rate-limit@0.3.0
79
+ - @shipfox/node-tokens@0.3.0
80
+
3
81
  ## 7.1.0
4
82
 
5
83
  ### Minor Changes
package/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Shipfox API Auth
2
2
 
3
- Shipfox API Auth provides the server-side auth module for Shipfox APIs. It owns user accounts, email verification, login, refresh sessions, password reset, password change, JWT auth, and its PostgreSQL tables.
3
+ Shipfox API Auth provides the server-side auth module for Shipfox APIs. This
4
+ package owns user accounts, email verification, login, refresh sessions,
5
+ password reset, password change, JWT auth, and its PostgreSQL tables.
6
+
7
+ For repository-wide backend module, configuration, error, and observability
8
+ rules, read the [backend architecture guide](../../../docs/architecture/backend-architecture.md).
9
+ This README owns the local security model, package API, routes, data model, and
10
+ auth-specific operational constraints.
4
11
 
5
12
  ## Example
6
13
 
@@ -383,13 +390,8 @@ turbo type --filter=@shipfox/api-auth
383
390
  turbo test --filter=@shipfox/api-auth
384
391
  ```
385
392
 
386
- Tests use Vitest and a real PostgreSQL database. Start local services before running the test suite:
387
-
388
- ```sh
389
- docker compose up -d
390
- ```
391
-
392
- The test environment uses the `api_test` database and sets fake auth secrets in `test/env.ts`.
393
+ For repository test conventions, read the [testing guide](../../../docs/guides/testing.md).
394
+ This package uses the `api_test` database and sets fake auth secrets in `test/env.ts`.
393
395
 
394
396
  ## License
395
397
 
package/dist/index.js CHANGED
@@ -27,7 +27,8 @@ export function createAuthModule({ workspaces }) {
27
27
  name: 'auth',
28
28
  database: {
29
29
  db,
30
- migrationsPath
30
+ migrationsPath,
31
+ databaseNamespace: 'auth'
31
32
  },
32
33
  auth: [
33
34
  createJwtAuthMethod(),
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n AUTH_PASSWORD_RESET_SEND_REQUESTED,\n type AuthEventMap,\n authEventSchemas,\n} from '@shipfox/api-auth-dto';\nimport type {ShipfoxModule} from '@shipfox/node-module';\nimport {subscriberFactory} from '@shipfox/node-module';\nimport {config} from '#config.js';\nimport {db} from '#db/db.js';\nimport {migrationsPath} from '#db/migrations.js';\nimport {authOutbox} from '#db/schema/outbox.js';\nimport {createJwtAuthMethod} from '#presentation/auth/jwt-auth.js';\nimport {createLeaseTokenAuthMethod} from '#presentation/auth/lease-token-auth.js';\nimport {createRunnerSessionAuthMethod} from '#presentation/auth/runner-session-auth.js';\nimport {createAuthE2eRoutes} from '#presentation/e2eRoutes/index.js';\nimport {createAuthInterModulePresentation} from '#presentation/inter-module.js';\nimport {buildAuthRoutes} from '#presentation/routes/index.js';\nimport {onPasswordResetSendRequested} from '#presentation/subscribers/index.js';\nimport {passwordLoginMethods} from './login-methods.js';\n\nexport type {JobLeaseTokenClaims, RunnerSessionTokenClaims} from '@shipfox/api-auth-dto';\nexport type {\n CreateSessionForUserError,\n CreateSessionForUserParams,\n CreateSessionForUserResult,\n ProvisionUserParams,\n} from '#core/auth.js';\nexport {createSessionForUser, provisionUser} from '#core/auth.js';\nexport type {EmailOwner, FindUserByEmailParams} from '#core/email-owner.js';\nexport {findUserByEmail} from '#core/email-owner.js';\nexport type {User, UserStatus} from '#core/entities/user.js';\nexport {\n AuthDependencyUnavailableError,\n EmailNotVerifiedError,\n InvalidCredentialsError,\n UserNotFoundError,\n} from '#core/errors.js';\nexport {\n issueJobLeaseToken,\n jobLeaseParamsFrom,\n verifyJobLeaseToken,\n} from '#core/job-lease-token.js';\nexport {\n issueRunnerSessionToken,\n verifyRunnerSessionToken,\n} from '#core/runner-session-token.js';\nexport {\n type AuthenticatedSessionContext,\n createJwtAuthMethod,\n getAuthenticatedSessionContext,\n type RefreshSessionId,\n type UserId,\n} from '#presentation/auth/jwt-auth.js';\nexport {createLeaseTokenAuthMethod} from '#presentation/auth/lease-token-auth.js';\nexport {\n authCookiePlugin,\n clearRefreshTokenCookie,\n getRefreshTokenCookie,\n setRefreshTokenCookie,\n} from '#presentation/auth/refresh-cookie.js';\nexport {createRunnerSessionAuthMethod} from '#presentation/auth/runner-session-auth.js';\n\nconst subscriber = subscriberFactory<AuthEventMap>();\n\nexport function createAuthModule({\n workspaces,\n}: {\n workspaces: import('@shipfox/api-workspaces-dto/inter-module').WorkspacesInterModuleClient;\n}): ShipfoxModule {\n return {\n name: 'auth',\n database: {db, migrationsPath},\n auth: [createJwtAuthMethod(), createLeaseTokenAuthMethod(), createRunnerSessionAuthMethod()],\n loginMethods: passwordLoginMethods(config.AUTH_PASSWORD_ENABLED),\n routes: [buildAuthRoutes(config.AUTH_PASSWORD_ENABLED, workspaces)],\n e2eRoutes: [createAuthE2eRoutes(workspaces)],\n publishers: [{name: 'auth', table: authOutbox, db, eventSchemas: authEventSchemas}],\n subscribers: [subscriber(AUTH_PASSWORD_RESET_SEND_REQUESTED, onPasswordResetSendRequested)],\n interModulePresentations: [createAuthInterModulePresentation()],\n };\n}\n"],"names":["AUTH_PASSWORD_RESET_SEND_REQUESTED","authEventSchemas","subscriberFactory","config","db","migrationsPath","authOutbox","createJwtAuthMethod","createLeaseTokenAuthMethod","createRunnerSessionAuthMethod","createAuthE2eRoutes","createAuthInterModulePresentation","buildAuthRoutes","onPasswordResetSendRequested","passwordLoginMethods","createSessionForUser","provisionUser","findUserByEmail","AuthDependencyUnavailableError","EmailNotVerifiedError","InvalidCredentialsError","UserNotFoundError","issueJobLeaseToken","jobLeaseParamsFrom","verifyJobLeaseToken","issueRunnerSessionToken","verifyRunnerSessionToken","getAuthenticatedSessionContext","authCookiePlugin","clearRefreshTokenCookie","getRefreshTokenCookie","setRefreshTokenCookie","subscriber","createAuthModule","workspaces","name","database","auth","loginMethods","AUTH_PASSWORD_ENABLED","routes","e2eRoutes","publishers","table","eventSchemas","subscribers","interModulePresentations"],"mappings":"AAAA,SACEA,kCAAkC,EAElCC,gBAAgB,QACX,wBAAwB;AAE/B,SAAQC,iBAAiB,QAAO,uBAAuB;AACvD,SAAQC,MAAM,QAAO,aAAa;AAClC,SAAQC,EAAE,QAAO,YAAY;AAC7B,SAAQC,cAAc,QAAO,oBAAoB;AACjD,SAAQC,UAAU,QAAO,uBAAuB;AAChD,SAAQC,mBAAmB,QAAO,iCAAiC;AACnE,SAAQC,0BAA0B,QAAO,yCAAyC;AAClF,SAAQC,6BAA6B,QAAO,4CAA4C;AACxF,SAAQC,mBAAmB,QAAO,mCAAmC;AACrE,SAAQC,iCAAiC,QAAO,gCAAgC;AAChF,SAAQC,eAAe,QAAO,gCAAgC;AAC9D,SAAQC,4BAA4B,QAAO,qCAAqC;AAChF,SAAQC,oBAAoB,QAAO,qBAAqB;AASxD,SAAQC,oBAAoB,EAAEC,aAAa,QAAO,gBAAgB;AAElE,SAAQC,eAAe,QAAO,uBAAuB;AAErD,SACEC,8BAA8B,EAC9BC,qBAAqB,EACrBC,uBAAuB,EACvBC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,kBAAkB,EAClBC,kBAAkB,EAClBC,mBAAmB,QACd,2BAA2B;AAClC,SACEC,uBAAuB,EACvBC,wBAAwB,QACnB,gCAAgC;AACvC,SAEEnB,mBAAmB,EACnBoB,8BAA8B,QAGzB,iCAAiC;AACxC,SAAQnB,0BAA0B,QAAO,yCAAyC;AAClF,SACEoB,gBAAgB,EAChBC,uBAAuB,EACvBC,qBAAqB,EACrBC,qBAAqB,QAChB,uCAAuC;AAC9C,SAAQtB,6BAA6B,QAAO,4CAA4C;AAExF,MAAMuB,aAAa9B;AAEnB,OAAO,SAAS+B,iBAAiB,EAC/BC,UAAU,EAGX;IACC,OAAO;QACLC,MAAM;QACNC,UAAU;YAAChC;YAAIC;QAAc;QAC7BgC,MAAM;YAAC9B;YAAuBC;YAA8BC;SAAgC;QAC5F6B,cAAcxB,qBAAqBX,OAAOoC,qBAAqB;QAC/DC,QAAQ;YAAC5B,gBAAgBT,OAAOoC,qBAAqB,EAAEL;SAAY;QACnEO,WAAW;YAAC/B,oBAAoBwB;SAAY;QAC5CQ,YAAY;YAAC;gBAACP,MAAM;gBAAQQ,OAAOrC;gBAAYF;gBAAIwC,cAAc3C;YAAgB;SAAE;QACnF4C,aAAa;YAACb,WAAWhC,oCAAoCa;SAA8B;QAC3FiC,0BAA0B;YAACnC;SAAoC;IACjE;AACF"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n AUTH_PASSWORD_RESET_SEND_REQUESTED,\n type AuthEventMap,\n authEventSchemas,\n} from '@shipfox/api-auth-dto';\nimport type {ShipfoxModule} from '@shipfox/node-module';\nimport {subscriberFactory} from '@shipfox/node-module';\nimport {config} from '#config.js';\nimport {db} from '#db/db.js';\nimport {migrationsPath} from '#db/migrations.js';\nimport {authOutbox} from '#db/schema/outbox.js';\nimport {createJwtAuthMethod} from '#presentation/auth/jwt-auth.js';\nimport {createLeaseTokenAuthMethod} from '#presentation/auth/lease-token-auth.js';\nimport {createRunnerSessionAuthMethod} from '#presentation/auth/runner-session-auth.js';\nimport {createAuthE2eRoutes} from '#presentation/e2eRoutes/index.js';\nimport {createAuthInterModulePresentation} from '#presentation/inter-module.js';\nimport {buildAuthRoutes} from '#presentation/routes/index.js';\nimport {onPasswordResetSendRequested} from '#presentation/subscribers/index.js';\nimport {passwordLoginMethods} from './login-methods.js';\n\nexport type {JobLeaseTokenClaims, RunnerSessionTokenClaims} from '@shipfox/api-auth-dto';\nexport type {\n CreateSessionForUserError,\n CreateSessionForUserParams,\n CreateSessionForUserResult,\n ProvisionUserParams,\n} from '#core/auth.js';\nexport {createSessionForUser, provisionUser} from '#core/auth.js';\nexport type {EmailOwner, FindUserByEmailParams} from '#core/email-owner.js';\nexport {findUserByEmail} from '#core/email-owner.js';\nexport type {User, UserStatus} from '#core/entities/user.js';\nexport {\n AuthDependencyUnavailableError,\n EmailNotVerifiedError,\n InvalidCredentialsError,\n UserNotFoundError,\n} from '#core/errors.js';\nexport {\n issueJobLeaseToken,\n jobLeaseParamsFrom,\n verifyJobLeaseToken,\n} from '#core/job-lease-token.js';\nexport {\n issueRunnerSessionToken,\n verifyRunnerSessionToken,\n} from '#core/runner-session-token.js';\nexport {\n type AuthenticatedSessionContext,\n createJwtAuthMethod,\n getAuthenticatedSessionContext,\n type RefreshSessionId,\n type UserId,\n} from '#presentation/auth/jwt-auth.js';\nexport {createLeaseTokenAuthMethod} from '#presentation/auth/lease-token-auth.js';\nexport {\n authCookiePlugin,\n clearRefreshTokenCookie,\n getRefreshTokenCookie,\n setRefreshTokenCookie,\n} from '#presentation/auth/refresh-cookie.js';\nexport {createRunnerSessionAuthMethod} from '#presentation/auth/runner-session-auth.js';\n\nconst subscriber = subscriberFactory<AuthEventMap>();\n\nexport function createAuthModule({\n workspaces,\n}: {\n workspaces: import('@shipfox/api-workspaces-dto/inter-module').WorkspacesInterModuleClient;\n}): ShipfoxModule {\n return {\n name: 'auth',\n database: {db, migrationsPath, databaseNamespace: 'auth'},\n auth: [createJwtAuthMethod(), createLeaseTokenAuthMethod(), createRunnerSessionAuthMethod()],\n loginMethods: passwordLoginMethods(config.AUTH_PASSWORD_ENABLED),\n routes: [buildAuthRoutes(config.AUTH_PASSWORD_ENABLED, workspaces)],\n e2eRoutes: [createAuthE2eRoutes(workspaces)],\n publishers: [{name: 'auth', table: authOutbox, db, eventSchemas: authEventSchemas}],\n subscribers: [subscriber(AUTH_PASSWORD_RESET_SEND_REQUESTED, onPasswordResetSendRequested)],\n interModulePresentations: [createAuthInterModulePresentation()],\n };\n}\n"],"names":["AUTH_PASSWORD_RESET_SEND_REQUESTED","authEventSchemas","subscriberFactory","config","db","migrationsPath","authOutbox","createJwtAuthMethod","createLeaseTokenAuthMethod","createRunnerSessionAuthMethod","createAuthE2eRoutes","createAuthInterModulePresentation","buildAuthRoutes","onPasswordResetSendRequested","passwordLoginMethods","createSessionForUser","provisionUser","findUserByEmail","AuthDependencyUnavailableError","EmailNotVerifiedError","InvalidCredentialsError","UserNotFoundError","issueJobLeaseToken","jobLeaseParamsFrom","verifyJobLeaseToken","issueRunnerSessionToken","verifyRunnerSessionToken","getAuthenticatedSessionContext","authCookiePlugin","clearRefreshTokenCookie","getRefreshTokenCookie","setRefreshTokenCookie","subscriber","createAuthModule","workspaces","name","database","databaseNamespace","auth","loginMethods","AUTH_PASSWORD_ENABLED","routes","e2eRoutes","publishers","table","eventSchemas","subscribers","interModulePresentations"],"mappings":"AAAA,SACEA,kCAAkC,EAElCC,gBAAgB,QACX,wBAAwB;AAE/B,SAAQC,iBAAiB,QAAO,uBAAuB;AACvD,SAAQC,MAAM,QAAO,aAAa;AAClC,SAAQC,EAAE,QAAO,YAAY;AAC7B,SAAQC,cAAc,QAAO,oBAAoB;AACjD,SAAQC,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