@zurchin/sdk 0.0.0 → 2.16.1
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/CHANGELOG.md +216 -0
- package/LICENSE +55 -0
- package/README.md +189 -1
- package/dist/auth.d.ts +152 -0
- package/dist/auth.js +189 -0
- package/dist/credential.d.ts +96 -0
- package/dist/credential.js +297 -0
- package/dist/declared-agents.d.ts +9 -0
- package/dist/declared-agents.js +46 -0
- package/dist/index.d.ts +1187 -0
- package/dist/index.js +714 -0
- package/dist/next.d.ts +104 -0
- package/dist/next.js +300 -0
- package/dist/node.d.ts +139 -0
- package/dist/node.js +402 -0
- package/dist/verdict.d.ts +57 -0
- package/dist/verdict.js +116 -0
- package/package.json +66 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pidgeon's TypeScript SDK: email for founders, teams and agents.
|
|
3
|
+
*
|
|
4
|
+
* `new Pidgeon({ apiKey })`: `.inboxes`, `.messages` and `.drafts` give an
|
|
5
|
+
* agent its own address on @pidgeon.email or your domain, send from it and
|
|
6
|
+
* wait for the reply; `.threads`, `.labels`, `.contacts`, `.attachments`,
|
|
7
|
+
* `.domains` and `.calendar` are the rest of Email. For a platform, `.pods`
|
|
8
|
+
* gives each of your users inboxes of their own.
|
|
9
|
+
*
|
|
10
|
+
* Sign in with Pidgeon: `.agents.setUp()` registers an agent, makes its key
|
|
11
|
+
* here and publishes the public half; `signedFetch`, or `agentFromEnv().fetch`,
|
|
12
|
+
* signs its requests; `.sites` and `.mandates` register sites and ask
|
|
13
|
+
* people's permission. `generateAgentKey()` and `.publishKey()` make a key
|
|
14
|
+
* where the agent runs and publish its public half.
|
|
15
|
+
*/
|
|
16
|
+
import { generateAgentKey, type AgentKeyPair } from './credential.ts';
|
|
17
|
+
export * from './credential.ts';
|
|
18
|
+
export { DECLARED_AGENT_TOKENS, declaredAgentToken } from './declared-agents.ts';
|
|
19
|
+
/**
|
|
20
|
+
* Where the API is: zurchin.com since the switch from Pidgeon (pidgeon.ai keeps
|
|
21
|
+
* answering the API for six months, so a client pointed there still works). `auth.ts`, the CLI, the MCP server
|
|
22
|
+
* and the AI SDK tools read it from here.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_BASE_URL = "https://zurchin.com";
|
|
25
|
+
type Env = Record<string, string | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* A setting from the environment, by its name after the prefix: `ZURCHIN_<name>`
|
|
28
|
+
* first, then `PIDGEON_<name>` (Pidgeon is becoming Zurchin, and both names work).
|
|
29
|
+
* An empty value counts as unset.
|
|
30
|
+
*/
|
|
31
|
+
export declare function envSetting(name: string, env?: Env): string | undefined;
|
|
32
|
+
export type Band = 'unverified' | 'new' | 'good' | 'flagged' | 'suspended';
|
|
33
|
+
/**
|
|
34
|
+
* What a check found (Patrick, 17 and 20 November), never saying more than
|
|
35
|
+
* is true:
|
|
36
|
+
* - `verified`: the signature holds and the key is a Pidgeon operator's.
|
|
37
|
+
* - `signed_known`: it holds against a directory outside Pidgeon on Pidgeon's
|
|
38
|
+
* recognised list (`signature_agent.operator` names whose). Not verified.
|
|
39
|
+
* - `signed_unknown`: it holds against a directory nobody vouches for.
|
|
40
|
+
* - `declared`: not signed, but its User-Agent names an agent on Pidgeon's
|
|
41
|
+
* list (`declared` says which, and whether its address is the vendor's).
|
|
42
|
+
* Since 20 November 2026; such a request was `refused`, `unsigned` before.
|
|
43
|
+
* - `refused`: unsigned, a bad signature, expired, revoked or replayed.
|
|
44
|
+
*/
|
|
45
|
+
export type CheckResult = 'verified' | 'signed_known' | 'signed_unknown' | 'declared' | 'refused';
|
|
46
|
+
/**
|
|
47
|
+
* Who a `declared` agent says it is: the token of its User-Agent, its
|
|
48
|
+
* vendor, what it is for, and whether its address is in the vendor's
|
|
49
|
+
* published ranges (`confirmed`, `mismatch`), or could not be checked
|
|
50
|
+
* (`unchecked`: no address sent, or the vendor publishes none).
|
|
51
|
+
*/
|
|
52
|
+
export type DeclaredAs = {
|
|
53
|
+
name: string;
|
|
54
|
+
operator: string;
|
|
55
|
+
purpose: 'user' | 'search' | 'training';
|
|
56
|
+
ip: 'confirmed' | 'mismatch' | 'unchecked';
|
|
57
|
+
};
|
|
58
|
+
/** Where on a website a check happens: a site rule is set per place. */
|
|
59
|
+
export type Place = 'signup' | 'checkout' | 'api' | 'other';
|
|
60
|
+
/** Who a place lets through: `any` agent but a flagged operator's, `known` (verified or recognised), or `verified` only. */
|
|
61
|
+
export type Requirement = 'any' | 'known' | 'verified';
|
|
62
|
+
/**
|
|
63
|
+
* What a website's rule decided about a check:
|
|
64
|
+
* - `allow`: Pidgeon vouches for the agent under the rule; the site may skip its own friction.
|
|
65
|
+
* - `limit`: Pidgeon couldn't identify it, so the site's own rules decide.
|
|
66
|
+
* - `block`: turn it away.
|
|
67
|
+
* - `watch`: the place only watches; `would` says what it would have decided.
|
|
68
|
+
*/
|
|
69
|
+
export type Decision = 'allow' | 'limit' | 'block' | 'watch';
|
|
70
|
+
/** One place's rule. */
|
|
71
|
+
export type PlaceRule = {
|
|
72
|
+
require: Requirement;
|
|
73
|
+
enforce: boolean;
|
|
74
|
+
};
|
|
75
|
+
/** A website's rules: one per place. */
|
|
76
|
+
export type SiteRules = Record<Place, PlaceRule>;
|
|
77
|
+
/** What the rule made of a check. Absent from answers before 20 November 2026. */
|
|
78
|
+
export type RuleOutcome = {
|
|
79
|
+
place: Place;
|
|
80
|
+
decision: Decision;
|
|
81
|
+
/** While watching: what the rule would have decided. */
|
|
82
|
+
would?: Exclude<Decision, 'watch'>;
|
|
83
|
+
/** One line: the place, its rule, and the agent. */
|
|
84
|
+
rule: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* What `verify` answers. `valid` is true for `verified` only, as it always
|
|
88
|
+
* was: an integration that reads only `valid` sees an agent from outside
|
|
89
|
+
* Pidgeon as before, not valid with `reason: 'unknown_key'`. Read `result`
|
|
90
|
+
* for the four.
|
|
91
|
+
*/
|
|
92
|
+
export type VerifyAnswer = Partial<RuleOutcome> & ({
|
|
93
|
+
valid: true;
|
|
94
|
+
/** Absent from answers before 17 November 2026. */
|
|
95
|
+
result?: 'verified';
|
|
96
|
+
verification_id: string;
|
|
97
|
+
agent: {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
purpose: string;
|
|
101
|
+
};
|
|
102
|
+
operator: {
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
kind: 'individual' | 'business';
|
|
106
|
+
verification: 'none' | 'domain' | 'kyc' | 'kyb';
|
|
107
|
+
country: string | null;
|
|
108
|
+
since: string;
|
|
109
|
+
/** The operator's verified domains. */
|
|
110
|
+
domains?: string[];
|
|
111
|
+
};
|
|
112
|
+
reputation: {
|
|
113
|
+
band: Band;
|
|
114
|
+
seen_at_receivers: number;
|
|
115
|
+
reports_90d: number;
|
|
116
|
+
revoked: false;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Whether Pidgeon will refuse this signature if it is sent again: true
|
|
120
|
+
* when it carries a nonce (every signature these SDKs make does).
|
|
121
|
+
*/
|
|
122
|
+
replay_protected?: boolean;
|
|
123
|
+
/** A signed verdict to hand a sign-up hook (`VerdictClaims`). Absent from answers before 19 November 2026. */
|
|
124
|
+
verdict?: string;
|
|
125
|
+
} | {
|
|
126
|
+
valid: false;
|
|
127
|
+
result: 'signed_known' | 'signed_unknown';
|
|
128
|
+
verification_id: string;
|
|
129
|
+
/** Pidgeon published no such key; the directory the signature names did. */
|
|
130
|
+
reason: 'unknown_key';
|
|
131
|
+
/** The directory the key came from, and the recognised operator behind it, if any. */
|
|
132
|
+
signature_agent: {
|
|
133
|
+
directory: string;
|
|
134
|
+
host: string;
|
|
135
|
+
operator: string | null;
|
|
136
|
+
};
|
|
137
|
+
replay_protected?: boolean;
|
|
138
|
+
/** As for `verified`: a signed verdict to hand a sign-up hook. */
|
|
139
|
+
verdict?: string;
|
|
140
|
+
} | {
|
|
141
|
+
valid: false;
|
|
142
|
+
result: 'declared';
|
|
143
|
+
verification_id: string;
|
|
144
|
+
/** It carries no signature. */
|
|
145
|
+
reason: 'unsigned';
|
|
146
|
+
declared: DeclaredAs;
|
|
147
|
+
} | {
|
|
148
|
+
valid: false;
|
|
149
|
+
/** Absent from answers before 17 November 2026. */
|
|
150
|
+
result?: 'refused';
|
|
151
|
+
verification_id: string;
|
|
152
|
+
/** `replayed`: this signature was verified before, so the request is a copy. */
|
|
153
|
+
reason: 'unsigned' | 'invalid' | 'unknown_key' | 'expired' | 'revoked' | 'replayed';
|
|
154
|
+
operator?: {
|
|
155
|
+
id: string;
|
|
156
|
+
name: string;
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
/**
|
|
160
|
+
* One visit for `pidgeon.visits.record`: the request's method, the URL the
|
|
161
|
+
* agent called (leave the query string out: it is never stored), its
|
|
162
|
+
* User-Agent, the visitor's address (checked against the vendor's published
|
|
163
|
+
* ranges, not stored), where on your site it was, and when (ISO 8601, within
|
|
164
|
+
* the last hour).
|
|
165
|
+
*/
|
|
166
|
+
export type Visit = {
|
|
167
|
+
method: string;
|
|
168
|
+
url: string;
|
|
169
|
+
user_agent: string;
|
|
170
|
+
ip?: string;
|
|
171
|
+
place?: Place;
|
|
172
|
+
at?: string;
|
|
173
|
+
};
|
|
174
|
+
/** The header a proxy hands the verdict on in, to the app behind it. */
|
|
175
|
+
export declare const VERDICT_HEADER = "pidgeon-verdict";
|
|
176
|
+
/** How long a verdict lasts after Pidgeon signs it. */
|
|
177
|
+
export declare const VERDICT_LIFETIME_SECONDS = 300;
|
|
178
|
+
/**
|
|
179
|
+
* What a verdict says: a compact JWS (RS256, `typ` `pidgeon-verdict+jwt`)
|
|
180
|
+
* that Pidgeon signs with the key it publishes at
|
|
181
|
+
* `https://pidgeon.ai/.well-known/jwks.json`, when `/v1/verify` finds a
|
|
182
|
+
* signature that holds (`verified`, `signed_known`, `signed_unknown`; never
|
|
183
|
+
* for `refused`). It lets a sign-up hook that cannot see the agent's request
|
|
184
|
+
* (Supabase, Auth0, WorkOS) trust what the website's proxy saw.
|
|
185
|
+
*/
|
|
186
|
+
export type VerdictClaims = {
|
|
187
|
+
iss: string;
|
|
188
|
+
/** The origin the agent signed its request for, as `https://shop.example`. */
|
|
189
|
+
aud: string;
|
|
190
|
+
/** The website's Pidgeon account, whose key asked. */
|
|
191
|
+
receiver: string;
|
|
192
|
+
/** The check it came from (`verification_id`); a verdict is spent once when checked with Pidgeon. */
|
|
193
|
+
jti: string;
|
|
194
|
+
iat: number;
|
|
195
|
+
exp: number;
|
|
196
|
+
result: 'verified' | 'signed_known' | 'signed_unknown';
|
|
197
|
+
/** The signature's key id (its JWK thumbprint). */
|
|
198
|
+
keyid: string;
|
|
199
|
+
/** The agent's address as the website saw it, when the website said. */
|
|
200
|
+
ip?: string;
|
|
201
|
+
/** `verified` only. */
|
|
202
|
+
agent?: {
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
};
|
|
206
|
+
/** `verified` only. */
|
|
207
|
+
operator?: {
|
|
208
|
+
id: string;
|
|
209
|
+
name: string;
|
|
210
|
+
kind: 'individual' | 'business';
|
|
211
|
+
verification: 'none' | 'domain' | 'kyc' | 'kyb';
|
|
212
|
+
country: string | null;
|
|
213
|
+
};
|
|
214
|
+
/** `verified` only: the operator's reputation band when it was signed. */
|
|
215
|
+
band?: Band;
|
|
216
|
+
/** The two signed results: the outside directory the key came from. */
|
|
217
|
+
signature_agent?: {
|
|
218
|
+
directory: string;
|
|
219
|
+
host: string;
|
|
220
|
+
operator: string | null;
|
|
221
|
+
};
|
|
222
|
+
/** The site's rule when it was signed (absent from verdicts before 20 November 2026): act on `decision`. */
|
|
223
|
+
place?: Place;
|
|
224
|
+
decision?: Decision;
|
|
225
|
+
would?: Exclude<Decision, 'watch'>;
|
|
226
|
+
rule?: string;
|
|
227
|
+
};
|
|
228
|
+
/** Why a verdict was refused. */
|
|
229
|
+
export type VerdictRefusal = 'invalid' | 'expired' | 'wrong_site' | 'wrong_account' | 'wrong_ip' | 'used' | 'revoked';
|
|
230
|
+
/** What `checkVerdict` answers. */
|
|
231
|
+
export type VerdictCheck = {
|
|
232
|
+
valid: true;
|
|
233
|
+
verdict: VerdictClaims;
|
|
234
|
+
} | {
|
|
235
|
+
valid: false;
|
|
236
|
+
reason: VerdictRefusal;
|
|
237
|
+
};
|
|
238
|
+
export type ReportCategory = 'fraud' | 'abuse' | 'scraping' | 'spam' | 'fake_signups' | 'other';
|
|
239
|
+
export declare class PidgeonError extends Error {
|
|
240
|
+
readonly status: number;
|
|
241
|
+
readonly code: string;
|
|
242
|
+
constructor(status: number, code: string, message: string);
|
|
243
|
+
}
|
|
244
|
+
/** An agent's request, as a website received it. */
|
|
245
|
+
export type IncomingRequest = Request | {
|
|
246
|
+
method: string;
|
|
247
|
+
url: string;
|
|
248
|
+
headers: Record<string, string | string[] | undefined> | Headers;
|
|
249
|
+
};
|
|
250
|
+
/** A page of a `/v1` list: every list answers this shape. */
|
|
251
|
+
export type Page<T> = {
|
|
252
|
+
data: T[];
|
|
253
|
+
has_more: boolean;
|
|
254
|
+
next_cursor: string | null;
|
|
255
|
+
};
|
|
256
|
+
export type ListOptions = {
|
|
257
|
+
limit?: number;
|
|
258
|
+
cursor?: string;
|
|
259
|
+
};
|
|
260
|
+
/** What `messages.search` narrows by, beside the words. */
|
|
261
|
+
export type SearchOptions = ListOptions & {
|
|
262
|
+
inboxId?: string;
|
|
263
|
+
body?: BodyChoice;
|
|
264
|
+
};
|
|
265
|
+
/** An agent identity, as `/v1/agents` answers it: who an agent is when it signs mail and signs in. */
|
|
266
|
+
export type Agent = {
|
|
267
|
+
id: string;
|
|
268
|
+
name: string;
|
|
269
|
+
purpose: string;
|
|
270
|
+
status: 'active' | 'revoked';
|
|
271
|
+
pod_id: string;
|
|
272
|
+
created_at: string;
|
|
273
|
+
revoked_at: string | null;
|
|
274
|
+
};
|
|
275
|
+
/** One agent identity in full: its published keys, its directory, and its operator's reputation. */
|
|
276
|
+
export type AgentDetail = Agent & {
|
|
277
|
+
directory: string;
|
|
278
|
+
keys: {
|
|
279
|
+
kid: string;
|
|
280
|
+
created_at: string;
|
|
281
|
+
expires_at: string | null;
|
|
282
|
+
revoked_at: string | null;
|
|
283
|
+
}[];
|
|
284
|
+
reputation: {
|
|
285
|
+
band: Band;
|
|
286
|
+
seen: string;
|
|
287
|
+
next: string | null;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* `agent`: an agent's inbox (the default). `person`: a person's own address,
|
|
292
|
+
* made in Pidgeon. `shared`: the team's, or some people's (hello@).
|
|
293
|
+
* `events`: receives only, as events.
|
|
294
|
+
*/
|
|
295
|
+
export type InboxKind = 'agent' | 'person' | 'shared' | 'events';
|
|
296
|
+
/**
|
|
297
|
+
* Who reads an inbox: `just_me` (one person and the keys they add), `some`
|
|
298
|
+
* (the people chosen), `team` (everyone in the team) or `agent` (its keys and
|
|
299
|
+
* the people supervising it). An account-wide key never reaches a `just_me`
|
|
300
|
+
* inbox it was not added to.
|
|
301
|
+
*/
|
|
302
|
+
export type InboxAccess = 'just_me' | 'some' | 'team' | 'agent';
|
|
303
|
+
/** What a key may do on an inbox it is added to; `draft` waits for a person. A person always sends. */
|
|
304
|
+
export type MemberLevel = 'read' | 'draft' | 'send';
|
|
305
|
+
export type InboxMember = {
|
|
306
|
+
id: string;
|
|
307
|
+
type: 'person' | 'key';
|
|
308
|
+
user_id: string | null;
|
|
309
|
+
key_id: string | null;
|
|
310
|
+
name: string;
|
|
311
|
+
email: string | null;
|
|
312
|
+
/** `oauth` for a connected app. */
|
|
313
|
+
key_kind: 'key' | 'oauth' | null;
|
|
314
|
+
level: MemberLevel;
|
|
315
|
+
created_at: string;
|
|
316
|
+
};
|
|
317
|
+
export type InboxMembers = {
|
|
318
|
+
inbox_id: string;
|
|
319
|
+
access: InboxAccess;
|
|
320
|
+
kind: InboxKind;
|
|
321
|
+
members: InboxMember[];
|
|
322
|
+
reassigned: {
|
|
323
|
+
from_user: string | null;
|
|
324
|
+
to_user: string | null;
|
|
325
|
+
at: string;
|
|
326
|
+
} | null;
|
|
327
|
+
};
|
|
328
|
+
export type Inbox = {
|
|
329
|
+
id: string;
|
|
330
|
+
/** Its main address: the one its mail is sent from. */
|
|
331
|
+
address: string;
|
|
332
|
+
/** Every address it receives at, the main one first. */
|
|
333
|
+
addresses?: string[];
|
|
334
|
+
kind: InboxKind;
|
|
335
|
+
/** Who reads it. */
|
|
336
|
+
access: InboxAccess;
|
|
337
|
+
display_name: string | null;
|
|
338
|
+
pod_id: string;
|
|
339
|
+
agent_id: string | null;
|
|
340
|
+
status: 'active' | 'suspended';
|
|
341
|
+
/** Mail the Firewall calls suspicious waits for a person. */
|
|
342
|
+
hold_suspicious: boolean;
|
|
343
|
+
/** Added under mail a person writes from this address in the mail client. */
|
|
344
|
+
signature: string | null;
|
|
345
|
+
created_at: string;
|
|
346
|
+
};
|
|
347
|
+
/** The Firewall's reading of a received message. */
|
|
348
|
+
export type Firewall = {
|
|
349
|
+
verdict: 'clean' | 'suspicious';
|
|
350
|
+
signals: {
|
|
351
|
+
kind: string;
|
|
352
|
+
where: string;
|
|
353
|
+
detail?: string;
|
|
354
|
+
}[];
|
|
355
|
+
clean_text?: string;
|
|
356
|
+
version: number;
|
|
357
|
+
};
|
|
358
|
+
export type Attachment = {
|
|
359
|
+
id: string;
|
|
360
|
+
filename: string;
|
|
361
|
+
content_type: string;
|
|
362
|
+
size: number;
|
|
363
|
+
inline: boolean;
|
|
364
|
+
content_id: string | null;
|
|
365
|
+
};
|
|
366
|
+
/** A message as the API serves it. A held one has `is_held` and nothing it says. */
|
|
367
|
+
export type Message = {
|
|
368
|
+
id: string;
|
|
369
|
+
thread_id: string;
|
|
370
|
+
inbox_id: string;
|
|
371
|
+
direction: 'in' | 'out';
|
|
372
|
+
status: string;
|
|
373
|
+
is_held: boolean;
|
|
374
|
+
from: {
|
|
375
|
+
address: string;
|
|
376
|
+
name: string | null;
|
|
377
|
+
};
|
|
378
|
+
to: string[];
|
|
379
|
+
cc: string[];
|
|
380
|
+
bcc?: string[];
|
|
381
|
+
subject: string | null;
|
|
382
|
+
text: string | null;
|
|
383
|
+
html: string | null;
|
|
384
|
+
spam: boolean | null;
|
|
385
|
+
seen: boolean;
|
|
386
|
+
test: boolean;
|
|
387
|
+
attachments: Attachment[];
|
|
388
|
+
firewall: Firewall | null;
|
|
389
|
+
created_at: string;
|
|
390
|
+
sent_at: string | null;
|
|
391
|
+
};
|
|
392
|
+
export type Thread = {
|
|
393
|
+
id: string;
|
|
394
|
+
inbox_id: string;
|
|
395
|
+
subject: string | null;
|
|
396
|
+
folder: 'inbox' | 'archive' | 'spam' | 'trash';
|
|
397
|
+
starred: boolean;
|
|
398
|
+
status: 'open' | 'waiting' | 'resolved' | 'human_review';
|
|
399
|
+
owner_type: 'agent' | 'human' | 'automation';
|
|
400
|
+
assignee_id: string | null;
|
|
401
|
+
labels: {
|
|
402
|
+
id: string;
|
|
403
|
+
name: string;
|
|
404
|
+
colour: string;
|
|
405
|
+
}[];
|
|
406
|
+
message_count: number;
|
|
407
|
+
unread_count: number;
|
|
408
|
+
last_message_at: string;
|
|
409
|
+
created_at: string;
|
|
410
|
+
};
|
|
411
|
+
export type Label = {
|
|
412
|
+
id: string;
|
|
413
|
+
inbox_id: string;
|
|
414
|
+
name: string;
|
|
415
|
+
colour: string;
|
|
416
|
+
created_at: string;
|
|
417
|
+
};
|
|
418
|
+
export type Contact = {
|
|
419
|
+
id: string;
|
|
420
|
+
inbox_id: string;
|
|
421
|
+
email: string;
|
|
422
|
+
name: string | null;
|
|
423
|
+
notes: string | null;
|
|
424
|
+
first_seen_at: string | null;
|
|
425
|
+
last_seen_at: string | null;
|
|
426
|
+
edited_at: string | null;
|
|
427
|
+
created_at: string;
|
|
428
|
+
};
|
|
429
|
+
export type MailDomain = {
|
|
430
|
+
id: string;
|
|
431
|
+
domain: string;
|
|
432
|
+
mail: boolean;
|
|
433
|
+
status: 'pending' | 'verified' | 'failed' | null;
|
|
434
|
+
receiving: boolean;
|
|
435
|
+
/** Whether Pidgeon signs agents' `Agent-of` here: the `pgn2._domainkey` record answered at the last check. */
|
|
436
|
+
agent_signing: boolean;
|
|
437
|
+
checked_at: string | null;
|
|
438
|
+
records: {
|
|
439
|
+
purpose: string;
|
|
440
|
+
type: string;
|
|
441
|
+
name: string;
|
|
442
|
+
value: string;
|
|
443
|
+
priority?: number;
|
|
444
|
+
required: boolean;
|
|
445
|
+
}[];
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* A domain as `/v1/domains` answers it: whether it is proved, its mail, and
|
|
449
|
+
* every DNS record to publish (`purpose` `ownership` is the `_pidgeon` TXT
|
|
450
|
+
* record that proves it; mail's follow once mail is on).
|
|
451
|
+
*/
|
|
452
|
+
export type Domain = MailDomain & {
|
|
453
|
+
pod_id: string;
|
|
454
|
+
verified: boolean;
|
|
455
|
+
verified_at: string | null;
|
|
456
|
+
created_at: string;
|
|
457
|
+
};
|
|
458
|
+
export type AppPassword = {
|
|
459
|
+
id: string;
|
|
460
|
+
inbox_id: string;
|
|
461
|
+
name: string;
|
|
462
|
+
prefix: string;
|
|
463
|
+
last_used_at: string | null;
|
|
464
|
+
revoked_at: string | null;
|
|
465
|
+
created_at: string;
|
|
466
|
+
/** Answered once, when it is made. */
|
|
467
|
+
password?: string;
|
|
468
|
+
};
|
|
469
|
+
export type CalendarEvent = {
|
|
470
|
+
id: string;
|
|
471
|
+
inbox_id: string;
|
|
472
|
+
uid: string;
|
|
473
|
+
title: string | null;
|
|
474
|
+
/** Timed: an instant. All day: the first day, `YYYY-MM-DD`. */
|
|
475
|
+
start: string;
|
|
476
|
+
/** Timed: an instant. All day: the last day, inclusive. */
|
|
477
|
+
end: string;
|
|
478
|
+
starts_at: string;
|
|
479
|
+
ends_at: string;
|
|
480
|
+
all_day: boolean;
|
|
481
|
+
/** The series' RRULE as written, or null for a one-off. */
|
|
482
|
+
recurrence: string | null;
|
|
483
|
+
description: string | null;
|
|
484
|
+
location: string | null;
|
|
485
|
+
/** The address organising it, when it has attendees. */
|
|
486
|
+
organizer: string | null;
|
|
487
|
+
attendees: {
|
|
488
|
+
email: string;
|
|
489
|
+
status: 'needs_action' | 'accepted' | 'declined' | 'tentative';
|
|
490
|
+
}[];
|
|
491
|
+
etag: string;
|
|
492
|
+
created_at: string;
|
|
493
|
+
updated_at: string;
|
|
494
|
+
/** After a write with `sendInvites`: who was sent the invitation, or why nobody was. */
|
|
495
|
+
invites?: {
|
|
496
|
+
sent_to: string[];
|
|
497
|
+
error: string | null;
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
/** The events a webhook can carry; the event log (`events.list`) holds more. */
|
|
501
|
+
export declare const WEBHOOK_EVENTS: readonly ["report.created", "reputation.changed", "operator.reputation_changed", "mandate.requested", "mandate.granted", "mandate.declined", "mandate.revoked", "message.received", "message.held", "message.released", "message.blocked", "message.quarantined", "message.sent", "message.failed", "message.scheduled", "message.delivered", "message.delayed", "message.bounced", "message.complained", "message.rejected", "message.exfiltration_blocked", "draft.created", "draft.approval_requested", "draft.approved", "draft.rejected", "thread.updated", "thread.deleted", "inbox.created", "inbox.updated", "inbox.removed", "email.domain_added", "email.domain_verified", "email.domain_broken", "email.domain_removed", "calendar.event.created", "calendar.event.updated", "calendar.event.deleted"];
|
|
502
|
+
export type WebhookEventType = (typeof WEBHOOK_EVENTS)[number];
|
|
503
|
+
export type Webhook = {
|
|
504
|
+
id: string;
|
|
505
|
+
url: string;
|
|
506
|
+
events: WebhookEventType[];
|
|
507
|
+
/** The inboxes it hears; null when it hears its pod, or the whole account. */
|
|
508
|
+
inbox_ids: string[] | null;
|
|
509
|
+
/** Its pod: the default pod's hear the whole account, another's that pod. */
|
|
510
|
+
pod_id: string;
|
|
511
|
+
created_at: string;
|
|
512
|
+
disabled_at: string | null;
|
|
513
|
+
};
|
|
514
|
+
export type ApiKeyAccess = 'read' | 'draft' | 'send' | 'admin';
|
|
515
|
+
export type ApiKey = {
|
|
516
|
+
id: string;
|
|
517
|
+
name: string;
|
|
518
|
+
prefix: string;
|
|
519
|
+
access: ApiKeyAccess;
|
|
520
|
+
pod_id: string | null;
|
|
521
|
+
test: boolean;
|
|
522
|
+
created_at: string;
|
|
523
|
+
last_used_at: string | null;
|
|
524
|
+
};
|
|
525
|
+
export type VercelTarget = 'production' | 'preview' | 'development';
|
|
526
|
+
/** A key put on a Vercel project: where it went, and never the key. */
|
|
527
|
+
export type DeliveredKey = {
|
|
528
|
+
id: string;
|
|
529
|
+
prefix: string;
|
|
530
|
+
name: string;
|
|
531
|
+
access: ApiKeyAccess;
|
|
532
|
+
pod_id: string | null;
|
|
533
|
+
delivered_to: {
|
|
534
|
+
vercel_project_id: string;
|
|
535
|
+
project_name: string;
|
|
536
|
+
env_name: string;
|
|
537
|
+
targets: VercelTarget[];
|
|
538
|
+
env_id: string;
|
|
539
|
+
};
|
|
540
|
+
};
|
|
541
|
+
export type BodyChoice = 'original' | 'clean';
|
|
542
|
+
/** What to send, or what a draft says. `replyTo` is one of the inbox's messages. */
|
|
543
|
+
export type MessageInput = {
|
|
544
|
+
to: string[];
|
|
545
|
+
cc?: string[];
|
|
546
|
+
bcc?: string[];
|
|
547
|
+
subject?: string;
|
|
548
|
+
text?: string;
|
|
549
|
+
html?: string;
|
|
550
|
+
replyTo?: string;
|
|
551
|
+
/** Finished uploads of this inbox (`pidgeon.attachments.upload`). */
|
|
552
|
+
attachmentIds?: string[];
|
|
553
|
+
};
|
|
554
|
+
/** What sending answers: `sent`, `held` for a person's approval, or `scheduled`. */
|
|
555
|
+
export type SendResult = {
|
|
556
|
+
id: string;
|
|
557
|
+
thread_id: string;
|
|
558
|
+
status: 'sent' | 'held' | 'scheduled';
|
|
559
|
+
};
|
|
560
|
+
/** A draft, or a message waiting (held for a person, or scheduled). */
|
|
561
|
+
export type Draft = {
|
|
562
|
+
id: string;
|
|
563
|
+
inbox_id: string;
|
|
564
|
+
thread_id: string;
|
|
565
|
+
status: 'draft' | 'held' | 'scheduled';
|
|
566
|
+
to: string[];
|
|
567
|
+
cc: string[];
|
|
568
|
+
bcc: string[];
|
|
569
|
+
subject: string;
|
|
570
|
+
text: string | null;
|
|
571
|
+
html: string | null;
|
|
572
|
+
send_at: string | null;
|
|
573
|
+
};
|
|
574
|
+
/** A send or receive rule: an address, or a domain and its subdomains, allowed or blocked. */
|
|
575
|
+
export type Rule = {
|
|
576
|
+
id: string;
|
|
577
|
+
inbox_id: string | null;
|
|
578
|
+
direction: 'send' | 'receive';
|
|
579
|
+
action: 'allow' | 'block';
|
|
580
|
+
pattern: string;
|
|
581
|
+
created_at: string;
|
|
582
|
+
};
|
|
583
|
+
export type Suppression = {
|
|
584
|
+
address: string;
|
|
585
|
+
reason: string;
|
|
586
|
+
created_at: string;
|
|
587
|
+
};
|
|
588
|
+
export type Event = {
|
|
589
|
+
id: string;
|
|
590
|
+
type: string;
|
|
591
|
+
created_at: string;
|
|
592
|
+
pod_id: string | null;
|
|
593
|
+
data: Record<string, unknown>;
|
|
594
|
+
};
|
|
595
|
+
export type Pod = {
|
|
596
|
+
id: string;
|
|
597
|
+
name: string;
|
|
598
|
+
default: boolean;
|
|
599
|
+
created_at: string;
|
|
600
|
+
};
|
|
601
|
+
/** A site registered for Sign in with Pidgeon. `client_secret` is answered once, at creation and at each rotation. */
|
|
602
|
+
export type Site = {
|
|
603
|
+
client_id: string;
|
|
604
|
+
name: string;
|
|
605
|
+
redirect_uris: string[];
|
|
606
|
+
pod_id: string | null;
|
|
607
|
+
created_at: string;
|
|
608
|
+
client_secret?: string;
|
|
609
|
+
};
|
|
610
|
+
export type Mandate = {
|
|
611
|
+
id: string;
|
|
612
|
+
agent_id: string;
|
|
613
|
+
client_id: string;
|
|
614
|
+
scope: string;
|
|
615
|
+
description: string;
|
|
616
|
+
status: 'requested' | 'granted' | 'declined' | 'revoked';
|
|
617
|
+
/** Asked with a test key: needs no verified domain, and every token under it says `test: true`. */
|
|
618
|
+
test: boolean;
|
|
619
|
+
expires_at: string;
|
|
620
|
+
created_at: string;
|
|
621
|
+
/** On a request: the link to send the person, and until when it works. */
|
|
622
|
+
consent_url?: string;
|
|
623
|
+
request_expires_at?: string;
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* The client for Pidgeon's API: the website's, the operator's, and a coding
|
|
627
|
+
* agent's. Keep the API key on a server. `apiKey` is an API key (`pgn_…`) or
|
|
628
|
+
* an OAuth access token (`pgn_oat_…`); `getToken` is asked before each
|
|
629
|
+
* request instead, for a token that is refreshed.
|
|
630
|
+
*/
|
|
631
|
+
export declare class Pidgeon {
|
|
632
|
+
private readonly token;
|
|
633
|
+
readonly baseUrl: string;
|
|
634
|
+
private readonly fetchImpl;
|
|
635
|
+
constructor(options: {
|
|
636
|
+
apiKey?: string;
|
|
637
|
+
getToken?: () => Promise<string>;
|
|
638
|
+
baseUrl?: string;
|
|
639
|
+
fetch?: typeof fetch;
|
|
640
|
+
});
|
|
641
|
+
/** Any `/v1` call: the methods below are this with the path and body filled in. */
|
|
642
|
+
request<T>(method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE', path: string, options?: {
|
|
643
|
+
body?: unknown;
|
|
644
|
+
query?: Record<string, string | number | undefined>;
|
|
645
|
+
headers?: Record<string, string>;
|
|
646
|
+
}): Promise<T>;
|
|
647
|
+
/**
|
|
648
|
+
* Who stands behind an agent's request, and how they stand. Forward it as
|
|
649
|
+
* you received it. `ip`, the agent's address as your server saw it, is
|
|
650
|
+
* written into the answer's `verdict`, so a hook that sees the address can
|
|
651
|
+
* hold the verdict to it.
|
|
652
|
+
*/
|
|
653
|
+
verify(request: IncomingRequest, options?: {
|
|
654
|
+
ip?: string;
|
|
655
|
+
place?: Place;
|
|
656
|
+
}): Promise<VerifyAnswer>;
|
|
657
|
+
/**
|
|
658
|
+
* Check a verdict with Pidgeon, for a sign-up hook: signed by Pidgeon, for
|
|
659
|
+
* this account (and `origin`, and `ip`, when given), not expired, its key
|
|
660
|
+
* and agent not revoked since, and never checked before. Spending it is
|
|
661
|
+
* what an offline check (`verifyVerdict`, `@zurchin/sdk/verdict`)
|
|
662
|
+
* cannot do.
|
|
663
|
+
*/
|
|
664
|
+
checkVerdict(verdict: string, options?: {
|
|
665
|
+
origin?: string;
|
|
666
|
+
ip?: string;
|
|
667
|
+
}): Promise<VerdictCheck>;
|
|
668
|
+
/** Report an agent from one of your verifications: what it did, in your words. */
|
|
669
|
+
report(input: {
|
|
670
|
+
verificationId: string;
|
|
671
|
+
category: ReportCategory;
|
|
672
|
+
evidence: string;
|
|
673
|
+
}): Promise<{
|
|
674
|
+
id: string;
|
|
675
|
+
}>;
|
|
676
|
+
/**
|
|
677
|
+
* Publish an agent identity's public key. The request is signed with the key itself,
|
|
678
|
+
* which is how Pidgeon knows you hold it; the private half never leaves you.
|
|
679
|
+
*/
|
|
680
|
+
publishKey(input: {
|
|
681
|
+
agentId: string;
|
|
682
|
+
key: AgentKeyPair;
|
|
683
|
+
directory: string;
|
|
684
|
+
}): Promise<{
|
|
685
|
+
kid: string;
|
|
686
|
+
}>;
|
|
687
|
+
/** Agent identities (once Passport): optional; an inbox works without one. */
|
|
688
|
+
readonly agents: {
|
|
689
|
+
/** The account's agent identities, a page at a time. */
|
|
690
|
+
list: (options?: ListOptions) => Promise<Page<Agent>>;
|
|
691
|
+
/** Register an agent identity. It has no key until you make one where it runs and publish it. */
|
|
692
|
+
create: (input: {
|
|
693
|
+
name: string;
|
|
694
|
+
purpose?: string;
|
|
695
|
+
podId?: string;
|
|
696
|
+
}) => Promise<Agent & {
|
|
697
|
+
directory: string;
|
|
698
|
+
}>;
|
|
699
|
+
/** The agent identity, its keys, its directory and its operator's reputation. */
|
|
700
|
+
get: (id: string) => Promise<AgentDetail>;
|
|
701
|
+
/** Rename the agent identity, or change what its agent does: what websites see when it arrives. */
|
|
702
|
+
update: (id: string, input: {
|
|
703
|
+
name?: string;
|
|
704
|
+
purpose?: string;
|
|
705
|
+
}) => Promise<Agent>;
|
|
706
|
+
/** Revoke the agent identity and every key it has. None verifies again; it cannot be undone. */
|
|
707
|
+
revoke: (id: string) => Promise<void>;
|
|
708
|
+
/** Revoke one of the agent identity's keys, by its `kid`. Its other keys stay. */
|
|
709
|
+
revokeKey: (id: string, kid: string) => Promise<void>;
|
|
710
|
+
/**
|
|
711
|
+
* Register an agent identity, make its key here, and publish the public half
|
|
712
|
+
* signed with it. Keep `key.privateJwk` where the agent runs: it is the
|
|
713
|
+
* agent's identity, and Pidgeon never sees it.
|
|
714
|
+
*/
|
|
715
|
+
setUp: (input: {
|
|
716
|
+
name: string;
|
|
717
|
+
purpose?: string;
|
|
718
|
+
podId?: string;
|
|
719
|
+
}) => Promise<{
|
|
720
|
+
agent: Agent & {
|
|
721
|
+
directory: string;
|
|
722
|
+
};
|
|
723
|
+
key: AgentKeyPair;
|
|
724
|
+
kid: string;
|
|
725
|
+
}>;
|
|
726
|
+
};
|
|
727
|
+
readonly inboxes: {
|
|
728
|
+
list: (options?: ListOptions) => Promise<Page<Inbox>>;
|
|
729
|
+
get: (id: string) => Promise<Inbox>;
|
|
730
|
+
/**
|
|
731
|
+
* `name` is the part before the @. Optionally link it to an agent identity
|
|
732
|
+
* with `agentId`: its mail is then signed as that agent.
|
|
733
|
+
*/
|
|
734
|
+
create: (input: {
|
|
735
|
+
name: string;
|
|
736
|
+
kind?: InboxKind;
|
|
737
|
+
displayName?: string;
|
|
738
|
+
agentId?: string;
|
|
739
|
+
podId?: string;
|
|
740
|
+
/** One of your own domains with mail on; `pidgeon.email` when left out. */
|
|
741
|
+
domain?: string;
|
|
742
|
+
/** `team` (default) or `agent`: this key, and the people added to supervise it. */
|
|
743
|
+
access?: "team" | "agent";
|
|
744
|
+
}) => Promise<Inbox>;
|
|
745
|
+
/** Who reads an inbox: its access, its people and its keys. */
|
|
746
|
+
members: (id: string) => Promise<InboxMembers>;
|
|
747
|
+
/** Add a key (or a connected app) at a level, or a person of the team. Needs `admin`. */
|
|
748
|
+
addMember: (id: string, member: {
|
|
749
|
+
keyId: string;
|
|
750
|
+
level?: MemberLevel;
|
|
751
|
+
} | {
|
|
752
|
+
userId: string;
|
|
753
|
+
}) => Promise<InboxMembers>;
|
|
754
|
+
/** Change the level a key was added at. Needs `admin`. */
|
|
755
|
+
updateMember: (id: string, memberId: string, level: MemberLevel) => Promise<InboxMembers>;
|
|
756
|
+
/** Take a key or a person off an inbox. Needs `admin`. */
|
|
757
|
+
removeMember: (id: string, memberId: string) => Promise<void>;
|
|
758
|
+
/**
|
|
759
|
+
* Choose who reads an inbox: `team`, `some` (the `people` given) or
|
|
760
|
+
* `agent` (its keys, and `people` supervising). Just me is a person's own
|
|
761
|
+
* choice, made in Pidgeon. Needs `admin`.
|
|
762
|
+
*/
|
|
763
|
+
setAccess: (id: string, access: "team" | "some" | "agent", people?: string[]) => Promise<InboxMembers>;
|
|
764
|
+
/** Hold suspicious mail for a person. A key can turn holding on, never off. */
|
|
765
|
+
holdSuspicious: (id: string) => Promise<Inbox>;
|
|
766
|
+
/** Set the lines the mail client adds under mail a person writes from it; null clears it. Needs `admin`. */
|
|
767
|
+
setSignature: (id: string, signature: string | null) => Promise<Inbox>;
|
|
768
|
+
/**
|
|
769
|
+
* Link the inbox to an agent identity in its pod, so its mail is signed as
|
|
770
|
+
* that agent; null unlinks it. Needs `admin` and a verified domain.
|
|
771
|
+
*/
|
|
772
|
+
setAgent: (id: string, agentId: string | null) => Promise<Inbox>;
|
|
773
|
+
/** Remove an inbox. Its address is retired, never given to anyone again. */
|
|
774
|
+
remove: (id: string) => Promise<void>;
|
|
775
|
+
};
|
|
776
|
+
readonly messages: {
|
|
777
|
+
/** Send from an inbox: `status` is `sent`, or `held` while a person approves it. */
|
|
778
|
+
send: (inboxId: string, input: MessageInput) => Promise<SendResult>;
|
|
779
|
+
/** The inbox's mail, newest first. `body: 'clean'` serves the Firewall's cleaned text. */
|
|
780
|
+
list: (inboxId: string, options?: ListOptions & {
|
|
781
|
+
body?: BodyChoice;
|
|
782
|
+
}) => Promise<Page<Message>>;
|
|
783
|
+
get: (id: string, options?: {
|
|
784
|
+
body?: BodyChoice;
|
|
785
|
+
}) => Promise<Message>;
|
|
786
|
+
/** Mark a received message read, or unread. */
|
|
787
|
+
markSeen: (id: string, seen?: boolean) => Promise<Message>;
|
|
788
|
+
/**
|
|
789
|
+
* Wait for mail: answers as soon as received mail newer than `since` (a
|
|
790
|
+
* time or a message id; default now) is there, or after `timeout`
|
|
791
|
+
* seconds (at most 50). Pass `next_since` back to wait for the next.
|
|
792
|
+
*/
|
|
793
|
+
await: (inboxId: string, options?: {
|
|
794
|
+
since?: string;
|
|
795
|
+
timeout?: number;
|
|
796
|
+
body?: BodyChoice;
|
|
797
|
+
}) => Promise<{
|
|
798
|
+
data: Message[];
|
|
799
|
+
held: number;
|
|
800
|
+
next_since: string;
|
|
801
|
+
}>;
|
|
802
|
+
/**
|
|
803
|
+
* Mail by words in its subject, sender or text, newest first:
|
|
804
|
+
* `search('invoice', { inboxId })`, or `search({ q: 'invoice', inboxId })`.
|
|
805
|
+
*/
|
|
806
|
+
search: (query: string | (SearchOptions & {
|
|
807
|
+
q: string;
|
|
808
|
+
}), options?: SearchOptions) => Promise<Page<Message>>;
|
|
809
|
+
};
|
|
810
|
+
/** Conversations across your inboxes, and what is filed where. */
|
|
811
|
+
readonly threads: {
|
|
812
|
+
list: (options?: ListOptions & {
|
|
813
|
+
inboxId?: string;
|
|
814
|
+
folder?: Thread["folder"];
|
|
815
|
+
labelId?: string;
|
|
816
|
+
status?: Thread["status"];
|
|
817
|
+
starred?: boolean;
|
|
818
|
+
}) => Promise<Page<Thread>>;
|
|
819
|
+
/** The conversation, and its messages oldest first. */
|
|
820
|
+
get: (id: string, options?: ListOptions & {
|
|
821
|
+
body?: BodyChoice;
|
|
822
|
+
}) => Promise<Thread & {
|
|
823
|
+
messages: Page<Message>;
|
|
824
|
+
}>;
|
|
825
|
+
/** File, star or hand over: `{ ownerType: 'human', status: 'human_review' }` puts it before a person. */
|
|
826
|
+
update: (id: string, input: {
|
|
827
|
+
folder?: Thread["folder"];
|
|
828
|
+
starred?: boolean;
|
|
829
|
+
status?: Thread["status"];
|
|
830
|
+
ownerType?: Thread["owner_type"];
|
|
831
|
+
assigneeId?: string | null;
|
|
832
|
+
}) => Promise<Thread>;
|
|
833
|
+
/** Delete the conversation, its messages and files, for good. */
|
|
834
|
+
remove: (id: string) => Promise<void>;
|
|
835
|
+
addLabel: (id: string, labelId: string) => Promise<Thread>;
|
|
836
|
+
removeLabel: (id: string, labelId: string) => Promise<Thread>;
|
|
837
|
+
};
|
|
838
|
+
/** An inbox's labels. */
|
|
839
|
+
readonly labels: {
|
|
840
|
+
list: (inboxId: string) => Promise<{
|
|
841
|
+
data: Label[];
|
|
842
|
+
}>;
|
|
843
|
+
create: (inboxId: string, input: {
|
|
844
|
+
name: string;
|
|
845
|
+
colour?: string;
|
|
846
|
+
}) => Promise<Label>;
|
|
847
|
+
update: (id: string, input: {
|
|
848
|
+
name?: string;
|
|
849
|
+
colour?: string;
|
|
850
|
+
}) => Promise<Label>;
|
|
851
|
+
remove: (id: string) => Promise<void>;
|
|
852
|
+
};
|
|
853
|
+
/** Files: those that arrived, and uploads to send. */
|
|
854
|
+
readonly attachments: {
|
|
855
|
+
/** Its details and a link to its bytes that lasts five minutes. */
|
|
856
|
+
get: (id: string) => Promise<Attachment & {
|
|
857
|
+
url: string;
|
|
858
|
+
expires_in: number;
|
|
859
|
+
}>;
|
|
860
|
+
/** Upload a file to send (name its id in `attachmentIds`). Up to 25 MB; over 4 MB goes straight to storage. */
|
|
861
|
+
upload: (inboxId: string, file: {
|
|
862
|
+
filename: string;
|
|
863
|
+
contentType: string;
|
|
864
|
+
content: Uint8Array | ArrayBuffer | Blob;
|
|
865
|
+
}) => Promise<Attachment>;
|
|
866
|
+
};
|
|
867
|
+
/** Who an inbox corresponds with. */
|
|
868
|
+
readonly contacts: {
|
|
869
|
+
list: (options?: ListOptions & {
|
|
870
|
+
inboxId?: string;
|
|
871
|
+
search?: string;
|
|
872
|
+
}) => Promise<Page<Contact>>;
|
|
873
|
+
get: (id: string) => Promise<Contact>;
|
|
874
|
+
update: (id: string, input: {
|
|
875
|
+
name?: string | null;
|
|
876
|
+
notes?: string | null;
|
|
877
|
+
}) => Promise<Contact>;
|
|
878
|
+
remove: (id: string) => Promise<void>;
|
|
879
|
+
};
|
|
880
|
+
/** Each inbox's calendar. */
|
|
881
|
+
readonly calendar: {
|
|
882
|
+
list: (inboxId: string, options?: ListOptions & {
|
|
883
|
+
after?: string;
|
|
884
|
+
before?: string;
|
|
885
|
+
}) => Promise<Page<CalendarEvent>>;
|
|
886
|
+
get: (id: string) => Promise<CalendarEvent>;
|
|
887
|
+
create: (inboxId: string, input: {
|
|
888
|
+
title: string;
|
|
889
|
+
start: string;
|
|
890
|
+
/** Required for a timed event; for an all-day one, the last day (default the start). */
|
|
891
|
+
end?: string;
|
|
892
|
+
allDay?: boolean;
|
|
893
|
+
description?: string;
|
|
894
|
+
location?: string;
|
|
895
|
+
/** Who is on it; writing the list sends nothing. */
|
|
896
|
+
attendees?: string[];
|
|
897
|
+
/** Invite them now (a key with `send` access): an email from the inbox with the `.ics`. */
|
|
898
|
+
sendInvites?: boolean;
|
|
899
|
+
}) => Promise<CalendarEvent>;
|
|
900
|
+
update: (id: string, input: {
|
|
901
|
+
title?: string;
|
|
902
|
+
start?: string;
|
|
903
|
+
end?: string;
|
|
904
|
+
allDay?: boolean;
|
|
905
|
+
/** `null` clears it. */
|
|
906
|
+
description?: string | null;
|
|
907
|
+
/** `null` clears it. */
|
|
908
|
+
location?: string | null;
|
|
909
|
+
attendees?: string[];
|
|
910
|
+
/** Send the attendees the updated invitation (a key with `send` access). */
|
|
911
|
+
sendInvites?: boolean;
|
|
912
|
+
}) => Promise<CalendarEvent>;
|
|
913
|
+
/** With `sendInvites`, the attendees are sent a cancellation first (a key with `send` access). */
|
|
914
|
+
remove: (id: string, options?: {
|
|
915
|
+
sendInvites?: boolean;
|
|
916
|
+
}) => Promise<void | {
|
|
917
|
+
deleted: true;
|
|
918
|
+
invites: {
|
|
919
|
+
sent_to: string[];
|
|
920
|
+
error: string | null;
|
|
921
|
+
};
|
|
922
|
+
}>;
|
|
923
|
+
};
|
|
924
|
+
/**
|
|
925
|
+
* Your domains, waiting and proved: add one (in a pod, for a platform's
|
|
926
|
+
* customer), publish its `records`, `verify`, then turn mail on for inboxes
|
|
927
|
+
* at it. A key of one pod reaches its own pod's domains only.
|
|
928
|
+
*/
|
|
929
|
+
readonly domains: {
|
|
930
|
+
list: () => Promise<{
|
|
931
|
+
data: Domain[];
|
|
932
|
+
}>;
|
|
933
|
+
get: (id: string) => Promise<Domain>;
|
|
934
|
+
/** Add a domain; answers it with the `_pidgeon` TXT record that proves it. */
|
|
935
|
+
create: (domain: string, options?: {
|
|
936
|
+
podId?: string;
|
|
937
|
+
}) => Promise<Domain>;
|
|
938
|
+
/** Look for the TXT record now; `verified` is true once it is found. */
|
|
939
|
+
verify: (id: string) => Promise<Domain>;
|
|
940
|
+
/** Remove a domain; a proved one's mail is turned off first, and none may be left at it (`409`). */
|
|
941
|
+
remove: (id: string) => Promise<void>;
|
|
942
|
+
/** Turn mail on for a domain you proved; answers the DNS records to set. */
|
|
943
|
+
enableMail: (id: string) => Promise<MailDomain>;
|
|
944
|
+
disableMail: (id: string) => Promise<void>;
|
|
945
|
+
/** Ask DNS and the mail service where the domain stands now. */
|
|
946
|
+
check: (id: string) => Promise<MailDomain>;
|
|
947
|
+
};
|
|
948
|
+
/** Passwords for mail apps (IMAP, SMTP, CalDAV), one inbox each. */
|
|
949
|
+
readonly appPasswords: {
|
|
950
|
+
list: (inboxId: string) => Promise<{
|
|
951
|
+
data: AppPassword[];
|
|
952
|
+
}>;
|
|
953
|
+
/** Answers `password` this once. */
|
|
954
|
+
create: (inboxId: string, name: string) => Promise<AppPassword>;
|
|
955
|
+
revoke: (id: string) => Promise<void>;
|
|
956
|
+
};
|
|
957
|
+
/** How much of the account's 10 GB its mail and files use. */
|
|
958
|
+
storage(): Promise<{
|
|
959
|
+
used_bytes: number;
|
|
960
|
+
limit_bytes: number;
|
|
961
|
+
}>;
|
|
962
|
+
/** With a test key: deliver a message to one of your inboxes as if from outside, marked test. */
|
|
963
|
+
testInbound(input: {
|
|
964
|
+
inboxId: string;
|
|
965
|
+
from: string;
|
|
966
|
+
fromName?: string;
|
|
967
|
+
subject?: string;
|
|
968
|
+
text?: string;
|
|
969
|
+
html?: string;
|
|
970
|
+
inReplyTo?: string;
|
|
971
|
+
}): Promise<{
|
|
972
|
+
inbox_id: string;
|
|
973
|
+
message_id: string | null;
|
|
974
|
+
outcome: string | null;
|
|
975
|
+
}>;
|
|
976
|
+
readonly drafts: {
|
|
977
|
+
create: (inboxId: string, input: MessageInput) => Promise<Draft>;
|
|
978
|
+
get: (id: string) => Promise<Draft>;
|
|
979
|
+
/** Replace a draft's addresses and body; its thread stays, so `replyTo` is not taken. */
|
|
980
|
+
update: (id: string, input: Omit<MessageInput, "replyTo">) => Promise<Draft>;
|
|
981
|
+
remove: (id: string) => Promise<void>;
|
|
982
|
+
/** Send now, or at `sendAt` (up to 90 days ahead). */
|
|
983
|
+
send: (id: string, options?: {
|
|
984
|
+
sendAt?: Date | string;
|
|
985
|
+
}) => Promise<SendResult>;
|
|
986
|
+
/** Hold it for a person of the account to send or reject (`draft.approval_requested` carries the link). */
|
|
987
|
+
requestApproval: (id: string) => Promise<Draft>;
|
|
988
|
+
};
|
|
989
|
+
/** Send and receive rules, for one inbox or (`inboxId` left out) every inbox. Keys of the whole account only. */
|
|
990
|
+
readonly rules: {
|
|
991
|
+
list: () => Promise<{
|
|
992
|
+
data: Rule[];
|
|
993
|
+
}>;
|
|
994
|
+
create: (input: {
|
|
995
|
+
direction: "send" | "receive";
|
|
996
|
+
action: "allow" | "block";
|
|
997
|
+
pattern: string;
|
|
998
|
+
inboxId?: string;
|
|
999
|
+
}) => Promise<Rule>;
|
|
1000
|
+
remove: (id: string) => Promise<void>;
|
|
1001
|
+
};
|
|
1002
|
+
/** The do-not-send list: bounces and complaints put addresses on it; you can too. */
|
|
1003
|
+
readonly suppressions: {
|
|
1004
|
+
list: () => Promise<{
|
|
1005
|
+
data: Suppression[];
|
|
1006
|
+
}>;
|
|
1007
|
+
add: (address: string) => Promise<{
|
|
1008
|
+
address: string;
|
|
1009
|
+
}>;
|
|
1010
|
+
remove: (address: string) => Promise<void>;
|
|
1011
|
+
};
|
|
1012
|
+
/** Sites registered for Sign in with Pidgeon. */
|
|
1013
|
+
readonly sites: {
|
|
1014
|
+
list: () => Promise<{
|
|
1015
|
+
data: Site[];
|
|
1016
|
+
}>;
|
|
1017
|
+
/** Answers `client_secret` once: keep it on the site's server. */
|
|
1018
|
+
create: (input: {
|
|
1019
|
+
name: string;
|
|
1020
|
+
redirectUris: string[];
|
|
1021
|
+
podId?: string;
|
|
1022
|
+
}) => Promise<Site>;
|
|
1023
|
+
/** Rename it, or replace its return addresses (the whole list); its id and secret stay. */
|
|
1024
|
+
update: (clientId: string, input: {
|
|
1025
|
+
name?: string;
|
|
1026
|
+
redirectUris?: string[];
|
|
1027
|
+
}) => Promise<Site>;
|
|
1028
|
+
/** A new `client_secret`, answered once; the old one stops working at once. */
|
|
1029
|
+
rotateSecret: (clientId: string) => Promise<Site & {
|
|
1030
|
+
client_secret: string;
|
|
1031
|
+
}>;
|
|
1032
|
+
remove: (clientId: string) => Promise<void>;
|
|
1033
|
+
};
|
|
1034
|
+
/** A person's permission for one of your agents to act for them at one site. */
|
|
1035
|
+
readonly mandates: {
|
|
1036
|
+
list: () => Promise<{
|
|
1037
|
+
data: Mandate[];
|
|
1038
|
+
}>;
|
|
1039
|
+
/** Answers `consent_url`: send it to the person, who allows or declines. */
|
|
1040
|
+
create: (input: {
|
|
1041
|
+
agentId: string;
|
|
1042
|
+
clientId: string;
|
|
1043
|
+
scope: string;
|
|
1044
|
+
description: string;
|
|
1045
|
+
days?: number;
|
|
1046
|
+
}) => Promise<Mandate>;
|
|
1047
|
+
revoke: (id: string) => Promise<void>;
|
|
1048
|
+
};
|
|
1049
|
+
readonly events: {
|
|
1050
|
+
/** The account's event log, newest first. */
|
|
1051
|
+
list: (options?: ListOptions & {
|
|
1052
|
+
type?: string;
|
|
1053
|
+
}) => Promise<Page<Event>>;
|
|
1054
|
+
};
|
|
1055
|
+
readonly pods: {
|
|
1056
|
+
list: () => Promise<{
|
|
1057
|
+
data: Pod[];
|
|
1058
|
+
}>;
|
|
1059
|
+
create: (name: string) => Promise<Pod>;
|
|
1060
|
+
/** Rename a pod. Its id, and everything in it, stay as they are. */
|
|
1061
|
+
rename: (id: string, name: string) => Promise<Pod>;
|
|
1062
|
+
/**
|
|
1063
|
+
* Move an agent, an address (`inbox`), a domain, a webhook endpoint or a
|
|
1064
|
+
* site (by client id) into a pod. An agent takes its addresses and their
|
|
1065
|
+
* mail with it; an address that belongs to an agent moves only with it.
|
|
1066
|
+
*/
|
|
1067
|
+
move: (id: string, thing: {
|
|
1068
|
+
type: "agent" | "inbox" | "domain" | "webhook" | "site";
|
|
1069
|
+
id: string;
|
|
1070
|
+
}) => Promise<{
|
|
1071
|
+
type: string;
|
|
1072
|
+
id: string;
|
|
1073
|
+
pod_id: string;
|
|
1074
|
+
moved_inboxes?: string[];
|
|
1075
|
+
}>;
|
|
1076
|
+
/** Remove an empty pod. Not the default pod, and not one with agents, domains or endpoints in it. */
|
|
1077
|
+
remove: (id: string) => Promise<void>;
|
|
1078
|
+
};
|
|
1079
|
+
/**
|
|
1080
|
+
* Bouncer's site rules: per place, who gets in and whether the rule acts
|
|
1081
|
+
* or only watches. Reading takes any key; setting takes an admin key of the
|
|
1082
|
+
* whole account.
|
|
1083
|
+
*/
|
|
1084
|
+
readonly siteRules: {
|
|
1085
|
+
get: () => Promise<SiteRules>;
|
|
1086
|
+
/** Change some places; the rest stay as they are. Answers every place. */
|
|
1087
|
+
set: (rules: Partial<Record<Place, Partial<PlaceRule>>>) => Promise<SiteRules>;
|
|
1088
|
+
};
|
|
1089
|
+
/**
|
|
1090
|
+
* Visits of agents that only name themselves (`declared`), recorded in a
|
|
1091
|
+
* batch after the responses, not counted as verifications. Up to 100 a
|
|
1092
|
+
* call; a User-Agent not on Pidgeon's list is skipped, not stored. Send
|
|
1093
|
+
* signed requests to `verify`. `bouncer()` (`@zurchin/sdk/next`) does
|
|
1094
|
+
* this for you.
|
|
1095
|
+
*/
|
|
1096
|
+
readonly visits: {
|
|
1097
|
+
record: (visits: Visit[]) => Promise<{
|
|
1098
|
+
recorded: number;
|
|
1099
|
+
skipped: number;
|
|
1100
|
+
}>;
|
|
1101
|
+
};
|
|
1102
|
+
/** Your API keys. Making and revoking takes an admin key of the whole account. */
|
|
1103
|
+
readonly keys: {
|
|
1104
|
+
list: () => Promise<{
|
|
1105
|
+
data: ApiKey[];
|
|
1106
|
+
}>;
|
|
1107
|
+
/** Answers `key` once. Never stronger than the key making it; a test key makes test keys. */
|
|
1108
|
+
create: (input: {
|
|
1109
|
+
name: string;
|
|
1110
|
+
access?: ApiKeyAccess;
|
|
1111
|
+
podId?: string;
|
|
1112
|
+
test?: boolean;
|
|
1113
|
+
}) => Promise<{
|
|
1114
|
+
id: string;
|
|
1115
|
+
key: string;
|
|
1116
|
+
prefix: string;
|
|
1117
|
+
}>;
|
|
1118
|
+
/**
|
|
1119
|
+
* Make a key and put it straight on a Vercel project as a sensitive
|
|
1120
|
+
* variable, through the account's Vercel installation: the key is never
|
|
1121
|
+
* in the answer. `targets`: production and preview when left out.
|
|
1122
|
+
*/
|
|
1123
|
+
deliverToVercel: (input: {
|
|
1124
|
+
name: string;
|
|
1125
|
+
access?: ApiKeyAccess;
|
|
1126
|
+
podId?: string;
|
|
1127
|
+
test?: boolean;
|
|
1128
|
+
vercelProjectId: string;
|
|
1129
|
+
envName: string;
|
|
1130
|
+
targets?: VercelTarget[];
|
|
1131
|
+
}) => Promise<DeliveredKey>;
|
|
1132
|
+
revoke: (id: string) => Promise<void>;
|
|
1133
|
+
};
|
|
1134
|
+
/** Your webhook endpoints. A key of the whole account only. */
|
|
1135
|
+
readonly webhooks: {
|
|
1136
|
+
list: () => Promise<{
|
|
1137
|
+
data: Webhook[];
|
|
1138
|
+
}>;
|
|
1139
|
+
/**
|
|
1140
|
+
* Answers `secret` once: check each delivery's signature with it (`verifyWebhook`).
|
|
1141
|
+
* With `inboxIds` it hears only those inboxes' events. `podId` puts it in a
|
|
1142
|
+
* pod, where it hears that pod's events; left out, the default pod, where it
|
|
1143
|
+
* hears the whole account. A key of one pod adds to its own pod only.
|
|
1144
|
+
*/
|
|
1145
|
+
create: (input: {
|
|
1146
|
+
url: string;
|
|
1147
|
+
events: WebhookEventType[];
|
|
1148
|
+
inboxIds?: string[];
|
|
1149
|
+
podId?: string;
|
|
1150
|
+
}) => Promise<{
|
|
1151
|
+
id: string;
|
|
1152
|
+
secret: string;
|
|
1153
|
+
}>;
|
|
1154
|
+
remove: (id: string) => Promise<void>;
|
|
1155
|
+
};
|
|
1156
|
+
/** A multipart POST (uploads): the same authentication and errors as `request`. */
|
|
1157
|
+
private multipart;
|
|
1158
|
+
}
|
|
1159
|
+
/** `fetch`, signed as your agent: every request carries its Web Bot Auth signature. */
|
|
1160
|
+
export declare function signedFetch(input: string | URL | Request, init: RequestInit | undefined, agent: {
|
|
1161
|
+
privateJwk: JsonWebKey;
|
|
1162
|
+
directory: string;
|
|
1163
|
+
}): Promise<Response>;
|
|
1164
|
+
/** Your agent, from `ZURCHIN_AGENT_KEY` (else `PIDGEON_AGENT_KEY`) and `ZURCHIN_DIRECTORY` (else `PIDGEON_DIRECTORY`); the dashboard gives both. */
|
|
1165
|
+
export declare function agentFromEnv(env?: Record<string, string | undefined>): {
|
|
1166
|
+
fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
1167
|
+
};
|
|
1168
|
+
export { generateAgentKey };
|
|
1169
|
+
/** A webhook Pidgeon sent you, once its signature checks out. */
|
|
1170
|
+
export type WebhookPayload = {
|
|
1171
|
+
id: string;
|
|
1172
|
+
type: WebhookEventType;
|
|
1173
|
+
created: string;
|
|
1174
|
+
data: Record<string, unknown>;
|
|
1175
|
+
};
|
|
1176
|
+
/**
|
|
1177
|
+
* Check a webhook's `Pidgeon-Signature` header against your endpoint's secret
|
|
1178
|
+
* and return the event, or throw. Pass the raw body as received, before any
|
|
1179
|
+
* JSON parsing. Signatures older than `toleranceSeconds` are refused, so a
|
|
1180
|
+
* captured delivery cannot be replayed later.
|
|
1181
|
+
*/
|
|
1182
|
+
export declare function verifyWebhook(secret: string, rawBody: string, signatureHeader: string | null, options?: {
|
|
1183
|
+
toleranceSeconds?: number;
|
|
1184
|
+
now?: Date;
|
|
1185
|
+
}): Promise<WebhookPayload>;
|
|
1186
|
+
/** The same client and error under the name Pidgeon is becoming. */
|
|
1187
|
+
export { Pidgeon as Zurchin, PidgeonError as ZurchinError };
|