{"id":21529684,"url":"https://github.com/samsamskies/nostr-build","last_synced_at":"2026-03-15T12:41:59.837Z","repository":{"id":252301755,"uuid":"839568673","full_name":"SamSamskies/nostr-build","owner":"SamSamskies","description":"Utilities for working with nostr.build media.","archived":false,"fork":false,"pushed_at":"2024-08-09T17:50:29.000Z","size":368,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T23:51:34.088Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SamSamskies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-07T22:10:14.000Z","updated_at":"2025-02-16T18:20:37.000Z","dependencies_parsed_at":"2024-08-08T22:51:04.312Z","dependency_job_id":"ad60b4b2-67ca-4291-91a0-3830bc4641a0","html_url":"https://github.com/SamSamskies/nostr-build","commit_stats":null,"previous_names":["samsamskies/nostr-build"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamSamskies%2Fnostr-build","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamSamskies%2Fnostr-build/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamSamskies%2Fnostr-build/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamSamskies%2Fnostr-build/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SamSamskies","download_url":"https://codeload.github.com/SamSamskies/nostr-build/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131454,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T01:58:41.001Z","updated_at":"2026-03-15T12:41:54.797Z","avatar_url":"https://github.com/SamSamskies.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nostr-build\n[![NPM](https://img.shields.io/npm/v/nostr-build.svg)](https://www.npmjs.com/package/nostr-build)\n\nUtilities for working with [nostr.build](https://nostr.build/) media.\n\n## Installation\n\nInstall the package with:\n\n```bash\nnpm i nostr-build\n# or\nyarn add nostr-build\n```\n\n## Usage\n\n- [uploadFile](#uploadFile) - Allows you to upload a file to nostr.build which complies with the [NIP-96](https://github.com/nostr-protocol/nips/blob/master/96.md) standard\n- [deleteFile](#deleteFile) - Allows you to delete a file from nostr.build which complies complies with the [NIP-96](https://github.com/nostr-protocol/nips/blob/master/96.md) standard\n\n### uploadFile\n\nAllows you to upload a file to nostr.build which complies with the [NIP-96](https://github.com/nostr-protocol/nips/blob/master/96.md) standard.\n\n```\n{\n    file: File; // The file to be uploaded, represented as a `File` object.\n    options?: {\n        /**\n         * Specifies the desired expiration time of the file on the server.\n         * It should be a string representing a UNIX timestamp in seconds.\n         * An empty string indicates that the file should be stored indefinitely.\n         */\n        expiration?: string;\n        /**\n         * Indicates the size of the file in bytes.\n         * This field can be used by the server to pre-validate the file size before processing the upload.\n         */\n        size?: string;\n        /**\n         * Provides a strict description of the file for accessibility purposes,\n         * particularly useful for visibility-impaired users.\n         */\n        alt?: string;\n        /**\n         * A loose, more descriptive caption for the file.\n         * This can be used for additional context or commentary about the file.\n         */\n        caption?: string;\n        /**\n         * Specifies the intended use of the file.\n         * Can be either 'avatar' or 'banner', indicating if the file is to be used as an avatar or a banner.\n         * Absence of this field suggests standard file upload without special treatment.\n         */\n        media_type?: \"avatar\" | \"banner\";\n        /**\n         * The MIME type of the file being uploaded.\n         * This can be used for early rejection by the server if the file type isn't supported.\n         */\n        content_type?: string;\n        /**\n         * Other custom form data fields.\n         */\n        [key: string]: string | undefined;\n    };\n    sign: (event: EventTemplate) =\u003e Promise\u003cEvent\u003e // nostr signing function;\n}\n\n@returns Promise\u003c{\n    /**\n     * The status of the upload request.\n     * - 'success': Indicates the file was successfully uploaded.\n     * - 'error': Indicates there was an error in the upload process.\n     * - 'processing': Indicates the file is still being processed (used in cases of delayed processing).\n     */\n    status: \"success\" | \"error\" | \"processing\";\n    /**\n     * A message provided by the server, which could be a success message, error description, or processing status.\n     */\n    message: string;\n    /**\n     * Optional. A URL provided by the server where the upload processing status can be checked.\n     * This is relevant in cases where the file upload involves delayed processing.\n     */\n    processing_url?: string;\n    /**\n     * Optional. An event object conforming to NIP-94, which includes details about the uploaded file.\n     * This object is typically provided in the response for a successful upload and contains\n     * essential information such as the download URL and file metadata.\n     */\n    nip94_event?: {\n        /**\n         * A collection of key-value pairs (tags) providing metadata about the uploaded file.\n         * Standard tags include:\n         * - 'url': The URL where the file can be accessed.\n         * - 'ox': The SHA-256 hash of the original file before any server-side transformations.\n         * Additional optional tags might include file dimensions, MIME type, etc.\n         */\n        tags: Array\u003c[string, string]\u003e;\n        /**\n         * A content field, which is typically empty for file upload events but included for consistency with the NIP-94 structure.\n         */\n        content: string;\n    };\n}\u003e\n```\n\nExample:\n\n```jsx\nimport { uploadFile } from \"nostr-build\";\n\nexport default function App() {\n  const handleFileChange = async (event) =\u003e {\n    const file = event.target.files[0];\n\n    console.log(\n      await uploadFile({\n        file,\n        sign: (event) =\u003e window.nostr.signEvent(event),\n      })\n    );\n  };\n\n  return (\n    \u003cdiv className=\"App\"\u003e\n      \u003cinput type=\"file\" onChange={handleFileChange} /\u003e\n    \u003c/div\u003e\n  );\n}\n\n```\n\n### deleteFile\n\nAllows you to delete a file from nostr.build which complies complies with the [NIP-96](https://github.com/nostr-protocol/nips/blob/master/96.md) standard\n\n```\nfileHashOrFileName: string; // The file hash for free accounts or file name for premium accounts.\nsign: (event: EventTemplate) =\u003e Promise\u003cEvent\u003e // nostr signing function\n\n@returns Promise\u003cany\u003e\n```\n\nExample:\n\n```js\nimport { deleteFile } from \"nostr-build\";\n\nconst fileName = 'exampleFileNameOnNostrBuild.jpg';\nconst sign = (event) =\u003e window.nostr.signEvent(event);\n\ndeleteFile(fileName, sign)\n  .then(console.log)\n  .catch(console.error);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsamskies%2Fnostr-build","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamsamskies%2Fnostr-build","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsamskies%2Fnostr-build/lists"}