zaikio-hub 0.10.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6de6ed1ed5cb7442b72ffa036df6de0cf7f371d59d52018b4458850b7e71848
4
- data.tar.gz: 5dc770e601267c847094fdb07875651529ec14458676c5d5be558af9c0d15c39
3
+ metadata.gz: 4a47f0490eda39c0fd1650ea60e0e46f88d4867a40448613f7665bb41b2677ce
4
+ data.tar.gz: 7f9b32bb341193d459e77b694d75152bd2026248661de28155683578f5e72fe2
5
5
  SHA512:
6
- metadata.gz: 2b168642b4f8c6ac5607602a7e2237224e98fe52b4991c3f06b3a61591eeeacb6a6d76a60f63acaa272fe55cb9ee43f42f0a7aea871a3eeca7a2a770abc5f8ae
7
- data.tar.gz: 4aca04231bccaf9dc4d85ebf752ef4663f365cc7bc788a8b55d979983047e4eb78e3978bf2bd28ef274186f7408ce2d5288941b08e4bdb40329ed6468ab000dc
6
+ metadata.gz: 9840f132efc25c081a7576aac95dd64f6a6c433f346cf10e8345540f7593a7aec2540905aac201d1868e7f14cc3c8445fb63e116d07cc8e1fabb4801f1964aec
7
+ data.tar.gz: ed6060c8af4aaf2b8899f0a76d70a4eec176b320d359c253e8a6cd0a17d02a573a97181ed0bed158026850e4e6c76f0694ccec357f2c2f2dfcea57a00ec2a825
data/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.11.1] - 2022-10-13
11
+
12
+ * Added `subscription_url` attribute in `Subscription`
13
+
14
+ ## [0.11.0] - 2022-08-30
15
+
16
+ * Extract token data logic into its own `Zaikio::Hub::TokenData` class
17
+ This also exposes the `sub` attribute of the token as `TokenData#subject`.
18
+ * Support newer versions of `jwt` and `spyke`
19
+
10
20
  ## [0.10.0] - 2022-08-15
11
21
 
12
22
  * Update `zaikio-client-helpers` and reuse logic to use `Zaikio::Client.with_token`
@@ -90,7 +100,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
90
100
  ### Added
91
101
  - Added subscriptions (migration required)
92
102
 
93
- [Unreleased]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.9.0..HEAD
103
+ [Unreleased]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.11.1..HEAD
104
+ [0.11.1]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.11.0..v0.11.1
105
+ [0.11.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.10.0..v0.11.0
106
+ [0.10.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.9.0..v0.10.0
94
107
  [0.9.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.8.0..v0.9.0
95
108
  [0.8.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.7.0..v0.8.0
96
109
  [0.7.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.6.2..v0.7.0
@@ -9,7 +9,7 @@ module Zaikio
9
9
  attributes :updated_at, :created_at, :subscriber_type, :subscriber_id,
10
10
  :status, :app_name, :activated_at, :last_billed_at,
11
11
  :last_paid_at, :trial_ended_at, :plan, :plan_name, :preceding_plan,
12
- :changed_plan_at, :usages_in_current_billing_period
12
+ :changed_plan_at, :subscripton_url, :usages_in_current_billing_period
13
13
 
14
14
  def initialize(attributes = {})
15
15
  if attributes["subscriber_id"]
@@ -0,0 +1,51 @@
1
+ module Zaikio
2
+ module Hub
3
+ class TokenData
4
+ attr_reader :audience, :on_behalf_of, :subject, :scopes
5
+
6
+ def self.from(payload)
7
+ subjects = payload["sub"].split(">")
8
+
9
+ new(
10
+ audience: payload["aud"].first,
11
+ on_behalf_of: subjects.first,
12
+ subject: subjects.last,
13
+ scopes: payload["scope"]
14
+ )
15
+ end
16
+
17
+ def initialize(audience:, on_behalf_of:, subject:, scopes:)
18
+ @audience = audience
19
+ @on_behalf_of = on_behalf_of
20
+ @subject = subject
21
+ @scopes = scopes
22
+ end
23
+
24
+ def on_behalf_of_type
25
+ @on_behalf_of_type ||= type_for(:on_behalf_of)
26
+ end
27
+
28
+ def on_behalf_of_id
29
+ @on_behalf_of_id ||= id_for(:on_behalf_of)
30
+ end
31
+
32
+ def subject_type
33
+ @subject_type ||= type_for(:subject)
34
+ end
35
+
36
+ def subject_id
37
+ @subject_id ||= id_for(:subject)
38
+ end
39
+
40
+ private
41
+
42
+ def type_for(key)
43
+ public_send(key).split("/").first
44
+ end
45
+
46
+ def id_for(key)
47
+ public_send(key).split("/").last
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module Hub
3
- VERSION = "0.10.0".freeze
3
+ VERSION = "0.11.1".freeze
4
4
  end
5
5
  end
data/lib/zaikio/hub.rb CHANGED
@@ -27,6 +27,7 @@ require "zaikio/hub/connection"
27
27
  require "zaikio/hub/app"
28
28
  require "zaikio/hub/subscription"
29
29
  require "zaikio/hub/test_account"
30
+ require "zaikio/hub/token_data"
30
31
 
31
32
  module Zaikio
32
33
  module Hub
@@ -73,15 +74,7 @@ module Zaikio
73
74
  end
74
75
 
75
76
  def create_token_data(payload)
76
- subjects = payload["sub"].split(">")
77
-
78
- OpenStruct.new(
79
- audience: payload["aud"].first,
80
- on_behalf_of_id: subjects.first.split("/").last,
81
- subject_id: subjects.last.split("/").last,
82
- subject_type: subjects.last.split("/").first,
83
- scopes: payload["scope"]
84
- )
77
+ TokenData.from(payload)
85
78
  end
86
79
  end
87
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - crispymtn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-08-15 00:00:00.000000000 Z
13
+ date: 2022-10-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: concurrent-ruby
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: 2.2.1
36
36
  - - "<"
37
37
  - !ruby/object:Gem::Version
38
- version: 2.5.0
38
+ version: 2.6.0
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: 2.2.1
46
46
  - - "<"
47
47
  - !ruby/object:Gem::Version
48
- version: 2.5.0
48
+ version: 2.6.0
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: multi_json
51
51
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +157,7 @@ files:
157
157
  - lib/zaikio/hub/specialist.rb
158
158
  - lib/zaikio/hub/subscription.rb
159
159
  - lib/zaikio/hub/test_account.rb
160
+ - lib/zaikio/hub/token_data.rb
160
161
  - lib/zaikio/hub/version.rb
161
162
  homepage: https://www.zaikio.com/
162
163
  licenses: