linerb 0.1.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fc0f82cf83433cc6e798d54d542ffe15839587526c60eab38a8ded0846882aea
4
+ data.tar.gz: 38bc0d916bc2f9d857b9740e3a27f4d931d6dcbb27695251708e4e5dbcacbf27
5
+ SHA512:
6
+ metadata.gz: 69487a94fe2dc9c9170d16c945ef5010ce96d6a0c6fbcc897e52b92296177a8b123638fb8e55b1eddc42eba743887f02f141bbf4d47db6800e491728fb9eb376
7
+ data.tar.gz: c4f65d968af9e5c843e9b3325e9f12b1afc93470e2c6f1529423cebd0a5e35840605854919e278dd7a4146cdf528849b6bf9993b083719f316e9ade4e4d6a473
@@ -0,0 +1 @@
1
+ require 'linerb/client'
@@ -0,0 +1 @@
1
+ #in progress
@@ -0,0 +1,13 @@
1
+ $:.push('./gen-rb')
2
+
3
+ class TalkApi
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+ end
8
+ def api_sendMessage(text:, to:)
9
+ mes = Message.new
10
+ mes:: text = text
11
+ mes::to = to
12
+ @client.sendMessage(0, mes)
13
+ end
@@ -0,0 +1,126 @@
1
+ $:.push('./gen-rb')
2
+
3
+ require 'thrift'
4
+ require 'openssl'
5
+ require "base64"
6
+ require 'cgi'
7
+ require 'securerandom'
8
+
9
+ require_relative 'config'
10
+
11
+ require_relative 'gen-rb/takagi_chan_types'
12
+ require_relative 'gen-rb/secondary_qrcode_login_service'
13
+ require_relative 'gen-rb/secondary_qr_code_login_permit_notice_service'
14
+
15
+ begin
16
+
17
+ class Auth
18
+
19
+ def initialize(authToken:, certificate:)
20
+ @a = authToken
21
+ @c = certificate
22
+
23
+ #authToken login is in progress
24
+ end
25
+
26
+ def client_proto(url, headers)
27
+
28
+ transport = Thrift::HTTPClientTransport.new(url)
29
+ transport.add_headers(headers)
30
+
31
+ protocol = Thrift::CompactProtocol.new(transport)
32
+
33
+ return protocol
34
+ end
35
+
36
+ def login
37
+ protocol = client_proto(Config::LOGIN_URL, Config::HEADERS)
38
+ loginClient = SecondaryQrcodeLoginService::Client.new(protocol)
39
+
40
+ sessionId = loginClient.createSession(CreateQrSessionRequest).authSessionId
41
+
42
+ qr_req = CreateQrCodeRequest.new
43
+ qr_req::authSessionId = sessionId
44
+
45
+ qr_url = loginClient.createQrCode(qr_req).callbackUrl
46
+
47
+ secret = Base64.strict_encode64(SecureRandom.base64(32))
48
+ version = 1
49
+ e2ee = "?secret=#{secret}" + "&e2eeVersion=#{version}"
50
+ puts "[LOGIN] => " + qr_url + e2ee
51
+
52
+ Config::HEADERS[:"X-Line-Access"] = ""
53
+
54
+ protocol = client_proto(Config::PERMIT_NOTICE_URL, Config::HEADERS)
55
+ certClient = SecondaryQrCodeLoginPermitNoticeService::Client.new(protocol)
56
+
57
+ qr_check = CheckQrCodeVerifiedRequest.new
58
+ qr_check::authSessionId = sessionId
59
+
60
+ begin
61
+ certClient.checkQrCodeVerified(qr_check)
62
+
63
+ rescue Net::ReadTimeout
64
+ puts "[Timeout] QrCode verification"
65
+ exit(1)
66
+ end
67
+
68
+ Config::HEADERS.delete(:"X-Line-Access") #=> ""
69
+
70
+ protocol = client_proto(Config::LOGIN_URL, Config::HEADERS)
71
+ loginClient = SecondaryQrcodeLoginService::Client.new(protocol)
72
+
73
+ begin
74
+
75
+ certificate_check = VerifyCertificateRequest.new
76
+ certificate_check::authSessionId = sessionId
77
+ certificate_check::certificate = @certificate
78
+
79
+ loginClient.verifyCertificate(certificate_check)
80
+
81
+ login_req = QrCodeLoginRequest.new
82
+ login_req.authSessionId = sessionId
83
+ login_req.systemName = "Ruby on Rails"
84
+ login_req.autoLoginIsRequired = FALSE
85
+
86
+ res = loginClient.qrCodeLogin(login_req)
87
+
88
+ puts "[CERT] => " + res.certificate
89
+ puts "[TOKEN] => " + res.accessToken
90
+
91
+ Config::HEADERS[:"X-Line-Access"] = res.accessToken
92
+
93
+ rescue SecondaryQrCodeException
94
+ pin_req = CreatePinCodeRequest.new
95
+ pin_req::authSessionId = sessionId
96
+ pincode = loginClient.createPinCode(pin_req).pinCode
97
+
98
+ if pincode != nil then
99
+ puts "[PIN] => " + pincode
100
+ pin_check = CheckPinCodeVerifiedRequest.new
101
+ pin_check::authSessionId = sessionId
102
+
103
+ begin
104
+ certClient.checkPinCodeVerified(pin_check)
105
+
106
+ login_req = QrCodeLoginRequest.new
107
+ login_req.authSessionId = sessionId
108
+ login_req.systemName = "Ruby on Rails"
109
+ login_req.autoLoginIsRequired = FALSE
110
+
111
+ res = loginClient.qrCodeLogin(login_req)
112
+
113
+ puts "[CERT] => " + res.certificate
114
+ puts "[TOKEN] => " + res.accessToken
115
+
116
+ Config::HEADERS[:"X-Line-Access"] = res.accessToken
117
+
118
+ rescue Net::ReadTimeout
119
+ puts "[Timeout] PinCode verification"
120
+ exit(1)
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,38 @@
1
+ $:.push('./gen-rb')
2
+
3
+ require_relative 'auth'
4
+ require_relative 'gen-rb/talk_service'
5
+
6
+ class LineClient
7
+
8
+ def initialize(authToken:, certificate:)
9
+ @a = authToken
10
+ @c = certificate
11
+ end
12
+
13
+ def doAuthService
14
+ Auth.new(authToken: @a, certificate: @c).login
15
+ end
16
+
17
+ def getTalkService
18
+ transport = Thrift::HTTPClientTransport.new(Config::TALK_SERVICE_V4_URL)
19
+ transport.add_headers(Config::HEADERS)
20
+
21
+ protocol = Thrift::CompactProtocol.new(transport)
22
+
23
+ client = TalkService::Client.new(protocol)
24
+
25
+ return client
26
+ end
27
+
28
+ def getPollService
29
+ transport = Thrift::HTTPClientTransport.new(Config::POLL_SERVICE_V4_URL)
30
+ transport.add_headers(Config::HEADERS)
31
+
32
+ protocol = Thrift::CompactProtocol.new(transport)
33
+
34
+ client = TalkService::Client.new(protocol)
35
+
36
+ return client
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ module Config
2
+ HOST_URL = "https://legy-jp-addr.line.naver.jp"
3
+ LOGIN_URL = HOST_URL + "/acct/lgn/sq/v1"
4
+ PERMIT_NOTICE_URL = HOST_URL + "/acct/lp/lgn/sq/v1"
5
+
6
+ TALK_SERVICE_V4_URL = HOST_URL + "/S4"
7
+ POLL_SERVICE_V4_URL = HOST_URL + "/P4"
8
+
9
+ HEADERS = {
10
+ "User-Agent": "LLA/2.11.1 Nexus 5X 10",
11
+ "X-Line-Application": "ANDROIDLITE\t2.11.1\tAndroid OS\t10.0;SECONDARY",
12
+ "x-lal": "ja_jp",
13
+ }
14
+ end
@@ -0,0 +1,268 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.13.0)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require_relative 'takagi_chan_types'
9
+
10
+ module AccountAuthFactorEapConnectService
11
+ class Client
12
+ include ::Thrift::Client
13
+
14
+ def connectEapAccount(request)
15
+ send_connectEapAccount(request)
16
+ return recv_connectEapAccount()
17
+ end
18
+
19
+ def send_connectEapAccount(request)
20
+ send_message('connectEapAccount', ConnectEapAccount_args, :request => request)
21
+ end
22
+
23
+ def recv_connectEapAccount()
24
+ result = receive_message(ConnectEapAccount_result)
25
+ return result.success unless result.success.nil?
26
+ raise result.e unless result.e.nil?
27
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'connectEapAccount failed: unknown result')
28
+ end
29
+
30
+ def disconnectEapAccount(request)
31
+ send_disconnectEapAccount(request)
32
+ return recv_disconnectEapAccount()
33
+ end
34
+
35
+ def send_disconnectEapAccount(request)
36
+ send_message('disconnectEapAccount', DisconnectEapAccount_args, :request => request)
37
+ end
38
+
39
+ def recv_disconnectEapAccount()
40
+ result = receive_message(DisconnectEapAccount_result)
41
+ return result.success unless result.success.nil?
42
+ raise result.e unless result.e.nil?
43
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'disconnectEapAccount failed: unknown result')
44
+ end
45
+
46
+ def openSession(request)
47
+ send_openSession(request)
48
+ return recv_openSession()
49
+ end
50
+
51
+ def send_openSession(request)
52
+ send_message('openSession', OpenSession_args, :request => request)
53
+ end
54
+
55
+ def recv_openSession()
56
+ result = receive_message(OpenSession_result)
57
+ return result.success unless result.success.nil?
58
+ raise result.e unless result.e.nil?
59
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'openSession failed: unknown result')
60
+ end
61
+
62
+ def verifyEapLogin(request)
63
+ send_verifyEapLogin(request)
64
+ return recv_verifyEapLogin()
65
+ end
66
+
67
+ def send_verifyEapLogin(request)
68
+ send_message('verifyEapLogin', VerifyEapLogin_args, :request => request)
69
+ end
70
+
71
+ def recv_verifyEapLogin()
72
+ result = receive_message(VerifyEapLogin_result)
73
+ return result.success unless result.success.nil?
74
+ raise result.e unless result.e.nil?
75
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'verifyEapLogin failed: unknown result')
76
+ end
77
+
78
+ end
79
+
80
+ class Processor
81
+ include ::Thrift::Processor
82
+
83
+ def process_connectEapAccount(seqid, iprot, oprot)
84
+ args = read_args(iprot, ConnectEapAccount_args)
85
+ result = ConnectEapAccount_result.new()
86
+ begin
87
+ result.success = @handler.connectEapAccount(args.request)
88
+ rescue ::AccountEapConnectException => e
89
+ result.e = e
90
+ end
91
+ write_result(result, oprot, 'connectEapAccount', seqid)
92
+ end
93
+
94
+ def process_disconnectEapAccount(seqid, iprot, oprot)
95
+ args = read_args(iprot, DisconnectEapAccount_args)
96
+ result = DisconnectEapAccount_result.new()
97
+ begin
98
+ result.success = @handler.disconnectEapAccount(args.request)
99
+ rescue ::AccountEapConnectException => e
100
+ result.e = e
101
+ end
102
+ write_result(result, oprot, 'disconnectEapAccount', seqid)
103
+ end
104
+
105
+ def process_openSession(seqid, iprot, oprot)
106
+ args = read_args(iprot, OpenSession_args)
107
+ result = OpenSession_result.new()
108
+ begin
109
+ result.success = @handler.openSession(args.request)
110
+ rescue ::AuthException => e
111
+ result.e = e
112
+ end
113
+ write_result(result, oprot, 'openSession', seqid)
114
+ end
115
+
116
+ def process_verifyEapLogin(seqid, iprot, oprot)
117
+ args = read_args(iprot, VerifyEapLogin_args)
118
+ result = VerifyEapLogin_result.new()
119
+ begin
120
+ result.success = @handler.verifyEapLogin(args.request)
121
+ rescue ::AccountEapConnectException => e
122
+ result.e = e
123
+ end
124
+ write_result(result, oprot, 'verifyEapLogin', seqid)
125
+ end
126
+
127
+ end
128
+
129
+ # HELPER FUNCTIONS AND STRUCTURES
130
+
131
+ class ConnectEapAccount_args
132
+ include ::Thrift::Struct, ::Thrift::Struct_Union
133
+ REQUEST = 1
134
+
135
+ FIELDS = {
136
+ REQUEST => {:type => ::Thrift::Types::STRUCT, :name => 'request', :class => ::ConnectEapAccountRequest}
137
+ }
138
+
139
+ def struct_fields; FIELDS; end
140
+
141
+ def validate
142
+ end
143
+
144
+ ::Thrift::Struct.generate_accessors self
145
+ end
146
+
147
+ class ConnectEapAccount_result
148
+ include ::Thrift::Struct, ::Thrift::Struct_Union
149
+ SUCCESS = 0
150
+ E = 1
151
+
152
+ FIELDS = {
153
+ SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::ConnectEapAccountResponse},
154
+ E => {:type => ::Thrift::Types::STRUCT, :name => 'e', :class => ::AccountEapConnectException}
155
+ }
156
+
157
+ def struct_fields; FIELDS; end
158
+
159
+ def validate
160
+ end
161
+
162
+ ::Thrift::Struct.generate_accessors self
163
+ end
164
+
165
+ class DisconnectEapAccount_args
166
+ include ::Thrift::Struct, ::Thrift::Struct_Union
167
+ REQUEST = 1
168
+
169
+ FIELDS = {
170
+ REQUEST => {:type => ::Thrift::Types::STRUCT, :name => 'request', :class => ::DisconnectEapAccountRequest}
171
+ }
172
+
173
+ def struct_fields; FIELDS; end
174
+
175
+ def validate
176
+ end
177
+
178
+ ::Thrift::Struct.generate_accessors self
179
+ end
180
+
181
+ class DisconnectEapAccount_result
182
+ include ::Thrift::Struct, ::Thrift::Struct_Union
183
+ SUCCESS = 0
184
+ E = 1
185
+
186
+ FIELDS = {
187
+ SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::DisconnectEapAccountResponse},
188
+ E => {:type => ::Thrift::Types::STRUCT, :name => 'e', :class => ::AccountEapConnectException}
189
+ }
190
+
191
+ def struct_fields; FIELDS; end
192
+
193
+ def validate
194
+ end
195
+
196
+ ::Thrift::Struct.generate_accessors self
197
+ end
198
+
199
+ class OpenSession_args
200
+ include ::Thrift::Struct, ::Thrift::Struct_Union
201
+ REQUEST = 1
202
+
203
+ FIELDS = {
204
+ REQUEST => {:type => ::Thrift::Types::STRUCT, :name => 'request', :class => ::OpenSessionRequest}
205
+ }
206
+
207
+ def struct_fields; FIELDS; end
208
+
209
+ def validate
210
+ end
211
+
212
+ ::Thrift::Struct.generate_accessors self
213
+ end
214
+
215
+ class OpenSession_result
216
+ include ::Thrift::Struct, ::Thrift::Struct_Union
217
+ SUCCESS = 0
218
+ E = 1
219
+
220
+ FIELDS = {
221
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'},
222
+ E => {:type => ::Thrift::Types::STRUCT, :name => 'e', :class => ::AuthException}
223
+ }
224
+
225
+ def struct_fields; FIELDS; end
226
+
227
+ def validate
228
+ end
229
+
230
+ ::Thrift::Struct.generate_accessors self
231
+ end
232
+
233
+ class VerifyEapLogin_args
234
+ include ::Thrift::Struct, ::Thrift::Struct_Union
235
+ REQUEST = 1
236
+
237
+ FIELDS = {
238
+ REQUEST => {:type => ::Thrift::Types::STRUCT, :name => 'request', :class => ::VerifyEapLoginRequest}
239
+ }
240
+
241
+ def struct_fields; FIELDS; end
242
+
243
+ def validate
244
+ end
245
+
246
+ ::Thrift::Struct.generate_accessors self
247
+ end
248
+
249
+ class VerifyEapLogin_result
250
+ include ::Thrift::Struct, ::Thrift::Struct_Union
251
+ SUCCESS = 0
252
+ E = 1
253
+
254
+ FIELDS = {
255
+ SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::VerifyEapLoginResponse},
256
+ E => {:type => ::Thrift::Types::STRUCT, :name => 'e', :class => ::AccountEapConnectException}
257
+ }
258
+
259
+ def struct_fields; FIELDS; end
260
+
261
+ def validate
262
+ end
263
+
264
+ ::Thrift::Struct.generate_accessors self
265
+ end
266
+
267
+ end
268
+