@augmenting-integrations/auth 8.4.1 → 8.6.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/dist/client.cjs CHANGED
@@ -21,14 +21,11 @@ __export(client_exports, {
21
21
  AppUserProvider: () => import_AppUserProvider.AppUserProvider,
22
22
  ImpersonationBanner: () => import_ImpersonationBanner.ImpersonationBanner,
23
23
  SignOutButton: () => import_SignOutButton.SignOutButton,
24
- TENANT_GLOBAL_KEY: () => import_tenant.TENANT_GLOBAL_KEY,
25
- TenantProvider: () => import_tenant.TenantProvider,
26
24
  UserMenu: () => import_UserMenu.UserMenu,
27
25
  useAppUser: () => import_AppUserProvider.useAppUser,
28
26
  useDbAppUser: () => import_AppUserProvider.useDbAppUser,
29
27
  useImpersonation: () => import_use_impersonation.useImpersonation,
30
- useRole: () => import_AppUserProvider.useRole,
31
- useTenant: () => import_tenant.useTenant
28
+ useRole: () => import_AppUserProvider.useRole
32
29
  });
33
30
  module.exports = __toCommonJS(client_exports);
34
31
  var import_AppUserProvider = require("./client/AppUserProvider.js");
@@ -36,19 +33,15 @@ var import_UserMenu = require("./client/UserMenu.js");
36
33
  var import_SignOutButton = require("./client/SignOutButton.js");
37
34
  var import_ImpersonationBanner = require("./client/ImpersonationBanner.js");
38
35
  var import_use_impersonation = require("./client/use-impersonation.js");
39
- var import_tenant = require("./client/tenant.js");
40
36
  // Annotate the CommonJS export names for ESM import in node:
41
37
  0 && (module.exports = {
42
38
  AppUserProvider,
43
39
  ImpersonationBanner,
44
40
  SignOutButton,
45
- TENANT_GLOBAL_KEY,
46
- TenantProvider,
47
41
  UserMenu,
48
42
  useAppUser,
49
43
  useDbAppUser,
50
44
  useImpersonation,
51
- useRole,
52
- useTenant
45
+ useRole
53
46
  });
54
47
  //# sourceMappingURL=client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["export {\n AppUserProvider,\n useAppUser,\n useDbAppUser,\n useRole,\n type AppUserState,\n type DbAppUser,\n type SessionAppUser,\n} from \"./client/AppUserProvider.js\";\nexport { UserMenu } from \"./client/UserMenu.js\";\nexport { SignOutButton } from \"./client/SignOutButton.js\";\nexport { ImpersonationBanner } from \"./client/ImpersonationBanner.js\";\nexport {\n useImpersonation,\n type EffectiveUser,\n type ImpersonatedBy,\n type MeResponse,\n} from \"./client/use-impersonation.js\";\nexport {\n TenantProvider,\n useTenant,\n TENANT_GLOBAL_KEY,\n type TenantPublicConfig,\n type TenantRole,\n} from \"./client/tenant.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAQO;AACP,sBAAyB;AACzB,2BAA8B;AAC9B,iCAAoC;AACpC,+BAKO;AACP,oBAMO;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["export {\n AppUserProvider,\n useAppUser,\n useDbAppUser,\n useRole,\n type AppUserState,\n type DbAppUser,\n type SessionAppUser,\n} from \"./client/AppUserProvider.js\";\nexport { UserMenu } from \"./client/UserMenu.js\";\nexport { SignOutButton } from \"./client/SignOutButton.js\";\nexport { ImpersonationBanner } from \"./client/ImpersonationBanner.js\";\nexport {\n useImpersonation,\n type EffectiveUser,\n type ImpersonatedBy,\n type MeResponse,\n} from \"./client/use-impersonation.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAQO;AACP,sBAAyB;AACzB,2BAA8B;AAC9B,iCAAoC;AACpC,+BAKO;","names":[]}
package/dist/client.d.ts CHANGED
@@ -3,5 +3,4 @@ export { UserMenu } from "./client/UserMenu.js";
3
3
  export { SignOutButton } from "./client/SignOutButton.js";
4
4
  export { ImpersonationBanner } from "./client/ImpersonationBanner.js";
5
5
  export { useImpersonation, type EffectiveUser, type ImpersonatedBy, type MeResponse, } from "./client/use-impersonation.js";
