jwt-eddsa 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28ed2f26cd80ec13936990c38cf5103e1be0c868ba5291e99532f904365a425a
4
- data.tar.gz: 651d235fe08f3128e7c963d207f4078f4885dba867d48626be0ff6fbb8f8bff4
3
+ metadata.gz: 397516e999d09d5630932c9e83855bdcdca32a4ce1ea5c3727bc8a69cdf0488a
4
+ data.tar.gz: 120eb2ca3c66104aa8023063c96077e7e3b158388f292b766546d58eb86c8a09
5
5
  SHA512:
6
- metadata.gz: cc667b1f8b1367a6bff9ecb3b39d19a3bd5e91fe2944b91db60ed0e4d038184cf8abc17a706a80c0eb246c26038d8aa8067a637f8c36eb01194a5ef70d4e6a0d
7
- data.tar.gz: 7d579ca9744bf14eab7372b33aaa44de5a22b3030027fcb304e7a3ce7cd240eca6d60688ab58215f8acd2ae31ad06df33f6cb94be89be2f04bb2125ee31feffb
6
+ metadata.gz: 7da8d363b401a7d741539941d99be57eca69fb1c2a09cf8d6eaa0431da4346952e8d4711df1518bee69cce5bf77d762d6ea45e0e2cbb4bd0a96e581019b164a3
7
+ data.tar.gz: 5027b733b26cc75604395f972db17eadfe6757219a749ed1094e0bbcfa8a056bcc49cca060dc14ea71cb33c844485324a742acd793003b4445cac0fec8b4141f
data/.rubocop.yml CHANGED
@@ -1,8 +1,14 @@
1
1
  AllCops:
2
- TargetRubyVersion: 3.0
2
+ TargetRubyVersion: 2.5
3
+ NewCops: enable
4
+ SuggestExtensions: false
3
5
 
4
6
  Style/StringLiterals:
5
7
  EnforcedStyle: double_quotes
6
8
 
7
9
  Style/StringLiteralsInInterpolation:
8
10
  EnforcedStyle: double_quotes
11
+
12
+ Metrics/BlockLength:
13
+ Exclude:
14
+ - spec/**/*_spec.rb
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.4
data/README.md CHANGED
@@ -2,14 +2,37 @@
2
2
 
3
3
  A library extending the ruby-jwt gem with EdDSA algorithms
4
4
 
5
+ **NOTE: This gem is still WIP**
6
+
7
+ Work is currently done in [ruby-jwt](https://github.com/jwt/ruby-jwt/pull/607) to allow extending the algorithms.
8
+
9
+ Plan is to replace rbnacl with something else in the near future.
10
+
5
11
  ## Installation
6
12
 
13
+ Will only work with the WIP branch, so adding the following to your the Gemfile should do the trick:
14
+ ```
15
+ gem "jwt", github: "anakinj/ruby-jwt", branch: "extendable-algos"
16
+ ```
17
+
18
+ ```
19
+ require "jwt/eddsa" # not verified if this actually works
20
+ ```
21
+
7
22
  ## Usage
8
23
 
9
- TODO: Write usage instructions here
24
+ ```ruby
25
+ private_key = RbNaCl::Signatures::Ed25519::SigningKey.new("b" * 32)
26
+ token = JWT.encode({pay: "load"}, private_key, "EdDSA")
27
+ payload, header = JWT.decode(token, private_key.verify_key, true, algorithm: "EdDSA")
28
+ ```
10
29
 
11
30
  ## Development
12
31
 
32
+ ```
33
+ bundle install
34
+ bundle exec rspec
35
+ ```
13
36
 
14
37
  ## Contributing
15
38
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JWT
4
4
  module Eddsa
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/jwt/eddsa.rb CHANGED
@@ -1,10 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "jwt"
3
4
  require_relative "eddsa/version"
4
5
 
5
6
  module JWT
7
+ # EdDSA algorithm implementation
6
8
  module Eddsa
7
- class Error < StandardError; end
8
- # Your code goes here...
9
+ include JWT::JWA::Algorithm
10
+
11
+ register_algorithm("EdDSA")
12
+
13
+ class << self
14
+ def sign(_algorithm, msg, key)
15
+ unless key.is_a?(RbNaCl::Signatures::Ed25519::SigningKey)
16
+ raise_sign_error!("Key given is a #{key.class} but needs to be a RbNaCl::Signatures::Ed25519::SigningKey")
17
+ end
18
+
19
+ key.sign(msg)
20
+ end
21
+
22
+ def verify(_algorithm, public_key, signing_input, signature)
23
+ unless public_key.is_a?(RbNaCl::Signatures::Ed25519::VerifyKey)
24
+ raise_verify_error!("Key given is a #{public_key.class} but needs to be a RbNaCl::Signatures::Ed25519::VerifyKey")
25
+ end
26
+
27
+ public_key.verify(signature, signing_input)
28
+ rescue RbNaCl::CryptoError
29
+ false
30
+ end
31
+ end
9
32
  end
10
33
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwt-eddsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Antman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-23 00:00:00.000000000 Z
11
+ date: 2024-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jwt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.8.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.8.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rbnacl
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,7 +38,7 @@ dependencies:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: '6.0'
27
- description:
41
+ description:
28
42
  email:
29
43
  - antmanj@gmail.com
30
44
  executables: []
@@ -33,6 +47,7 @@ extra_rdoc_files: []
33
47
  files:
34
48
  - ".rspec"
35
49
  - ".rubocop.yml"
50
+ - ".ruby-version"
36
51
  - CHANGELOG.md
37
52
  - CODE_OF_CONDUCT.md
38
53
  - LICENSE
@@ -46,8 +61,9 @@ licenses:
46
61
  metadata:
47
62
  homepage_uri: https://github.com/anakinj/jwt-eddsa
48
63
  source_code_uri: https://github.com/anakinj/jwt-eddsa
49
- changelog_uri: https://github.com/anakinj/jwt-eddsablob/v0.1.0/CHANGELOG.md
50
- post_install_message:
64
+ changelog_uri: https://github.com/anakinj/jwt-eddsablob/v0.2.0/CHANGELOG.md
65
+ rubygems_mfa_required: 'true'
66
+ post_install_message:
51
67
  rdoc_options: []
52
68
  require_paths:
53
69
  - lib
@@ -62,8 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
78
  - !ruby/object:Gem::Version
63
79
  version: '0'
64
80
  requirements: []
65
- rubygems_version: 3.5.3
66
- signing_key:
81
+ rubygems_version: 3.5.11
82
+ signing_key:
67
83
  specification_version: 4
68
84
  summary: Extension for the jwt gem
69
85
  test_files: []