@azlib/identity 0.2.0 → 0.2.1
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/README.md +44 -0
- package/dist/{errors-C2xZAatu.d.cts → errors-CBbiRO2n.d.cts} +1 -2
- package/dist/errors-CBbiRO2n.d.cts.map +1 -0
- package/dist/{errors-BGMwaW5s.d.mts → errors-_OcodtdV.d.mts} +1 -2
- package/dist/errors-_OcodtdV.d.mts.map +1 -0
- package/dist/express.cjs +34 -0
- package/dist/express.d.cts +5 -6
- package/dist/express.d.cts.map +1 -1
- package/dist/express.d.mts +5 -6
- package/dist/express.d.mts.map +1 -1
- package/dist/express.mjs +34 -1
- package/dist/express.mjs.map +1 -1
- package/dist/identity-Bz9RDOvT.mjs.map +1 -1
- package/dist/{identity-router-DBL20UWT.d.mts → identity-router-D1xJ5H7y.d.cts} +22 -6
- package/dist/identity-router-D1xJ5H7y.d.cts.map +1 -0
- package/dist/{identity-router-Dib30Waj.d.cts → identity-router-tj3-teBI.d.mts} +22 -6
- package/dist/identity-router-tj3-teBI.d.mts.map +1 -0
- package/dist/{identity-service-CLzKx8Z7.d.cts → identity-service---OTann1.d.cts} +2 -3
- package/dist/identity-service---OTann1.d.cts.map +1 -0
- package/dist/{identity-service-B9zrvE9z.d.mts → identity-service-WpOKb0MK.d.mts} +2 -3
- package/dist/identity-service-WpOKb0MK.d.mts.map +1 -0
- package/dist/identity-store-BRRahxcS.d.cts.map +1 -1
- package/dist/identity-store-BRRahxcS.d.mts.map +1 -1
- package/dist/index-CpufYgyn.d.cts.map +1 -1
- package/dist/index-CpufYgyn.d.mts.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/nestjs.cjs +4 -5
- package/dist/nestjs.d.cts +3 -4
- package/dist/nestjs.d.cts.map +1 -1
- package/dist/nestjs.d.mts +3 -4
- package/dist/nestjs.d.mts.map +1 -1
- package/dist/nestjs.mjs +4 -5
- package/dist/nestjs.mjs.map +1 -1
- package/dist/node.d.cts +2 -3
- package/dist/node.d.cts.map +1 -1
- package/dist/node.d.mts +2 -3
- package/dist/node.d.mts.map +1 -1
- package/dist/node.mjs.map +1 -1
- package/dist/test-utils.d.cts +0 -1
- package/dist/test-utils.d.cts.map +1 -1
- package/dist/test-utils.d.mts +0 -1
- package/dist/test-utils.d.mts.map +1 -1
- package/package.json +12 -12
- package/dist/errors-BGMwaW5s.d.mts.map +0 -1
- package/dist/errors-C2xZAatu.d.cts.map +0 -1
- package/dist/identity-router-DBL20UWT.d.mts.map +0 -1
- package/dist/identity-router-Dib30Waj.d.cts.map +0 -1
- package/dist/identity-service-B9zrvE9z.d.mts.map +0 -1
- package/dist/identity-service-CLzKx8Z7.d.cts.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { F as IdentityLogger } from "./errors-
|
|
2
|
-
import { t as IdentityService } from "./identity-service-
|
|
3
|
-
import { Request, Response, Router } from "express";
|
|
4
|
-
|
|
1
|
+
import { F as IdentityLogger } from "./errors-_OcodtdV.mjs";
|
|
2
|
+
import { t as IdentityService } from "./identity-service-WpOKb0MK.mjs";
|
|
3
|
+
import { NextFunction, Request, Response, Router } from "express";
|
|
5
4
|
//#region core/express/identity-router.d.ts
|
|
6
5
|
/** Options for controlling the refresh-token cookie. */
|
|
7
6
|
interface CookieRefreshOptions {
|
|
@@ -110,6 +109,23 @@ interface IdentityRouterOptions {
|
|
|
110
109
|
* | GET | `/:provider/callback` | Handle an OAuth 2.0 callback *(optional)* |
|
|
111
110
|
*/
|
|
112
111
|
declare function createIdentityRouter(service: IdentityService, options?: IdentityRouterOptions): Router;
|
|
112
|
+
/**
|
|
113
|
+
* Factory that creates an Express error-handling middleware which converts
|
|
114
|
+
* {@link IdentityError} instances to structured JSON responses.
|
|
115
|
+
* Mount it after the identity router:
|
|
116
|
+
*
|
|
117
|
+
* ```ts
|
|
118
|
+
* app.use(createIdentityRouter(service, { prefix: "auth" }));
|
|
119
|
+
* app.use(identityErrorHandler()); // default console logger
|
|
120
|
+
* app.use(identityErrorHandler({ logger: false })); // silent
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @param options.logger - Logger for recording serialised error details.
|
|
124
|
+
* Pass `false` to disable. Defaults to the console logger.
|
|
125
|
+
*/
|
|
126
|
+
declare function identityErrorHandler(options?: {
|
|
127
|
+
logger?: IdentityLogger | false;
|
|
128
|
+
}): (err: unknown, req: Request, res: Response, next: NextFunction) => void;
|
|
113
129
|
//#endregion
|
|
114
|
-
export { IdentityRouterOptions as n, createIdentityRouter as r, CookieRefreshOptions as t };
|
|
115
|
-
//# sourceMappingURL=identity-router-
|
|
130
|
+
export { identityErrorHandler as i, IdentityRouterOptions as n, createIdentityRouter as r, CookieRefreshOptions as t };
|
|
131
|
+
//# sourceMappingURL=identity-router-tj3-teBI.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-router-tj3-teBI.d.mts","names":[],"sources":["../core/express/identity-router.ts"],"mappings":";;;;;UAeiB;;EAEf;;EAEA;;;;;EAKA;;EAEA;;EAEA;;EAEA;;;;;UAMe;;;;;;;;;;;;EAYf;IAA0B,QAAQ;;;;;;;;;;EAUlC;;;;;;;;;;;;;;EAeA;;;;;;;;;;;;;;EAeA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsIK,qBACd,SAAS,iBACT,UAAS,wBACR;;;;;;;;;;;;;;;iBAkUa,qBACd;EAAW,SAAS;KAClB,cAAc,KAAK,SAAS,KAAK,UAAU,MAAM"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { T as TotpSetupResult, c as AuthResult, d as AuthenticatedIdentity, r as IdentityStore, v as LoginResult } from "./identity-store-BRRahxcS.cjs";
|
|
2
|
-
import { B as AuthorizationDecision, D as IdentityConfigInput, V as AuthorizationRequirement, a as IdentityError, f as OAuthService, v as OAuthProvider, w as AuditLogger, x as SessionDeps, z as AuthorizationContext } from "./errors-
|
|
3
|
-
|
|
2
|
+
import { B as AuthorizationDecision, D as IdentityConfigInput, V as AuthorizationRequirement, a as IdentityError, f as OAuthService, v as OAuthProvider, w as AuditLogger, x as SessionDeps, z as AuthorizationContext } from "./errors-CBbiRO2n.cjs";
|
|
4
3
|
//#region core/password-hasher.d.ts
|
|
5
4
|
interface PasswordHasher {
|
|
6
5
|
hash(password: string): Promise<string>;
|
|
@@ -125,4 +124,4 @@ interface IdentityServiceConfig extends IdentityConfigInput {
|
|
|
125
124
|
declare function createIdentityService(configInput: IdentityServiceConfig, store: IdentityStore): IdentityService;
|
|
126
125
|
//#endregion
|
|
127
126
|
export { RegisterInput as a, registerUser as c, loginUser as d, PasswordHasher as f, RegisterDeps as i, LoginDeps as l, IdentityServiceConfig as n, RegistrationValidationError as o, createPasswordHasher as p, createIdentityService as r, normalizeEmail as s, IdentityService as t, LoginInput as u };
|
|
128
|
-
//# sourceMappingURL=identity-service
|
|
127
|
+
//# sourceMappingURL=identity-service---OTann1.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-service---OTann1.d.cts","names":[],"sources":["../core/password-hasher.ts","../core/login.ts","../core/register.ts","../core/identity-service.ts"],"mappings":";;;UAuBiB;EACf,KAAK,mBAAmB;EACxB,OAAO,kBAAkB,qBAAqB;;;iBAIhC,qBAAqB,eAAe;;;;UCnBnC,kBAAkB;EACjC,QAAQ;EACR,OAAO;;;UAIQ;EACf;EACA;;;;;;;;;;iBAWoB,UAAU,MAAM,WAAW,OAAO,aAAa,QAAQ;;;;UCtB5D,qBAAqB;EACpC,QAAQ;EACR,OAAO;;;UAIQ;EACf;EACA;EACA;;;cAIW,oCAAoC;EACnC,YAAA;;;iBASE,eAAe;;;;;iBAQT,aACpB,MAAM,cACN,OAAO,gBACN,QAAQ;;;;UCDM;EACf,SAAS,OAAO,gBAAgB,QAAQ;;;;;;EAMxC,MAAM,OAAO,aAAa,QAAQ;EAClC,QAAQ,uBAAuB,QAAQ;EACvC,OAAO,uBAAuB;;;;;EAK9B,aAAa,sBAAsB,QAAQ;EAC3C,UAAU,qBACR,aAAa,yBAAyB,YACtC,SAAS,qBAAqB,aAC7B,QAAQ;;EAIX,yBAAyB,iBAAiB;;EAE1C,YAAY,gBAAgB;;EAI5B,qBAAqB,gBAAgB;;EAErC,cAAc,eAAe,sBAAsB;;;;;EAOnD,SAAS,iBAAiB,QAAQ;;EAElC,UAAU,gBAAgB,mBAAmB;;EAE7C,WAAW,gBAAgB,mBAAmB;;;;;EAK9C,mBAAmB,kBAAkB,mBAAmB,QAAQ;;EAIhE,YAAY,iBAAiB;;EAE7B,cAAc,iBAAiB;;EAE/B,eAAe,iBAAiB;;;;;EAMhC,QAAQ;;;UAIO,8BAA8B;;EAE7C;;;;;;IAME,WAAW;;;;;;;iBAQC,sBACd,aAAa,uBACb,OAAO,gBACN"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { T as TotpSetupResult, c as AuthResult, d as AuthenticatedIdentity, r as IdentityStore, v as LoginResult } from "./identity-store-BRRahxcS.mjs";
|
|
2
|
-
import { B as AuthorizationDecision, D as IdentityConfigInput, V as AuthorizationRequirement, a as IdentityError, f as OAuthService, v as OAuthProvider, w as AuditLogger, x as SessionDeps, z as AuthorizationContext } from "./errors-
|
|
3
|
-
|
|
2
|
+
import { B as AuthorizationDecision, D as IdentityConfigInput, V as AuthorizationRequirement, a as IdentityError, f as OAuthService, v as OAuthProvider, w as AuditLogger, x as SessionDeps, z as AuthorizationContext } from "./errors-_OcodtdV.mjs";
|
|
4
3
|
//#region core/password-hasher.d.ts
|
|
5
4
|
interface PasswordHasher {
|
|
6
5
|
hash(password: string): Promise<string>;
|
|
@@ -125,4 +124,4 @@ interface IdentityServiceConfig extends IdentityConfigInput {
|
|
|
125
124
|
declare function createIdentityService(configInput: IdentityServiceConfig, store: IdentityStore): IdentityService;
|
|
126
125
|
//#endregion
|
|
127
126
|
export { RegisterInput as a, registerUser as c, loginUser as d, PasswordHasher as f, RegisterDeps as i, LoginDeps as l, IdentityServiceConfig as n, RegistrationValidationError as o, createPasswordHasher as p, createIdentityService as r, normalizeEmail as s, IdentityService as t, LoginInput as u };
|
|
128
|
-
//# sourceMappingURL=identity-service-
|
|
127
|
+
//# sourceMappingURL=identity-service-WpOKb0MK.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-service-WpOKb0MK.d.mts","names":[],"sources":["../core/password-hasher.ts","../core/login.ts","../core/register.ts","../core/identity-service.ts"],"mappings":";;;UAuBiB;EACf,KAAK,mBAAmB;EACxB,OAAO,kBAAkB,qBAAqB;;;iBAIhC,qBAAqB,eAAe;;;;UCnBnC,kBAAkB;EACjC,QAAQ;EACR,OAAO;;;UAIQ;EACf;EACA;;;;;;;;;;iBAWoB,UAAU,MAAM,WAAW,OAAO,aAAa,QAAQ;;;;UCtB5D,qBAAqB;EACpC,QAAQ;EACR,OAAO;;;UAIQ;EACf;EACA;EACA;;;cAIW,oCAAoC;EACnC,YAAA;;;iBASE,eAAe;;;;;iBAQT,aACpB,MAAM,cACN,OAAO,gBACN,QAAQ;;;;UCDM;EACf,SAAS,OAAO,gBAAgB,QAAQ;;;;;;EAMxC,MAAM,OAAO,aAAa,QAAQ;EAClC,QAAQ,uBAAuB,QAAQ;EACvC,OAAO,uBAAuB;;;;;EAK9B,aAAa,sBAAsB,QAAQ;EAC3C,UAAU,qBACR,aAAa,yBAAyB,YACtC,SAAS,qBAAqB,aAC7B,QAAQ;;EAIX,yBAAyB,iBAAiB;;EAE1C,YAAY,gBAAgB;;EAI5B,qBAAqB,gBAAgB;;EAErC,cAAc,eAAe,sBAAsB;;;;;EAOnD,SAAS,iBAAiB,QAAQ;;EAElC,UAAU,gBAAgB,mBAAmB;;EAE7C,WAAW,gBAAgB,mBAAmB;;;;;EAK9C,mBAAmB,kBAAkB,mBAAmB,QAAQ;;EAIhE,YAAY,iBAAiB;;EAE7B,cAAc,iBAAiB;;EAE/B,eAAe,iBAAiB;;;;;EAMhC,QAAQ;;;UAIO,8BAA8B;;EAE7C;;;;;;IAME,WAAW;;;;;;;iBAQC,sBACd,aAAa,uBACb,OAAO,gBACN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-store-BRRahxcS.d.cts","names":[],"sources":["../core/types.ts","../core/verification-token.ts","../core/identity-store.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"identity-store-BRRahxcS.d.cts","names":[],"sources":["../core/types.ts","../core/verification-token.ts","../core/identity-store.ts"],"mappings":";;;;;;;;KAQY;;UAGK;EACf;EACA;EACA;EACA,QAAQ;EACR,iBAAiB;;;;EAIjB;;;;;EAKA;;;;;EAKA;;;;;EAKA,aAAa;EACb,WAAW;EACX,WAAW;;;UAII;EACf;;EAEA;EACA,WAAW;;;;;;UAOI;EACf;EACA;;EAEA;EACA,WAAW;EACX,WAAW;;EAEX,WAAW;;;KAID;;UAGK;EACf;EACA;EACA;;;UAIe;EACf;EACA;;;UAIe;EACf;EACA,YAAY;;;UAIG;EACf;EACA,YAAY;;;KAIF;;UAoBK;EACf;;EAEA;;EAEA;EACA;EACA;EACA,UAAU;;;UAIK;EACf,MAAM;EACN;;EAEA,UAAU;EACV,YAAY;;;;;;UAOG;EACf;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,sBAAsB;;;UAIP;EACf;EACA;EACA,sBAAsB;EACtB,uBAAuB;;;UAIR;EACf,MAAM;EACN,QAAQ;;;;;;UAOO;EACf;;EAEA;;;KAIU,cAAc,aAAa;;KAG3B;;UAGK;;EAEf;EACA;EACA,MAAM;EACN,WAAW;;EAEX,QAAQ;;;UAIO;EACf;;EAEA;;EAEA,WAAW;EACX,WAAW;;;UAII;;EAEf;;EAEA;;;UAIe;;EAEf;;EAEA;;EAEA;;EAEA;;;;;UC/Me;;EAEf;EACA;EACA,MAAM;EACN,WAAW;;;;;;iBAOG;EAA+B;EAAe;;;iBAO9C,sBAAsB;;;;UCTrB;EACf;EACA;EACA;EACA,QAAQ;EACR;EACA,WAAW;EACX,WAAW;;;UAII;EACf;EACA;EACA;EACA,WAAW;EACX,WAAW;;;;;;;;;;UAWI;EAEf,gBAAgB,gBAAgB,QAAQ;EACxC,aAAa,iBAAiB,QAAQ;EACtC,WAAW,OAAO,0BAA0B,QAAQ;EACpD,WACE,gBACA,OAAO,QACL,KACE,4IAUH,QAAQ;EAEX,eAAe,iBAAiB,QAAQ;EACxC,iBAAiB,QAAQ,mBAAmB;EAG5C,cAAc,OAAO,yBAAyB,QAAQ;EACtD,gBAAgB,oBAAoB,QAAQ;;EAE5C,cAAc,mBAAmB,WAAW,OAAO;;EAEnD,cAAc,mBAAmB,0BAA0B,WAAW,OAAO;;EAE7E,kBAAkB,gBAAgB,WAAW,OAAO;EAGpD,iBAAiB,iBAAiB,iBAAiB;EACnD,uBAAuB,iBAAiB,iBAAiB;EACzD,WAAW,YAAY,qBAAqB;EAC5C,oBAAoB,OAAO,sBAAsB;EACjD,sBAAsB,OAAO,wBAAwB;;EAIrD,yBAAyB,OAAO,+BAA+B;;EAE/D,uBAAuB,oBAAoB,QAAQ;;EAEnD,2BAA2B,mBAAmB,QAAQ,OAAO;;EAI7D,gBAAgB,iBAAiB,QAAQ;;EAEzC,kBAAkB,QAAQ,aAAa;;EAEvC,kBAAkB,iBAAiB;EAGnC,aAAa,OAAO,gBAAgB;;;;;EAOpC,mBAAmB,kBAAkB,yBAAyB,QAAQ;;EAEtE,iBAAiB,MAAM,qBAAqB;;EAE5C,gBAAgB,iBAAiB,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-store-BRRahxcS.d.mts","names":[],"sources":["../core/types.ts","../core/verification-token.ts","../core/identity-store.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"identity-store-BRRahxcS.d.mts","names":[],"sources":["../core/types.ts","../core/verification-token.ts","../core/identity-store.ts"],"mappings":";;;;;;;;KAQY;;UAGK;EACf;EACA;EACA;EACA,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B,WAAW,OAAO;;EAEnD,cAAc,mBAAmB,0BAA0B,WAAW,OAAO;;EAE7E,kBAAkB,gBAAgB,WAAW,OAAO;EAGpD,iBAAiB,iBAAiB,iBAAiB;EACnD,uBAAuB,iBAAiB,iBAAiB;EACzD,WAAW,YAAY,qBAAqB;EAC5C,oBAAoB,OAAO,sBAAsB;EACjD,sBAAsB,OAAO,wBAAwB;;EAIrD,yBAAyB,OAAO,+BAA+B;;EAE/D,uBAAuB,oBAAoB,QAAQ;;EAEnD,2BAA2B,mBAAmB,QAAQ,OAAO;;EAI7D,gBAAgB,iBAAiB,QAAQ;;EAEzC,kBAAkB,QAAQ,aAAa;;EAEvC,kBAAkB,iBAAiB;EAGnC,aAAa,OAAO,gBAAgB;;;;;EAOpC,mBAAmB,kBAAkB,yBAAyB,QAAQ;;EAEtE,iBAAiB,MAAM,qBAAqB;;EAE5C,gBAAgB,iBAAiB,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-CpufYgyn.d.cts","names":[],"sources":["../schema/model.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index-CpufYgyn.d.cts","names":[],"sources":["../schema/model.ts"],"mappings":";;;;;;;;;;;;;UAYiB;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA,kBAAkB;;UAGH;EACf,iBAAiB;;cAGN,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-CpufYgyn.d.mts","names":[],"sources":["../schema/model.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index-CpufYgyn.d.mts","names":[],"sources":["../schema/model.ts"],"mappings":";;;;;;;;;;;;;UAYiB;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA,kBAAkB;;UAGH;EACf,iBAAiB;;cAGN,qBAAqB"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
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-
|
|
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-CBbiRO2n.cjs";
|
|
3
3
|
import { t as identitySchemaModel } from "./index-CpufYgyn.cjs";
|
|
4
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
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-
|
|
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-_OcodtdV.mjs";
|
|
3
3
|
import { t as identitySchemaModel } from "./index-CpufYgyn.mjs";
|
|
4
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/nestjs.cjs
CHANGED
|
@@ -2,19 +2,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_errors = require("./errors-Bcjx9o6g.cjs");
|
|
3
3
|
let _nestjs_common = require("@nestjs/common");
|
|
4
4
|
let _nestjs_core = require("@nestjs/core");
|
|
5
|
-
//#region \0@oxc-project+runtime@0.
|
|
5
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateMetadata.js
|
|
6
6
|
function __decorateMetadata(k, v) {
|
|
7
7
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
|
-
//#region \0@oxc-project+runtime@0.
|
|
10
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
11
11
|
function __decorateParam(paramIndex, decorator) {
|
|
12
12
|
return function(target, key) {
|
|
13
13
|
decorator(target, key, paramIndex);
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region \0@oxc-project+runtime@0.
|
|
17
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
18
18
|
function __decorate(decorators, target, key, desc) {
|
|
19
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -373,7 +373,6 @@ function createIdentityController(prefix, controllerOptions = {}) {
|
|
|
373
373
|
* by metadata decorators, and a `@CurrentUser()` param decorator. `@nestjs/common` and
|
|
374
374
|
* `reflect-metadata` are optional peer dependencies — only required when this entry is used.
|
|
375
375
|
*/
|
|
376
|
-
var _ref;
|
|
377
376
|
/** Token used to inject the configured {@link IdentityService} in Nest providers. */
|
|
378
377
|
const IDENTITY_SERVICE = Symbol.for("azlib.identity.service");
|
|
379
378
|
/** Metadata key holding the authorization requirement for a route. */
|
|
@@ -429,7 +428,7 @@ let IdentityAuthorizationGuard = class IdentityAuthorizationGuard {
|
|
|
429
428
|
IdentityAuthorizationGuard = __decorate([
|
|
430
429
|
(0, _nestjs_common.Injectable)(),
|
|
431
430
|
__decorateParam(0, (0, _nestjs_common.Inject)(IDENTITY_SERVICE)),
|
|
432
|
-
__decorateMetadata("design:paramtypes", [Object, typeof
|
|
431
|
+
__decorateMetadata("design:paramtypes", [Object, typeof _nestjs_core.Reflector === "undefined" ? Object : _nestjs_core.Reflector])
|
|
433
432
|
], IdentityAuthorizationGuard);
|
|
434
433
|
/** Declares the authorization requirement for a route or controller. */
|
|
435
434
|
const RequireAuthorization = (requirement) => (0, _nestjs_common.SetMetadata)(IDENTITY_REQUIREMENT, requirement);
|
package/dist/nestjs.d.cts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { V as AuthorizationRequirement } from "./errors-
|
|
2
|
-
import { t as IdentityService } from "./identity-service
|
|
3
|
-
import { t as CookieRefreshOptions } from "./identity-router-
|
|
1
|
+
import { V as AuthorizationRequirement } from "./errors-CBbiRO2n.cjs";
|
|
2
|
+
import { t as IdentityService } from "./identity-service---OTann1.cjs";
|
|
3
|
+
import { t as CookieRefreshOptions } from "./identity-router-D1xJ5H7y.cjs";
|
|
4
4
|
import { Request, Response } from "express";
|
|
5
5
|
import { CanActivate, DynamicModule, ExecutionContext } from "@nestjs/common";
|
|
6
6
|
import { Reflector } from "@nestjs/core";
|
|
7
|
-
|
|
8
7
|
//#region core/nestjs/identity-controller.d.ts
|
|
9
8
|
/** Options accepted by {@link createIdentityController}. */
|
|
10
9
|
interface IdentityControllerOptions {
|
package/dist/nestjs.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nestjs.d.cts","names":[],"sources":["../core/nestjs/identity-controller.ts","../core/nestjs/identity.module.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"nestjs.d.cts","names":[],"sources":["../core/nestjs/identity-controller.ts","../core/nestjs/identity.module.ts"],"mappings":";;;;;;;;UAkGiB;;;;;EAKf,SAAS;;;;;cC1EE;;cAGA;;;;UAKI,8BAA8B;;;;;;;EAO7C;;UAGe;;EAEf,SAAS;;;;;;;;;;;;;;;;;;;;;EAqBT,gBAAgB;;UAGD;EACf,UAAU;;EAEV,gBAAgB,kBAAkB,kBAAkB,QAAQ;EAC5D;;;;;EAKA,gBAAgB;;;;;;cAqBL,6BAA6B;mBACe;EAAA,YAAA,SAAS;EAE1D,YAAY,SAAS,mBAAmB;;;;;;cAoBnC,sCAAsC;mBAEJ;mBAC1B;EAD0B,YAAA,SAAS,iBACnC,WAAW;EAGxB,YAAY,SAAS,mBAAmB;;;cAyBnC,uBAAoB,aAAiB,sDAAwB,uBAAA;;cAI7D,oBAAiB,gDAAsB,uBAAA;;cAIvC,iBAAW,2BAAA;cAsBX;SACJ,QAAQ,SAAS,wBAAwB;SAczC,aAAa,SAAS,6BAA6B"}
|
package/dist/nestjs.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { V as AuthorizationRequirement } from "./errors-
|
|
2
|
-
import { t as IdentityService } from "./identity-service-
|
|
3
|
-
import { t as CookieRefreshOptions } from "./identity-router-
|
|
1
|
+
import { V as AuthorizationRequirement } from "./errors-_OcodtdV.mjs";
|
|
2
|
+
import { t as IdentityService } from "./identity-service-WpOKb0MK.mjs";
|
|
3
|
+
import { t as CookieRefreshOptions } from "./identity-router-tj3-teBI.mjs";
|
|
4
4
|
import { Request, Response } from "express";
|
|
5
5
|
import { CanActivate, DynamicModule, ExecutionContext } from "@nestjs/common";
|
|
6
6
|
import { Reflector } from "@nestjs/core";
|
|
7
|
-
|
|
8
7
|
//#region core/nestjs/identity-controller.d.ts
|
|
9
8
|
/** Options accepted by {@link createIdentityController}. */
|
|
10
9
|
interface IdentityControllerOptions {
|
package/dist/nestjs.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nestjs.d.mts","names":[],"sources":["../core/nestjs/identity-controller.ts","../core/nestjs/identity.module.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"nestjs.d.mts","names":[],"sources":["../core/nestjs/identity-controller.ts","../core/nestjs/identity.module.ts"],"mappings":";;;;;;;;UAkGiB;;;;;EAKf,SAAS;;;;;cC1EE;;cAGA;;;;UAKI,8BAA8B;;;;;;;EAO7C;;UAGe;;EAEf,SAAS;;;;;;;;;;;;;;;;;;;;;EAqBT,gBAAgB;;UAGD;EACf,UAAU;;EAEV,gBAAgB,kBAAkB,kBAAkB,QAAQ;EAC5D;;;;;EAKA,gBAAgB;;;;;;cAqBL,6BAA6B;mBACe;EAAA,YAAA,SAAS;EAE1D,YAAY,SAAS,mBAAmB;;;;;;cAoBnC,sCAAsC;mBAEJ;mBAC1B;EAD0B,YAAA,SAAS,iBACnC,WAAW;EAGxB,YAAY,SAAS,mBAAmB;;;cAyBnC,uBAAoB,aAAiB,sDAAwB,uBAAA;;cAI7D,oBAAiB,gDAAsB,uBAAA;;cAIvC,iBAAW,2BAAA;cAsBX;SACJ,QAAQ,SAAS,wBAAwB;SAczC,aAAa,SAAS,6BAA6B"}
|
package/dist/nestjs.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { a as IdentityError, c as UnauthenticatedError } from "./errors-CEmnZxIn.mjs";
|
|
2
2
|
import { Body, Controller, ForbiddenException, Get, HttpCode, HttpException, Inject, Injectable, Param, Post, Req, Res, SetMetadata, UnauthorizedException, UseGuards, createParamDecorator } from "@nestjs/common";
|
|
3
3
|
import { Reflector } from "@nestjs/core";
|
|
4
|
-
//#region \0@oxc-project+runtime@0.
|
|
4
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateMetadata.js
|
|
5
5
|
function __decorateMetadata(k, v) {
|
|
6
6
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
|
-
//#region \0@oxc-project+runtime@0.
|
|
9
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
10
10
|
function __decorateParam(paramIndex, decorator) {
|
|
11
11
|
return function(target, key) {
|
|
12
12
|
decorator(target, key, paramIndex);
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
|
-
//#region \0@oxc-project+runtime@0.
|
|
16
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
17
17
|
function __decorate(decorators, target, key, desc) {
|
|
18
18
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
19
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -372,7 +372,6 @@ function createIdentityController(prefix, controllerOptions = {}) {
|
|
|
372
372
|
* by metadata decorators, and a `@CurrentUser()` param decorator. `@nestjs/common` and
|
|
373
373
|
* `reflect-metadata` are optional peer dependencies — only required when this entry is used.
|
|
374
374
|
*/
|
|
375
|
-
var _ref;
|
|
376
375
|
/** Token used to inject the configured {@link IdentityService} in Nest providers. */
|
|
377
376
|
const IDENTITY_SERVICE = Symbol.for("azlib.identity.service");
|
|
378
377
|
/** Metadata key holding the authorization requirement for a route. */
|
|
@@ -428,7 +427,7 @@ let IdentityAuthorizationGuard = class IdentityAuthorizationGuard {
|
|
|
428
427
|
IdentityAuthorizationGuard = __decorate([
|
|
429
428
|
Injectable(),
|
|
430
429
|
__decorateParam(0, Inject(IDENTITY_SERVICE)),
|
|
431
|
-
__decorateMetadata("design:paramtypes", [Object, typeof
|
|
430
|
+
__decorateMetadata("design:paramtypes", [Object, typeof Reflector === "undefined" ? Object : Reflector])
|
|
432
431
|
], IdentityAuthorizationGuard);
|
|
433
432
|
/** Declares the authorization requirement for a route or controller. */
|
|
434
433
|
const RequireAuthorization = (requirement) => SetMetadata(IDENTITY_REQUIREMENT, requirement);
|
package/dist/nestjs.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nestjs.mjs","names":[],"sources":["../core/nestjs/identity-controller.ts","../core/nestjs/identity.module.ts"],"sourcesContent":["/**\n * Pre-built NestJS controller for `@azlib/identity`.\n *\n * Register it automatically via `IdentityModule.forRoot({ routes: true })`.\n * `@nestjs/common` is an optional peer dependency — only required when this file is used.\n */\nimport {\n Body,\n Controller,\n Get,\n HttpCode,\n HttpException,\n type HttpStatus,\n Inject,\n Param,\n Post,\n Req,\n Res,\n UseGuards,\n} from \"@nestjs/common\";\nimport type { Request, Response } from \"express\";\n\nimport { IdentityError, UnauthenticatedError } from \"../errors\";\nimport type { IdentityService } from \"../identity-service\";\nimport type { AuthResult, AuthTokens, LoginResult } from \"../types\";\nimport type { CookieRefreshOptions } from \"../express/identity-router\";\nimport { IdentityAuthGuard, IDENTITY_SERVICE } from \"./identity.module\";\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nfunction resolveCookieName(opts: CookieRefreshOptions): string {\n return opts.name ?? \"azlib_rt\";\n}\n\nfunction rethrowAsHttp(err: unknown): never {\n if (err instanceof IdentityError) {\n throw new HttpException({ code: err.code, message: err.message }, err.statusCode as HttpStatus);\n }\n throw err;\n}\n\nfunction setCookieAndStripRefreshToken(\n res: Response,\n tokens: AuthTokens,\n opts: CookieRefreshOptions,\n): Omit<AuthTokens, \"refreshToken\" | \"refreshTokenExpiresAt\"> {\n const maxAge = tokens.refreshTokenExpiresAt.getTime() - Date.now();\n res.cookie(resolveCookieName(opts), tokens.refreshToken, {\n httpOnly: opts.httpOnly ?? true,\n secure: opts.secure ?? process.env.NODE_ENV === \"production\",\n sameSite: opts.sameSite ?? \"lax\",\n path: opts.path ?? \"/\",\n domain: opts.domain,\n maxAge,\n });\n const { refreshToken: _rt, refreshTokenExpiresAt: _exp, ...bodyTokens } = tokens;\n return bodyTokens;\n}\n\nfunction buildAuthResponse(result: AuthResult, cookieOpts: CookieRefreshOptions | undefined, res: Response) {\n if (cookieOpts) {\n const tokens = setCookieAndStripRefreshToken(res, result.tokens, cookieOpts);\n return { user: result.user, tokens };\n }\n return result;\n}\n\nfunction buildLoginResponse(\n result: LoginResult,\n cookieOpts: CookieRefreshOptions | undefined,\n res: Response,\n) {\n if (\"mfaToken\" in result) {\n return result; // { kind: \"mfa_required\", mfaToken: \"...\" }\n }\n return buildAuthResponse(result, cookieOpts, res);\n}\n\nfunction readRefreshTokenFromRequest(\n req: Request,\n cookieOpts: CookieRefreshOptions | undefined,\n): string | undefined {\n if (cookieOpts) {\n const cookies = req.cookies as Record<string, string> | undefined;\n return cookies?.[resolveCookieName(cookieOpts)];\n }\n const body = req.body as Record<string, unknown> | undefined;\n const token = body?.[\"refreshToken\"];\n return typeof token === \"string\" ? token : undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Controller options\n// ---------------------------------------------------------------------------\n\n/** Options accepted by {@link createIdentityController}. */\nexport interface IdentityControllerOptions {\n /**\n * Cookie-based refresh-token transport. When set, the refresh token is stored in an\n * `HttpOnly` cookie instead of the response body. Omit for body mode.\n */\n cookie?: CookieRefreshOptions;\n}\n\n// ---------------------------------------------------------------------------\n// Controller factory\n// ---------------------------------------------------------------------------\n\n/**\n * Returns a dynamically created NestJS controller class with all standard identity\n * routes pre-wired. The class is registered directly in `IdentityModule.forRoot()`\n * when `routes` is configured — consumers do not need to define this controller.\n *\n * Pre-wired routes (relative to the module prefix, default `\"auth\"`):\n *\n * | Method | Path | Description |\n * |--------|------|-------------|\n * | POST | `/register` | Create a new account |\n * | POST | `/login` | Email + password login; may return MFA challenge |\n * | POST | `/refresh` | Rotate the refresh token |\n * | POST | `/logout` | Revoke the current session |\n * | GET | `/me` | Return the authenticated principal (requires auth) |\n * | POST | `/request-email-verification` | Re-send verification link (requires auth) |\n * | POST | `/verify-email` | Consume an email verification token |\n * | POST | `/request-password-reset` | Send a password reset link |\n * | POST | `/reset-password` | Set a new password using a reset token |\n * | POST | `/mfa/verify` | Complete an MFA challenge after login |\n * | POST | `/2fa/setup` | Begin TOTP 2FA setup (requires auth) |\n * | POST | `/2fa/enable` | Confirm and enable 2FA (requires auth) |\n * | POST | `/2fa/disable` | Disable 2FA (requires auth) |\n * | POST | `/admin/lock/:userId` | Lock an account |\n * | POST | `/admin/unlock/:userId` | Unlock an account |\n * | POST | `/admin/disable/:userId` | Disable an account |\n */\nexport function createIdentityController(\n prefix: string,\n controllerOptions: IdentityControllerOptions = {},\n) {\n const cookieOpts = controllerOptions.cookie;\n\n @Controller(prefix)\n class IdentityController {\n constructor(@Inject(IDENTITY_SERVICE) readonly service: IdentityService) {}\n\n @Post(\"register\")\n async register(\n @Body() body: { email: string; password: string; displayName?: string },\n @Res({ passthrough: true }) res: Response,\n ) {\n try {\n const result = await this.service.register(body);\n return buildAuthResponse(result, cookieOpts, res);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"login\")\n async login(\n @Body() body: { email: string; password: string },\n @Res({ passthrough: true }) res: Response,\n ) {\n try {\n const result = await this.service.login(body);\n return buildLoginResponse(result, cookieOpts, res);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"refresh\")\n async refresh(@Req() req: Request, @Res({ passthrough: true }) res: Response) {\n try {\n const token = readRefreshTokenFromRequest(req, cookieOpts);\n if (!token) {\n throw new UnauthenticatedError(\"Refresh token is missing.\");\n }\n const result = await this.service.refresh(token);\n return buildAuthResponse(result, cookieOpts, res);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"logout\")\n @HttpCode(204)\n async logout(@Req() req: Request, @Res({ passthrough: true }) res: Response) {\n try {\n const token = readRefreshTokenFromRequest(req, cookieOpts);\n if (token) {\n await this.service.logout(token);\n }\n if (cookieOpts) {\n res.clearCookie(resolveCookieName(cookieOpts), { path: cookieOpts.path ?? \"/\" });\n }\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Get(\"me\")\n @UseGuards(IdentityAuthGuard)\n getMe(@Req() req: Request & { identity?: unknown }) {\n return req.identity;\n }\n\n // -------------------------------------------------------------------------\n // Email verification\n // -------------------------------------------------------------------------\n\n @Post(\"request-email-verification\")\n @HttpCode(204)\n @UseGuards(IdentityAuthGuard)\n async requestEmailVerification(@Req() req: Request & { identity?: { userId: string } }) {\n try {\n await this.service.requestEmailVerification(req.identity!.userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"verify-email\")\n @HttpCode(204)\n async verifyEmail(@Body() body: { token?: string }) {\n try {\n if (!body.token) throw new UnauthenticatedError(\"token is required.\");\n await this.service.verifyEmail(body.token);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n // -------------------------------------------------------------------------\n // Password reset\n // -------------------------------------------------------------------------\n\n @Post(\"request-password-reset\")\n @HttpCode(204)\n async requestPasswordReset(@Body() body: { email?: string }) {\n try {\n if (!body.email) throw new UnauthenticatedError(\"email is required.\");\n await this.service.requestPasswordReset(body.email);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"reset-password\")\n @HttpCode(204)\n async resetPassword(@Body() body: { token?: string; newPassword?: string }) {\n try {\n if (!body.token || !body.newPassword)\n throw new UnauthenticatedError(\"token and newPassword are required.\");\n await this.service.resetPassword(body.token, body.newPassword);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n // -------------------------------------------------------------------------\n // Two-factor authentication\n // -------------------------------------------------------------------------\n\n @Post(\"mfa/verify\")\n async verifyMfaChallenge(\n @Body() body: { mfaToken?: string; code?: string },\n @Res({ passthrough: true }) res: Response,\n ) {\n try {\n if (!body.mfaToken || !body.code)\n throw new UnauthenticatedError(\"mfaToken and code are required.\");\n const result = await this.service.verifyMfaChallenge(body.mfaToken, body.code);\n return buildAuthResponse(result, cookieOpts, res);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"2fa/setup\")\n @UseGuards(IdentityAuthGuard)\n async setup2FA(@Req() req: Request & { identity?: { userId: string } }) {\n try {\n return await this.service.setup2FA(req.identity!.userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"2fa/enable\")\n @HttpCode(204)\n @UseGuards(IdentityAuthGuard)\n async enable2FA(\n @Req() req: Request & { identity?: { userId: string } },\n @Body() body: { code?: string },\n ) {\n try {\n if (!body.code) throw new UnauthenticatedError(\"code is required.\");\n await this.service.enable2FA(req.identity!.userId, body.code);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"2fa/disable\")\n @HttpCode(204)\n @UseGuards(IdentityAuthGuard)\n async disable2FA(\n @Req() req: Request & { identity?: { userId: string } },\n @Body() body: { code?: string },\n ) {\n try {\n if (!body.code) throw new UnauthenticatedError(\"code is required.\");\n await this.service.disable2FA(req.identity!.userId, body.code);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n // -------------------------------------------------------------------------\n // Account management (admin)\n // -------------------------------------------------------------------------\n\n @Post(\"admin/lock/:userId\")\n @HttpCode(204)\n async lockAccount(@Param(\"userId\") userId: string) {\n try {\n await this.service.lockAccount(userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"admin/unlock/:userId\")\n @HttpCode(204)\n async unlockAccount(@Param(\"userId\") userId: string) {\n try {\n await this.service.unlockAccount(userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"admin/disable/:userId\")\n @HttpCode(204)\n async disableAccount(@Param(\"userId\") userId: string) {\n try {\n await this.service.disableAccount(userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n }\n\n return IdentityController;\n}\n","/**\n * NestJS integration for `@azlib/identity`.\n *\n * Provides a configurable module, an authentication guard, an authorization guard driven\n * by metadata decorators, and a `@CurrentUser()` param decorator. `@nestjs/common` and\n * `reflect-metadata` are optional peer dependencies — only required when this entry is used.\n */\nimport {\n type CanActivate,\n type DynamicModule,\n type ExecutionContext,\n ForbiddenException,\n Inject,\n Injectable,\n SetMetadata,\n UnauthorizedException,\n createParamDecorator,\n} from \"@nestjs/common\";\nimport { Reflector } from \"@nestjs/core\";\n\nimport type { AuthorizationRequirement } from \"../authorization\";\nimport type { IdentityService } from \"../identity-service\";\nimport type { AuthenticatedIdentity } from \"../types\";\nimport {\n createIdentityController,\n type IdentityControllerOptions,\n} from \"./identity-controller\";\n\n/** Token used to inject the configured {@link IdentityService} in Nest providers. */\nexport const IDENTITY_SERVICE = Symbol.for(\"azlib.identity.service\");\n\n/** Metadata key holding the authorization requirement for a route. */\nexport const IDENTITY_REQUIREMENT = Symbol.for(\"azlib.identity.requirement\");\n\n/**\n * Options for enabling the pre-built REST routes in {@link IdentityModule}.\n */\nexport interface IdentityRoutesOptions extends IdentityControllerOptions {\n /**\n * URL prefix for the built-in controller. Default: `\"auth\"`.\n *\n * The controller is mounted at this prefix relative to the application's global\n * prefix (if any).\n */\n prefix?: string;\n}\n\nexport interface IdentityModuleOptions {\n /** A fully wired identity service (see `createIdentityService`). */\n service: IdentityService;\n /**\n * When set, the module automatically registers a built-in REST controller with all\n * standard auth endpoints (`POST /register`, `POST /login`, `POST /refresh`,\n * `POST /logout`, `GET /me`).\n *\n * Pass `true` to use the defaults (`prefix: \"auth\"`, body-mode refresh tokens), or\n * supply an `IdentityRoutesOptions` object to customise the prefix and cookie behaviour.\n *\n * @example\n * ```ts\n * // Minimal — everything works out of the box\n * IdentityModule.forRoot({ service, routes: true })\n *\n * // With a custom prefix and HttpOnly refresh-token cookie\n * IdentityModule.forRoot({\n * service,\n * routes: { prefix: \"v1/auth\", cookie: { name: \"rt\", secure: true } },\n * })\n * ```\n */\n routes?: true | IdentityRoutesOptions;\n}\n\nexport interface IdentityModuleAsyncOptions {\n imports?: DynamicModule[\"imports\"];\n /** Factory returning the configured identity service. */\n useFactory: (...args: never[]) => IdentityService | Promise<IdentityService>;\n inject?: unknown[];\n /**\n * Same as {@link IdentityModuleOptions.routes} — enable built-in REST routes\n * alongside the async service factory.\n */\n routes?: true | IdentityRoutesOptions;\n}\n\ninterface RequestWithIdentity {\n headers: Record<string, string | string[] | undefined>;\n identity?: AuthenticatedIdentity;\n}\n\nconst extractBearerToken = (req: RequestWithIdentity): string | null => {\n const header = req.headers.authorization;\n const value = Array.isArray(header) ? header[0] : header;\n if (!value || !value.startsWith(\"Bearer \")) return null;\n const token = value.slice(\"Bearer \".length).trim();\n return token.length > 0 ? token : null;\n};\n\n/**\n * Authentication guard: verifies the Bearer access token and attaches the hydrated\n * principal to `request.identity`. Apply with `@UseGuards(IdentityAuthGuard)`.\n */\n@Injectable()\nexport class IdentityAuthGuard implements CanActivate {\n constructor(@Inject(IDENTITY_SERVICE) private readonly service: IdentityService) {}\n\n async canActivate(context: ExecutionContext): Promise<boolean> {\n const req = context.switchToHttp().getRequest<RequestWithIdentity>();\n const token = extractBearerToken(req);\n if (!token) {\n throw new UnauthorizedException(\"Missing bearer token.\");\n }\n try {\n req.identity = await this.service.authenticate(token);\n } catch {\n throw new UnauthorizedException(\"Invalid or expired token.\");\n }\n return true;\n }\n}\n\n/**\n * Authorization guard: enforces the requirement declared by `@RequireAuthorization()`\n * (or `@RequirePermission()`). Must run after {@link IdentityAuthGuard}. Deny-by-default.\n */\n@Injectable()\nexport class IdentityAuthorizationGuard implements CanActivate {\n constructor(\n @Inject(IDENTITY_SERVICE) private readonly service: IdentityService,\n private readonly reflector: Reflector,\n ) {}\n\n async canActivate(context: ExecutionContext): Promise<boolean> {\n const requirement = this.reflector.getAllAndOverride<AuthorizationRequirement | undefined>(\n IDENTITY_REQUIREMENT,\n [context.getHandler(), context.getClass()],\n );\n // No requirement declared: nothing extra to enforce beyond authentication.\n if (!requirement) return true;\n\n const req = context.switchToHttp().getRequest<RequestWithIdentity>();\n const principal = req.identity;\n if (!principal) {\n throw new UnauthorizedException(\"Not authenticated.\");\n }\n const decision = await this.service.authorize(requirement, {\n principal,\n action: requirement.permission ?? \"custom\",\n });\n if (!decision.allowed) {\n throw new ForbiddenException();\n }\n return true;\n }\n}\n\n/** Declares the authorization requirement for a route or controller. */\nexport const RequireAuthorization = (requirement: AuthorizationRequirement) =>\n SetMetadata(IDENTITY_REQUIREMENT, requirement);\n\n/** Convenience: declare a single required permission for a route or controller. */\nexport const RequirePermission = (permission: string) =>\n SetMetadata(IDENTITY_REQUIREMENT, { permission } satisfies AuthorizationRequirement);\n\n/** Param decorator that resolves the authenticated principal from the request. */\nexport const CurrentUser = createParamDecorator(\n (_data: unknown, context: ExecutionContext): AuthenticatedIdentity | undefined => {\n const req = context.switchToHttp().getRequest<RequestWithIdentity>();\n return req.identity;\n },\n);\n\n/**\n * NestJS module exposing the identity service plus guards. Register once at the root:\n *\n * ```ts\n * IdentityModule.forRoot({ service: createIdentityService(config, store) })\n * ```\n */\nfunction buildControllers(routes: true | IdentityRoutesOptions | undefined) {\n if (!routes) return [];\n const routesOpts = routes === true ? {} : routes;\n const prefix = routesOpts.prefix ?? \"auth\";\n const controllerOpts: IdentityControllerOptions = { cookie: routesOpts.cookie };\n return [createIdentityController(prefix, controllerOpts)];\n}\n\nexport class IdentityModule {\n static forRoot(options: IdentityModuleOptions): DynamicModule {\n return {\n module: IdentityModule,\n global: true,\n controllers: buildControllers(options.routes),\n providers: [\n { provide: IDENTITY_SERVICE, useValue: options.service },\n IdentityAuthGuard,\n IdentityAuthorizationGuard,\n ],\n exports: [IDENTITY_SERVICE, IdentityAuthGuard, IdentityAuthorizationGuard],\n };\n }\n\n static forRootAsync(options: IdentityModuleAsyncOptions): DynamicModule {\n return {\n module: IdentityModule,\n global: true,\n imports: options.imports ?? [],\n controllers: buildControllers(options.routes),\n providers: [\n {\n provide: IDENTITY_SERVICE,\n useFactory: options.useFactory,\n inject: options.inject as never[],\n },\n IdentityAuthGuard,\n IdentityAuthorizationGuard,\n ],\n exports: [IDENTITY_SERVICE, IdentityAuthGuard, IdentityAuthorizationGuard],\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,kBAAkB,MAAoC;CAC7D,OAAO,KAAK,QAAQ;AACtB;AAEA,SAAS,cAAc,KAAqB;CAC1C,IAAI,eAAe,eACjB,MAAM,IAAI,cAAc;EAAE,MAAM,IAAI;EAAM,SAAS,IAAI;CAAQ,GAAG,IAAI,UAAwB;CAEhG,MAAM;AACR;AAEA,SAAS,8BACP,KACA,QACA,MAC4D;CAC5D,MAAM,SAAS,OAAO,sBAAsB,QAAQ,IAAI,KAAK,IAAI;CACjE,IAAI,OAAO,kBAAkB,IAAI,GAAG,OAAO,cAAc;EACvD,UAAU,KAAK,YAAY;EAC3B,QAAQ,KAAK,UAAU,QAAQ,IAAI,aAAa;EAChD,UAAU,KAAK,YAAY;EAC3B,MAAM,KAAK,QAAQ;EACnB,QAAQ,KAAK;EACb;CACF,CAAC;CACD,MAAM,EAAE,cAAc,KAAK,uBAAuB,MAAM,GAAG,eAAe;CAC1E,OAAO;AACT;AAEA,SAAS,kBAAkB,QAAoB,YAA8C,KAAe;CAC1G,IAAI,YAAY;EACd,MAAM,SAAS,8BAA8B,KAAK,OAAO,QAAQ,UAAU;EAC3E,OAAO;GAAE,MAAM,OAAO;GAAM;EAAO;CACrC;CACA,OAAO;AACT;AAEA,SAAS,mBACP,QACA,YACA,KACA;CACA,IAAI,cAAc,QAChB,OAAO;CAET,OAAO,kBAAkB,QAAQ,YAAY,GAAG;AAClD;AAEA,SAAS,4BACP,KACA,YACoB;CACpB,IAAI,YAEF,OADgB,IAAI,UACH,kBAAkB,UAAU;CAG/C,MAAM,QADO,IAAI,OACI;CACrB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,OAAO,QAAQ,SAA+C;EAC5D,OAAO;GACL,QAAQ;GACR,QAAQ;GACR,aAAa,iBAAiB,QAAQ,MAAM;GAC5C,WAAW;IACT;KAAE,SAAS;KAAkB,UAAU,QAAQ;IAAQ;IACvD;IACA;GACF;GACA,SAAS;IAAC;IAAkB;IAAmB;GAA0B;EAC3E;CACF;CAEA,OAAO,aAAa,SAAoD;EACtE,OAAO;GACL,QAAQ;GACR,QAAQ;GACR,SAAS,QAAQ,WAAW,CAAC;GAC7B,aAAa,iBAAiB,QAAQ,MAAM;GAC5C,WAAW;IACT;KACE,SAAS;KACT,YAAY,QAAQ;KACpB,QAAQ,QAAQ;IAClB;IACA;IACA;GACF;GACA,SAAS;IAAC;IAAkB;IAAmB;GAA0B;EAC3E;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"nestjs.mjs","names":[],"sources":["../core/nestjs/identity-controller.ts","../core/nestjs/identity.module.ts"],"sourcesContent":["/**\n * Pre-built NestJS controller for `@azlib/identity`.\n *\n * Register it automatically via `IdentityModule.forRoot({ routes: true })`.\n * `@nestjs/common` is an optional peer dependency — only required when this file is used.\n */\nimport {\n Body,\n Controller,\n Get,\n HttpCode,\n HttpException,\n type HttpStatus,\n Inject,\n Param,\n Post,\n Req,\n Res,\n UseGuards,\n} from \"@nestjs/common\";\nimport type { Request, Response } from \"express\";\n\nimport { IdentityError, UnauthenticatedError } from \"../errors\";\nimport type { IdentityService } from \"../identity-service\";\nimport type { AuthResult, AuthTokens, LoginResult } from \"../types\";\nimport type { CookieRefreshOptions } from \"../express/identity-router\";\nimport { IdentityAuthGuard, IDENTITY_SERVICE } from \"./identity.module\";\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nfunction resolveCookieName(opts: CookieRefreshOptions): string {\n return opts.name ?? \"azlib_rt\";\n}\n\nfunction rethrowAsHttp(err: unknown): never {\n if (err instanceof IdentityError) {\n throw new HttpException({ code: err.code, message: err.message }, err.statusCode as HttpStatus);\n }\n throw err;\n}\n\nfunction setCookieAndStripRefreshToken(\n res: Response,\n tokens: AuthTokens,\n opts: CookieRefreshOptions,\n): Omit<AuthTokens, \"refreshToken\" | \"refreshTokenExpiresAt\"> {\n const maxAge = tokens.refreshTokenExpiresAt.getTime() - Date.now();\n res.cookie(resolveCookieName(opts), tokens.refreshToken, {\n httpOnly: opts.httpOnly ?? true,\n secure: opts.secure ?? process.env.NODE_ENV === \"production\",\n sameSite: opts.sameSite ?? \"lax\",\n path: opts.path ?? \"/\",\n domain: opts.domain,\n maxAge,\n });\n const { refreshToken: _rt, refreshTokenExpiresAt: _exp, ...bodyTokens } = tokens;\n return bodyTokens;\n}\n\nfunction buildAuthResponse(result: AuthResult, cookieOpts: CookieRefreshOptions | undefined, res: Response) {\n if (cookieOpts) {\n const tokens = setCookieAndStripRefreshToken(res, result.tokens, cookieOpts);\n return { user: result.user, tokens };\n }\n return result;\n}\n\nfunction buildLoginResponse(\n result: LoginResult,\n cookieOpts: CookieRefreshOptions | undefined,\n res: Response,\n) {\n if (\"mfaToken\" in result) {\n return result; // { kind: \"mfa_required\", mfaToken: \"...\" }\n }\n return buildAuthResponse(result, cookieOpts, res);\n}\n\nfunction readRefreshTokenFromRequest(\n req: Request,\n cookieOpts: CookieRefreshOptions | undefined,\n): string | undefined {\n if (cookieOpts) {\n const cookies = req.cookies as Record<string, string> | undefined;\n return cookies?.[resolveCookieName(cookieOpts)];\n }\n const body = req.body as Record<string, unknown> | undefined;\n const token = body?.[\"refreshToken\"];\n return typeof token === \"string\" ? token : undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Controller options\n// ---------------------------------------------------------------------------\n\n/** Options accepted by {@link createIdentityController}. */\nexport interface IdentityControllerOptions {\n /**\n * Cookie-based refresh-token transport. When set, the refresh token is stored in an\n * `HttpOnly` cookie instead of the response body. Omit for body mode.\n */\n cookie?: CookieRefreshOptions;\n}\n\n// ---------------------------------------------------------------------------\n// Controller factory\n// ---------------------------------------------------------------------------\n\n/**\n * Returns a dynamically created NestJS controller class with all standard identity\n * routes pre-wired. The class is registered directly in `IdentityModule.forRoot()`\n * when `routes` is configured — consumers do not need to define this controller.\n *\n * Pre-wired routes (relative to the module prefix, default `\"auth\"`):\n *\n * | Method | Path | Description |\n * |--------|------|-------------|\n * | POST | `/register` | Create a new account |\n * | POST | `/login` | Email + password login; may return MFA challenge |\n * | POST | `/refresh` | Rotate the refresh token |\n * | POST | `/logout` | Revoke the current session |\n * | GET | `/me` | Return the authenticated principal (requires auth) |\n * | POST | `/request-email-verification` | Re-send verification link (requires auth) |\n * | POST | `/verify-email` | Consume an email verification token |\n * | POST | `/request-password-reset` | Send a password reset link |\n * | POST | `/reset-password` | Set a new password using a reset token |\n * | POST | `/mfa/verify` | Complete an MFA challenge after login |\n * | POST | `/2fa/setup` | Begin TOTP 2FA setup (requires auth) |\n * | POST | `/2fa/enable` | Confirm and enable 2FA (requires auth) |\n * | POST | `/2fa/disable` | Disable 2FA (requires auth) |\n * | POST | `/admin/lock/:userId` | Lock an account |\n * | POST | `/admin/unlock/:userId` | Unlock an account |\n * | POST | `/admin/disable/:userId` | Disable an account |\n */\nexport function createIdentityController(\n prefix: string,\n controllerOptions: IdentityControllerOptions = {},\n) {\n const cookieOpts = controllerOptions.cookie;\n\n @Controller(prefix)\n class IdentityController {\n constructor(@Inject(IDENTITY_SERVICE) readonly service: IdentityService) {}\n\n @Post(\"register\")\n async register(\n @Body() body: { email: string; password: string; displayName?: string },\n @Res({ passthrough: true }) res: Response,\n ) {\n try {\n const result = await this.service.register(body);\n return buildAuthResponse(result, cookieOpts, res);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"login\")\n async login(\n @Body() body: { email: string; password: string },\n @Res({ passthrough: true }) res: Response,\n ) {\n try {\n const result = await this.service.login(body);\n return buildLoginResponse(result, cookieOpts, res);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"refresh\")\n async refresh(@Req() req: Request, @Res({ passthrough: true }) res: Response) {\n try {\n const token = readRefreshTokenFromRequest(req, cookieOpts);\n if (!token) {\n throw new UnauthenticatedError(\"Refresh token is missing.\");\n }\n const result = await this.service.refresh(token);\n return buildAuthResponse(result, cookieOpts, res);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"logout\")\n @HttpCode(204)\n async logout(@Req() req: Request, @Res({ passthrough: true }) res: Response) {\n try {\n const token = readRefreshTokenFromRequest(req, cookieOpts);\n if (token) {\n await this.service.logout(token);\n }\n if (cookieOpts) {\n res.clearCookie(resolveCookieName(cookieOpts), { path: cookieOpts.path ?? \"/\" });\n }\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Get(\"me\")\n @UseGuards(IdentityAuthGuard)\n getMe(@Req() req: Request & { identity?: unknown }) {\n return req.identity;\n }\n\n // -------------------------------------------------------------------------\n // Email verification\n // -------------------------------------------------------------------------\n\n @Post(\"request-email-verification\")\n @HttpCode(204)\n @UseGuards(IdentityAuthGuard)\n async requestEmailVerification(@Req() req: Request & { identity?: { userId: string } }) {\n try {\n await this.service.requestEmailVerification(req.identity!.userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"verify-email\")\n @HttpCode(204)\n async verifyEmail(@Body() body: { token?: string }) {\n try {\n if (!body.token) throw new UnauthenticatedError(\"token is required.\");\n await this.service.verifyEmail(body.token);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n // -------------------------------------------------------------------------\n // Password reset\n // -------------------------------------------------------------------------\n\n @Post(\"request-password-reset\")\n @HttpCode(204)\n async requestPasswordReset(@Body() body: { email?: string }) {\n try {\n if (!body.email) throw new UnauthenticatedError(\"email is required.\");\n await this.service.requestPasswordReset(body.email);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"reset-password\")\n @HttpCode(204)\n async resetPassword(@Body() body: { token?: string; newPassword?: string }) {\n try {\n if (!body.token || !body.newPassword)\n throw new UnauthenticatedError(\"token and newPassword are required.\");\n await this.service.resetPassword(body.token, body.newPassword);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n // -------------------------------------------------------------------------\n // Two-factor authentication\n // -------------------------------------------------------------------------\n\n @Post(\"mfa/verify\")\n async verifyMfaChallenge(\n @Body() body: { mfaToken?: string; code?: string },\n @Res({ passthrough: true }) res: Response,\n ) {\n try {\n if (!body.mfaToken || !body.code)\n throw new UnauthenticatedError(\"mfaToken and code are required.\");\n const result = await this.service.verifyMfaChallenge(body.mfaToken, body.code);\n return buildAuthResponse(result, cookieOpts, res);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"2fa/setup\")\n @UseGuards(IdentityAuthGuard)\n async setup2FA(@Req() req: Request & { identity?: { userId: string } }) {\n try {\n return await this.service.setup2FA(req.identity!.userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"2fa/enable\")\n @HttpCode(204)\n @UseGuards(IdentityAuthGuard)\n async enable2FA(\n @Req() req: Request & { identity?: { userId: string } },\n @Body() body: { code?: string },\n ) {\n try {\n if (!body.code) throw new UnauthenticatedError(\"code is required.\");\n await this.service.enable2FA(req.identity!.userId, body.code);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"2fa/disable\")\n @HttpCode(204)\n @UseGuards(IdentityAuthGuard)\n async disable2FA(\n @Req() req: Request & { identity?: { userId: string } },\n @Body() body: { code?: string },\n ) {\n try {\n if (!body.code) throw new UnauthenticatedError(\"code is required.\");\n await this.service.disable2FA(req.identity!.userId, body.code);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n // -------------------------------------------------------------------------\n // Account management (admin)\n // -------------------------------------------------------------------------\n\n @Post(\"admin/lock/:userId\")\n @HttpCode(204)\n async lockAccount(@Param(\"userId\") userId: string) {\n try {\n await this.service.lockAccount(userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"admin/unlock/:userId\")\n @HttpCode(204)\n async unlockAccount(@Param(\"userId\") userId: string) {\n try {\n await this.service.unlockAccount(userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n\n @Post(\"admin/disable/:userId\")\n @HttpCode(204)\n async disableAccount(@Param(\"userId\") userId: string) {\n try {\n await this.service.disableAccount(userId);\n } catch (err) {\n rethrowAsHttp(err);\n }\n }\n }\n\n return IdentityController;\n}\n","/**\n * NestJS integration for `@azlib/identity`.\n *\n * Provides a configurable module, an authentication guard, an authorization guard driven\n * by metadata decorators, and a `@CurrentUser()` param decorator. `@nestjs/common` and\n * `reflect-metadata` are optional peer dependencies — only required when this entry is used.\n */\nimport {\n type CanActivate,\n type DynamicModule,\n type ExecutionContext,\n ForbiddenException,\n Inject,\n Injectable,\n SetMetadata,\n UnauthorizedException,\n createParamDecorator,\n} from \"@nestjs/common\";\nimport { Reflector } from \"@nestjs/core\";\n\nimport type { AuthorizationRequirement } from \"../authorization\";\nimport type { IdentityService } from \"../identity-service\";\nimport type { AuthenticatedIdentity } from \"../types\";\nimport {\n createIdentityController,\n type IdentityControllerOptions,\n} from \"./identity-controller\";\n\n/** Token used to inject the configured {@link IdentityService} in Nest providers. */\nexport const IDENTITY_SERVICE = Symbol.for(\"azlib.identity.service\");\n\n/** Metadata key holding the authorization requirement for a route. */\nexport const IDENTITY_REQUIREMENT = Symbol.for(\"azlib.identity.requirement\");\n\n/**\n * Options for enabling the pre-built REST routes in {@link IdentityModule}.\n */\nexport interface IdentityRoutesOptions extends IdentityControllerOptions {\n /**\n * URL prefix for the built-in controller. Default: `\"auth\"`.\n *\n * The controller is mounted at this prefix relative to the application's global\n * prefix (if any).\n */\n prefix?: string;\n}\n\nexport interface IdentityModuleOptions {\n /** A fully wired identity service (see `createIdentityService`). */\n service: IdentityService;\n /**\n * When set, the module automatically registers a built-in REST controller with all\n * standard auth endpoints (`POST /register`, `POST /login`, `POST /refresh`,\n * `POST /logout`, `GET /me`).\n *\n * Pass `true` to use the defaults (`prefix: \"auth\"`, body-mode refresh tokens), or\n * supply an `IdentityRoutesOptions` object to customise the prefix and cookie behaviour.\n *\n * @example\n * ```ts\n * // Minimal — everything works out of the box\n * IdentityModule.forRoot({ service, routes: true })\n *\n * // With a custom prefix and HttpOnly refresh-token cookie\n * IdentityModule.forRoot({\n * service,\n * routes: { prefix: \"v1/auth\", cookie: { name: \"rt\", secure: true } },\n * })\n * ```\n */\n routes?: true | IdentityRoutesOptions;\n}\n\nexport interface IdentityModuleAsyncOptions {\n imports?: DynamicModule[\"imports\"];\n /** Factory returning the configured identity service. */\n useFactory: (...args: never[]) => IdentityService | Promise<IdentityService>;\n inject?: unknown[];\n /**\n * Same as {@link IdentityModuleOptions.routes} — enable built-in REST routes\n * alongside the async service factory.\n */\n routes?: true | IdentityRoutesOptions;\n}\n\ninterface RequestWithIdentity {\n headers: Record<string, string | string[] | undefined>;\n identity?: AuthenticatedIdentity;\n}\n\nconst extractBearerToken = (req: RequestWithIdentity): string | null => {\n const header = req.headers.authorization;\n const value = Array.isArray(header) ? header[0] : header;\n if (!value || !value.startsWith(\"Bearer \")) return null;\n const token = value.slice(\"Bearer \".length).trim();\n return token.length > 0 ? token : null;\n};\n\n/**\n * Authentication guard: verifies the Bearer access token and attaches the hydrated\n * principal to `request.identity`. Apply with `@UseGuards(IdentityAuthGuard)`.\n */\n@Injectable()\nexport class IdentityAuthGuard implements CanActivate {\n constructor(@Inject(IDENTITY_SERVICE) private readonly service: IdentityService) {}\n\n async canActivate(context: ExecutionContext): Promise<boolean> {\n const req = context.switchToHttp().getRequest<RequestWithIdentity>();\n const token = extractBearerToken(req);\n if (!token) {\n throw new UnauthorizedException(\"Missing bearer token.\");\n }\n try {\n req.identity = await this.service.authenticate(token);\n } catch {\n throw new UnauthorizedException(\"Invalid or expired token.\");\n }\n return true;\n }\n}\n\n/**\n * Authorization guard: enforces the requirement declared by `@RequireAuthorization()`\n * (or `@RequirePermission()`). Must run after {@link IdentityAuthGuard}. Deny-by-default.\n */\n@Injectable()\nexport class IdentityAuthorizationGuard implements CanActivate {\n constructor(\n @Inject(IDENTITY_SERVICE) private readonly service: IdentityService,\n private readonly reflector: Reflector,\n ) {}\n\n async canActivate(context: ExecutionContext): Promise<boolean> {\n const requirement = this.reflector.getAllAndOverride<AuthorizationRequirement | undefined>(\n IDENTITY_REQUIREMENT,\n [context.getHandler(), context.getClass()],\n );\n // No requirement declared: nothing extra to enforce beyond authentication.\n if (!requirement) return true;\n\n const req = context.switchToHttp().getRequest<RequestWithIdentity>();\n const principal = req.identity;\n if (!principal) {\n throw new UnauthorizedException(\"Not authenticated.\");\n }\n const decision = await this.service.authorize(requirement, {\n principal,\n action: requirement.permission ?? \"custom\",\n });\n if (!decision.allowed) {\n throw new ForbiddenException();\n }\n return true;\n }\n}\n\n/** Declares the authorization requirement for a route or controller. */\nexport const RequireAuthorization = (requirement: AuthorizationRequirement) =>\n SetMetadata(IDENTITY_REQUIREMENT, requirement);\n\n/** Convenience: declare a single required permission for a route or controller. */\nexport const RequirePermission = (permission: string) =>\n SetMetadata(IDENTITY_REQUIREMENT, { permission } satisfies AuthorizationRequirement);\n\n/** Param decorator that resolves the authenticated principal from the request. */\nexport const CurrentUser = createParamDecorator(\n (_data: unknown, context: ExecutionContext): AuthenticatedIdentity | undefined => {\n const req = context.switchToHttp().getRequest<RequestWithIdentity>();\n return req.identity;\n },\n);\n\n/**\n * NestJS module exposing the identity service plus guards. Register once at the root:\n *\n * ```ts\n * IdentityModule.forRoot({ service: createIdentityService(config, store) })\n * ```\n */\nfunction buildControllers(routes: true | IdentityRoutesOptions | undefined) {\n if (!routes) return [];\n const routesOpts = routes === true ? {} : routes;\n const prefix = routesOpts.prefix ?? \"auth\";\n const controllerOpts: IdentityControllerOptions = { cookie: routesOpts.cookie };\n return [createIdentityController(prefix, controllerOpts)];\n}\n\nexport class IdentityModule {\n static forRoot(options: IdentityModuleOptions): DynamicModule {\n return {\n module: IdentityModule,\n global: true,\n controllers: buildControllers(options.routes),\n providers: [\n { provide: IDENTITY_SERVICE, useValue: options.service },\n IdentityAuthGuard,\n IdentityAuthorizationGuard,\n ],\n exports: [IDENTITY_SERVICE, IdentityAuthGuard, IdentityAuthorizationGuard],\n };\n }\n\n static forRootAsync(options: IdentityModuleAsyncOptions): DynamicModule {\n return {\n module: IdentityModule,\n global: true,\n imports: options.imports ?? [],\n controllers: buildControllers(options.routes),\n providers: [\n {\n provide: IDENTITY_SERVICE,\n useFactory: options.useFactory,\n inject: options.inject as never[],\n },\n IdentityAuthGuard,\n IdentityAuthorizationGuard,\n ],\n exports: [IDENTITY_SERVICE, IdentityAuthGuard, IdentityAuthorizationGuard],\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,kBAAkB,MAAoC;CAC7D,OAAO,KAAK,QAAQ;AACtB;AAEA,SAAS,cAAc,KAAqB;CAC1C,IAAI,eAAe,eACjB,MAAM,IAAI,cAAc;EAAE,MAAM,IAAI;EAAM,SAAS,IAAI;CAAQ,GAAG,IAAI,UAAwB;CAEhG,MAAM;AACR;AAEA,SAAS,8BACP,KACA,QACA,MAC4D;CAC5D,MAAM,SAAS,OAAO,sBAAsB,QAAQ,IAAI,KAAK,IAAI;CACjE,IAAI,OAAO,kBAAkB,IAAI,GAAG,OAAO,cAAc;EACvD,UAAU,KAAK,YAAY;EAC3B,QAAQ,KAAK,UAAU,QAAQ,IAAI,aAAa;EAChD,UAAU,KAAK,YAAY;EAC3B,MAAM,KAAK,QAAQ;EACnB,QAAQ,KAAK;EACb;CACF,CAAC;CACD,MAAM,EAAE,cAAc,KAAK,uBAAuB,MAAM,GAAG,eAAe;CAC1E,OAAO;AACT;AAEA,SAAS,kBAAkB,QAAoB,YAA8C,KAAe;CAC1G,IAAI,YAAY;EACd,MAAM,SAAS,8BAA8B,KAAK,OAAO,QAAQ,UAAU;EAC3E,OAAO;GAAE,MAAM,OAAO;GAAM;EAAO;CACrC;CACA,OAAO;AACT;AAEA,SAAS,mBACP,QACA,YACA,KACA;CACA,IAAI,cAAc,QAChB,OAAO;CAET,OAAO,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AAA,GAAA,OAAO,gBAAgB,CAAA;;;;AA6B5B,MAAa,wBAAwB,gBACnC,YAAY,sBAAsB,WAAW;;AAG/C,MAAa,qBAAqB,eAChC,YAAY,sBAAsB,EAAE,WAAW,CAAoC;;AAGrF,MAAa,cAAc,sBACxB,OAAgB,YAAiE;CAEhF,OADY,QAAQ,aAAa,CAAC,CAAC,WAC1B,CAAC,CAAC;AACb,CACF;;;;;;;;AASA,SAAS,iBAAiB,QAAkD;CAC1E,IAAI,CAAC,QAAQ,OAAO,CAAC;CACrB,MAAM,aAAa,WAAW,OAAO,CAAC,IAAI;CAG1C,OAAO,CAAC,yBAFO,WAAW,UAAU,QAEK,EADW,QAAQ,WAAW,OACjB,CAAC,CAAC;AAC1D;AAEA,IAAa,iBAAb,MAAa,eAAe;CAC1B,OAAO,QAAQ,SAA+C;EAC5D,OAAO;GACL,QAAQ;GACR,QAAQ;GACR,aAAa,iBAAiB,QAAQ,MAAM;GAC5C,WAAW;IACT;KAAE,SAAS;KAAkB,UAAU,QAAQ;IAAQ;IACvD;IACA;GACF;GACA,SAAS;IAAC;IAAkB;IAAmB;GAA0B;EAC3E;CACF;CAEA,OAAO,aAAa,SAAoD;EACtE,OAAO;GACL,QAAQ;GACR,QAAQ;GACR,SAAS,QAAQ,WAAW,CAAC;GAC7B,aAAa,iBAAiB,QAAQ,MAAM;GAC5C,WAAW;IACT;KACE,SAAS;KACT,YAAY,QAAQ;KACpB,QAAQ,QAAQ;IAClB;IACA;IACA;GACF;GACA,SAAS;IAAC;IAAkB;IAAmB;GAA0B;EAC3E;CACF;AACF"}
|
package/dist/node.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { C as RolePermissionGrant, D as VerificationToken, E as UserRoleAssignment, O as VerificationTokenType, S as Role, T as TotpSetupResult, _ as IdentityUserStatus, a as generateVerificationToken, b as OAuthLinkedAccount, c as AuthResult, d as AuthenticatedIdentity, f as CredentialRecord, g as IdentityUser, h as IdentityEventType, i as CreateVerificationTokenInput, l as AuthSession, m as IdentityEvent, n as CreateIdentityUserInput, o as hashVerificationToken, 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, C as createTokenService, D as IdentityConfigInput, E as IdentityConfig, F as IdentityLogger, H as PolicyRule, I as consoleLogger, L as noopLogger, M as NotificationService, N as PasswordResetParams, O as IdentityOverrides, P as TwoFactorSmsParams, R as resolveLogger, S as TokenService, T as createAuditLogger, 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, j as EmailVerificationParams, 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, w as AuditLogger, x as SessionDeps, y as OAuthTokens, z as AuthorizationContext } from "./errors-
|
|
3
|
-
import { a as RegisterInput, c as registerUser, d as loginUser, f as PasswordHasher, i as RegisterDeps, l as LoginDeps, n as IdentityServiceConfig, o as RegistrationValidationError, p as createPasswordHasher, r as createIdentityService, s as normalizeEmail, t as IdentityService, u as LoginInput } from "./identity-service
|
|
2
|
+
import { A as resolveIdentityConfig, B as AuthorizationDecision, C as createTokenService, D as IdentityConfigInput, E as IdentityConfig, F as IdentityLogger, H as PolicyRule, I as consoleLogger, L as noopLogger, M as NotificationService, N as PasswordResetParams, O as IdentityOverrides, P as TwoFactorSmsParams, R as resolveLogger, S as TokenService, T as createAuditLogger, 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, j as EmailVerificationParams, 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, w as AuditLogger, x as SessionDeps, y as OAuthTokens, z as AuthorizationContext } from "./errors-CBbiRO2n.cjs";
|
|
3
|
+
import { a as RegisterInput, c as registerUser, d as loginUser, f as PasswordHasher, i as RegisterDeps, l as LoginDeps, n as IdentityServiceConfig, o as RegistrationValidationError, p as createPasswordHasher, r as createIdentityService, s as normalizeEmail, t as IdentityService, u as LoginInput } from "./identity-service---OTann1.cjs";
|
|
4
4
|
import { t as identitySchemaModel } from "./index-CpufYgyn.cjs";
|
|
5
|
-
|
|
6
5
|
//#region core/lockout.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Checks whether the user account is currently locked. Throws {@link AccountUnavailableError}
|
package/dist/node.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.cts","names":[],"sources":["../core/lockout.ts","../core/refresh-service.ts","../core/oauth/providers/google.ts","../core/oauth/providers/microsoft.ts","../core/email-verification.ts","../core/password-reset.ts","../core/totp.ts","../core/two-factor.ts","../core/account-admin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.cts","names":[],"sources":["../core/lockout.ts","../core/refresh-service.ts","../core/oauth/providers/google.ts","../core/oauth/providers/microsoft.ts","../core/email-verification.ts","../core/password-reset.ts","../core/totp.ts","../core/two-factor.ts","../core/account-admin.ts"],"mappings":";;;;;;;;;;;;iBAYgB,aACd,MAAM,cACN,QAAQ,eACR,WAAW;;;;;iBAYS,oBACpB,OAAO,eACP,MAAM,cACN,QAAQ,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G;EACf,QAAQ;EACR,OAAO;EACP,OAAO;;;;;;;;;iBAUa,YAAY,MAAM,kBAAkB,iBAAiB;;;;;iBAiBrD,cAAc,MAAM,kBAAkB,iBAAiB;;;;;;iBAoBvD,eAAe,MAAM,kBAAkB,iBAAiB"}
|
package/dist/node.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { C as RolePermissionGrant, D as VerificationToken, E as UserRoleAssignment, O as VerificationTokenType, S as Role, T as TotpSetupResult, _ as IdentityUserStatus, a as generateVerificationToken, b as OAuthLinkedAccount, c as AuthResult, d as AuthenticatedIdentity, f as CredentialRecord, g as IdentityUser, h as IdentityEventType, i as CreateVerificationTokenInput, l as AuthSession, m as IdentityEvent, n as CreateIdentityUserInput, o as hashVerificationToken, 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, C as createTokenService, D as IdentityConfigInput, E as IdentityConfig, F as IdentityLogger, H as PolicyRule, I as consoleLogger, L as noopLogger, M as NotificationService, N as PasswordResetParams, O as IdentityOverrides, P as TwoFactorSmsParams, R as resolveLogger, S as TokenService, T as createAuditLogger, 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, j as EmailVerificationParams, 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, w as AuditLogger, x as SessionDeps, y as OAuthTokens, z as AuthorizationContext } from "./errors-
|
|
3
|
-
import { a as RegisterInput, c as registerUser, d as loginUser, f as PasswordHasher, i as RegisterDeps, l as LoginDeps, n as IdentityServiceConfig, o as RegistrationValidationError, p as createPasswordHasher, r as createIdentityService, s as normalizeEmail, t as IdentityService, u as LoginInput } from "./identity-service-
|
|
2
|
+
import { A as resolveIdentityConfig, B as AuthorizationDecision, C as createTokenService, D as IdentityConfigInput, E as IdentityConfig, F as IdentityLogger, H as PolicyRule, I as consoleLogger, L as noopLogger, M as NotificationService, N as PasswordResetParams, O as IdentityOverrides, P as TwoFactorSmsParams, R as resolveLogger, S as TokenService, T as createAuditLogger, 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, j as EmailVerificationParams, 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, w as AuditLogger, x as SessionDeps, y as OAuthTokens, z as AuthorizationContext } from "./errors-_OcodtdV.mjs";
|
|
3
|
+
import { a as RegisterInput, c as registerUser, d as loginUser, f as PasswordHasher, i as RegisterDeps, l as LoginDeps, n as IdentityServiceConfig, o as RegistrationValidationError, p as createPasswordHasher, r as createIdentityService, s as normalizeEmail, t as IdentityService, u as LoginInput } from "./identity-service-WpOKb0MK.mjs";
|
|
4
4
|
import { t as identitySchemaModel } from "./index-CpufYgyn.mjs";
|
|
5
|
-
|
|
6
5
|
//#region core/lockout.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Checks whether the user account is currently locked. Throws {@link AccountUnavailableError}
|
package/dist/node.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.mts","names":[],"sources":["../core/lockout.ts","../core/refresh-service.ts","../core/oauth/providers/google.ts","../core/oauth/providers/microsoft.ts","../core/email-verification.ts","../core/password-reset.ts","../core/totp.ts","../core/two-factor.ts","../core/account-admin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.mts","names":[],"sources":["../core/lockout.ts","../core/refresh-service.ts","../core/oauth/providers/google.ts","../core/oauth/providers/microsoft.ts","../core/email-verification.ts","../core/password-reset.ts","../core/totp.ts","../core/two-factor.ts","../core/account-admin.ts"],"mappings":";;;;;;;;;;;;iBAYgB,aACd,MAAM,cACN,QAAQ,eACR,WAAW;;;;;iBAYS,oBACpB,OAAO,eACP,MAAM,cACN,QAAQ,eACR,WAAW,OACV;;;;;iBAwBmB,aACpB,OAAO,eACP,MAAM,eACL;;;;UClDc;EACf,QAAQ;EACR,OAAO;EACP,cAAc;EACd,OAAO;;;;;;;;;iBAUa,eACpB,MAAM,aACN,yBACC,QAAQ;;iBAoDW,cACpB,MAAM,KAAK,6DACX,yBACC;;;;UCjDc;;EAEf;;;;;EAKA;;;;EAIA;;;;;;;;;;;iBA+Bc,0BAA0B,QAAQ,oBAAoB;;;;UC3CrD;;EAEf;;;;;EAKA;;;;;;EAMA;;;;;EAKA;;;;;;;;;;;iBA+Bc,6BAA6B,QAAQ,uBAAuB;;;;cCrE/D,+BAA+B;EAC9B,YAAA;;UAKG;EACf,QAAQ;EACR,OAAO;EACP,OAAO;;;;;;;;iBASa,yBACpB,MAAM,uBACN,iBACC;;;;;;iBAiCmB,YACpB,MAAM,uBACN,mBACC;;;;cCrDU,2BAA2B;EAC1B,YAAA;;UAKG;EACf,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,OAAO;;;;;;;;iBASa,qBACpB,MAAM,mBACN,gBACC;;;;;;;iBAsCmB,cACpB,MAAM,mBACN,kBACA,sBACC;;;;iBCtEa,aAAa,QAAQ;;iBAoBrB,aAAa,kBAAkB;;;;;iBAgD/B;;;;iBAOA,aAAa,sBAAsB,MAAK;;;;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