Skip to content

Commit c104a31

Browse files
committed
docs(lib): add JSDoc to base64url and getFrame functions
1 parent 080d613 commit c104a31

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/frames.js/src/getFrame.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@ type GetFrameOptions = {
3535

3636
/**
3737
* Extracts frame metadata from the given htmlString.
38+
* Parses the HTML and extracts frame information based on the specified protocol.
3839
*
39-
* @returns an object representing the parsing result
40+
* @param options - Configuration options for frame extraction
41+
* @param options.htmlString - The HTML string to parse
42+
* @param options.frameUrl - URL to the frame
43+
* @param options.url - Fallback URL used if post_url is missing
44+
* @param options.specification - The parsing specification (default: 'farcaster')
45+
* @param options.fromRequestMethod - Request method used to fetch the frame (default: 'GET')
46+
* @returns An object representing the parsing result with frame data and any reports
4047
*/
4148
export async function getFrame({
4249
htmlString,

packages/frames.js/src/lib/base64url.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Encodes a Buffer to a URL-safe base64 string.
3+
* Replaces '+' with '-', '/' with '_', and removes padding '='.
4+
* @param data - The buffer to encode
5+
* @returns URL-safe base64 encoded string
6+
*/
17
export function base64urlEncode(data: Buffer): string {
28
// we could use .toString('base64url') on buffer, but that throws in browser
39
return data
@@ -7,6 +13,12 @@ export function base64urlEncode(data: Buffer): string {
713
.replace(/=/g, "");
814
}
915

16+
/**
17+
* Decodes a URL-safe base64 string back to a Buffer.
18+
* Handles the reverse transformations of base64urlEncode.
19+
* @param encodedData - The URL-safe base64 string to decode
20+
* @returns Decoded buffer
21+
*/
1022
export function base64urlDecode(encodedData: string): Buffer {
1123
const encodedChunks = encodedData.length % 4;
1224
const base64 = encodedData
@@ -17,3 +29,4 @@ export function base64urlDecode(encodedData: string): Buffer {
1729
// we could use base64url on buffer, but that throws in browser
1830
return Buffer.from(base64, "base64");
1931
}
32+

0 commit comments

Comments
 (0)