mixin_bot 0.11.3 → 0.12.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: fbe972f6a75908bd8c682e1a29208177cbd3766ee246bc44ac53a9416063ec3b
4
- data.tar.gz: 783349cc919f4c0cb6fb6a4637a9768e4713a02cb91c859b24518ccf6e1e28cb
3
+ metadata.gz: cf2e7ef08c38a52d5d31ce1be5a0531f13680e31cb5e7f11cd6e1582436d8711
4
+ data.tar.gz: '08cfa89514d3f102cdd064cfb3c3367cf2166292a3abc854481320a2fb610d15'
5
5
  SHA512:
6
- metadata.gz: bdaf7d01136e90ee031b8fc974037cc84bb9ef7b492edc8ab36cbcf1c73c5c4679c8cc28e350f806ec57fc45eac1feaa8dd5beeeb28e8b560edd80c5afe1024a
7
- data.tar.gz: b21eacbe6a3e34c0a08d1b719c46f62a83a6da4e1b70f9ec2460cb611df480efd74f4a66c8c43ea651f00bde484c251654997e75924d1a336159ea1786fd2acc
6
+ metadata.gz: a5f7af8574ea545b899bd2081923dd75e0b2ef2288346fb8e8d842b642ef596c626370d9a5140a695c267db4281e4c51239cce2d55f5edb87ed33127c76c379b
7
+ data.tar.gz: b2393b4a392ff025b0e6d58c545018bd4cafb26e9fb130bba8938e42d4850a6f2b5d0244d887f6dae8d8f53fcb000819737ea71d999add7e175637c7e2d591d1
@@ -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
@@ -49,5 +49,22 @@ 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
+ def authcode
58
+ res = {}
59
+ CLI::UI::Spinner.spin('POST /oauth/authorize') do |_spinner|
60
+ res =
61
+ api_instance.authorize_code(
62
+ user_id: options[:client_id],
63
+ scope: options[:scope],
64
+ pin: keystore['pin']
65
+ )
66
+ end
67
+ log res['data']
68
+ end
52
69
  end
53
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MixinBot
4
- VERSION = '0.11.3'
4
+ VERSION = '0.12.1'
5
5
  end
data/lib/mvm/registry.rb CHANGED
@@ -11,7 +11,7 @@ module MVM
11
11
 
12
12
  def pid
13
13
  hex = @rpc.call(@registry, 'PID').to_s(16)
14
- MixinBot::Utils::UUID.new(hex:hex).unpacked
14
+ MixinBot::Utils::UUID.new(hex: hex).unpacked
15
15
  end
16
16
 
17
17
  def version
@@ -20,7 +20,7 @@ module MVM
20
20
 
21
21
  def asset_from_contract(contract)
22
22
  hex = @rpc.call(@registry, 'assets', contract).to_s(16)
23
- MixinBot::Utils::UUID.new(hex:hex).unpacked
23
+ MixinBot::Utils::UUID.new(hex: hex).unpacked
24
24
  end
25
25
 
26
26
  def users_from_contract(contract)
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.11.3
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - an-lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-17 00:00:00.000000000 Z
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.3.4
350
+ rubygems_version: 3.4.2
351
351
  signing_key:
352
352
  specification_version: 4
353
353
  summary: An API wrapper for Mixin Nexwork