pkce_oauth 0.2.0 → 0.2.1

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: 2b318658ee574454f7b5c521cdf74f16f2d459e9eb24d79d20990a854b3cdabe
4
- data.tar.gz: 16d6e810e9bd9e4b9e18bfe5be08447f1d7f4368bb6b30f0fb3f2ed9aa67ee6c
3
+ metadata.gz: 9b199006a114978dddc334598c50e4b9bb70a763a73ad8301cd1267946e06117
4
+ data.tar.gz: c4dd344fb575d81ef2018be27c3e5a376fdc374dbd9b15b7356c97a0902333bd
5
5
  SHA512:
6
- metadata.gz: 7de6bf552d019b112584551c9bdf4294c86d83d1da9a8d41b8db1a6abf498edb6d28595fa89ffe552a0af142dc90d047981cfabb33ffb3c16b7a1fb92cd3b0da
7
- data.tar.gz: ffb20006db7b4177feff3955978df56593af763cf99318c83f5aa4e12685f5540bce93bb4c4ab5598e27de498a300f1abd50f0b962151e5647dadd1e3d78f573
6
+ metadata.gz: 260b21b7fcaf22ad409fff024933419fff064ec9e6b4e4380a90d936a133448cbe3e899734d90caad9f3225470dbba1ae135a71f20ba4aedfe77ddf90aafd092
7
+ data.tar.gz: 2b53aca98fd4121ba5e740a108923529b42907a296a37e4cccab410a178ccdfee4dfa72856cb5e88ff9e857cadab0e4f141afb99feaa8a1857cd4bb49e0dff80
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.2.1] - 2025-03-28
2
+ ### Modified
3
+ - using rust package pkce
4
+
1
5
  ## [0.2.0] - 2024-12-16
2
6
  ### Added
3
7
  - generating random key with charset
data/Cargo.lock CHANGED
@@ -2,21 +2,6 @@
2
2
  # It is not intended for manual editing.
3
3
  version = 4
4
4
 
5
- [[package]]
6
- name = "addr2line"
7
- version = "0.24.2"
8
- source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
10
- dependencies = [
11
- "gimli",
12
- ]
13
-
14
- [[package]]
15
- name = "adler2"
16
- version = "2.0.0"
17
- source = "registry+https://github.com/rust-lang/crates.io-index"
18
- checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
19
-
20
5
  [[package]]
21
6
  name = "aho-corasick"
22
7
  version = "1.1.3"
@@ -26,46 +11,11 @@ dependencies = [
26
11
  "memchr",
27
12
  ]
28
13
 
29
- [[package]]
30
- name = "async-trait"
31
- version = "0.1.83"
32
- source = "registry+https://github.com/rust-lang/crates.io-index"
33
- checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
34
- dependencies = [
35
- "proc-macro2",
36
- "quote",
37
- "syn",
38
- ]
39
-
40
- [[package]]
41
- name = "backtrace"
42
- version = "0.3.74"
43
- source = "registry+https://github.com/rust-lang/crates.io-index"
44
- checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
45
- dependencies = [
46
- "addr2line",
47
- "cfg-if",
48
- "libc",
49
- "miniz_oxide",
50
- "object",
51
- "rustc-demangle",
52
- "windows-targets",
53
- ]
54
-
55
14
  [[package]]
56
15
  name = "base64"
57
- version = "0.22.1"
16
+ version = "0.21.7"
58
17
  source = "registry+https://github.com/rust-lang/crates.io-index"
59
- checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
60
-
61
- [[package]]
62
- name = "base64-url"
63
- version = "3.0.0"
64
- source = "registry+https://github.com/rust-lang/crates.io-index"
65
- checksum = "38e2b6c78c06f7288d5e3c3d683bde35a79531127c83b087e5d0d77c974b4b28"
66
- dependencies = [
67
- "base64",
68
- ]
18
+ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
69
19
 
