This is crucial to ensure that any driver (better-auth, Auth0, etc.) implementing this spec provides a consistent API experience for frontend clients.
Please perform the following tasks:
-
Create Constants File (packages/spec/src/system/authentication-constants.ts):
- Define and export an
AUTH_CONSTANTS object.
- It must include standard keys for API communication:
HEADER_KEY: Set to 'Authorization'.
TOKEN_PREFIX: Set to 'Bearer '.
COOKIE_PREFIX: Set to 'os_' (for consistent cookie namespacing).
CSRF_HEADER: Set to 'x-os-csrf-token'.
-
Create Types File (packages/spec/src/system/authentication-types.ts):
- Define
interface StandardUser: This represents the normalized user object that all drivers must return.
- Required fields:
id, email, emailVerified (boolean), createdAt, updatedAt.
- Optional fields:
name, image.
- Allow index signature
[key: string]: any for driver-specific extensions.
- Define
interface StandardSession:
- Required fields:
id, userId, expiresAt, token.
- Optional fields:
ipAddress, userAgent.
-
Update Exports (packages/spec/src/index.ts):
- Export everything from the new
authentication-constants.ts and authentication-types.ts files.
-
Update Documentation (docs/AUTHENTICATION.md):
- Add a new section titled "API & Wire Protocol".
- Document that all implementations MUST accept the standard Bearer token header.
- Document the
StandardUser interface, explaining that plugins/drivers must map their internal user representation to this standard interface.
-
Refinement:
- Ensure the naming consistency with the existing
authentication.zod.ts.
This is crucial to ensure that any driver (better-auth, Auth0, etc.) implementing this spec provides a consistent API experience for frontend clients.
Please perform the following tasks:
Create Constants File (
packages/spec/src/system/authentication-constants.ts):AUTH_CONSTANTSobject.HEADER_KEY: Set to'Authorization'.TOKEN_PREFIX: Set to'Bearer '.COOKIE_PREFIX: Set to'os_'(for consistent cookie namespacing).CSRF_HEADER: Set to'x-os-csrf-token'.Create Types File (
packages/spec/src/system/authentication-types.ts):interface StandardUser: This represents the normalized user object that all drivers must return.id,email,emailVerified(boolean),createdAt,updatedAt.name,image.[key: string]: anyfor driver-specific extensions.interface StandardSession:id,userId,expiresAt,token.ipAddress,userAgent.Update Exports (
packages/spec/src/index.ts):authentication-constants.tsandauthentication-types.tsfiles.Update Documentation (
docs/AUTHENTICATION.md):StandardUserinterface, explaining that plugins/drivers must map their internal user representation to this standard interface.Refinement:
authentication.zod.ts.