( sessionId: string, role: CollabRole, expiry: LinkExpiry, createdBy: string )
| 57 | }; |
| 58 | |
| 59 | export function createShareLink( |
| 60 | sessionId: string, |
| 61 | role: CollabRole, |
| 62 | expiry: LinkExpiry, |
| 63 | createdBy: string |
| 64 | ): ShareLink { |
| 65 | const expiryMs = EXPIRY_MS[expiry]; |
| 66 | return { |
| 67 | id: nanoid(12), |
| 68 | sessionId, |
| 69 | role, |
| 70 | createdAt: Date.now(), |
| 71 | expiresAt: expiryMs !== null ? Date.now() + expiryMs : null, |
| 72 | createdBy, |
| 73 | }; |
| 74 | } |
| 75 | |
| 76 | export function isLinkExpired(link: ShareLink): boolean { |
| 77 | return link.expiresAt !== null && Date.now() > link.expiresAt; |
no outgoing calls
no test coverage detected