70
20
  [[package]]
71
21
  name = "bindgen"
@@ -108,12 +58,6 @@ version = "1.5.0"
108
58
  source = "registry+https://github.com/rust-lang/crates.io-index"
109
59
  checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
110
60
 
111
- [[package]]
112
- name = "bytes"
113
- version = "1.9.0"
114
- source = "registry+https://github.com/rust-lang/crates.io-index"
115
- checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"
116
-
117
61
  [[package]]
118
62
  name = "cexpr"
119
63
  version = "0.6.0"
@@ -196,24 +140,12 @@ dependencies = [
196
140
  "wasi",
197
141
  ]
198
142
 
199
- [[package]]
200
- name = "gimli"
201
- version = "0.31.1"
202
- source = "registry+https://github.com/rust-lang/crates.io-index"
203
- checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
204
-
205
143
  [[package]]
206
144
  name = "glob"
207
145
  version = "0.3.1"
208
146
  source = "registry+https://github.com/rust-lang/crates.io-index"
209
147
  checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
210
148
 
211
- [[package]]
212
- name = "hex"
213
- version = "0.4.3"
214
- source = "registry+https://github.com/rust-lang/crates.io-index"
215
- checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
216
-
217
149
  [[package]]
218
150
  name = "itertools"
219
151
  version = "0.12.1"
