@azlib/identity 0.2.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/LICENSE +201 -0
- package/README.md +387 -0
- package/dist/errors-BGMwaW5s.d.mts +481 -0
- package/dist/errors-BGMwaW5s.d.mts.map +1 -0
- package/dist/errors-Bcjx9o6g.cjs +111 -0
- package/dist/errors-C2xZAatu.d.cts +481 -0
- package/dist/errors-C2xZAatu.d.cts.map +1 -0
- package/dist/errors-CEmnZxIn.mjs +66 -0
- package/dist/errors-CEmnZxIn.mjs.map +1 -0
- package/dist/express.cjs +405 -0
- package/dist/express.d.cts +87 -0
- package/dist/express.d.cts.map +1 -0
- package/dist/express.d.mts +87 -0
- package/dist/express.d.mts.map +1 -0
- package/dist/express.mjs +401 -0
- package/dist/express.mjs.map +1 -0
- package/dist/identity-4eP45YIP.cjs +461 -0
- package/dist/identity-Bz9RDOvT.mjs +410 -0
- package/dist/identity-Bz9RDOvT.mjs.map +1 -0
- package/dist/identity-router-DBL20UWT.d.mts +115 -0
- package/dist/identity-router-DBL20UWT.d.mts.map +1 -0
- package/dist/identity-router-Dib30Waj.d.cts +115 -0
- package/dist/identity-router-Dib30Waj.d.cts.map +1 -0
- package/dist/identity-service-B9zrvE9z.d.mts +128 -0
- package/dist/identity-service-B9zrvE9z.d.mts.map +1 -0
- package/dist/identity-service-CLzKx8Z7.d.cts +128 -0
- package/dist/identity-service-CLzKx8Z7.d.cts.map +1 -0
- package/dist/identity-store-BRRahxcS.d.cts +272 -0
- package/dist/identity-store-BRRahxcS.d.cts.map +1 -0
- package/dist/identity-store-BRRahxcS.d.mts +272 -0
- package/dist/identity-store-BRRahxcS.d.mts.map +1 -0
- package/dist/index-CpufYgyn.d.cts +30 -0
- package/dist/index-CpufYgyn.d.cts.map +1 -0
- package/dist/index-CpufYgyn.d.mts +30 -0
- package/dist/index-CpufYgyn.d.mts.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +3 -0
- package/dist/logger-Be1wDzBC.cjs +48 -0
- package/dist/logger-CcCHJVVe.mjs +33 -0
- package/dist/logger-CcCHJVVe.mjs.map +1 -0
- package/dist/nestjs.cjs +516 -0
- package/dist/nestjs.d.cts +102 -0
- package/dist/nestjs.d.cts.map +1 -0
- package/dist/nestjs.d.mts +102 -0
- package/dist/nestjs.d.mts.map +1 -0
- package/dist/nestjs.mjs +500 -0
- package/dist/nestjs.mjs.map +1 -0
- package/dist/node.cjs +946 -0
- package/dist/node.d.cts +260 -0
- package/dist/node.d.cts.map +1 -0
- package/dist/node.d.mts +260 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +890 -0
- package/dist/node.mjs.map +1 -0
- package/dist/test-utils.cjs +169 -0
- package/dist/test-utils.d.cts +12 -0
- package/dist/test-utils.d.cts.map +1 -0
- package/dist/test-utils.d.mts +12 -0
- package/dist/test-utils.d.mts.map +1 -0
- package/dist/test-utils.mjs +170 -0
- package/dist/test-utils.mjs.map +1 -0
- package/package.json +92 -0
- package/schema/model.ts +100 -0
- package/schema/mysql.sql +102 -0
- package/schema/postgres.sql +92 -0
- package/schema/prisma.schema +122 -0
- package/schema/sqlite.sql +92 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
//#region core/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Shared, framework-agnostic domain types for `@azlib/identity`.
|
|
4
|
+
*
|
|
5
|
+
* These types describe the persistence model and the runtime principal. They do not
|
|
6
|
+
* depend on Node, Express, or NestJS so they can be imported from any surface.
|
|
7
|
+
*/
|
|
8
|
+
/** Lifecycle status for an identity user. */
|
|
9
|
+
type IdentityUserStatus = "active" | "disabled" | "locked";
|
|
10
|
+
/** A persisted identity user record. */
|
|
11
|
+
interface IdentityUser {
|
|
12
|
+
userId: string;
|
|
13
|
+
email: string;
|
|
14
|
+
displayName: string | null;
|
|
15
|
+
status: IdentityUserStatus;
|
|
16
|
+
emailVerifiedAt: Date | null;
|
|
17
|
+
/**
|
|
18
|
+
* Whether TOTP-based two-factor authentication is currently active for this account.
|
|
19
|
+
*/
|
|
20
|
+
twoFactorEnabled: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Incremented to invalidate previously issued access/refresh tokens (for example on
|
|
23
|
+
* password change or forced logout). Tokens carry this value and are rejected on mismatch.
|
|
24
|
+
*/
|
|
25
|
+
authVersion: number;
|
|
26
|
+
/**
|
|
27
|
+
* Consecutive failed login attempts since the last successful login. Reset to 0 on success.
|
|
28
|
+
* Used by the account lockout feature.
|
|
29
|
+
*/
|
|
30
|
+
failedLoginAttempts: number;
|
|
31
|
+
/**
|
|
32
|
+
* When set, the account is temporarily locked until this time. The lockout feature sets
|
|
33
|
+
* this after the configured `maxFailedAttempts` threshold is exceeded.
|
|
34
|
+
*/
|
|
35
|
+
lockedUntil: Date | null;
|
|
36
|
+
createdAt: Date;
|
|
37
|
+
updatedAt: Date;
|
|
38
|
+
}
|
|
39
|
+
/** Stored password credential for a user. The plaintext password is never persisted. */
|
|
40
|
+
interface CredentialRecord {
|
|
41
|
+
userId: string;
|
|
42
|
+
/** Opaque, algorithm-tagged password hash. */
|
|
43
|
+
passwordHash: string;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A server-side refresh session. The raw refresh token is returned to the client once;
|
|
48
|
+
* only its hash is stored so a database leak does not expose usable tokens.
|
|
49
|
+
*/
|
|
50
|
+
interface AuthSession {
|
|
51
|
+
sessionId: string;
|
|
52
|
+
userId: string;
|
|
53
|
+
/** Hash of the current refresh token. Rotated on every refresh. */
|
|
54
|
+
refreshTokenHash: string;
|
|
55
|
+
createdAt: Date;
|
|
56
|
+
expiresAt: Date;
|
|
57
|
+
/** Set when the session has been rotated or revoked; such sessions are unusable. */
|
|
58
|
+
revokedAt: Date | null;
|
|
59
|
+
}
|
|
60
|
+
/** A coarse permission string, e.g. `documents:read`. */
|
|
61
|
+
type Permission = string;
|
|
62
|
+
/** A role groups permissions for assignment to users. */
|
|
63
|
+
interface Role {
|
|
64
|
+
roleId: string;
|
|
65
|
+
name: string;
|
|
66
|
+
description: string | null;
|
|
67
|
+
}
|
|
68
|
+
/** Assignment of a role to a user. */
|
|
69
|
+
interface UserRoleAssignment {
|
|
70
|
+
userId: string;
|
|
71
|
+
roleId: string;
|
|
72
|
+
}
|
|
73
|
+
/** Grant of a permission to a role. */
|
|
74
|
+
interface RolePermissionGrant {
|
|
75
|
+
roleId: string;
|
|
76
|
+
permission: Permission;
|
|
77
|
+
}
|
|
78
|
+
/** Direct grant of a permission to a user, bypassing roles. */
|
|
79
|
+
interface DirectPermissionGrant {
|
|
80
|
+
userId: string;
|
|
81
|
+
permission: Permission;
|
|
82
|
+
}
|
|
83
|
+
/** Names of the supported identity event types for auditing. */
|
|
84
|
+
type IdentityEventType = "user.registered" | "user.login.succeeded" | "user.login.failed" | "user.login.mfa.challenged" | "user.account.locked" | "user.account.unlocked" | "user.email.verification.requested" | "user.email.verified" | "user.password.reset.requested" | "user.password.reset.completed" | "user.2fa.setup.started" | "user.2fa.enabled" | "user.2fa.disabled" | "user.oauth.linked" | "session.refreshed" | "session.revoked" | "authorization.denied";
|
|
85
|
+
/** A linked OAuth / OIDC identity from an external provider (Google, Microsoft, etc.). */
|
|
86
|
+
interface OAuthLinkedAccount {
|
|
87
|
+
userId: string;
|
|
88
|
+
/** Provider identifier, e.g. `"google"` or `"microsoft"`. */
|
|
89
|
+
provider: string;
|
|
90
|
+
/** The user's stable id on the provider side (`sub` claim). */
|
|
91
|
+
providerUserId: string;
|
|
92
|
+
email: string | null;
|
|
93
|
+
displayName: string | null;
|
|
94
|
+
linkedAt: Date;
|
|
95
|
+
}
|
|
96
|
+
/** An audit event emitted by identity flows. */
|
|
97
|
+
interface IdentityEvent {
|
|
98
|
+
type: IdentityEventType;
|
|
99
|
+
userId: string | null;
|
|
100
|
+
/** Free-form, non-sensitive metadata. Never include passwords or raw tokens. */
|
|
101
|
+
metadata: Record<string, string | number | boolean | null>;
|
|
102
|
+
occurredAt: Date;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The authenticated principal hydrated from the store after a token is verified.
|
|
106
|
+
* Attached to the request by the Express middleware / NestJS guard.
|
|
107
|
+
*/
|
|
108
|
+
interface AuthenticatedIdentity {
|
|
109
|
+
userId: string;
|
|
110
|
+
email: string;
|
|
111
|
+
displayName: string | null;
|
|
112
|
+
status: IdentityUserStatus;
|
|
113
|
+
emailVerified: boolean;
|
|
114
|
+
roles: readonly string[];
|
|
115
|
+
permissions: readonly Permission[];
|
|
116
|
+
}
|
|
117
|
+
/** A successful authentication result containing tokens and the principal. */
|
|
118
|
+
interface AuthTokens {
|
|
119
|
+
accessToken: string;
|
|
120
|
+
refreshToken: string;
|
|
121
|
+
accessTokenExpiresAt: Date;
|
|
122
|
+
refreshTokenExpiresAt: Date;
|
|
123
|
+
}
|
|
124
|
+
/** Result returned by register/login flows. */
|
|
125
|
+
interface AuthResult {
|
|
126
|
+
user: AuthenticatedIdentity;
|
|
127
|
+
tokens: AuthTokens;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Returned by `login` when the user has 2FA enabled and the TOTP code has not yet
|
|
131
|
+
* been verified. The client must call `verifyMfaChallenge` to complete the login.
|
|
132
|
+
*/
|
|
133
|
+
interface MfaRequiredResult {
|
|
134
|
+
kind: "mfa_required";
|
|
135
|
+
/** Short-lived signed token identifying the pending MFA session. */
|
|
136
|
+
mfaToken: string;
|
|
137
|
+
}
|
|
138
|
+
/** Union return type for the login flow — either a full session or an MFA challenge. */
|
|
139
|
+
type LoginResult = AuthResult | MfaRequiredResult;
|
|
140
|
+
/** Token type for email verification or password reset links. */
|
|
141
|
+
type VerificationTokenType = "email_verification" | "password_reset";
|
|
142
|
+
/** A short-lived opaque token stored by hash, used for email verification and password reset. */
|
|
143
|
+
interface VerificationToken {
|
|
144
|
+
/** SHA-256 hash of the raw token (stored; raw token is sent to the user). */
|
|
145
|
+
tokenHash: string;
|
|
146
|
+
userId: string;
|
|
147
|
+
type: VerificationTokenType;
|
|
148
|
+
expiresAt: Date;
|
|
149
|
+
/** Set when the token has been consumed; consumed tokens cannot be reused. */
|
|
150
|
+
usedAt: Date | null;
|
|
151
|
+
}
|
|
152
|
+
/** Persisted TOTP secret for a user. */
|
|
153
|
+
interface TotpSecret {
|
|
154
|
+
userId: string;
|
|
155
|
+
/** Base32-encoded TOTP secret key. */
|
|
156
|
+
secretBase32: string;
|
|
157
|
+
/** Set once the user has confirmed the TOTP code after setup. */
|
|
158
|
+
enabledAt: Date | null;
|
|
159
|
+
createdAt: Date;
|
|
160
|
+
}
|
|
161
|
+
/** Returned by the 2FA setup flow. Display the QR code / secret to the user. */
|
|
162
|
+
interface TotpSetupResult {
|
|
163
|
+
/** Base32-encoded secret to show to the user (or encode as a QR code). */
|
|
164
|
+
secret: string;
|
|
165
|
+
/** OTP Auth URI suitable for QR code display in authenticator apps. */
|
|
166
|
+
otpAuthUri: string;
|
|
167
|
+
}
|
|
168
|
+
/** Verified access-token claims. */
|
|
169
|
+
interface AccessTokenClaims {
|
|
170
|
+
/** Subject — the user id. */
|
|
171
|
+
sub: string;
|
|
172
|
+
/** Auth version the token was minted against. */
|
|
173
|
+
authVersion: number;
|
|
174
|
+
/** Issued-at (seconds since epoch). */
|
|
175
|
+
iat: number;
|
|
176
|
+
/** Expiry (seconds since epoch). */
|
|
177
|
+
exp: number;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region core/verification-token.d.ts
|
|
181
|
+
/** Input for persisting a new verification token. */
|
|
182
|
+
interface CreateVerificationTokenInput {
|
|
183
|
+
/** SHA-256 hash of the raw token (never store the raw token). */
|
|
184
|
+
tokenHash: string;
|
|
185
|
+
userId: string;
|
|
186
|
+
type: VerificationTokenType;
|
|
187
|
+
expiresAt: Date;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Generates a cryptographically random opaque token and its SHA-256 hash.
|
|
191
|
+
* Returns both: the raw token is sent to the user; only the hash is persisted.
|
|
192
|
+
*/
|
|
193
|
+
declare function generateVerificationToken(): {
|
|
194
|
+
token: string;
|
|
195
|
+
tokenHash: string;
|
|
196
|
+
};
|
|
197
|
+
/** Hashes a token presented by the user for secure lookup against stored hashes. */
|
|
198
|
+
declare function hashVerificationToken(token: string): string;
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region core/identity-store.d.ts
|
|
201
|
+
/** Fields required to create a new user (ids/timestamps are assigned by the service). */
|
|
202
|
+
interface CreateIdentityUserInput {
|
|
203
|
+
userId: string;
|
|
204
|
+
email: string;
|
|
205
|
+
displayName: string | null;
|
|
206
|
+
status: IdentityUser["status"];
|
|
207
|
+
authVersion: number;
|
|
208
|
+
createdAt: Date;
|
|
209
|
+
updatedAt: Date;
|
|
210
|
+
}
|
|
211
|
+
/** Fields required to create a new refresh session. */
|
|
212
|
+
interface CreateAuthSessionInput {
|
|
213
|
+
sessionId: string;
|
|
214
|
+
userId: string;
|
|
215
|
+
refreshTokenHash: string;
|
|
216
|
+
createdAt: Date;
|
|
217
|
+
expiresAt: Date;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Storage contract for `@azlib/identity`. Implement this against your own database
|
|
221
|
+
* engine (Postgres, MySQL, SQLite, Prisma, etc.). The package ships predefined schema
|
|
222
|
+
* artifacts under `@azlib/identity/schema/*` you can apply directly.
|
|
223
|
+
*
|
|
224
|
+
* Implementations must treat email lookups as case-insensitive and enforce uniqueness
|
|
225
|
+
* on email. All methods may be async.
|
|
226
|
+
*/
|
|
227
|
+
interface IdentityStore {
|
|
228
|
+
findUserByEmail(email: string): Promise<IdentityUser | null>;
|
|
229
|
+
findUserById(userId: string): Promise<IdentityUser | null>;
|
|
230
|
+
createUser(input: CreateIdentityUserInput): Promise<IdentityUser>;
|
|
231
|
+
updateUser(userId: string, patch: Partial<Pick<IdentityUser, "displayName" | "status" | "emailVerifiedAt" | "twoFactorEnabled" | "authVersion" | "failedLoginAttempts" | "lockedUntil">>): Promise<IdentityUser>;
|
|
232
|
+
findCredential(userId: string): Promise<CredentialRecord | null>;
|
|
233
|
+
upsertCredential(record: CredentialRecord): Promise<void>;
|
|
234
|
+
createSession(input: CreateAuthSessionInput): Promise<AuthSession>;
|
|
235
|
+
findSessionById(sessionId: string): Promise<AuthSession | null>;
|
|
236
|
+
/** Marks a session revoked (used during rotation and logout). */
|
|
237
|
+
revokeSession(sessionId: string, revokedAt: Date): Promise<void>;
|
|
238
|
+
/** Replaces the stored refresh-token hash for a session during rotation. */
|
|
239
|
+
rotateSession(sessionId: string, refreshTokenHash: string, expiresAt: Date): Promise<void>;
|
|
240
|
+
/** Revokes every active session for a user (e.g. password change / global logout). */
|
|
241
|
+
revokeAllSessions(userId: string, revokedAt: Date): Promise<void>;
|
|
242
|
+
listRolesForUser(userId: string): Promise<readonly Role[]>;
|
|
243
|
+
listPermissionsForUser(userId: string): Promise<readonly Permission[]>;
|
|
244
|
+
assignRole(assignment: UserRoleAssignment): Promise<void>;
|
|
245
|
+
grantRolePermission(grant: RolePermissionGrant): Promise<void>;
|
|
246
|
+
grantDirectPermission(grant: DirectPermissionGrant): Promise<void>;
|
|
247
|
+
/** Persists a new short-lived verification/reset token (stored as hash). */
|
|
248
|
+
createVerificationToken?(input: CreateVerificationTokenInput): Promise<void>;
|
|
249
|
+
/** Looks up a stored token by its SHA-256 hash. */
|
|
250
|
+
findVerificationToken?(tokenHash: string): Promise<VerificationToken | null>;
|
|
251
|
+
/** Marks a token as consumed so it cannot be reused. */
|
|
252
|
+
markVerificationTokenUsed?(tokenHash: string, usedAt: Date): Promise<void>;
|
|
253
|
+
/** Returns the pending or active TOTP secret for a user, or null if none. */
|
|
254
|
+
findTotpSecret?(userId: string): Promise<TotpSecret | null>;
|
|
255
|
+
/** Creates or replaces the TOTP secret for a user. */
|
|
256
|
+
upsertTotpSecret?(record: TotpSecret): Promise<void>;
|
|
257
|
+
/** Removes the TOTP secret, effectively disabling 2FA at the storage layer. */
|
|
258
|
+
deleteTotpSecret?(userId: string): Promise<void>;
|
|
259
|
+
recordEvent?(event: IdentityEvent): Promise<void>;
|
|
260
|
+
/**
|
|
261
|
+
* Finds the local user linked to a provider + provider user id. Returns null when
|
|
262
|
+
* no OAuth link exists yet.
|
|
263
|
+
*/
|
|
264
|
+
findUserByOAuthId?(provider: string, providerUserId: string): Promise<IdentityUser | null>;
|
|
265
|
+
/** Persists a new OAuth link between a local user and their provider identity. */
|
|
266
|
+
createOAuthLink?(link: OAuthLinkedAccount): Promise<void>;
|
|
267
|
+
/** Lists all provider links for a user. */
|
|
268
|
+
listOAuthLinks?(userId: string): Promise<readonly OAuthLinkedAccount[]>;
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
export { RolePermissionGrant as C, VerificationToken as D, UserRoleAssignment as E, VerificationTokenType as O, Role as S, TotpSetupResult as T, IdentityUserStatus as _, generateVerificationToken as a, OAuthLinkedAccount as b, AuthResult as c, AuthenticatedIdentity as d, CredentialRecord as f, IdentityUser as g, IdentityEventType as h, CreateVerificationTokenInput as i, AuthSession as l, IdentityEvent as m, CreateIdentityUserInput as n, hashVerificationToken as o, DirectPermissionGrant as p, IdentityStore as r, AccessTokenClaims as s, CreateAuthSessionInput as t, AuthTokens as u, LoginResult as v, TotpSecret as w, Permission as x, MfaRequiredResult as y };
|
|
272
|
+
//# sourceMappingURL=identity-store-BRRahxcS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-store-BRRahxcS.d.mts","names":[],"sources":["../core/types.ts","../core/verification-token.ts","../core/identity-store.ts"],"mappings":";;AAQA;;;;AAA8B;AAG9B;AAAA,KAHY,kBAAA;;UAGK,YAAA;EACf,MAAA;EACA,KAAA;EACA,WAAA;EACA,MAAA,EAAQ,kBAAA;EACR,eAAA,EAAiB,IAAA;EAqBF;;;EAjBf,gBAAA;EALA;;;;EAUA,WAAA;EAAA;;;;E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AA;AAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region schema/model.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Logical description of the relational schema `@azlib/identity` expects.
|
|
4
|
+
*
|
|
5
|
+
* Concrete DDL is shipped alongside this module:
|
|
6
|
+
* - `@azlib/identity/schema/postgres.sql`
|
|
7
|
+
* - `@azlib/identity/schema/mysql.sql`
|
|
8
|
+
* - `@azlib/identity/schema/sqlite.sql`
|
|
9
|
+
* - `@azlib/identity/schema/prisma.schema`
|
|
10
|
+
*
|
|
11
|
+
* This object is documentation-as-data so consumers and tooling can introspect the
|
|
12
|
+
* expected tables without parsing SQL.
|
|
13
|
+
*/
|
|
14
|
+
interface SchemaColumn {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
nullable: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface SchemaTable {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
columns: readonly SchemaColumn[];
|
|
23
|
+
}
|
|
24
|
+
interface SchemaModel {
|
|
25
|
+
tables: readonly SchemaTable[];
|
|
26
|
+
}
|
|
27
|
+
declare const identitySchemaModel: SchemaModel;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { identitySchemaModel as t };
|
|
30
|
+
//# sourceMappingURL=index-CpufYgyn.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CpufYgyn.d.cts","names":[],"sources":["../schema/model.ts"],"mappings":";;AAYA;;;;;;;;AAGU;AAGV;;UANiB,YAAA;EACf,IAAA;EACA,WAAA;EACA,QAAA;AAAA;AAAA,UAGe,WAAA;EACf,IAAA;EACA,WAAA;EACA,OAAA,WAAkB,YAAY;AAAA;AAAA,UAGf,WAAA;EACf,MAAA,WAAiB,WAAW;AAAA;AAAA,cAGjB,mBAAA,EAAqB,WAuEjC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region schema/model.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Logical description of the relational schema `@azlib/identity` expects.
|
|
4
|
+
*
|
|
5
|
+
* Concrete DDL is shipped alongside this module:
|
|
6
|
+
* - `@azlib/identity/schema/postgres.sql`
|
|
7
|
+
* - `@azlib/identity/schema/mysql.sql`
|
|
8
|
+
* - `@azlib/identity/schema/sqlite.sql`
|
|
9
|
+
* - `@azlib/identity/schema/prisma.schema`
|
|
10
|
+
*
|
|
11
|
+
* This object is documentation-as-data so consumers and tooling can introspect the
|
|
12
|
+
* expected tables without parsing SQL.
|
|
13
|
+
*/
|
|
14
|
+
interface SchemaColumn {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
nullable: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface SchemaTable {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
columns: readonly SchemaColumn[];
|
|
23
|
+
}
|
|
24
|
+
interface SchemaModel {
|
|
25
|
+
tables: readonly SchemaTable[];
|
|
26
|
+
}
|
|
27
|
+
declare const identitySchemaModel: SchemaModel;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { identitySchemaModel as t };
|
|
30
|
+
//# sourceMappingURL=index-CpufYgyn.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CpufYgyn.d.mts","names":[],"sources":["../schema/model.ts"],"mappings":";;AAYA;;;;;;;;AAGU;AAGV;;UANiB,YAAA;EACf,IAAA;EACA,WAAA;EACA,QAAA;AAAA;AAAA,UAGe,WAAA;EACf,IAAA;EACA,WAAA;EACA,OAAA,WAAkB,YAAY;AAAA;AAAA,UAGf,WAAA;EACf,MAAA,WAAiB,WAAW;AAAA;AAAA,cAGjB,mBAAA,EAAqB,WAuEjC"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_errors = require("./errors-Bcjx9o6g.cjs");
|
|
3
|
+
const require_identity = require("./identity-4eP45YIP.cjs");
|
|
4
|
+
exports.AccountUnavailableError = require_errors.AccountUnavailableError;
|
|
5
|
+
exports.EmailAlreadyRegisteredError = require_errors.EmailAlreadyRegisteredError;
|
|
6
|
+
exports.ForbiddenError = require_errors.ForbiddenError;
|
|
7
|
+
exports.IdentityConfigError = require_errors.IdentityConfigError;
|
|
8
|
+
exports.IdentityError = require_errors.IdentityError;
|
|
9
|
+
exports.InvalidCredentialsError = require_errors.InvalidCredentialsError;
|
|
10
|
+
exports.InvalidTokenError = require_errors.InvalidTokenError;
|
|
11
|
+
exports.OAuthProviderNotFoundError = require_identity.OAuthProviderNotFoundError;
|
|
12
|
+
exports.OAuthStateMismatchError = require_identity.OAuthStateMismatchError;
|
|
13
|
+
exports.UnauthenticatedError = require_errors.UnauthenticatedError;
|
|
14
|
+
exports.createOAuthService = require_identity.createOAuthService;
|
|
15
|
+
exports.evaluateAuthorization = require_identity.evaluateAuthorization;
|
|
16
|
+
exports.identitySchemaModel = require_identity.identitySchemaModel;
|
|
17
|
+
exports.isAuthorized = require_identity.isAuthorized;
|
|
18
|
+
exports.resolveIdentityConfig = require_identity.resolveIdentityConfig;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { C as RolePermissionGrant, D as VerificationToken, E as UserRoleAssignment, O as VerificationTokenType, S as Role, T as TotpSetupResult, _ as IdentityUserStatus, b as OAuthLinkedAccount, c as AuthResult, d as AuthenticatedIdentity, f as CredentialRecord, g as IdentityUser, h as IdentityEventType, l as AuthSession, m as IdentityEvent, n as CreateIdentityUserInput, p as DirectPermissionGrant, r as IdentityStore, s as AccessTokenClaims, t as CreateAuthSessionInput, u as AuthTokens, v as LoginResult, w as TotpSecret, x as Permission, y as MfaRequiredResult } from "./identity-store-BRRahxcS.cjs";
|
|
2
|
+
import { A as resolveIdentityConfig, B as AuthorizationDecision, D as IdentityConfigInput, E as IdentityConfig, H as PolicyRule, O as IdentityOverrides, U as evaluateAuthorization, V as AuthorizationRequirement, W as isAuthorized, _ as ExchangeCodeParams, a as IdentityError, b as OAuthUserInfo, c as UnauthenticatedError, d as OAuthProviderNotFoundError, f as OAuthService, g as BuildAuthUrlParams, h as createOAuthService, i as IdentityConfigError, k as LockoutConfig, l as OAuthAuthorizationUrl, m as OAuthStateMismatchError, n as EmailAlreadyRegisteredError, o as InvalidCredentialsError, p as OAuthServiceDeps, r as ForbiddenError, s as InvalidTokenError, t as AccountUnavailableError, u as OAuthCallbackParams, v as OAuthProvider, y as OAuthTokens, z as AuthorizationContext } from "./errors-C2xZAatu.cjs";
|
|
3
|
+
import { t as identitySchemaModel } from "./index-CpufYgyn.cjs";
|
|
4
|
+
export { AccessTokenClaims, AccountUnavailableError, AuthResult, AuthSession, AuthTokens, AuthenticatedIdentity, AuthorizationContext, AuthorizationDecision, AuthorizationRequirement, BuildAuthUrlParams, CreateAuthSessionInput, CreateIdentityUserInput, CredentialRecord, DirectPermissionGrant, EmailAlreadyRegisteredError, ExchangeCodeParams, ForbiddenError, IdentityConfig, IdentityConfigError, IdentityConfigInput, IdentityError, IdentityEvent, IdentityEventType, IdentityOverrides, IdentityStore, IdentityUser, IdentityUserStatus, InvalidCredentialsError, InvalidTokenError, LockoutConfig, LoginResult, MfaRequiredResult, OAuthAuthorizationUrl, OAuthCallbackParams, OAuthLinkedAccount, OAuthProvider, OAuthProviderNotFoundError, OAuthService, OAuthServiceDeps, OAuthStateMismatchError, OAuthTokens, OAuthUserInfo, Permission, PolicyRule, Role, RolePermissionGrant, TotpSecret, TotpSetupResult, UnauthenticatedError, UserRoleAssignment, VerificationToken, VerificationTokenType, createOAuthService, evaluateAuthorization, identitySchemaModel, isAuthorized, resolveIdentityConfig };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { C as RolePermissionGrant, D as VerificationToken, E as UserRoleAssignment, O as VerificationTokenType, S as Role, T as TotpSetupResult, _ as IdentityUserStatus, b as OAuthLinkedAccount, c as AuthResult, d as AuthenticatedIdentity, f as CredentialRecord, g as IdentityUser, h as IdentityEventType, l as AuthSession, m as IdentityEvent, n as CreateIdentityUserInput, p as DirectPermissionGrant, r as IdentityStore, s as AccessTokenClaims, t as CreateAuthSessionInput, u as AuthTokens, v as LoginResult, w as TotpSecret, x as Permission, y as MfaRequiredResult } from "./identity-store-BRRahxcS.mjs";
|
|
2
|
+
import { A as resolveIdentityConfig, B as AuthorizationDecision, D as IdentityConfigInput, E as IdentityConfig, H as PolicyRule, O as IdentityOverrides, U as evaluateAuthorization, V as AuthorizationRequirement, W as isAuthorized, _ as ExchangeCodeParams, a as IdentityError, b as OAuthUserInfo, c as UnauthenticatedError, d as OAuthProviderNotFoundError, f as OAuthService, g as BuildAuthUrlParams, h as createOAuthService, i as IdentityConfigError, k as LockoutConfig, l as OAuthAuthorizationUrl, m as OAuthStateMismatchError, n as EmailAlreadyRegisteredError, o as InvalidCredentialsError, p as OAuthServiceDeps, r as ForbiddenError, s as InvalidTokenError, t as AccountUnavailableError, u as OAuthCallbackParams, v as OAuthProvider, y as OAuthTokens, z as AuthorizationContext } from "./errors-BGMwaW5s.mjs";
|
|
3
|
+
import { t as identitySchemaModel } from "./index-CpufYgyn.mjs";
|
|
4
|
+
export { AccessTokenClaims, AccountUnavailableError, AuthResult, AuthSession, AuthTokens, AuthenticatedIdentity, AuthorizationContext, AuthorizationDecision, AuthorizationRequirement, BuildAuthUrlParams, CreateAuthSessionInput, CreateIdentityUserInput, CredentialRecord, DirectPermissionGrant, EmailAlreadyRegisteredError, ExchangeCodeParams, ForbiddenError, IdentityConfig, IdentityConfigError, IdentityConfigInput, IdentityError, IdentityEvent, IdentityEventType, IdentityOverrides, IdentityStore, IdentityUser, IdentityUserStatus, InvalidCredentialsError, InvalidTokenError, LockoutConfig, LoginResult, MfaRequiredResult, OAuthAuthorizationUrl, OAuthCallbackParams, OAuthLinkedAccount, OAuthProvider, OAuthProviderNotFoundError, OAuthService, OAuthServiceDeps, OAuthStateMismatchError, OAuthTokens, OAuthUserInfo, Permission, PolicyRule, Role, RolePermissionGrant, TotpSecret, TotpSetupResult, UnauthenticatedError, UserRoleAssignment, VerificationToken, VerificationTokenType, createOAuthService, evaluateAuthorization, identitySchemaModel, isAuthorized, resolveIdentityConfig };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as IdentityError, c as UnauthenticatedError, i as IdentityConfigError, n as EmailAlreadyRegisteredError, o as InvalidCredentialsError, r as ForbiddenError, s as InvalidTokenError, t as AccountUnavailableError } from "./errors-CEmnZxIn.mjs";
|
|
2
|
+
import { c as isAuthorized, i as createOAuthService, l as resolveIdentityConfig, n as OAuthProviderNotFoundError, r as OAuthStateMismatchError, s as evaluateAuthorization, t as identitySchemaModel } from "./identity-Bz9RDOvT.mjs";
|
|
3
|
+
export { AccountUnavailableError, EmailAlreadyRegisteredError, ForbiddenError, IdentityConfigError, IdentityError, InvalidCredentialsError, InvalidTokenError, OAuthProviderNotFoundError, OAuthStateMismatchError, UnauthenticatedError, createOAuthService, evaluateAuthorization, identitySchemaModel, isAuthorized, resolveIdentityConfig };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region core/logger.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default logger that writes to the Node.js console with an `[identity]` prefix.
|
|
4
|
+
* Used when no custom logger is provided.
|
|
5
|
+
*/
|
|
6
|
+
const consoleLogger = {
|
|
7
|
+
debug: (msg, meta) => console.debug(`[identity] ${msg}`, ...meta !== void 0 ? [meta] : []),
|
|
8
|
+
info: (msg, meta) => console.info(`[identity] ${msg}`, ...meta !== void 0 ? [meta] : []),
|
|
9
|
+
warn: (msg, meta) => console.warn(`[identity] ${msg}`, ...meta !== void 0 ? [meta] : []),
|
|
10
|
+
error: (msg, meta) => console.error(`[identity] ${msg}`, ...meta !== void 0 ? [meta] : [])
|
|
11
|
+
};
|
|
12
|
+
/** No-op logger. Pass `false` or `noopLogger` to disable all identity logging. */
|
|
13
|
+
const noopLogger = {
|
|
14
|
+
debug: () => {},
|
|
15
|
+
info: () => {},
|
|
16
|
+
warn: () => {},
|
|
17
|
+
error: () => {}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Resolves an `IdentityLogger | false | undefined` to a concrete `IdentityLogger`.
|
|
21
|
+
*
|
|
22
|
+
* - `false` → {@link noopLogger}
|
|
23
|
+
* - `undefined` → {@link consoleLogger}
|
|
24
|
+
* - anything else → returned as-is
|
|
25
|
+
*/
|
|
26
|
+
function resolveLogger(logger) {
|
|
27
|
+
if (logger === false) return noopLogger;
|
|
28
|
+
return logger ?? consoleLogger;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
Object.defineProperty(exports, "consoleLogger", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function() {
|
|
34
|
+
return consoleLogger;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "noopLogger", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function() {
|
|
40
|
+
return noopLogger;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "resolveLogger", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function() {
|
|
46
|
+
return resolveLogger;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region core/logger.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default logger that writes to the Node.js console with an `[identity]` prefix.
|
|
4
|
+
* Used when no custom logger is provided.
|
|
5
|
+
*/
|
|
6
|
+
const consoleLogger = {
|
|
7
|
+
debug: (msg, meta) => console.debug(`[identity] ${msg}`, ...meta !== void 0 ? [meta] : []),
|
|
8
|
+
info: (msg, meta) => console.info(`[identity] ${msg}`, ...meta !== void 0 ? [meta] : []),
|
|
9
|
+
warn: (msg, meta) => console.warn(`[identity] ${msg}`, ...meta !== void 0 ? [meta] : []),
|
|
10
|
+
error: (msg, meta) => console.error(`[identity] ${msg}`, ...meta !== void 0 ? [meta] : [])
|
|
11
|
+
};
|
|
12
|
+
/** No-op logger. Pass `false` or `noopLogger` to disable all identity logging. */
|
|
13
|
+
const noopLogger = {
|
|
14
|
+
debug: () => {},
|
|
15
|
+
info: () => {},
|
|
16
|
+
warn: () => {},
|
|
17
|
+
error: () => {}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Resolves an `IdentityLogger | false | undefined` to a concrete `IdentityLogger`.
|
|
21
|
+
*
|
|
22
|
+
* - `false` → {@link noopLogger}
|
|
23
|
+
* - `undefined` → {@link consoleLogger}
|
|
24
|
+
* - anything else → returned as-is
|
|
25
|
+
*/
|
|
26
|
+
function resolveLogger(logger) {
|
|
27
|
+
if (logger === false) return noopLogger;
|
|
28
|
+
return logger ?? consoleLogger;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { noopLogger as n, resolveLogger as r, consoleLogger as t };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=logger-CcCHJVVe.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-CcCHJVVe.mjs","names":[],"sources":["../core/logger.ts"],"sourcesContent":["/**\n * Pluggable logger interface for `@azlib/identity`.\n *\n * The package uses this interface for request/response logging in the Express router and\n * for operational messages throughout the module. Consumers can hook any structured\n * logging library (Winston, Pino, Bunyan, etc.) by implementing this interface.\n *\n * @example\n * ```ts\n * import pino from \"pino\";\n *\n * const logger = pino();\n * createIdentityRouter(service, { logger });\n * ```\n */\nexport interface IdentityLogger {\n debug(message: string, meta?: Record<string, unknown>): void;\n info(message: string, meta?: Record<string, unknown>): void;\n warn(message: string, meta?: Record<string, unknown>): void;\n error(message: string, meta?: Record<string, unknown>): void;\n}\n\n/**\n * Default logger that writes to the Node.js console with an `[identity]` prefix.\n * Used when no custom logger is provided.\n */\nexport const consoleLogger: IdentityLogger = {\n debug: (msg, meta) => console.debug(`[identity] ${msg}`, ...(meta !== undefined ? [meta] : [])),\n info: (msg, meta) => console.info(`[identity] ${msg}`, ...(meta !== undefined ? [meta] : [])),\n warn: (msg, meta) => console.warn(`[identity] ${msg}`, ...(meta !== undefined ? [meta] : [])),\n error: (msg, meta) => console.error(`[identity] ${msg}`, ...(meta !== undefined ? [meta] : [])),\n};\n\n/** No-op logger. Pass `false` or `noopLogger` to disable all identity logging. */\nexport const noopLogger: IdentityLogger = {\n debug: () => {},\n info: () => {},\n warn: () => {},\n error: () => {},\n};\n\n/**\n * Resolves an `IdentityLogger | false | undefined` to a concrete `IdentityLogger`.\n *\n * - `false` → {@link noopLogger}\n * - `undefined` → {@link consoleLogger}\n * - anything else → returned as-is\n */\nexport function resolveLogger(logger?: IdentityLogger | false): IdentityLogger {\n if (logger === false) return noopLogger;\n return logger ?? consoleLogger;\n}\n"],"mappings":";;;;;AA0BA,MAAa,gBAAgC;CAC3C,QAAQ,KAAK,SAAS,QAAQ,MAAM,cAAc,OAAO,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,IAAI,CAAC,CAAE;CAC9F,OAAO,KAAK,SAAS,QAAQ,KAAK,cAAc,OAAO,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,IAAI,CAAC,CAAE;CAC5F,OAAO,KAAK,SAAS,QAAQ,KAAK,cAAc,OAAO,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,IAAI,CAAC,CAAE;CAC5F,QAAQ,KAAK,SAAS,QAAQ,MAAM,cAAc,OAAO,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,IAAI,CAAC,CAAE;AAChG;;AAGA,MAAa,aAA6B;CACxC,aAAa,CAAC;CACd,YAAY,CAAC;CACb,YAAY,CAAC;CACb,aAAa,CAAC;AAChB;;;;;;;;AASA,SAAgB,cAAc,QAAiD;CAC7E,IAAI,WAAW,OAAO,OAAO;CAC7B,OAAO,UAAU;AACnB"}
|