@hatk/hatk 0.0.1-alpha.9 → 0.0.1-alpha.90
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/adapter.d.ts +19 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +113 -0
- package/dist/backfill.d.ts +29 -2
- package/dist/backfill.d.ts.map +1 -1
- package/dist/backfill.js +137 -51
- package/dist/car.d.ts +20 -0
- package/dist/car.d.ts.map +1 -1
- package/dist/car.js +108 -0
- package/dist/cli.js +247 -1043
- package/dist/config.d.ts +145 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +61 -8
- package/dist/database/adapter-factory.d.ts +6 -0
- package/dist/database/adapter-factory.d.ts.map +1 -0
- package/dist/database/adapter-factory.js +20 -0
- package/dist/database/adapters/duckdb-search.d.ts +12 -0
- package/dist/database/adapters/duckdb-search.d.ts.map +1 -0
- package/dist/database/adapters/duckdb-search.js +27 -0
- package/dist/database/adapters/duckdb.d.ts +25 -0
- package/dist/database/adapters/duckdb.d.ts.map +1 -0
- package/dist/database/adapters/duckdb.js +161 -0
- package/dist/database/adapters/sqlite-search.d.ts +16 -0
- package/dist/database/adapters/sqlite-search.d.ts.map +1 -0
- package/dist/database/adapters/sqlite-search.js +76 -0
- package/dist/database/adapters/sqlite.d.ts +18 -0
- package/dist/database/adapters/sqlite.d.ts.map +1 -0
- package/dist/database/adapters/sqlite.js +88 -0
- package/dist/{db.d.ts → database/db.d.ts} +68 -6
- package/dist/database/db.d.ts.map +1 -0
- package/dist/database/db.js +1775 -0
- package/dist/database/dialect.d.ts +45 -0
- package/dist/database/dialect.d.ts.map +1 -0
- package/dist/database/dialect.js +72 -0
- package/dist/{fts.d.ts → database/fts.d.ts} +7 -0
- package/dist/database/fts.d.ts.map +1 -0
- package/dist/{fts.js → database/fts.js} +122 -34
- package/dist/database/index.d.ts +7 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +6 -0
- package/dist/database/ports.d.ts +50 -0
- package/dist/database/ports.d.ts.map +1 -0
- package/dist/database/ports.js +1 -0
- package/dist/{schema.d.ts → database/schema.d.ts} +16 -3
- package/dist/database/schema.d.ts.map +1 -0
- package/dist/{schema.js → database/schema.js} +126 -44
- package/dist/dev-entry.d.ts +8 -0
- package/dist/dev-entry.d.ts.map +1 -0
- package/dist/dev-entry.js +127 -0
- package/dist/feeds.d.ts +26 -8
- package/dist/feeds.d.ts.map +1 -1
- package/dist/feeds.js +72 -16
- package/dist/hooks.d.ts +102 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +186 -0
- package/dist/hydrate.d.ts +49 -6
- package/dist/hydrate.d.ts.map +1 -1
- package/dist/hydrate.js +21 -20
- package/dist/indexer.d.ts +156 -3
- package/dist/indexer.d.ts.map +1 -1
- package/dist/indexer.js +539 -94
- package/dist/jetstream.d.ts +118 -0
- package/dist/jetstream.d.ts.map +1 -0
- package/dist/jetstream.js +225 -0
- package/dist/labels.d.ts +36 -0
- package/dist/labels.d.ts.map +1 -1
- package/dist/labels.js +71 -6
- package/dist/lex-types.d.ts +2 -0
- package/dist/lex-types.d.ts.map +1 -1
- package/dist/lexicon-resolve.d.ts.map +1 -1
- package/dist/lexicon-resolve.js +27 -112
- package/dist/lexicons/com/atproto/label/defs.json +75 -0
- package/dist/lexicons/com/atproto/moderation/defs.json +30 -0
- package/dist/lexicons/com/atproto/repo/strongRef.json +21 -0
- package/dist/lexicons/dev/hatk/applyWrites.json +87 -0
- package/dist/lexicons/dev/hatk/createRecord.json +40 -0
- package/dist/lexicons/dev/hatk/createReport.json +48 -0
- package/dist/lexicons/dev/hatk/deleteRecord.json +25 -0
- package/dist/lexicons/dev/hatk/describeCollections.json +41 -0
- package/dist/lexicons/dev/hatk/describeFeeds.json +29 -0
- package/dist/lexicons/dev/hatk/describeLabels.json +45 -0
- package/dist/lexicons/dev/hatk/getFeed.json +30 -0
- package/dist/lexicons/dev/hatk/getPreferences.json +19 -0
- package/dist/lexicons/dev/hatk/getRecord.json +26 -0
- package/dist/lexicons/dev/hatk/getRecords.json +32 -0
- package/dist/lexicons/dev/hatk/putPreference.json +28 -0
- package/dist/lexicons/dev/hatk/putRecord.json +41 -0
- package/dist/lexicons/dev/hatk/searchRecords.json +32 -0
- package/dist/lexicons/dev/hatk/uploadBlob.json +23 -0
- package/dist/logger.d.ts +29 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +29 -0
- package/dist/main.js +198 -75
- package/dist/mst.d.ts +15 -0
- package/dist/mst.d.ts.map +1 -1
- package/dist/mst.js +13 -0
- package/dist/oauth/db.d.ts +16 -1
- package/dist/oauth/db.d.ts.map +1 -1
- package/dist/oauth/db.js +74 -19
- package/dist/oauth/discovery.d.ts +10 -0
- package/dist/oauth/discovery.d.ts.map +1 -1
- package/dist/oauth/discovery.js +54 -2
- package/dist/oauth/server.d.ts +93 -1
- package/dist/oauth/server.d.ts.map +1 -1
- package/dist/oauth/server.js +416 -39
- package/dist/oauth/service-describe.d.ts +42 -0
- package/dist/oauth/service-describe.d.ts.map +1 -0
- package/dist/oauth/service-describe.js +108 -0
- package/dist/oauth/session.d.ts +32 -0
- package/dist/oauth/session.d.ts.map +1 -0
- package/dist/oauth/session.js +131 -0
- package/dist/opengraph.d.ts +10 -0
- package/dist/opengraph.d.ts.map +1 -1
- package/dist/opengraph.js +94 -42
- package/dist/pds-proxy.d.ts +82 -0
- package/dist/pds-proxy.d.ts.map +1 -0
- package/dist/pds-proxy.js +356 -0
- package/dist/private-collections.d.ts +13 -0
- package/dist/private-collections.d.ts.map +1 -0
- package/dist/private-collections.js +27 -0
- package/dist/push.d.ts +54 -0
- package/dist/push.d.ts.map +1 -0
- package/dist/push.js +367 -0
- package/dist/renderer.d.ts +27 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +46 -0
- package/dist/resolve-hatk.d.ts +6 -0
- package/dist/resolve-hatk.d.ts.map +1 -0
- package/dist/resolve-hatk.js +20 -0
- package/dist/response.d.ts +16 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +69 -0
- package/dist/scanner.d.ts +21 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +88 -0
- package/dist/seed.d.ts +19 -0
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +43 -4
- package/dist/server-init.d.ts +8 -0
- package/dist/server-init.d.ts.map +1 -0
- package/dist/server-init.js +62 -0
- package/dist/server.d.ts +34 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1021 -649
- package/dist/setup.d.ts +28 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +50 -3
- package/dist/spaces/blob.d.ts +51 -0
- package/dist/spaces/blob.d.ts.map +1 -0
- package/dist/spaces/blob.js +111 -0
- package/dist/spaces/credential.d.ts +62 -0
- package/dist/spaces/credential.d.ts.map +1 -0
- package/dist/spaces/credential.js +184 -0
- package/dist/spaces/engine.d.ts +97 -0
- package/dist/spaces/engine.d.ts.map +1 -0
- package/dist/spaces/engine.js +559 -0
- package/dist/spaces/guard.d.ts +41 -0
- package/dist/spaces/guard.d.ts.map +1 -0
- package/dist/spaces/guard.js +79 -0
- package/dist/spaces/identity.d.ts +37 -0
- package/dist/spaces/identity.d.ts.map +1 -0
- package/dist/spaces/identity.js +88 -0
- package/dist/spaces/index.d.ts +55 -0
- package/dist/spaces/index.d.ts.map +1 -0
- package/dist/spaces/index.js +133 -0
- package/dist/spaces/notify.d.ts +51 -0
- package/dist/spaces/notify.d.ts.map +1 -0
- package/dist/spaces/notify.js +121 -0
- package/dist/spaces/records.d.ts +37 -0
- package/dist/spaces/records.d.ts.map +1 -0
- package/dist/spaces/records.js +63 -0
- package/dist/spaces/store.d.ts +51 -0
- package/dist/spaces/store.d.ts.map +1 -0
- package/dist/spaces/store.js +99 -0
- package/dist/spaces/uri.d.ts +60 -0
- package/dist/spaces/uri.d.ts.map +1 -0
- package/dist/spaces/uri.js +97 -0
- package/dist/spaces/verify.d.ts +39 -0
- package/dist/spaces/verify.d.ts.map +1 -0
- package/dist/spaces/verify.js +87 -0
- package/dist/spaces/viewer.d.ts +51 -0
- package/dist/spaces/viewer.d.ts.map +1 -0
- package/dist/spaces/viewer.js +167 -0
- package/dist/spaces/visibility.d.ts +57 -0
- package/dist/spaces/visibility.d.ts.map +1 -0
- package/dist/spaces/visibility.js +81 -0
- package/dist/templates/feed.tpl +18 -0
- package/dist/templates/hook.tpl +5 -0
- package/dist/templates/label.tpl +15 -0
- package/dist/templates/og.tpl +17 -0
- package/dist/templates/seed.tpl +11 -0
- package/dist/templates/setup.tpl +5 -0
- package/dist/templates/test-feed.tpl +19 -0
- package/dist/templates/test-xrpc.tpl +19 -0
- package/dist/templates/xrpc.tpl +53 -0
- package/dist/test.d.ts +3 -1
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +60 -36
- package/dist/views.js +1 -1
- package/dist/vite-plugin.d.ts +1 -1
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +254 -66
- package/dist/xrpc.d.ts +101 -12
- package/dist/xrpc.d.ts.map +1 -1
- package/dist/xrpc.js +255 -55
- package/package.json +21 -9
- package/public/admin-auth.js +271 -306
- package/public/admin.html +177 -61
- package/dist/db.d.ts.map +0 -1
- package/dist/db.js +0 -1361
- package/dist/fts.d.ts.map +0 -1
- package/dist/oauth/hooks.d.ts +0 -10
- package/dist/oauth/hooks.d.ts.map +0 -1
- package/dist/oauth/hooks.js +0 -40
- package/dist/schema.d.ts.map +0 -1
- package/dist/test-browser.d.ts +0 -14
- package/dist/test-browser.d.ts.map +0 -1
- package/dist/test-browser.js +0 -26
package/dist/oauth/db.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const OAUTH_DDL = "\nCREATE TABLE IF NOT EXISTS _oauth_keys (\n kid TEXT PRIMARY KEY,\n private_key TEXT NOT NULL,\n public_key TEXT NOT NULL,\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_sessions (\n did TEXT PRIMARY KEY,\n pds_endpoint TEXT NOT NULL,\n access_token TEXT NOT NULL,\n refresh_token TEXT,\n dpop_jkt TEXT NOT NULL,\n token_expires_at INTEGER,\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_requests (\n request_uri TEXT PRIMARY KEY,\n client_id TEXT NOT NULL,\n redirect_uri TEXT NOT NULL,\n scope TEXT,\n state TEXT,\n code_challenge TEXT NOT NULL,\n code_challenge_method TEXT NOT NULL DEFAULT 'S256',\n dpop_jkt TEXT NOT NULL,\n pds_request_uri TEXT,\n pds_auth_server TEXT,\n pds_code_verifier TEXT,\n pds_state TEXT,\n did TEXT,\n login_hint TEXT,\n expires_at INTEGER NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_codes (\n code TEXT PRIMARY KEY,\n request_uri TEXT NOT NULL,\n created_at INTEGER NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_refresh_tokens (\n token TEXT PRIMARY KEY,\n client_id TEXT NOT NULL,\n did TEXT NOT NULL,\n dpop_jkt TEXT NOT NULL,\n scope TEXT,\n created_at INTEGER NOT NULL,\n expires_at INTEGER,\n revoked INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_dpop_jtis (\n jti TEXT PRIMARY KEY,\n expires_at INTEGER NOT NULL\n);\n";
|
|
1
|
+
export declare const OAUTH_DDL = "\nCREATE TABLE IF NOT EXISTS _oauth_keys (\n kid TEXT PRIMARY KEY,\n private_key TEXT NOT NULL,\n public_key TEXT NOT NULL,\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_sessions (\n did TEXT PRIMARY KEY,\n pds_endpoint TEXT NOT NULL,\n pds_auth_server TEXT,\n pds_token_endpoint TEXT,\n access_token TEXT NOT NULL,\n refresh_token TEXT,\n dpop_jkt TEXT NOT NULL,\n token_expires_at INTEGER,\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_requests (\n request_uri TEXT PRIMARY KEY,\n client_id TEXT NOT NULL,\n redirect_uri TEXT NOT NULL,\n scope TEXT,\n state TEXT,\n code_challenge TEXT NOT NULL,\n code_challenge_method TEXT NOT NULL DEFAULT 'S256',\n dpop_jkt TEXT NOT NULL,\n pds_request_uri TEXT,\n pds_auth_server TEXT,\n pds_authorization_endpoint TEXT,\n pds_token_endpoint TEXT,\n pds_endpoint TEXT,\n pds_code_verifier TEXT,\n pds_state TEXT,\n did TEXT,\n login_hint TEXT,\n expires_at INTEGER NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_codes (\n code TEXT PRIMARY KEY,\n request_uri TEXT NOT NULL,\n created_at INTEGER NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_refresh_tokens (\n token TEXT PRIMARY KEY,\n client_id TEXT NOT NULL,\n did TEXT NOT NULL,\n dpop_jkt TEXT NOT NULL,\n scope TEXT,\n created_at INTEGER NOT NULL,\n expires_at INTEGER,\n revoked INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE IF NOT EXISTS _oauth_dpop_jtis (\n jti TEXT PRIMARY KEY,\n expires_at INTEGER NOT NULL\n);\n";
|
|
2
2
|
export declare function getServerKey(kid: string): Promise<{
|
|
3
3
|
privateKey: string;
|
|
4
4
|
publicKey: string;
|
|
@@ -14,6 +14,9 @@ export declare function storeOAuthRequest(requestUri: string, data: {
|
|
|
14
14
|
dpopJkt: string;
|
|
15
15
|
pdsRequestUri?: string;
|
|
16
16
|
pdsAuthServer?: string;
|
|
17
|
+
pdsAuthorizationEndpoint?: string;
|
|
18
|
+
pdsTokenEndpoint?: string;
|
|
19
|
+
pdsEndpoint?: string;
|
|
17
20
|
pdsCodeVerifier?: string;
|
|
18
21
|
pdsState?: string;
|
|
19
22
|
did?: string;
|
|
@@ -26,12 +29,24 @@ export declare function storeAuthCode(code: string, requestUri: string): Promise
|
|
|
26
29
|
export declare function consumeAuthCode(code: string): Promise<string | null>;
|
|
27
30
|
export declare function storeSession(did: string, data: {
|
|
28
31
|
pdsEndpoint: string;
|
|
32
|
+
pdsAuthServer?: string;
|
|
33
|
+
/** From the auth server's metadata, so refreshes don't guess the path. */
|
|
34
|
+
pdsTokenEndpoint?: string;
|
|
29
35
|
accessToken: string;
|
|
30
36
|
refreshToken?: string;
|
|
31
37
|
dpopJkt: string;
|
|
32
38
|
tokenExpiresAt?: number;
|
|
33
39
|
}): Promise<void>;
|
|
34
40
|
export declare function getSession(did: string): Promise<any | null>;
|
|
41
|
+
/**
|
|
42
|
+
* Every DID this instance holds a PDS session for, most recently refreshed
|
|
43
|
+
* first.
|
|
44
|
+
*
|
|
45
|
+
* Space indexing reads as a member rather than as itself, so this is the set of
|
|
46
|
+
* people it could borrow a delegation from. Ordered by recency because a
|
|
47
|
+
* session refreshed lately is the one most likely to still work.
|
|
48
|
+
*/
|
|
49
|
+
export declare function listSessionDids(): Promise<string[]>;
|
|
35
50
|
export declare function deleteSession(did: string): Promise<void>;
|
|
36
51
|
export declare function storeRefreshToken(token: string, data: {
|
|
37
52
|
clientId: string;
|
package/dist/oauth/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/oauth/db.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/oauth/db.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,ykDA+DrB,CAAA;AAID,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;I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zD"}
|
package/dist/oauth/db.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/hatk/src/oauth/db.ts
|
|
2
|
-
import { querySQL, runSQL } from "../db.js";
|
|
2
|
+
import { querySQL, runSQL } from "../database/db.js";
|
|
3
3
|
// --- DDL ---
|
|
4
4
|
export const OAUTH_DDL = `
|
|
5
5
|
CREATE TABLE IF NOT EXISTS _oauth_keys (
|
|
@@ -12,6 +12,8 @@ CREATE TABLE IF NOT EXISTS _oauth_keys (
|
|
|
12
12
|
CREATE TABLE IF NOT EXISTS _oauth_sessions (
|
|
13
13
|
did TEXT PRIMARY KEY,
|
|
14
14
|
pds_endpoint TEXT NOT NULL,
|
|
15
|
+
pds_auth_server TEXT,
|
|
16
|
+
pds_token_endpoint TEXT,
|
|
15
17
|
access_token TEXT NOT NULL,
|
|
16
18
|
refresh_token TEXT,
|
|
17
19
|
dpop_jkt TEXT NOT NULL,
|
|
@@ -31,6 +33,9 @@ CREATE TABLE IF NOT EXISTS _oauth_requests (
|
|
|
31
33
|
dpop_jkt TEXT NOT NULL,
|
|
32
34
|
pds_request_uri TEXT,
|
|
33
35
|
pds_auth_server TEXT,
|
|
36
|
+
pds_authorization_endpoint TEXT,
|
|
37
|
+
pds_token_endpoint TEXT,
|
|
38
|
+
pds_endpoint TEXT,
|
|
34
39
|
pds_code_verifier TEXT,
|
|
35
40
|
pds_state TEXT,
|
|
36
41
|
did TEXT,
|
|
@@ -62,18 +67,41 @@ CREATE TABLE IF NOT EXISTS _oauth_dpop_jtis (
|
|
|
62
67
|
`;
|
|
63
68
|
// --- Key Management ---
|
|
64
69
|
export async function getServerKey(kid) {
|
|
65
|
-
const rows = await querySQL('SELECT private_key, public_key FROM _oauth_keys WHERE kid = $1', [kid]);
|
|
70
|
+
const rows = (await querySQL('SELECT private_key, public_key FROM _oauth_keys WHERE kid = $1', [kid]));
|
|
66
71
|
if (rows.length === 0)
|
|
67
72
|
return null;
|
|
68
73
|
return { privateKey: rows[0].private_key, publicKey: rows[0].public_key };
|
|
69
74
|
}
|
|
70
75
|
export async function storeServerKey(kid, privateKey, publicKey) {
|
|
71
|
-
await runSQL('INSERT OR REPLACE INTO _oauth_keys (kid, private_key, public_key) VALUES ($1, $2, $3)',
|
|
76
|
+
await runSQL('INSERT OR REPLACE INTO _oauth_keys (kid, private_key, public_key) VALUES ($1, $2, $3)', [
|
|
77
|
+
kid,
|
|
78
|
+
privateKey,
|
|
79
|
+
publicKey,
|
|
80
|
+
]);
|
|
72
81
|
}
|
|
73
82
|
// --- OAuth Request Storage ---
|
|
74
83
|
export async function storeOAuthRequest(requestUri, data) {
|
|
75
|
-
await runSQL(`INSERT INTO _oauth_requests (request_uri, client_id, redirect_uri, scope, state, code_challenge, code_challenge_method, dpop_jkt, pds_request_uri, pds_auth_server, pds_code_verifier, pds_state, did, login_hint, expires_at)
|
|
76
|
-
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)`,
|
|
84
|
+
await runSQL(`INSERT INTO _oauth_requests (request_uri, client_id, redirect_uri, scope, state, code_challenge, code_challenge_method, dpop_jkt, pds_request_uri, pds_auth_server, pds_authorization_endpoint, pds_token_endpoint, pds_endpoint, pds_code_verifier, pds_state, did, login_hint, expires_at)
|
|
85
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18)`, [
|
|
86
|
+
requestUri,
|
|
87
|
+
data.clientId,
|
|
88
|
+
data.redirectUri,
|
|
89
|
+
data.scope || null,
|
|
90
|
+
data.state || null,
|
|
91
|
+
data.codeChallenge,
|
|
92
|
+
data.codeChallengeMethod || 'S256',
|
|
93
|
+
data.dpopJkt,
|
|
94
|
+
data.pdsRequestUri || null,
|
|
95
|
+
data.pdsAuthServer || null,
|
|
96
|
+
data.pdsAuthorizationEndpoint || null,
|
|
97
|
+
data.pdsTokenEndpoint || null,
|
|
98
|
+
data.pdsEndpoint || null,
|
|
99
|
+
data.pdsCodeVerifier || null,
|
|
100
|
+
data.pdsState || null,
|
|
101
|
+
data.did || null,
|
|
102
|
+
data.loginHint || null,
|
|
103
|
+
data.expiresAt,
|
|
104
|
+
]);
|
|
77
105
|
}
|
|
78
106
|
export async function getOAuthRequest(requestUri) {
|
|
79
107
|
const rows = await querySQL('SELECT * FROM _oauth_requests WHERE request_uri = $1 AND expires_at > $2', [
|
|
@@ -83,57 +111,84 @@ export async function getOAuthRequest(requestUri) {
|
|
|
83
111
|
return rows.length > 0 ? rows[0] : null;
|
|
84
112
|
}
|
|
85
113
|
export async function deleteOAuthRequest(requestUri) {
|
|
86
|
-
await runSQL('DELETE FROM _oauth_requests WHERE request_uri = $1', requestUri);
|
|
114
|
+
await runSQL('DELETE FROM _oauth_requests WHERE request_uri = $1', [requestUri]);
|
|
87
115
|
}
|
|
88
116
|
// --- Authorization Codes ---
|
|
89
117
|
export async function storeAuthCode(code, requestUri) {
|
|
90
|
-
await runSQL('INSERT INTO _oauth_codes (code, request_uri, created_at) VALUES ($1, $2, $3)',
|
|
118
|
+
await runSQL('INSERT INTO _oauth_codes (code, request_uri, created_at) VALUES ($1, $2, $3)', [
|
|
119
|
+
code,
|
|
120
|
+
requestUri,
|
|
121
|
+
Math.floor(Date.now() / 1000),
|
|
122
|
+
]);
|
|
91
123
|
}
|
|
92
124
|
export async function consumeAuthCode(code) {
|
|
93
|
-
const rows = await querySQL('SELECT request_uri FROM _oauth_codes WHERE code = $1', [code]);
|
|
125
|
+
const rows = (await querySQL('SELECT request_uri FROM _oauth_codes WHERE code = $1', [code]));
|
|
94
126
|
if (rows.length === 0)
|
|
95
127
|
return null;
|
|
96
|
-
await runSQL('DELETE FROM _oauth_codes WHERE code = $1', code);
|
|
128
|
+
await runSQL('DELETE FROM _oauth_codes WHERE code = $1', [code]);
|
|
97
129
|
return rows[0].request_uri;
|
|
98
130
|
}
|
|
99
131
|
// --- Sessions ---
|
|
100
132
|
export async function storeSession(did, data) {
|
|
101
|
-
await runSQL(`INSERT OR REPLACE INTO _oauth_sessions (did, pds_endpoint, access_token, refresh_token, dpop_jkt, token_expires_at, updated_at)
|
|
102
|
-
VALUES ($1,$2,$3,$4,$5,$6,CURRENT_TIMESTAMP)`,
|
|
133
|
+
await runSQL(`INSERT OR REPLACE INTO _oauth_sessions (did, pds_endpoint, pds_auth_server, pds_token_endpoint, access_token, refresh_token, dpop_jkt, token_expires_at, updated_at)
|
|
134
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,CURRENT_TIMESTAMP)`, [
|
|
135
|
+
did,
|
|
136
|
+
data.pdsEndpoint,
|
|
137
|
+
data.pdsAuthServer || null,
|
|
138
|
+
data.pdsTokenEndpoint || null,
|
|
139
|
+
data.accessToken,
|
|
140
|
+
data.refreshToken || null,
|
|
141
|
+
data.dpopJkt,
|
|
142
|
+
data.tokenExpiresAt || null,
|
|
143
|
+
]);
|
|
103
144
|
}
|
|
104
145
|
export async function getSession(did) {
|
|
105
146
|
const rows = await querySQL('SELECT * FROM _oauth_sessions WHERE did = $1', [did]);
|
|
106
147
|
return rows.length > 0 ? rows[0] : null;
|
|
107
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Every DID this instance holds a PDS session for, most recently refreshed
|
|
151
|
+
* first.
|
|
152
|
+
*
|
|
153
|
+
* Space indexing reads as a member rather than as itself, so this is the set of
|
|
154
|
+
* people it could borrow a delegation from. Ordered by recency because a
|
|
155
|
+
* session refreshed lately is the one most likely to still work.
|
|
156
|
+
*/
|
|
157
|
+
export async function listSessionDids() {
|
|
158
|
+
const rows = (await querySQL('SELECT did FROM _oauth_sessions ORDER BY updated_at DESC, created_at DESC'));
|
|
159
|
+
return rows.map((r) => r.did);
|
|
160
|
+
}
|
|
108
161
|
export async function deleteSession(did) {
|
|
109
|
-
await runSQL('DELETE FROM _oauth_sessions WHERE did = $1', did);
|
|
162
|
+
await runSQL('DELETE FROM _oauth_sessions WHERE did = $1', [did]);
|
|
110
163
|
}
|
|
111
164
|
// --- Refresh Tokens ---
|
|
112
165
|
export async function storeRefreshToken(token, data) {
|
|
113
166
|
const now = Math.floor(Date.now() / 1000);
|
|
114
167
|
const expiresAt = data.expiresAt ?? now + 14 * 86400; // 14 days default
|
|
115
168
|
await runSQL(`INSERT INTO _oauth_refresh_tokens (token, client_id, did, dpop_jkt, scope, created_at, expires_at)
|
|
116
|
-
VALUES ($1,$2,$3,$4,$5,$6,$7)`, token, data.clientId, data.did, data.dpopJkt, data.scope || null, now, expiresAt);
|
|
169
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7)`, [token, data.clientId, data.did, data.dpopJkt, data.scope || null, now, expiresAt]);
|
|
117
170
|
}
|
|
118
171
|
export async function getRefreshToken(token) {
|
|
119
172
|
const rows = await querySQL('SELECT * FROM _oauth_refresh_tokens WHERE token = $1', [token]);
|
|
120
173
|
return rows.length > 0 ? rows[0] : null;
|
|
121
174
|
}
|
|
122
175
|
export async function revokeRefreshToken(token) {
|
|
123
|
-
await runSQL('UPDATE _oauth_refresh_tokens SET revoked = 1 WHERE token = $1', token);
|
|
176
|
+
await runSQL('UPDATE _oauth_refresh_tokens SET revoked = 1 WHERE token = $1', [token]);
|
|
124
177
|
}
|
|
125
178
|
// --- DPoP JTI Replay Protection ---
|
|
126
179
|
export async function checkAndStoreDpopJti(jti, expiresAt) {
|
|
127
180
|
const rows = await querySQL('SELECT 1 FROM _oauth_dpop_jtis WHERE jti = $1', [jti]);
|
|
128
181
|
if (rows.length > 0)
|
|
129
182
|
return false;
|
|
130
|
-
await runSQL('INSERT INTO _oauth_dpop_jtis (jti, expires_at) VALUES ($1, $2)', jti, expiresAt);
|
|
183
|
+
await runSQL('INSERT INTO _oauth_dpop_jtis (jti, expires_at) VALUES ($1, $2)', [jti, expiresAt]);
|
|
131
184
|
return true;
|
|
132
185
|
}
|
|
133
186
|
export async function cleanupExpiredOAuth() {
|
|
134
187
|
const now = Math.floor(Date.now() / 1000);
|
|
135
|
-
await runSQL('DELETE FROM _oauth_dpop_jtis WHERE expires_at < $1', now);
|
|
136
|
-
await runSQL('DELETE FROM _oauth_requests WHERE expires_at < $1', now);
|
|
137
|
-
await runSQL('DELETE FROM _oauth_codes WHERE created_at < $1', now - 600);
|
|
138
|
-
await runSQL('DELETE FROM _oauth_refresh_tokens WHERE revoked = 1 OR (expires_at IS NOT NULL AND expires_at < $1)',
|
|
188
|
+
await runSQL('DELETE FROM _oauth_dpop_jtis WHERE expires_at < $1', [now]);
|
|
189
|
+
await runSQL('DELETE FROM _oauth_requests WHERE expires_at < $1', [now]);
|
|
190
|
+
await runSQL('DELETE FROM _oauth_codes WHERE created_at < $1', [now - 600]);
|
|
191
|
+
await runSQL('DELETE FROM _oauth_refresh_tokens WHERE revoked = 1 OR (expires_at IS NOT NULL AND expires_at < $1)', [
|
|
192
|
+
now,
|
|
193
|
+
]);
|
|
139
194
|
}
|
|
@@ -18,5 +18,15 @@ export declare function discoverAuthServer(did: string, plcUrl: string): Promise
|
|
|
18
18
|
authServerEndpoint: string;
|
|
19
19
|
authServerMetadata: AuthServerMetadata;
|
|
20
20
|
}>;
|
|
21
|
+
/**
|
|
22
|
+
* A handle to its DID.
|
|
23
|
+
*
|
|
24
|
+
* The protocol defines two ways, and both are asked first: the DNS TXT record
|
|
25
|
+
* and the well-known document. Either answers for a handle on any PDS, which
|
|
26
|
+
* is what lets somebody from another host sign in here. A handle neither
|
|
27
|
+
* method knows — a dev network's `.test` names, which have no DNS and no TLS
|
|
28
|
+
* — falls back to asking a PDS: the local one in dev, the one behind a
|
|
29
|
+
* self-hosted relay, or bsky.social.
|
|
30
|
+
*/
|
|
21
31
|
export declare function resolveHandle(handle: string, relayUrl?: string): Promise<string>;
|
|
22
32
|
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/oauth/discovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/oauth/discovery.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,sBAAsB,EAAE,MAAM,CAAA;IAC9B,cAAc,EAAE,MAAM,CAAA;IACtB,qCAAqC,CAAC,EAAE,MAAM,CAAA;IAC9C,QAAQ,EAAE,MAAM,CAAA;IAChB,iCAAiC,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAU1E;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAGzD;AAED,wBAAsB,8BAA8B,CAClD,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,qBAAqB,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAI9C;AAED,wBAAsB,uBAAuB,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAIrG;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IACT,WAAW,EAAE,MAAM,CAAA;IACnB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,kBAAkB,EAAE,kBAAkB,CAAA;CACvC,CAAC,CAWD;AA+BD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBtF"}
|
package/dist/oauth/discovery.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { resolveTxt } from 'node:dns/promises';
|
|
2
2
|
export async function resolveDid(did, plcUrl) {
|
|
3
3
|
if (did.startsWith('did:web:')) {
|
|
4
4
|
const domain = did.slice('did:web:'.length);
|
|
@@ -40,8 +40,60 @@ export async function discoverAuthServer(did, plcUrl) {
|
|
|
40
40
|
const authServerMetadata = await fetchAuthServerMetadata(authServerEndpoint);
|
|
41
41
|
return { pdsEndpoint, authServerEndpoint, authServerMetadata };
|
|
42
42
|
}
|
|
43
|
+
const HANDLE_RESOLVE_TIMEOUT_MS = 5000;
|
|
44
|
+
/** The DNS method: a `_atproto.<handle>` TXT record carrying `did=...`. */
|
|
45
|
+
async function resolveHandleViaDns(handle) {
|
|
46
|
+
try {
|
|
47
|
+
for (const chunks of await resolveTxt(`_atproto.${handle}`)) {
|
|
48
|
+
const txt = chunks.join('');
|
|
49
|
+
if (txt.startsWith('did='))
|
|
50
|
+
return txt.slice('did='.length).trim();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// No record, or not a resolvable name: not this method.
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
/** The HTTPS method: `https://<handle>/.well-known/atproto-did`, the DID as plain text. */
|
|
59
|
+
async function resolveHandleViaWellKnown(handle) {
|
|
60
|
+
try {
|
|
61
|
+
const res = await fetch(`https://${handle}/.well-known/atproto-did`, {
|
|
62
|
+
signal: AbortSignal.timeout(HANDLE_RESOLVE_TIMEOUT_MS),
|
|
63
|
+
});
|
|
64
|
+
if (!res.ok)
|
|
65
|
+
return null;
|
|
66
|
+
const did = (await res.text()).trim().split('\n')[0].trim();
|
|
67
|
+
return did.startsWith('did:') ? did : null;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A handle to its DID.
|
|
75
|
+
*
|
|
76
|
+
* The protocol defines two ways, and both are asked first: the DNS TXT record
|
|
77
|
+
* and the well-known document. Either answers for a handle on any PDS, which
|
|
78
|
+
* is what lets somebody from another host sign in here. A handle neither
|
|
79
|
+
* method knows — a dev network's `.test` names, which have no DNS and no TLS
|
|
80
|
+
* — falls back to asking a PDS: the local one in dev, the one behind a
|
|
81
|
+
* self-hosted relay, or bsky.social.
|
|
82
|
+
*/
|
|
43
83
|
export async function resolveHandle(handle, relayUrl) {
|
|
44
|
-
const
|
|
84
|
+
const direct = (await resolveHandleViaDns(handle)) ?? (await resolveHandleViaWellKnown(handle));
|
|
85
|
+
if (direct)
|
|
86
|
+
return direct;
|
|
87
|
+
let baseUrl;
|
|
88
|
+
if (relayUrl?.includes('localhost:2583')) {
|
|
89
|
+
baseUrl = 'http://localhost:2583';
|
|
90
|
+
}
|
|
91
|
+
else if (!relayUrl || relayUrl.includes('bsky.network')) {
|
|
92
|
+
baseUrl = 'https://bsky.social';
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
baseUrl = relayUrl.replace(/^ws/, 'http'); // wss://pds.example → https://pds.example
|
|
96
|
+
}
|
|
45
97
|
const res = await fetch(`${baseUrl}/xrpc/com.atproto.identity.resolveHandle?handle=${encodeURIComponent(handle)}`);
|
|
46
98
|
if (!res.ok)
|
|
47
99
|
throw new Error(`resolveHandle failed: ${res.status}`);
|
package/dist/oauth/server.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import type { OAuthConfig } from '../config.ts';
|
|
2
|
+
/**
|
|
3
|
+
* RFC 6749 §5.2 OAuth token-endpoint error.
|
|
4
|
+
*
|
|
5
|
+
* Surfaces as HTTP `status` (default 400) with body
|
|
6
|
+
* `{ error: code, error_description: description }` so OAuth clients can
|
|
7
|
+
* distinguish a permanently-rejected refresh token (`invalid_grant`) from
|
|
8
|
+
* a transient server failure and decide whether to log the user out.
|
|
9
|
+
*/
|
|
10
|
+
export declare class OAuthError extends Error {
|
|
11
|
+
readonly code: 'invalid_request' | 'invalid_client' | 'invalid_grant' | 'unauthorized_client' | 'unsupported_grant_type' | 'invalid_scope';
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly status: number;
|
|
14
|
+
constructor(code: 'invalid_request' | 'invalid_client' | 'invalid_grant' | 'unauthorized_client' | 'unsupported_grant_type' | 'invalid_scope', description: string, status?: number);
|
|
15
|
+
}
|
|
2
16
|
export declare function initOAuth(_config: OAuthConfig, plcUrl: string, relayUrl: string): Promise<void>;
|
|
3
17
|
export declare function getAuthServerMetadata(issuer: string, config: OAuthConfig): {
|
|
4
18
|
issuer: string;
|
|
@@ -49,30 +63,108 @@ export declare function getJwks(): {
|
|
|
49
63
|
y?: string;
|
|
50
64
|
}[];
|
|
51
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Whether we authenticate to PDSes as a confidential client.
|
|
68
|
+
*
|
|
69
|
+
* A confidential client gets a 2-year session and 3-month refresh window
|
|
70
|
+
* instead of 2 weeks, and is exempt from the consent screen atproto forces on
|
|
71
|
+
* every authorization request from a public client. It requires a fetchable
|
|
72
|
+
* `jwks_uri`, so loopback deployments (local dev) stay public.
|
|
73
|
+
*/
|
|
74
|
+
export declare function isConfidentialClient(issuer: string): boolean;
|
|
75
|
+
/** Public half of the client-authentication key, for the PDS to verify assertions. */
|
|
76
|
+
export declare function getClientJwks(): {
|
|
77
|
+
keys: {
|
|
78
|
+
kid: string;
|
|
79
|
+
use: string;
|
|
80
|
+
alg: string;
|
|
81
|
+
crv?: string;
|
|
82
|
+
d?: string;
|
|
83
|
+
dp?: string;
|
|
84
|
+
dq?: string;
|
|
85
|
+
e?: string;
|
|
86
|
+
ext?: boolean;
|
|
87
|
+
k?: string;
|
|
88
|
+
key_ops?: string[];
|
|
89
|
+
kty?: string;
|
|
90
|
+
n?: string;
|
|
91
|
+
oth?: RsaOtherPrimesInfo[];
|
|
92
|
+
p?: string;
|
|
93
|
+
q?: string;
|
|
94
|
+
qi?: string;
|
|
95
|
+
x?: string;
|
|
96
|
+
y?: string;
|
|
97
|
+
}[];
|
|
98
|
+
};
|
|
52
99
|
export declare function getClientMetadata(issuer: string, config: OAuthConfig): {
|
|
100
|
+
dpop_bound_access_tokens: boolean;
|
|
101
|
+
scope: string;
|
|
102
|
+
token_endpoint_auth_method: string;
|
|
103
|
+
token_endpoint_auth_signing_alg: string;
|
|
104
|
+
jwks_uri: string;
|
|
53
105
|
client_id: string;
|
|
54
106
|
client_name: string;
|
|
55
107
|
redirect_uris: string[];
|
|
56
108
|
grant_types: string[];
|
|
57
109
|
response_types: string[];
|
|
58
|
-
|
|
110
|
+
} | {
|
|
59
111
|
dpop_bound_access_tokens: boolean;
|
|
60
112
|
scope: string;
|
|
113
|
+
token_endpoint_auth_method: string;
|
|
114
|
+
client_id: string;
|
|
115
|
+
client_name: string;
|
|
116
|
+
redirect_uris: string[];
|
|
117
|
+
grant_types: string[];
|
|
118
|
+
response_types: string[];
|
|
61
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* Handle a Pushed Authorization Request (PAR).
|
|
122
|
+
*
|
|
123
|
+
* Supports account creation via `prompt=create`. When set, `login_hint`
|
|
124
|
+
* is treated as a PDS hostname (e.g. "selfhosted.social" or "localhost:2583")
|
|
125
|
+
* rather than a handle or DID. The auth server is discovered from the PDS's
|
|
126
|
+
* protected resource metadata, and `prompt=create` is forwarded to the PDS
|
|
127
|
+
* PAR so it shows the signup page.
|
|
128
|
+
*
|
|
129
|
+
* For normal login, `login_hint` is a handle or DID as usual.
|
|
130
|
+
*/
|
|
62
131
|
export declare function handlePar(config: OAuthConfig, body: Record<string, string>, dpopHeader: string, requestUrl: string): Promise<{
|
|
63
132
|
request_uri: string;
|
|
64
133
|
expires_in: number;
|
|
65
134
|
}>;
|
|
66
135
|
export declare function buildAuthorizeRedirect(config: OAuthConfig, request: any): string;
|
|
136
|
+
/**
|
|
137
|
+
* Initiate a server-side OAuth login or account creation flow.
|
|
138
|
+
*
|
|
139
|
+
* For account creation, pass `{ prompt: 'create', pds: 'selfhosted.social' }`.
|
|
140
|
+
* The `pds` is a bare hostname; the auth server is discovered from its
|
|
141
|
+
* protected resource metadata.
|
|
142
|
+
*/
|
|
143
|
+
export declare function serverLogin(config: OAuthConfig, handle: string, options?: {
|
|
144
|
+
prompt?: string;
|
|
145
|
+
pds?: string;
|
|
146
|
+
}): Promise<string>;
|
|
67
147
|
export declare function handleCallback(config: OAuthConfig, code: string, state: string | null, iss: string | null): Promise<{
|
|
68
148
|
requestUri: string;
|
|
69
149
|
clientRedirectUri: string;
|
|
70
150
|
clientState: string | null;
|
|
151
|
+
did: string;
|
|
71
152
|
}>;
|
|
153
|
+
/**
|
|
154
|
+
* Handle an error redirect from the PDS (user denied, request expired, etc).
|
|
155
|
+
*
|
|
156
|
+
* The PDS reports failures by redirecting to our callback with `error` and no
|
|
157
|
+
* `code`. Discard the pending request and return a URL that hands the error
|
|
158
|
+
* back to the app, so the browser lands somewhere renderable instead of on a
|
|
159
|
+
* raw error response.
|
|
160
|
+
*/
|
|
161
|
+
export declare function handleCallbackError(config: OAuthConfig, error: string, errorDescription: string | null, state: string | null): Promise<string>;
|
|
72
162
|
export declare function handleToken(config: OAuthConfig, body: Record<string, string>, dpopHeader: string, requestUrl: string): Promise<any>;
|
|
73
163
|
export declare function refreshPdsSession(config: OAuthConfig, session: {
|
|
74
164
|
did: string;
|
|
75
165
|
pds_endpoint: string;
|
|
166
|
+
pds_auth_server?: string;
|
|
167
|
+
pds_token_endpoint?: string;
|
|
76
168
|
refresh_token: string;
|
|
77
169
|
dpop_jkt: string;
|
|
78
170
|
}): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/oauth/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/oauth/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAgD/C;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,KAAK;aAEjB,IAAI,EAChB,iBAAiB,GACjB,gBAAgB,GAChB,eAAe,GACf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