@protobase/ui 0.21.9 → 0.21.10

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.
@@ -17,7 +17,8 @@ const takeLinkError = () => {
17
17
  };
18
18
  /** The signed-in person's passkeys, two-factor authentication and connected accounts, within what the sign-in policy allows. */
19
19
  const AccountSecurityPage = ({ email }) => {
20
- const { session, signInProviders, linkProvider } = useAuth();
20
+ const { session, signInProviders, socialProviders, linkProvider } = useAuth();
21
+ const linkable = signInProviders.filter((provider) => socialProviders.includes(provider.id));
21
22
  const { account } = session;
22
23
  const [loaded, setLoaded] = useState();
23
24
  const [error, setError] = useState();
@@ -61,11 +62,11 @@ const AccountSecurityPage = ({ email }) => {
61
62
  onNewBackupCodes: (password) => account.newBackupCodes(password),
62
63
  onChanged: reload
63
64
  }),
64
- signInProviders.length > 0 && /* @__PURE__ */ jsx(SignInProvidersSection, {
65
- providers: signInProviders,
65
+ linkable.length > 0 && /* @__PURE__ */ jsx(SignInProvidersSection, {
66
+ providers: linkable,
66
67
  linked: loaded.linked,
67
68
  onConnect: linkProvider,
68
- error: linkError && providerMessage(linkError, signInProviders.length === 1 ? signInProviders[0].name : "the provider")
69
+ error: linkError && providerMessage(linkError, linkable.length === 1 ? linkable[0].name : "the provider")
69
70
  })
70
71
  ] }) : error ? /* @__PURE__ */ jsx("p", {
71
72
  role: "alert",
@@ -49,7 +49,8 @@ const providerMessages = {
49
49
  account_not_linked: (name) => `Your ${name} account is not linked to your account here. Sign in another way, then connect ${name} on the Sign-in & security page.`,
50
50
  account_already_linked_to_different_user: (name) => `This ${name} account is linked to someone else here already.`,
51
51
  unable_to_link_account: (name) => `Your ${name} account could not be linked. Try again.`,
52
- access_denied: (name) => `${name} did not let you in, or you cancelled.`
52
+ access_denied: (name) => `${name} did not let you in, or you cancelled.`,
53
+ EMAIL_DOMAIN_NOT_ALLOWED: (name) => `${name} signed you in with an address this app does not accept from it. Sign in another way.`
53
54
  };
54
55
  /** Why signing in or linking with the provider `name` did not go through, from the code it came back with. */
55
56
  const providerMessage = (code, name) => providerMessages[code]?.(name) ?? `Signing in with ${name} did not go through. Try again.`;
@@ -18,6 +18,7 @@ const AuthProvider = ({ session: given, children }) => {
18
18
  const [passkeyDomains, setPasskeyDomains] = useState([]);
19
19
  const [socialProviders, setSocialProviders] = useState([]);
20
20
  const [platformSignIn, setPlatformSignIn] = useState();
21
+ const [samlProviders, setSamlProviders] = useState([]);
21
22
  const [staffSignIn, setStaffSignIn] = useState();
22
23
  const [organizations, setOrganizations] = useState();
23
24
  const [anonymous, setAnonymous] = useState(false);
@@ -52,6 +53,7 @@ const AuthProvider = ({ session: given, children }) => {
52
53
  setPasskeyDomains(status.passkeyDomains ?? []);
53
54
  setSocialProviders(status.socialProviders);
54
55
  setPlatformSignIn(status.platformSignIn);
56
+ setSamlProviders(status.samlProviders);
55
57
  setStaffSignIn(status.staffSignIn);
56
58
  setOrganizations(status.organizations);
57
59
  setAnonymous(Boolean(status.anonymous));
@@ -73,10 +75,10 @@ const AuthProvider = ({ session: given, children }) => {
73
75
  canSignUp,
74
76
  passkeyDomains,
75
77
  socialProviders,
76
- signInProviders: socialProviders.map((id) => ({
78
+ signInProviders: [...socialProviders.map((id) => ({
77
79
  id,
78
80
  name: providerName(id, platformSignIn)
79
- })),
81
+ })), ...samlProviders],
80
82
  staffSignIn,
81
83
  ...organizations && { organizations },
82
84
  markSignedOut,
@@ -100,7 +102,9 @@ const AuthProvider = ({ session: given, children }) => {
100
102
  signInWithPasskey: async (domain) => enter(await session.signInWithPasskey(domain)),
101
103
  verifyTwoFactor: async (input) => enter(await session.verifyTwoFactor(input)),
102
104
  signInSocial: async (provider) => {
103
- window.location.assign(await session.signInSocial(provider, new URL(withoutSignInLink(window.location.href), window.location.href).href));
105
+ const callbackURL = new URL(withoutSignInLink(window.location.href), window.location.href).href;
106
+ const saml = samlProviders.some((candidate) => candidate.id === provider);
107
+ window.location.assign(await (saml ? session.signInSaml(provider, callbackURL) : session.signInSocial(provider, callbackURL)));
104
108
  },
105
109
  linkProvider: async (provider) => {
106
110
  window.location.assign(await session.account.linkProvider(provider, new URL(withoutSignInLink(window.location.href), window.location.href).href));
@@ -122,6 +126,7 @@ const AuthProvider = ({ session: given, children }) => {
122
126
  passkeyDomains,
123
127
  socialProviders,
124
128
  platformSignIn,
129
+ samlProviders,
125
130
  staffSignIn,
126
131
  organizations,
127
132
  anonymous,
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.21.9";
2
+ var version = "0.21.10";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };