setsuzoku 0.13.1 → 0.14.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 +4 -4
 - data/Gemfile.lock +19 -18
 - data/lib/setsuzoku/service/web_service/auth_strategies/strategy_can_use_tokens.rb +13 -24
 - data/lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb +0 -20
 - data/lib/setsuzoku/service/web_service/credentials/uses_credential_token.rb +5 -5
 - data/lib/setsuzoku/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4233d295eb8e38d96442e9727a7325cf1b7673f41fd1575af095a4c89563213c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a25508116b564e0fdc9aaa007b56a72404b8f7116d7fe7506e008337717a649c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a2257bb847f9e182885aa367ac5c886517460b57f9e84fd4f043678f1767da72c6d39fc32bc5c0a9efd92b57f0e582ff1b08d9ba4b7f008959bd20b55e1eddcd
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e5bd652f32e76a02e2c34e6afbec22920afc44ec9c96503d2a78b00ef5da62c1e87f013a9919ee20ce9c0788b82473f93164e770ecc3abda86ee65cee1a1ba00
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                setsuzoku (0. 
     | 
| 
      
 4 
     | 
    
         
            +
                setsuzoku (0.14.0)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  activesupport (>= 5.0, < 7)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  faraday (~> 0.11)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  nokogiri (~> 1.10)
         
     | 
| 
         @@ -10,29 +10,31 @@ PATH 
     | 
|
| 
       10 
10 
     | 
    
         
             
            GEM
         
     | 
| 
       11 
11 
     | 
    
         
             
              remote: https://rubygems.org/
         
     | 
| 
       12 
12 
     | 
    
         
             
              specs:
         
     | 
| 
       13 
     | 
    
         
            -
                activesupport (6. 
     | 
| 
      
 13 
     | 
    
         
            +
                activesupport (6.1.4)
         
     | 
| 
       14 
14 
     | 
    
         
             
                  concurrent-ruby (~> 1.0, >= 1.0.2)
         
     | 
| 
       15 
     | 
    
         
            -
                  i18n (>=  
     | 
| 
       16 
     | 
    
         
            -
                  minitest ( 
     | 
| 
       17 
     | 
    
         
            -
                  tzinfo (~>  
     | 
| 
       18 
     | 
    
         
            -
                  zeitwerk (~> 2. 
     | 
| 
      
 15 
     | 
    
         
            +
                  i18n (>= 1.6, < 2)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  minitest (>= 5.1)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  tzinfo (~> 2.0)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  zeitwerk (~> 2.3)
         
     | 
| 
       19 
19 
     | 
    
         
             
                addressable (2.7.0)
         
     | 
| 
       20 
20 
     | 
    
         
             
                  public_suffix (>= 2.0.2, < 5.0)
         
     | 
| 
       21 
     | 
    
         
            -
                concurrent-ruby (1.1. 
     | 
| 
      
 21 
     | 
    
         
            +
                concurrent-ruby (1.1.9)
         
     | 
| 
       22 
22 
     | 
    
         
             
                crack (0.4.3)
         
     | 
| 
       23 
23 
     | 
    
         
             
                  safe_yaml (~> 1.0.0)
         
     | 
| 
       24 
24 
     | 
    
         
             
                diff-lcs (1.4.2)
         
     | 
| 
       25 
     | 
    
         
            -
                faraday (0.17. 
     | 
| 
      
 25 
     | 
    
         
            +
                faraday (0.17.4)
         
     | 
| 
       26 
26 
     | 
    
         
             
                  multipart-post (>= 1.2, < 3)
         
     | 
| 
       27 
27 
     | 
    
         
             
                hashdiff (1.0.1)
         
     | 
| 
       28 
     | 
    
         
            -
                i18n (1.8. 
     | 
| 
      
 28 
     | 
    
         
            +
                i18n (1.8.10)
         
     | 
| 
       29 
29 
     | 
    
         
             
                  concurrent-ruby (~> 1.0)
         
     | 
| 
       30 
     | 
    
         
            -
                mini_portile2 (2. 
     | 
| 
       31 
     | 
    
         
            -
                minitest (5.14. 
     | 
| 
      
 30 
     | 
    
         
            +
                mini_portile2 (2.5.3)
         
     | 
| 
      
 31 
     | 
    
         
            +
                minitest (5.14.4)
         
     | 
| 
       32 
32 
     | 
    
         
             
                multipart-post (2.1.1)
         
     | 
| 
       33 
     | 
    
         
            -
                nokogiri (1. 
     | 
| 
       34 
     | 
    
         
            -
                  mini_portile2 (~> 2. 
     | 
| 
      
 33 
     | 
    
         
            +
                nokogiri (1.11.7)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  mini_portile2 (~> 2.5.0)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  racc (~> 1.4)
         
     | 
| 
       35 
36 
     | 
    
         
             
                public_suffix (4.0.5)
         
     | 
| 
      
 37 
     | 
    
         
            +
                racc (1.5.2)
         
     | 
| 
       36 
38 
     | 
    
         
             
                rake (10.5.0)
         
     | 
| 
       37 
39 
     | 
    
         
             
                rspec (3.8.0)
         
     | 
| 
       38 
40 
     | 
    
         
             
                  rspec-core (~> 3.8.0)
         
     | 
| 
         @@ -50,16 +52,15 @@ GEM 
     | 
|
| 
       50 
52 
     | 
    
         
             
                safe_yaml (1.0.5)
         
     | 
| 
       51 
53 
     | 
    
         
             
                sorbet (0.5.5675)
         
     | 
| 
       52 
54 
     | 
    
         
             
                  sorbet-static (= 0.5.5675)
         
     | 
| 
       53 
     | 
    
         
            -
                sorbet-runtime (0.5. 
     | 
| 
      
 55 
     | 
    
         
            +
                sorbet-runtime (0.5.6466)
         
     | 
| 
       54 
56 
     | 
    
         
             
                sorbet-static (0.5.5675-universal-darwin-14)
         
     | 
| 
       55 
     | 
    
         
            -
                 
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                  thread_safe (~> 0.1)
         
     | 
| 
      
 57 
     | 
    
         
            +
                tzinfo (2.0.4)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  concurrent-ruby (~> 1.0)
         
     | 
| 
       58 
59 
     | 
    
         
             
                webmock (3.8.0)
         
     | 
| 
       59 
60 
     | 
    
         
             
                  addressable (>= 2.3.6)
         
     | 
| 
       60 
61 
     | 
    
         
             
                  crack (>= 0.3.2)
         
     | 
| 
       61 
62 
     | 
    
         
             
                  hashdiff (>= 0.4.0, < 2.0.0)
         
     | 
| 
       62 
     | 
    
         
            -
                zeitwerk (2.4. 
     | 
| 
      
 63 
     | 
    
         
            +
                zeitwerk (2.4.2)
         
     | 
| 
       63 
64 
     | 
    
         | 
| 
       64 
65 
     | 
    
         
             
            PLATFORMS
         
     | 
| 
       65 
66 
     | 
    
         
             
              ruby
         
     | 
| 
         @@ -144,31 +144,20 @@ module Setsuzoku 
     | 
|
| 
       144 
144 
     | 
    
         | 
| 
       145 
145 
     | 
    
         
             
                        return false unless resp.success
         
     | 
| 
       146 
146 
     | 
    
         | 
| 
       147 
     | 
    
         
            -
                         
     | 
| 
       148 
     | 
    
         
            -
                        attrs[:status] = if attrs[:token]
         
     | 
| 
       149 
     | 
    
         
            -
                                           'active'
         
     | 
| 
       150 
     | 
    
         
            -
                                         else
         
     | 
| 
       151 
     | 
    
         
            -
                                           'error'
         
     | 
| 
       152 
     | 
    
         
            -
                                         end
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
                        # Assign any additional attributes the plugin's credential needs to know about.
         
     | 
| 
       155 
     | 
    
         
            -
                        # E.g. the extension for a phone_number.
         
     | 
| 
       156 
     | 
    
         
            -
                        plugin_attrs = self.credential.additional_attributes_to_assign(resp) if self.plugin.respond_to?(:credential_fields_to_update)
         
     | 
| 
       157 
     | 
    
         
            -
                        attrs.merge!(plugin_attrs) if plugin_attrs
         
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
                        # Only save Setsuzoku known fields, and any additional attributes the plugin specifies
         
     | 
| 
       160 
     | 
    
         
            -
                        # in credential_fields_to_update.
         
     | 
| 
       161 
     | 
    
         
            -
                        if self.credential.respond_to?(:"update_columns")
         
     | 
| 
       162 
     | 
    
         
            -
                          # we issue an update_columns instead of a save/update_attributes
         
     | 
| 
       163 
     | 
    
         
            -
                          # so as to only mutate these attributes
         
     | 
| 
       164 
     | 
    
         
            -
                          # and not any other fields that may have been set for the credential
         
     | 
| 
       165 
     | 
    
         
            -
                          save = self.credential.update_columns(attrs)
         
     | 
| 
       166 
     | 
    
         
            -
                          self.credential.touch if save && self.credential.respond_to?(:"touch")
         
     | 
| 
       167 
     | 
    
         
            -
                          save
         
     | 
| 
       168 
     | 
    
         
            -
                        else
         
     | 
| 
       169 
     | 
    
         
            -
                          true
         
     | 
| 
       170 
     | 
    
         
            -
                        end
         
     | 
| 
      
 147 
     | 
    
         
            +
                        self.credential.set_token!(resp)
         
     | 
| 
       171 
148 
     | 
    
         
             
                      end
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
                      #
         
     | 
| 
      
 151 
     | 
    
         
            +
                      # set_token!
         
     | 
| 
      
 152 
     | 
    
         
            +
                      sig { abstract.params(resp: Setsuzoku::ApiResponse, attrs: T::Hash[Symbol, T.untyped]).void }
         
     | 
| 
      
 153 
     | 
    
         
            +
                      #
         
     | 
| 
      
 154 
     | 
    
         
            +
                      # Persist relevant token and response data after authentication.
         
     | 
| 
      
 155 
     | 
    
         
            +
                      #
         
     | 
| 
      
 156 
     | 
    
         
            +
                      # @param resp [Setsuzoku::ApiResponse] the successful response for an authentication token.
         
     | 
| 
      
 157 
     | 
    
         
            +
                      # @param attrs [Hash] additional attrs that can be set by a specific credential implementation.
         
     | 
| 
      
 158 
     | 
    
         
            +
                      #
         
     | 
| 
      
 159 
     | 
    
         
            +
                      # @return [void]
         
     | 
| 
      
 160 
     | 
    
         
            +
                      def set_token!(resp, attrs); end
         
     | 
| 
       172 
161 
     | 
    
         
             
                    end
         
     | 
| 
       173 
162 
     | 
    
         
             
                  end
         
     | 
| 
       174 
163 
     | 
    
         
             
                end
         
     | 
| 
         @@ -54,26 +54,6 @@ module Setsuzoku 
     | 
|
| 
       54 
54 
     | 
    
         
             
                      sig { abstract.returns(T.nilable(String)) }
         
     | 
| 
       55 
55 
     | 
    
         
             
                      def redirect_url; end
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
                      # The token, refresh_token, and expires_at to assign for an OAuth token request.
         
     | 
| 
       58 
     | 
    
         
            -
                      #
         
     | 
| 
       59 
     | 
    
         
            -
                      # @param resp [Hash] the response hash from the external api call for a token.
         
     | 
| 
       60 
     | 
    
         
            -
                      #
         
     | 
| 
       61 
     | 
    
         
            -
                      # @return [Hash] the attributes to assign to the credential.
         
     | 
| 
       62 
     | 
    
         
            -
                      sig{ overridable.params(resp: Setsuzoku::ApiResponse).returns(T::Hash[Symbol, T.untyped]) }
         
     | 
| 
       63 
     | 
    
         
            -
                      def token_attributes_to_assign(resp)
         
     | 
| 
       64 
     | 
    
         
            -
                        attrs = {
         
     | 
| 
       65 
     | 
    
         
            -
                            token: resp.data[:access_token],
         
     | 
| 
       66 
     | 
    
         
            -
                            refresh_token: resp.data[:refresh_token]
         
     | 
| 
       67 
     | 
    
         
            -
                        }
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                        expires_in = resp.data[:expires_in]
         
     | 
| 
       70 
     | 
    
         
            -
                        if expires_in && (expires_in.is_a?(Integer) || expires_in.match(/^\d+$/))
         
     | 
| 
       71 
     | 
    
         
            -
                          attrs[:expires_on] = expires_in.to_i.seconds.from_now
         
     | 
| 
       72 
     | 
    
         
            -
                        end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                        attrs
         
     | 
| 
       75 
     | 
    
         
            -
                      end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
57 
     | 
    
         
             
                      # Stub an o_auth_credential-like instance.
         
     | 
| 
       78 
58 
     | 
    
         
             
                      #
         
     | 
| 
       79 
59 
     | 
    
         
             
                      # @return [Struct] a stubbed o_auth_credential-like struct.
         
     | 
| 
         @@ -51,16 +51,16 @@ module Setsuzoku 
     | 
|
| 
       51 
51 
     | 
    
         
             
                      #
         
     | 
| 
       52 
52 
     | 
    
         
             
                      # @return [Datetime] the time to set for the current token's expiry.
         
     | 
| 
       53 
53 
     | 
    
         
             
                      sig{ abstract.params(val: DateTime).returns(T.nilable(DateTime)) }
         
     | 
| 
       54 
     | 
    
         
            -
                      def expires_on=(val);
         
     | 
| 
      
 54 
     | 
    
         
            +
                      def expires_on=(val); end
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
                      #  
     | 
| 
      
 56 
     | 
    
         
            +
                      # Alternatively, a credential can manually handle what to do with a token response.
         
     | 
| 
      
 57 
     | 
    
         
            +
                      # For instance, storing multiple tokens as sub-resources
         
     | 
| 
       57 
58 
     | 
    
         
             
                      #
         
     | 
| 
       58 
59 
     | 
    
         
             
                      # @param resp [Hash] the response hash from the external api call for a token.
         
     | 
| 
       59 
60 
     | 
    
         
             
                      #
         
     | 
| 
       60 
61 
     | 
    
         
             
                      # @return [Hash] the attributes to assign to the credential.
         
     | 
| 
       61 
     | 
    
         
            -
                      sig{ abstract.params(resp: T::Hash[Symbol, T.untyped]). 
     | 
| 
       62 
     | 
    
         
            -
                      def  
     | 
| 
       63 
     | 
    
         
            -
                      end
         
     | 
| 
      
 62 
     | 
    
         
            +
                      sig{ abstract.params(resp: T::Hash[Symbol, T.untyped]).void }
         
     | 
| 
      
 63 
     | 
    
         
            +
                      def set_token!; end
         
     | 
| 
       64 
64 
     | 
    
         
             
                    end
         
     | 
| 
       65 
65 
     | 
    
         
             
                  end
         
     | 
| 
       66 
66 
     | 
    
         
             
                end
         
     | 
    
        data/lib/setsuzoku/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: setsuzoku
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.14.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Luke Stadtler
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2021- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-06-28 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |