-
Notifications
You must be signed in to change notification settings - Fork 6
/
post-disguised-link.ts
53 lines (49 loc) · 1.56 KB
/
post-disguised-link.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { createRecord } from '../helpers/Records';
import { getSession } from '../helpers/Session';
import { ExploitModule } from '../lib/CommandModules';
import { Post } from '../lib/bsky/Post';
export async function postDisguisedLink(
authToken: string,
text: string,
uri: string,
start: number,
length: number
): Promise<void> {
const session = await getSession(authToken);
const post: Post = {
$type: 'app.bsky.feed.post',
createdAt: new Date().toISOString(),
text: text,
facets: [
{
index: { byteStart: start, byteEnd: start + length },
features: [{ $type: 'app.bsky.richtext.facet#link', uri: uri }],
},
],
};
const record = await createRecord(authToken, session.did, 'app.bsky.feed.post', post);
if (record.cid && record.uri) {
console.log(`Success! cid=${record.cid}, uri=${record.uri}}`);
}
}
const commandModule: ExploitModule<{
post: string;
uri: string;
start: number;
length: number;
}> = {
command: 'pdl',
describe: 'Create post with disguised link.',
builder: (args) => {
return args.options({
post: { desc: "The post's text.", type: 'string', demandOption: true },
uri: { desc: 'URI to use in href=.', type: 'string', demandOption: true },
start: { desc: 'Link start position.', type: 'number', demandOption: true },
length: { desc: 'Link length.', type: 'number', demandOption: true },
});
},
handler: async (argv) => {
await postDisguisedLink(argv.authToken, argv.post, argv.uri, argv.start, argv.length);
},
};
export { commandModule as command };