asca 0.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 +7 -0
- data/.gitignore +8 -0
- data/.rakeTasks +7 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +10 -0
- data/asca.gemspec +36 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/asca +30 -0
- data/lib/asca.rb +10 -0
- data/lib/asca/configuration.rb +55 -0
- data/lib/asca/consts.rb +10 -0
- data/lib/asca/profiles.rb +36 -0
- data/lib/asca/token.rb +92 -0
- data/lib/asca/version.rb +3 -0
- metadata +150 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: eb99fd99b67a5d8440d6aa5cdc76e1a5b2626f1791a552a997e739639c2cef24
|
|
4
|
+
data.tar.gz: b6f522bd18d8cec13379bbe6cb5dd12eb7bea4d33df66c9536aee2f9c2cf95f0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5662fe1aa8eea3b3b60d78f95f4dbe83faf5b514c435c7718da8a7502ff2e9dbd8b739ccd29f611a017cca5495f38c8eedc0cfc14f6408c28b737d8f05b8cb9b
|
|
7
|
+
data.tar.gz: 811fed53802b08427f50dc1d5b365d403b05afcc5522dc366b3fb3425ebb70abbce13fb0673132dc1cb05af5004d4ee19925524514c21e594e3d4594a80864c5
|
data/.gitignore
ADDED
data/.rakeTasks
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
|
3
|
+
You are allowed to:
|
|
4
|
+
1. Remove rake task
|
|
5
|
+
2. Add existing rake tasks
|
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build asca-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install asca-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install asca-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push asca-0.1.0.gem to https://github.com/xueminghao/appstoreconnectapi.git" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run tests" fullCmd="test" taksId="test" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at minghaoxue@clubfactory.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
asca (0.1.0)
|
|
5
|
+
curb
|
|
6
|
+
json
|
|
7
|
+
jwt
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: https://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
curb (0.9.10)
|
|
13
|
+
json (2.3.1)
|
|
14
|
+
jwt (2.2.2)
|
|
15
|
+
minitest (5.14.1)
|
|
16
|
+
rake (10.5.0)
|
|
17
|
+
|
|
18
|
+
PLATFORMS
|
|
19
|
+
ruby
|
|
20
|
+
|
|
21
|
+
DEPENDENCIES
|
|
22
|
+
asca!
|
|
23
|
+
bundler (~> 2.0)
|
|
24
|
+
minitest (~> 5.0)
|
|
25
|
+
rake (~> 10.0)
|
|
26
|
+
|
|
27
|
+
BUNDLED WITH
|
|
28
|
+
2.0.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 xueminghao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Asca
|
|
2
|
+
|
|
3
|
+
An apple app store connect api wrapper based on ruby!!!
|
|
4
|
+
|
|
5
|
+
Why ruby?
|
|
6
|
+
|
|
7
|
+
Every mac's ready for ruby out of the box!!!
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem install specific_install
|
|
15
|
+
gem specific_install https://github.com/xueminghao/appstoreconnectapi.git
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
* Download provisioning files by name from developer account
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
asca -a profile-download -n [profile-name]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
* Download & install provisioning files by name from developer account
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
asca -a profile-install -n [profile-name]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## TODO
|
|
33
|
+
|
|
34
|
+
Support more actions such as device management
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Contributing
|
|
38
|
+
|
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/xueminghao/appstoreconnectapi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/asca.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require "asca/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "asca"
|
|
7
|
+
spec.version = Asca::VERSION
|
|
8
|
+
spec.authors = ["xueminghao"]
|
|
9
|
+
spec.email = ["minghaoxue@clubfactory.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = %q{A ruby wrapper for apple store connect api}
|
|
12
|
+
spec.description = %q{A ruby wrapper for apple store connect api}
|
|
13
|
+
spec.homepage = "https://github.com/xueminghao/appstoreconnectapi"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/xueminghao/appstoreconnectapi.git"
|
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/xueminghao/appstoreconnectapi.git"
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
33
|
+
spec.add_dependency "json"
|
|
34
|
+
spec.add_dependency "curb"
|
|
35
|
+
spec.add_dependency 'jwt'
|
|
36
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "asca"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/asca
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
|
3
|
+
|
|
4
|
+
require "asca"
|
|
5
|
+
|
|
6
|
+
#https://apidock.com/ruby/OptionParser
|
|
7
|
+
require "optparse"
|
|
8
|
+
|
|
9
|
+
require 'optparse'
|
|
10
|
+
|
|
11
|
+
options = {}
|
|
12
|
+
option_parser = OptionParser.new do |opts|
|
|
13
|
+
opts.banner = 'This is an apple connect api wrapper cli.'
|
|
14
|
+
|
|
15
|
+
opts.on('-a action-name', '--action action-name', 'profile-install, profile-download') do |value|
|
|
16
|
+
options[:action] = value
|
|
17
|
+
end
|
|
18
|
+
opts.on('-n name', '--name name', 'Profile name') do |value|
|
|
19
|
+
options[:profile_name] = value
|
|
20
|
+
end
|
|
21
|
+
end.parse!
|
|
22
|
+
|
|
23
|
+
case options[:action]
|
|
24
|
+
when 'profile-download'
|
|
25
|
+
Asca::Profiles.download_profile options[:profile_name]
|
|
26
|
+
when 'profile-install'
|
|
27
|
+
Asca::Profiles.install_profile options[:profile_name]
|
|
28
|
+
else
|
|
29
|
+
puts "Unsupported action: " + options[:action]
|
|
30
|
+
end
|
data/lib/asca.rb
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
module Asca
|
|
5
|
+
class Configuration
|
|
6
|
+
ROOTDIR = File.expand_path '~/.com.hurryup.asca'
|
|
7
|
+
JSONFILE = File.expand_path 'config.json', ROOTDIR
|
|
8
|
+
CACHE_DIR = File.expand_path 'cache', ROOTDIR
|
|
9
|
+
class << self
|
|
10
|
+
# reset config file
|
|
11
|
+
def reset_config
|
|
12
|
+
# remove all
|
|
13
|
+
FileUtils.rm_rf(ROOTDIR)
|
|
14
|
+
|
|
15
|
+
# create root dir
|
|
16
|
+
Dir.mkdir ROOTDIR
|
|
17
|
+
|
|
18
|
+
# create cache dir
|
|
19
|
+
Dir.mkdir CACHE_DIR
|
|
20
|
+
|
|
21
|
+
# init config file
|
|
22
|
+
File.open(JSONFILE, 'w') { |file|
|
|
23
|
+
file.write("{}")
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# update config
|
|
28
|
+
def update_config(key, value)
|
|
29
|
+
if !File.exist?(JSONFILE)
|
|
30
|
+
reset_config
|
|
31
|
+
end
|
|
32
|
+
file_content = File.read(JSONFILE)
|
|
33
|
+
configuration = JSON.parse(file_content)
|
|
34
|
+
if value
|
|
35
|
+
configuration[key] = value
|
|
36
|
+
else
|
|
37
|
+
configuration.delete(key)
|
|
38
|
+
end
|
|
39
|
+
File.open(JSONFILE, 'w') { |file|
|
|
40
|
+
file.write(JSON.pretty_generate(configuration))
|
|
41
|
+
}
|
|
42
|
+
return 0
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def get_config(key)
|
|
46
|
+
if !File.exist?(JSONFILE)
|
|
47
|
+
reset_config
|
|
48
|
+
end
|
|
49
|
+
file_content = File.read(JSONFILE)
|
|
50
|
+
configuration = JSON.parse(file_content)
|
|
51
|
+
return configuration[key]
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/asca/consts.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'curb'
|
|
2
|
+
require 'json'
|
|
3
|
+
require "base64"
|
|
4
|
+
|
|
5
|
+
module Asca
|
|
6
|
+
class Profiles
|
|
7
|
+
class << self
|
|
8
|
+
def download_profile(profile_name, out_put_dir = nil)
|
|
9
|
+
if !out_put_dir
|
|
10
|
+
out_put_dir = Asca::Configuration.get_config('out_put_dir')
|
|
11
|
+
if !out_put_dir
|
|
12
|
+
puts "Please enter your out put dir:"
|
|
13
|
+
out_put_dir = File.expand_path(gets.chomp)
|
|
14
|
+
Asca::Configuration.update_config('out_put_dir', out_put_dir)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
http = Curl.get(URI_PROFILES, { 'filter[name]' => profile_name}) do |http|
|
|
18
|
+
http.headers['Authorization'] = ' Bearer ' + Asca::Token.new_token
|
|
19
|
+
end
|
|
20
|
+
profile_obj = JSON.parse(http.body_str)
|
|
21
|
+
profile_content = profile_obj["data"][0]["attributes"]['profileContent']
|
|
22
|
+
File.open(File.expand_path(profile_name + ".mobileprovision", out_put_dir), 'w') do |file|
|
|
23
|
+
file.write(Base64.decode64(profile_content))
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def install_profile(profile_name)
|
|
28
|
+
download_profile profile_name, Asca::Configuration::CACHE_DIR
|
|
29
|
+
profile_file_path = File.expand_path(profile_name + ".mobileprovision", Asca::Configuration::CACHE_DIR)
|
|
30
|
+
|
|
31
|
+
# install profile
|
|
32
|
+
`open #{profile_file_path}`
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/asca/token.rb
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'jwt'
|
|
3
|
+
|
|
4
|
+
module Asca
|
|
5
|
+
class Token
|
|
6
|
+
EXPIRE_DURATION = 20 * 60
|
|
7
|
+
class << self
|
|
8
|
+
# Generate new jwt token.
|
|
9
|
+
def new_token
|
|
10
|
+
# get token from cache
|
|
11
|
+
token = get_token_from_cache
|
|
12
|
+
if token
|
|
13
|
+
return token
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# get kid
|
|
17
|
+
kid = Asca::Configuration.get_config('kid')
|
|
18
|
+
if !kid
|
|
19
|
+
puts "Before generating a jwt token, please enter your kid:"
|
|
20
|
+
kid = gets.chomp
|
|
21
|
+
Asca::Configuration.update_config('kid', kid)
|
|
22
|
+
end
|
|
23
|
+
if !kid
|
|
24
|
+
puts "Error: no kid!"
|
|
25
|
+
return
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# get issuer id
|
|
29
|
+
iss = Asca::Configuration.get_config('iss')
|
|
30
|
+
if !iss
|
|
31
|
+
puts "Before generating a jwt token, please enter your issuer id:"
|
|
32
|
+
iss = gets.chomp
|
|
33
|
+
Asca::Configuration.update_config('iss', iss)
|
|
34
|
+
end
|
|
35
|
+
if !iss
|
|
36
|
+
puts "Error: no issuer id!"
|
|
37
|
+
return
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# get private key
|
|
41
|
+
private_key = Asca::Configuration.get_config('private_key')
|
|
42
|
+
if !private_key
|
|
43
|
+
puts "Before generating a jwt token, please enter your private key path:"
|
|
44
|
+
private_key_path = gets.chomp
|
|
45
|
+
private_key = File.read private_key_path
|
|
46
|
+
Asca::Configuration.update_config('private_key', private_key)
|
|
47
|
+
end
|
|
48
|
+
if !private_key
|
|
49
|
+
puts "Error: no private key!"
|
|
50
|
+
return
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# generate jwt header
|
|
54
|
+
jwt_header = {
|
|
55
|
+
"alg": "ES256",
|
|
56
|
+
"kid": kid,
|
|
57
|
+
"typ": "JWT"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# generate jwt payload
|
|
61
|
+
exp = Time.now.to_i + EXPIRE_DURATION
|
|
62
|
+
jwt_payload = {
|
|
63
|
+
"iss": iss,
|
|
64
|
+
"exp": exp,
|
|
65
|
+
"aud": "appstoreconnect-v1"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
es_key = OpenSSL::PKey::EC.new private_key
|
|
69
|
+
|
|
70
|
+
token = JWT.encode jwt_payload, es_key, 'ES256', jwt_header
|
|
71
|
+
Asca::Configuration.update_config('cache_token_time', exp)
|
|
72
|
+
Asca::Configuration.update_config('cache_token', token)
|
|
73
|
+
puts "==== New token generated ===="
|
|
74
|
+
puts token
|
|
75
|
+
puts "============================="
|
|
76
|
+
return token
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def get_token_from_cache
|
|
80
|
+
cached_token_time = Asca::Configuration.get_config('cache_token_time')
|
|
81
|
+
if !cached_token_time
|
|
82
|
+
return nil
|
|
83
|
+
end
|
|
84
|
+
current = Time.now.to_i
|
|
85
|
+
if cached_token_time - current > EXPIRE_DURATION
|
|
86
|
+
return nil
|
|
87
|
+
end
|
|
88
|
+
return Asca::Configuration.get_config('cache_token')
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
data/lib/asca/version.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: asca
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- xueminghao
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-08-18 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: minitest
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '5.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '5.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: json
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: curb
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: jwt
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: A ruby wrapper for apple store connect api
|
|
98
|
+
email:
|
|
99
|
+
- minghaoxue@clubfactory.com
|
|
100
|
+
executables:
|
|
101
|
+
- asca
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".rakeTasks"
|
|
107
|
+
- ".travis.yml"
|
|
108
|
+
- CODE_OF_CONDUCT.md
|
|
109
|
+
- Gemfile
|
|
110
|
+
- Gemfile.lock
|
|
111
|
+
- LICENSE.txt
|
|
112
|
+
- README.md
|
|
113
|
+
- Rakefile
|
|
114
|
+
- asca.gemspec
|
|
115
|
+
- bin/console
|
|
116
|
+
- bin/setup
|
|
117
|
+
- exe/asca
|
|
118
|
+
- lib/asca.rb
|
|
119
|
+
- lib/asca/configuration.rb
|
|
120
|
+
- lib/asca/consts.rb
|
|
121
|
+
- lib/asca/profiles.rb
|
|
122
|
+
- lib/asca/token.rb
|
|
123
|
+
- lib/asca/version.rb
|
|
124
|
+
homepage: https://github.com/xueminghao/appstoreconnectapi
|
|
125
|
+
licenses:
|
|
126
|
+
- MIT
|
|
127
|
+
metadata:
|
|
128
|
+
homepage_uri: https://github.com/xueminghao/appstoreconnectapi
|
|
129
|
+
source_code_uri: https://github.com/xueminghao/appstoreconnectapi.git
|
|
130
|
+
changelog_uri: https://github.com/xueminghao/appstoreconnectapi.git
|
|
131
|
+
post_install_message:
|
|
132
|
+
rdoc_options: []
|
|
133
|
+
require_paths:
|
|
134
|
+
- lib
|
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - ">="
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '0'
|
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '0'
|
|
145
|
+
requirements: []
|
|
146
|
+
rubygems_version: 3.0.3
|
|
147
|
+
signing_key:
|
|
148
|
+
specification_version: 4
|
|
149
|
+
summary: A ruby wrapper for apple store connect api
|
|
150
|
+
test_files: []
|