@bkazemi/verily 0.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 +21 -0
- package/README.md +503 -0
- package/dist/browser/badge.d.ts +39 -0
- package/dist/browser/badge.js +440 -0
- package/dist/browser/connect-dialog.d.ts +83 -0
- package/dist/browser/connect-dialog.js +514 -0
- package/dist/browser/evidence-dialog.d.ts +59 -0
- package/dist/browser/evidence-dialog.js +541 -0
- package/dist/browser/index.d.ts +59 -0
- package/dist/browser/index.js +809 -0
- package/dist/browser/logo.d.ts +2 -0
- package/dist/browser/logo.js +17 -0
- package/dist/browser/mark.d.ts +19 -0
- package/dist/browser/mark.js +77 -0
- package/dist/browser/provider-mark.d.ts +6 -0
- package/dist/browser/provider-mark.js +99 -0
- package/dist/browser/signed.d.ts +40 -0
- package/dist/browser/signed.js +219 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +3 -0
- package/dist/core/index.d.ts +454 -0
- package/dist/core/index.js +128 -0
- package/dist/core/signed.d.ts +49 -0
- package/dist/core/signed.js +113 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/logo.d.ts +21 -0
- package/dist/logo.js +38 -0
- package/dist/postgres/index.d.ts +12 -0
- package/dist/postgres/index.js +76 -0
- package/dist/server/addresses.d.ts +2 -0
- package/dist/server/addresses.js +61 -0
- package/dist/server/body.d.ts +11 -0
- package/dist/server/body.js +49 -0
- package/dist/server/copy.d.ts +8 -0
- package/dist/server/copy.js +42 -0
- package/dist/server/discord.d.ts +7 -0
- package/dist/server/discord.js +69 -0
- package/dist/server/email-logo.d.ts +11 -0
- package/dist/server/email-logo.js +122 -0
- package/dist/server/email.d.ts +46 -0
- package/dist/server/email.js +145 -0
- package/dist/server/escape.d.ts +2 -0
- package/dist/server/escape.js +2 -0
- package/dist/server/github-gist.d.ts +11 -0
- package/dist/server/github-gist.js +68 -0
- package/dist/server/github.d.ts +7 -0
- package/dist/server/github.js +65 -0
- package/dist/server/index.d.ts +70 -0
- package/dist/server/index.js +862 -0
- package/dist/server/link.d.ts +64 -0
- package/dist/server/link.js +458 -0
- package/dist/server/openpgp.d.ts +49 -0
- package/dist/server/openpgp.js +158 -0
- package/dist/server/pgp.d.ts +29 -0
- package/dist/server/pgp.js +198 -0
- package/dist/server/public-fetch.d.ts +23 -0
- package/dist/server/public-fetch.js +62 -0
- package/dist/server/resend.d.ts +13 -0
- package/dist/server/resend.js +37 -0
- package/dist/server/service.d.ts +311 -0
- package/dist/server/service.js +1178 -0
- package/dist/server/signing.d.ts +16 -0
- package/dist/server/signing.js +56 -0
- package/dist/server/style.d.ts +17 -0
- package/dist/server/style.js +244 -0
- package/dist/server/wkd.d.ts +7 -0
- package/dist/server/wkd.js +65 -0
- package/dist/server/youtube.d.ts +11 -0
- package/dist/server/youtube.js +99 -0
- package/dist/site/index.d.ts +139 -0
- package/dist/site/index.js +239 -0
- package/dist/verily.js +11907 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.js +10 -0
- package/docs/licenses/gpl-3.0.txt +232 -0
- package/docs/licenses/octicons.txt +21 -0
- package/docs/licenses/openpgp.txt +172 -0
- package/docs/licenses/rubik.txt +93 -0
- package/docs/licenses/simple-icons.txt +8 -0
- package/package.json +86 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { type Attestations, type Connection, type Evidence, type ExternalAccount, type Flow, type LocalAccount, type Provider, type SignedDocument, type SignedEvidence, type Storage, type VerifierKey, type Visibility } from '../core/index.js';
|
|
2
|
+
export declare const secret: () => string;
|
|
3
|
+
export declare const hash: (value: string) => string;
|
|
4
|
+
export declare class Unavailable extends Error {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export interface ServiceOptions {
|
|
8
|
+
storage: Storage;
|
|
9
|
+
/**
|
|
10
|
+
* The methods this instance offers. Several may share a provider id: `githubProvider()`,
|
|
11
|
+
* `githubGistProvider()` and `githubLinkProvider()` are three ways to show one GitHub
|
|
12
|
+
* account, and a record shown by more than one keeps them all. The first is the default.
|
|
13
|
+
*/
|
|
14
|
+
providers: Provider[];
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
siteName: string;
|
|
17
|
+
verifierName: string;
|
|
18
|
+
profileOrigins: string[];
|
|
19
|
+
validityMs?: number;
|
|
20
|
+
flowTtlMs?: number;
|
|
21
|
+
shareTtlMs?: number;
|
|
22
|
+
/** How stale a published proof may be before it stops counting. Infinity never expires. */
|
|
23
|
+
freshnessMs?: number;
|
|
24
|
+
/** How often recheck() reads a given proof again. Must be well under freshnessMs. */
|
|
25
|
+
recheckMs?: number;
|
|
26
|
+
recheckTimeoutMs?: number;
|
|
27
|
+
/**
|
|
28
|
+
* How many messages a code provider may send in any twenty-four hours: in all, and to
|
|
29
|
+
* any one address. A visitor chooses where a message goes, so the first bounds what one
|
|
30
|
+
* of them can spend of the deployment's mail allowance and the second what an address
|
|
31
|
+
* whose holder never asked can be sent. A hundred and five unless set; `Infinity` lifts
|
|
32
|
+
* one. Each provider is counted on its own.
|
|
33
|
+
*/
|
|
34
|
+
sendLimits?: {
|
|
35
|
+
day?: number;
|
|
36
|
+
address?: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Signs public records, so a saved signed record can be checked away from this
|
|
40
|
+
* instance, with `gpg` or anything else that reads OpenPGP. A key from
|
|
41
|
+
* `generateSigningKey()`, or a function giving one where it is read from storage.
|
|
42
|
+
* Unset signs nothing. Losing the key puts every record it signed out of reach of a
|
|
43
|
+
* check, so keep it wherever the instance's other secrets are kept.
|
|
44
|
+
*/
|
|
45
|
+
signingKey?: string | (() => Promise<string>);
|
|
46
|
+
/** Public keys this instance signed with before, so what they signed still checks. */
|
|
47
|
+
retiredKeys?: VerifierKey[];
|
|
48
|
+
now?: () => number;
|
|
49
|
+
}
|
|
50
|
+
export declare class VerilyService {
|
|
51
|
+
readonly options: ServiceOptions;
|
|
52
|
+
readonly now: () => number;
|
|
53
|
+
readonly baseUrl: string;
|
|
54
|
+
readonly providers: Provider[];
|
|
55
|
+
constructor(options: ServiceOptions);
|
|
56
|
+
private signing?;
|
|
57
|
+
/** The key this instance signs with, read once. */
|
|
58
|
+
private signer;
|
|
59
|
+
/** Every key a record of this instance may be signed by: the current one first. */
|
|
60
|
+
keys(): Promise<VerifierKey[]>;
|
|
61
|
+
/** The same keys as one armored text, which is what `gpg --import` takes. */
|
|
62
|
+
armoredKeys(): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* A public record that stands, signed as of now. Signed when asked for, not when
|
|
65
|
+
* approved, so a signed record says the record stood on the day it was taken and none can be
|
|
66
|
+
* made once it is removed.
|
|
67
|
+
*/
|
|
68
|
+
signed(id: string): Promise<SignedEvidence>;
|
|
69
|
+
/** What a signed record says, if this instance signed it. */
|
|
70
|
+
checked(signed: unknown): Promise<SignedDocument | undefined>;
|
|
71
|
+
private get sendLimits();
|
|
72
|
+
/** A proof is only as fresh as the schedule that reads it, so both live together. */
|
|
73
|
+
private get freshness();
|
|
74
|
+
validateLocal(local: LocalAccount): LocalAccount;
|
|
75
|
+
/** The site a subject belongs to: its own name where it has one, else this instance's. */
|
|
76
|
+
siteOf(local: Pick<LocalAccount, 'siteName'>): string;
|
|
77
|
+
/**
|
|
78
|
+
* The configured method a caller asked for: a provider id and, where that provider is
|
|
79
|
+
* shown more than one way, which way. Nothing asked for means the first configured.
|
|
80
|
+
*/
|
|
81
|
+
resolve(provider?: string, method?: string): Provider;
|
|
82
|
+
/** The method a flow was started with. A flow from before methods were recorded ran the first. */
|
|
83
|
+
providerOf(flow: Flow): Provider;
|
|
84
|
+
start(local?: LocalAccount, connectionId?: string, kind?: Flow['kind'], choice?: {
|
|
85
|
+
provider?: string;
|
|
86
|
+
method?: string;
|
|
87
|
+
}, context?: Record<string, string>): Promise<{
|
|
88
|
+
flowId: string;
|
|
89
|
+
binding: string;
|
|
90
|
+
expect: string;
|
|
91
|
+
instructions: import("../core/index.js").Instruction[];
|
|
92
|
+
authorizationUrl?: undefined;
|
|
93
|
+
} | {
|
|
94
|
+
flowId: string;
|
|
95
|
+
binding: string;
|
|
96
|
+
authorizationUrl: string;
|
|
97
|
+
expect?: undefined;
|
|
98
|
+
instructions?: undefined;
|
|
99
|
+
} | {
|
|
100
|
+
flowId: string;
|
|
101
|
+
binding: string;
|
|
102
|
+
expect?: undefined;
|
|
103
|
+
instructions?: undefined;
|
|
104
|
+
authorizationUrl?: undefined;
|
|
105
|
+
}>;
|
|
106
|
+
/**
|
|
107
|
+
* Which method a flow runs. A flow on an existing record stays in that record's
|
|
108
|
+
* namespace, and without a choice it uses the method the record was first shown by.
|
|
109
|
+
*
|
|
110
|
+
* Removing a link from the external side takes a method whose proof is fresh. A standing
|
|
111
|
+
* proof, such as a link back, is there for anyone to point at: handing one back shows
|
|
112
|
+
* the link exists, not that whoever handed it back holds the account.
|
|
113
|
+
*/
|
|
114
|
+
private chosen;
|
|
115
|
+
/**
|
|
116
|
+
* Accepts what the holder hands back: the address they published the flow's string at,
|
|
117
|
+
* or the proof itself. Both are holder-supplied, so the provider decides what counts.
|
|
118
|
+
* A code provider is handed two things in turn, the address to send to and then the
|
|
119
|
+
* code that arrived there.
|
|
120
|
+
*/
|
|
121
|
+
submit(id: string, binding: string, artifact: string): Promise<string>;
|
|
122
|
+
/**
|
|
123
|
+
* One step of a mailed code. The first answer is an address: a code is minted, sent
|
|
124
|
+
* there, and only its hash kept. The second is the code, which the holder could only
|
|
125
|
+
* have read at that address. The code is the whole proof and short enough to type, so
|
|
126
|
+
* the guesses are counted and a flow that runs out of them is dead.
|
|
127
|
+
*/
|
|
128
|
+
private answer;
|
|
129
|
+
/**
|
|
130
|
+
* Counts one message against the day's ceiling and the address's, and says whether both
|
|
131
|
+
* had room. All or nothing, so a message refused by one spends nothing from the other.
|
|
132
|
+
* Counted before the message goes, so one that fails to send is still spent: a sender
|
|
133
|
+
* that is failing is not a reason to try it more often. The address is kept as a hash.
|
|
134
|
+
*/
|
|
135
|
+
private spend;
|
|
136
|
+
/**
|
|
137
|
+
* The flow a confirmation link belongs to, while the link is still good. The link is
|
|
138
|
+
* the whole credential and is used from wherever the holder reads their mail, so no
|
|
139
|
+
* binding is asked for: it proves the mailbox and nothing else, and what happens to the
|
|
140
|
+
* flow next is still up to the browser that started it.
|
|
141
|
+
*/
|
|
142
|
+
private linked;
|
|
143
|
+
/**
|
|
144
|
+
* What a confirmation link would confirm, to show its holder before they press anything.
|
|
145
|
+
* The subject is named only for a new link, where the one who started the flow is the
|
|
146
|
+
* one who named it. A flow on an existing record is started by anybody, and its subject
|
|
147
|
+
* is nobody's to read until the matching account has been shown.
|
|
148
|
+
*/
|
|
149
|
+
confirming(id: string, token: string): Promise<{
|
|
150
|
+
kind: "visibility" | "connect" | "renew" | "revoke" | "share-revoke";
|
|
151
|
+
provider: Provider;
|
|
152
|
+
account: ExternalAccount;
|
|
153
|
+
local: LocalAccount | undefined;
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* Takes a pressed confirmation link as the proof a typed code would have been, and
|
|
157
|
+
* returns the flow as that left it. The link is spent either way.
|
|
158
|
+
*/
|
|
159
|
+
confirm(id: string, token: string): Promise<Flow>;
|
|
160
|
+
private bound;
|
|
161
|
+
flow(id: string, binding: string): Promise<Flow>;
|
|
162
|
+
callback(state: string, binding: string, code?: string): Promise<string>;
|
|
163
|
+
/**
|
|
164
|
+
* The identity is established the same way whichever method produced it, so both paths
|
|
165
|
+
* land here: a provider result is never trusted for its shape, and a flow against an
|
|
166
|
+
* existing connection must still be the same account on the same provider. No binding
|
|
167
|
+
* means a confirmation link got here, which is held to the link and not to a browser.
|
|
168
|
+
*/
|
|
169
|
+
private established;
|
|
170
|
+
/**
|
|
171
|
+
* A failed check leaves the flow dead rather than retryable in place. Only a `Refused`
|
|
172
|
+
* reason is kept: any other error may describe this backend rather than the proof.
|
|
173
|
+
*/
|
|
174
|
+
private failed;
|
|
175
|
+
approve(id: string, binding: string, local: LocalAccount | undefined, visibility: Visibility, cancel?: boolean,
|
|
176
|
+
/**
|
|
177
|
+
* The visibilities this subject may choose, where it may not choose either. Checked at
|
|
178
|
+
* the point the record's visibility is set, inside the transaction that decides whether
|
|
179
|
+
* this approval makes a record or joins one, so no change in between gets past it.
|
|
180
|
+
*/
|
|
181
|
+
allowed?: Visibility[]): Promise<string | undefined>;
|
|
182
|
+
/**
|
|
183
|
+
* Ends a flow and records how, inside the transaction that ends it: the connection as it
|
|
184
|
+
* stands now, since whatever later reports this result must not read a record that has
|
|
185
|
+
* changed since. The caller puts the flow.
|
|
186
|
+
*/
|
|
187
|
+
private ended;
|
|
188
|
+
/** Every read of a connection goes through here, so a record in an older shape is upgraded. */
|
|
189
|
+
private transaction;
|
|
190
|
+
/**
|
|
191
|
+
* The methods a reader is shown. An additional method whose proof has gone unread no
|
|
192
|
+
* longer shows anything, so it is left out until it reads again; the main one is
|
|
193
|
+
* never left out, because the record's status already says what became of it.
|
|
194
|
+
*/
|
|
195
|
+
private shown;
|
|
196
|
+
evidence(connection: Connection): Evidence;
|
|
197
|
+
/**
|
|
198
|
+
* The live record a connect flow reproves by another method, if there is one: the same
|
|
199
|
+
* subject linked to the same account on the same provider, first shown some other way.
|
|
200
|
+
* The same method again is a second record, as it always was; renewing is how that
|
|
201
|
+
* one is extended.
|
|
202
|
+
*/
|
|
203
|
+
private joins;
|
|
204
|
+
/**
|
|
205
|
+
* The record a connect flow awaiting approval would add its method to, so the approval
|
|
206
|
+
* page can say so: the holder is not creating a link but reproving one, and the
|
|
207
|
+
* visibility already chosen for it stands.
|
|
208
|
+
*/
|
|
209
|
+
joining(flow: Flow): Promise<Connection | undefined>;
|
|
210
|
+
/**
|
|
211
|
+
* Records that a flow just showed the record's account again. Shown by the method the
|
|
212
|
+
* record was first shown by, it replaces that one; shown another way, it takes that
|
|
213
|
+
* method's place after it, or joins the end. Either way the holder approved it and the
|
|
214
|
+
* site reasserted its subject, so the record is extended and its subject refreshed.
|
|
215
|
+
*/
|
|
216
|
+
private recordMethod;
|
|
217
|
+
/**
|
|
218
|
+
* Whether a proof still names the subject as it is now. A method that has the holder
|
|
219
|
+
* publish something derived from the subject, as a link back publishes its address,
|
|
220
|
+
* proved the subject as it was then; one whose proof is a token minted per flow names no
|
|
221
|
+
* subject, and holds whatever the subject's address becomes.
|
|
222
|
+
*/
|
|
223
|
+
private names;
|
|
224
|
+
/** The site is the only authority on its own namespace, so it declares the local subject. */
|
|
225
|
+
private declared;
|
|
226
|
+
/** How the provider established the external account, by whatever method the flow ran. */
|
|
227
|
+
private attestation;
|
|
228
|
+
/**
|
|
229
|
+
* The proof itself, for a method whose artifact this backend publishes. It is as public
|
|
230
|
+
* as the evidence it belongs to and no more: an unlisted record's proof is the holder's
|
|
231
|
+
* to hand out, exactly like the evidence page it is linked from.
|
|
232
|
+
*/
|
|
233
|
+
proof(id: string, local?: LocalAccount): Promise<string>;
|
|
234
|
+
/** A record from a provider this instance no longer configures keeps its raw id. */
|
|
235
|
+
private providerName;
|
|
236
|
+
read(id: string, local?: LocalAccount): Promise<Evidence>;
|
|
237
|
+
/**
|
|
238
|
+
* Every connection this site has published. Public evidence is already world-readable
|
|
239
|
+
* one id at a time; listing it lets an embed follow the current connections instead of
|
|
240
|
+
* hardcoding an id that dies whenever one is revoked and replaced. Unlisted records are
|
|
241
|
+
* never included: they must not appear in any directory listing.
|
|
242
|
+
*/
|
|
243
|
+
published(): Promise<Evidence[]>;
|
|
244
|
+
mine(local: LocalAccount): Promise<Evidence[]>;
|
|
245
|
+
private owned;
|
|
246
|
+
revoke(id: string, local: LocalAccount): Promise<void>;
|
|
247
|
+
share(id: string, local: LocalAccount, revoke?: boolean): Promise<{
|
|
248
|
+
url: string;
|
|
249
|
+
expiresAt: number;
|
|
250
|
+
} | undefined>;
|
|
251
|
+
shared(token: string): Promise<{
|
|
252
|
+
evidenceUrl: string;
|
|
253
|
+
linkExpiresAt: number;
|
|
254
|
+
id: string;
|
|
255
|
+
local: Omit<LocalAccount, "id" | "siteName">;
|
|
256
|
+
external: ExternalAccount;
|
|
257
|
+
provider: string;
|
|
258
|
+
providerName: string;
|
|
259
|
+
attestations: Attestations;
|
|
260
|
+
siteName: string;
|
|
261
|
+
verifierName: string;
|
|
262
|
+
visibility: Visibility;
|
|
263
|
+
status: import("../core/index.js").Status;
|
|
264
|
+
connectedAt: number;
|
|
265
|
+
authenticatedAt: number;
|
|
266
|
+
approvedAt: number;
|
|
267
|
+
visibilityApprovedAt: number;
|
|
268
|
+
expiresAt: number;
|
|
269
|
+
revokedAt?: number;
|
|
270
|
+
signedUrl?: string;
|
|
271
|
+
}>;
|
|
272
|
+
/**
|
|
273
|
+
* Asks again about proofs, because unlike a sign-in they can stop being true with nobody
|
|
274
|
+
* told. What that means depends on who holds the proof:
|
|
275
|
+
*
|
|
276
|
+
* A proof published elsewhere is reread. The holder deletes the gist and this record
|
|
277
|
+
* would otherwise go on claiming it, so continued silence ages the connection out.
|
|
278
|
+
*
|
|
279
|
+
* A proof this backend hosts cannot go missing, so there is nothing to reread. What can
|
|
280
|
+
* still change is the identity behind it, and a method that has somewhere to say so is
|
|
281
|
+
* asked. A holder who publishes a revocation for their key has withdrawn it, which is a
|
|
282
|
+
* revocation of the connection rather than a proof gone stale.
|
|
283
|
+
*
|
|
284
|
+
* A failed read writes nothing. One refusal is not evidence the proof is gone, and a
|
|
285
|
+
* provider being down must not revoke anyone; it is continued silence that ages a
|
|
286
|
+
* connection out through `status`, and a single later success undoes that. Revocation
|
|
287
|
+
* stays what it is, something a party chose.
|
|
288
|
+
*
|
|
289
|
+
* `budget` bounds the reads per run, since providers rate-limit and the alarm this runs
|
|
290
|
+
* on is shared. Oldest first, so nothing starves however many connections are waiting.
|
|
291
|
+
*
|
|
292
|
+
* Returns how many were confirmed. A connection revoked here is not one of them.
|
|
293
|
+
*/
|
|
294
|
+
recheck(budget?: number): Promise<number>;
|
|
295
|
+
/**
|
|
296
|
+
* The configured method that can ask again about one attestation, or nothing when there
|
|
297
|
+
* is nothing to ask: no published proof, a method this instance no longer runs, or a
|
|
298
|
+
* hosted proof whose method has nowhere to hear of a withdrawal.
|
|
299
|
+
*/
|
|
300
|
+
private rereads;
|
|
301
|
+
/** Asks about one proof and records the answer. Returns 1 when it confirmed. */
|
|
302
|
+
private reread;
|
|
303
|
+
/** A provider that never answers must not hold up the maintenance run behind it. */
|
|
304
|
+
private deadline;
|
|
305
|
+
/** Run periodically. Pending secrets expire immediately; historical evidence defaults to 90 days. */
|
|
306
|
+
prune(retentionMs?: number): Promise<void>;
|
|
307
|
+
private invalidateShare;
|
|
308
|
+
private audit;
|
|
309
|
+
}
|
|
310
|
+
/** How many wrong codes a flow takes before it is dead. */
|
|
311
|
+
export declare const codeAttempts = 5;
|