jpsclient 2.0.6 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad5bd859a9d9ac069a226f185690a9b913e05d0f069f0110a1037845229be10b
4
- data.tar.gz: 889c49e9c9ef77845eef1aaf2b0514d7ad23608493912757ecca98e678ecf136
3
+ metadata.gz: 981dafda351203d47d3137bf2e81b0e4e25bb188f23f0842b6b979379d671b23
4
+ data.tar.gz: e779e003a1ba7d260e146feecc07e5484580e38daa12c94a2613ebed0dc2cf8f
5
5
  SHA512:
6
- metadata.gz: 394b3e8b9052b2eb58681dc890b5c495e134a331d3dc1b3d6c255a76e4d801836b2f179d9989968d62294776872cf7367752264702f8a8fd545871fb3c2b5b2f
7
- data.tar.gz: 91458dc40febc7035047212ba3843a1e32618bca862e6d0fe58770436ed7bad4de35ea791314150b42ad7b3c96cf6a4b9e3d07d9123a01bd3e556fc378fe3d46
6
+ metadata.gz: e18798568d960240dbb7a9d0929f085ecedd5cc1ecaf7abf8ab342dbef25d201a57b39e10d3718e610f6af5698010634a716bacbc0b651bde3e14b1e9e1533be
7
+ data.tar.gz: e0f48d126f0ac6806f7e4263f1d329c67c3d83193865b4a2040c940c7ca3e6e99bf56d87280dfd4b2c38c71e39c1fb4f00de0c001e15c3facfbbae86fd7df5f8
@@ -9,6 +9,7 @@ module JPSClient
9
9
  # - 删除 JKS 证书
10
10
  # - 获取 JKS 证书列表
11
11
  # - 获取 JKS 证书详情
12
+ # - 重命名 JKS 证书(异步)
12
13
  # - APK 重签名(异步)
13
14
  module AndroidJks
14
15
 
@@ -19,24 +20,23 @@ module JPSClient
19
20
  # @param key_password [String] key 密码,为空则与 store_password 一致
20
21
  # @param validity [Integer] 有效期(天),默认 36500
21
22
  # @param distinguished_name [Hash] DN 信息,如 {CN: "xxx", O: "xxx"}
22
- # @param bundle_id [String] 包名
23
+ # @param bundle_id [String] 包名(必填)
23
24
  # @param google_account [String] Google 开发者账号
24
25
  # @param project_id [String] 关联项目 ID
25
26
  # @param remark [String] 备注
26
27
  # @return [Hash] API 响应(异步任务)
27
- def create_android_jks(alias_name:, store_password: nil, key_password: nil, validity: nil,
28
- distinguished_name: nil, bundle_id: nil, google_account: nil,
28
+ def create_android_jks(alias_name:, bundle_id:, store_password: nil, key_password: nil, validity: nil,
29
+ distinguished_name: nil, google_account: nil,
29
30
  project_id: nil, remark: nil)
30
31
  config = @request_config && @request_config["android_jks_create"]
31
32
  raise JPSClient::ExceptionError, "Missing config for android_jks_create" unless config && config["url"]
32
33
  path = config["url"]
33
34
 
34
- body_params = { aliasName: alias_name }
35
+ body_params = { aliasName: alias_name, bundleId: bundle_id }
35
36
  body_params[:storePassword] = store_password if store_password
36
37
  body_params[:keyPassword] = key_password if key_password
37
38
  body_params[:validity] = validity if validity
38
39
  body_params[:distinguishedName] = distinguished_name if distinguished_name
39
- body_params[:bundleId] = bundle_id if bundle_id
40
40
  body_params[:googleAccount] = google_account if google_account
41
41
  body_params[:projectId] = project_id if project_id
42
42
  body_params[:remark] = remark if remark
@@ -139,14 +139,14 @@ module JPSClient
139
139
 
140
140
  # 获取 Android JKS 证书详情
141
141
  #
142
- # @param alias_name [String] 证书别名(必填)
143
- # @return [Hash] API 响应,data 包含 id、jksFileUrl、storePassword、keyPassword
144
- def get_android_jks_detail(alias_name:)
142
+ # @param bundle_id [String] 包名(必填)
143
+ # @return [Hash] API 响应,data 包含 id、aliasName、bundleId、jksFileUrl、storePassword、keyPassword
144
+ def get_android_jks_detail(bundle_id:)
145
145
  config = @request_config && @request_config["android_jks_detail"]
146
146
  raise JPSClient::ExceptionError, "Missing config for android_jks_detail" unless config && config["url"]
147
147
  path = config["url"]
148
148
 
149
- get_params = { aliasName: alias_name }
149
+ get_params = { bundleId: bundle_id }
150
150
 
151
151
  response = @http_client.get(path, params: get_params)
152
152
  result = JPSClient::Response.new(response)
@@ -160,6 +160,35 @@ module JPSClient
160
160
  return result.to_h
161
161
  end
162
162
 
163
+ # 重命名 Android JKS 证书(异步接口)
164
+ #
165
+ # @param id [String] JKS 证书 ID(必填)
166
+ # @param new_alias [String] 新别名(必填)
167
+ # @param new_store_password [String] 新 storePassword(必填)
168
+ # @return [Hash] API 响应(异步任务)
169
+ def rename_android_jks(id:, new_alias:, new_store_password:)
170
+ config = @request_config && @request_config["android_jks_rename"]
171
+ raise JPSClient::ExceptionError, "Missing config for android_jks_rename" unless config && config["url"]
172
+ path = config["url"]
173
+
174
+ body_params = {
175
+ id: id,
176
+ newAlias: new_alias,
177
+ newStorePassword: new_store_password
178
+ }
179
+
180
+ response = @http_client.post(path, body: body_params)
181
+ result = JPSClient::Response.new(response)
182
+
183
+ if result.need_login?
184
+ do_login(force_login: true)
185
+ response = @http_client.post(path, body: body_params)
186
+ result = JPSClient::Response.new(response)
187
+ end
188
+
189
+ return result.to_h
190
+ end
191
+
163
192
  # APK 重签名(异步接口)
164
193
  #
165
194
  # @param input_s3_key [String] 输入 APK 文件的 S3 Key(必填)
@@ -3,6 +3,8 @@ require 'typhoeus'
3
3
  require 'thread'
4
4
  require 'etc'
5
5
  require 'digest'
6
+ require 'cgi'
7
+ require 'uri'
6
8
  require 'jpsclient/base/exception'
7
9
  require 'jpsclient/upload/upload_config'
8
10
  require 'jpsclient/upload/upload_progress'
@@ -39,12 +41,13 @@ module JPSClient
39
41
  @upload_failed = false
40
42
  end
41
43
 
42
- def upload_file(binary_file:nil, isAttach:false)
44
+ def upload_file(binary_file:nil, isAttach:false, enable_cloudflare:false)
43
45
 
44
46
  raise ExceptionError, "上传文件不能为空" if binary_file.nil? || !File.exist?(binary_file)
45
47
 
46
48
  @upload_binary_file = binary_file
47
49
  @file_size = File.size(@upload_binary_file)
50
+ @enable_cloudflare = enable_cloudflare
48
51
 
49
52
  # 处理空文件
50
53
  if @file_size == 0
@@ -89,6 +92,11 @@ module JPSClient
89
92
  upload_config: @upload_config
90
93
  )