6
- export { TenantProvider, useTenant, TENANT_GLOBAL_KEY, type TenantPublicConfig, type TenantRole, } from "./client/tenant.js";
7
6
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,YAAY,EACZ,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,cAAc,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,UAAU,GAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,UAAU,GAChB,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,YAAY,EACZ,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,cAAc,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,UAAU,GAChB,MAAM,+BAA+B,CAAC"}
package/dist/client.js CHANGED
@@ -10,22 +10,14 @@ import { ImpersonationBanner } from "./client/ImpersonationBanner.js";
10
10
  import {
11
11
  useImpersonation
12
12
  } from "./client/use-impersonation.js";
13
- import {
14
- TenantProvider,
15
- useTenant,
16
- TENANT_GLOBAL_KEY
17
- } from "./client/tenant.js";
18
13
  export {
19
14
  AppUserProvider,
20
15
  ImpersonationBanner,
21
16
  SignOutButton,
22
- TENANT_GLOBAL_KEY,
23
- TenantProvider,
24
17
  UserMenu,
25
18
  useAppUser,
26
19
  useDbAppUser,
27
20
  useImpersonation,
28
- useRole,
29
- useTenant
21
+ useRole
30
22
  };
31
23
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["export {\n AppUserProvider,\n useAppUser,\n useDbAppUser,\n useRole,\n type AppUserState,\n type DbAppUser,\n type SessionAppUser,\n} from \"./client/AppUserProvider.js\";\nexport { UserMenu } from \"./client/UserMenu.js\";\nexport { SignOutButton } from \"./client/SignOutButton.js\";\nexport { ImpersonationBanner } from \"./client/ImpersonationBanner.js\";\nexport {\n useImpersonation,\n type EffectiveUser,\n type ImpersonatedBy,\n type MeResponse,\n} from \"./client/use-impersonation.js\";\nexport {\n TenantProvider,\n useTenant,\n TENANT_GLOBAL_KEY,\n type TenantPublicConfig,\n type TenantRole,\n} from \"./client/tenant.js\";\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["export {\n AppUserProvider,\n useAppUser,\n useDbAppUser,\n useRole,\n type AppUserState,\n type DbAppUser,\n type SessionAppUser,\n} from \"./client/AppUserProvider.js\";\nexport { UserMenu } from \"./client/UserMenu.js\";\nexport { SignOutButton } from \"./client/SignOutButton.js\";\nexport { ImpersonationBanner } from \"./client/ImpersonationBanner.js\";\nexport {\n useImpersonation,\n type EffectiveUser,\n type ImpersonatedBy,\n type MeResponse,\n} from \"./client/use-impersonation.js\";\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,OAIK;","names":[]}
@@ -1,10 +1,17 @@
1
1
  import { type DefaultSession, type Session } from "next-auth";
