kitty-agent 8.5.0 → 9.0.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/package.json +11 -5
- package/out/agent.d.ts +0 -139
- package/out/agent.d.ts.map +0 -1
- package/out/agent.js +0 -223
- package/out/agent.js.map +0 -1
- package/out/cid.d.ts +0 -5
- package/out/cid.d.ts.map +0 -1
- package/out/cid.js +0 -38
- package/out/cid.js.map +0 -1
- package/out/handles/did-document.d.ts +0 -58
- package/out/handles/did-document.d.ts.map +0 -1
- package/out/handles/did-document.js +0 -101
- package/out/handles/did-document.js.map +0 -1
- package/out/handles/doh.d.ts +0 -3
- package/out/handles/doh.d.ts.map +0 -1
- package/out/handles/doh.js +0 -77
- package/out/handles/doh.js.map +0 -1
- package/out/handles/http.d.ts +0 -3
- package/out/handles/http.d.ts.map +0 -1
- package/out/handles/http.js +0 -15
- package/out/handles/http.js.map +0 -1
- package/out/handles/index.d.ts +0 -3
- package/out/handles/index.d.ts.map +0 -1
- package/out/handles/index.js +0 -4
- package/out/handles/index.js.map +0 -1
- package/out/handles/resolve.d.ts +0 -2
- package/out/handles/resolve.d.ts.map +0 -1
- package/out/handles/resolve.js +0 -24
- package/out/handles/resolve.js.map +0 -1
- package/out/index.d.ts +0 -8
- package/out/index.d.ts.map +0 -1
- package/out/index.js +0 -8
- package/out/index.js.map +0 -1
- package/out/oauth-nanostores.d.ts +0 -311
- package/out/oauth-nanostores.d.ts.map +0 -1
- package/out/oauth-nanostores.js +0 -52
- package/out/oauth-nanostores.js.map +0 -1
- package/out/oauth-solidjs.d.ts +0 -75
- package/out/oauth-solidjs.d.ts.map +0 -1
- package/out/oauth-solidjs.js +0 -57
- package/out/oauth-solidjs.js.map +0 -1
- package/out/oauth-stateful-base.d.ts +0 -47
- package/out/oauth-stateful-base.d.ts.map +0 -1
- package/out/oauth-stateful-base.js +0 -58
- package/out/oauth-stateful-base.js.map +0 -1
- package/out/oauth-svelte.d.ts +0 -80
- package/out/oauth-svelte.d.ts.map +0 -1
- package/out/oauth-svelte.js +0 -104
- package/out/oauth-svelte.js.map +0 -1
- package/out/oauth.d.ts +0 -13
- package/out/oauth.d.ts.map +0 -1
- package/out/oauth.js +0 -62
- package/out/oauth.js.map +0 -1
- package/out/pds-helpers.d.ts +0 -8
- package/out/pds-helpers.d.ts.map +0 -1
- package/out/pds-helpers.js +0 -16
- package/out/pds-helpers.js.map +0 -1
- package/out/rkey.d.ts +0 -5
- package/out/rkey.d.ts.map +0 -1
- package/out/rkey.js +0 -6
- package/out/rkey.js.map +0 -1
- package/out/sample-authenticated-client.d.ts +0 -19
- package/out/sample-authenticated-client.d.ts.map +0 -1
- package/out/sample-authenticated-client.js +0 -13
- package/out/sample-authenticated-client.js.map +0 -1
- package/out/shortid.d.ts +0 -22
- package/out/shortid.d.ts.map +0 -1
- package/out/shortid.js +0 -50
- package/out/shortid.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kitty-agent",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.0.0",
|
|
5
5
|
"description": "Helpers for @atcute/client",
|
|
6
6
|
"main": "out/index.js",
|
|
7
7
|
"types": "out/index.d.ts",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"author": "",
|
|
34
34
|
"license": "ISC",
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@atcute/cid": "^2.1
|
|
37
|
-
"@atcute/client": "^2.
|
|
38
|
-
"@atcute/oauth-browser-client": "^
|
|
39
|
-
"@atproto/syntax": "^0.3
|
|
36
|
+
"@atcute/cid": "^2.4.1",
|
|
37
|
+
"@atcute/client": "^4.2.1",
|
|
38
|
+
"@atcute/oauth-browser-client": "^3.0.0",
|
|
39
|
+
"@atproto/syntax": "^0.4.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@atcute/cid": "^2.1.0",
|
|
@@ -44,6 +44,12 @@
|
|
|
44
44
|
"@atcute/oauth-browser-client": "^1.0.9",
|
|
45
45
|
"@atproto/syntax": "^0.3.1"
|
|
46
46
|
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@atcute/atproto": "^3.1.10",
|
|
49
|
+
"@atcute/identity": "^1.1.3",
|
|
50
|
+
"@atcute/identity-resolver": "^1.2.2",
|
|
51
|
+
"@atcute/lexicons": "^1.2.9"
|
|
52
|
+
},
|
|
47
53
|
"scripts": {
|
|
48
54
|
"build": "tsc"
|
|
49
55
|
}
|
package/out/agent.d.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { CredentialManager, XRPC, type XRPCOptions, type XRPCRequestOptions, type XRPCResponse } from "@atcute/client";
|
|
2
|
-
import type { At, ComAtprotoRepoApplyWrites, ComAtprotoRepoCreateRecord, ComAtprotoRepoDeleteRecord, ComAtprotoRepoGetRecord, ComAtprotoRepoListRecords, ComAtprotoRepoPutRecord, ComAtprotoSyncGetBlob, ComAtprotoSyncListRepos, Procedures, Queries, Records } from "@atcute/client/lexicons";
|
|
3
|
-
import { AtUri } from "@atproto/syntax";
|
|
4
|
-
interface GetRecordParams<K extends keyof Records> extends ComAtprotoRepoGetRecord.Params {
|
|
5
|
-
collection: K;
|
|
6
|
-
}
|
|
7
|
-
interface ListRecordsParams<K extends keyof Records> extends ComAtprotoRepoListRecords.Params {
|
|
8
|
-
collection: K;
|
|
9
|
-
}
|
|
10
|
-
interface PutRecordInput<K extends keyof Records> extends ComAtprotoRepoPutRecord.Input {
|
|
11
|
-
collection: K;
|
|
12
|
-
record: Records[K];
|
|
13
|
-
}
|
|
14
|
-
interface CreateRecordInput<K extends keyof Records> extends ComAtprotoRepoCreateRecord.Input {
|
|
15
|
-
collection: K;
|
|
16
|
-
record: Records[K];
|
|
17
|
-
}
|
|
18
|
-
interface DeleteRecordInput<K extends keyof Records> extends ComAtprotoRepoDeleteRecord.Input {
|
|
19
|
-
collection: K;
|
|
20
|
-
}
|
|
21
|
-
interface GetRecordOutput<K extends keyof Records> {
|
|
22
|
-
cid?: At.CID;
|
|
23
|
-
uri: AtUri;
|
|
24
|
-
value: Records[K];
|
|
25
|
-
}
|
|
26
|
-
interface ListRecordsOutput<K extends keyof Records> {
|
|
27
|
-
records: {
|
|
28
|
-
cid: At.CID;
|
|
29
|
-
uri: AtUri;
|
|
30
|
-
value: Records[K];
|
|
31
|
-
}[];
|
|
32
|
-
}
|
|
33
|
-
export declare function isInvalidSwapError(err: unknown): boolean;
|
|
34
|
-
export declare function isRecordNotFoundError(err: unknown): boolean;
|
|
35
|
-
type OutputOf<T> = T extends {
|
|
36
|
-
output: infer U;
|
|
37
|
-
} ? U : void;
|
|
38
|
-
type ParamsThenData<T> = T extends {
|
|
39
|
-
params: infer U;
|
|
40
|
-
} ? T extends {
|
|
41
|
-
input: infer V;
|
|
42
|
-
} ? [params: U, data: V] : [params: U] : T extends {
|
|
43
|
-
input: infer W;
|
|
44
|
-
} ? [params: undefined, data: W] : [];
|
|
45
|
-
type DataThenParams<T> = T extends {
|
|
46
|
-
input: infer U;
|
|
47
|
-
} ? T extends {
|
|
48
|
-
params: infer V;
|
|
49
|
-
} ? [data: U, params: V] : [data: U] : T extends {
|
|
50
|
-
params: infer W;
|
|
51
|
-
} ? [data: undefined, params: W] : [];
|
|
52
|
-
export declare class KittyAgent<X extends XRPC = XRPC> {
|
|
53
|
-
readonly xrpc: X;
|
|
54
|
-
constructor(opts: XRPCOptions | X);
|
|
55
|
-
/**
|
|
56
|
-
* Gets a read-only client for bsky.social PDSes.
|
|
57
|
-
*/
|
|
58
|
-
static createUnauthed(service?: string): KittyAgent;
|
|
59
|
-
/**
|
|
60
|
-
* Gets a read-only client for the Bluesky AppView.
|
|
61
|
-
*/
|
|
62
|
-
static createAppview(service?: string): KittyAgent;
|
|
63
|
-
private static readonly pdsAgentCache;
|
|
64
|
-
/**
|
|
65
|
-
* Gets a read-only client for the PDS hosting a specific account via handle or DID.
|
|
66
|
-
*/
|
|
67
|
-
static getOrCreatePds(handleOrDid: string): Promise<KittyAgent<XRPC>>;
|
|
68
|
-
/**
|
|
69
|
-
* Gets an authenticated client for the PDS hosting a specific account via handle or DID.
|
|
70
|
-
*/
|
|
71
|
-
static createPdsWithCredentials(handleOrDid: string): Promise<{
|
|
72
|
-
did: `did:${string}`;
|
|
73
|
-
manager: CredentialManager;
|
|
74
|
-
agent: KittyAgent<XRPC>;
|
|
75
|
-
}>;
|
|
76
|
-
/** Makes a request to the XRPC service */
|
|
77
|
-
request(options: XRPCRequestOptions): Promise<XRPCResponse>;
|
|
78
|
-
query<K extends keyof Queries>(nsid: K, ...args: ParamsThenData<Queries[K]>): Promise<OutputOf<Queries[K]>>;
|
|
79
|
-
call<K extends keyof Procedures>(nsid: K, ...args: DataThenParams<Procedures[K]>): Promise<OutputOf<Procedures[K]>>;
|
|
80
|
-
get<K extends keyof Records>(params: GetRecordParams<K>): Promise<GetRecordOutput<K>>;
|
|
81
|
-
getBlob(params: ComAtprotoSyncGetBlob.Params | {
|
|
82
|
-
did: At.DID;
|
|
83
|
-
cid: At.Blob;
|
|
84
|
-
}): Promise<Uint8Array | string>;
|
|
85
|
-
/**
|
|
86
|
-
* Atcute likes to return blobs as text sometimes. I don't know why yet. This returns them as binary if that
|
|
87
|
-
* happens.
|
|
88
|
-
*/
|
|
89
|
-
getBlobAsBinary(params: ComAtprotoSyncGetBlob.Params | {
|
|
90
|
-
did: At.DID;
|
|
91
|
-
cid: At.Blob;
|
|
92
|
-
}): Promise<Uint8Array<ArrayBufferLike>>;
|
|
93
|
-
/**
|
|
94
|
-
* Atcute likes to return blobs as text sometimes. I don't know why yet. This returns them as text no matter what,
|
|
95
|
-
* and also allows you to specify an encoding.
|
|
96
|
-
*/
|
|
97
|
-
getBlobAsText(params: ComAtprotoSyncGetBlob.Params | {
|
|
98
|
-
did: At.DID;
|
|
99
|
-
cid: At.Blob;
|
|
100
|
-
}, encoding?: string): Promise<string>;
|
|
101
|
-
tryGet<K extends keyof Records>(params: GetRecordParams<K>): Promise<GetRecordOutput<K> | {
|
|
102
|
-
uri: undefined;
|
|
103
|
-
value: undefined;
|
|
104
|
-
cid: undefined;
|
|
105
|
-
}>;
|
|
106
|
-
list<K extends keyof Records>(params: ListRecordsParams<K>): Promise<ListRecordsOutput<K>>;
|
|
107
|
-
put<K extends keyof Records>(params: PutRecordInput<K>): Promise<ComAtprotoRepoPutRecord.Output>;
|
|
108
|
-
uploadBlob(buf: Uint8Array | Blob): Promise<At.Blob<string>>;
|
|
109
|
-
trySwap<K extends keyof Records>(params: PutRecordInput<K>): Promise<boolean>;
|
|
110
|
-
create<K extends keyof Records>(params: CreateRecordInput<K>): Promise<ComAtprotoRepoCreateRecord.Output>;
|
|
111
|
-
delete<K extends keyof Records>(params: DeleteRecordInput<K>): Promise<ComAtprotoRepoDeleteRecord.Output>;
|
|
112
|
-
private paginationHelper;
|
|
113
|
-
paginatedList<K extends keyof Records>(params: {
|
|
114
|
-
repo: string;
|
|
115
|
-
collection: K;
|
|
116
|
-
reverse?: boolean;
|
|
117
|
-
limit?: number;
|
|
118
|
-
}): Promise<ListRecordsOutput<K>>;
|
|
119
|
-
paginatedListBlobs(params: {
|
|
120
|
-
did: At.DID;
|
|
121
|
-
limit?: number;
|
|
122
|
-
}): Promise<{
|
|
123
|
-
cids: string[];
|
|
124
|
-
} & {
|
|
125
|
-
cursor: string | undefined;
|
|
126
|
-
}>;
|
|
127
|
-
paginatedListRepos(params: {
|
|
128
|
-
did: At.DID;
|
|
129
|
-
limit?: number;
|
|
130
|
-
}): Promise<{
|
|
131
|
-
repos: ComAtprotoSyncListRepos.Repo[];
|
|
132
|
-
} & {
|
|
133
|
-
cursor: string | undefined;
|
|
134
|
-
}>;
|
|
135
|
-
batchWrite(params: ComAtprotoRepoApplyWrites.Input): Promise<ComAtprotoRepoApplyWrites.Output>;
|
|
136
|
-
resolveHandle(handle: string): Promise<At.DID>;
|
|
137
|
-
}
|
|
138
|
-
export {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;QACjD,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,CAAC,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAkB3B,kBAAkB,CAAC,MAAM,EAAE;QAC7B,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB;;;gBAjEyC,MAAM,GAAG,SAAS;;IA+EtD,kBAAkB,CAAC,MAAM,EAAE;QAC7B,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB;;;gBAlFyC,MAAM,GAAG,SAAS;;IA+FtD,UAAU,CAAC,MAAM,EAAE,yBAAyB,CAAC,KAAK;IAIlD,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC;CASvD"}
|
package/out/agent.js
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
2
|
-
import { CredentialManager, simpleFetchHandler, XRPC, XRPCError } from "@atcute/client";
|
|
3
|
-
import { AtUri } from "@atproto/syntax";
|
|
4
|
-
import { getDidAndPds } from "./pds-helpers.js";
|
|
5
|
-
import { resolveHandleAnonymously } from "./handles/resolve.js";
|
|
6
|
-
export function isInvalidSwapError(err) {
|
|
7
|
-
return err instanceof XRPCError && err.kind === 'InvalidSwap';
|
|
8
|
-
}
|
|
9
|
-
export function isRecordNotFoundError(err) {
|
|
10
|
-
return err instanceof XRPCError && err.kind === 'RecordNotFound';
|
|
11
|
-
}
|
|
12
|
-
function makeRecordTyped(record) {
|
|
13
|
-
let memoizedAtUri;
|
|
14
|
-
const uri = record.uri; // closure variable
|
|
15
|
-
return {
|
|
16
|
-
...record,
|
|
17
|
-
value: record.value,
|
|
18
|
-
get uri() {
|
|
19
|
-
return memoizedAtUri ??= new AtUri(uri);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function makeRecordsTyped(value) {
|
|
24
|
-
return {
|
|
25
|
-
...value,
|
|
26
|
-
records: value.records.map(makeRecordTyped)
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export class KittyAgent {
|
|
30
|
-
xrpc;
|
|
31
|
-
constructor(opts) {
|
|
32
|
-
this.xrpc = opts instanceof XRPC ? opts : new XRPC(opts);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Gets a read-only client for bsky.social PDSes.
|
|
36
|
-
*/
|
|
37
|
-
static createUnauthed(service = 'https://bsky.social') {
|
|
38
|
-
return new KittyAgent({ handler: simpleFetchHandler({ service }) });
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Gets a read-only client for the Bluesky AppView.
|
|
42
|
-
*/
|
|
43
|
-
static createAppview(service = 'https://api.bsky.app') {
|
|
44
|
-
return new KittyAgent({ handler: simpleFetchHandler({ service }) });
|
|
45
|
-
}
|
|
46
|
-
static pdsAgentCache = new Map();
|
|
47
|
-
/**
|
|
48
|
-
* Gets a read-only client for the PDS hosting a specific account via handle or DID.
|
|
49
|
-
*/
|
|
50
|
-
static async getOrCreatePds(handleOrDid) {
|
|
51
|
-
const did = await resolveHandleAnonymously(handleOrDid);
|
|
52
|
-
const existingAgent = KittyAgent.pdsAgentCache.get(did);
|
|
53
|
-
if (existingAgent)
|
|
54
|
-
return existingAgent;
|
|
55
|
-
const didAndPds = await getDidAndPds(did);
|
|
56
|
-
const agent = KittyAgent.createUnauthed(didAndPds.pds);
|
|
57
|
-
KittyAgent.pdsAgentCache.set(did, agent);
|
|
58
|
-
return agent;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Gets an authenticated client for the PDS hosting a specific account via handle or DID.
|
|
62
|
-
*/
|
|
63
|
-
static async createPdsWithCredentials(handleOrDid) {
|
|
64
|
-
const { did, pds } = await getDidAndPds(handleOrDid);
|
|
65
|
-
const manager = new CredentialManager({ service: pds });
|
|
66
|
-
const agent = new KittyAgent({ handler: manager });
|
|
67
|
-
return { did, manager, agent };
|
|
68
|
-
}
|
|
69
|
-
/** Makes a request to the XRPC service */
|
|
70
|
-
async request(options) {
|
|
71
|
-
return await this.xrpc.request(options);
|
|
72
|
-
}
|
|
73
|
-
async query(nsid, ...args) {
|
|
74
|
-
const [params, data] = args;
|
|
75
|
-
const { data: outData } = await this.xrpc.get(nsid, { params, data, });
|
|
76
|
-
return outData;
|
|
77
|
-
}
|
|
78
|
-
async call(nsid, ...args) {
|
|
79
|
-
const [data, params] = args;
|
|
80
|
-
const { data: outData } = await this.xrpc.call(nsid, { params, data });
|
|
81
|
-
return outData;
|
|
82
|
-
}
|
|
83
|
-
async get(params) {
|
|
84
|
-
const data = makeRecordTyped(await this.query('com.atproto.repo.getRecord', params));
|
|
85
|
-
return data;
|
|
86
|
-
}
|
|
87
|
-
async getBlob(params) {
|
|
88
|
-
if (typeof params.cid !== 'string') {
|
|
89
|
-
params = {
|
|
90
|
-
cid: params.cid.ref.$link,
|
|
91
|
-
did: params.did,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
const data = await this.query('com.atproto.sync.getBlob', params);
|
|
95
|
-
return data;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Atcute likes to return blobs as text sometimes. I don't know why yet. This returns them as binary if that
|
|
99
|
-
* happens.
|
|
100
|
-
*/
|
|
101
|
-
async getBlobAsBinary(params) {
|
|
102
|
-
let blob = await this.getBlob(params);
|
|
103
|
-
if (typeof blob === 'string')
|
|
104
|
-
blob = new TextEncoder().encode(blob);
|
|
105
|
-
return blob;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Atcute likes to return blobs as text sometimes. I don't know why yet. This returns them as text no matter what,
|
|
109
|
-
* and also allows you to specify an encoding.
|
|
110
|
-
*/
|
|
111
|
-
async getBlobAsText(params, encoding) {
|
|
112
|
-
let blob = await this.getBlob(params);
|
|
113
|
-
if (typeof blob !== 'string')
|
|
114
|
-
blob = new TextDecoder(encoding).decode(blob);
|
|
115
|
-
return blob;
|
|
116
|
-
}
|
|
117
|
-
async tryGet(params) {
|
|
118
|
-
try {
|
|
119
|
-
return await this.get(params);
|
|
120
|
-
}
|
|
121
|
-
catch (err) {
|
|
122
|
-
if (!isRecordNotFoundError(err))
|
|
123
|
-
throw err;
|
|
124
|
-
return {
|
|
125
|
-
uri: undefined,
|
|
126
|
-
value: undefined,
|
|
127
|
-
cid: undefined,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
async list(params) {
|
|
132
|
-
const data = makeRecordsTyped(await this.query('com.atproto.repo.listRecords', params));
|
|
133
|
-
return data;
|
|
134
|
-
}
|
|
135
|
-
async put(params) {
|
|
136
|
-
const data = await this.call('com.atproto.repo.putRecord', params);
|
|
137
|
-
return data;
|
|
138
|
-
}
|
|
139
|
-
async uploadBlob(buf) {
|
|
140
|
-
const data = await this.call('com.atproto.repo.uploadBlob', buf);
|
|
141
|
-
return data.blob;
|
|
142
|
-
}
|
|
143
|
-
async trySwap(params) {
|
|
144
|
-
try {
|
|
145
|
-
await this.put(params);
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
catch (err) {
|
|
149
|
-
if (!isInvalidSwapError(err)) {
|
|
150
|
-
throw err;
|
|
151
|
-
}
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
async create(params) {
|
|
156
|
-
const data = await this.call('com.atproto.repo.createRecord', params);
|
|
157
|
-
return data;
|
|
158
|
-
}
|
|
159
|
-
async delete(params) {
|
|
160
|
-
const data = await this.call('com.atproto.repo.deleteRecord', params);
|
|
161
|
-
return data;
|
|
162
|
-
}
|
|
163
|
-
async paginationHelper(limit, key, query, getResults, resultsEqual) {
|
|
164
|
-
const PER_PAGE = 100;
|
|
165
|
-
const results = [];
|
|
166
|
-
let cursor = undefined;
|
|
167
|
-
do {
|
|
168
|
-
const data = await query(cursor, limit === undefined
|
|
169
|
-
? PER_PAGE
|
|
170
|
-
: limit / PER_PAGE > 1
|
|
171
|
-
? PER_PAGE
|
|
172
|
-
: limit);
|
|
173
|
-
const theseResults = getResults(data);
|
|
174
|
-
if (!theseResults.length ||
|
|
175
|
-
theseResults.every(e => results.find(e1 => resultsEqual(e1, e)))) {
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
if (limit !== undefined) {
|
|
179
|
-
limit -= theseResults.length;
|
|
180
|
-
}
|
|
181
|
-
results.push(...theseResults);
|
|
182
|
-
cursor = data.cursor;
|
|
183
|
-
if (!cursor)
|
|
184
|
-
break;
|
|
185
|
-
} while (cursor);
|
|
186
|
-
return { [key]: results, cursor };
|
|
187
|
-
}
|
|
188
|
-
async paginatedList(params) {
|
|
189
|
-
const data = makeRecordsTyped(await this.paginationHelper(params.limit, 'records', async (cursor, limit) => await this.query('com.atproto.repo.listRecords', {
|
|
190
|
-
repo: params.repo,
|
|
191
|
-
collection: params.collection,
|
|
192
|
-
limit,
|
|
193
|
-
reverse: params.reverse ?? true,
|
|
194
|
-
cursor
|
|
195
|
-
}), output => output.records, (a, b) => a.uri === b.uri));
|
|
196
|
-
return data;
|
|
197
|
-
}
|
|
198
|
-
async paginatedListBlobs(params) {
|
|
199
|
-
return await this.paginationHelper(params.limit, 'cids', async (cursor, limit) => await this.query('com.atproto.sync.listBlobs', {
|
|
200
|
-
did: params.did,
|
|
201
|
-
limit,
|
|
202
|
-
cursor
|
|
203
|
-
}), output => output.cids, (a, b) => a === b);
|
|
204
|
-
}
|
|
205
|
-
async paginatedListRepos(params) {
|
|
206
|
-
return await this.paginationHelper(params.limit, 'repos', async (cursor, limit) => await this.query('com.atproto.sync.listRepos', {
|
|
207
|
-
limit,
|
|
208
|
-
cursor
|
|
209
|
-
}), output => output.repos, (a, b) => a.did === b.did);
|
|
210
|
-
}
|
|
211
|
-
async batchWrite(params) {
|
|
212
|
-
return await this.call('com.atproto.repo.applyWrites', params);
|
|
213
|
-
}
|
|
214
|
-
async resolveHandle(handle) {
|
|
215
|
-
if (handle.startsWith('did:'))
|
|
216
|
-
return handle;
|
|
217
|
-
const { did } = await this.query('com.atproto.identity.resolveHandle', {
|
|
218
|
-
handle
|
|
219
|
-
});
|
|
220
|
-
return did;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
//# sourceMappingURL=agent.js.map
|
package/out/agent.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAgE,MAAM,gBAAgB,CAAC;AAEtJ,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAsBhE,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC3C,OAAO,GAAG,YAAY,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAC9C,OAAO,GAAG,YAAY,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,gBAAgB,CAAC;AACrE,CAAC;AAWD,SAAS,eAAe,CAA4C,MAAS;IACzE,IAAI,aAAgC,CAAC;IACrC,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,mBAAmB;IAC3C,OAAO;QACH,GAAG,MAAM;QACT,KAAK,EAAE,MAAM,CAAC,KAAmB;QACjC,IAAI,GAAG;YACH,OAAO,aAAa,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC;KACJ,CAAC;AACN,CAAC;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AC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAC5B,CAAC;IACN,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAuC;QACpD,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,8BAA8B,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAc;QAC9B,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,OAAO,MAAgB,CAAC;QAEvD,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,oCAAoC,EAAE;YACnE,MAAM;SACT,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACf,CAAC"}
|
package/out/cid.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type Cid, type CidLink } from '@atcute/cid';
|
|
2
|
-
import type { At } from '@atcute/client/lexicons';
|
|
3
|
-
export declare function isCidMatching(data: ArrayBufferLike, blob: At.Blob): Promise<boolean>;
|
|
4
|
-
export declare function getSha256(cidOrBlob: At.Blob | CidLink | Cid): string;
|
|
5
|
-
//# sourceMappingURL=cid.d.ts.map
|
package/out/cid.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../src/cid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,OAAO,EAAe,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,yBAAyB,CAAC;AAElD,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,oBAOvE;AAqBD,wBAAgB,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,GAAG,GAAG,UAI3D"}
|
package/out/cid.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// import { sha256 } from '@noble/hashes/sha256';
|
|
2
|
-
import { fromCidLink } from '@atcute/cid';
|
|
3
|
-
export async function isCidMatching(data, blob) {
|
|
4
|
-
const cid = fromCidLink(blob.ref);
|
|
5
|
-
const digest = cid.digest.contents;
|
|
6
|
-
const actualDigest = new Uint8Array(await crypto.subtle.digest('sha-256', data));
|
|
7
|
-
return isEqualBytes(digest, actualDigest);
|
|
8
|
-
}
|
|
9
|
-
// https://stackoverflow.com/a/77736145
|
|
10
|
-
function isEqualBytes(bytes1, bytes2) {
|
|
11
|
-
if (typeof indexedDB !== 'undefined' && indexedDB.cmp) {
|
|
12
|
-
return indexedDB.cmp(bytes1, bytes2) === 0;
|
|
13
|
-
}
|
|
14
|
-
if (bytes1.length !== bytes2.length) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
for (let i = 0; i < bytes1.length; i++) {
|
|
18
|
-
if (bytes1[i] !== bytes2[i]) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
export function getSha256(cidOrBlob) {
|
|
25
|
-
if ('ref' in cidOrBlob)
|
|
26
|
-
cidOrBlob = fromCidLink(cidOrBlob.ref);
|
|
27
|
-
if ('$link' in cidOrBlob)
|
|
28
|
-
cidOrBlob = fromCidLink(cidOrBlob);
|
|
29
|
-
return arrayToHex(cidOrBlob.digest.contents);
|
|
30
|
-
}
|
|
31
|
-
// https://stackoverflow.com/a/39225475
|
|
32
|
-
function arrayToHex(arr) {
|
|
33
|
-
return Array.from(arr).map(numberToHex).join('');
|
|
34
|
-
}
|
|
35
|
-
function numberToHex(i) {
|
|
36
|
-
return i.toString(16).padStart(2, '0');
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=cid.js.map
|
package/out/cid.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cid.js","sourceRoot":"","sources":["../src/cid.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO,EA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AAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED,uCAAuC;AACvC,SAAS,UAAU,CAAC,GAAyC;IACzD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,WAAW,CAAC,CAAS;IAC1B,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
https://github.com/mary-ext/atcute
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
in the Software without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
import type { At } from "@atcute/client/lexicons";
|
|
23
|
-
/**
|
|
24
|
-
* DID document
|
|
25
|
-
*/
|
|
26
|
-
export interface DidDocument {
|
|
27
|
-
id: string;
|
|
28
|
-
alsoKnownAs?: string[];
|
|
29
|
-
verificationMethod?: Array<{
|
|
30
|
-
id: string;
|
|
31
|
-
type: string;
|
|
32
|
-
controller: string;
|
|
33
|
-
publicKeyMultibase?: string;
|
|
34
|
-
}>;
|
|
35
|
-
service?: Array<{
|
|
36
|
-
id: string;
|
|
37
|
-
type: string;
|
|
38
|
-
serviceEndpoint: string | Record<string, unknown>;
|
|
39
|
-
}>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Retrieves AT Protocol PDS endpoint from the DID document, if available
|
|
43
|
-
* @param doc DID document
|
|
44
|
-
* @returns The PDS endpoint, if available
|
|
45
|
-
*/
|
|
46
|
-
export declare function getPdsEndpoint(doc: DidDocument): string | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Retrieve a service endpoint from the DID document, if available
|
|
49
|
-
* @param doc DID document
|
|
50
|
-
* @param serviceId Service ID
|
|
51
|
-
* @param serviceType Service type
|
|
52
|
-
* @returns The requested service endpoint, if available
|
|
53
|
-
*/
|
|
54
|
-
export declare function getServiceEndpoint(doc: DidDocument, serviceId: string, serviceType: string): string | undefined;
|
|
55
|
-
export declare function getDidDocument(did: At.DID): Promise<DidDocument>;
|
|
56
|
-
export declare function getDid(didDoc: DidDocument): At.DID;
|
|
57
|
-
export declare function getHandle(didDoc: DidDocument): string | undefined;
|
|
58
|
-
//# sourceMappingURL=did-document.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"did-document.d.ts","sourceRoot":"","sources":["../../src/handles/did-document.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;EAoBE;AAEF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,yBAAyB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,kBAAkB,CAAC,EAAE,KAAK,CAAC;QACvB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC/B,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,KAAK,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrD,CAAC,CAAC;CACN;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAEnE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAC9B,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GACpB,MAAM,GAAG,SAAS,CAWpB;AAiBD,wBAAsB,cAAc,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CA2CtE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,EAAE,CAAC,GAAG,CAElD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,WAAW,sBAI5C"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
https://github.com/mary-ext/atcute
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
in the Software without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* Retrieves AT Protocol PDS endpoint from the DID document, if available
|
|
24
|
-
* @param doc DID document
|
|
25
|
-
* @returns The PDS endpoint, if available
|
|
26
|
-
*/
|
|
27
|
-
export function getPdsEndpoint(doc) {
|
|
28
|
-
return getServiceEndpoint(doc, '#atproto_pds', 'AtprotoPersonalDataServer');
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Retrieve a service endpoint from the DID document, if available
|
|
32
|
-
* @param doc DID document
|
|
33
|
-
* @param serviceId Service ID
|
|
34
|
-
* @param serviceType Service type
|
|
35
|
-
* @returns The requested service endpoint, if available
|
|
36
|
-
*/
|
|
37
|
-
export function getServiceEndpoint(doc, serviceId, serviceType) {
|
|
38
|
-
const did = doc.id;
|
|
39
|
-
const didServiceId = did + serviceId;
|
|
40
|
-
const found = doc.service?.find((service) => service.id === serviceId || service.id === didServiceId);
|
|
41
|
-
if (!found || found.type !== serviceType || typeof found.serviceEndpoint !== 'string') {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
return validateUrl(found.serviceEndpoint);
|
|
45
|
-
}
|
|
46
|
-
function validateUrl(urlStr) {
|
|
47
|
-
let url;
|
|
48
|
-
try {
|
|
49
|
-
url = new URL(urlStr);
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
const proto = url.protocol;
|
|
55
|
-
if (url.hostname && (proto === 'http:' || proto === 'https:')) {
|
|
56
|
-
return urlStr;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export async function getDidDocument(did) {
|
|
60
|
-
const colon_index = did.indexOf(':', 4);
|
|
61
|
-
const type = did.slice(4, colon_index);
|
|
62
|
-
const ident = did.slice(colon_index + 1);
|
|
63
|
-
// 2. retrieve their DID documents
|
|
64
|
-
let doc;
|
|
65
|
-
if (type === 'plc') {
|
|
66
|
-
const response = await fetch(`https://plc.directory/${did}`);
|
|
67
|
-
if (response.status === 404) {
|
|
68
|
-
throw new Error('did not found in directory');
|
|
69
|
-
}
|
|
70
|
-
if (!response.ok) {
|
|
71
|
-
throw new Error('directory is unreachable');
|
|
72
|
-
}
|
|
73
|
-
const json = await response.json();
|
|
74
|
-
doc = json;
|
|
75
|
-
}
|
|
76
|
-
else if (type === 'web') {
|
|
77
|
-
const DID_WEB_RE = /^([a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*(?:\.[a-zA-Z]{2,}))$/;
|
|
78
|
-
if (!DID_WEB_RE.test(ident)) {
|
|
79
|
-
throw new Error('invalid identifier');
|
|
80
|
-
}
|
|
81
|
-
const response = await fetch(`https://${ident}/.well-known/did.json`);
|
|
82
|
-
if (!response.ok) {
|
|
83
|
-
throw new Error('did document is unreachable');
|
|
84
|
-
}
|
|
85
|
-
const json = await response.json();
|
|
86
|
-
doc = json;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
throw new Error('unsupported did method');
|
|
90
|
-
}
|
|
91
|
-
return doc;
|
|
92
|
-
}
|
|
93
|
-
export function getDid(didDoc) {
|
|
94
|
-
return didDoc.id;
|
|
95
|
-
}
|
|
96
|
-
export function getHandle(didDoc) {
|
|
97
|
-
return didDoc.alsoKnownAs
|
|
98
|
-
?.find(handle => handle.startsWith('at://'))
|
|
99
|
-
?.slice('at://'.length);
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=did-document.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"did-document.js","sourceRoot":"","sources":["../../src/handles/did-document.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;EAoBE;AAuBF;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAgB;IAC3C,OAAO,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,2BAA2B,CAAC,CAAC;AAChF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAC9B,GAAgB,EAChB,SAAiB,EACjB,WAAmB;IAEnB,MAAM,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC;IAEnB,MAAM,YAAY,GAAG,GAAG,GAAG,SAAS,CAAC;IACrC,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,SAAS,IAAI,OAAO,CAAC,EAAE,KAAK,YAAY,CAAC,CAAC;IAEtG,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,KAAK,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;QACpF,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,WAAW,CAAC,MAAc;IAC/B,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACD,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAA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