@protobase/client 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.
@@ -23,11 +23,16 @@ export type PlatformSignIn = {
23
23
  provider: string;
24
24
  name: string;
25
25
  };
26
+ /** A SAML identity provider of the app: its id, for `signInSaml`, and the name to show. */
27
+ export type SamlSignIn = {
28
+ id: string;
29
+ name: string;
30
+ };
26
31
  /**
27
32
  * `needsAdmin` while no user exists yet; `signInMethods` the ways to sign in the server's policy leaves on;
28
33
  * `passwordReset` when the server can email reset links; `signUp` when anyone can make their own account (see
29
34
  * `sendSignUpCode`); `socialProviders` the ids of the sign-in providers, for example
30
- * `github`; `platformSignIn` the one of them the platform adds; `staffSignIn` the operator provider's name when its staff
35
+ * `github`; `platformSignIn` the one of them the platform adds; `samlProviders` the app's SAML identity providers; `staffSignIn` the operator provider's name when its staff
31
36
  * can sign in as people; `organizations` when the app has them; `anonymous` when visitors may browse what the project's
32
37
  * anonymous role reads without signing in; `plugins` those the app loads before anyone signs in.
33
38
  */
@@ -38,6 +43,7 @@ export type SetupStatus = {
38
43
  signUp?: boolean;
39
44
  socialProviders: string[];
40
45
  platformSignIn?: PlatformSignIn;
46
+ samlProviders: SamlSignIn[];
41
47
  staffSignIn?: string;
42
48
  /**
43
49
  * When people have passkeys made for more than one of the app's domains: those domains, the one new passkeys are made
package/dist/auth.d.ts CHANGED
@@ -33,6 +33,12 @@ export declare const createAuthSession: (options?: AuthSessionOptions) => {
33
33
  * `signup_disabled` when no account here has that provider account or its address.
34
34
  */
35
35
  signInSocial: (provider: string, callbackURL: string) => Promise<string>;
36
+ /**
37
+ * Starts sign-in with one of the app's SAML identity providers by its id: resolves with the provider's sign-in URL,
38
+ * for the page to go to. The provider sends the browser back to `callbackURL` signed in, or with `?error=<code>`,
39
+ * for example `EMAIL_DOMAIN_NOT_ALLOWED` for an address outside the provider's domains, or `account_not_linked`.
40
+ */
41
+ signInSaml: (providerId: string, callbackURL: string) => Promise<string>;
36
42
  signOut: () => Promise<void>;
37
43
  /**
38
44
  * Emails a reset link when an account has this address; the answer is the same either way. The link leads back to
package/dist/auth.js CHANGED
@@ -76,6 +76,7 @@ const createAuthSession = (options = {}) => {
76
76
  ...body.signUp && { signUp: true },
77
77
  socialProviders: body.socialProviders ?? [],
78
78
  ...body.platformSignIn && { platformSignIn: body.platformSignIn },
79
+ samlProviders: body.samlProviders ?? [],
79
80
  ...body.staffSignIn && { staffSignIn: body.staffSignIn },
80
81
  ...body.passkeyDomains && { passkeyDomains: body.passkeyDomains },
81
82
  ...body.organizations && { organizations: body.organizations },
@@ -104,6 +105,23 @@ const createAuthSession = (options = {}) => {
104
105
  if (error || !data?.url) throw authError(error, "Sign-in failed");
105
106
  return data.url;
106
107
  },
108
+ /**
109
+ * Starts sign-in with one of the app's SAML identity providers by its id: resolves with the provider's sign-in URL,
110
+ * for the page to go to. The provider sends the browser back to `callbackURL` signed in, or with `?error=<code>`,
111
+ * for example `EMAIL_DOMAIN_NOT_ALLOWED` for an address outside the provider's domains, or `account_not_linked`.
112
+ */
113
+ signInSaml: async (providerId, callbackURL) => {
114
+ const { data, error } = await client.$fetch("/sign-in/sso", {
115
+ method: "POST",
116
+ body: {
117
+ providerId,
118
+ callbackURL,
119
+ errorCallbackURL: callbackURL
120
+ }
121
+ });
122
+ if (error || !data?.url) throw authError(error, "Sign-in failed");
123
+ return data.url;
124
+ },
107
125
  signOut: async () => {
108
126
  forget();
109
127
  await client.signOut();
package/dist/index.d.ts CHANGED
@@ -12,10 +12,10 @@ import { AccountSecurity, AccountSignIn, AuthenticatorSetup, Passkey, RequiredSe
12
12
  import { CurrentOrganization, InvitationPreview, InvitationSent, Organization, OrganizationInvitation, OrganizationMember, OrganizationRole, OrganizationsClient } from "./organizations.js";
13
13
  import { ActiveRole, RoleOption, RolesClient } from "./roles.js";
14
14
  import { StaffSignIn, StaffSignInClient } from "./staff-sign-in.js";
15
- import { AuthUser, PlatformSignIn, RoleLabel, SetupStatus, SignInMethod, SignInResult, TwoFactorMethod } from "./auth-types.js";
15
+ import { AuthUser, PlatformSignIn, RoleLabel, SamlSignIn, SetupStatus, SignInMethod, SignInResult, TwoFactorMethod } from "./auth-types.js";
16
16
  import { AuthError } from "./auth-error.js";
17
17
  import { AuthSession, AuthSessionOptions, createAuthSession, tokenExpiry } from "./auth.js";
18
18
  import { createStaticSession } from "./static-session.js";
19
19
  import { AssistantClient, AssistantClientOptions, AssistantConnection, createAssistantClient } from "./assistant.js";
20
20
  import { RuntimeClient, RuntimeClientOptions, RuntimeLastUpdate, RuntimePolicy, RuntimeStatus, RuntimeUpdateStage, createRuntimeClient } from "./runtime.js";
21
- export { type AccountSecurity, type AccountSignIn, type ActiveRole, type Aggregate, type AggregateGroup, type AggregateParams, ApiError, type AssistantClient, type AssistantClientOptions, type AssistantConnection, AuthError, type AuthSession, type AuthSessionOptions, type AuthUser, type AuthenticatorSetup, type BatchOp, type BatchRef, type BatchResult, type Client, type ClientOptions, type CommentPage, type CommentPerson, type CurrentOrganization, type Facet, type FilterInput, type FormChallenge, type FormProof, type Histogram, type HistogramBucket, type HistoryChange, type HistoryPage, type InvitationPreview, type InvitationSent, type InvokeOptions, type ListPage, type ListParams, type MapBounds, type MapBucket, type MapLayerModel, type MapParams, type MapResult, type MentionableUser, type Meta, type MetaResult, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationRole, type OrganizationsClient, type Passkey, type PlatformSignIn, type PluginRef, PreconditionFailedError, type ProblemDetails, type ProblemError, type PublicForm, type RecordComment, type RecordOf, type RecordPermissions, type RecordPhotos, type RelatedLabels, type RequiredSetup, type ResourcePermissions, type ResourceRef, type RoleLabel, type RoleOption, type RolesClient, type RuntimeClient, type RuntimeClientOptions, type RuntimeLastUpdate, type RuntimePolicy, type RuntimeStatus, type RuntimeUpdateStage, type Series, type SeriesParams, type SeriesPoint, type SetupStatus, type SignInMethod, type SignInPolicy, type SignInPolicyClient, type SignInPolicyState, type SignInResult, type SignInRule, type SourceMeta, type SourceRef, type StaffAccessRule, type StaffSignIn, type StaffSignInClient, type Stored, type StoredFile, type StoredFileVariant, type TwoFactorMethod, type UploadOptions, type UploadProgress, type UploadResult, createAssistantClient, createAuthSession, createClient, createRuntimeClient, createStaticSession, fileUrl, filterText, isApiError, listWire, routedClient, sourceMeta, tokenExpiry };
21
+ export { type AccountSecurity, type AccountSignIn, type ActiveRole, type Aggregate, type AggregateGroup, type AggregateParams, ApiError, type AssistantClient, type AssistantClientOptions, type AssistantConnection, AuthError, type AuthSession, type AuthSessionOptions, type AuthUser, type AuthenticatorSetup, type BatchOp, type BatchRef, type BatchResult, type Client, type ClientOptions, type CommentPage, type CommentPerson, type CurrentOrganization, type Facet, type FilterInput, type FormChallenge, type FormProof, type Histogram, type HistogramBucket, type HistoryChange, type HistoryPage, type InvitationPreview, type InvitationSent, type InvokeOptions, type ListPage, type ListParams, type MapBounds, type MapBucket, type MapLayerModel, type MapParams, type MapResult, type MentionableUser, type Meta, type MetaResult, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationRole, type OrganizationsClient, type Passkey, type PlatformSignIn, type PluginRef, PreconditionFailedError, type ProblemDetails, type ProblemError, type PublicForm, type RecordComment, type RecordOf, type RecordPermissions, type RecordPhotos, type RelatedLabels, type RequiredSetup, type ResourcePermissions, type ResourceRef, type RoleLabel, type RoleOption, type RolesClient, type RuntimeClient, type RuntimeClientOptions, type RuntimeLastUpdate, type RuntimePolicy, type RuntimeStatus, type RuntimeUpdateStage, type SamlSignIn, type Series, type SeriesParams, type SeriesPoint, type SetupStatus, type SignInMethod, type SignInPolicy, type SignInPolicyClient, type SignInPolicyState, type SignInResult, type SignInRule, type SourceMeta, type SourceRef, type StaffAccessRule, type StaffSignIn, type StaffSignInClient, type Stored, type StoredFile, type StoredFileVariant, type TwoFactorMethod, type UploadOptions, type UploadProgress, type UploadResult, createAssistantClient, createAuthSession, createClient, createRuntimeClient, createStaticSession, fileUrl, filterText, isApiError, listWire, routedClient, sourceMeta, tokenExpiry };
@@ -19,7 +19,8 @@ const createStaticSession = (token, user = {
19
19
  needsAdmin: false,
20
20
  signInMethods: ["password"],
21
21
  passwordReset: false,
22
- socialProviders: []
22
+ socialProviders: [],
23
+ samlProviders: []
23
24
  }),
24
25
  session: async () => user,
25
26
  signIn: async () => ({
@@ -38,6 +39,7 @@ const createStaticSession = (token, user = {
38
39
  sendTwoFactorCode: async () => void 0,
39
40
  verifyTwoFactor: async () => user,
40
41
  signInSocial: unsupported("sign in with a provider"),
42
+ signInSaml: unsupported("sign in with a provider"),
41
43
  signOut: async () => void 0,
42
44
  requestPasswordReset: async () => void 0,
43
45
  resetPassword: async () => void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/client",
3
- "version": "0.21.9",
3
+ "version": "0.21.10",
4
4
  "description": "Typed fetch client for the Protobase REST API.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@better-auth/passkey": "^1.7.7",
33
- "@protobase/layout": "0.21.9",
34
- "@protobase/schema": "0.21.9",
33
+ "@protobase/layout": "0.21.10",
34
+ "@protobase/schema": "0.21.10",
35
35
  "@simplewebauthn/browser": "^13.3.0",
36
36
  "better-auth": "^1.7.7"
37
37
  }