{"id":18285949,"url":"https://github.com/exodusmovement/secure-container","last_synced_at":"2025-04-05T08:30:45.621Z","repository":{"id":57390897,"uuid":"59775758","full_name":"ExodusMovement/secure-container","owner":"ExodusMovement","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-26T17:19:27.000Z","size":53,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-04-14T13:10:04.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ExodusMovement.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-26T19:01:25.000Z","updated_at":"2024-06-21T16:53:04.589Z","dependencies_parsed_at":"2024-06-21T16:53:03.093Z","dependency_job_id":"657e7513-81ae-4cb1-85ba-231a4f365b49","html_url":"https://github.com/ExodusMovement/secure-container","commit_stats":{"total_commits":45,"total_committers":3,"mean_commits":15.0,"dds":"0.28888888888888886","last_synced_commit":"328128166a57fb3872fcafb3e1d4bc9b41371b5c"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fsecure-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fsecure-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fsecure-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fsecure-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExodusMovement","download_url":"https://codeload.github.com/ExodusMovement/secure-container/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223174744,"owners_count":17100272,"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-05T13:18:19.253Z","updated_at":"2024-11-05T13:18:19.972Z","avatar_url":"https://github.com/ExodusMovement.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"secure-container\n================\n\n[![Build Status](https://travis-ci.org/ExodusMovement/secure-container.svg?branch=master)](https://travis-ci.org/ExodusMovement/secure-container)\n\n\nInstall\n-------\n\n    npm i --save secure-container\n\n\n\nAPI\n-----\n\n### Main Module\n\nThis is the main module most users should use; other modules are for advanced users only.\n\n```js\nimport * as seco from 'secure-container'\n// OR\nconst seco = require('secure-container')\n```\n\n#### `seco.encrypt()`\n\n`encrypt(data, options)`\n\n- `data` (String | Buffer) Data to encrypt\n- `options` (Object)\n  - `header` (Object)\n    - `appName` (String) Name of your app\n    - `appVersion` (String) Version of your app\n  - `passphrase` (String | Buffer) Passphrase used to encrypt the data\n  - `metadata` (Object)\n  - `blobKey` (Buffer)\n\n_Note:_ Must set either `passphrase` or `metadata` \u0026 `blobKey`.\n\nReturns an Object that contains:\n\n- `encryptedData` (Buffer) The encrypted data\n- `blobKey` (Buffer)\n- `metadata` (Object)\n\n#### `seco.decrypt()`\n\n`decrypt(encryptedData, passphrase)`\n\n- `encryptedData` (Buffer) Data to decrypt\n- `passphrase` (String | Buffer) Passphrase to decrypt the data\n\nReturns an Object that contains:\n\n- `data` (Buffer) The file data\n- `header` (Object) The header for the secure-container\n- `blobKey` (Buffer)\n- `metadata` (Object)\n\n### `header` module\n\n```js\nimport * as header from 'secure-container/lib/header'\n// OR\nconst header = require('secure-container/lib/header')\n```\n\n#### `header.create(data)`\n\nCreate a header object.\n\n- `data` (Object)\n  - `appName` (String) Name of your app\n  - `appVersion` (String) Version of your app\n\nReturns an Object.\n\n#### `header.serialize(headerObj)`\n\nSerialize a header object. `headerObj` is a header object made with `create()`. Returns a Buffer.\n\n#### `header.decode(buffer)`\n\nDecodes a header buffer and returns the Object.\n\n### `metadata` module\n\n```js\nimport * as metadata from 'secure-container/lib/metadata'\n// OR\nconst metadata = require('secure-container/lib/metadata')\n```\n\n#### `metadata.create()`\n\nCreate a metadata object. Returns an Object.\n\n#### `metadata.encryptBlobKey(metadata, passphrase, blobKey)`\n\n- `metadata` (Object) Metadata created with `metadata.create()`.\n- `passphrase` (String | Buffer)\n- `blobKey` (Buffer)\n\nMutates `metadata` object; returns `undefined`.\n\n#### `metadata.serialize(metadata)`\n\nSerialize a metadata object. Returns a Buffer.\n\n#### `metadata.decode(buffer)`\n\nTakes a metadata buffer, decodes it, and returns an object.\n\n#### `metadata.decryptBlobKey(metadata, passphrase)`\n\n- `metadata` (Object) Metadata with an encrypted blobKey.\n- `passphrase` (String | Buffer)\n\nReturns `blobKey` as a buffer.\n\n### `blob` module\n\n```js\nimport * as blob from 'secure-container/lib/blob'\n// OR\nconst blob = require('secure-container/lib/blob')\n```\n\n#### `blob.encrypt(data, metadata, blobKey)`\n\n- `data` (Buffer) Data or message to encrypt.\n- `metadata` (Object) Metadata object.\n- `blobKey` (Buffer)\n\nMutates `metadata`. Returns an object:\n\n- `blob` (Buffer) Encrypted data.\n- `blobKey` (Buffer) The `blobKey` you passed in.\n\n#### `blob.decrypt(blob, metadata, blobKey)`\n\n- `blob` (Buffer) Encrypted data.\n- `metadata` (Object) Metadata object.\n- `blobKey` (Buffer)\n\nReturns the decrypted data as a buffer.\n\n### `file` module\n\n```js\nimport * as file from 'secure-container/lib/file'\n// OR\nconst file = require('secure-container/lib/file')\n```\n\n#### `file.computeChecksum(metadata, blob)`\n\n- `metadata` (Buffer) Metadata as a Buffer\n- `blob` (Buffer) Encrypted blob\n\nReturns a `sha256` checksum as a buffer.\n\n#### `file.encode(fileObj)`\n\n- `fileObj` (Object)\n  - `header` (Buffer) Serialized header\n  - `checksum` (Buffer) Checksum from `file.computeChecksum()`\n  - `metadata` (Buffer) Metadata as a Buffer\n  - `blob` (Buffer) Encrypted blob\n\nReturns a buffer.\n\n#### `file.decode(fileBuffer)`\n\nThe opposite of `file.encode()`. Takes a buffer and returns an object.\n\nFile Format Description\n-----------\n\nThis is the documentation for the binary structure of secure containers.\n\nFor clarity, we have split the documentation into four sections: `header`, `checksum`, `metadata`, and `blob`.\n\n### Header\n\nSize | Label | Description |\n---- | ----- | ----------- |\n4 | `magic` | The magic header indicating the file type. Always `SECO`.\n4 | `version` | File format version. Currently `0`, stored as `UInt32BE`.\n4 | `reserved` | Reserved for future use.\n1 | `versionTagLength` | Length of `versionTag` as `UInt8`.\n`versionTagLength` | `versionTag` | Should be `'seco-v0-scrypt-aes'`.\n1 | `appNameLength` | Length of `appName` as `UInt8`.\n`appNameLength` | `appName` | Name of the application writing the file.\n1 | `appVersionLength` | Length of `appVersion` as `UInt8`.\n`appVersionLength` | `appVersion` | Version of the application writing the file.\n\n### Checksum\n\n32-byte `sha256` checksum of the following data:\n\n1. The `metadata`.\n1. Byte-length of the `blob`, stored as `UInt32BE`.\n1. The `blob`.\n\n### Metadata\n\nSize | Label | Description |\n---- | ----- | ----------- |\n32 | `salt` | Scrypt salt.\n4 | `n` | Scrypt `n` parameter.\n4 | `r` | Scrypt `r` parameter.\n4 | `p` | Scrypt `p` parameter.\n32 | `cipher` | Currently `aes-256-gcm` stored as a zero-terminated C-string.\n12 | `iv` | `blobKey`'s `iv`.\n16 | `authTag` | `blobKey`'s `authTag`.\n32 | `key` | `blobKey`'s `key`.\n12 | `iv` | The `blob`'s `iv`.\n16 | `authTag` | The `blob`'s `authTag`.\n\n### Blob\n\nSize | Label | Description |\n---- | ----- | ----------- |\n4 | `blobLength` | Length of `blob` as `UInt32BE`.\n`blobLength` | `blob` | Encrypted data.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexodusmovement%2Fsecure-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexodusmovement%2Fsecure-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexodusmovement%2Fsecure-container/lists"}