@@ -253,9 +185,9 @@ dependencies = [
253
185
 
254
186
  [[package]]
255
187
  name = "magnus"
256
- version = "0.6.4"
188
+ version = "0.7.1"
257
189
  source = "registry+https://github.com/rust-lang/crates.io-index"
258
- checksum = "b1597ef40aa8c36be098249e82c9a20cf7199278ac1c1a1a995eeead6a184479"
190
+ checksum = "3d87ae53030f3a22e83879e666cb94e58a7bdf31706878a0ba48752994146dab"
259
191
  dependencies = [
260
192
  "magnus-macros",
261
193
  "rb-sys",
@@ -286,15 +218,6 @@ version = "0.2.1"
286
218
  source = "registry+https://github.com/rust-lang/crates.io-index"
287
219
  checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
288
220
 
289
- [[package]]
290
- name = "miniz_oxide"
291
- version = "0.8.0"
292
- source = "registry+https://github.com/rust-lang/crates.io-index"
293
- checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
294
- dependencies = [
295
- "adler2",
296
- ]
297
-
298
221
  [[package]]
299
222
  name = "nom"
300
223
  version = "7.1.3"
@@ -306,28 +229,22 @@ dependencies = [
306
229
  ]
307
230
 
308
231
  [[package]]
309
- name = "object"
310
- version = "0.36.5"
232
+ name = "pkce"
233
+ version = "0.2.0"
311
234
  source = "registry+https://github.com/rust-lang/crates.io-index"
312
- checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
235
+ checksum = "e228dbe2aebd82de09c914fe28d36d3170ed5192e8d52b9c070ee0794519c2d3"
313
236
  dependencies = [
314
- "memchr",
237
+ "base64",
238
+ "rand",
239
+ "sha2",
315
240
  ]
316
241
 
317
- [[package]]
318
- name = "pin-project-lite"
319
- version = "0.2.15"
320
- source = "registry+https://github.com/rust-lang/crates.io-index"
321
- checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff"
322
-
323
242
  [[package]]
324
243
  name = "pkce_oauth"
325
- version = "0.1.0"
244
+ version = "0.1.1"
326
245
  dependencies = [
327
- "base64-url",
328
246
  "magnus",
329
- "rand",
330
- "sha256",
247
+ "pkce",
331
248
  ]
332
249
 
333
250
  [[package]]
@@ -446,12 +363,6 @@ version = "0.8.5"
446
363
  source = "registry+https://github.com/rust-lang/crates.io-index"
447
364
  checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
448
365
 
449
- [[package]]
450
- name = "rustc-demangle"
451
- version = "0.1.24"
452
- source = "registry+https://github.com/rust-lang/crates.io-index"
453
- checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
454
-
455
366
  [[package]]
456
367
  name = "rustc-hash"
457
368
  version = "1.1.0"
@@ -475,19 +386,6 @@ dependencies = [
475
386
  "digest",
476
387
  ]
477
388
 
478
- [[package]]
479
- name = "sha256"
480
- version = "1.5.0"
481
- source = "registry+https://github.com/rust-lang/crates.io-index"
482
- checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0"
483
- dependencies = [
484
- "async-trait",
485
- "bytes",
486
- "hex",
487
- "sha2",
488
- "tokio",
489
- ]
490
-
491
389
  [[package]]
492
390
  name = "shell-words"
493
391
  version = "1.1.0"
@@ -511,17 +409,6 @@ dependencies = [
511
409
  "unicode-ident",
512
410
  ]
513
411
 
514
- [[package]]
515
- name = "tokio"
516
- version = "1.42.0"
517
- source = "registry+https://github.com/rust-lang/crates.io-index"
518
- checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551"
519
- dependencies = [
520
- "backtrace",
521
- "bytes",
522
- "pin-project-lite",
523
- ]
524
-
525
412
  [[package]]
526
413
  name = "typenum"
527
414
  version = "1.17.0"
data/README.md CHANGED
@@ -29,13 +29,13 @@ PkceOauth.challenge(key_length: 64)
29
29
  PkceOauth.challenge_valid?(code_verifier: code_verifier, code_challenge: code_challenge)
30
30
  ```
31
31
 
32
- ## Usage with dry-container
32
+ ### Usage with dry-container
33
33
 
34
34
  If you use dry-container for class memoization and use `PkceOauth.challenge` with the same options, then you can add initialized objects to container
35
35
 
36
36
  ```ruby
37
37
  register('pkce_challenge') { PkceOauth::Challenge.new }
38
- register('pkce_comparator') { PkceOauth::Comparator.new }
38
+ register('pkce_comparator') { PkceOauth::Comparison.new }
39
39
  ```
40
40
 
41
41
  and later call them
@@ -45,6 +45,16 @@ pkce_challenge.call
45
45
  pkce_comparator.equal?(code_verifier: code_verifier, code_challenge: code_challenge)
46
46
  ```
47
47
 
48
+ ### Direct usage
49
+
50
+ You can directly call generating code verifier and code challenge
51
+
52
+ ```ruby
53
+ PkceOauth.generate_code_verifier
54
+ PkceOauth.generate_limited_code_verifier(64)
55
+ PkceOauth.generate_code_challenge(code_verifier)
56
+ ```
57
+
48
58
  ## Development
49
59
 
50
60
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "pkce_oauth"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  edition = "2021"
5
5
  authors = ["Bogdanov Anton <kortirso@gmail.com>"]
6
6
  license = "MIT"
@@ -10,7 +10,5 @@ publish = false
10
10
  crate-type = ["cdylib"]
11
11
 
12
12
  [dependencies]
13
- base64-url = { version = "3.0.0" }
14
- magnus = { version = "0.6.2" }
15
- rand = { version = "0.8.5" }
16
- sha256 = { version = "1.5.0" }
13
+ magnus = { version = "0.7" }
14
+ pkce = { version = "0.2.0" }
@@ -1,20 +1,8 @@
1
- use base64_url::escape;
2
1
  use magnus::{function, prelude::*, Error, Ruby};
3
- use rand::{thread_rng, Rng};
4
- //use rand::distributions::Alphanumeric;
5
- use sha256::digest;
2
+ use pkce;
6
3
 
7
4
  fn generate_limited_code_verifier(length: usize) -> String {
8
- const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
9
- abcdefghijklmnopqrstuvwxyz\
10
- 0123456789-_";
11
- let mut rng = thread_rng();
12
- (0..length)
13
- .map(|_| {
14
- let index = rng.gen_range(0..CHARSET.len());
15
- CHARSET[index] as char
16
- })
17
- .collect()
5
+ String::from_utf8(pkce::code_verifier(length)).expect("REASON")
18
6
  }
19
7
 
20
8
  fn generate_code_verifier() -> String {
@@ -22,7 +10,7 @@ fn generate_code_verifier() -> String {
22
10
  }
23
11
 
24
12
  fn generate_code_challenge(code_verifier: String) -> String {
25
- escape(&digest(code_verifier)).to_string()
13
+ pkce::code_challenge(&code_verifier.as_bytes())
26
14
  }
27
15
 
28
16
  #[magnus::init]
@@ -4,7 +4,7 @@ module PkceOauth
4
4
  class Challenge
5
5
  attr_reader :verifier, :challenger
6
6
 
7
- def initialize(verifier: Verifier, challenger: Challenger, **options)
7
+ def initialize(verifier: CodeVerifier, challenger: CodeChallenger, **options)
8
8
  @verifier = verifier.new(**options.slice(:key_length))
9
9
  @challenger = challenger.new
10
10
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PkceOauth
4
- class Challenger
4
+ class CodeChallenger
5
5
  def call(code_verifier:)
6
6
  PkceOauth.generate_code_challenge(code_verifier)
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PkceOauth
4
- class Verifier
4
+ class CodeVerifier
5
5
  class KeyLengthError < StandardError; end
6
6
 
7
7
  MINIMUM_KEY_LENGTH = 43
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PkceOauth
4
- class Comparator
4
+ class Comparison
5
5
  attr_reader :challenger
6
6
 
7
- def initialize(challenger: Challenger)
7
+ def initialize(challenger: CodeChallenger)
8
8
  @challenger = challenger.new
9
9
  end
10
10
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PkceOauth
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
data/lib/pkce_oauth.rb CHANGED
@@ -2,22 +2,21 @@
2
2
 
3
3
  require_relative 'pkce_oauth/version'
4
4
  require_relative 'pkce_oauth/pkce_oauth'
5
+ require_relative 'pkce_oauth/code_verifier'
6
+ require_relative 'pkce_oauth/code_challenger'
5
7
  require_relative 'pkce_oauth/challenge'
6
- require_relative 'pkce_oauth/comparator'
7
- require_relative 'pkce_oauth/verifier'
8
- require_relative 'pkce_oauth/challenger'
8
+ require_relative 'pkce_oauth/comparison'
9
9
 
10
10
  module PkceOauth
11
11
  module_function
12
12
 
13
13
  class Error < StandardError; end
14
- # Your code goes here...
15
14
 
16
15
  def challenge(...)
17
16
  PkceOauth::Challenge.new(...).call
18
17
  end
19
18
 
20
19
  def challenge_valid?(...)
21
- PkceOauth::Comparator.new.equal?(...)
20
+ PkceOauth::Comparison.new.equal?(...)
22
21
  end
23
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkce_oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdanov Anton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-16 00:00:00.000000000 Z
11
+ date: 2025-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -129,9 +129,9 @@ files:
129
129
  - ext/pkce_oauth/src/lib.rs
130
130
  - lib/pkce_oauth.rb
131
131
  - lib/pkce_oauth/challenge.rb
132
- - lib/pkce_oauth/challenger.rb
133
- - lib/pkce_oauth/comparator.rb
134
- - lib/pkce_oauth/verifier.rb
132
+ - lib/pkce_oauth/code_challenger.rb
133
+ - lib/pkce_oauth/code_verifier.rb
134
+ - lib/pkce_oauth/comparison.rb
135
135
  - lib/pkce_oauth/version.rb
136
136
  - sig/pkce_oauth.rbs
137
137
  homepage: https://github.com/kortirso/pkce_oauth