@protobase/client 0.62.4 → 0.62.5
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.
- package/dist/account-security.d.ts +9 -0
- package/dist/account-security.js +24 -0
- package/dist/auth-types.d.ts +14 -1
- package/dist/auth.d.ts +3 -1
- package/dist/auth.js +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/static-session.js +2 -0
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BetterAuthClient } from "./better-auth-client.js";
|
|
2
|
+
import { PersonalMailLink } from "./auth-types.js";
|
|
2
3
|
import { SignInPolicy } from "./sign-in-policy.js";
|
|
3
4
|
//#region src/account-security.d.ts
|
|
4
5
|
/** What a sign-in policy can require that an account sets up once. */
|
|
@@ -68,6 +69,14 @@ export declare const accountSecurity: (client: BetterAuthClient) => {
|
|
|
68
69
|
* `?error=<code>` when the link did not go through, for example `account_already_linked_to_different_user`.
|
|
69
70
|
*/
|
|
70
71
|
linkProvider: (provider: string, callbackURL: string) => Promise<string>;
|
|
72
|
+
/** The ids of the mail providers of `links` the account is linked to with every scope they ask for, for example `gmail`. */
|
|
73
|
+
linkedPersonalMail: (links: PersonalMailLink[]) => Promise<string[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Starts linking a mailbox, such as Gmail through Google sign-in with leave to send mail: resolves with the provider's
|
|
76
|
+
* authorization URL, for the page to go to. The provider sends the browser back to `callbackURL`, with
|
|
77
|
+
* `?error=<code>` when the link did not go through.
|
|
78
|
+
*/
|
|
79
|
+
linkPersonalMail: (link: PersonalMailLink, callbackURL: string) => Promise<string>;
|
|
71
80
|
/** The apps the person allowed to act as them, newest first; on an app with MCP on. */
|
|
72
81
|
connectedApps: () => Promise<ConnectedApp[]>;
|
|
73
82
|
/** Disconnects an app: it is forgotten, and its access ends within 15 minutes; it has to ask again to come back. */
|
package/dist/account-security.js
CHANGED
|
@@ -85,6 +85,30 @@ const accountSecurity = (client) => ({
|
|
|
85
85
|
if (error || !data?.url) throw authError(error, "Could not start linking the account");
|
|
86
86
|
return data.url;
|
|
87
87
|
},
|
|
88
|
+
/** The ids of the mail providers of `links` the account is linked to with every scope they ask for, for example `gmail`. */
|
|
89
|
+
linkedPersonalMail: async (links) => {
|
|
90
|
+
const { data, error } = await client.listAccounts();
|
|
91
|
+
if (error || !data) throw authError(error, "Could not read your linked accounts");
|
|
92
|
+
const holds = (link) => data.some((account) => account.providerId === link.provider && link.scopes.every((scope) => account.scopes.includes(scope)));
|
|
93
|
+
return links.filter(holds).map((link) => link.id);
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Starts linking a mailbox, such as Gmail through Google sign-in with leave to send mail: resolves with the provider's
|
|
97
|
+
* authorization URL, for the page to go to. The provider sends the browser back to `callbackURL`, with
|
|
98
|
+
* `?error=<code>` when the link did not go through.
|
|
99
|
+
*/
|
|
100
|
+
linkPersonalMail: async (link, callbackURL) => {
|
|
101
|
+
const { data, error } = await client.linkSocial({
|
|
102
|
+
provider: link.provider,
|
|
103
|
+
scopes: link.scopes,
|
|
104
|
+
additionalParams: link.params,
|
|
105
|
+
callbackURL,
|
|
106
|
+
errorCallbackURL: callbackURL,
|
|
107
|
+
disableRedirect: true
|
|
108
|
+
});
|
|
109
|
+
if (error || !data?.url) throw authError(error, "Could not start linking the mailbox");
|
|
110
|
+
return data.url;
|
|
111
|
+
},
|
|
88
112
|
/** The apps the person allowed to act as them, newest first; on an app with MCP on. */
|
|
89
113
|
connectedApps: async () => {
|
|
90
114
|
const { data, error } = await client.$fetch("/account/connected-apps");
|
package/dist/auth-types.d.ts
CHANGED
|
@@ -24,6 +24,18 @@ export type PlatformSignIn = {
|
|
|
24
24
|
provider: string;
|
|
25
25
|
name: string;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* A mail provider people may link their own mailbox with, for the app to send mail from it: its id and name, such as
|
|
29
|
+
* `gmail` and `Gmail`, the sign-in provider it links through, such as `google`, the scopes the link asks for and more
|
|
30
|
+
* authorization parameters of the link.
|
|
31
|
+
*/
|
|
32
|
+
export type PersonalMailLink = {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
provider: string;
|
|
36
|
+
scopes: string[];
|
|
37
|
+
params: Record<string, string>;
|
|
38
|
+
};
|
|
27
39
|
/** A SAML identity provider of the app: its id, for `signInSaml`, and the name to show. */
|
|
28
40
|
export type SamlSignIn = {
|
|
29
41
|
id: string;
|
|
@@ -37,7 +49,7 @@ export type SamlSignIn = {
|
|
|
37
49
|
* `sendSignUpCode`); `socialProviders` the ids of the sign-in providers, for example
|
|
38
50
|
* `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
|
|
39
51
|
* can sign in as people; `organizations` when the app has them; `anonymous` when visitors may browse what the project's
|
|
40
|
-
* anonymous role reads without signing in; `mcp` when MCP clients can connect, with the `url` of the app's MCP endpoint, so the account page shows it and lists the clients; `plugins`
|
|
52
|
+
* anonymous role reads without signing in; `personalMail` the mail providers people may link their mailbox with (see `account.linkPersonalMail`); `mcp` when MCP clients can connect, with the `url` of the app's MCP endpoint, so the account page shows it and lists the clients; `plugins`
|
|
41
53
|
* those the app loads before anyone signs in; `locale` the language the app sets for everyone, which the screens before
|
|
42
54
|
* `/meta` are in.
|
|
43
55
|
*/
|
|
@@ -67,6 +79,7 @@ export type SetupStatus = {
|
|
|
67
79
|
mcp?: {
|
|
68
80
|
url: string;
|
|
69
81
|
};
|
|
82
|
+
personalMail?: PersonalMailLink[];
|
|
70
83
|
plugins?: PluginRef[];
|
|
71
84
|
locale?: Locale;
|
|
72
85
|
};
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DeviceSession } from "./account-profile.js";
|
|
2
|
+
import { AuthUser, PersonalMailLink, RoleLabel, SetupStatus, SignInResult, TwoFactorMethod } from "./auth-types.js";
|
|
2
3
|
import { SignInPolicy, SignInPolicyState } from "./sign-in-policy.js";
|
|
3
4
|
import { AccountSignIn, AuthenticatorSetup, ConnectedApp, Passkey } from "./account-security.js";
|
|
4
5
|
import { ConnectingClient } from "./connect.js";
|
|
5
6
|
import { CurrentOrganization, InvitationPreview, InvitationSent, Organization, OrganizationInvitation, OrganizationMember, OrganizationPerson, OrganizationRole, OrganizationsFound } from "./organizations.js";
|
|
6
7
|
import { ActiveRole } from "./roles.js";
|
|
7
|
-
import { AuthUser, RoleLabel, SetupStatus, SignInResult, TwoFactorMethod } from "./auth-types.js";
|
|
8
8
|
import { AppUser, UserInvitation, UserInvitationSent, UsersFound } from "./users.js";
|
|
9
9
|
import { StaffSignIn } from "./staff-sign-in.js";
|
|
10
10
|
import { AuthError } from "./auth-error.js";
|
|
@@ -76,6 +76,8 @@ export declare const createAuthSession: (options?: AuthSessionOptions) => {
|
|
|
76
76
|
turnOffTwoFactor: (password?: string) => Promise<void>;
|
|
77
77
|
linkedProviders: () => Promise<string[]>;
|
|
78
78
|
linkProvider: (provider: string, callbackURL: string) => Promise<string>;
|
|
79
|
+
linkedPersonalMail: (links: PersonalMailLink[]) => Promise<string[]>;
|
|
80
|
+
linkPersonalMail: (link: PersonalMailLink, callbackURL: string) => Promise<string>;
|
|
79
81
|
connectedApps: () => Promise<ConnectedApp[]>;
|
|
80
82
|
disconnectApp: (clientId: string) => Promise<void>;
|
|
81
83
|
newBackupCodes: (password?: string) => Promise<string[]>;
|
package/dist/auth.js
CHANGED
|
@@ -89,6 +89,7 @@ const createAuthSession = (options = {}) => {
|
|
|
89
89
|
...body.organizations && { organizations: body.organizations },
|
|
90
90
|
...body.anonymous && { anonymous: true },
|
|
91
91
|
...body.mcp && { mcp: { url: body.mcp.url } },
|
|
92
|
+
...body.personalMail && body.personalMail.length > 0 && { personalMail: body.personalMail },
|
|
92
93
|
...body.plugins && body.plugins.length > 0 && { plugins: body.plugins },
|
|
93
94
|
...isLocale(body.locale) && { locale: body.locale }
|
|
94
95
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -17,12 +17,12 @@ import { fileUrl } from "./file-urls.js";
|
|
|
17
17
|
import { routedClient } from "./routed-client.js";
|
|
18
18
|
import { SourceMeta, sourceMeta } from "./source-meta.js";
|
|
19
19
|
import { DeviceSession } from "./account-profile.js";
|
|
20
|
+
import { AuthUser, PersonalMailLink, PlatformSignIn, RoleLabel, SamlSignIn, SetupStatus, SignInMethod, SignInResult, TwoFactorMethod } from "./auth-types.js";
|
|
20
21
|
import { SignInPolicy, SignInPolicyClient, SignInPolicyState, SignInRule, StaffAccessRule } from "./sign-in-policy.js";
|
|
21
22
|
import { AccountSecurity, AccountSignIn, AuthenticatorSetup, ConnectedApp, Passkey, RequiredSetup } from "./account-security.js";
|
|
22
23
|
import { ConnectClient, ConnectingClient } from "./connect.js";
|
|
23
24
|
import { CurrentOrganization, InvitationPreview, InvitationSent, Organization, OrganizationInvitation, OrganizationMember, OrganizationPerson, OrganizationRole, OrganizationsClient, OrganizationsFound } from "./organizations.js";
|
|
24
25
|
import { ActiveRole, RoleOption, RolesClient } from "./roles.js";
|
|
25
|
-
import { AuthUser, PlatformSignIn, RoleLabel, SamlSignIn, SetupStatus, SignInMethod, SignInResult, TwoFactorMethod } from "./auth-types.js";
|
|
26
26
|
import { AppUser, UserInvitation, UserInvitationSent, UsersClient, UsersFound } from "./users.js";
|
|
27
27
|
import { StaffSignIn, StaffSignInClient } from "./staff-sign-in.js";
|
|
28
28
|
import { AuthError } from "./auth-error.js";
|
|
@@ -31,4 +31,4 @@ import { createStaticSession } from "./static-session.js";
|
|
|
31
31
|
import { AssistantClient, AssistantClientOptions, AssistantConnection, createAssistantClient } from "./assistant.js";
|
|
32
32
|
import { RuntimeClient, RuntimeClientOptions, RuntimeLastUpdate, RuntimePolicy, RuntimeStatus, RuntimeUpdateStage, createRuntimeClient } from "./runtime.js";
|
|
33
33
|
import { availabilities, heldStatus, maxStatusText, statusTextProblem } from "@protobase/schema/internal";
|
|
34
|
-
export { type AccountSecurity, type AccountSignIn, type ActiveRole, type Aggregate, type AggregateGroup, type AggregateParams, type AggregateSplitTotal, ApiError, type AppUser, type AssistantClient, type AssistantClientOptions, type AssistantConnection, AuthError, type AuthSession, type AuthSessionOptions, type AuthUser, type AuthenticatorSetup, type Availability, type BatchOp, type BatchRef, type BatchResult, type CallRing, type Channel, type ChannelError, type ChannelMessage, ChannelRefusal, type ChannelStatus, type ChannelUser, type Client, type ClientOptions, type CommentPage, type CommentPerson, type ConnectClient, type ConnectedApp, type ConnectingClient, type CurrentOrganization, type DeviceSession, type DevicesClient, type Facet, type FilterInput, type FormChallenge, type FormProof, type Histogram, type HistogramBucket, type HistoryChange, type HistoryPage, type InboxNotification, type InboxPage, type InvitationPreview, type InvitationSent, type InvokeOptions, type ListPage, type ListParams, type LiveChange, type LiveHandlers, type MapBounds, type MapBucket, type MapLayerModel, type MapParams, type MapResult, type MentionableUser, type Meta, type MetaResult, type NotificationHistoryClient, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationPerson, type OrganizationRole, type OrganizationsClient, type OrganizationsFound, type Passkey, type PersonStatus, type PlatformSignIn, type PluginRef, PreconditionFailedError, type PresenceChange, type PresenceEntry, type ProblemDetails, type ProblemError, type PublicForm, type RecordCall, type RecordCallsHandlers, type RecordComment, type RecordOf, type RecordPermissions, type RecordPhotos, type RegisteredDevice, type RelatedLabels, type RequiredSetup, type ResourcePermissions, type ResourceRef, type RingsClient, 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 SocketLike, type SourceMeta, type SourceRef, type StaffAccessRule, type StaffSignIn, type StaffSignInClient, type StatusClient, type StatusInput, type Stored, type StoredFile, type StoredFileVariant, type TwoFactorMethod, type UploadOptions, type UploadProgress, type UploadResult, type UserInvitation, type UserInvitationSent, type UsersClient, type UsersFound, type WebDeviceRegistration, availabilities, createAssistantClient, createAuthSession, createClient, createRuntimeClient, createStaticSession, fileUrl, filterText, heldStatus, isApiError, listWire, maxStatusText, routedClient, sourceMeta, statusTextProblem, tokenExpiry };
|
|
34
|
+
export { type AccountSecurity, type AccountSignIn, type ActiveRole, type Aggregate, type AggregateGroup, type AggregateParams, type AggregateSplitTotal, ApiError, type AppUser, type AssistantClient, type AssistantClientOptions, type AssistantConnection, AuthError, type AuthSession, type AuthSessionOptions, type AuthUser, type AuthenticatorSetup, type Availability, type BatchOp, type BatchRef, type BatchResult, type CallRing, type Channel, type ChannelError, type ChannelMessage, ChannelRefusal, type ChannelStatus, type ChannelUser, type Client, type ClientOptions, type CommentPage, type CommentPerson, type ConnectClient, type ConnectedApp, type ConnectingClient, type CurrentOrganization, type DeviceSession, type DevicesClient, type Facet, type FilterInput, type FormChallenge, type FormProof, type Histogram, type HistogramBucket, type HistoryChange, type HistoryPage, type InboxNotification, type InboxPage, type InvitationPreview, type InvitationSent, type InvokeOptions, type ListPage, type ListParams, type LiveChange, type LiveHandlers, type MapBounds, type MapBucket, type MapLayerModel, type MapParams, type MapResult, type MentionableUser, type Meta, type MetaResult, type NotificationHistoryClient, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationPerson, type OrganizationRole, type OrganizationsClient, type OrganizationsFound, type Passkey, type PersonStatus, type PersonalMailLink, type PlatformSignIn, type PluginRef, PreconditionFailedError, type PresenceChange, type PresenceEntry, type ProblemDetails, type ProblemError, type PublicForm, type RecordCall, type RecordCallsHandlers, type RecordComment, type RecordOf, type RecordPermissions, type RecordPhotos, type RegisteredDevice, type RelatedLabels, type RequiredSetup, type ResourcePermissions, type ResourceRef, type RingsClient, 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 SocketLike, type SourceMeta, type SourceRef, type StaffAccessRule, type StaffSignIn, type StaffSignInClient, type StatusClient, type StatusInput, type Stored, type StoredFile, type StoredFileVariant, type TwoFactorMethod, type UploadOptions, type UploadProgress, type UploadResult, type UserInvitation, type UserInvitationSent, type UsersClient, type UsersFound, type WebDeviceRegistration, availabilities, createAssistantClient, createAuthSession, createClient, createRuntimeClient, createStaticSession, fileUrl, filterText, heldStatus, isApiError, listWire, maxStatusText, routedClient, sourceMeta, statusTextProblem, tokenExpiry };
|
package/dist/static-session.js
CHANGED
|
@@ -75,6 +75,8 @@ const createStaticSession = (token, user = {
|
|
|
75
75
|
newBackupCodes: unsupported("make backup codes"),
|
|
76
76
|
linkedProviders: async () => [],
|
|
77
77
|
linkProvider: unsupported("link a sign-in provider"),
|
|
78
|
+
linkedPersonalMail: async () => [],
|
|
79
|
+
linkPersonalMail: unsupported("link a mailbox"),
|
|
78
80
|
connectedApps: async () => [],
|
|
79
81
|
disconnectApp: unsupported("disconnect an app"),
|
|
80
82
|
updateName: unsupported("change its name"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/client",
|
|
3
|
-
"version": "0.62.
|
|
3
|
+
"version": "0.62.5",
|
|
4
4
|
"description": "Typed fetch client for the Protobase REST API.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@better-auth/passkey": "^1.7.12",
|
|
34
|
-
"@protobase/layout": "0.62.
|
|
35
|
-
"@protobase/schema": "0.62.
|
|
34
|
+
"@protobase/layout": "0.62.5",
|
|
35
|
+
"@protobase/schema": "0.62.5",
|
|
36
36
|
"@simplewebauthn/browser": "^13.3.0",
|
|
37
37
|
"better-auth": "^1.7.12"
|
|
38
38
|
}
|