omniauth-lastfm 1.0.3 → 1.0.5

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: 4669ea9ca70a4e4a7c7f08279a588fafafd35c032af578d9020629037f4d2dbb
4
- data.tar.gz: a7067d4983190aa84f6bc68e18792363efb8d260f6e66c0341efc87cc9cf83d3
3
+ metadata.gz: a67ccc625319b274e05dcf6d72408609250311e4f7b49e69483908e9e4aba0b5
4
+ data.tar.gz: a1adf2888f18732b1beb8bfc1a1560355edeed485241c3734cc8d8efbff49c9f
5
5
  SHA512:
6
- metadata.gz: 198f79d10470feb34693e1043ddcfa6acca8a1081993ffc2b594cf92e7cbd8b77520aa0cf4cd2b643083c6f7d661fde32165fcc8771004b136afc5ecccbbec4a
7
- data.tar.gz: ef16eb5143daff1c2fe542d7c7a4d0ea9ca3250a3d7d432c8882742705289ac3f2dac5680c7d52f075f1d9d29d82e0b2b5cd6f57a85e206209e8dc69c8fb7ecb
6
+ metadata.gz: 74816a83bfad71a6bddd32a3d63e404d1657586d6dce4926d9ae5a1d4a120609795ce5a27b643d785408c379974f019933510885a98ecbeed7a8d3ba7d02f357
7
+ data.tar.gz: 16cb5487a86289dc826bef56ac687c869b442f27d0d9f94d0d633f61669d485efc308bbb47239ef0fa86e2c7b99a65662e10b6256ec50cbc30033140c19ac3de
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # OmniAuth Last.fm
1
+ # OmniAuth Last.fm Strategy
2
2
 
