Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit c2e8ce8

Browse files
authored
feat: Log warning if userIdentifierKey is an email (#196)
* feat: Log warning if userIdentifierKey is an email * Cite regex source
1 parent a2dbedc commit c2e8ce8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/seam-connect/client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ export class Seam extends Routes {
110110
throw new Error("userIdentifierKey is required")
111111
}
112112

113+
if (isEmail(options.userIdentifierKey)) {
114+
console.warn(`Using an email for the userIdentifierKey!
115+
This is insecure because an email is common knowledge or easily guessed.
116+
Use something with sufficient entropy know only to the owner of the client session (like a server-generated UUID).`)
117+
}
118+
113119
const getKeyHeaders = (): AxiosRequestHeaders => {
114120
const { publishableKey } = options
115121
if (publishableKey) {
@@ -216,3 +222,7 @@ const getAuthHeaders = ({
216222
"Must provide either clientSessionToken or apiKey (API Key or Access Token with Workspace ID)."
217223
)
218224
}
225+
226+
// SOURCE: https://stackoverflow.com/a/46181
227+
const isEmail = (value: string): boolean =>
228+
/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)

0 commit comments

Comments
 (0)