@authyon/server 0.2.0-beta.16 → 0.2.0-beta.17

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/bff.cjs CHANGED
@@ -693,6 +693,16 @@ function createBffSession(options) {
693
693
  const tokens = await options.provider.verifyTwoFactor(input);
694
694
  return finishLogin(tokens, void 0, input.sessionPersistence);
695
695
  }),
696
+ /** Same guards as `verifyTwoFactor`; never creates a session or sets a cookie. */
697
+ resendTwoFactorEmail: handler("POST", async (request) => {
698
+ await assertSignedOut(request);
699
+ if (!options.provider.resendTwoFactorEmail) {
700
+ throw new BffSessionError("provider.unsupported_operation", 501);
701
+ }
702
+ const challengeToken = inputString(await readBffBody(request), "challengeToken");
703
+ await options.provider.resendTwoFactorEmail(challengeToken);
704
+ return http.response(null, { status: 204 });
705
+ }),
696
706
  session: handler(
697
707
  "GET",
698
708
  async (request) => http.response(publicSession(await manager.read(requiredSessionId(request))))
@@ -1013,6 +1023,13 @@ function createAuthyonBffProvider(options) {
1013
1023
  await http.request("/auth/2fa/verify", { method: "POST", headers, body: verification })
1014
1024
  );
1015
1025
  },
1026
+ async resendTwoFactorEmail(challengeToken) {
1027
+ await http.request("/auth/2fa/resend-email", {
1028
+ method: "POST",
1029
+ headers,
1030
+ body: { challengeToken }
1031
+ });
1032
+ },
1016
1033
  async refresh(refreshToken) {
1017
1034
  return readTokens(
1018
1035
  await http.request("/auth/refresh", { method: "POST", headers, body: { refreshToken } })
package/dist/bff.d.cts CHANGED
@@ -45,6 +45,11 @@ interface BffChallenge {
45
45
  interface BffAuthProvider {
46
46
  login(input: BffLoginInput): Promise<BffTokens | BffChallenge>;
47
47
  verifyTwoFactor(input: BffVerifyTwoFactorInput): Promise<BffTokens>;
48
+ /**
49
+ * Resends the e-mail code of an in-flight login challenge. Optional so existing
50
+ * custom providers keep compiling; without it the handler answers 501.
51
+ */
52
+ resendTwoFactorEmail?(challengeToken: string): Promise<void>;
48
53
  refresh(refreshToken: string): Promise<BffTokens>;
49
54
  logout(refreshToken: string): Promise<void>;
50
55
  switchOrganization(accessToken: string, slug: string): Promise<BffTokens>;
@@ -90,6 +95,8 @@ declare class BffSessionError extends Error {
90
95
  declare function createBffSession(options: BffSessionOptions): {
91
96
  login: (request: Request) => Promise<Response>;
92
97
  verifyTwoFactor: (request: Request) => Promise<Response>;
98
+ /** Same guards as `verifyTwoFactor`; never creates a session or sets a cookie. */
99
+ resendTwoFactorEmail: (request: Request) => Promise<Response>;
93
100
  session: (request: Request) => Promise<Response>;
94
101
  switchOrganization: (request: Request) => Promise<Response>;
95
102
  logout: (request: Request) => Promise<Response>;
package/dist/bff.d.ts CHANGED
@@ -45,6 +45,11 @@ interface BffChallenge {
45
45
  interface BffAuthProvider {
46
46
  login(input: BffLoginInput): Promise<BffTokens | BffChallenge>;
47
47
  verifyTwoFactor(input: BffVerifyTwoFactorInput): Promise<BffTokens>;
48
+ /**
49
+ * Resends the e-mail code of an in-flight login challenge. Optional so existing
50
+ * custom providers keep compiling; without it the handler answers 501.
51
+ */
52
+ resendTwoFactorEmail?(challengeToken: string): Promise<void>;
48
53
  refresh(refreshToken: string): Promise<BffTokens>;
49
54
  logout(refreshToken: string): Promise<void>;
50
55
  switchOrganization(accessToken: string, slug: string): Promise<BffTokens>;
@@ -90,6 +95,8 @@ declare class BffSessionError extends Error {
90
95
  declare function createBffSession(options: BffSessionOptions): {
91
96
  login: (request: Request) => Promise<Response>;
92
97
  verifyTwoFactor: (request: Request) => Promise<Response>;
98
+ /** Same guards as `verifyTwoFactor`; never creates a session or sets a cookie. */
99
+ resendTwoFactorEmail: (request: Request) => Promise<Response>;
93
100
  session: (request: Request) => Promise<Response>;
94
101
  switchOrganization: (request: Request) => Promise<Response>;
95
102
  logout: (request: Request) => Promise<Response>;
package/dist/bff.js CHANGED
@@ -533,6 +533,16 @@ function createBffSession(options) {
533
533
  const tokens = await options.provider.verifyTwoFactor(input);
534
534
  return finishLogin(tokens, void 0, input.sessionPersistence);
535
535
  }),
536
+ /** Same guards as `verifyTwoFactor`; never creates a session or sets a cookie. */
537
+ resendTwoFactorEmail: handler("POST", async (request) => {
538
+ await assertSignedOut(request);
539
+ if (!options.provider.resendTwoFactorEmail) {
540
+ throw new BffSessionError("provider.unsupported_operation", 501);
541
+ }
542
+ const challengeToken = inputString(await readBffBody(request), "challengeToken");
543
+ await options.provider.resendTwoFactorEmail(challengeToken);
544
+ return http.response(null, { status: 204 });
545
+ }),
536
546
  session: handler(
537
547
  "GET",
538
548
  async (request) => http.response(publicSession(await manager.read(requiredSessionId(request))))
@@ -648,6 +658,13 @@ function createAuthyonBffProvider(options) {
648
658
  await http.request("/auth/2fa/verify", { method: "POST", headers, body: verification })
649
659
  );
650
660
  },
661
+ async resendTwoFactorEmail(challengeToken) {
662
+ await http.request("/auth/2fa/resend-email", {
663
+ method: "POST",
664
+ headers,
665
+ body: { challengeToken }
666
+ });
667
+ },
651
668
  async refresh(refreshToken) {
652
669
  return readTokens(
653
670
  await http.request("/auth/refresh", { method: "POST", headers, body: { refreshToken } })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authyon/server",
3
- "version": "0.2.0-beta.16",
3
+ "version": "0.2.0-beta.17",
4
4
  "description": "Authyon SDK for backends — server-to-server organization/member management and access-token verification.",
5
5
  "license": "MIT",
6
6
  "type": "module",