91
94
 
95
+ # Debug 模式下打印初始化结果
96
+ if ENV['PINDO_DEBUG'] == '1'
97
+ puts "[PINDO_DEBUG] init_file_multipart 返回: #{init_result.inspect}"
98
+ end
99
+
92
100
  if init_result.nil? || !init_result.dig("data", "upload_id")
93
101
  raise ExceptionError, "初始化上传失败,请检查网络或服务器状态"
94
102
  end
@@ -291,7 +299,21 @@ module JPSClient
291
299
  return
292
300
  end
293
301
 
294
- upload_url = sign_result["data"]["url"]
302
+ original_url = sign_result["data"]["url"]
303
+ upload_url = original_url
304
+
305
+ # 如果启用 Cloudflare 加速,转换 URL
306
+ if @enable_cloudflare
307
+ upload_url = convert_to_cloudflare_fetch_url(original_url)
308
+ end
309
+
310
+ # Debug 模式下打印加速前后 URL 对比
311
+ if ENV['PINDO_DEBUG'] == '1'
312
+ puts "[PINDO_DEBUG] 分片 ##{part_no} 原始 URL: #{original_url}"
313
+ if @enable_cloudflare
314
+ puts "[PINDO_DEBUG] 分片 ##{part_no} 加速 URL: #{upload_url}"
315
+ end
316
+ end
295
317
 
296
318
  # 计算分片数据范围(使用配置的分片大小)
297
319
  chunk_size = @upload_config.chunk_size_bytes
@@ -401,7 +423,29 @@ module JPSClient
401
423
  end
402
424
  end
403
425
 
426
+ # 将 S3 预签名 URL 转换为 Cloudflare fetch 代理 URL
427
+ # 格式: https://fetch.goosoul.dev/{filename}?url={percent_encoded_original_url}
428
+ def convert_to_cloudflare_fetch_url(original_url)
429
+ return original_url if original_url.nil? || original_url.empty?
404
430
 
431
+ begin
432
+ uri = URI.parse(original_url)
433
+
434
+ # 从路径中提取文件名
435
+ path_parts = uri.path.split('/')
436
+ filename = path_parts.last || 'file'
437
+
438
+ # 对原始完整 URL 进行 percent 编码
439
+ encoded_url = CGI.escape(original_url)
440
+
441
+ # 构建 Cloudflare fetch URL
442
+ "https://fetch.goosoul.dev/#{filename}?url=#{encoded_url}"
443
+ rescue => e
444
+ # 解析失败时返回原始 URL
445
+ Logger.instance.info("URL 转换失败: #{e.message},使用原始 URL")
446
+ original_url
447
+ end
448
+ end
405
449
 
406
450
  end
407
- end
451
+ end
@@ -58,7 +58,7 @@ module JPSClient
58
58
  attach_url: json_config['attach_url'] || "attach_file/",
59
59
  upload_type: json_config['upload_type'] || "s3",
60
60
  concurrent_workers: concurrent_workers,
61
- chunk_size_mb: json_config['chunk_size_mb'] || 5,
61
+ chunk_size_mb: json_config['chunk_size_mb'] || 10,
62
62
  max_retry_times: json_config['max_retry_times'] || 6, # 每个分片重试6次
63
63
  timeout_seconds: json_config['timeout_seconds'] || 600, # 单个分片超时10分钟
64
64
  media_region: json_config['media_region'] || "ap-east-1",
@@ -1,3 +1,3 @@
1
1
  module JPSClient
2
- VERSION = "2.0.6"
3
- end
2
+ VERSION = '2.1.0'
3
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jpsclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Your Name
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-03-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: faraday
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  - !ruby/object:Gem::Version
282
282
  version: '0'
283
283
  requirements: []
284
- rubygems_version: 3.6.3
284
+ rubygems_version: 4.0.3
285
285
  specification_version: 4
286
286
  summary: JPS Platform API Client with Full API Support
287
287
  test_files: []