mixin_bot 0.11.3 → 0.12.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/lib/mixin_bot/api/auth.rb +50 -0
- data/lib/mixin_bot/cli/api.rb +18 -0
- data/lib/mixin_bot/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5281229704ca2a0c90428a5f74d6d581bc79e19fe50b842ef1b517524aa206c6
|
4
|
+
data.tar.gz: 8e3961405502a068167665c596cf3d1b97a13e3fe9d5c0a217213db50317cc3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d87f1bb6e3079edd9a5a0759a61396aaa1c886793362fd759f5f191926b16deb0bbbee497fc9f9b534ea769780a2807264518725ab4747e9c6e864651d5bb574
|
7
|
+
data.tar.gz: 61af8a4a4dc9b1521dd4e3e47bb228605325abd4f3717e5ac8df928eb2314e00548a1b65c88eecf5a7417992d3318cd6eea0fb596404df83d2dc62123c972f5d
|
data/lib/mixin_bot/api/auth.rb
CHANGED
@@ -52,6 +52,56 @@ module MixinBot
|
|
52
52
|
scope: scope
|
53
53
|
)
|
54
54
|
end
|
55
|
+
|
56
|
+
def authorize_code(**kwargs)
|
57
|
+
path = '/oauth/authorize'
|
58
|
+
data = authorization_data(
|
59
|
+
kwargs[:user_id],
|
60
|
+
kwargs[:scope] || ['PROFILE:READ']
|
61
|
+
)
|
62
|
+
|
63
|
+
payload = {
|
64
|
+
authorization_id: data['authorization_id'],
|
65
|
+
scopes: data['scopes'],
|
66
|
+
pin_base64: encrypt_pin(kwargs[:pin])
|
67
|
+
}
|
68
|
+
|
69
|
+
access_token = kwargs[:access_token]
|
70
|
+
access_token ||= access_token('POST', path, payload.to_json)
|
71
|
+
authorization = format('Bearer %<access_token>s', access_token: access_token)
|
72
|
+
client.post(path, headers: { 'Authorization': authorization }, json: payload)
|
73
|
+
end
|
74
|
+
|
75
|
+
def authorization_data(user_id, scope = ['PROFILE:READ'])
|
76
|
+
@_client_id = user_id
|
77
|
+
@_scope = scope.join(' ')
|
78
|
+
EM.run do
|
79
|
+
start_blaze_connect do
|
80
|
+
def on_open(ws, event)
|
81
|
+
ws.send write_ws_message(
|
82
|
+
action: 'REFRESH_OAUTH_CODE',
|
83
|
+
params: {
|
84
|
+
client_id: @_client_id,
|
85
|
+
scope: @_scope,
|
86
|
+
authorization_id: '',
|
87
|
+
code_challenge: ''
|
88
|
+
}
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
def on_message(ws, event)
|
93
|
+
raw = JSON.parse read_ws_message(event.data)
|
94
|
+
@_data = raw['data']
|
95
|
+
ws.close
|
96
|
+
end
|
97
|
+
|
98
|
+
def on_close(ws, event)
|
99
|
+
EM.stop_event_loop
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
@_data
|
104
|
+
end
|
55
105
|
end
|
56
106
|
end
|
57
107
|
end
|
data/lib/mixin_bot/cli/api.rb
CHANGED
@@ -49,5 +49,23 @@ module MixinBot
|
|
49
49
|
|
50
50
|
log res['data']
|
51
51
|
end
|
52
|
+
|
53
|
+
desc 'authcode', 'code to authorize other mixin account'
|
54
|
+
option :keystore, type: :string, aliases: '-k', required: true, desc: 'keystore or keystore.json file path'
|
55
|
+
option :client_id, type: :string, required: true, aliases: '-c', desc: "client_id of bot to authorize"
|
56
|
+
option :scope, type: :array, default: ['PROFILE:READ'], aliases: '-s', desc: 'scope to authorize'
|
57
|
+
option :pin, type: :string, required: true, aliases: '-p', desc: 'pin'
|
58
|
+
def authcode
|
59
|
+
res = {}
|
60
|
+
CLI::UI::Spinner.spin("POST /oauth/authorize") do |_spinner|
|
61
|
+
res =
|
62
|
+
api_instance.authorize_code(
|
63
|
+
user_id: options[:client_id],
|
64
|
+
scope: options[:scope],
|
65
|
+
pin: options[:pin]
|
66
|
+
)
|
67
|
+
end
|
68
|
+
log res['data']
|
69
|
+
end
|
52
70
|
end
|
53
71
|
end
|
data/lib/mixin_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixin_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- an-lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -347,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
347
347
|
- !ruby/object:Gem::Version
|
348
348
|
version: '0'
|
349
349
|
requirements: []
|
350
|
-
rubygems_version: 3.
|
350
|
+
rubygems_version: 3.4.2
|
351
351
|
signing_key:
|
352
352
|
specification_version: 4
|
353
353
|
summary: An API wrapper for Mixin Nexwork
|