@verft/sdk 0.0.0-stage → 1.1.0
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/LICENSE +22 -0
- package/README.md +14 -2
- package/dist/activity.d.ts +12 -0
- package/dist/activity.js +59 -0
- package/dist/connection.d.ts +135 -0
- package/dist/connection.js +1032 -0
- package/dist/drafts.d.ts +13 -0
- package/dist/drafts.js +21 -0
- package/dist/encoding.d.ts +112 -0
- package/dist/encoding.js +428 -0
- package/dist/files.d.ts +31 -0
- package/dist/files.js +56 -0
- package/dist/functions.d.ts +26 -0
- package/dist/functions.js +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +8 -0
- package/dist/landing.d.ts +25 -0
- package/dist/landing.js +19 -0
- package/dist/platform.d.ts +70 -0
- package/dist/platform.js +11 -0
- package/dist/protocol.d.ts +1198 -0
- package/dist/protocol.js +334 -0
- package/dist/react-native.d.ts +30 -0
- package/dist/react-native.js +34 -0
- package/dist/react.d.ts +23 -0
- package/dist/react.js +43 -0
- package/dist/readable.d.ts +14 -0
- package/dist/readable.js +31 -0
- package/dist/storage.d.ts +6 -0
- package/dist/storage.js +8 -0
- package/dist/subscriptions.d.ts +70 -0
- package/dist/subscriptions.js +168 -0
- package/dist/svelte.d.ts +26 -0
- package/dist/svelte.js +73 -0
- package/dist/tables.d.ts +17 -0
- package/dist/tables.js +18 -0
- package/dist/vue.d.ts +20 -0
- package/dist/vue.js +60 -0
- package/package.json +72 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Verft Developer Tools Licence
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arn Software ApS. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This licence covers the software it comes with: the verft and verft-server programs, the verft, verft-abi and verft-macros Rust crates, the Verft test host libraries, and the @verft/sdk package (together, "the Tools").
|
|
6
|
+
|
|
7
|
+
1. Permission. You may download, install, copy and run the Tools, and include them in your own software, only to build, test and run applications that use Verft's services, and only for as long as you follow this licence.
|
|
8
|
+
|
|
9
|
+
2. Restrictions. You may not:
|
|
10
|
+
a. distribute, sell, sublicense or otherwise make the Tools available to anyone, except as part of an application you build with them, and in the SDK's case only in the form your application's build produces;
|
|
11
|
+
b. use the Tools, or any part of them, to build, offer or support a service that competes with Verft's services, or to run Verft's services or any part of them yourself for others;
|
|
12
|
+
c. remove or change this licence or any notice of ownership in the Tools.
|
|
13
|
+
|
|
14
|
+
3. Ownership. The Tools are licensed, not sold. The licensor and its licensors keep every right not expressly given here.
|
|
15
|
+
|
|
16
|
+
4. No warranty. The Tools are provided "as is", without warranty of any kind, express or implied, including fitness for a particular purpose, merchantability and non-infringement.
|
|
17
|
+
|
|
18
|
+
5. Limit of liability. To the extent the law allows, the licensor is not liable for any damages arising from the Tools or their use, whether direct, indirect, incidental or consequential.
|
|
19
|
+
|
|
20
|
+
6. End. This licence ends at once if you break it. When it ends, you must stop using the Tools and delete your copies of them.
|
|
21
|
+
|
|
22
|
+
Your use of Verft's services themselves is governed by Verft's terms of service, not by this licence.
|
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @verft/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The client library of [Verft](https://docs.verft.cloud) Apps. An App is one Module that holds its Tables, logic and API, and runs on Verft; its frontend talks to it through a client that `verft` generates from the Module, built on this package.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @verft/sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
It gives the generated client typed Actions and Queries, live Subscriptions that stay current over one connection, sign-in, files and push registration, with bindings for React (`@verft/sdk/react`), React Native (`@verft/sdk/react-native`), Vue (`@verft/sdk/vue`) and Svelte (`@verft/sdk/svelte`).
|
|
10
|
+
|
|
11
|
+
You rarely import it by hand: `verft dev` writes the client of your Module into your frontend, and that client imports this package. Start with the [Quickstart](https://docs.verft.cloud).
|
|
12
|
+
|
|
13
|
+
The major version of this package is the version of Verft's wire protocol it speaks, which it also exports as `PROTOCOL`.
|
|
14
|
+
|
|
15
|
+
Licensed under the terms in `LICENSE`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Connection } from "./connection.js";
|
|
2
|
+
import type { Activity, IdentityFailure } from "./protocol.js";
|
|
3
|
+
import { type Readable } from "./readable.js";
|
|
4
|
+
export interface AccountActivityLog {
|
|
5
|
+
readonly entries: Activity[];
|
|
6
|
+
readonly loading: boolean;
|
|
7
|
+
readonly complete: boolean;
|
|
8
|
+
readonly failure: IdentityFailure | null;
|
|
9
|
+
readonly more: () => void;
|
|
10
|
+
readonly refresh: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function accountActivityLog(connection: Connection, limit?: number): Readable<AccountActivityLog>;
|
package/dist/activity.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { IdentityError } from "./connection.js";
|
|
2
|
+
import { Watched } from "./readable.js";
|
|
3
|
+
export function accountActivityLog(connection, limit) {
|
|
4
|
+
let whose = undefined;
|
|
5
|
+
let next = null;
|
|
6
|
+
let reading = undefined;
|
|
7
|
+
let listeners = 0;
|
|
8
|
+
let unfollow = () => { };
|
|
9
|
+
const more = () => {
|
|
10
|
+
const { entries, loading, complete } = log.get();
|
|
11
|
+
if (loading || complete)
|
|
12
|
+
return;
|
|
13
|
+
const read = (reading = {});
|
|
14
|
+
show({ entries, loading: true, complete, failure: null });
|
|
15
|
+
connection.accountActivity({ after: next ?? undefined, limit }).then((page) => {
|
|
16
|
+
if (reading !== read)
|
|
17
|
+
return;
|
|
18
|
+
next = page.next;
|
|
19
|
+
show({ entries: [...entries, ...page.entries], loading: false, complete: next === null, failure: null });
|
|
20
|
+
}, (error) => {
|
|
21
|
+
if (reading !== read)
|
|
22
|
+
return;
|
|
23
|
+
const failure = error instanceof IdentityError ? error.failure : { tag: "Unavailable", value: String(error) };
|
|
24
|
+
show({ entries, loading: false, complete, failure });
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const start = () => {
|
|
28
|
+
next = null;
|
|
29
|
+
reading = undefined;
|
|
30
|
+
show({ entries: [], loading: false, complete: whose === null, failure: null });
|
|
31
|
+
more();
|
|
32
|
+
};
|
|
33
|
+
const follow = () => {
|
|
34
|
+
const caller = connection.caller.get();
|
|
35
|
+
const signedIn = caller?.kind.tag === "SignedIn" ? caller.identity : null;
|
|
36
|
+
if (signedIn === whose)
|
|
37
|
+
return;
|
|
38
|
+
whose = signedIn;
|
|
39
|
+
start();
|
|
40
|
+
};
|
|
41
|
+
const log = new Watched({ entries: [], loading: true, complete: false, failure: null, more, refresh: start });
|
|
42
|
+
const show = (shown) => {
|
|
43
|
+
log.set({ ...shown, more, refresh: start });
|
|
44
|
+
log.notify();
|
|
45
|
+
};
|
|
46
|
+
const onChange = (listener) => {
|
|
47
|
+
const stop = log.onChange(listener);
|
|
48
|
+
if (listeners++ === 0) {
|
|
49
|
+
unfollow = connection.caller.onChange(follow);
|
|
50
|
+
follow();
|
|
51
|
+
}
|
|
52
|
+
return () => {
|
|
53
|
+
stop();
|
|
54
|
+
if (--listeners === 0)
|
|
55
|
+
unfollow();
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
return { get: log.get, onChange };
|
|
59
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { type Bytes, type ConnectionId } from "./encoding.js";
|
|
2
|
+
import { type Action, type Query, type Reply } from "./functions.js";
|
|
3
|
+
import { type Landing } from "./landing.js";
|
|
4
|
+
import { type Authenticator } from "./platform.js";
|
|
5
|
+
import { type ActivityPage, type Caller, type CallFailure, type ConnectRefusal, type IdentityFailure, type ListedPasskey } from "./protocol.js";
|
|
6
|
+
import { type Readable } from "./readable.js";
|
|
7
|
+
import { type Storage } from "./storage.js";
|
|
8
|
+
import { type Local, type Shared, type Subscription } from "./subscriptions.js";
|
|
9
|
+
import type { ClientQuery } from "./tables.js";
|
|
10
|
+
export type Status = {
|
|
11
|
+
readonly state: "connecting";
|
|
12
|
+
} | {
|
|
13
|
+
readonly state: "connected";
|
|
14
|
+
readonly connection: ConnectionId;
|
|
15
|
+
readonly caller: Caller;
|
|
16
|
+
} | {
|
|
17
|
+
readonly state: "reconnecting";
|
|
18
|
+
} | {
|
|
19
|
+
readonly state: "signedOut";
|
|
20
|
+
} | {
|
|
21
|
+
readonly state: "refused";
|
|
22
|
+
readonly reason: ConnectRefusal;
|
|
23
|
+
} | {
|
|
24
|
+
readonly state: "unsupportedProtocol";
|
|
25
|
+
readonly supported: number[];
|
|
26
|
+
} | {
|
|
27
|
+
readonly state: "closed";
|
|
28
|
+
};
|
|
29
|
+
export interface Options {
|
|
30
|
+
readonly environment: string;
|
|
31
|
+
readonly server?: string;
|
|
32
|
+
readonly storage?: Storage;
|
|
33
|
+
readonly authenticator?: Authenticator;
|
|
34
|
+
readonly relyingParty?: string;
|
|
35
|
+
readonly callTimeLimit?: number;
|
|
36
|
+
readonly emailTimeLimit?: number;
|
|
37
|
+
readonly providerTimeLimit?: number;
|
|
38
|
+
readonly welcomeTimeLimit?: number;
|
|
39
|
+
readonly connectTimeLimit?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface CallOptions {
|
|
42
|
+
readonly timeLimit?: number;
|
|
43
|
+
}
|
|
44
|
+
export declare const CALL_TIME_LIMIT = 30000;
|
|
45
|
+
export declare const EMAIL_TIME_LIMIT = 90000;
|
|
46
|
+
export declare const PROVIDER_TIME_LIMIT = 60000;
|
|
47
|
+
export declare const WELCOME_TIME_LIMIT = 45000;
|
|
48
|
+
export declare const CONNECT_TIME_LIMIT = 30000;
|
|
49
|
+
export declare const LONGEST_TIME_LIMIT: number;
|
|
50
|
+
export declare const MANAGED_CLOUD = "verft.app";
|
|
51
|
+
export interface Connection {
|
|
52
|
+
readonly status: Readable<Status>;
|
|
53
|
+
readonly failedAttempts: Readable<number>;
|
|
54
|
+
readonly caller: Readable<Caller | null>;
|
|
55
|
+
readonly landing: Readable<Landing>;
|
|
56
|
+
redeem(url: string): boolean;
|
|
57
|
+
wake(): void;
|
|
58
|
+
reconnect(): void;
|
|
59
|
+
action<A, R, E>(action: Action<A, R, E>, args: NoInfer<A>, optimistic?: (local: Local) => void, options?: CallOptions): Promise<Reply<R, E>>;
|
|
60
|
+
query<A, R, E>(query: Query<A, R, E>, args: NoInfer<A>, options?: CallOptions): Promise<Reply<R, E>>;
|
|
61
|
+
subscribe<A, R, E>(query: Query<A, R, E>, args: NoInfer<A>): Subscription<Reply<R, E>>;
|
|
62
|
+
subscribe<R>(query: ClientQuery<R>): Subscription<R[]>;
|
|
63
|
+
shared<A, R, E>(query: Query<A, R, E>, args: NoInfer<A>): Shared<Reply<R, E>>;
|
|
64
|
+
shared<R>(query: ClientQuery<R>): Shared<R[]>;
|
|
65
|
+
startAnonymous(): Promise<Caller>;
|
|
66
|
+
signUp(email: string, password: string): Promise<void>;
|
|
67
|
+
verifyEmail(emailed: string): Promise<Caller>;
|
|
68
|
+
signIn(email: string, password: string): Promise<Caller>;
|
|
69
|
+
requestSignInLink(email: string, redirectTo?: string): Promise<void>;
|
|
70
|
+
signInWithLink(emailed: string): Promise<Caller>;
|
|
71
|
+
requestSignInCode(email: string): Promise<void>;
|
|
72
|
+
signInWithCode(email: string, code: string): Promise<Caller>;
|
|
73
|
+
requestPasswordReset(email: string): Promise<void>;
|
|
74
|
+
resetPassword(emailed: string, password: string): Promise<void>;
|
|
75
|
+
acceptInvitation(emailed: string): Promise<Caller>;
|
|
76
|
+
startProviderSignIn(connection: string, redirectTo: string): Promise<string>;
|
|
77
|
+
finishProviderSignIn(result: string): Promise<Caller>;
|
|
78
|
+
startDirectoryConsent(connection: string, redirectTo: string): Promise<string>;
|
|
79
|
+
finishDirectoryConsent(consent: string): Promise<string>;
|
|
80
|
+
passSecondStep(code: string): Promise<Caller>;
|
|
81
|
+
startEnrolment(): Promise<string>;
|
|
82
|
+
finishEnrolment(code: string): Promise<string[]>;
|
|
83
|
+
startReplacement(): Promise<string>;
|
|
84
|
+
finishReplacement(code: string, newCode: string): Promise<void>;
|
|
85
|
+
removeSecondFactor(code: string): Promise<void>;
|
|
86
|
+
reissueRecoveryCodes(): Promise<string[]>;
|
|
87
|
+
registerPasskey(account: string, name: string): Promise<void>;
|
|
88
|
+
signInWithPasskey(): Promise<Caller>;
|
|
89
|
+
passkeys(): Promise<ListedPasskey[]>;
|
|
90
|
+
renamePasskey(id: Bytes, name: string): Promise<void>;
|
|
91
|
+
removePasskey(id: Bytes): Promise<void>;
|
|
92
|
+
accountActivity(asked?: ActivityAsked): Promise<ActivityPage>;
|
|
93
|
+
registerDevice(device: PushDevice): Promise<Bytes>;
|
|
94
|
+
unregisterDevice(): Promise<void>;
|
|
95
|
+
sessionToken(): string | null;
|
|
96
|
+
issueSessionCode(bindingHash: string): Promise<string>;
|
|
97
|
+
signOut(): Promise<void>;
|
|
98
|
+
signOutEverywhere(): Promise<void>;
|
|
99
|
+
close(): void;
|
|
100
|
+
}
|
|
101
|
+
export type PushDevice = {
|
|
102
|
+
readonly service: "apns";
|
|
103
|
+
readonly token: string;
|
|
104
|
+
readonly sandbox?: boolean | undefined;
|
|
105
|
+
} | {
|
|
106
|
+
readonly service: "fcm";
|
|
107
|
+
readonly token: string;
|
|
108
|
+
} | {
|
|
109
|
+
readonly service: "webPush";
|
|
110
|
+
readonly subscription: PushSubscriptionKeys | {
|
|
111
|
+
toJSON(): PushSubscriptionKeys;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export interface PushSubscriptionKeys {
|
|
115
|
+
readonly endpoint: string;
|
|
116
|
+
readonly keys?: {
|
|
117
|
+
readonly p256dh?: string | undefined;
|
|
118
|
+
readonly auth?: string | undefined;
|
|
119
|
+
} | undefined;
|
|
120
|
+
}
|
|
121
|
+
export interface ActivityAsked {
|
|
122
|
+
readonly after?: bigint | undefined;
|
|
123
|
+
readonly limit?: number | undefined;
|
|
124
|
+
}
|
|
125
|
+
export declare const ACTIVITY_PAGE = 25;
|
|
126
|
+
export declare function authenticatorUri(secret: string, account: string, issuer: string): string;
|
|
127
|
+
export declare class CallError extends Error {
|
|
128
|
+
readonly failure: CallFailure;
|
|
129
|
+
constructor(failure: CallFailure);
|
|
130
|
+
}
|
|
131
|
+
export declare class IdentityError extends Error {
|
|
132
|
+
readonly failure: IdentityFailure;
|
|
133
|
+
constructor(failure: IdentityFailure);
|
|
134
|
+
}
|
|
135
|
+
export declare function connect(options: Options): Connection;
|