pups-client 0.0.0-stage → 0.2.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.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +163 -2
  3. package/dist/cli/bin.d.ts +3 -0
  4. package/dist/cli/bin.d.ts.map +1 -0
  5. package/dist/cli/bin.js +4 -0
  6. package/dist/cli/bin.js.map +1 -0
  7. package/dist/cli/file-store.d.ts +21 -0
  8. package/dist/cli/file-store.d.ts.map +1 -0
  9. package/dist/cli/file-store.js +59 -0
  10. package/dist/cli/file-store.js.map +1 -0
  11. package/dist/cli/loopback.d.ts +28 -0
  12. package/dist/cli/loopback.d.ts.map +1 -0
  13. package/dist/cli/loopback.js +82 -0
  14. package/dist/cli/loopback.js.map +1 -0
  15. package/dist/cli/main.d.ts +16 -0
  16. package/dist/cli/main.d.ts.map +1 -0
  17. package/dist/cli/main.js +337 -0
  18. package/dist/cli/main.js.map +1 -0
  19. package/dist/client.d.ts +151 -0
  20. package/dist/client.d.ts.map +1 -0
  21. package/dist/client.js +427 -0
  22. package/dist/client.js.map +1 -0
  23. package/dist/discovery.d.ts +58 -0
  24. package/dist/discovery.d.ts.map +1 -0
  25. package/dist/discovery.js +138 -0
  26. package/dist/discovery.js.map +1 -0
  27. package/dist/errors.d.ts +77 -0
  28. package/dist/errors.d.ts.map +1 -0
  29. package/dist/errors.js +59 -0
  30. package/dist/errors.js.map +1 -0
  31. package/dist/feed.d.ts +314 -0
  32. package/dist/feed.d.ts.map +1 -0
  33. package/dist/feed.js +805 -0
  34. package/dist/feed.js.map +1 -0
  35. package/dist/file-types.d.ts +30 -0
  36. package/dist/file-types.d.ts.map +1 -0
  37. package/dist/file-types.js +67 -0
  38. package/dist/file-types.js.map +1 -0
  39. package/dist/host-meta.d.ts +71 -0
  40. package/dist/host-meta.d.ts.map +1 -0
  41. package/dist/host-meta.js +122 -0
  42. package/dist/host-meta.js.map +1 -0
  43. package/dist/index.d.ts +25 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +16 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/oauth.d.ts +54 -0
  48. package/dist/oauth.d.ts.map +1 -0
  49. package/dist/oauth.js +124 -0
  50. package/dist/oauth.js.map +1 -0
  51. package/dist/paths.d.ts +32 -0
  52. package/dist/paths.d.ts.map +1 -0
  53. package/dist/paths.js +91 -0
  54. package/dist/paths.js.map +1 -0
  55. package/dist/scopes.d.ts +28 -0
  56. package/dist/scopes.d.ts.map +1 -0
  57. package/dist/scopes.js +56 -0
  58. package/dist/scopes.js.map +1 -0
  59. package/dist/session.d.ts +194 -0
  60. package/dist/session.d.ts.map +1 -0
  61. package/dist/session.js +317 -0
  62. package/dist/session.js.map +1 -0
  63. package/dist/store/indexeddb-store.d.ts +23 -0
  64. package/dist/store/indexeddb-store.d.ts.map +1 -0
  65. package/dist/store/indexeddb-store.js +116 -0
  66. package/dist/store/indexeddb-store.js.map +1 -0
  67. package/dist/store/memory-store.d.ts +13 -0
  68. package/dist/store/memory-store.d.ts.map +1 -0
  69. package/dist/store/memory-store.js +22 -0
  70. package/dist/store/memory-store.js.map +1 -0
  71. package/dist/store/token-store.d.ts +35 -0
  72. package/dist/store/token-store.d.ts.map +1 -0
  73. package/dist/store/token-store.js +2 -0
  74. package/dist/store/token-store.js.map +1 -0
  75. package/dist/tabs.d.ts +29 -0
  76. package/dist/tabs.d.ts.map +1 -0
  77. package/dist/tabs.js +51 -0
  78. package/dist/tabs.js.map +1 -0
  79. package/dist/tokens.d.ts +59 -0
  80. package/dist/tokens.d.ts.map +1 -0
  81. package/dist/tokens.js +200 -0
  82. package/dist/tokens.js.map +1 -0
  83. package/dist/util.d.ts +23 -0
  84. package/dist/util.d.ts.map +1 -0
  85. package/dist/util.js +109 -0
  86. package/dist/util.js.map +1 -0
  87. package/dist/version.d.ts +2 -0
  88. package/dist/version.d.ts.map +1 -0
  89. package/dist/version.js +2 -0
  90. package/dist/version.js.map +1 -0
  91. package/package.json +55 -4
  92. package/src/cli/bin.ts +4 -0
  93. package/src/cli/file-store.ts +66 -0
  94. package/src/cli/loopback.ts +103 -0
  95. package/src/cli/main.ts +329 -0
  96. package/src/client.ts +496 -0
  97. package/src/discovery.ts +178 -0
  98. package/src/errors.ts +136 -0
  99. package/src/feed.ts +1007 -0
  100. package/src/file-types.ts +80 -0
  101. package/src/host-meta.ts +148 -0
  102. package/src/index.ts +49 -0
  103. package/src/oauth.ts +163 -0
  104. package/src/paths.ts +92 -0
  105. package/src/scopes.ts +68 -0
  106. package/src/session.ts +396 -0
  107. package/src/store/indexeddb-store.ts +140 -0
  108. package/src/store/memory-store.ts +28 -0
  109. package/src/store/token-store.ts +36 -0
  110. package/src/tabs.ts +61 -0
  111. package/src/tokens.ts +208 -0
  112. package/src/util.ts +118 -0
  113. package/src/version.ts +1 -0
