wework 1.2.5 → 1.2.8

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: adce838cfedd4fc0628785f3dd0fde51dc36fb69a4300548781ecbd2430d7138
4
- data.tar.gz: 6324188d880595fd28d72b89ee8475226d92ab749959f36bb37648922d89c0cd
3
+ metadata.gz: 2370a71d7a4ebb3f04257eee4d1573748cfcc5e15ade5931a973d8abcfbe790b
4
+ data.tar.gz: 9340553291b76e20b4f8db91caeadd7455cd11489a78e45f210d2e5a60e02e02
5
5
  SHA512:
6
- metadata.gz: dda7d4b6c87833bc5b23d5be3376e2c24dec32515fe848bfc8e8d7e429fe0c9f87197c748dfd54bad073f3d027f07be6c2db09e011209db84bc8f874e319ea0d
7
- data.tar.gz: d4eafae82010a37c403a282091ad684d503b3550151484530842ea60a68c9839358ffc66a5da7faa8a5395b2bab678e8e2b722fe6ee85747c3c099ddfba0c201
6
+ metadata.gz: 2100dbeb253d7fd17723c440d016f24510ef8215145099bbbf9c80b46411f52089b2cdbf8bf36c458dc21e1266d753945def2c83bbc052773f5dbee78048ee15
7
+ data.tar.gz: 4f7ce15118f59d0843e97e9fbd2adfec40b638fe02dc6e46ea2e00b36d9c97179f78f8b2681e30dc67e400b3e0cf03d5f0179e22d4cc9d02f7373c689134091c
@@ -2,8 +2,8 @@ require 'redis'
2
2
  require 'active_support/all'
3
3
  #require 'active_support/core_ext/object/blank'
4
4
 
5
- LIB_PATH = "#{File.dirname(__FILE__)}/wework"
6
- Dir["#{LIB_PATH}/api/methods/*.rb", "#{LIB_PATH}/token/*.rb"].each { |path| require path }
5
+ lib_path = "#{File.dirname(__FILE__)}/wework"
6
+ Dir["#{lib_path}/api/methods/*.rb", "#{lib_path}/token/*.rb"].each { |path| require path }
7
7
 
8
8
  require 'wework/version'
9
9
  require 'wework/cipher'
@@ -20,6 +20,7 @@ module Wework
20
20
  API_ENDPOINT = 'https://qyapi.weixin.qq.com/cgi-bin/'.freeze
21
21
  AUTHORIZE_ENDPOINT = 'https://open.weixin.qq.com/connect/oauth2/authorize'.freeze
22
22
  SSO_AUTHORIZE_ENDPOINT = 'https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect'.freeze
23
+ AGENT_SSO_AUTHORIZE_ENDPOINT = 'https://open.work.weixin.qq.com/wwopen/sso/qrConnect'.freeze
23
24
  APP_AUTHORIZE_ENDPOINT = 'https://open.work.weixin.qq.com/3rdapp/install'.freeze
24
25
  REGISTER_ENDPOINT = 'https://open.work.weixin.qq.com/3rdservice/wework/register'.freeze
25
26
  HTTP_OK_STATUS = [200, 201].freeze
@@ -8,6 +8,7 @@ module Wework
8
8
  include Methods::Menu
9
9
  include Methods::Checkin
10
10
  include Methods::Approval
11
+ include Wework::Cipher
11
12
 
12
13
  attr_reader :agent_id
13
14
 
@@ -4,6 +4,11 @@ module Wework
4
4
  module Api
5
5
  module Methods
6
6
  module Agent
7
+ def sso_authorize_url(redirect_uri, state='qrconnect')
8
+ uri = ERB::Util.url_encode(redirect_uri)
9
+ "#{AGENT_SSO_AUTHORIZE_ENDPOINT}?appid=#{corp_id}&agentid=#{agent_id}&redirect_uri=#{uri}&state=#{state}"
10
+ end
11
+
7
12
  def authorize_url(redirect_uri, scope="snsapi_base", state="wxwork")
8
13
  # user agent: UA is mozilla/5.0 (iphone; cpu iphone os 10_2 like mac os x) applewebkit/602.3.12 (khtml, like gecko) mobile/14c92 wxwork/1.3.2 micromessenger/6.2
9
14
  uri = ERB::Util.url_encode(redirect_uri)
@@ -4,14 +4,6 @@ module Wework
4
4
  include Methods::Provider
5
5
  include Wework::Cipher
6
6
 
7
- attr_reader :encoding_aes_key, :token
8
-
9
- def initialize(options={})
10
- @token = options.delete(:token)
11
- @encoding_aes_key = options.delete(:encoding_aes_key)
12
- super(options)
13
- end
14
-
15
7
  private
16
8
 
17
9
  def token_store
@@ -7,13 +7,12 @@ module Wework
7
7
  include Wework::Cipher
8
8
  include Methods::Service
9
9
 
10
- attr_reader :encoding_aes_key, :suite_id, :suite_secret, :suite_token, :token
10
+ attr_reader :suite_id, :suite_secret, :suite_token
11
11
 
12
12
  def initialize(options={})
13
13
  @suite_id = options.delete(:suite_id)
14
14
  @suite_secret = options.delete(:suite_secret)
15
15
  @token = @suite_token = options.delete(:suite_token)
16
- @encoding_aes_key = options.delete(:encoding_aes_key)
17
16
  super(options)
18
17
  end
19
18
 
@@ -11,6 +11,14 @@ module Wework
11
11
  BLOCK_SIZE = 32
12
12
  CIPHER = 'AES-256-CBC'.freeze
13
13
 
14
+ def token
15
+ @token ||= options[:token]
16
+ end
17
+
18
+ def encoding_aes_key
19
+ @encoding_aes_key ||= options[:encoding_aes_key]
20
+ end
21
+
14
22
  def encrypt(plain, encoding_aes_key)
15
23
  cipher = OpenSSL::Cipher.new(CIPHER)
16
24
  cipher.encrypt
@@ -1,3 +1,3 @@
1
1
  module Wework
2
- VERSION = '1.2.5'.freeze
2
+ VERSION = '1.2.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - seandong
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-12 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
251
  requirements: []
252
- rubygems_version: 3.0.3
252
+ rubygems_version: 3.1.2
253
253
  signing_key:
254
254
  specification_version: 4
255
255
  summary: Ruby API wrapper for wechat work「企业微信」