From 4729016fb98e7045ee4043857be7eef780c01e35 Mon Sep 17 00:00:00 2001 From: Luan Date: Mon, 25 Nov 2024 03:23:23 -0300 Subject: [PATCH] feat(parser): Add `RunAttestationCommand` Can be used to get attestation responses from BotGuard, assuming you have a VM (retrieved using the `/att/get` endpoint, with engagement type set to `ENGAGEMENT_TYPE_UNBOUND`) loaded up. --- .../classes/commands/RunAttestationCommand.ts | 37 +++++++++++++++++++ src/parser/nodes.ts | 1 + src/parser/parser.ts | 1 - 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/parser/classes/commands/RunAttestationCommand.ts diff --git a/src/parser/classes/commands/RunAttestationCommand.ts b/src/parser/classes/commands/RunAttestationCommand.ts new file mode 100644 index 000000000..d0c1625d2 --- /dev/null +++ b/src/parser/classes/commands/RunAttestationCommand.ts @@ -0,0 +1,37 @@ +import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../types/index.js'; + +export type AttIds = { + encrypted_video_id?: string; + external_channel_id?: string; + comment_id?: string; + external_owner_id?: string; + artist_id?: string; + playlist_id?: string; + external_post_id?: string; + share_id?: string; +} + +export default class RunAttestationCommand extends YTNode { + static type = 'RunAttestationCommand'; + + public engagement_type: string; + public ids?: AttIds[]; + + constructor(data: RawNode) { + super(); + this.engagement_type = data.engagementType; + if (Reflect.has(data, 'ids')) { + this.ids = data.ids.map((id: RawNode) => ({ + encrypted_video_id: id.encryptedVideoId, + external_channel_id: id.externalChannelId, + comment_id: id.commentId, + external_owner_id: id.externalOwnerId, + artist_id: id.artistId, + playlist_id: id.playlistId, + external_post_id: id.externalPostId, + share_id: id.shareId + })); + } + } +} \ No newline at end of file diff --git a/src/parser/nodes.ts b/src/parser/nodes.ts index f9d00b876..65919e73b 100644 --- a/src/parser/nodes.ts +++ b/src/parser/nodes.ts @@ -70,6 +70,7 @@ export { default as AddToPlaylistCommand } from './classes/commands/AddToPlaylis export { default as CommandExecutorCommand } from './classes/commands/CommandExecutorCommand.js'; export { default as ContinuationCommand } from './classes/commands/ContinuationCommand.js'; export { default as GetKidsBlocklistPickerCommand } from './classes/commands/GetKidsBlocklistPickerCommand.js'; +export { default as RunAttestationCommand } from './classes/commands/RunAttestationCommand.js'; export { default as ShowDialogCommand } from './classes/commands/ShowDialogCommand.js'; export { default as AuthorCommentBadge } from './classes/comments/AuthorCommentBadge.js'; export { default as CommentActionButtons } from './classes/comments/CommentActionButtons.js'; diff --git a/src/parser/parser.ts b/src/parser/parser.ts index d0faa4121..1e87891a5 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -78,7 +78,6 @@ const IGNORED_LIST = new Set([ 'PrimetimePromo', 'BackgroundPromo', 'PromotedSparklesWeb', - 'RunAttestationCommand', 'CompactPromotedVideo', 'BrandVideoShelf', 'BrandVideoSingleton',