@verne-software/sdk 1.1.0 → 1.3.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/README.md +59 -5
- package/dist/index.d.mts +227 -1
- package/dist/index.d.ts +227 -1
- package/dist/index.js +171 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +170 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,18 +27,20 @@ pnpm add @verne-software/sdk
|
|
|
27
27
|
import { Verne } from '@verne-software/sdk';
|
|
28
28
|
|
|
29
29
|
const verne = new Verne({
|
|
30
|
-
relay:
|
|
31
|
-
gate:
|
|
30
|
+
relay: process.env.VERNE_RELAY_KEY,
|
|
31
|
+
gate: process.env.VERNE_GATE_KEY,
|
|
32
|
+
clockwork: process.env.VERNE_CLOCKWORK_KEY,
|
|
32
33
|
});
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
You can also instantiate services independently if you only need one:
|
|
36
37
|
|
|
37
38
|
```ts
|
|
38
|
-
import { Relay, Gate } from '@verne-software/sdk';
|
|
39
|
+
import { Relay, Gate, Clockwork } from '@verne-software/sdk';
|
|
39
40
|
|
|
40
|
-
const relay
|
|
41
|
-
const gate
|
|
41
|
+
const relay = new Relay({ apiKey: process.env.VERNE_RELAY_KEY });
|
|
42
|
+
const gate = new Gate({ apiKey: process.env.VERNE_GATE_KEY });
|
|
43
|
+
const clockwork = new Clockwork({ apiKey: process.env.VERNE_CLOCKWORK_KEY });
|
|
42
44
|
```
|
|
43
45
|
|
|
44
46
|
## Relay — Webhooks-as-a-Service
|
|
@@ -170,6 +172,58 @@ if (!decision.allowed) {
|
|
|
170
172
|
}
|
|
171
173
|
```
|
|
172
174
|
|
|
175
|
+
## Clockwork — Cron-as-a-Service
|
|
176
|
+
|
|
177
|
+
Schedule recurring and one-shot HTTP jobs. The `tenant_id` is automatically scoped to your API key.
|
|
178
|
+
|
|
179
|
+
### Cron Jobs
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
// Create a recurring job
|
|
183
|
+
const job = await verne.clockwork.jobs.create({
|
|
184
|
+
name: 'nightly-report',
|
|
185
|
+
schedule: '0 2 * * *', // cron expression
|
|
186
|
+
url: 'https://example.com/hooks/report',
|
|
187
|
+
method: 'POST', // optional, defaults to POST
|
|
188
|
+
headers: { 'X-Api-Key': 'secret' }, // optional
|
|
189
|
+
body: JSON.stringify({ scope: 'all' }), // optional
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// List all cron jobs (returns CronJob[])
|
|
193
|
+
const jobs = await verne.clockwork.jobs.list();
|
|
194
|
+
|
|
195
|
+
// Update a job (partial — only the fields you pass are changed)
|
|
196
|
+
await verne.clockwork.jobs.update(job.id, { schedule: '0 3 * * *', is_active: false });
|
|
197
|
+
|
|
198
|
+
// Inspect the execution history (returns Execution[])
|
|
199
|
+
const runs = await verne.clockwork.jobs.executions(job.id);
|
|
200
|
+
|
|
201
|
+
// Delete a job
|
|
202
|
+
await verne.clockwork.jobs.delete(job.id);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Delayed Jobs
|
|
206
|
+
|
|
207
|
+
One-shot jobs that fire once at a specific time:
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
// Schedule a delayed job
|
|
211
|
+
const delayed = await verne.clockwork.delayed.create({
|
|
212
|
+
name: 'send-reminder',
|
|
213
|
+
run_at: '2026-01-01T09:00:00Z', // ISO 8601 timestamp
|
|
214
|
+
url: 'https://example.com/hooks/reminder',
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// List all delayed jobs (returns DelayedJob[])
|
|
218
|
+
const pending = await verne.clockwork.delayed.list();
|
|
219
|
+
|
|
220
|
+
// Inspect the execution history (returns Execution[])
|
|
221
|
+
const runs = await verne.clockwork.delayed.executions(delayed.id);
|
|
222
|
+
|
|
223
|
+
// Cancel a pending job
|
|
224
|
+
await verne.clockwork.delayed.cancel(delayed.id);
|
|
225
|
+
```
|
|
226
|
+
|
|
173
227
|
## Error Handling
|
|
174
228
|
|
|
175
229
|
All API errors throw a `VerneAPIError` with structured fields:
|
package/dist/index.d.mts
CHANGED
|
@@ -26,6 +26,10 @@ interface VerneConfig {
|
|
|
26
26
|
relay?: string;
|
|
27
27
|
/** API key for the Gate (Auth-as-a-Service) service. Format: vrn_gate_<env>_<secret> */
|
|
28
28
|
gate?: string;
|
|
29
|
+
/** API key for the Passepartout (Telegram Auth) service. Format: vrn_passepartout_<env>_<secret> */
|
|
30
|
+
passepartout?: string;
|
|
31
|
+
/** API key for the Clockwork (Cron-as-a-Service) service. Format: vrn_clockwork_<env>_<secret> */
|
|
32
|
+
clockwork?: string;
|
|
29
33
|
/** Base URL override. Defaults to https://api.vernesoft.com */
|
|
30
34
|
baseUrl?: string;
|
|
31
35
|
/** Default request timeout in milliseconds. Defaults to 30000. */
|
|
@@ -67,6 +71,154 @@ declare class HttpClient {
|
|
|
67
71
|
private request;
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
/** A recurring HTTP job scheduled on a cron expression. */
|
|
75
|
+
interface CronJob {
|
|
76
|
+
id: string;
|
|
77
|
+
tenant_id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
/** Cron expression, e.g. `'0 * * * *'` (hourly). */
|
|
80
|
+
schedule: string;
|
|
81
|
+
url: string;
|
|
82
|
+
method: string;
|
|
83
|
+
headers: Record<string, string>;
|
|
84
|
+
body: string | null;
|
|
85
|
+
is_active: boolean;
|
|
86
|
+
last_run_at: string | null;
|
|
87
|
+
next_run_at: string | null;
|
|
88
|
+
created_at: string;
|
|
89
|
+
updated_at: string;
|
|
90
|
+
}
|
|
91
|
+
/** Parameters for creating a new cron job. */
|
|
92
|
+
interface CreateCronJobParams {
|
|
93
|
+
name: string;
|
|
94
|
+
/** Cron expression, e.g. `'0 * * * *'` (hourly). */
|
|
95
|
+
schedule: string;
|
|
96
|
+
url: string;
|
|
97
|
+
/** HTTP method to invoke the target URL with. Defaults to `POST`. */
|
|
98
|
+
method?: string;
|
|
99
|
+
headers?: Record<string, string>;
|
|
100
|
+
body?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Parameters for updating an existing cron job. All fields are optional —
|
|
104
|
+
* only the fields you provide are changed.
|
|
105
|
+
*/
|
|
106
|
+
interface UpdateCronJobParams {
|
|
107
|
+
name?: string;
|
|
108
|
+
/** Cron expression, e.g. `'0 * * * *'` (hourly). */
|
|
109
|
+
schedule?: string;
|
|
110
|
+
url?: string;
|
|
111
|
+
method?: string;
|
|
112
|
+
headers?: Record<string, string>;
|
|
113
|
+
body?: string;
|
|
114
|
+
is_active?: boolean;
|
|
115
|
+
}
|
|
116
|
+
/** A one-shot HTTP job scheduled to run once at a specific time. */
|
|
117
|
+
interface DelayedJob {
|
|
118
|
+
id: string;
|
|
119
|
+
tenant_id: string;
|
|
120
|
+
name: string;
|
|
121
|
+
/** ISO 8601 timestamp at which the job should fire. */
|
|
122
|
+
run_at: string;
|
|
123
|
+
url: string;
|
|
124
|
+
method: string;
|
|
125
|
+
headers: Record<string, string>;
|
|
126
|
+
body: string | null;
|
|
127
|
+
status: string;
|
|
128
|
+
created_at: string;
|
|
129
|
+
updated_at: string;
|
|
130
|
+
}
|
|
131
|
+
/** Parameters for scheduling a new delayed job. */
|
|
132
|
+
interface CreateDelayedJobParams {
|
|
133
|
+
name: string;
|
|
134
|
+
/** ISO 8601 timestamp at which the job should fire. */
|
|
135
|
+
run_at: string;
|
|
136
|
+
url: string;
|
|
137
|
+
/** HTTP method to invoke the target URL with. Defaults to `POST`. */
|
|
138
|
+
method?: string;
|
|
139
|
+
headers?: Record<string, string>;
|
|
140
|
+
body?: string;
|
|
141
|
+
}
|
|
142
|
+
/** A single execution (run) of a cron or delayed job. */
|
|
143
|
+
interface Execution {
|
|
144
|
+
id: string;
|
|
145
|
+
job_id: string;
|
|
146
|
+
status: string;
|
|
147
|
+
started_at: string;
|
|
148
|
+
completed_at: string | null;
|
|
149
|
+
duration_ms: number | null;
|
|
150
|
+
response_status: number | null;
|
|
151
|
+
response_body: string | null;
|
|
152
|
+
error_message: string | null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
declare class ClockworkDelayedResource {
|
|
156
|
+
private readonly http;
|
|
157
|
+
constructor(http: HttpClient);
|
|
158
|
+
/**
|
|
159
|
+
* Returns all delayed (one-shot) jobs for the current tenant.
|
|
160
|
+
*/
|
|
161
|
+
list(options?: RequestOptions): Promise<DelayedJob[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Schedules a new delayed job to run once at the given `run_at` time.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* const job = await clockwork.delayed.create({
|
|
167
|
+
* name: 'send-reminder',
|
|
168
|
+
* run_at: '2026-01-01T09:00:00Z',
|
|
169
|
+
* url: 'https://example.com/hooks/reminder',
|
|
170
|
+
* });
|
|
171
|
+
*/
|
|
172
|
+
create(params: CreateDelayedJobParams, options?: RequestOptions): Promise<DelayedJob>;
|
|
173
|
+
/**
|
|
174
|
+
* Cancels a pending delayed job. Resolves on `204 No Content`.
|
|
175
|
+
*/
|
|
176
|
+
cancel(jobId: string, options?: RequestOptions): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Returns the execution history for a delayed job.
|
|
179
|
+
*/
|
|
180
|
+
executions(jobId: string, options?: RequestOptions): Promise<Execution[]>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare class ClockworkJobsResource {
|
|
184
|
+
private readonly http;
|
|
185
|
+
constructor(http: HttpClient);
|
|
186
|
+
/**
|
|
187
|
+
* Returns all cron jobs for the current tenant.
|
|
188
|
+
*/
|
|
189
|
+
list(options?: RequestOptions): Promise<CronJob[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Creates a new recurring cron job.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* const job = await clockwork.jobs.create({
|
|
195
|
+
* name: 'nightly-report',
|
|
196
|
+
* schedule: '0 2 * * *',
|
|
197
|
+
* url: 'https://example.com/hooks/report',
|
|
198
|
+
* });
|
|
199
|
+
*/
|
|
200
|
+
create(params: CreateCronJobParams, options?: RequestOptions): Promise<CronJob>;
|
|
201
|
+
/**
|
|
202
|
+
* Partially updates an existing cron job. Only the fields you provide are changed.
|
|
203
|
+
*/
|
|
204
|
+
update(jobId: string, params: UpdateCronJobParams, options?: RequestOptions): Promise<CronJob>;
|
|
205
|
+
/**
|
|
206
|
+
* Deletes a cron job. Resolves on `204 No Content`.
|
|
207
|
+
*/
|
|
208
|
+
delete(jobId: string, options?: RequestOptions): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Returns the execution history for a cron job (most recent runs first).
|
|
211
|
+
*/
|
|
212
|
+
executions(jobId: string, options?: RequestOptions): Promise<Execution[]>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
declare class Clockwork {
|
|
216
|
+
readonly jobs: ClockworkJobsResource;
|
|
217
|
+
readonly delayed: ClockworkDelayedResource;
|
|
218
|
+
private readonly http;
|
|
219
|
+
constructor(config: ServiceConfig);
|
|
220
|
+
}
|
|
221
|
+
|
|
70
222
|
/** A Kratos identity managed by Gate. */
|
|
71
223
|
interface Identity {
|
|
72
224
|
id: string;
|
|
@@ -317,6 +469,76 @@ declare class Gate {
|
|
|
317
469
|
createLoginFlow(options?: RequestOptions): Promise<LoginFlow>;
|
|
318
470
|
}
|
|
319
471
|
|
|
472
|
+
/** The Telegram end-user captured during login. */
|
|
473
|
+
interface TelegramUser {
|
|
474
|
+
id: string;
|
|
475
|
+
username?: string;
|
|
476
|
+
first_name?: string;
|
|
477
|
+
photo_url?: string;
|
|
478
|
+
}
|
|
479
|
+
/** Response from starting a Telegram login. */
|
|
480
|
+
interface LoginStart {
|
|
481
|
+
/** Opaque nonce identifying this login attempt. Poll `loginStatus(nonce)` with it. */
|
|
482
|
+
nonce: string;
|
|
483
|
+
/** `https://t.me/<bot>?start=<nonce>` — send the end-user here to authenticate. */
|
|
484
|
+
deep_link: string;
|
|
485
|
+
/** ISO-8601 timestamp after which the nonce expires. */
|
|
486
|
+
expires_at: string;
|
|
487
|
+
}
|
|
488
|
+
/** Current state of a Telegram login attempt. */
|
|
489
|
+
interface LoginStatus {
|
|
490
|
+
/** `pending` until the user completes the Telegram flow, then `completed`. */
|
|
491
|
+
status: 'pending' | 'completed';
|
|
492
|
+
/** Present once completed — the end-user's access token. */
|
|
493
|
+
access_token?: string;
|
|
494
|
+
/** Present once completed — when the access token expires (ISO-8601). */
|
|
495
|
+
expires_at?: string;
|
|
496
|
+
/** Present once completed — the provisioned Kratos identity id. */
|
|
497
|
+
identity_id?: string;
|
|
498
|
+
/** Present once completed — the authenticated Telegram user. */
|
|
499
|
+
user?: TelegramUser;
|
|
500
|
+
}
|
|
501
|
+
/** Result of introspecting a Passepartout access token. */
|
|
502
|
+
interface TokenIntrospection {
|
|
503
|
+
active: boolean;
|
|
504
|
+
subject?: string;
|
|
505
|
+
tenant_id?: string;
|
|
506
|
+
scopes?: string[];
|
|
507
|
+
expires_at?: string;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Verne Passepartout — Telegram Auth-as-a-Service.
|
|
512
|
+
*
|
|
513
|
+
* Lets your end-users sign in with Telegram: start a login to get a deep link,
|
|
514
|
+
* send the user to it, then poll for completion to receive an access token.
|
|
515
|
+
*/
|
|
516
|
+
declare class Passepartout {
|
|
517
|
+
private readonly http;
|
|
518
|
+
constructor(config: ServiceConfig);
|
|
519
|
+
/**
|
|
520
|
+
* Starts a Telegram login and returns a nonce + deep link. Send the user to
|
|
521
|
+
* `deep_link`, then poll {@link loginStatus} with `nonce` until it completes.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* const { nonce, deep_link } = await passepartout.loginStart();
|
|
525
|
+
* // redirect the user to `deep_link`, then poll:
|
|
526
|
+
* const status = await passepartout.loginStatus(nonce);
|
|
527
|
+
*/
|
|
528
|
+
loginStart(options?: RequestOptions): Promise<LoginStart>;
|
|
529
|
+
/**
|
|
530
|
+
* Returns the current state of a login attempt. While the user hasn't
|
|
531
|
+
* finished, `status` is `pending`; once done it becomes `completed` and
|
|
532
|
+
* carries the `access_token` and `user`.
|
|
533
|
+
*/
|
|
534
|
+
loginStatus(nonce: string, options?: RequestOptions): Promise<LoginStatus>;
|
|
535
|
+
/**
|
|
536
|
+
* Validates a Passepartout access token and returns its attributes.
|
|
537
|
+
* Tokens owned by another tenant are reported as `{ active: false }`.
|
|
538
|
+
*/
|
|
539
|
+
introspect(accessToken: string, options?: RequestOptions): Promise<TokenIntrospection>;
|
|
540
|
+
}
|
|
541
|
+
|
|
320
542
|
/** A message (event) as returned by the Relay API. */
|
|
321
543
|
interface Message {
|
|
322
544
|
/** Unique message identifier. */
|
|
@@ -379,9 +601,13 @@ declare class Verne {
|
|
|
379
601
|
private readonly config;
|
|
380
602
|
private _relay?;
|
|
381
603
|
private _gate?;
|
|
604
|
+
private _passepartout?;
|
|
605
|
+
private _clockwork?;
|
|
382
606
|
constructor(config: VerneConfig);
|
|
383
607
|
get relay(): Relay;
|
|
384
608
|
get gate(): Gate;
|
|
609
|
+
get passepartout(): Passepartout;
|
|
610
|
+
get clockwork(): Clockwork;
|
|
385
611
|
}
|
|
386
612
|
|
|
387
613
|
/**
|
|
@@ -418,4 +644,4 @@ interface APIErrorBody {
|
|
|
418
644
|
};
|
|
419
645
|
}
|
|
420
646
|
|
|
421
|
-
export { type APIErrorBody, type AccessToken, type AuthorizeParams, type AuthorizeResult, type CreateIdentityParams, type CreateTokenParams, Gate, type Identity, type IdentityTraits, type IntrospectResult, type JsonPatchOp, type ListMessagesParams, type ListMessagesResponse, type LoginFlow, type Message, type OidcProvider, type Paginated, Relay, type RequestOptions, type SecuritySettings, type SendMessageParams, type ServiceConfig, Verne, VerneAPIError, type VerneConfig, VerneError };
|
|
647
|
+
export { type APIErrorBody, type AccessToken, type AuthorizeParams, type AuthorizeResult, Clockwork, type CreateCronJobParams, type CreateDelayedJobParams, type CreateIdentityParams, type CreateTokenParams, type CronJob, type DelayedJob, type Execution, Gate, type Identity, type IdentityTraits, type IntrospectResult, type JsonPatchOp, type ListMessagesParams, type ListMessagesResponse, type LoginFlow, type LoginStart, type LoginStatus, type Message, type OidcProvider, type Paginated, Passepartout, Relay, type RequestOptions, type SecuritySettings, type SendMessageParams, type ServiceConfig, type TelegramUser, type TokenIntrospection, type UpdateCronJobParams, Verne, VerneAPIError, type VerneConfig, VerneError };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ interface VerneConfig {
|
|
|
26
26
|
relay?: string;
|
|
27
27
|
/** API key for the Gate (Auth-as-a-Service) service. Format: vrn_gate_<env>_<secret> */
|
|
28
28
|
gate?: string;
|
|
29
|
+
/** API key for the Passepartout (Telegram Auth) service. Format: vrn_passepartout_<env>_<secret> */
|
|
30
|
+
passepartout?: string;
|
|
31
|
+
/** API key for the Clockwork (Cron-as-a-Service) service. Format: vrn_clockwork_<env>_<secret> */
|
|
32
|
+
clockwork?: string;
|
|
29
33
|
/** Base URL override. Defaults to https://api.vernesoft.com */
|
|
30
34
|
baseUrl?: string;
|
|
31
35
|
/** Default request timeout in milliseconds. Defaults to 30000. */
|
|
@@ -67,6 +71,154 @@ declare class HttpClient {
|
|
|
67
71
|
private request;
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
/** A recurring HTTP job scheduled on a cron expression. */
|
|
75
|
+
interface CronJob {
|
|
76
|
+
id: string;
|
|
77
|
+
tenant_id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
/** Cron expression, e.g. `'0 * * * *'` (hourly). */
|
|
80
|
+
schedule: string;
|
|
81
|
+
url: string;
|
|
82
|
+
method: string;
|
|
83
|
+
headers: Record<string, string>;
|
|
84
|
+
body: string | null;
|
|
85
|
+
is_active: boolean;
|
|
86
|
+
last_run_at: string | null;
|
|
87
|
+
next_run_at: string | null;
|
|
88
|
+
created_at: string;
|
|
89
|
+
updated_at: string;
|
|
90
|
+
}
|
|
91
|
+
/** Parameters for creating a new cron job. */
|
|
92
|
+
interface CreateCronJobParams {
|
|
93
|
+
name: string;
|
|
94
|
+
/** Cron expression, e.g. `'0 * * * *'` (hourly). */
|
|
95
|
+
schedule: string;
|
|
96
|
+
url: string;
|
|
97
|
+
/** HTTP method to invoke the target URL with. Defaults to `POST`. */
|
|
98
|
+
method?: string;
|
|
99
|
+
headers?: Record<string, string>;
|
|
100
|
+
body?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Parameters for updating an existing cron job. All fields are optional —
|
|
104
|
+
* only the fields you provide are changed.
|
|
105
|
+
*/
|
|
106
|
+
interface UpdateCronJobParams {
|
|
107
|
+
name?: string;
|
|
108
|
+
/** Cron expression, e.g. `'0 * * * *'` (hourly). */
|
|
109
|
+
schedule?: string;
|
|
110
|
+
url?: string;
|
|
111
|
+
method?: string;
|
|
112
|
+
headers?: Record<string, string>;
|
|
113
|
+
body?: string;
|
|
114
|
+
is_active?: boolean;
|
|
115
|
+
}
|
|
116
|
+
/** A one-shot HTTP job scheduled to run once at a specific time. */
|
|
117
|
+
interface DelayedJob {
|
|
118
|
+
id: string;
|
|
119
|
+
tenant_id: string;
|
|
120
|
+
name: string;
|
|
121
|
+
/** ISO 8601 timestamp at which the job should fire. */
|
|
122
|
+
run_at: string;
|
|
123
|
+
url: string;
|
|
124
|
+
method: string;
|
|
125
|
+
headers: Record<string, string>;
|
|
126
|
+
body: string | null;
|
|
127
|
+
status: string;
|
|
128
|
+
created_at: string;
|
|
129
|
+
updated_at: string;
|
|
130
|
+
}
|
|
131
|
+
/** Parameters for scheduling a new delayed job. */
|
|
132
|
+
interface CreateDelayedJobParams {
|
|
133
|
+
name: string;
|
|
134
|
+
/** ISO 8601 timestamp at which the job should fire. */
|
|
135
|
+
run_at: string;
|
|
136
|
+
url: string;
|
|
137
|
+
/** HTTP method to invoke the target URL with. Defaults to `POST`. */
|
|
138
|
+
method?: string;
|
|
139
|
+
headers?: Record<string, string>;
|
|
140
|
+
body?: string;
|
|
141
|
+
}
|
|
142
|
+
/** A single execution (run) of a cron or delayed job. */
|
|
143
|
+
interface Execution {
|
|
144
|
+
id: string;
|
|
145
|
+
job_id: string;
|
|
146
|
+
status: string;
|
|
147
|
+
started_at: string;
|
|
148
|
+
completed_at: string | null;
|
|
149
|
+
duration_ms: number | null;
|
|
150
|
+
response_status: number | null;
|
|
151
|
+
response_body: string | null;
|
|
152
|
+
error_message: string | null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
declare class ClockworkDelayedResource {
|
|
156
|
+
private readonly http;
|
|
157
|
+
constructor(http: HttpClient);
|
|
158
|
+
/**
|
|
159
|
+
* Returns all delayed (one-shot) jobs for the current tenant.
|
|
160
|
+
*/
|
|
161
|
+
list(options?: RequestOptions): Promise<DelayedJob[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Schedules a new delayed job to run once at the given `run_at` time.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* const job = await clockwork.delayed.create({
|
|
167
|
+
* name: 'send-reminder',
|
|
168
|
+
* run_at: '2026-01-01T09:00:00Z',
|
|
169
|
+
* url: 'https://example.com/hooks/reminder',
|
|
170
|
+
* });
|
|
171
|
+
*/
|
|
172
|
+
create(params: CreateDelayedJobParams, options?: RequestOptions): Promise<DelayedJob>;
|
|
173
|
+
/**
|
|
174
|
+
* Cancels a pending delayed job. Resolves on `204 No Content`.
|
|
175
|
+
*/
|
|
176
|
+
cancel(jobId: string, options?: RequestOptions): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Returns the execution history for a delayed job.
|
|
179
|
+
*/
|
|
180
|
+
executions(jobId: string, options?: RequestOptions): Promise<Execution[]>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare class ClockworkJobsResource {
|
|
184
|
+
private readonly http;
|
|
185
|
+
constructor(http: HttpClient);
|
|
186
|
+
/**
|
|
187
|
+
* Returns all cron jobs for the current tenant.
|
|
188
|
+
*/
|
|
189
|
+
list(options?: RequestOptions): Promise<CronJob[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Creates a new recurring cron job.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* const job = await clockwork.jobs.create({
|
|
195
|
+
* name: 'nightly-report',
|
|
196
|
+
* schedule: '0 2 * * *',
|
|
197
|
+
* url: 'https://example.com/hooks/report',
|
|
198
|
+
* });
|
|
199
|
+
*/
|
|
200
|
+
create(params: CreateCronJobParams, options?: RequestOptions): Promise<CronJob>;
|
|
201
|
+
/**
|
|
202
|
+
* Partially updates an existing cron job. Only the fields you provide are changed.
|
|
203
|
+
*/
|
|
204
|
+
update(jobId: string, params: UpdateCronJobParams, options?: RequestOptions): Promise<CronJob>;
|
|
205
|
+
/**
|
|
206
|
+
* Deletes a cron job. Resolves on `204 No Content`.
|
|
207
|
+
*/
|
|
208
|
+
delete(jobId: string, options?: RequestOptions): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Returns the execution history for a cron job (most recent runs first).
|
|
211
|
+
*/
|
|
212
|
+
executions(jobId: string, options?: RequestOptions): Promise<Execution[]>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
declare class Clockwork {
|
|
216
|
+
readonly jobs: ClockworkJobsResource;
|
|
217
|
+
readonly delayed: ClockworkDelayedResource;
|
|
218
|
+
private readonly http;
|
|
219
|
+
constructor(config: ServiceConfig);
|
|
220
|
+
}
|
|
221
|
+
|
|
70
222
|
/** A Kratos identity managed by Gate. */
|
|
71
223
|
interface Identity {
|
|
72
224
|
id: string;
|
|
@@ -317,6 +469,76 @@ declare class Gate {
|
|
|
317
469
|
createLoginFlow(options?: RequestOptions): Promise<LoginFlow>;
|
|
318
470
|
}
|
|
319
471
|
|
|
472
|
+
/** The Telegram end-user captured during login. */
|
|
473
|
+
interface TelegramUser {
|
|
474
|
+
id: string;
|
|
475
|
+
username?: string;
|
|
476
|
+
first_name?: string;
|
|
477
|
+
photo_url?: string;
|
|
478
|
+
}
|
|
479
|
+
/** Response from starting a Telegram login. */
|
|
480
|
+
interface LoginStart {
|
|
481
|
+
/** Opaque nonce identifying this login attempt. Poll `loginStatus(nonce)` with it. */
|
|
482
|
+
nonce: string;
|
|
483
|
+
/** `https://t.me/<bot>?start=<nonce>` — send the end-user here to authenticate. */
|
|
484
|
+
deep_link: string;
|
|
485
|
+
/** ISO-8601 timestamp after which the nonce expires. */
|
|
486
|
+
expires_at: string;
|
|
487
|
+
}
|
|
488
|
+
/** Current state of a Telegram login attempt. */
|
|
489
|
+
interface LoginStatus {
|
|
490
|
+
/** `pending` until the user completes the Telegram flow, then `completed`. */
|
|
491
|
+
status: 'pending' | 'completed';
|
|
492
|
+
/** Present once completed — the end-user's access token. */
|
|
493
|
+
access_token?: string;
|
|
494
|
+
/** Present once completed — when the access token expires (ISO-8601). */
|
|
495
|
+
expires_at?: string;
|
|
496
|
+
/** Present once completed — the provisioned Kratos identity id. */
|
|
497
|
+
identity_id?: string;
|
|
498
|
+
/** Present once completed — the authenticated Telegram user. */
|
|
499
|
+
user?: TelegramUser;
|
|
500
|
+
}
|
|
501
|
+
/** Result of introspecting a Passepartout access token. */
|
|
502
|
+
interface TokenIntrospection {
|
|
503
|
+
active: boolean;
|
|
504
|
+
subject?: string;
|
|
505
|
+
tenant_id?: string;
|
|
506
|
+
scopes?: string[];
|
|
507
|
+
expires_at?: string;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Verne Passepartout — Telegram Auth-as-a-Service.
|
|
512
|
+
*
|
|
513
|
+
* Lets your end-users sign in with Telegram: start a login to get a deep link,
|
|
514
|
+
* send the user to it, then poll for completion to receive an access token.
|
|
515
|
+
*/
|
|
516
|
+
declare class Passepartout {
|
|
517
|
+
private readonly http;
|
|
518
|
+
constructor(config: ServiceConfig);
|
|
519
|
+
/**
|
|
520
|
+
* Starts a Telegram login and returns a nonce + deep link. Send the user to
|
|
521
|
+
* `deep_link`, then poll {@link loginStatus} with `nonce` until it completes.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* const { nonce, deep_link } = await passepartout.loginStart();
|
|
525
|
+
* // redirect the user to `deep_link`, then poll:
|
|
526
|
+
* const status = await passepartout.loginStatus(nonce);
|
|
527
|
+
*/
|
|
528
|
+
loginStart(options?: RequestOptions): Promise<LoginStart>;
|
|
529
|
+
/**
|
|
530
|
+
* Returns the current state of a login attempt. While the user hasn't
|
|
531
|
+
* finished, `status` is `pending`; once done it becomes `completed` and
|
|
532
|
+
* carries the `access_token` and `user`.
|
|
533
|
+
*/
|
|
534
|
+
loginStatus(nonce: string, options?: RequestOptions): Promise<LoginStatus>;
|
|
535
|
+
/**
|
|
536
|
+
* Validates a Passepartout access token and returns its attributes.
|
|
537
|
+
* Tokens owned by another tenant are reported as `{ active: false }`.
|
|
538
|
+
*/
|
|
539
|
+
introspect(accessToken: string, options?: RequestOptions): Promise<TokenIntrospection>;
|
|
540
|
+
}
|
|
541
|
+
|
|
320
542
|
/** A message (event) as returned by the Relay API. */
|
|
321
543
|
interface Message {
|
|
322
544
|
/** Unique message identifier. */
|
|
@@ -379,9 +601,13 @@ declare class Verne {
|
|
|
379
601
|
private readonly config;
|
|
380
602
|
private _relay?;
|
|
381
603
|
private _gate?;
|
|
604
|
+
private _passepartout?;
|
|
605
|
+
private _clockwork?;
|
|
382
606
|
constructor(config: VerneConfig);
|
|
383
607
|
get relay(): Relay;
|
|
384
608
|
get gate(): Gate;
|
|
609
|
+
get passepartout(): Passepartout;
|
|
610
|
+
get clockwork(): Clockwork;
|
|
385
611
|
}
|
|
386
612
|
|
|
387
613
|
/**
|
|
@@ -418,4 +644,4 @@ interface APIErrorBody {
|
|
|
418
644
|
};
|
|
419
645
|
}
|
|
420
646
|
|
|
421
|
-
export { type APIErrorBody, type AccessToken, type AuthorizeParams, type AuthorizeResult, type CreateIdentityParams, type CreateTokenParams, Gate, type Identity, type IdentityTraits, type IntrospectResult, type JsonPatchOp, type ListMessagesParams, type ListMessagesResponse, type LoginFlow, type Message, type OidcProvider, type Paginated, Relay, type RequestOptions, type SecuritySettings, type SendMessageParams, type ServiceConfig, Verne, VerneAPIError, type VerneConfig, VerneError };
|
|
647
|
+
export { type APIErrorBody, type AccessToken, type AuthorizeParams, type AuthorizeResult, Clockwork, type CreateCronJobParams, type CreateDelayedJobParams, type CreateIdentityParams, type CreateTokenParams, type CronJob, type DelayedJob, type Execution, Gate, type Identity, type IdentityTraits, type IntrospectResult, type JsonPatchOp, type ListMessagesParams, type ListMessagesResponse, type LoginFlow, type LoginStart, type LoginStatus, type Message, type OidcProvider, type Paginated, Passepartout, Relay, type RequestOptions, type SecuritySettings, type SendMessageParams, type ServiceConfig, type TelegramUser, type TokenIntrospection, type UpdateCronJobParams, Verne, VerneAPIError, type VerneConfig, VerneError };
|