{"_id":"@ankarhem/secrecy-ts","_rev":"1-a96e6a6632fa5f3f01cd0d59a9a1d9b1","name":"@ankarhem/secrecy-ts","dist-tags":{"latest":"0.1.7"},"versions":{"0.1.6":{"name":"@ankarhem/secrecy-ts","version":"0.1.6","license":"MIT","_id":"@ankarhem/secrecy-ts@0.1.6","maintainers":[{"name":"jakobankarhem","email":"jakob.ankarhem@outlook.com"}],"homepage":"https://github.com/ankarhem/secrecy-ts#readme","bugs":{"url":"https://github.com/ankarhem/secrecy-ts/issues"},"dist":{"shasum":"ecad3c3821a0b74a6c76c3c5d1eebe155311dad8","tarball":"https://registry.npmjs.org/@ankarhem/secrecy-ts/-/secrecy-ts-0.1.6.tgz","fileCount":81,"integrity":"sha512-QbaQsVTlkD4PQ2kD+Qdpy8UT6pfN2RlRVIINq4aMSakXQnVmjHDKZ9ehbDam6y/taVav4HVe9z6HWNkEEAmcJg==","signatures":[{"sig":"MEUCIE9MM8A5DlAvcoUnCvVQP7F2AXlKLI4J+cxUOQbxTfLKAiEA7PQklu5yOyf/gyVhMD8CJOSBBLEXtkEdu6IG7Af6gyU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ankarhem%2fsecrecy-ts@0.1.6","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":44269},"main":"./script/mod.js","types":"./script/mod.d.ts","module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"}},"gitHead":"4d171a7349a2685963c692687c78d041842dd905","scripts":{"test":"node test_runner.js"},"_npmUser":{"name":"jakobankarhem","email":"jakob.ankarhem@outlook.com"},"repository":{"url":"git+https://github.com/ankarhem/secrecy-ts.git","type":"git"},"_npmVersion":"10.8.2","description":"A TypeScript port of the Rust secrecy crate. Wrap secrets in a type to ensure they are not exposed.","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"picocolors":"^1.0.0","@types/node":"^20.9.0","@deno/shim-deno":"~0.18.0"},"_npmOperationalInternal":{"tmp":"tmp/secrecy-ts_0.1.6_1731156180743_0.6234576706645751","host":"s3://npm-registry-packages"}},"0.1.7":{"name":"@ankarhem/secrecy-ts","version":"0.1.7","description":"A TypeScript port of the Rust secrecy crate. Wrap secrets in a type to ensure they are not exposed.","repository":{"type":"git","url":"git+https://github.com/ankarhem/secrecy-ts.git"},"license":"MIT","bugs":{"url":"https://github.com/ankarhem/secrecy-ts/issues"},"main":"./script/mod.js","module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"}},"scripts":{"test":"node test_runner.js"},"devDependencies":{"@types/node":"^20.9.0","picocolors":"^1.0.0","@deno/shim-deno":"~0.18.0"},"_id":"@ankarhem/secrecy-ts@0.1.7","gitHead":"babeea530c70553778d8e00e1149066299bd2df2","types":"./script/mod.d.ts","homepage":"https://github.com/ankarhem/secrecy-ts#readme","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-oReaL1icDDeEBGu3tm3DoM/+Jo26Tr9rzDcPHJKjiMk+6zqG0Pq1VZ96fW5MgdwUd0m0E+CVDU/C+TTNWNBgeg==","shasum":"75a3dda9f6c32e5d0c8cf128351bfc698fd1ca10","tarball":"https://registry.npmjs.org/@ankarhem/secrecy-ts/-/secrecy-ts-0.1.7.tgz","fileCount":82,"unpackedSize":45876,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ankarhem%2fsecrecy-ts@0.1.7","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCjv90uwBGqeHIS96iXIPosyvDocQ9QV+cgfiHg9e0JgwIgL3mwEIgpx178gO8/zI/i/36hbKETraDmB/+KOQfQI6E="}]},"_npmUser":{"name":"jakobankarhem","email":"jakob.ankarhem@outlook.com"},"directories":{},"maintainers":[{"name":"jakobankarhem","email":"jakob.ankarhem@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/secrecy-ts_0.1.7_1731156605851_0.96736709809221"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-09T12:43:00.667Z","modified":"2024-11-09T12:50:06.449Z","0.1.6":"2024-11-09T12:43:00.941Z","0.1.7":"2024-11-09T12:50:06.011Z"},"bugs":{"url":"https://github.com/ankarhem/secrecy-ts/issues"},"license":"MIT","homepage":"https://github.com/ankarhem/secrecy-ts#readme","repository":{"type":"git","url":"git+https://github.com/ankarhem/secrecy-ts.git"},"description":"A TypeScript port of the Rust secrecy crate. Wrap secrets in a type to ensure they are not exposed.","maintainers":[{"name":"jakobankarhem","email":"jakob.ankarhem@outlook.com"}],"readme":"<!-- Codecov-->\n\n[![Coverage Status](https://coveralls.io/repos/github/ankarhem/secrecy-ts/badge.svg?branch=main)](https://coveralls.io/github/ankarhem/secrecy-ts?branch=main)\n\n# secrecy-ts\n\nA typescript port of the rust library [secrecy](https://lib.rs/crates/secrecy).\n\n## Usage\n\n```typescript\nconst secret = new Secret(\"password\");\n\nconsole.log(secret.expose()); // \"password\"\n\n// If not explicitly exposed, the secret is hidden\nconsole.log(secret); // \"[REDACTED]\"\nconsole.log(String(secret)); // \"[REDACTED]\"\nconsole.log(secret.toString()); // \"[REDACTED]\"\nconsole.log(secret.valueOf().toString()); // \"[REDACTED]\"\nconsole.log(`${secret}`); // \"[REDACTED]\"\nconsole.log(JSON.stringify(secret)); // \"[REDACTED]\"\nconsole.log(JSON.stringify({ secret: secret })); // \"{\"secret\":\"[REDACTED]\"}\"\n\n// Compare secrets with other secrets or with non-secret values\nconsole.log(secret.equals(secret)); // true\nconsole.log(secret.equals(\"not a secret\")); // false\n\n// Clone secrets\nconst cloned = secret.clone();\nconsole.log(cloned.expose()); // \"password\"\nconsole.log(Object.is(secret, cloned)); // false\nconsole.log(secret.equals(cloned)); // true\n\n// Map the secret value to a new secret value\nconst mapped = secret.map((value) => value.length);\nconsole.log(mapped.expose()); // 8\n\n// Assert that a value is a secret\nassertSecret(secret);\n// If the value is not a secret, an error is thrown\nassertSecret(\"not a secret\"); // throws SecretError\n\n// Check if a value is a secret\nconst something = new Secret(\"something\") as unknown;\nif (isSecret(something)) {\n  console.log(something.expose()); // \"something\"\n}\n```\n","readmeFilename":"README.md"}