{"id":19834839,"url":"https://github.com/jamesalbert/json-webtoken","last_synced_at":"2025-05-01T17:31:55.658Z","repository":{"id":148569584,"uuid":"55184173","full_name":"jamesalbert/JSON-WebToken","owner":"jamesalbert","description":"JSON::WebToken - JSON Web Token (JWT) implementation for Perl6","archived":false,"fork":false,"pushed_at":"2023-10-04T19:43:13.000Z","size":782,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-22T00:42:16.511Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamesalbert.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}},"created_at":"2016-03-31T21:28:54.000Z","updated_at":"2024-04-22T00:42:16.512Z","dependencies_parsed_at":"2023-10-05T02:42:19.953Z","dependency_job_id":null,"html_url":"https://github.com/jamesalbert/JSON-WebToken","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesalbert%2FJSON-WebToken","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesalbert%2FJSON-WebToken/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesalbert%2FJSON-WebToken/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesalbert%2FJSON-WebToken/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamesalbert","download_url":"https://codeload.github.com/jamesalbert/JSON-WebToken/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224270298,"owners_count":17283649,"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-11-12T12:05:43.722Z","updated_at":"2024-11-12T12:05:44.356Z","avatar_url":"https://github.com/jamesalbert.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/jamesalbert/JSON-WebToken.svg?branch=master)](https://travis-ci.org/jamesalbert/JSON-WebToken)\n\nNAME\n====\n\nJSON::WebToken - JSON Web Token (JWT) implementation for Perl6\n\nINSTALL\n=======\n\n    panda update\n    panda install JSON::WebToken\n\n\nSYNOPSIS\n========\n\n    use Data::Dump;\n    use JSON::WebToken;\n    use Test;\n\n    my $claims = {\n      iss =\u003e 'joe',\n      exp =\u003e 1300819380\n    };\n    my $secret = 'secret';\n\n    my $jwt = encode_jwt $claims, $secret; #, 'RS256';\n    say \"encoded \" ~ Dump($claims) ~ \" to $jwt\";\n    my $decoded = decode_jwt $jwt, $secret;\n    say \"decoded to \" ~ Dump($decoded);\n\n    is-deeply $decoded, $claims;\n    done-testing;\n\nDESCRIPTION\n===========\n\nWARNING: This module is brand-spankin' new. It only supports one type of encryption/decryption (HS256). Contributors Welcome!\n\nJSON::WebToken is a JSON Web Token (JWT) implementation for Perl6\n\n**THIS MODULE IS ALPHA LEVEL INTERFACE. **\n\nMETHODS\n=======\n\nencode($claims [, $secret, $algorithm, $extra_headers ]) : String\n-----------------------------------------------------------------\n\nThe default and currently only supported encryption algorithm is `HS256 ` and the synopsis above explains how to do it. Once we support RSA, you will be able to specify the algorithm by doing:\n\n    use JSON::WebToken;\n\n    my $pricate_key_string = '...';\n    my $public_key_string  = '...';\n    my $claims = {\n      iss =\u003e 'joe',\n      exp =\u003e 1300819380\n    };\n    my $jwt = encode-jwt($claims, $pricate_key_string, 'RS256'); # NOTE: not supported yet\n\n    my $decoded = decode-jwt $jwt, $public_key_string;\n\nIf and when you use RS256, RS384 or RS512 algorithm, [Crypt::OpenSSL::RSA ](Crypt::OpenSSL::RSA ) is required.\n\nIf you want to create a `Plaintext JWT `, should be specify `none ` for the algorithm.\n\n    my $jwt = encode-jwt($claims, '', 'none');\n\ndecode($jwt [, $secret, $verify_signature, $accepted_algorithms ]) : HASH\n-------------------------------------------------------------------------\n\nThis method decodes a hash from JWT string.\n\n    my $decoded = decode-jwt $jwt, $secret, 1, ['HS256'];\n\nAny signing algorithm (except \"none\") is acceptable by default, so you should check it with $accepted_algorithms parameter.\n\nadd_signing_algorithm($algorithm, $class)\n-----------------------------------------\n\nThis method adds a signing algorithm.\n\n    use JSON::WebToken;\n\n    class Foo {\n      method sign ($algorithm, $message, $key) {\n        return 'H*'; # or whatever the heck your signature is\n      }\n\n      method verify ($algorithm, $message, $key, $signature) {\n        $signature eq self.sign($algorithm, $message, $key);\n      }\n    }\n\n    add_signing_algorithm Foo.new;\n\nSEE ALSO [JSON::WebToken::Crypt::HMAC ](JSON::WebToken::Crypt::HMAC ) or [JSON::WebToken::Crypt::RSA ](JSON::WebToken::Crypt::RSA ).\n\nFUNCTIONS\n=========\n\nencode_jwt($claims [, $secret, $algorithm, $extra_headers ]) : String\n---------------------------------------------------------------------\n\nSame as `encode() ` method.\n\ndecode_jwt($jwt [, $secret, $verify_signature, $accepted_algorithms ]) : Hash\n-----------------------------------------------------------------------------\n\nSame as `decode() ` method.\n\nERROR CODES\n===========\n\nJSON::WebToken::Exception will be thrown with following code.\n\nERROR_JWT_INVALID_PARAMETER\n---------------------------\n\nWhen some method arguments are not valid.\n\nERROR_JWT_MISSING_SECRET\n------------------------\n\nWhen secret is required. (`alg != \"none\" `)\n\nERROR_JWT_INVALID_SEGMENT_COUNT\n-------------------------------\n\nWhen JWT segment count is not between 2 and 4.\n\nERROR_JWT_INVALID_SEGMENT_ENCODING\n----------------------------------\n\nWhen each JWT segment is not encoded by base64url.\n\nERROR_JWT_UNWANTED_SIGNATURE\n----------------------------\n\nWhen `alg == \"none\" ` but signature segment found.\n\nERROR_JWT_INVALID_SIGNATURE\n---------------------------\n\nWhen JWT signature is invalid.\n\nERROR_JWT_NOT_SUPPORTED_SIGNING_ALGORITHM\n-----------------------------------------\n\nWhen given signing algorithm is not supported.\n\nERROR_JWT_UNACCEPTABLE_ALGORITHM\n--------------------------------\n\nWhen given signing algorithm is not included in acceptable_algorithms.\n\nAUTHOR\n======\n\njamesalbert AKA jimmyjam5000ME (Millennium Edition) \u003clt\u003ejalbert1@uci.edu\u003cgt\u003e\n\nAuthors of Perl5 JSON::WebToken:\n\nxaicron \u003clt\u003exaicron@cpan.orggt\n\nzentooo\n\nCOPYRIGHT\n=========\n\nCopyright 2016 - jamesalbert\n\nLICENSE\n=======\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.\n\nSEE ALSO\n========\n\n[http://tools.ietf.org/html/draft-ietf-oauth-json-web-token ](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token )\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesalbert%2Fjson-webtoken","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamesalbert%2Fjson-webtoken","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesalbert%2Fjson-webtoken/lists"}