3
3
  [![Test](https://github.com/icoretech/omniauth-lastfm/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/icoretech/omniauth-lastfm/actions/workflows/test.yml)
4
- [![Gem Version](https://img.shields.io/gem/v/omniauth-lastfm.svg)](https://rubygems.org/gems/omniauth-lastfm)
4
+ [![Gem Version](https://badge.fury.io/rb/omniauth-lastfm.svg)](https://badge.fury.io/rb/omniauth-lastfm)
5
5
 
6
6
  `omniauth-lastfm` is an OmniAuth strategy for authenticating with Last.fm.
7
7
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Lastfm
5
- VERSION = '1.0.3'
5
+ VERSION = "1.0.5"
6
6
  end
7
7
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'digest/md5'
4
- require 'json'
5
- require 'net/http'
6
- require 'omniauth'
7
- require 'uri'
3
+ require "digest/md5"
4
+ require "json"
5
+ require "net/http"
6
+ require "omniauth"
7
+ require "uri"
8
8
 
9
9
  module OmniAuth
10
10
  module Strategies
@@ -14,40 +14,40 @@ module OmniAuth
14
14
 
15
15
  args %i[api_key secret_key]
16
16
 
17
- option :name, 'lastfm'
17
+ option :name, "lastfm"
18
18
  option :api_key, nil
19
19
  option :secret_key, nil
20
20
  option :api_timeout, 10
21
21
  option :client_options,
22
- site: 'https://www.last.fm',
23
- authorize_path: '/api/auth',
24
- api_url: 'https://ws.audioscrobbler.com/2.0/',
25
- user_agent: 'icoretech-omniauth-lastfm gem'
22
+ site: "https://www.last.fm",
23
+ authorize_path: "/api/auth",
24
+ api_url: "https://ws.audioscrobbler.com/2.0/",
25
+ user_agent: "icoretech-omniauth-lastfm gem"
26
26
 
27
- uid { session_data['name'] }
27
+ uid { session_data["name"] }
28
28
 
29
29
  info do
30
30
  {
31
- nickname: user_data['name'],
32
- name: user_data['realname'],
33
- url: user_data['url'],
34
- image: image_url(user_data['image']),
35
- country: user_data['country'],
36
- age: user_data['age'],
37
- gender: user_data['gender']
31
+ nickname: user_data["name"],
32
+ name: user_data["realname"],
33
+ url: user_data["url"],
34
+ image: image_url(user_data["image"]),
35
+ country: user_data["country"],
36
+ age: user_data["age"],
37
+ gender: user_data["gender"]
38
38
  }.compact
39
39
  end
40
40
 
41
41
  extra do
42
42
  {
43
- 'raw_info' => user_data
43
+ "raw_info" => user_data
44
44
  }
45
45
  end
46
46
 
47
47
  credentials do
48
48
  {
49
- token: session_data['key'],
50
- name: session_data['name']
49
+ token: session_data["key"],
50
+ name: session_data["name"]
51
51
  }.compact
52
52
  end
53
53
 
@@ -64,19 +64,19 @@ module OmniAuth
64
64
  def callback_phase
65
65
  load_profile!
66
66
  super
67
- rescue StandardError => e
67
+ rescue => e
68
68
  fail!(:invalid_credentials, e)
69
69
  end
70
70
 
71
71
  protected
72
72
 
73
73
  def load_profile!
74
- token = request.params['token'].to_s
75
- raise ArgumentError, 'Missing token parameter in callback request' if token.empty?
74
+ token = request.params["token"].to_s
75
+ raise ArgumentError, "Missing token parameter in callback request" if token.empty?
76
76
 
77
77
  session_payload = fetch_json(session_params(token))
78
- user_name = session_payload.dig('session', 'name').to_s
79
- raise ArgumentError, 'Missing session name in Last.fm session response' if user_name.empty?
78
+ user_name = session_payload.dig("session", "name").to_s
79
+ raise ArgumentError, "Missing session name in Last.fm session response" if user_name.empty?
80
80
 
81
81
  @json = session_payload
82
82
  @json.merge!(fetch_json(user_info_params(user_name)))
@@ -87,13 +87,13 @@ module OmniAuth
87
87
  uri.query = URI.encode_www_form(params)
88
88
 
89
89
  http = Net::HTTP.new(uri.host, uri.port)
90
- http.use_ssl = uri.scheme == 'https'
90
+ http.use_ssl = uri.scheme == "https"
91
91
  http.open_timeout = options.api_timeout
92
92
  http.read_timeout = options.api_timeout
93
93
 
94
94
  request = Net::HTTP::Get.new(uri.request_uri)
95
- request['Accept'] = 'application/json'
96
- request['User-Agent'] = options.client_options.user_agent
95
+ request["Accept"] = "application/json"
96
+ request["User-Agent"] = options.client_options.user_agent
97
97
 
98
98
  response = http.request(request)
99
99
  unless response.is_a?(Net::HTTPSuccess)
@@ -106,23 +106,23 @@ module OmniAuth
106
106
  end
107
107
 
108
108
  def session_data
109
- @json&.fetch('session', {}) || {}
109
+ @json&.fetch("session", {}) || {}
110
110
  end
111
111
 
112
112
  def user_data
113
- @json&.fetch('user', {}) || {}
113
+ @json&.fetch("user", {}) || {}
114
114
  end
115
115
 
116
116
  def image_url(value)
117
117
  case value
118
118
  when Array
119
119
  value.reverse_each do |entry|
120
- image = entry.fetch('#text', '').to_s
120
+ image = entry.fetch("#text", "").to_s
121
121
  return image unless image.empty?
122
122
  end
123
123
  nil
124
124
  when Hash
125
- image = value.fetch('#text', '').to_s
125
+ image = value.fetch("#text", "").to_s
126
126
  image.empty? ? nil : image
127
127
  else
128
128
  image = value.to_s
@@ -142,8 +142,8 @@ module OmniAuth
142
142
  api_key: options.api_key,
143
143
  token: token,
144
144
  api_sig: signature(token),
145
- method: 'auth.getSession',
146
- format: 'json'
145
+ method: "auth.getSession",
146
+ format: "json"
147
147
  }
148
148
  end
149
149
 
@@ -151,8 +151,8 @@ module OmniAuth
151
151
  {
152
152
  api_key: options.api_key,
153
153
  user: user_name,
154
- method: 'user.getInfo',
155
- format: 'json'
154
+ method: "user.getInfo",
155
+ format: "json"
156
156
  }
157
157
  end
158
158
 
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'omniauth/lastfm/version'
3
+ require "omniauth/lastfm/version"
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'omniauth-lastfm/version'
4
- require 'omniauth/strategies/lastfm'
3
+ require "omniauth-lastfm/version"
4
+ require "omniauth/strategies/lastfm"
@@ -1,33 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'omniauth/lastfm/version'
5
+ require "omniauth/lastfm/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'omniauth-lastfm'
8
+ spec.name = "omniauth-lastfm"
9
9
  spec.version = OmniAuth::Lastfm::VERSION
10
- spec.authors = ['Claudio Poli']
11
- spec.email = ['masterkain@gmail.com']
10
+ spec.authors = ["Claudio Poli"]
11
+ spec.email = ["masterkain@gmail.com"]
12
12
 
13
- spec.summary = 'OmniAuth strategy for Last.fm authentication.'
14
- spec.description = 'OAuth strategy for OmniAuth that authenticates users with Last.fm and exposes profile metadata.'
15
- spec.homepage = 'https://github.com/icoretech/omniauth-lastfm'
16
- spec.license = 'MIT'
17
- spec.required_ruby_version = '>= 3.2'
13
+ spec.summary = "OmniAuth strategy for Last.fm authentication."
14
+ spec.description = "OAuth strategy for OmniAuth that authenticates users with Last.fm and exposes profile metadata."
15
+ spec.homepage = "https://github.com/icoretech/omniauth-lastfm"
16
+ spec.license = "MIT"
17
+ spec.required_ruby_version = ">= 3.2"
18
18
 
19
- spec.metadata['source_code_uri'] = 'https://github.com/icoretech/omniauth-lastfm'
20
- spec.metadata['bug_tracker_uri'] = 'https://github.com/icoretech/omniauth-lastfm/issues'
21
- spec.metadata['changelog_uri'] = 'https://github.com/icoretech/omniauth-lastfm/releases'
22
- spec.metadata['rubygems_mfa_required'] = 'true'
19
+ spec.metadata["source_code_uri"] = "https://github.com/icoretech/omniauth-lastfm"
20
+ spec.metadata["bug_tracker_uri"] = "https://github.com/icoretech/omniauth-lastfm/issues"
21
+ spec.metadata["changelog_uri"] = "https://github.com/icoretech/omniauth-lastfm/releases"
22
+ spec.metadata["rubygems_mfa_required"] = "true"
23
23
 
24
24
  spec.files = Dir[
25
- 'lib/**/*.rb',
26
- 'README*',
27
- 'LICENSE*',
28
- '*.gemspec'
25
+ "lib/**/*.rb",
26
+ "README*",
27
+ "LICENSE*",
28
+ "*.gemspec"
29
29
  ]
30
- spec.require_paths = ['lib']
30
+ spec.require_paths = ["lib"]
31
31
 
32
- spec.add_dependency 'omniauth', '>= 2.1', '< 3.0'
32
+ spec.add_dependency "omniauth", ">= 2.1", "< 3.0"
33
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-lastfm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Poli