{"id":13760279,"url":"https://github.com/bettiolo/oauth-signature-js","last_synced_at":"2025-10-22T13:57:29.200Z","repository":{"id":9790071,"uuid":"11765708","full_name":"bettiolo/oauth-signature-js","owner":"bettiolo","description":"JavaScript OAuth 1.0a signature generator (RFC 5849) for node and the browser","archived":false,"fork":false,"pushed_at":"2017-12-07T15:39:14.000Z","size":2535,"stargazers_count":232,"open_issues_count":21,"forks_count":72,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-29T21:10:43.041Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/oauth-signature","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bettiolo.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}},"created_at":"2013-07-30T13:29:17.000Z","updated_at":"2024-04-03T13:07:53.000Z","dependencies_parsed_at":"2022-07-30T21:08:12.368Z","dependency_job_id":null,"html_url":"https://github.com/bettiolo/oauth-signature-js","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bettiolo%2Foauth-signature-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bettiolo%2Foauth-signature-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bettiolo%2Foauth-signature-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bettiolo%2Foauth-signature-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bettiolo","download_url":"https://codeload.github.com/bettiolo/oauth-signature-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224859694,"owners_count":17381676,"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-08-03T13:01:06.694Z","updated_at":"2025-10-22T13:57:29.103Z","avatar_url":"https://github.com/bettiolo.png","language":"JavaScript","funding_links":[],"categories":["API","API [🔝](#readme)"],"sub_categories":["Runner","运行器","运行器e2e测试"],"readme":"# OAuth 1.0a signature generator for node and the browser \n### Compliant with [RFC 5843](http://tools.ietf.org/html/rfc5849) + [Errata ID 2550](http://www.rfc-editor.org/errata_search.php?rfc=5849) and [community spec](http://oauth.net/core/1.0a)\n\n[![Build Status](https://travis-ci.org/bettiolo/oauth-signature-js.png?branch=master)](https://travis-ci.org/bettiolo/oauth-signature-js)\n[![Bower version](https://badge.fury.io/bo/oauth-signature.svg)](http://badge.fury.io/bo/oauth-signature-js)\n[![NPM version](https://badge.fury.io/js/oauth-signature.png)](http://badge.fury.io/js/oauth-signature)\n[![Dependency Status](https://david-dm.org/bettiolo/oauth-signature-js.png?theme=shields.io)](https://david-dm.org/bettiolo/oauth-signature-js)\n\n## Installation\n\n#### Install with `npm`:\n\n```shell\nnpm install oauth-signature\n```\n\n#### Install with `bower`:\n\n```shell\nbower install oauth-signature\n```\n\nAdd a `\u003cscript\u003e` to your `index.html`:\n\n```html\n\u003cscript src=\"/bower_components/oauth-signature/dist/oauth-signature.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nTo generate the OAuth signature call the following method:\n\n```js\noauthSignature.generate(httpMethod, url, parameters, consumerSecret, tokenSecret, options)\n```\n- `tokenSecret` is optional\n- `options` is optional\n\nthe default `options` parameter is as follows\n```js\nvar options = {\n\tencodeSignature: true // will encode the signature following the RFC 3986 Spec by default\n}\n```\n\n## Example\n\nThe following is an example on how to generate the signature for the reference sample as defined in  \n - http://oauth.net/core/1.0a/#rfc.section.A.5.1 \n - http://oauth.net/core/1.0a/#rfc.section.A.5.2\n\n```js\nvar httpMethod = 'GET',\n\turl = 'http://photos.example.net/photos',\n\tparameters = {\n\t\toauth_consumer_key : 'dpf43f3p2l4k3l03',\n\t\toauth_token : 'nnch734d00sl2jdk',\n\t\toauth_nonce : 'kllo9940pd9333jh',\n\t\toauth_timestamp : '1191242096',\n\t\toauth_signature_method : 'HMAC-SHA1',\n\t\toauth_version : '1.0',\n\t\tfile : 'vacation.jpg',\n\t\tsize : 'original'\n\t},\n\tconsumerSecret = 'kd94hf93k423kf44',\n\ttokenSecret = 'pfkkdhi9sl3r4s00',\n\t// generates a RFC 3986 encoded, BASE64 encoded HMAC-SHA1 hash\n\tencodedSignature = oauthSignature.generate(httpMethod, url, parameters, consumerSecret, tokenSecret),\n\t// generates a BASE64 encode HMAC-SHA1 hash\n\tsignature = oauthSignature.generate(httpMethod, url, parameters, consumerSecret, tokenSecret,\n\t\t{ encodeSignature: false});\n```\n\nThe `encodedSignature` variable will contain the RFC 3986 encoded, BASE64 encoded HMAC-SHA1 hash, ready to be used as a query parameter in a request: `tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D`.\n\nThe `signature` variable will contain the BASE64 HMAC-SHA1 hash, without encoding: `tR3+Ty81lMeYAr/Fid0kMTYa/WM=`.\n\n## Requesting a protected resource\n\nUse the generated signature to populate the `oauth_signature` parameter to sign a protected resource as per [RFC](http://oauth.net/core/1.0a/#rfc.section.A.5.3).\n\nExample GET request using query string parameters:\n\nhttp://photos.example.net/photos?file=vacation.jpg\u0026size=original\u0026oauth_consumer_key=dpf43f3p2l4k3l03\u0026oauth_token=nnch734d00sl2jdk\u0026oauth_signature_method=HMAC-SHA1\u0026oauth_signature=tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D\u0026oauth_timestamp=1191242096\u0026oauth_nonce=kllo9940pd9333jh\u0026oauth_version=1.0\n\n## Advantages\n\nThis project has an extensive test coverage for all the corner cases present in the OAuth specifications ([RFC 5843](http://tools.ietf.org/html/rfc5849) + [Errata ID 2550](http://www.rfc-editor.org/errata_search.php?rfc=5849) and [OAuth.net community-based specification](http://oauth.net/core/1.0a))\n\nTake a look at the test file [src/app/signature.tests.js](src/app/oauth-signature.tests.js)\n\n## How do I run tests?\n\nThe tests can be executed in your browser or in node\n\n### Browser\n\nOpen the file [src/test-runner.html](src/test-runner.html) in your browser\n\nYou can also run them live: [src/test-runner.html](https://bettiolo.github.io/oauth-signature-js/src/test-runner.html)\n\n### Node\n\nExecute `npm test` in the console\n\n### Live example\n\nIf you want to make a working experiment you can use the live version of the OAuth signature page at this url: http://bettiolo.github.io/oauth-reference-page/\n\nAnd you can hit the echo OAuth endpoints at this url: http://echo.lab.madgex.com/\n\n- url: **http://echo.lab.madgex.com/echo.ashx**\n- consumer key: **key**\n- consumer secret: **secret**\n- token: **accesskey**\n- token secret: **accesssecret**\n- nonce: **IMPORTANT!** generate a new one at EACH request otherwise you will get a 400 Bad Request\n- timestamp: **IMPORTANT!** refresh the timestamp before each call\n- fields: **add a field with name `foo` and value `bar`**\n\nA url similar to this one will be generated: `http://echo.lab.madgex.com/echo.ashx?foo=bar\u0026oauth_consumer_key=key\u0026oauth_nonce=643377115\u0026oauth_signature_method=HMAC-SHA1\u0026oauth_timestamp=1410807318\u0026oauth_token=accesskey\u0026oauth_version=1.0\u0026oauth_signature=zCmKoF9rVlNxAkD8wUCizFUajs4%3D`\n\nClick on the generated link on the right hand side and you will see the echo server returning `foo=bar`\n\n# Maintenance\n\n## Updating uri-js/js-url\n\n`npm run update`\n\n## Updating chai/mocha\n\nUpdate them via `npm` but also manually in `test-runner.html`\n\n## Publish a new version\n\n```bash\nnpm version [major|minor|patch]\ngit push\ngit push --tags\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbettiolo%2Foauth-signature-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbettiolo%2Foauth-signature-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbettiolo%2Foauth-signature-js/lists"}