@8wave/ai-elements 0.125.0-beta.44 → 0.125.0-beta.46

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.
@@ -1,4 +1,15 @@
1
- export declare function handleOrganizationAutoJoin(userId: string, userEmail: string, emailVerified: boolean): Promise<void>;
1
+ type Account = {
2
+ providerId: string;
3
+ idToken?: string | null;
4
+ accessToken?: string | null;
5
+ };
6
+ /**
7
+ * Auto-joins a user to the organization one of their identities maps to.
8
+ * `account` is the one the caller just created, when it has it: it names the
9
+ * identity that triggered the call, which matters for a user with more than
10
+ * one social account.
11
+ */
12
+ export declare function handleOrganizationAutoJoin(userId: string, userEmail: string, emailVerified: boolean, account?: Account): Promise<void>;
2
13
  /**
3
14
  * Auto-join a user to the organization mapped to their identity provider, if
4
15
  * any. Shared by the interactive login hook (which derives provider + org id
@@ -13,3 +24,4 @@ export declare function joinOrganizationForProvider(params: {
13
24
  providerId: string;
14
25
  providerOrgId: string;
15
26
  }): Promise<void>;
27
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Prepares a user whose email was never verified for the social account
3
+ * (Microsoft, Google) about to be linked to it, and answers whether the link
4
+ * may go ahead.
5
+ *
6
+ * A social sign-in whose email matches an existing user links to it, and the
7
+ * link marks the email verified (packages/auth/src/index.ts,
8
+ * `requireLocalEmailVerified: false`). If that user registered with a password
9
+ * and never confirmed the address, the password may not be theirs: anyone can
10
+ * sign up with someone else's email and wait. It could not sign in while the
11
+ * email was unverified, but it would start working the moment the owner's
12
+ * social sign-in verified it. So the password goes first, and the account is
13
+ * left to whoever proved the address. The owner can set a password again
14
+ * through the reset link, which creates the credential account when there is
15
+ * none.
16
+ *
17
+ * Removing the password is enough only while the account was never used,
18
+ * which is the rule since sign-in requires a verified email. An unverified
19
+ * password account with a session, a passkey, an API key or a second factor
20
+ * dates from before that rule, and whoever holds those would keep them after
21
+ * the link: the link is refused instead, as better-auth refused it before.
22
+ *
23
+ * The password is removed in one statement that checks the email is still
24
+ * unverified, so a confirmation link clicked at the same moment does not lose
25
+ * a password that has just become valid. Nothing here shares a transaction
26
+ * with better-auth (the Drizzle adapter runs without one): if the link then
27
+ * fails, the password stays removed, which costs nothing because it could not
28
+ * sign in.
29
+ */
30
+ export declare function admitSocialLink(userId: string): Promise<boolean>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8wave/ai-elements",
3
3
  "private": false,
4
- "version": "0.125.0-beta.44",
4
+ "version": "0.125.0-beta.46",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite --port 8082 --open --host",