Skip to content

Add IconsClient.getPublic() for reading public icons across accounts#368

Open
lucasrosa90 wants to merge 1 commit into
mainfrom
feature/icons-get-public
Open

Add IconsClient.getPublic() for reading public icons across accounts#368
lucasrosa90 wants to merge 1 commit into
mainfrom
feature/icons-get-public

Conversation

@lucasrosa90

Copy link
Copy Markdown
Contributor

Adds a way to download a public icon's bytes, including one that belongs to another account, instead of only being able to mint a public URL.

Changes

  • New getPublic() on IconsClient to download a public icon's bytes, including one that belongs to another account. Returns { data, mimeType }, or null when there's nothing there.
  • Backed by getPublicContent() on the session and provider. It mints the public URL, fetches it, and lets the anchor decrypt server-side via /api/public, so the caller never needs the owner's key.
  • Added tests for the own-icon round-trip, parity with get(), not-found and post-delete cases, and cross-account reads (plus a negative test for the owner-pinned policy). Added an AnySignerTestPathPolicy and harness to model the deployed behavior.

@lucasrosa90 lucasrosa90 requested a review from sephynox June 11, 2026 22:46
@lucasrosa90 lucasrosa90 self-assigned this Jun 11, 2026
@lucasrosa90 lucasrosa90 added the enhancement New feature or request label Jun 11, 2026
@sonarqubecloud

Copy link
Copy Markdown

@lucasrosa90 lucasrosa90 requested a review from ezraripps June 11, 2026 23:19
async getPublicContent(
relativePath: string,
options?: { ttl?: number }
): Promise<{ data: Buffer; mimeType: string } | null> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this type just a Blob ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkeene It is, but as get was already using this type I just did the same:

async get(relativePath: string): Promise<{ data: Buffer; mimeType: string } | null> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed Blob is the cleaner type conceptually, but I'd keep { data: Buffer; mimeType } for now:

  • It's symmetric with put() (we write a Buffer, so we read one back) and consistent with IconData/the rest of the storage API.
  • Consumer needs sync .toString('base64') for data URLs and Blob forces an extra await blob.arrayBuffer().
  • Changing get() return is breaking on a published lib.

@lucasrosa90 lucasrosa90 requested a review from rkeene June 15, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants