rapier-html 1.1.0 → 1.1.2

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.
@@ -0,0 +1,17 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Shared by the writer and carried-page boot: a file can only return to this worker's one-use route.
3
+ export const RETURN_ORIGIN = 'https://mcp.rapier.website';
4
+ export function returnAddress(value) {
5
+ if (typeof value !== 'string' || /[\s\u0000-\u001f\u007f-\u009f\\@?#]/u.test(value))
6
+ throw new Error('the return address must be an HTTPS return URL on ' + RETURN_ORIGIN);
7
+ let url;
8
+ try { url = new URL(value); } catch { throw new Error('the return address must be an HTTPS return URL on ' + RETURN_ORIGIN); }
9
+ if (url.origin !== RETURN_ORIGIN || !/^\/return\/[A-Za-z0-9._-]{1,256}$/.test(url.pathname))
10
+ throw new Error('the return address must be an HTTPS return URL on ' + RETURN_ORIGIN);
11
+ return url.href;
12
+ }
13
+ export function returnExpiresAt(value) {
14
+ if (typeof value !== 'string' || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(value) || !Number.isFinite(Date.parse(value)) || new Date(value).toISOString() !== value)
15
+ throw new Error('the return expiry must be the ISO timestamp from document.create_return');
16
+ return value;
17
+ }