Skip to content

Commit

Permalink
feat(link-adapter): allow configuration of magic link expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
omikader committed Feb 14, 2024
1 parent 36f11a9 commit 974699d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-drinks-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sst": patch
---

link-adapter: allow configuration of magic link expiry
4 changes: 3 additions & 1 deletion packages/sst/src/node/auth/adapter/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { createAdapter } from "./adapter.js";
import { getPrivateKey, getPublicKey } from "../auth.js";

interface LinkConfig {
expiresInMinutes?: number;
onLink: (
link: string,
claims: Record<string, any>
Expand All @@ -22,8 +23,9 @@ interface LinkConfig {

export const LinkAdapter = /* @__PURE__ */ createAdapter(
(config: LinkConfig) => {
const { expiresInMinutes = 10 } = config;
const signer = createSigner({
expiresIn: 1000 * 60 * 10,
expiresIn: 1000 * 60 * expiresInMinutes,
key: getPrivateKey(),
algorithm: "RS512",
});
Expand Down
4 changes: 3 additions & 1 deletion packages/sst/src/node/future/auth/adapter/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { Adapter } from "./adapter.js";

export function LinkAdapter(config: {
expiresInMinutes?: number;
onLink: (
link: string,
claims: Record<string, any>
Expand All @@ -21,8 +22,9 @@ export function LinkAdapter(config: {
const key = Config[process.env.AUTH_ID + "PrivateKey"];
// @ts-expect-error
const publicKey = Config[process.env.AUTH_ID + "PublicKey"];
const { expiresInMinutes = 10 } = config;
const signer = createSigner({
expiresIn: 1000 * 60 * 10,
expiresIn: 1000 * 60 * expiresInMinutes,
key,
algorithm: "RS512",
});
Expand Down

0 comments on commit 974699d

Please sign in to comment.