@@ -0,0 +1,138 @@
1
+ import { PupsError } from './errors.js';
2
+ import { fetchWithTimeout, parseUrl } from './util.js';
3
+ /** The link relation in `host-meta.json` that points to the PUPS configuration document. A placeholder in RFC-6 0.1. */
4
+ export const PUPS_REL = 'https://bigwide.net/ns/personal-storage';
5
+ /** The `spec_version` values this library implements. */
6
+ export const SUPPORTED_SPEC_VERSIONS = ['0.1'];
7
+ const discoveryTimeoutMs = 10_000;
8
+ /**
9
+ * Normalizes what the user typed (`tim.example.com`, `https://tim.example.com/some/page`) to `https://<host>/`,
10
+ * as RFC-6 "Starting point" requires: HTTPS, lowercase host, IDNs in ASCII form, no port, path, query or fragment.
11
+ * @throws {PupsError} `invalid_domain`
12
+ */
13
+ export function normalizeDomain(input) {
14
+ const trimmed = input.trim();
15
+ const url = parseUrl(/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`);
16
+ if (!url || (url.protocol != 'https:' && url.protocol != 'http:') || !url.hostname)
17
+ throw new PupsError('invalid_domain', `"${input}" is not a domain name. Enter something like "example.com".`);
18
+ // The URL parser lowercases the host and converts IDNs to punycode.
19
+ const host = url.hostname.replace(/\.$/, '');
20
+ if (!host.includes('.') && !host.startsWith('['))
21
+ throw new PupsError('invalid_domain', `"${input}" is not a full domain name. Enter something like "example.com".`);
22
+ return `https://${host}/`;
23
+ }
24
+ async function fetchJson(fetchFn, url, signal, notFound) {
25
+ const response = await fetchWithTimeout(fetchFn, url, {
26
+ headers: { Accept: 'application/json' },
27
+ credentials: 'omit',
28
+ redirect: 'follow',
29
+ cache: 'no-cache',
30
+ }, discoveryTimeoutMs, signal);
31
+ // Browsers follow redirects without exposing the chain; at least the final URL must be HTTPS.
32
+ if (response.url && !response.url.startsWith('https://'))
33
+ throw new PupsError('no_pups_server', `${url} redirected to a non-HTTPS URL.`);
34
+ if (!response.ok)
35
+ throw notFound();
36
+ try {
37
+ return { json: await response.json(), finalUrl: response.url || url };
38
+ }
39
+ catch {
40
+ throw notFound();
41
+ }
42
+ }
43
+ /**
44
+ * Discovers the PUPS server of a domain (RFC-6 "Discovery"): fetches `/.well-known/host-meta.json`, follows the
45
+ * PUPS link, and validates the configuration document.
46
+ */
47
+ export async function discover(domain, fetchFn, signal) {
48
+ const normalized = normalizeDomain(domain);
49
+ const hostMetaUrl = `${normalized}.well-known/host-meta.json`;
50
+ const noServer = () => new PupsError('no_pups_server', `${new URL(normalized).host} has no Personal Upload Server: ${hostMetaUrl} is missing, not readable from the browser, or has no PUPS link.`);
51
+ const hostMeta = await fetchJson(fetchFn, hostMetaUrl, signal, noServer);
52
+ const links = hostMeta.json?.links;
53
+ const link = Array.isArray(links)
54
+ ? links.find((l) => l && l.rel == PUPS_REL)
55
+ : undefined;
56
+ const configUrl = parseUrl(link?.href);
57
+ if (!configUrl)
58
+ throw noServer();
59
+ if (configUrl.protocol != 'https:')
60
+ throw new PupsError('invalid_server_config', `The PUPS link in ${hostMetaUrl} must be an HTTPS URL.`);
61
+ const config = await fetchJson(fetchFn, configUrl.href, signal, () => new PupsError('invalid_server_config', `The PUPS configuration document ${configUrl.href} can't be read.`));
62
+ const identityHosts = [new URL(normalized).hostname];
63
+ const finalHost = new URL(hostMeta.finalUrl).hostname;
64
+ if (!identityHosts.includes(finalHost))
65
+ identityHosts.push(finalHost);
66
+ return parseConfig(config.json, normalized, identityHosts);
67
+ }
68
+ /**
69
+ * Validates a configuration document (RFC-6 "Configuration document"). Unknown fields are kept in `raw` and
70
+ * otherwise ignored.
71
+ * @throws {PupsError} `invalid_server_config`, `unsupported_server_version`
72
+ */
73
+ export function parseConfig(json, domain, identityHosts) {
74
+ if (!json || typeof json != 'object' || Array.isArray(json))
75
+ throw new PupsError('invalid_server_config', 'The PUPS configuration document is not a JSON object.');
76
+ const raw = json;
77
+ const fail = (field, problem) => {
78
+ throw new PupsError('invalid_server_config', `PUPS configuration: "${field}" ${problem}.`);
79
+ };
80
+ const https = (field, value = raw[field]) => {
81
+ const url = parseUrl(value);
82
+ if (!url || url.protocol != 'https:' || url.hash)
83
+ return fail(field, 'must be an HTTPS URL without fragment');
84
+ return value;
85
+ };
86
+ const optionalHttps = (field) => raw[field] === undefined ? undefined : https(field);
87
+ const base = (field) => https(field).endsWith('/') ? raw[field] : fail(field, 'must end with "/"');
88
+ const strings = (field, value) => Array.isArray(value) && value.every(v => typeof v == 'string') ? value : fail(field, 'must be an array of strings');
89
+ const specVersion = typeof raw.spec_version == 'string' ? raw.spec_version : fail('spec_version', 'is missing');
90
+ if (!SUPPORTED_SPEC_VERSIONS.includes(specVersion))
91
+ throw new PupsError('unsupported_server_version', `The server implements PUPS ${specVersion}; this library supports ${SUPPORTED_SPEC_VERSIONS.join(', ')}.`);
92
+ const issuer = https('issuer');
93
+ if (new URL(issuer).search)
94
+ fail('issuer', 'must not have a query');
95
+ const maxUploadBytes = raw.max_upload_bytes;
96
+ if (typeof maxUploadBytes != 'number' || !Number.isSafeInteger(maxUploadBytes) || maxUploadBytes <= 0)
97
+ fail('max_upload_bytes', 'must be a positive integer');
98
+ const wellKnownRaw = raw.well_known_paths ?? [];
99
+ if (!Array.isArray(wellKnownRaw))
100
+ fail('well_known_paths', 'must be an array');
101
+ const wellKnownPaths = wellKnownRaw.map((entry, i) => {
102
+ const field = `well_known_paths[${i}]`;
103
+ if (!entry || typeof entry != 'object')
104
+ return fail(field, 'must be an object');
105
+ const e = entry;
106
+ if (typeof e.path != 'string' || !e.path.startsWith('/'))
107
+ return fail(`${field}.path`, 'must start with "/"');
108
+ const url = e.url === undefined ? undefined : https(`${field}.url`, e.url);
109
+ if (url && e.path.endsWith('/') && !url.endsWith('/'))
110
+ fail(`${field}.url`, 'must end with "/" for a directory');
111
+ return {
112
+ path: e.path,
113
+ ...url ? { url } : {},
114
+ rels: e.rels === undefined ? [] : strings(`${field}.rels`, e.rels),
115
+ properties: e.properties === undefined ? [] : strings(`${field}.properties`, e.properties),
116
+ };
117
+ });
118
+ const hostMetaEndpoint = optionalHttps('host_meta_endpoint');
119
+ const postEndpoint = optionalHttps('post_endpoint');
120
+ return {
121
+ domain,
122
+ identityHosts,
123
+ issuer,
124
+ authorizationEndpoint: https('authorization_endpoint'),
125
+ tokenEndpoint: https('token_endpoint'),
126
+ revocationEndpoint: https('revocation_endpoint'),
127
+ storageBase: base('storage_base'),
128
+ publicBase: base('public_base'),
129
+ scopesSupported: strings('scopes_supported', raw.scopes_supported),
130
+ wellKnownPaths,
131
+ ...hostMetaEndpoint ? { hostMetaEndpoint } : {},
132
+ ...postEndpoint ? { postEndpoint } : {},
133
+ maxUploadBytes: maxUploadBytes,
134
+ specVersion,
135
+ raw,
136
+ };
137
+ }
138
+ //# sourceMappingURL=discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEtD,wHAAwH;AACxH,MAAM,CAAC,MAAM,QAAQ,GAAG,yCAAyC,CAAA;AAEjE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AAC,CAAC,EAAE;QAC/C,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE;QACvC,cAAc,EAAE,cAAwB;QACxC,WAAW;QACX,GAAG;KACJ,CAAA;AACH,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Error codes of {@link PupsError}.
3
+ *
4
+ * Codes of the upload API are the `error` values of RFC-6 ("Errors"), so apps can switch on them directly.
5
+ * Problems the library detects before sending a request use the same codes the server would answer with.
6
+ */
7
+ export type PupsErrorCode =
8
+ /** The domain the user typed can't be turned into `https://<host>/`. */
9
+ 'invalid_domain'
10
+ /** The domain has no `host-meta.json` with a PUPS link, or it can't be fetched. */
11
+ | 'no_pups_server'
12
+ /** The configuration document is missing required fields or has invalid values. */
13
+ | 'invalid_server_config'
14
+ /** The server implements a `spec_version` this library doesn't support. */
15
+ | 'unsupported_server_version'
16
+ /** A requested scope is not allowed by the server or for this client. */
17
+ | 'invalid_scope'
18
+ /** The owner denied the request, or dropped every scope. */
19
+ | 'access_denied'
20
+ /** The authorization response doesn't belong to a request started by this app in this browser. */
21
+ | 'state_mismatch'
22
+ /** The `iss` of the authorization response is not the discovered issuer (mix-up defence, RFC 9207). */
23
+ | 'issuer_mismatch'
24
+ /** The `me` of the token response is not the domain the user entered, and doesn't lead to the same issuer. */
25
+ | 'identity_mismatch'
26
+ /** The browser blocked the login popup. Fall back to `login()`. */
27
+ | 'popup_blocked'
28
+ /** The popup flow didn't finish in time. */
29
+ | 'popup_timeout'
30
+ /** Any other failure of the authorization or the code exchange. */
31
+ | 'authorization_failed'
32
+ /** The session ended: the grant was revoked, the refresh token expired, or the user logged out. Log in again. */
33
+ | 'session_expired' | 'invalid_path' | 'invalid_token' | 'insufficient_scope' | 'not_found' | 'precondition_failed' | 'too_large' | 'unsupported_type' | 'insufficient_storage'
34
+ /** A feed file or archive has no `_pups.pupsControlled` marker: it is maintained by other means and never written. */
35
+ | 'not_pups_controlled'
36
+ /** A feed file or archive is not a JSON Feed. */
37
+ | 'invalid_feed'
38
+ /** `409` from the host-meta endpoint: a single-valued rel is taken, or `host-meta.json` is not valid JSON. */
39
+ | 'conflict'
40
+ /** `429`: the server limits the write rate of this grant. See {@link PupsError.retryAfter}. */
41
+ | 'rate_limited'
42
+ /** `400` for a reason other than the path, or an argument the library can't send. */
43
+ | 'invalid_request'
44
+ /** The server doesn't offer the feature, e.g. no `host_meta_endpoint`. */
45
+ | 'unsupported'
46
+ /** The request couldn't be sent, or timed out. */
47
+ | 'network'
48
+ /** The caller aborted the operation with an `AbortSignal`. */
49
+ | 'aborted'
50
+ /** The server answered with an unexpected status, usually `5xx`. */
51
+ | 'server_error';
52
+ export interface PupsErrorOptions {
53
+ status?: number;
54
+ serverMessage?: string;
55
+ retryAfter?: number;
56
+ cause?: unknown;
57
+ }
58
+ /** The only error type thrown by pups-client. */
59
+ export declare class PupsError extends Error {
60
+ readonly name = "PupsError";
61
+ /** What went wrong, see {@link PupsErrorCode}. */
62
+ readonly code: PupsErrorCode;
63
+ /** The HTTP status, if a response caused the error. */
64
+ readonly status?: number;
65
+ /** The `message` (or OAuth `error_description`) from the server's error body, if any. Not localized. */
66
+ readonly serverMessage?: string;
67
+ /** Seconds to wait before retrying, from a `Retry-After` header. */
68
+ readonly retryAfter?: number;
69
+ /** Whether repeating the same call later may succeed: network problems, `429` and `5xx` (except `507`). */
70
+ readonly retryable: boolean;
71
+ constructor(code: PupsErrorCode, message: string, options?: PupsErrorOptions);
72
+ }
73
+ /** Whether `e` is a {@link PupsError}, optionally with one of the given codes. */
74
+ export declare const isPupsError: (e: unknown, ...codes: PupsErrorCode[]) => e is PupsError;
75
+ /** Turns an error response of the upload API or the host-meta endpoint into a {@link PupsError} (RFC-6 "Errors"). */
76
+ export declare function errorFromResponse(response: Response, what: string): Promise<PupsError>;
77
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/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EAAoE;IACpE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,2GAA2G;IAC3G,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;gBAEf,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB;CAQjF;AAED,kFAAkF;AAClF,eAAO,MAAM,WAAW,GAAI,GAAG,OAAO,EAAE,GAAG,OAAO,aAAa,EAAE,KAAG,CAAC,IAAI,SACJ,CAAA;AAcrE,qHAAqH;AACrH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAmB5F"}
package/dist/errors.js ADDED
@@ -0,0 +1,59 @@
1
+ const retryableCodes = new Set(['network', 'rate_limited', 'server_error']);
2
+ /** The only error type thrown by pups-client. */
3
+ export class PupsError extends Error {
4
+ name = 'PupsError';
5
+ /** What went wrong, see {@link PupsErrorCode}. */
6
+ code;
7
+ /** The HTTP status, if a response caused the error. */
8
+ status;
9
+ /** The `message` (or OAuth `error_description`) from the server's error body, if any. Not localized. */
10
+ serverMessage;
11
+ /** Seconds to wait before retrying, from a `Retry-After` header. */
12
+ retryAfter;
13
+ /** Whether repeating the same call later may succeed: network problems, `429` and `5xx` (except `507`). */
14
+ retryable;
15
+ constructor(code, message, options = {}) {
16
+ super(message, options.cause === undefined ? undefined : { cause: options.cause });
17
+ this.code = code;
18
+ this.status = options.status;
19
+ this.serverMessage = options.serverMessage;
20
+ this.retryAfter = options.retryAfter;
21
+ this.retryable = retryableCodes.has(code);
22
+ }
23
+ }
24
+ /** Whether `e` is a {@link PupsError}, optionally with one of the given codes. */
25
+ export const isPupsError = (e, ...codes) => e instanceof PupsError && (!codes.length || codes.includes(e.code));
26
+ const statusCodes = {
27
+ 401: 'invalid_token',
28
+ 403: 'insufficient_scope',
29
+ 404: 'not_found',
30
+ 409: 'conflict',
31
+ 412: 'precondition_failed',
32
+ 413: 'too_large',
33
+ 415: 'unsupported_type',
34
+ 429: 'rate_limited',
35
+ 507: 'insufficient_storage',
36
+ };
37
+ /** Turns an error response of the upload API or the host-meta endpoint into a {@link PupsError} (RFC-6 "Errors"). */
38
+ export async function errorFromResponse(response, what) {
39
+ let body = {};
40
+ try {
41
+ body = await response.json();
42
+ }
43
+ catch {
44
+ // Not every error comes from PUPS itself (proxies, WAFs), so a missing JSON body is normal.
45
+ }
46
+ const status = response.status;
47
+ const serverError = typeof body.error == 'string' ? body.error : undefined;
48
+ const serverMessage = typeof body.message == 'string' ? body.message : undefined;
49
+ const code = status == 400
50
+ ? serverError == 'invalid_path' ? 'invalid_path' : 'invalid_request'
51
+ : statusCodes[status] ?? 'server_error';
52
+ const retryAfterHeader = Number(response.headers.get('Retry-After'));
53
+ return new PupsError(code, `${what} failed with HTTP ${status}${serverMessage ? `: ${serverMessage}` : ''}`, {
54
+ status,
55
+ serverMessage,
56
+ retryAfter: retryAfterHeader > 0 ? retryAfterHeader : undefined,
57
+ });
58
+ }
59
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAkEA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;AAS1F,iDAAiD;AACjD,MAAM,OAAO,SAAU,SAAQ,KAAK;IAChB,IAAI,GAAG,WAAW,CAAA;IACpC,kDAAkD;IACzC,IAAI,CAAe;IAC5B,uDAAuD;IAC9C,MAAM,CAAS;IACxB,wGAAwG;IAC/F,aAAa,CAAS;IAC/B,oEAAoE;IAC3D,UAAU,CAAS;IAC5B,2GAA2G;IAClG,SAAS,CAAS;IAE3B,YAAY,IAAmB,EAAE,OAAe,EAAE,UAA4B,EAAE;QAC9E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAA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AAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IAC1E,MAAM,aAAa,GAAG,OAAO,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;IAChF,MAAM,IAAI,GAAkB,MAAM,IAAI,GAAG;QACvC,CAAC,CAAC,WAAW,IAAI,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,iBAAiB;QACpE,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,cAAc,CAAA;IACzC,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAA;IACpE,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,GAAG,IAAI,qBAAqB,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE;QAC3G,MAAM;QACN,aAAa;QACb,UAAU,EAAE,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;KAChE,CAAC,CAAA;AACJ,CAAC"}
package/dist/feed.d.ts ADDED
@@ -0,0 +1,314 @@
1
+ import type { Scope } from './scopes.js';
2
+ import type { Body, PupsSession } from './session.js';
3
+ /** The link relation that registers a feed in `host-meta.json` (RFC-7). A placeholder in RFC-7. */
4
+ export declare const FEED_REL = "https://bigwide.net/ns/feed";
5
+ /** The `about` of the `_pups` object: RFC-7. Not its final location; readers must not rely on it. */
6
+ export declare const PUPS_FEED_SPEC = "https://github.com/bigwide-net/RFCs/blob/main/RFC-7-Feed-Publishing-with-PUPS.md";
7
+ export interface FeedAuthor {
8
+ name?: string;
9
+ url?: string;
10
+ avatar?: string;
11
+ [field: string]: unknown;
12
+ }
13
+ export interface FeedAttachment {
14
+ url: string;
15
+ mime_type: string;
16
+ title?: string;
17
+ size_in_bytes?: number;
18
+ duration_in_seconds?: number;
19
+ [field: string]: unknown;
20
+ }
21
+ /** A JSON Feed 1.1 item. */
22
+ export interface FeedItem {
23
+ id: string;
24
+ url?: string;
25
+ external_url?: string;
26
+ title?: string;
27
+ content_html?: string;
28
+ content_text?: string;
29
+ summary?: string;
30
+ image?: string;
31
+ banner_image?: string;
32
+ date_published?: string;
33
+ date_modified?: string;
34
+ authors?: FeedAuthor[];
35
+ tags?: string[];
36
+ language?: string;
37
+ attachments?: FeedAttachment[];
38
+ [field: string]: unknown;
39
+ }
40
+ /** The `_pups` object of a feed file or archive. */
41
+ export interface PupsMarker {
42
+ about?: string;
43
+ pupsControlled?: boolean;
44
+ /** In the feed file: the public URL of the newest archive. */
45
+ archive_url?: string;
46
+ /** In an archive: the public URL of the feed file, which readers poll. */
47
+ updates_url?: string;
48
+ [field: string]: unknown;
49
+ }
50
+ /** A JSON Feed 1.1 document, as stored in a feed file or archive. */
51
+ export interface FeedDocument {
52
+ version: string;
53
+ title: string;
54
+ home_page_url?: string;
55
+ feed_url?: string;
56
+ description?: string;
57
+ user_comment?: string;
58
+ next_url?: string;
59
+ icon?: string;
60
+ favicon?: string;
61
+ authors?: FeedAuthor[];
62
+ language?: string;
63
+ expired?: boolean;
64
+ hubs?: unknown[];
65
+ items: FeedItem[];
66
+ _pups?: PupsMarker;
67
+ [field: string]: unknown;
68
+ }
69
+ /**
70
+ * The fields of a feed that belong to the owner (RFC-7 "Fields"). Extensions such as `_podcast` (RFC-3) or
71
+ * `_source` (RFC-1) are allowed too. Icons are set with `setIcon()` and `setFavicon()`.
72
+ */
73
+ export interface FeedSettings {
74
+ title?: string;
75
+ description?: string;
76
+ authors?: FeedAuthor[];
77
+ language?: string;
78
+ expired?: boolean;
79
+ [extension: `_${string}`]: unknown;
80
+ }
81
+ /** Changes to the settings: a value sets the field, `null` removes it, `undefined` leaves it unchanged. */
82
+ export type FeedSettingsChanges = {
83
+ [K in keyof FeedSettings]?: FeedSettings[K] | null;
84
+ };
85
+ /**
86
+ * An image, audio or video file to upload: a `Blob` (or `File`) with a type or name, or a body with its type or
87
+ * extension. The extension must be on the RFC-6 allowlist.
88
+ */
89
+ export type MediaInput = Blob | {
90
+ body: Body;
91
+ type?: string;
92
+ extension?: string;
93
+ };
94
+ /** The settings of a new feed. */
95
+ export interface FeedSetup extends FeedSettings {
96
+ title: string;
97
+ /** 512 × 512 pixels, stored in `images/icons/` in the feed directory. */
98
+ icon?: MediaInput;
99
+ /** 64 × 64 pixels, stored in `images/icons/` in the feed directory. */
100
+ favicon?: MediaInput;
101
+ }
102
+ /** A new post: a JSON Feed item without `id` (generated unless given) and with a few conveniences. */
103
+ export interface PostInput {
104
+ /** Generated if missing: 16 random URL-safe characters. Must be unique across the feed and its archives. */
105
+ id?: string;
106
+ title?: string;
107
+ content_html?: string;
108
+ content_text?: string;
109
+ /**
110
+ * The text as Markdown, stored in `_source.markdown` (RFC-1). If neither `content_html` nor `content_text` is
111
+ * given, the Markdown is also used as `content_text`, since JSON Feed requires one of them.
112
+ */
113
+ markdown?: string;
114
+ summary?: string;
115
+ url?: string;
116
+ external_url?: string;
117
+ image?: string;
118
+ banner_image?: string;
119
+ /** Default: now. */
120
+ date_published?: string | Date;
121
+ authors?: FeedAuthor[];
122
+ tags?: string[];
123
+ language?: string;
124
+ attachments?: FeedAttachment[];
125
+ [extension: `_${string}`]: unknown;
126
+ }
127
+ /** Changes to a post: a value sets the field, `null` removes it, `undefined` leaves it unchanged. */
128
+ export type PostChanges = {
129
+ [K in Exclude<keyof PostInput, 'id'>]?: PostInput[K] | null;
130
+ };
131
+ export interface PostResult {
132
+ id: string;
133
+ /** The item as stored. */
134
+ item: FeedItem;
135
+ /**
136
+ * The URL of the item's archive plus `#<id>`. Items never leave their archive, so it never changes; use it e.g.
137
+ * as the `source` of an RFC-4 webmention. In a feed without archives, the feed file's URL plus `#<id>`.
138
+ */
139
+ url: string;
140
+ }
141
+ export interface MediaResult {
142
+ path: string;
143
+ /** The public URL, to reference from items. */
144
+ url: string;
145
+ /** The served type, e.g. for `attachments[].mime_type`. */
146
+ type: string;
147
+ size: number;
148
+ }
149
+ export type FeedState =
150
+ /** There is no feed file yet. `create()` sets it up. */
151
+ {
152
+ status: 'missing';
153
+ }
154
+ /** A feed maintained by PUPS clients, ready to write. */
155
+ | {
156
+ status: 'pups';
157
+ feed: FeedDocument;
158
+ etag: string;
159
+ }
160
+ /** A JSON Feed without `_pups.pupsControlled`: maintained by other means, and never written (RFC-7). */
161
+ | {
162
+ status: 'foreign';
163
+ feed: FeedDocument;
164
+ }
165
+ /** The file exists but is not a JSON Feed. */
166
+ | {
167
+ status: 'invalid';
168
+ };
169
+ export interface FeedOptions {
170
+ /** How many of the newest items the feed file holds. Default 30 (RFC-7 "Feed size"). */
171
+ maxItems?: number;
172
+ /** How many items an archive holds. Default 20 (RFC-7 "Archives"); other clients expect 20. */
173
+ archiveSize?: number;
174
+ /**
175
+ * Whether to start archives for a feed that has none, on its next post (RFC-7 "Starting the archives").
176
+ * Default true. With false, posts to such a feed only go into the feed file, and items beyond `maxItems` are
177
+ * dropped. Feeds that have archives always keep them.
178
+ */
179
+ startArchives?: boolean;
180
+ /**
181
+ * Optional: keep fewer items in the feed file when it would be larger than this many bytes, but at least 10
182
+ * (RFC-7 "Size in bytes").
183
+ */
184
+ maxBytes?: number;
185
+ /** How often an operation is repeated when another client changed the feed in between. Default 8. */
186
+ maxAttempts?: number;
187
+ }
188
+ /** A feed registered in `host-meta.json`. */
189
+ export interface FeedLink {
190
+ /** The public URL of the feed file. */
191
+ url: string;
192
+ type?: string;
193
+ /** Set if the feed is a main or named feed on this PUPS server, in the layout of RFC-7. */
194
+ feed?: PupsFeed;
195
+ }
196
+ type Signal = {
197
+ signal?: AbortSignal;
198
+ };
199
+ /** The scopes an app needs to write a feed: the feed file and the feed directory (RFC-7 "Server requirements"). */
200
+ export declare function feedScopes(name?: string): Scope[];
201
+ /**
202
+ * A feed on the owner's domain, maintained according to RFC-7: the main feed `/feed.json`, or a named feed
203
+ * `/feed/<name>.json`, each with its feed directory for archives, icons and media: `/feed/`, or `/feed/<name>/`.
204
+ * The main feed keeps its media in `/feed/images/` and `/feed/media/`, since the rest of `/feed/` belongs to the
205
+ * named feeds.
206
+ *
207
+ * Get one from `session.feed()` or `session.feed('photos')`. The session needs the feed's scopes, see
208
+ * {@link feedScopes}. All writes are safe against concurrent changes by other apps and the owner: they are
209
+ * read-modify-write cycles with ETags, repeated when another client wrote in between.
210
+ */
211
+ export declare class PupsFeed {
212
+ #private;
213
+ /** The name of a named feed; undefined for the main feed. */
214
+ readonly name?: string;
215
+ /** The feed file, e.g. `/feed.json` or `/feed/photos.json`. */
216
+ readonly path: string;
217
+ /** The feed directory, e.g. `/feed/` or `/feed/photos/`. */
218
+ readonly directory: string;
219
+ /** @internal Use `session.feed()`. */
220
+ constructor(session: PupsSession, name?: string, options?: FeedOptions);
221
+ /** The public URL of the feed file, its `feed_url`. */
222
+ get url(): string;
223
+ /** The scopes needed to write this feed. */
224
+ get scopes(): Scope[];
225
+ /** Whether the session may write the feed file and the feed directory. */
226
+ get writable(): boolean;
227
+ /** Reads the feed file and tells whether it exists, and whether PUPS clients may write it. */
228
+ load(options?: Signal): Promise<FeedState>;
229
+ /**
230
+ * Sets up a new feed (RFC-7 "Setting up a feed"): uploads the icons, writes the feed file with the fixed fields
231
+ * and the `_pups` marker, and registers the feed in `host-meta.json` (unless `register` is false).
232
+ * @returns `registered`: false if the feed couldn't be registered; call `register()` again later, or tell the owner
233
+ * to add the link to `host-meta.json` by hand.
234
+ * @throws {PupsError} `precondition_failed` if the feed file exists already; `insufficient_scope`.
235
+ */
236
+ create(setup: FeedSetup, options?: Signal & {
237
+ register?: boolean;
238
+ }): Promise<{
239
+ url: string;
240
+ registered: boolean;
241
+ }>;
242
+ /**
243
+ * Registers the feed in `host-meta.json` (RFC-7 "Registering feeds"), unless a link with the feed relation and
244
+ * this feed's URL exists already.
245
+ * @returns false if the server has no host-meta endpoint, or doesn't allow the feed relation for this path.
246
+ */
247
+ register(options?: Signal): Promise<boolean>;
248
+ /**
249
+ * Changes the owner's fields of the feed (RFC-7 "Editing a feed"): a value sets a field, `null` removes it.
250
+ * @returns the feed as written.
251
+ */
252
+ updateSettings(changes: FeedSettingsChanges, options?: Signal): Promise<FeedDocument>;
253
+ /**
254
+ * Uploads a new icon (512 × 512) to `/feed/images/icons/` (`/feed/<name>/images/icons/` for a named feed) and
255
+ * deletes the old one, or removes it with `null`.
256
+ */
257
+ setIcon(media: MediaInput | null, options?: Signal): Promise<FeedDocument>;
258
+ /** Uploads a new favicon (64 × 64) to the icons directory, like `setIcon()`, or removes it with `null`. */
259
+ setFavicon(media: MediaInput | null, options?: Signal): Promise<FeedDocument>;
260
+ /**
261
+ * Uploads an image, audio or video file into the feed directory under a new, unique name, by default
262
+ * `images/<year>/…` for images and `media/<year>/…` for everything else. Reference it from a post by its `url`.
263
+ * For the main feed, `folder` must be inside `images/` or `media/`: the rest of `/feed/` belongs to named feeds.
264
+ */
265
+ uploadMedia(media: MediaInput, options?: Signal & {
266
+ folder?: string;
267
+ }): Promise<MediaResult>;
268
+ /**
269
+ * Adds a post (RFC-7 "Posting with archives"): first to the newest archive, or to a new archive once the newest
270
+ * holds `archiveSize` items, then to the top of the feed file, which keeps the newest `maxItems`. A feed without
271
+ * archives gets them now, unless `startArchives` is false; then the post only goes into the feed file. Upload
272
+ * media with `uploadMedia()` before posting.
273
+ * @returns the post, with `url`: its archive's URL plus `#<id>`, which never changes; for a feed without
274
+ * archives, the feed file's URL plus `#<id>`, valid while the post is among the newest.
275
+ */
276
+ addPost(input: PostInput, options?: Signal): Promise<PostResult>;
277
+ /**
278
+ * Finds a post by id in the archives (or, for a handed-over feed without archives yet, in the feed file).
279
+ * @returns undefined if there is no such post.
280
+ */
281
+ getPost(id: string, options?: Signal): Promise<PostResult | undefined>;
282
+ /**
283
+ * All posts, newest first: the archives from `_pups.archive_url` along `next_url` (for a feed without archives,
284
+ * the feed file and its `next_url` chain). Each post is returned once.
285
+ */
286
+ posts(options?: Signal): AsyncGenerator<FeedItem>;
287
+ /**
288
+ * Edits a post in its archive, and in the feed file if it is among the newest items (RFC-7 "Editing and deleting
289
+ * items"), and sets `date_modified`. `changes` is either an object (a value sets a field, `null` removes it), or
290
+ * a function that gets a copy of the item and returns the new item, or `undefined` to leave it unchanged. The
291
+ * function may run more than once.
292
+ *
293
+ * Apps should edit posts only when the owner asks them to, whichever app created them.
294
+ * @throws {PupsError} `not_found`
295
+ */
296
+ editPost(id: string, changes: PostChanges | ((item: FeedItem) => FeedItem | undefined | Promise<FeedItem | undefined>), options?: Signal): Promise<PostResult>;
297
+ /**
298
+ * Deletes a post from its archive and from the feed file, which is then filled up again with the newest items
299
+ * from the archives. With `deleteMedia`, it also deletes the files in the feed directory that the post references
300
+ * and no other post does; this reads all archives.
301
+ * @returns the deleted item, and the public URLs of the deleted media files.
302
+ * @throws {PupsError} `not_found`
303
+ */
304
+ deletePost(id: string, options?: Signal & {
305
+ deleteMedia?: boolean;
306
+ }): Promise<{
307
+ item: FeedItem;
308
+ deletedMedia: string[];
309
+ }>;
310
+ }
311
+ /** The feeds registered in the owner's `host-meta.json` (RFC-7 "Registering feeds"). */
312
+ export declare function listFeeds(session: PupsSession, options?: Signal & FeedOptions): Promise<FeedLink[]>;
313
+ export {};
314
+ //# sourceMappingURL=feed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAGrD,mGAAmG;AACnG,eAAO,MAAM,QAAQ,gCAAgC,CAAA;AAErD,qGAAqG;AACrG,eAAO,MAAM,cAAc,qFAAqF,CAAA;AAsBhH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAA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