{"id":21178668,"url":"https://github.com/primno/dpapi","last_synced_at":"2025-07-09T22:31:45.325Z","repository":{"id":63732323,"uuid":"570289550","full_name":"primno/dpapi","owner":"primno","description":"Prebuilt native module (Node.JS) to encrypt data on Windows with DPAPI.","archived":false,"fork":false,"pushed_at":"2023-10-07T10:02:01.000Z","size":258,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-03T08:50:55.621Z","etag":null,"topics":["dpapi","nodejs","prebuilt"],"latest_commit_sha":null,"homepage":"https://primno.io","language":"C++","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/primno.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-24T20:00:48.000Z","updated_at":"2024-10-06T00:02:33.000Z","dependencies_parsed_at":"2024-06-20T23:41:06.833Z","dependency_job_id":"fe46c5a1-20ea-4c8c-8889-d6ffd8ae5153","html_url":"https://github.com/primno/dpapi","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.1333333333333333,"last_synced_commit":"4e92a98947c0c21ad2848971df840f32ff7c1a7e"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primno%2Fdpapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primno%2Fdpapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primno%2Fdpapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primno%2Fdpapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/primno","download_url":"https://codeload.github.com/primno/dpapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225598779,"owners_count":17494394,"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":["dpapi","nodejs","prebuilt"],"created_at":"2024-11-20T17:23:07.639Z","updated_at":"2025-07-09T22:31:45.319Z","avatar_url":"https://github.com/primno.png","language":"C++","readme":"# DPAPI\n[![npm](https://img.shields.io/npm/v/@primno/dpapi.svg)](https://www.npmjs.com/package/@primno/dpapi)\n[![npm](https://img.shields.io/npm/l/@primno/dpapi.svg)](https://github.com/primno/dpapi/blob/main/LICENSE)\n![build](https://img.shields.io/github/actions/workflow/status/primno/dpapi/test.yml)\n[![coverage](https://codecov.io/gh/primno/dpapi/branch/main/graph/badge.svg?token=J4AVWIOR9F)](https://codecov.io/gh/primno/dpapi)\n\nNative module to encrypt/decrypt data on Windows with DPAPI.\n\nThis native module is **prebuilt** for Node.JS running on Windows. It provides the **x64** and the **arm64** N-API modules for Windows.\n\nThis package indicates if the prebuilt module is supported on the current platform.\n\nBased on the port to N-API made by [Microsoft](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/extensions/msal-node-extensions/src/dpapi-addon) in @msal-node-extension from the work of [Brad Hughes](https://github.com/bradhugh/node-dpapi).\n\n\u003e This package is part of the [Primno](https://primno.io) framework.\n\n## Why this package?\n\nOther similar packages require to build the native module on the target machine during the installation.\nThis means that you must have Python and Visual C++ installed, production environment included.\n\nThis package is prebuilt, so you don't need to have build tools installed on the target machine.\n\n## Install\n\nThe prebuilt module will be installed with the following command.\n\n```bash\nnpm install @primno/dpapi\n```\n\n## Definition\n\n```ts\nclass Dpapi {\n    public protectData(\n        userData: Uint8Array,\n        optionalEntropy: Uint8Array | null,\n        scope: \"CurrentUser\" | \"LocalMachine\"\n    ): Uint8Array;\n\n    public unprotectData(\n        encryptedData: Uint8Array,\n        optionalEntropy: Uint8Array | null,\n        scope: \"CurrentUser\" | \"LocalMachine\"\n    ): Uint8Array;\n}\n\nconst isPlatformSupported: boolean;\n```\n\n## Usage\n\n### ECMAScript Module\n```ts\nimport { Dpapi, isPlatformSupported } from \"@primno/dpapi\";\n\nif (isPlatformSupported) {\n    const buffer = Buffer.from(\"Hello world\", \"utf-8\");\n\n    const encrypted = Dpapi.protectData(buffer, null, \"CurrentUser\");\n    const decrypted = Dpapi.unprotectData(encrypted, null, \"CurrentUser\");\n}\nelse {\n    console.error(\"Platform not supported. Only Windows is supported (x64, ARM64)\");\n}\n```\n\n### CommonJS\n```js\nconst { Dpapi, isPlatformSupported } = require(\"@primno/dpapi\");\n\nif (isPlatformSupported) {\n    const buffer = Buffer.from(\"Hello world\", \"utf-8\");\n\n    const encrypted = Dpapi.protectData(buffer, null, \"CurrentUser\");\n    const decrypted = Dpapi.unprotectData(encrypted, null, \"CurrentUser\");\n}\nelse {\n    console.error(\"Platform not supported. Only Windows is supported (x64, ARM64)\");\n}\n```\n\n## Credits\n\n- Brad Hughes for the original code.\n- Microsoft for the N-API port in MSAL-Node-Extension.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimno%2Fdpapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprimno%2Fdpapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimno%2Fdpapi/lists"}