branca-ruby 1.0.3 → 1.0.4

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: bb38a9b375ff1f3510d4f8be5d535210fa926b1852402900bfaffa78bc86954a
4
- data.tar.gz: eb611a373fb87ac2c44c7ad98ebcfb64cf4a94d53128bb78e86d38c6553bdff8
3
+ metadata.gz: a18a64bfdd3003e06e8cf821c88851354edab732357676b3b86014a62fd6a172
4
+ data.tar.gz: 281778e2b9e47f9ba6d92a982c5b7e3adfae2cab7a0eee7e2e1610ea143677eb
5
5
  SHA512:
6
- metadata.gz: 845eb83b9b1fdaa2fea3957cf7b930607af154e3440265fcebade68b2db40dcd0177270d7f5d5016e8d3e4446df2115448b4e8e35964f0facc85e6012cf15334
7
- data.tar.gz: 13f6b3408237cb98b24c4489d37d5b9a9386ed8ddeb5f9cef3473ff951eb9a811b6403c0f6cf005f9d3f8667dc54bb065db95ddaf76ad6f8f04dbe9b062c8098
6
+ metadata.gz: 8b80e5b4e5df1e1ffa41ac6cf95c2dd861c9db446cfbed290d84cdafebeea41370ccd819add02d4a5949a3de25c72c5e46179ac700ffefa866f50e8b7b8162eb
7
+ data.tar.gz: a37487ab60fe01d67e1ee7d49c4e57e64bb0afda1554a4e5708fcde5c09d450d15497022a9e0190dbab4e200e75037a7c193cd9e192c550e626f7f7a0ae73055
data/.gitpod.yml ADDED
@@ -0,0 +1,8 @@
1
+ # This configuration file was automatically generated by Gitpod.
2
+ # Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
3
+ # and commit this file to your remote git repository to share the goodness with others.
4
+
5
+ tasks:
6
+ - init: bin/setup
7
+
8
+
data/Gemfile CHANGED
@@ -7,4 +7,4 @@ gemspec
7
7
 
8
8
  ruby '>= 2.5.8'
9
9
 
10
- gem "byebug", "~> 10.0", :group => :test
10
+ gem "byebug", :group => :test
data/README.md CHANGED
@@ -17,7 +17,7 @@ It is possible to use [Branca as an alternative to JWT](https://appelsiini.net/2
17
17
  Add this line to your application's Gemfile, Note that you also must have [libsodium](https://download.libsodium.org/doc/) installed.
18
18
 
19
19
  ```ruby
20
- gem 'branca-ruby', '~> 1.0.2'
20
+ gem 'branca-ruby', '~> 1.0.3'
21
21
  ```
22
22
 
23
23
  ## Configure
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Branca
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.4'
5
5
  end
data/lib/branca.rb CHANGED
@@ -21,7 +21,7 @@ module Branca
21
21
  ciphertext = cipher.encrypt(nonce, message, header)
22
22
  raw_token = header + ciphertext
23
23
 
24
- BaseX::Base62.encode(raw_token)
24
+ base62_encode(raw_token)
25
25
  end
26
26
 
27
27
  def decode(token, ttl: self.ttl, secret_key: self.secret_key)
@@ -58,12 +58,28 @@ module Branca
58
58
  end
59
59
 
60
60
  def token_explode(token)
61
- bytes = BaseX::Base62.decode(token).unpack('C C4 C24 C*')
61
+ raw = base62_decode(token)
62
+ bytes = raw.unpack('C C4 C24 C*')
62
63
  header = bytes.shift(1 + 4 + 24)
63
64
 
64
65
  [header, bytes]
65
66
  end
66
67
 
68
+ BASE62_NO_LEADING_ZERO = BaseX.new(
69
+ '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0'
70
+ ).freeze
71
+
72
+ def base62_encode(raw_token)
73
+ BASE62_NO_LEADING_ZERO.encode(raw_token)
74
+ end
75
+
76
+ def base62_decode(token)
77
+ raw = BASE62_NO_LEADING_ZERO.decode(token)
78
+ return raw if raw.getbyte(0) == VERSION
79
+
80
+ BaseX::Base62.decode(token)
81
+ end
82
+
67
83
  def header_explode(header)
68
84
  version = header[0]
69
85
  nonce = header[5..header.size].pack('C*')
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: branca-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thadeu Esteves
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-08-12 00:00:00.000000000 Z
10
+ date: 2026-02-10 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: base_x
@@ -104,6 +103,7 @@ files:
104
103
  - ".github/FUNDING.yml"
105
104
  - ".github/workflows/ruby.yml"
106
105
  - ".gitignore"
106
+ - ".gitpod.yml"
107
107
  - ".rspec"
108
108
  - ".rubocop.yml"
109
109
  - ".travis-libsodium.sh"
@@ -123,7 +123,6 @@ homepage: https://github.com/thadeu/branca-ruby
123
123
  licenses:
124
124
  - MIT
125
125
  metadata: {}
126
- post_install_message:
127
126
  rdoc_options: []
128
127
  require_paths:
129
128
  - lib
@@ -138,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
137
  - !ruby/object:Gem::Version
139
138
  version: '0'
140
139
  requirements: []
141
- rubygems_version: 3.3.7
142
- signing_key:
140
+ rubygems_version: 3.6.2
143
141
  specification_version: 4
144
142
  summary: Authenticated and encrypted API tokens using modern crypto
145
143
  test_files: []