2
- import type { TenantServerConfig } from "../tenant-types.js";
2
+ import type { TenantServerConfig } from "@augmenting-integrations/platform/server";
3
3
  declare module "next-auth" {
4
4
  interface Session {
5
5
  user: {
6
6
  groups: string[];
7
7
  } & DefaultSession["user"];
8
+ /**
9
+ * Cognito access token, preserved on the session for spoke-side
10
+ * Cognito user-pool calls (TOTP setup/verify, ChangePassword). Only
11
+ * present after a fresh OAuth login on the apex; absent on cookie-only
12
+ * sessions in spokes that never sat in front of the OAuth dance.
13
+ */
14
+ accessToken?: string;
8
15
  }
9
16
  interface User {
10
17
  groups?: string[];
@@ -14,7 +21,7 @@ export type CreateAuthOptions = {
14
21
  /**
15
22
  * Full tenant configuration. Provides apex/cookieDomain/parentDomain/
16
23
  * appDomain/role + cognito client id + issuer + allowed admin emails.
17
- * Load via `loadTenantConfig()` from `@augmenting-integrations/tenant/server`.
24
+ * Load via `loadTenantConfig()` from `@augmenting-integrations/platform/server`.
18
25
  */
19
26
  tenant: TenantServerConfig;
20
27
  /** Path prefixes that require an authenticated session. */
@@ -38,6 +45,28 @@ export type CreateAuthOptions = {
38
45
  signInPage?: string;
39
46
  /** Override prod/dev detection. Default reads NODE_ENV. */
40
47
  isProd?: boolean;
48
+ /**
49
+ * App-level access policy. When set, signed-in users whose Cognito
50
+ * identity groups don't intersect `requiredIdentityGroups` are
51
+ * redirected to `forbiddenPage` (default: the apex /login page with
52
+ * `?error=app_forbidden&app=<slug>`). Sourced from
53
+ * `app.manifest.json#access`.
54
+ *
55
+ * `requiredIdentityGroups: []` means all authenticated users may
56
+ * enter; access enforcement is a no-op (same as omitting `appAccess`
57
+ * entirely). This is NOT product-level authorization; it gates entry
58
+ * to the entire app surface, mirroring the registry field of the
59
+ * same name.
60
+ */
61
+ appAccess?: {
62
+ requiredIdentityGroups: string[];
63
+ /**
64
+ * Optional override. Default:
65
+ * - apex: "/login?error=app_forbidden&app=<slug>"
66
+ * - spoke: "https://<apex>/login?error=app_forbidden&app=<slug>"
67
+ */
68
+ forbiddenPage?: string;
69
+ };
41
70
  };
42
71
  export declare class AuthError extends Error {
43
72
  code: "unauthenticated" | "forbidden";
@@ -1 +1 @@
1
- {"version":3,"file":"createAuth.d.ts","sourceRoot":"","sources":["../../src/server/createAuth.ts"],"names":[],"mappings":"AAkBA,OAAiB,EACf,KAAK,cAAc,EAEnB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAM7D,OAAO,QAAQ,WAAW,CAAC;IACzB,UAAU,OAAO;QACf,IAAI,EAAE;YACJ,MAAM,EAAE,MAAM,EAAE,CAAC;SAClB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;KAC5B;IACD,UAAU,IAAI;QACZ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;KACnB;CACF;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;OAIG;IACH,MAAM,EAAE,kBAAkB,CAAC;IAC3B,2DAA2D;IAC3D,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,CAAC;CA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;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE;QACV,sBAAsB,EAAE,MAAM,EAAE,CAAC;QACjC;;;;WAIG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACH,CAAC;AAIF,qBAAa,SAAU,SAAQ,KAAK;IACf,IAAI,EAAE,iBAAiB,GAAG,WAAW;gBAArC,IAAI,EAAE,iBAAiB,GAAG,WAAW;CAIzD;AAID,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,EAAE,CAE3E;AAED,+CAA+C;AAC/C,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAInF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EACnC,GAAG,KAAK,EAAE,MAAM,EAAE,GACjB,IAAI,CAKN;AA+BD,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,sCAwKjD;AAED,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,82 @@
1
+ import "server-only";
2
+ import type { Session } from "next-auth";
3
+ type AuthFn = () => Promise<Session | null>;
4
+ export type InvitationSendAppUser = {
5
+ id: bigint | string | number;
6
+ name: string;
7
+ role: string;
8
+ };
9
+ export type InvitationCreateInput = {
10
+ token: string;
11
+ email: string;
12
+ inviter_id: bigint | string | number;
13
+ intended_role: string;
14
+ parent_id: bigint | string | number | null;
15
+ expires_at: Date;
16
+ };
17
+ export type InvitationCreatedRow = {
18
+ id: bigint | string | number;
19
+ expires_at: Date;
20
+ };
21
+ export type InvitationSendDb = {
22
+ user: {
23
+ findUnique: (args: {
24
+ where: {
25
+ email: string;
26
+ };
27
+ }) => Promise<unknown | null>;
28
+ };
29
+ invitation: {
30
+ create: (args: {
31
+ data: InvitationCreateInput;
32
+ }) => Promise<InvitationCreatedRow>;
33
+ };
34
+ };
35
+ export type RenderedEmail = {
36
+ subject: string;
37
+ html: string;
38
+ text?: string;
39
+ };
40
+ export type InvitationEmailContext = {
41
+ inviterName: string;
42
+ inviteeEmail: string;
43
+ intendedRole: string;
44
+ invitationUrl: string;
45
+ expiresAt: Date;
46
+ appDisplayName: string;
47
+ };
48
+ export type CreateInvitationSendHandlersOptions = {
49
+ auth: AuthFn;
50
+ getDb: () => Promise<InvitationSendDb>;
51
+ getOrCreateAppUser: (session: Session) => Promise<InvitationSendAppUser>;
52
+ /** Returns true if the caller's role may invite. */
53
+ canInvite: (callerRole: string) => boolean;
54
+ /**
55
+ * Derive the new invitation's parent_id given the caller + the optional
56
+ * client override. Return null for a flat-tree spoke.
57
+ */
58
+ resolveInviteScope: (caller: InvitationSendAppUser, overrideParentId: bigint | null) => bigint | string | number | null;
59
+ /** Optional allow-list. If provided, body.role must be one of these. */
60
+ allowedRoles?: string[];
61
+ generateInvitationToken: () => string;
62
+ invitationExpiresAt: () => Date;
63
+ buildInvitationUrl: (token: string, origin: string) => string;
64
+ renderInvitationEmail: (ctx: InvitationEmailContext) => RenderedEmail;
65
+ sendEmail: (args: {
66
+ to: string;
67
+ subject: string;
68
+ html: string;
69
+ text?: string;
70
+ }) => Promise<void>;
71
+ /** Used as fallback origin if APP_DOMAIN env is unset. */
72
+ appDomainEnv?: string;
73
+ /** Issuer name shown in the invitation email. */
74
+ appDisplayName: string;
75
+ };
76
+ export declare function createInvitationSendHandlers(opts: CreateInvitationSendHandlersOptions): {
77
+ send: {
78
+ POST: (request: Request) => Promise<Response>;
79
+ };
80
+ };
81
+ export {};
82
+ //# sourceMappingURL=invitations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["../../src/server/invitations.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwBzC,KAAK,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3C,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7B,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE;QACJ,UAAU,EAAE,CAAC,IAAI,EAAE;YAAE,KAAK,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;KAC7E,CAAC;IACF,UAAU,EAAE;QACV,MAAM,EAAE,CAAC,IAAI,EAAE;YAAE,IAAI,EAAE,qBAAqB,CAAA;SAAE,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;KAClF,CAAC;CACH,CAAC;AAEF,MA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KACf,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAUF,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,mCAAmC;;wBAE5D,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;EA2GpD"}
@@ -0,0 +1,64 @@
1
+ import "server-only";
2
+ import type { Session } from "next-auth";
3
+ type AuthFn = () => Promise<Session | null>;
4
+ export type SettingsAppUser = {
5
+ id: bigint | string | number;
6
+ };
7
+ export type SettingsDb = {
8
+ user: {
9
+ update: (args: Record<string, unknown>) => Promise<unknown>;
10
+ };
11
+ };
12
+ export type CognitoOps = {
13
+ associateSoftwareToken: (args: {
14
+ accessToken: string;
15
+ }) => Promise<{
16
+ secretCode: string;
17
+ }>;
18
+ verifySoftwareToken: (args: {
19
+ accessToken: string;
20
+ code: string;
21
+ }) => Promise<{
22
+ status: string;
23
+ }>;
24
+ setUserMfaPreference: (args: {
25
+ accessToken: string;
26
+ enabled: boolean;
27
+ }) => Promise<void>;
28
+ changePassword: (args: {
29
+ accessToken: string;
30
+ previousPassword: string;
31
+ proposedPassword: string;
32
+ }) => Promise<void>;
33
+ buildOtpAuthUri: (args: {
34
+ secret: string;
35
+ accountName: string;
36
+ issuer: string;
37
+ }) => string;
38
+ };
39
+ export type CreateSettingsHandlersOptions = {
40
+ auth: AuthFn;
41
+ getDb: () => Promise<SettingsDb>;
42
+ getOrCreateAppUser: (session: Session) => Promise<SettingsAppUser>;
43
+ cognito: CognitoOps;
44
+ /** OTP issuer name shown in authenticator apps. */
45
+ appDisplayName: string;
46
+ /** Optional QR data URL generator -- spoke supplies `qrcode` if desired. */
47
+ generateQrDataUrl?: (otpAuthUri: string) => Promise<string>;
48
+ };
49
+ export declare function createSettingsHandlers(opts: CreateSettingsHandlersOptions): {
50
+ passwordChange: {
51
+ POST: (request: Request) => Promise<Response>;
52
+ };
53
+ twoFactorSetup: {
54
+ POST: () => Promise<Response>;
55
+ };
56
+ twoFactorVerify: {
57
+ POST: (request: Request) => Promise<Response>;
58
+ };
59
+ twoFactorDisable: {
60
+ POST: () => Promise<Response>;
61
+ };
62
+ };
63
+ export {};
64
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/server/settings.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBzC,KAAK,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;KAC7D,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,sBAAsB,EAAE,CAAC,IAAI,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;QACjE,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,mBAAmB,EAAE,CAAC,IAAI,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;QAC5E,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,oBAAoB,EAAE,CAAC,IAAI,EAAE;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,OAAO,CAAC;KAClB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,cAAc,EAAE,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