{"id":16515206,"url":"https://github.com/pine/safe-storage","last_synced_at":"2025-09-20T20:32:02.151Z","repository":{"id":251368992,"uuid":"834325064","full_name":"pine/safe-storage","owner":"pine","description":"[WIP] Electron-like encryption/decryption API for Node.js and browsers","archived":false,"fork":false,"pushed_at":"2025-01-04T08:12:00.000Z","size":42,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-04T09:21:57.864Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/pine.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-07-27T00:19:23.000Z","updated_at":"2025-01-04T08:12:03.000Z","dependencies_parsed_at":"2024-08-02T14:41:25.088Z","dependency_job_id":"e42ac79e-9d77-4292-9b50-47fbae7e15c9","html_url":"https://github.com/pine/safe-storage","commit_stats":null,"previous_names":["pine/safe-storage"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pine%2Fsafe-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pine%2Fsafe-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pine%2Fsafe-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pine%2Fsafe-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pine","download_url":"https://codeload.github.com/pine/safe-storage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233686189,"owners_count":18714104,"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-10-11T16:16:05.937Z","updated_at":"2025-09-20T20:32:02.138Z","avatar_url":"https://github.com/pine.png","language":"JavaScript","readme":"# safe-storage\n\n![NPM Version](https://img.shields.io/npm/v/%40pinemz%2Fsafe-storage)\n[![Test](https://github.com/pine/safe-storage/actions/workflows/test.yml/badge.svg)](https://github.com/pine/safe-storage/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/pine/safe-storage/graph/badge.svg?token=mrSLYH77nf)](https://codecov.io/gh/pine/safe-storage)\n\n\u003e Electron-like encryption/decryption API for Node.js and browsers\n\n## Features\n\n- Only ESM is supported as a module system (CJS is not supported)\n- Supports Node.js (\u003e= v19.0.0) and modern browsers\n- Provides TypeScript type definitions as default\n\n## Getting started\n### Install\n\nFirst, install this package as follows:\n```bash\n# For npm users\n$ npm install --save @pinemz/safe-storage\n\n# For yarn users\n$ yarn add @pinemz/safe-storage\n\n# For pnpm users\n$ pnpm add @pinemz/safe-storage\n```\n\n### Usage\nAfter installation, use the CLI to encrypt any text:\n\n```bash\n# Encrypts using a password stored in the OS keychain.\n# (If none exists, it will be generated automatically and stored in the OS keychain)\n$ safe-storage encrypt -s \u003cservice\u003e -a \u003caccount\u003e \u003ctext to encrypt\u003e\n```\n\nFinally, decrypt the encrypted text in your script:\n```js\nimport { Keychain, SafeStorage } from '@pinemz/safe-storage'\n\nconst keychain = new Keychain('\u003cservice\u003e', '\u003caccount\u003e')\nconst safeStorage = new SafeStorage(await keychain.getOrCreatePassword())\n\nconst decryptedText = safeStorage.decryptString('\u003cencrypted text\u003e')\nconsole.log(decryptedText)\n```\n\n## References\n### CLI\n\n```bash\n$ safe-storage --help\nUsage: safe-storage \u003ccommand\u003e \u003coptions\u003e \u003cinputs\u003e\n\nEncryption command:\n  Encryption requires -s and -a or -p.\n  If you use -s and -a, save your password in your keychain beforehand,\n  otherwise a new password will be generated and saved.\n\n  $ safe-storage encrypt -s \u003cservice\u003e -a \u003caccount\u003e \u003cplainText\u003e\n  $ safe-storage encrypt -p \u003cpassword\u003e \u003cplainText\u003e\n\nDecryption command:\n  Decryption requires -s and -a or -p.\n  If you use -s and -a, save your password in your keychain beforehand,\n  otherwise a new password will be generated and saved.\n\n  $ safe-storage decrypt -s \u003cservice\u003e -a \u003caccount\u003e \u003cencryptedText\u003e\n  $ safe-storage decrypt -p \u003cpassword\u003e \u003cencryptedText\u003e\n\nOptions:\n  -s/--service  : Specify keychain service\n  -a/--account  : Specify keychain account\n  -p/--password : Specify password directly in plain text\n  -v/--version  : Show package version\n  -h/--help     : Show help\n```\n\n## API\n- [API Reference](https://pine.github.io/safe-storage/)\n\n## FAQ\n### Q. Is this library only available for macOS?\nNo, it is also available for Linux and Windows.\n\nThis library uses _[keytar](https://www.npmjs.com/package/keytar)_ to access keychain when running on Node.js.\n_keytar_ supports not only macOS, but also Linux and Windows.\n\n## License\nMIT \u0026copy; Pine Mizune\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpine%2Fsafe-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpine%2Fsafe-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpine%2Fsafe-storage/lists"}