@adminiumjs/public-client 0.3.0-rc.3 → 0.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/dist/index.d.ts +205 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +446 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -31,8 +31,16 @@
|
|
|
31
31
|
* resource and a forbidden one answer identically — so do not build UI that
|
|
32
32
|
* tries to tell those apart.
|
|
33
33
|
*/
|
|
34
|
-
export declare const PUBLIC_ERROR_CODES: readonly ["PUBLIC_API_DISABLED", "PUBLIC_KEY_INVALID", "PUBLIC_REF_NOT_FOUND", "PUBLIC_ACTION_NOT_ALLOWED", "PUBLIC_QUERY_REFUSED", "PUBLIC_RATE_LIMITED", "PUBLIC_ORIGIN_REFUSED", "PUBLIC_CLAIM_NO_MATCH", "PUBLIC_CLAIM_UNAVAILABLE", "PUBLIC_WRITE_REFUSED", "PUBLIC_WRITE_REJECTED", "PUBLIC_UPSTREAM_UNAVAILABLE", "PUBLIC_NETWORK_UNAVAILABLE"];
|
|
34
|
+
export declare const PUBLIC_ERROR_CODES: readonly ["PUBLIC_API_DISABLED", "PUBLIC_KEY_INVALID", "PUBLIC_REF_NOT_FOUND", "PUBLIC_ACTION_NOT_ALLOWED", "PUBLIC_QUERY_REFUSED", "PUBLIC_RATE_LIMITED", "PUBLIC_ORIGIN_REFUSED", "PUBLIC_CLAIM_NO_MATCH", "PUBLIC_CLAIM_UNAVAILABLE", "PUBLIC_WRITE_REFUSED", "PUBLIC_WRITE_REJECTED", "PUBLIC_SLOT_FULL", "PUBLIC_SLOT_BUSY", "PUBLIC_TOO_LATE", "PUBLIC_TOO_EARLY", "PUBLIC_CLAIM_LEVEL", "PUBLIC_LIMIT_REACHED", "PUBLIC_SWITCHED_OFF", "PUBLIC_STAFF_REQUIRED", "PUBLIC_KEY_OFF", "PUBLIC_CLAIM_NO_EMAIL", "PUBLIC_CLAIM_LOCKED", "PUBLIC_CODE_TOO_SOON", "PUBLIC_CODE_LIMIT", "PUBLIC_CODE_LOCKED", "PUBLIC_CODE_WRONG", "PUBLIC_CODE_EXPIRED", "PUBLIC_CODE_UNAVAILABLE", "PUBLIC_CODE_STEP_UP", "PUBLIC_EMAIL_CHANGE_LIMIT", "PUBLIC_PROOF_REQUIRED", "PUBLIC_UPSTREAM_UNAVAILABLE", "APP_DISABLED", "SURFACE_OFF", "PUBLIC_NETWORK_UNAVAILABLE"];
|
|
35
35
|
export type PublicErrorCode = (typeof PUBLIC_ERROR_CODES)[number];
|
|
36
|
+
/**
|
|
37
|
+
* What a `PUBLIC_TOO_EARLY` refusal carries, as instants (ISO strings): the
|
|
38
|
+
* row's own time, and the moment the change will be taken.
|
|
39
|
+
*/
|
|
40
|
+
export interface PublicTooEarly {
|
|
41
|
+
at: string;
|
|
42
|
+
from: string;
|
|
43
|
+
}
|
|
36
44
|
/**
|
|
37
45
|
* A failed request.
|
|
38
46
|
*
|
|
@@ -44,8 +52,14 @@ export type PublicErrorCode = (typeof PUBLIC_ERROR_CODES)[number];
|
|
|
44
52
|
export declare class PublicApiError extends Error {
|
|
45
53
|
readonly code: PublicErrorCode;
|
|
46
54
|
readonly status: number;
|
|
55
|
+
/**
|
|
56
|
+
* How long to wait before asking again: the `Retry-After` header on a rate
|
|
57
|
+
* limit, or the reply's own `retryAfter` on a code asked for too soon.
|
|
58
|
+
*/
|
|
47
59
|
readonly retryAfterSeconds: number | null;
|
|
48
|
-
|
|
60
|
+
/** What the server said beside the code — `triesLeft`, `retryAfter`. Empty when it said nothing. */
|
|
61
|
+
readonly params: Readonly<Record<string, unknown>>;
|
|
62
|
+
constructor(code: PublicErrorCode, status: number, message: string, retryAfterSeconds?: number, params?: Record<string, unknown>);
|
|
49
63
|
/**
|
|
50
64
|
* True when retrying later could plausibly work.
|
|
51
65
|
*
|
|
@@ -56,6 +70,8 @@ export declare class PublicApiError extends Error {
|
|
|
56
70
|
get isTransient(): boolean;
|
|
57
71
|
/** True when the surface is off — the signal to fall back to demo content. */
|
|
58
72
|
get isDisabled(): boolean;
|
|
73
|
+
/** On a `PUBLIC_TOO_EARLY` refusal, the times it carries; null on any other. */
|
|
74
|
+
get tooEarly(): PublicTooEarly | null;
|
|
59
75
|
}
|
|
60
76
|
export type PublicSide = 'staff' | 'customer';
|
|
61
77
|
/**
|
|
@@ -83,6 +99,8 @@ export interface PublicRefConfig {
|
|
|
83
99
|
response?: {
|
|
84
100
|
shape: PublicResponseShape;
|
|
85
101
|
};
|
|
102
|
+
/** Present on an availability ref: ask `availability` or `bookingTimes`, never `list`. */
|
|
103
|
+
kind?: 'availability';
|
|
86
104
|
}
|
|
87
105
|
export interface PublicConfig {
|
|
88
106
|
version: 1;
|
|
@@ -100,6 +118,8 @@ export interface PublicConfig {
|
|
|
100
118
|
strategy: 'lookup' | 'email-code' | 'external';
|
|
101
119
|
ref: string;
|
|
102
120
|
match: string[];
|
|
121
|
+
/** A found session can be raised to `verified` by a code emailed to the person. */
|
|
122
|
+
verify?: 'email-code';
|
|
103
123
|
} | null;
|
|
104
124
|
/**
|
|
105
125
|
* Whether this key may ask for a document to be drawn.
|
|
@@ -153,6 +173,106 @@ export interface PublicClientOptions {
|
|
|
153
173
|
publishableKey: string;
|
|
154
174
|
/** Injectable for tests; `globalThis.fetch` otherwise. */
|
|
155
175
|
fetch?: typeof fetch;
|
|
176
|
+
/**
|
|
177
|
+
* The human check on `create` and `claim`.
|
|
178
|
+
*
|
|
179
|
+
* Absent, the client answers the server: it sends without a proof and, when
|
|
180
|
+
* refused for want of one, solves a challenge and sends again. `true` solves
|
|
181
|
+
* one before every create and claim — a page that knows its refs ask saves
|
|
182
|
+
* the refused round trip. `false` never solves one, and the refusal reaches
|
|
183
|
+
* the page as `PUBLIC_PROOF_REQUIRED`. The object form names what is known
|
|
184
|
+
* to ask, and answers the server for the rest.
|
|
185
|
+
*/
|
|
186
|
+
humanCheck?: boolean | {
|
|
187
|
+
refs?: readonly string[];
|
|
188
|
+
claim?: boolean;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* The signed-in staff member's CSRF token, for a key bound to staff (a
|
|
192
|
+
* kiosk). Sent on every write, never on a read.
|
|
193
|
+
*
|
|
194
|
+
* A kiosk page reads both halves from its staff `surface-config.json`: the
|
|
195
|
+
* token from `csrfToken`, and the key from `publicKeys[purpose]` as
|
|
196
|
+
* `publishableKey`. A getter is read on each request, so a token that
|
|
197
|
+
* changes with a new sign-in is picked up without a new client.
|
|
198
|
+
*
|
|
199
|
+
* The key's other condition is the staff cookie, which a same-origin fetch
|
|
200
|
+
* sends by default: this client never sets `credentials`, and must not.
|
|
201
|
+
*/
|
|
202
|
+
csrfToken?: string | (() => string | null | undefined);
|
|
203
|
+
}
|
|
204
|
+
/** How far a claim session reaches: `lookup` found the person, `verified` proved their mailbox. */
|
|
205
|
+
export type ClaimLevel = 'lookup' | 'verified';
|
|
206
|
+
/** The claim session a client holds, without its token. */
|
|
207
|
+
export interface PublicSession {
|
|
208
|
+
level: ClaimLevel;
|
|
209
|
+
/** Epoch ms. */
|
|
210
|
+
expiresAt: number;
|
|
211
|
+
}
|
|
212
|
+
/** A day of a strip of days, as a booking availability ref answers it. */
|
|
213
|
+
export interface DayAvailability {
|
|
214
|
+
/** `YYYY-MM-DD` on the tenant's calendar. */
|
|
215
|
+
date: string;
|
|
216
|
+
/** How many of the day's times are free. */
|
|
217
|
+
open: number;
|
|
218
|
+
state: 'open' | 'full' | 'closed';
|
|
219
|
+
}
|
|
220
|
+
/** What a booking availability read asks, whichever form. */
|
|
221
|
+
export interface BookingQuery {
|
|
222
|
+
/** The kind of visit — its key, as the table knows it. */
|
|
223
|
+
kind: string;
|
|
224
|
+
/** One person's key, or `any` (the default). */
|
|
225
|
+
resource?: string;
|
|
226
|
+
/**
|
|
227
|
+
* The id of a row this session reaches — the visit being moved — so its
|
|
228
|
+
* own time is not counted against it. Ignored for a row the session cannot
|
|
229
|
+
* read, so it tells a stranger nothing.
|
|
230
|
+
*/
|
|
231
|
+
exclude?: string;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* What `requestCode` asks for. `verify` goes to the address the person
|
|
235
|
+
* already has; `email-change` goes to the NEW address, and needs a verified
|
|
236
|
+
* session that confirmed a code in the last few minutes.
|
|
237
|
+
*/
|
|
238
|
+
export type CodeRequest = {
|
|
239
|
+
purpose: 'verify';
|
|
240
|
+
} | {
|
|
241
|
+
purpose: 'email-change';
|
|
242
|
+
email: string;
|
|
243
|
+
};
|
|
244
|
+
/** A code is on its way. */
|
|
245
|
+
export interface CodeSent {
|
|
246
|
+
/** The address, masked (`l•••@e•••.com`): show it so the person knows where to look. */
|
|
247
|
+
sentTo: string;
|
|
248
|
+
/** Seconds before another code may be asked for. */
|
|
249
|
+
resendAfter: number;
|
|
250
|
+
/** Epoch ms after which this code no longer works. */
|
|
251
|
+
expiresAt: number;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The answer to a typed-back code.
|
|
255
|
+
*
|
|
256
|
+
* A wrong code is an ordinary outcome, like a claim that does not match, so it
|
|
257
|
+
* is a result rather than an exception. `ended` is true after an address
|
|
258
|
+
* change: every session of that person ends, this one too, and the client has
|
|
259
|
+
* already dropped it — the page asks them to find themselves again.
|
|
260
|
+
*/
|
|
261
|
+
export type VerifyCodeResult = {
|
|
262
|
+
ok: true;
|
|
263
|
+
level: ClaimLevel;
|
|
264
|
+
expiresAt: number;
|
|
265
|
+
ended: boolean;
|
|
266
|
+
email?: string;
|
|
267
|
+
} | {
|
|
268
|
+
ok: false;
|
|
269
|
+
triesLeft: number;
|
|
270
|
+
};
|
|
271
|
+
/** A created row, and where it stands when the endpoint ranks ("you are 3rd on the list"). */
|
|
272
|
+
export interface Created<T = Row> {
|
|
273
|
+
data: T;
|
|
274
|
+
/** Null when the endpoint does not rank. */
|
|
275
|
+
rank: number | null;
|
|
156
276
|
}
|
|
157
277
|
/** One drawn document, as a claimed visitor may see it. */
|
|
158
278
|
export interface PublicDocument {
|
|
@@ -204,12 +324,23 @@ export interface PublicDocuments {
|
|
|
204
324
|
/** The same-origin bytes URL — an `<a download>`, never an `<iframe>`. */
|
|
205
325
|
contentUrl: (id: string) => string;
|
|
206
326
|
}
|
|
327
|
+
/** One time of a day, as an availability ref answers it. */
|
|
328
|
+
export interface SlotAvailability {
|
|
329
|
+
/** `HH:mm` on the tenant's clock; {@link fromTenantLocal} turns it into the instant to book. */
|
|
330
|
+
time: string;
|
|
331
|
+
state: 'free' | 'full';
|
|
332
|
+
}
|
|
207
333
|
export interface PublicClient {
|
|
208
334
|
/** The scope, fetched once and cached. */
|
|
209
335
|
config: () => Promise<PublicConfig>;
|
|
210
336
|
list: <T = Row>(ref: string, options?: ListOptions) => Promise<ListResult<T>>;
|
|
211
337
|
get: <T = Row>(ref: string, id: string, signal?: AbortSignal) => Promise<T>;
|
|
212
338
|
create: <T = Row>(ref: string, values: Row) => Promise<T>;
|
|
339
|
+
/**
|
|
340
|
+
* `create`, with where the new row stands. Its own verb so that `create`
|
|
341
|
+
* keeps answering the bare row every app already reads.
|
|
342
|
+
*/
|
|
343
|
+
createWithRank: <T = Row>(ref: string, values: Row) => Promise<Created<T>>;
|
|
213
344
|
update: <T = Row>(ref: string, id: string, values: Row) => Promise<T>;
|
|
214
345
|
/**
|
|
215
346
|
* Replace the row's writable columns — every one of them must be present (a
|
|
@@ -225,11 +356,42 @@ export interface PublicClient {
|
|
|
225
356
|
batch: (ref: string, rows: Row[]) => Promise<{
|
|
226
357
|
count: number;
|
|
227
358
|
}>;
|
|
359
|
+
/**
|
|
360
|
+
* Which of a day's times have room for a party, from an availability ref:
|
|
361
|
+
* `HH:mm` on the tenant's clock, free or full, and nothing more. A claimed
|
|
362
|
+
* visitor's own booking is not counted against them.
|
|
363
|
+
*/
|
|
364
|
+
availability: (ref: string, day: string, party: number, signal?: AbortSignal) => Promise<SlotAvailability[]>;
|
|
365
|
+
/**
|
|
366
|
+
* The times of one day, from an availability ref on a BOOKING table (a
|
|
367
|
+
* clinic): a kind of visit, with one person or anyone.
|
|
368
|
+
*/
|
|
369
|
+
bookingTimes: (ref: string, query: BookingQuery & {
|
|
370
|
+
date: string;
|
|
371
|
+
}, signal?: AbortSignal) => Promise<SlotAvailability[]>;
|
|
372
|
+
/** A strip of up to 31 days from `from`, each open, full or closed, from the same ref. */
|
|
373
|
+
bookingDays: (ref: string, query: BookingQuery & {
|
|
374
|
+
from: string;
|
|
375
|
+
days: number;
|
|
376
|
+
}, signal?: AbortSignal) => Promise<DayAvailability[]>;
|
|
228
377
|
/** Identify the visitor. Returns false when the details did not match. */
|
|
229
378
|
claim: (match: Record<string, unknown>) => Promise<boolean>;
|
|
379
|
+
/** Email the claimed person a code — to raise the session, or to confirm a new address. */
|
|
380
|
+
requestCode: (request: CodeRequest) => Promise<CodeSent>;
|
|
381
|
+
/**
|
|
382
|
+
* Type the code back. On success the session the client holds takes the new
|
|
383
|
+
* level and expiry; after an address change it is dropped (see
|
|
384
|
+
* {@link VerifyCodeResult}).
|
|
385
|
+
*/
|
|
386
|
+
verifyCode: (input: {
|
|
387
|
+
purpose?: CodeRequest['purpose'];
|
|
388
|
+
code: string;
|
|
389
|
+
}) => Promise<VerifyCodeResult>;
|
|
230
390
|
signOut: () => Promise<void>;
|
|
231
391
|
/** Is a claim session currently held? */
|
|
232
392
|
isClaimed: () => boolean;
|
|
393
|
+
/** The claim session held, or null. */
|
|
394
|
+
session: () => PublicSession | null;
|
|
233
395
|
/**
|
|
234
396
|
* The documents this visitor may see and ask for.
|
|
235
397
|
*
|
|
@@ -266,6 +428,16 @@ export declare function createPublicClient(options: Partial<PublicClientOptions>
|
|
|
266
428
|
export declare function toTenantDay(iso: string, timezone: string): string;
|
|
267
429
|
/** Minutes since midnight in the tenant's zone. */
|
|
268
430
|
export declare function toTenantMinutes(iso: string, timezone: string): number;
|
|
431
|
+
/**
|
|
432
|
+
* The instant a tenant-local wall time names, as an ISO string — the inverse
|
|
433
|
+
* of {@link toTenantDay} and {@link toTenantMinutes}. A guest picks "7 pm on
|
|
434
|
+
* Friday" on the venue's calendar; this is what the API is sent, whatever
|
|
435
|
+
* zone the guest's own device is in.
|
|
436
|
+
*
|
|
437
|
+
* A time the clocks skip in spring reads as the hour after; one they pass
|
|
438
|
+
* twice in autumn, as the first.
|
|
439
|
+
*/
|
|
440
|
+
export declare function fromTenantLocal(day: string, minutes: number, timezone: string): string;
|
|
269
441
|
/**
|
|
270
442
|
* Is a zone a real, canonical IANA name?
|
|
271
443
|
*
|
|
@@ -285,4 +457,35 @@ export declare function toTenantMinutes(iso: string, timezone: string): number;
|
|
|
285
457
|
*/
|
|
286
458
|
export declare function formatTenantMoney(value: string | number, currency: string | null, locale?: string): string;
|
|
287
459
|
export declare function isCanonicalTimeZone(timezone: string): boolean;
|
|
460
|
+
/** What a proof is asked for: a create, or a claim. */
|
|
461
|
+
export type ProofPurpose = 'write' | 'claim';
|
|
462
|
+
/** A challenge, as `GET /public/challenge` hands it out. */
|
|
463
|
+
export interface ProofChallenge {
|
|
464
|
+
/** Sent back as `x-adminium-proof: <id>.<nonce>`. */
|
|
465
|
+
id: string;
|
|
466
|
+
salt: string;
|
|
467
|
+
/** Leading zero bits `sha256(salt + nonce)` must start with. */
|
|
468
|
+
difficulty: number;
|
|
469
|
+
/** Epoch ms. Two minutes after it was handed out. */
|
|
470
|
+
expiresAt: number;
|
|
471
|
+
}
|
|
472
|
+
/** SHA-256 of a string (as UTF-8) or of bytes, synchronously. */
|
|
473
|
+
export declare const sha256: (input: string | Uint8Array) => Uint8Array;
|
|
474
|
+
/** How many zero bits a hash starts with. */
|
|
475
|
+
export declare const leadingZeroBits: (bytes: Uint8Array) => number;
|
|
476
|
+
/**
|
|
477
|
+
* What the worker runs: the kernel, rebuilt from its own text, searching from
|
|
478
|
+
* zero until it finds a nonce. Built as a string so that no bundler has to be
|
|
479
|
+
* told about a worker file.
|
|
480
|
+
*/
|
|
481
|
+
export declare function proofWorkerSource(): string;
|
|
482
|
+
/**
|
|
483
|
+
* Find the nonce a challenge asks for.
|
|
484
|
+
*
|
|
485
|
+
* In a Web Worker where there is one, so the page stays responsive through
|
|
486
|
+
* the second a cheap phone spends on it. Where there is none — a test, a
|
|
487
|
+
* server render, a CSP that refuses `blob:` workers — on this thread, in
|
|
488
|
+
* small chunks that yield between them, so a click still lands meanwhile.
|
|
489
|
+
*/
|
|
490
|
+
export declare function solveChallenge(challenge: ProofChallenge): Promise<string>;
|
|
288
491
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,6zBAkFrB,CAAC;AACX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,oGAAoG;IACpG,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;gBAGjD,IAAI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it is the project's own text.
|
|
50
50
|
*/
|
|
51
51
|
'PUBLIC_WRITE_REJECTED',
|
|
52
|
+
/**
|
|
53
|
+
* The time a booking asks for has no room left, or another guest is booking
|
|
54
|
+
* it this instant (`BUSY`: try again in a moment).
|
|
55
|
+
*/
|
|
56
|
+
'PUBLIC_SLOT_FULL',
|
|
57
|
+
'PUBLIC_SLOT_BUSY',
|
|
58
|
+
/** Too close to the time to cancel online; the venue still can. */
|
|
59
|
+
'PUBLIC_TOO_LATE',
|
|
60
|
+
/**
|
|
61
|
+
* Too early for this change — a kiosk check-in more than an hour before the
|
|
62
|
+
* visit (409). `error.tooEarly` holds the row's time and when the window
|
|
63
|
+
* opens; say them in the venue's zone (`toTenantMinutes`).
|
|
64
|
+
*/
|
|
65
|
+
'PUBLIC_TOO_EARLY',
|
|
66
|
+
/**
|
|
67
|
+
* The resource needs a VERIFIED session and this one only found the person
|
|
68
|
+
* (403): ask for the emailed code with `requestCode`, then `verifyCode`.
|
|
69
|
+
*/
|
|
70
|
+
'PUBLIC_CLAIM_LEVEL',
|
|
71
|
+
/** The signed-in person already holds as many open rows here as the app allows (409). */
|
|
72
|
+
'PUBLIC_LIMIT_REACHED',
|
|
73
|
+
/** The app switched this off in its own settings — online booking, say (403). */
|
|
74
|
+
'PUBLIC_SWITCHED_OFF',
|
|
75
|
+
/**
|
|
76
|
+
* A kiosk's key used without its staff member signed in on this screen
|
|
77
|
+
* (403). One code for every reason, so do not try to tell them apart.
|
|
78
|
+
*/
|
|
79
|
+
'PUBLIC_STAFF_REQUIRED',
|
|
80
|
+
/** The app switched this key off — the kiosk switch (503). */
|
|
81
|
+
'PUBLIC_KEY_OFF',
|
|
82
|
+
/** The person has no address a code could go to (409): send them to the desk. */
|
|
83
|
+
'PUBLIC_CLAIM_NO_EMAIL',
|
|
84
|
+
/** Too many wrong codes for this person today (403); the desk can lift it. */
|
|
85
|
+
'PUBLIC_CLAIM_LOCKED',
|
|
86
|
+
/** A code was sent a moment ago (429); `retryAfterSeconds` says how long to wait. */
|
|
87
|
+
'PUBLIC_CODE_TOO_SOON',
|
|
88
|
+
/** This session has asked for as many codes as it may (429). */
|
|
89
|
+
'PUBLIC_CODE_LIMIT',
|
|
90
|
+
/** The last code died of wrong tries and this session waits (429, `retryAfterSeconds`). */
|
|
91
|
+
'PUBLIC_CODE_LOCKED',
|
|
92
|
+
/** That code is not right (403). `verifyCode` answers it as a result, with the tries left. */
|
|
93
|
+
'PUBLIC_CODE_WRONG',
|
|
94
|
+
/** No code is open for this session: it expired, was used or was replaced (410). */
|
|
95
|
+
'PUBLIC_CODE_EXPIRED',
|
|
96
|
+
/** No code can be sent from this server right now (503). */
|
|
97
|
+
'PUBLIC_CODE_UNAVAILABLE',
|
|
98
|
+
/** Changing the address needs a code confirmed in the last few minutes (403). */
|
|
99
|
+
'PUBLIC_CODE_STEP_UP',
|
|
100
|
+
/** The address was changed today already (429). */
|
|
101
|
+
'PUBLIC_EMAIL_CHANGE_LIMIT',
|
|
102
|
+
/**
|
|
103
|
+
* The human check is missing, wrong, expired or already used (403). The
|
|
104
|
+
* client answers it itself on `create` and `claim` — once — so a page only
|
|
105
|
+
* sees it when a fresh proof was refused too.
|
|
106
|
+
*/
|
|
107
|
+
'PUBLIC_PROOF_REQUIRED',
|
|
52
108
|
'PUBLIC_UPSTREAM_UNAVAILABLE',
|
|
109
|
+
/**
|
|
110
|
+
* The app that made this key at install is switched off (503), or its
|
|
111
|
+
* customer side is. Nothing is wrong with the key or the request; it
|
|
112
|
+
* answers again once the app is switched back on.
|
|
113
|
+
*/
|
|
114
|
+
'APP_DISABLED',
|
|
115
|
+
'SURFACE_OFF',
|
|
53
116
|
/** Not from the server: the network never answered. */
|
|
54
117
|
'PUBLIC_NETWORK_UNAVAILABLE',
|
|
55
118
|
];
|
|
@@ -64,13 +127,21 @@ export const PUBLIC_ERROR_CODES = [
|
|
|
64
127
|
export class PublicApiError extends Error {
|
|
65
128
|
code;
|
|
66
129
|
status;
|
|
130
|
+
/**
|
|
131
|
+
* How long to wait before asking again: the `Retry-After` header on a rate
|
|
132
|
+
* limit, or the reply's own `retryAfter` on a code asked for too soon.
|
|
133
|
+
*/
|
|
67
134
|
retryAfterSeconds;
|
|
68
|
-
|
|
135
|
+
/** What the server said beside the code — `triesLeft`, `retryAfter`. Empty when it said nothing. */
|
|
136
|
+
params;
|
|
137
|
+
constructor(code, status, message, retryAfterSeconds, params) {
|
|
69
138
|
super(message);
|
|
70
139
|
this.name = 'PublicApiError';
|
|
71
140
|
this.code = code;
|
|
72
141
|
this.status = status;
|
|
73
|
-
this.
|
|
142
|
+
this.params = params ?? {};
|
|
143
|
+
const told = this.params['retryAfter'];
|
|
144
|
+
this.retryAfterSeconds = retryAfterSeconds ?? (typeof told === 'number' ? told : null);
|
|
74
145
|
}
|
|
75
146
|
/**
|
|
76
147
|
* True when retrying later could plausibly work.
|
|
@@ -81,6 +152,7 @@ export class PublicApiError extends Error {
|
|
|
81
152
|
*/
|
|
82
153
|
get isTransient() {
|
|
83
154
|
return (this.code === 'PUBLIC_RATE_LIMITED' ||
|
|
155
|
+
this.code === 'PUBLIC_SLOT_BUSY' ||
|
|
84
156
|
this.code === 'PUBLIC_UPSTREAM_UNAVAILABLE' ||
|
|
85
157
|
this.code === 'PUBLIC_NETWORK_UNAVAILABLE');
|
|
86
158
|
}
|
|
@@ -88,9 +160,22 @@ export class PublicApiError extends Error {
|
|
|
88
160
|
get isDisabled() {
|
|
89
161
|
return this.code === 'PUBLIC_API_DISABLED';
|
|
90
162
|
}
|
|
163
|
+
/** On a `PUBLIC_TOO_EARLY` refusal, the times it carries; null on any other. */
|
|
164
|
+
get tooEarly() {
|
|
165
|
+
if (this.code !== 'PUBLIC_TOO_EARLY')
|
|
166
|
+
return null;
|
|
167
|
+
const { at, from } = this.params;
|
|
168
|
+
return typeof at === 'string' && typeof from === 'string' ? { at, from } : null;
|
|
169
|
+
}
|
|
91
170
|
}
|
|
92
171
|
/* --------------------------------------------------------------- client */
|
|
93
172
|
const SESSION_HEADER = 'x-adminium-public-session';
|
|
173
|
+
const PROOF_HEADER = 'x-adminium-proof';
|
|
174
|
+
/** The staff member's token on a kiosk's writes — the dashboard's own CSRF header. */
|
|
175
|
+
const CSRF_HEADER = 'x-adminium-csrf';
|
|
176
|
+
const SAFE_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);
|
|
177
|
+
/** Where a claim that asked for a proof is remembered — a symbol, so no ref name can be it. */
|
|
178
|
+
const CLAIM = Symbol('claim');
|
|
94
179
|
const WRAPPED_KEYS = new Set(['data', 'page', 'cursor']);
|
|
95
180
|
/**
|
|
96
181
|
* Every list shape as one {@link ListResult}, read off the
|
|
@@ -123,14 +208,33 @@ export function createPublicClient(options) {
|
|
|
123
208
|
if (baseUrl === undefined || baseUrl === '' || key === undefined || key === '')
|
|
124
209
|
return null;
|
|
125
210
|
const doFetch = options?.fetch ?? globalThis.fetch.bind(globalThis);
|
|
211
|
+
const humanCheck = options?.humanCheck;
|
|
212
|
+
const csrfToken = options?.csrfToken;
|
|
126
213
|
let session = null;
|
|
127
214
|
let cachedConfig = null;
|
|
215
|
+
/** Refs that asked for a proof under the session held now, and {@link CLAIM} when a claim did. */
|
|
216
|
+
const asked = new Set();
|
|
217
|
+
/**
|
|
218
|
+
* The only way the session changes. What asked for a proof is forgotten
|
|
219
|
+
* with it: a signed-in person is excused the proof on a ref that caps what
|
|
220
|
+
* they hold, so what asked of a stranger need not ask of them.
|
|
221
|
+
*/
|
|
222
|
+
const holdSession = (next) => {
|
|
223
|
+
session = next;
|
|
224
|
+
asked.clear();
|
|
225
|
+
};
|
|
128
226
|
/** One request, with the reply's headers — `list()` reads `X-Next-Cursor`. */
|
|
129
|
-
const send = async (path, init = {}) => {
|
|
227
|
+
const send = async (path, init = {}, extra = {}) => {
|
|
228
|
+
const csrf = typeof csrfToken === 'function' ? csrfToken() : csrfToken;
|
|
229
|
+
const writes = init.method !== undefined && !SAFE_METHODS.has(init.method.toUpperCase());
|
|
130
230
|
const headers = {
|
|
131
231
|
authorization: `Bearer ${key}`,
|
|
132
232
|
...(init.body === undefined ? {} : { 'content-type': 'application/json' }),
|
|
133
|
-
...(session === null ? {} : { [SESSION_HEADER]: session }),
|
|
233
|
+
...(session === null ? {} : { [SESSION_HEADER]: session.token }),
|
|
234
|
+
// Only on a write: the server checks it only there, and a token in every
|
|
235
|
+
// read is one more place for it to be logged.
|
|
236
|
+
...(writes && typeof csrf === 'string' && csrf !== '' ? { [CSRF_HEADER]: csrf } : {}),
|
|
237
|
+
...extra,
|
|
134
238
|
};
|
|
135
239
|
let res;
|
|
136
240
|
try {
|
|
@@ -144,6 +248,7 @@ export function createPublicClient(options) {
|
|
|
144
248
|
if (!res.ok) {
|
|
145
249
|
let code = 'PUBLIC_UPSTREAM_UNAVAILABLE';
|
|
146
250
|
let message = `HTTP ${String(res.status)}`;
|
|
251
|
+
let params;
|
|
147
252
|
try {
|
|
148
253
|
const body = (await res.json());
|
|
149
254
|
const got = body.error?.code;
|
|
@@ -152,16 +257,77 @@ export function createPublicClient(options) {
|
|
|
152
257
|
}
|
|
153
258
|
if (typeof body.error?.message === 'string')
|
|
154
259
|
message = body.error.message;
|
|
260
|
+
if (typeof body.error?.params === 'object' && body.error.params !== null)
|
|
261
|
+
params = body.error.params;
|
|
155
262
|
}
|
|
156
263
|
catch {
|
|
157
264
|
/* a non-JSON error body — the status is all there is */
|
|
158
265
|
}
|
|
159
266
|
const retry = res.headers.get('retry-after');
|
|
160
|
-
throw new PublicApiError(code, res.status, message, retry === null ? undefined : Number(retry));
|
|
267
|
+
throw new PublicApiError(code, res.status, message, retry === null ? undefined : Number(retry), params);
|
|
161
268
|
}
|
|
162
269
|
return { body: (await res.json()), headers: res.headers };
|
|
163
270
|
};
|
|
164
|
-
const request = async (path, init = {}) => (await send(path, init)).body;
|
|
271
|
+
const request = async (path, init = {}, extra) => (await send(path, init, extra)).body;
|
|
272
|
+
/** A challenge fetched and solved, as the header value that carries it. */
|
|
273
|
+
const prove = async (purpose) => {
|
|
274
|
+
const out = await request(`/api/v1/public/challenge?purpose=${purpose}`);
|
|
275
|
+
return `${out.data.id}.${await solveChallenge(out.data)}`;
|
|
276
|
+
};
|
|
277
|
+
/** Is this create (a ref) or the claim (null) known to ask for a proof before it is sent? */
|
|
278
|
+
const knownToAsk = (ref) => {
|
|
279
|
+
if (humanCheck === true || asked.has(ref ?? CLAIM))
|
|
280
|
+
return true;
|
|
281
|
+
if (typeof humanCheck !== 'object')
|
|
282
|
+
return false;
|
|
283
|
+
return ref === null ? humanCheck.claim === true : (humanCheck.refs ?? []).includes(ref);
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* A create or a claim, with the human check it may owe.
|
|
287
|
+
*
|
|
288
|
+
* Unless it is known to ask, it goes WITHOUT a proof first and answers the
|
|
289
|
+
* server. That is the one choice right on every key: the config does not
|
|
290
|
+
* say which refs ask, a kiosk's key is never asked, and a signed-in person
|
|
291
|
+
* is excused on a ref that caps what they hold. It costs a refused round
|
|
292
|
+
* trip where a proof was owed, against a second of a cheap phone's time on
|
|
293
|
+
* every write where it was not. A ref that asked once solves first after
|
|
294
|
+
* that, until the session changes.
|
|
295
|
+
*
|
|
296
|
+
* The challenge is fetched here, at the moment of sending, and never
|
|
297
|
+
* earlier: it lives two minutes, and one fetched when the form opened can be
|
|
298
|
+
* dead by the time the visitor presses the button.
|
|
299
|
+
*
|
|
300
|
+
* A refusal is retried ONCE with a fresh proof, never in a loop: a second
|
|
301
|
+
* refusal is a real one — a key whose clock or secret disagrees — and
|
|
302
|
+
* solving again would only spend the visitor's battery on it.
|
|
303
|
+
*/
|
|
304
|
+
const withProof = async (purpose, ref, attempt) => {
|
|
305
|
+
if (humanCheck === false)
|
|
306
|
+
return attempt({});
|
|
307
|
+
const first = knownToAsk(ref) ? { [PROOF_HEADER]: await prove(purpose) } : {};
|
|
308
|
+
try {
|
|
309
|
+
return await attempt(first);
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
if (!(error instanceof PublicApiError) || error.code !== 'PUBLIC_PROOF_REQUIRED')
|
|
313
|
+
throw error;
|
|
314
|
+
asked.add(ref ?? CLAIM);
|
|
315
|
+
return attempt({ [PROOF_HEADER]: await prove(purpose) });
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
const insert = (ref, values) => withProof('write', ref, (proof) => request(`/api/v1/public/records/${ref}`, { method: 'POST', body: JSON.stringify({ values }) }, proof));
|
|
319
|
+
/** A booking availability read, in either form. */
|
|
320
|
+
const booking = async (ref, query, signal) => {
|
|
321
|
+
const init = {};
|
|
322
|
+
if (signal !== undefined)
|
|
323
|
+
init.signal = signal;
|
|
324
|
+
const p = new URLSearchParams();
|
|
325
|
+
for (const [name, value] of Object.entries(query))
|
|
326
|
+
if (value !== undefined)
|
|
327
|
+
p.set(name, String(value));
|
|
328
|
+
const out = await request(`/api/v1/public/availability/${ref}?${p.toString()}`, init);
|
|
329
|
+
return out.data;
|
|
330
|
+
};
|
|
165
331
|
/**
|
|
166
332
|
* Query-string encoder.
|
|
167
333
|
*
|
|
@@ -202,6 +368,24 @@ export function createPublicClient(options) {
|
|
|
202
368
|
const reply = await send(`/api/v1/public/records/${ref}${encode(options)}`, init);
|
|
203
369
|
return asListResult(reply.body, reply.headers);
|
|
204
370
|
},
|
|
371
|
+
async availability(ref, day, party, signal) {
|
|
372
|
+
const init = {};
|
|
373
|
+
if (signal !== undefined)
|
|
374
|
+
init.signal = signal;
|
|
375
|
+
const query = new URLSearchParams({ date: day, party: String(party) });
|
|
376
|
+
const out = await request(`/api/v1/public/availability/${ref}?${query.toString()}`, init);
|
|
377
|
+
return out.data;
|
|
378
|
+
},
|
|
379
|
+
bookingTimes(ref, query, signal) {
|
|
380
|
+
// Named one by one rather than spread: the server refuses a mixture of
|
|
381
|
+
// the two forms, and a caller's stray `from` would be one.
|
|
382
|
+
const { kind, resource, exclude, date } = query;
|
|
383
|
+
return booking(ref, { kind, resource, date, exclude }, signal);
|
|
384
|
+
},
|
|
385
|
+
bookingDays(ref, query, signal) {
|
|
386
|
+
const { kind, resource, exclude, from, days } = query;
|
|
387
|
+
return booking(ref, { kind, resource, from, days, exclude }, signal);
|
|
388
|
+
},
|
|
205
389
|
async get(ref, id, signal) {
|
|
206
390
|
const init = {};
|
|
207
391
|
if (signal !== undefined)
|
|
@@ -210,11 +394,11 @@ export function createPublicClient(options) {
|
|
|
210
394
|
return out.data;
|
|
211
395
|
},
|
|
212
396
|
async create(ref, values) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return out.data;
|
|
397
|
+
return (await insert(ref, values)).data;
|
|
398
|
+
},
|
|
399
|
+
async createWithRank(ref, values) {
|
|
400
|
+
const out = await insert(ref, values);
|
|
401
|
+
return { data: out.data, rank: typeof out.rank === 'number' ? out.rank : null };
|
|
218
402
|
},
|
|
219
403
|
async update(ref, id, values) {
|
|
220
404
|
const out = await request(`/api/v1/public/records/${ref}/${encodeURIComponent(id)}`, { method: 'PATCH', body: JSON.stringify({ values }) });
|
|
@@ -238,8 +422,9 @@ export function createPublicClient(options) {
|
|
|
238
422
|
},
|
|
239
423
|
async claim(match) {
|
|
240
424
|
try {
|
|
241
|
-
const out = await request('/api/v1/public/claim', { method: 'POST', body: JSON.stringify({ match }) });
|
|
242
|
-
|
|
425
|
+
const out = await withProof('claim', null, (proof) => request('/api/v1/public/claim', { method: 'POST', body: JSON.stringify({ match }) }, proof));
|
|
426
|
+
// A claim finds the person; only a code raises it to `verified`.
|
|
427
|
+
holdSession({ token: out.data.session, level: 'lookup', expiresAt: out.data.expiresAt });
|
|
243
428
|
return true;
|
|
244
429
|
}
|
|
245
430
|
catch (error) {
|
|
@@ -257,6 +442,46 @@ export function createPublicClient(options) {
|
|
|
257
442
|
throw error;
|
|
258
443
|
}
|
|
259
444
|
},
|
|
445
|
+
async requestCode(input) {
|
|
446
|
+
// Exactly the two shapes the server takes; it refuses any other key.
|
|
447
|
+
const body = input.purpose === 'verify' ? { purpose: 'verify' } : { purpose: input.purpose, email: input.email };
|
|
448
|
+
const out = await request('/api/v1/public/claim/code', {
|
|
449
|
+
method: 'POST',
|
|
450
|
+
body: JSON.stringify(body),
|
|
451
|
+
});
|
|
452
|
+
return out.data;
|
|
453
|
+
},
|
|
454
|
+
async verifyCode(input) {
|
|
455
|
+
const purpose = input.purpose ?? 'verify';
|
|
456
|
+
let out;
|
|
457
|
+
try {
|
|
458
|
+
out = await request('/api/v1/public/claim/verify', {
|
|
459
|
+
method: 'POST',
|
|
460
|
+
body: JSON.stringify({ purpose, code: input.code }),
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
catch (error) {
|
|
464
|
+
// A mistyped code is an ordinary outcome, like a claim that does not
|
|
465
|
+
// match; everything else — expired, locked — still throws.
|
|
466
|
+
if (error instanceof PublicApiError && error.code === 'PUBLIC_CODE_WRONG') {
|
|
467
|
+
const left = error.params['triesLeft'];
|
|
468
|
+
return { ok: false, triesLeft: typeof left === 'number' ? left : 0 };
|
|
469
|
+
}
|
|
470
|
+
throw error;
|
|
471
|
+
}
|
|
472
|
+
const { level, expiresAt, email } = out.data;
|
|
473
|
+
/*
|
|
474
|
+
* An address change ends every session of the person, this one too, and
|
|
475
|
+
* its reply's `expiresAt` is the moment it ended. Holding on to the
|
|
476
|
+
* token would only turn the next request into a puzzling 401.
|
|
477
|
+
*/
|
|
478
|
+
const ended = purpose === 'email-change' || expiresAt <= Date.now();
|
|
479
|
+
if (ended)
|
|
480
|
+
holdSession(null);
|
|
481
|
+
else if (session !== null)
|
|
482
|
+
holdSession({ token: session.token, level, expiresAt });
|
|
483
|
+
return { ok: true, level, expiresAt, ended, ...(email === undefined ? {} : { email }) };
|
|
484
|
+
},
|
|
260
485
|
async signOut() {
|
|
261
486
|
if (session === null)
|
|
262
487
|
return;
|
|
@@ -266,12 +491,15 @@ export function createPublicClient(options) {
|
|
|
266
491
|
finally {
|
|
267
492
|
// Dropped locally whatever the server said: a visitor who clicked sign
|
|
268
493
|
// out must not still be holding a session because a request failed.
|
|
269
|
-
|
|
494
|
+
holdSession(null);
|
|
270
495
|
}
|
|
271
496
|
},
|
|
272
497
|
isClaimed() {
|
|
273
498
|
return session !== null;
|
|
274
499
|
},
|
|
500
|
+
session() {
|
|
501
|
+
return session === null ? null : { level: session.level, expiresAt: session.expiresAt };
|
|
502
|
+
},
|
|
275
503
|
async assertRefs(required) {
|
|
276
504
|
const config = await client.config();
|
|
277
505
|
const missing = [];
|
|
@@ -363,6 +591,30 @@ export function toTenantMinutes(iso, timezone) {
|
|
|
363
591
|
// `en-GB` renders midnight as 24 in some ICU versions; normalise it.
|
|
364
592
|
return (hour % 24) * 60 + minute;
|
|
365
593
|
}
|
|
594
|
+
/**
|
|
595
|
+
* The instant a tenant-local wall time names, as an ISO string — the inverse
|
|
596
|
+
* of {@link toTenantDay} and {@link toTenantMinutes}. A guest picks "7 pm on
|
|
597
|
+
* Friday" on the venue's calendar; this is what the API is sent, whatever
|
|
598
|
+
* zone the guest's own device is in.
|
|
599
|
+
*
|
|
600
|
+
* A time the clocks skip in spring reads as the hour after; one they pass
|
|
601
|
+
* twice in autumn, as the first.
|
|
602
|
+
*/
|
|
603
|
+
export function fromTenantLocal(day, minutes, timezone) {
|
|
604
|
+
const naive = Date.parse(`${day}T00:00:00Z`) + Math.round(minutes) * 60_000;
|
|
605
|
+
const offsetAt = (instant) => {
|
|
606
|
+
const localDay = toTenantDay(new Date(instant).toISOString(), timezone);
|
|
607
|
+
const localMinutes = toTenantMinutes(new Date(instant).toISOString(), timezone);
|
|
608
|
+
return (Date.parse(`${localDay}T00:00:00Z`) + localMinutes * 60_000 - Math.floor(instant / 60_000) * 60_000) / 60_000;
|
|
609
|
+
};
|
|
610
|
+
// The offsets either side of the day: equal on most days; across a clock
|
|
611
|
+
// change, each names one reading of the wall time.
|
|
612
|
+
const readings = [naive - offsetAt(naive - 43_200_000) * 60_000, naive - offsetAt(naive + 43_200_000) * 60_000];
|
|
613
|
+
const exact = readings.filter((instant) => toTenantDay(new Date(instant).toISOString(), timezone) === day &&
|
|
614
|
+
toTenantMinutes(new Date(instant).toISOString(), timezone) === Math.round(minutes));
|
|
615
|
+
// Twice in autumn: the first. Never in spring: the earlier offset, an hour on.
|
|
616
|
+
return new Date(exact.length > 0 ? Math.min(...exact) : readings[0]).toISOString();
|
|
617
|
+
}
|
|
366
618
|
/**
|
|
367
619
|
* Is a zone a real, canonical IANA name?
|
|
368
620
|
*
|
|
@@ -398,4 +650,184 @@ export function isCanonicalTimeZone(timezone) {
|
|
|
398
650
|
return timezone.includes('/');
|
|
399
651
|
return supported.includes(timezone);
|
|
400
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* The work, as one function that reaches for nothing outside itself.
|
|
655
|
+
*
|
|
656
|
+
* Self-contained because it is shipped twice: called here, and turned back
|
|
657
|
+
* into source text for the worker. A helper it named from outside would be
|
|
658
|
+
* missing in the worker, which has only what the text carries. That is also
|
|
659
|
+
* why the SHA-256 is written out rather than taken from `crypto.subtle`: that
|
|
660
|
+
* one is async, and a promise per attempt makes the ~65,000 attempts of a
|
|
661
|
+
* sixteen-bit proof many times slower than hashing them straight through.
|
|
662
|
+
*
|
|
663
|
+
* A bundler told to keep function names (esbuild's `keepNames`) wraps each
|
|
664
|
+
* inner function in a helper of its own, which the worker's text does not
|
|
665
|
+
* carry. That worker then fails to start and the search runs on the page
|
|
666
|
+
* instead — slower, never wrong.
|
|
667
|
+
*/
|
|
668
|
+
function proofKernel() {
|
|
669
|
+
const K = new Int32Array([
|
|
670
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
671
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
672
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
673
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
674
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
675
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
676
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
677
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
678
|
+
]);
|
|
679
|
+
const W = new Int32Array(64);
|
|
680
|
+
const encoder = new TextEncoder();
|
|
681
|
+
const sha256 = (input) => {
|
|
682
|
+
const bytes = typeof input === 'string' ? encoder.encode(input) : input;
|
|
683
|
+
// The message, a 1 bit, zeros, and its length in bits as 64 big-endian
|
|
684
|
+
// bits, filling a whole number of 64-byte blocks.
|
|
685
|
+
const padded = new Uint8Array((((bytes.length + 8) >> 6) + 1) * 64);
|
|
686
|
+
padded.set(bytes);
|
|
687
|
+
padded[bytes.length] = 0x80;
|
|
688
|
+
const view = new DataView(padded.buffer);
|
|
689
|
+
view.setUint32(padded.length - 8, Math.floor(bytes.length / 0x20000000));
|
|
690
|
+
view.setUint32(padded.length - 4, (bytes.length * 8) >>> 0);
|
|
691
|
+
const H = new Int32Array([0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]);
|
|
692
|
+
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
693
|
+
for (let i = 0; i < 16; i += 1)
|
|
694
|
+
W[i] = view.getInt32(offset + i * 4);
|
|
695
|
+
for (let i = 16; i < 64; i += 1) {
|
|
696
|
+
const w15 = W[i - 15];
|
|
697
|
+
const w2 = W[i - 2];
|
|
698
|
+
const s0 = ((w15 >>> 7) | (w15 << 25)) ^ ((w15 >>> 18) | (w15 << 14)) ^ (w15 >>> 3);
|
|
699
|
+
const s1 = ((w2 >>> 17) | (w2 << 15)) ^ ((w2 >>> 19) | (w2 << 13)) ^ (w2 >>> 10);
|
|
700
|
+
W[i] = (W[i - 16] + s0 + W[i - 7] + s1) | 0;
|
|
701
|
+
}
|
|
702
|
+
let a = H[0], b = H[1], c = H[2], d = H[3], e = H[4], f = H[5], g = H[6], h = H[7];
|
|
703
|
+
for (let i = 0; i < 64; i += 1) {
|
|
704
|
+
const S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
|
|
705
|
+
const t1 = (h + S1 + ((e & f) ^ (~e & g)) + K[i] + W[i]) | 0;
|
|
706
|
+
const S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
|
|
707
|
+
const t2 = (S0 + ((a & b) ^ (a & c) ^ (b & c))) | 0;
|
|
708
|
+
h = g;
|
|
709
|
+
g = f;
|
|
710
|
+
f = e;
|
|
711
|
+
e = (d + t1) | 0;
|
|
712
|
+
d = c;
|
|
713
|
+
c = b;
|
|
714
|
+
b = a;
|
|
715
|
+
a = (t1 + t2) | 0;
|
|
716
|
+
}
|
|
717
|
+
H[0] = (H[0] + a) | 0;
|
|
718
|
+
H[1] = (H[1] + b) | 0;
|
|
719
|
+
H[2] = (H[2] + c) | 0;
|
|
720
|
+
H[3] = (H[3] + d) | 0;
|
|
721
|
+
H[4] = (H[4] + e) | 0;
|
|
722
|
+
H[5] = (H[5] + f) | 0;
|
|
723
|
+
H[6] = (H[6] + g) | 0;
|
|
724
|
+
H[7] = (H[7] + h) | 0;
|
|
725
|
+
}
|
|
726
|
+
const out = new Uint8Array(32);
|
|
727
|
+
const outView = new DataView(out.buffer);
|
|
728
|
+
for (let i = 0; i < 8; i += 1)
|
|
729
|
+
outView.setInt32(i * 4, H[i]);
|
|
730
|
+
return out;
|
|
731
|
+
};
|
|
732
|
+
const leadingZeroBits = (bytes) => {
|
|
733
|
+
let bits = 0;
|
|
734
|
+
for (const byte of bytes) {
|
|
735
|
+
if (byte !== 0)
|
|
736
|
+
return bits + Math.clz32(byte) - 24;
|
|
737
|
+
bits += 8;
|
|
738
|
+
}
|
|
739
|
+
return bits;
|
|
740
|
+
};
|
|
741
|
+
// The nonce is the counter in lowercase base 36 — the only spelling the
|
|
742
|
+
// server's header pattern accepts.
|
|
743
|
+
const search = (salt, difficulty, start, count) => {
|
|
744
|
+
for (let n = start; n < start + count; n += 1) {
|
|
745
|
+
const nonce = n.toString(36);
|
|
746
|
+
if (leadingZeroBits(sha256(salt + nonce)) >= difficulty)
|
|
747
|
+
return nonce;
|
|
748
|
+
}
|
|
749
|
+
return null;
|
|
750
|
+
};
|
|
751
|
+
return { sha256, leadingZeroBits, search };
|
|
752
|
+
}
|
|
753
|
+
const kernel = /* @__PURE__ */ proofKernel();
|
|
754
|
+
/** SHA-256 of a string (as UTF-8) or of bytes, synchronously. */
|
|
755
|
+
export const sha256 = kernel.sha256;
|
|
756
|
+
/** How many zero bits a hash starts with. */
|
|
757
|
+
export const leadingZeroBits = kernel.leadingZeroBits;
|
|
758
|
+
/**
|
|
759
|
+
* What the worker runs: the kernel, rebuilt from its own text, searching from
|
|
760
|
+
* zero until it finds a nonce. Built as a string so that no bundler has to be
|
|
761
|
+
* told about a worker file.
|
|
762
|
+
*/
|
|
763
|
+
export function proofWorkerSource() {
|
|
764
|
+
return (`const kernel = (${proofKernel.toString()})();\n` +
|
|
765
|
+
'self.onmessage = (event) => {\n' +
|
|
766
|
+
' const { salt, difficulty } = event.data;\n' +
|
|
767
|
+
' self.postMessage(kernel.search(salt, difficulty, 0, Number.MAX_SAFE_INTEGER));\n' +
|
|
768
|
+
'};\n');
|
|
769
|
+
}
|
|
770
|
+
/** Attempts between yields on the main thread: a few milliseconds of work on a phone. */
|
|
771
|
+
const CHUNK = 2_000;
|
|
772
|
+
/** The search off the main thread, or null where there is no worker to be had. */
|
|
773
|
+
function solveInWorker(challenge) {
|
|
774
|
+
if (typeof Worker !== 'function' || typeof Blob !== 'function' || typeof URL.createObjectURL !== 'function') {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
let url = null;
|
|
778
|
+
let worker;
|
|
779
|
+
try {
|
|
780
|
+
url = URL.createObjectURL(new Blob([proofWorkerSource()], { type: 'text/javascript' }));
|
|
781
|
+
worker = new Worker(url);
|
|
782
|
+
}
|
|
783
|
+
catch {
|
|
784
|
+
// A page whose CSP refuses `blob:` workers throws here, in some browsers.
|
|
785
|
+
if (url !== null)
|
|
786
|
+
URL.revokeObjectURL(url);
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
const done = () => {
|
|
790
|
+
worker.terminate();
|
|
791
|
+
if (url !== null)
|
|
792
|
+
URL.revokeObjectURL(url);
|
|
793
|
+
};
|
|
794
|
+
return new Promise((resolve, reject) => {
|
|
795
|
+
worker.onmessage = (event) => {
|
|
796
|
+
done();
|
|
797
|
+
resolve(String(event.data));
|
|
798
|
+
};
|
|
799
|
+
// …and fires this instead, in others.
|
|
800
|
+
worker.onerror = (event) => {
|
|
801
|
+
event.preventDefault();
|
|
802
|
+
done();
|
|
803
|
+
reject(new Error('the proof worker could not run'));
|
|
804
|
+
};
|
|
805
|
+
worker.postMessage({ salt: challenge.salt, difficulty: challenge.difficulty });
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Find the nonce a challenge asks for.
|
|
810
|
+
*
|
|
811
|
+
* In a Web Worker where there is one, so the page stays responsive through
|
|
812
|
+
* the second a cheap phone spends on it. Where there is none — a test, a
|
|
813
|
+
* server render, a CSP that refuses `blob:` workers — on this thread, in
|
|
814
|
+
* small chunks that yield between them, so a click still lands meanwhile.
|
|
815
|
+
*/
|
|
816
|
+
export async function solveChallenge(challenge) {
|
|
817
|
+
const offThread = solveInWorker(challenge);
|
|
818
|
+
if (offThread !== null) {
|
|
819
|
+
try {
|
|
820
|
+
return await offThread;
|
|
821
|
+
}
|
|
822
|
+
catch {
|
|
823
|
+
/* the worker would not run — do the work here instead */
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
for (let start = 0;; start += CHUNK) {
|
|
827
|
+
const found = kernel.search(challenge.salt, challenge.difficulty, start, CHUNK);
|
|
828
|
+
if (found !== null)
|
|
829
|
+
return found;
|
|
830
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
831
|
+
}
|
|
832
|
+
}
|
|
401
833
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,4EAA4E;AAE5E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,qBAAqB;IACrB,oBAAoB;IACpB,sBAAsB;IACtB,2BAA2B;IAC3B,sBAAsB;IACtB,qBAAqB;IACrB,uBAAuB;IACvB,uBAAuB;IACvB,0BAA0B;IAC1B,sBAAsB;IACtB;;;OAGG;IACH,uBAAuB;IACvB,6BAA6B;IAC7B,uDAAuD;IACvD,4BAA4B;CACpB,CAAC;AAGX;;;;;;;GAOG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,IAAI,CAAkB;IACtB,MAAM,CAAS;IACf,iBAAiB,CAAgB;IAE1C,YAAY,IAAqB,EAAE,MAAc,EAAE,OAAe,EAAE,iBAA0B;QAC5F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,G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