{"_id":"@azure/cosmos-sign","_rev":"2954819","name":"@azure/cosmos-sign","description":"Utility for signing Azure Cosmos keys","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"azure-sdk","email":""}],"time":{"modified":"2023-04-27T03:55:12.000Z","created":"2018-12-18T20:23:51.508Z","1.0.2":"2018-12-18T20:23:51.508Z"},"users":{},"author":{"name":"Microsoft Corporation"},"repository":{"type":"git","url":"git+https://github.com/Azure/cosmos-sign.git"},"versions":{"1.0.2":{"name":"@azure/cosmos-sign","version":"1.0.2","description":"Utility for signing Azure Cosmos keys","browser":"./lib/browser.js","main":"./lib/node.js","types":"./lib/node.d.ts","scripts":{"compile":"rimraf lib && tsc","build":"npm run check-format && npm run compile && npm run test && webpack && bundlesize","test":"node lib/browser.test.js && node lib/node.test.js","format":"prettier --write \"src/**/*.ts\"","check-format":"prettier --list-different \"src/**/*.ts\"","prepack":"npm install && npm run compile"},"keywords":["Azure","Cosmos"],"repository":{"type":"git","url":"git+https://github.com/Azure/cosmos-sign.git"},"bugs":{"url":"https://github.com/Azure/cosmos-sign"},"author":{"name":"Microsoft Corporation"},"license":"MIT","devDependencies":{"@types/crypto-js":"3.1.43","@types/node":"10.12.9","bundlesize":"0.17.0","prettier":"1.15.2","rimraf":"2.6.2","typescript":"3.1.6","webpack":"4.25.1","webpack-cli":"3.1.2"},"dependencies":{"crypto-js":"3.1.9-1"},"bundlesize":[{"path":"./bundle.js","maxSize":"3.2 kB"}],"prettier":{"semi":false},"gitHead":"7e9d007b9c8ef6969b2981237f5ad726058c04a0","homepage":"https://github.com/Azure/cosmos-sign#readme","_id":"@azure/cosmos-sign@1.0.2","_npmVersion":"6.4.1","_nodeVersion":"11.3.0","_npmUser":{"name":"southpolesteve","email":"southpolesteve@gmail.com"},"dist":{"shasum":"a38b03f30bb6e39da397c95361b2916d70de2a79","size":3753,"noattachment":false,"key":"/@azure/cosmos-sign/-/@azure/cosmos-sign-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@azure/cosmos-sign/download/@azure/cosmos-sign-1.0.2.tgz"},"maintainers":[{"name":"azure-sdk","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cosmos-sign_1.0.2_1545164631321_0.5195858460867484"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-24T07:26:01.530Z","publish_time":1545164631508,"_cnpm_publish_time":1545164631508}},"readme":"# cosmos-sign\n\n[![latest npm badge](https://img.shields.io/npm/v/cosmos-sign/latest.svg)](https://www.npmjs.com/package/@azure/cosmos)\n[![CircleCI](https://circleci.com/gh/southpolesteve/cosmos-sign.svg?style=svg)](https://circleci.com/gh/southpolesteve/cosmos-sign)\n![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/cosmos-sign.svg)\n\nUtility library for signing Azure Cosmos tokens and generating headers. Works in both node and the browser\n\n`npm install cosmos-sign`\n\n## Generate a signed header value using your master key\n\n```js\nimport { generateSignature } from \"cosmos-sign\"\n\nconst masterKey = \"< your master key here >\"\nconst method = \"GET\"\nconst resourceId = \"\"\nconst resourceType = \"\"\n\nconst result = generateSignature(masterKey, method, resourceType, resourceId)\n```\n\n## Generate a headers object instead\n\n```js\nimport { generateHeaders } from \"cosmos-sign\"\n\nconst masterKey = \"< your master key here >\"\nconst method = \"GET\"\nconst resourceId = \"\"\nconst resourceType = \"\"\n\nconst headers = generateHeaders(masterKey, method, resourceType, resourceId)\n\nfetch(\"https://your-db.cosmos.azure.com/\", {\n  headers\n})\n```\n\n## Optionally pass a date in\n\n```js\nimport { generateSignature } from \"cosmos-sign\"\n\nconst masterKey = \"< your master key here >\";\nconst method = \"GET\";\nconst resourceId = \"\";\nconst resourceType = \"\";\nconst date = new Date(<tomorrow>)\n\nconst result = generateSignature(masterKey, method, resourceType, resourceId, date);\n```\n\n## Notes\n\nSee https://docs.microsoft.com/en-us/rest/api/cosmos-db/access-control-on-cosmosdb-resources for documentation on how to generate signatures\n\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https://cla.microsoft.com.\n\nWhen you submit a pull request, a CLA-bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n","_attachments":{},"homepage":"https://github.com/Azure/cosmos-sign#readme","bugs":{"url":"https://github.com/Azure/cosmos-sign"},"license":"MIT"}