{"id":21678457,"url":"https://github.com/jc21/cypress-jwt-creation","last_synced_at":"2025-04-12T05:36:23.664Z","repository":{"id":35143521,"uuid":"212469642","full_name":"jc21/cypress-jwt-creation","owner":"jc21","description":"Create JWT tokens with ease","archived":false,"fork":false,"pushed_at":"2024-09-06T05:45:38.000Z","size":331,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T01:01:53.464Z","etag":null,"topics":["cypress","jwt","tokens"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/jc21.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-03T00:40:47.000Z","updated_at":"2024-03-12T03:37:02.000Z","dependencies_parsed_at":"2024-11-25T16:15:10.140Z","dependency_job_id":null,"html_url":"https://github.com/jc21/cypress-jwt-creation","commit_stats":{"total_commits":6,"total_committers":3,"mean_commits":2.0,"dds":"0.33333333333333337","last_synced_commit":"f6c731be6b3007a7dae3f2eee74b28796dafe844"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jc21%2Fcypress-jwt-creation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jc21%2Fcypress-jwt-creation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jc21%2Fcypress-jwt-creation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jc21%2Fcypress-jwt-creation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jc21","download_url":"https://codeload.github.com/jc21/cypress-jwt-creation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248524650,"owners_count":21118612,"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":["cypress","jwt","tokens"],"created_at":"2024-11-25T14:34:52.172Z","updated_at":"2025-04-12T05:36:23.637Z","avatar_url":"https://github.com/jc21.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cypress JWT Creation\n\nCreate JWT tokens with ease\n\n[![npm (scoped)](https://img.shields.io/npm/v/@jc21/cypress-jwt-creation.svg?style=for-the-badge)](https://www.npmjs.com/package/@jc21/cypress-jwt-creation)\n[![npm (types)](https://img.shields.io/npm/types/@jc21/cypress-jwt-creation.svg?style=for-the-badge)](https://www.npmjs.com/package/@jc21/cypress-jwt-creation)\n[![npm (licence)](https://img.shields.io/npm/l/@jc21/cypress-jwt-creation.svg?style=for-the-badge)](https://www.npmjs.com/package/@jc21/cypress-jwt-creation)\n\n\n### Cypress Installation\n\n```bash\nyarn add @jc21/cypress-jwt-creation\n```\n\nThen in your cypress Plugins file:\n```javascript\nconst {JwtCreation} = require('@jc21/cypress-jwt-creation');\n\nmodule.exports = (on, config) =\u003e {\n    // ...\n    on('task', JwtCreation(config));\n    // ...\n    return config;\n};\n```\n\n\n### Cypress Usage\n\n```javascript\ndescribe('Hit an authenticated endpoint', () =\u003e {\n    it('Should be able to get a response', async function () {\n        cy.request('/users/me').then($response =\u003e {\n\n            const token = await cy.task('generateToken', {\n                privateKey: '/path/to/private.key',\n                issuer:     'cypress-tester',\n                algo:       'RS256',\n                expires:    '1 day',\n                claims:     {\n                    capabilities: 'superuser'\n                }\n            });\n\n            // use token in your requests\n        });\n    });\n});\n```\n\n### The Private Key\n\nDue to the fact that this plugin runs on the Cypress Backend, the location of the private key file must be defined as either\nthe full path on disk or relative path to the running of the cypress command. You can define the file location\neither with an environment variable which can apply to all tests:\n\n`config.env.jwtPrivateKey`\n\nor within each individial test using the options below. In addition, you can also define the JWT algorithm if different from\nthe default `RS256` with:\n\n`config.env.jwtAlgo`\n\n\n### Options\n\n| Option       | Description                                                   | Optional | Default                         |\n| ------------ | ------------------------------------------------------------- | -------- | ------------------------------- |\n| `privateKey` | The location of the private key file                          | true     | `config.env.jwtPrivateKey`      |\n| `issuer`     | Issuer string                                                 | true     | \"cypress.testing\"               |\n| `algo`       | The request method of the endpoint                            | true     | `config.env.jwtAlgo` or `RS256` |\n| `expires`    | English interval of token expiry                              | true     | \"1 day\"                         |\n| `claims`     | An object of extra claims you might want to set               | true     | {}                              |\n\n\n### Compiling Source\n\n```bash\nyarn install\nyarn build\nyarn test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjc21%2Fcypress-jwt-creation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjc21%2Fcypress-jwt-creation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjc21%2Fcypress-jwt-creation/lists"}