app_store_connect_jwt 0.2.0 → 0.3.0

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: 62dcbed3328ffadd0bc9835827e963cb83e2f998d59afbc68d858c1a5c0efcfa
4
- data.tar.gz: 5f0bc245b396b303331d3a3b5971a38c4fa425d16e857a02c8af72f0b5cfd282
3
+ metadata.gz: c71424de5f38c22a6d37033331e216d60aae61048d99ef31ecf87bcaa944604a
4
+ data.tar.gz: bb19b41b06c00c459303563fca6ad9a4258313f923aebff7db594ee71f3eef4d
5
5
  SHA512:
6
- metadata.gz: 2bae4b64b467d99f8fc7ebce578a2a600df9f332e22cca867f9637431ed50f3e40679e331683a16179932f72895ce9472c6113c6666c79e5cd3be95796a4dd65
7
- data.tar.gz: acdcf3d719bc3f12271a9876aa2f629eef37c4ab9a198f19aa9a7e58b36208517083a14b2f8f9a9aa45a113d9f51479e7334010c503ddd762921f1b7a512324c
6
+ metadata.gz: 82a3c208645dddbbec4a0dc63bf09522601e5f3aced6cc04199b8215074f6cdc78de41c833cd63413fefb62e9febad35b89ca524920529dee6c5fdb5e2e2e620
7
+ data.tar.gz: 6c9a1e669a463caebdcdaeb77db2222c35ab542f2e54618bfd60ae6edfaccbd3af2c6b68366212bda334e84da02d3c7e46a81ab04ddb948f62de21dff27575d2
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,6 @@
1
+ ---
2
+ blank_issues_enabled: true
3
+ contact_links:
4
+ - name: Twitter
5
+ url: https://twitter.com/kyledecot
6
+ about: Contact me on Twitter
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: Lint
3
+
4
+ on:
5
+ push:
6
+
7
+ jobs:
8
+ yamllint:
9
+ name: yamllint
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@master
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v1
16
+ with:
17
+ python-version: 3.x
18
+ - name: Install
19
+ run: |
20
+ pip install --user --no-warn-script-location yamllint
21
+ - name: Run
22
+ run: /home/runner/.local/bin/yamllint .
23
+
24
+ rubocop:
25
+ name: rubocop
26
+ runs-on: ubuntu-latest
27
+
28
+ steps:
29
+ - uses: actions/checkout@master
30
+ - name: Set up Ruby 2.6
31
+ uses: actions/setup-ruby@v1
32
+ with:
33
+ ruby-version: 2.6.x
34
+ - name: Install dependencies
35
+ run: |
36
+ gem install bundler
37
+ bundle install --jobs=3 --retry=3
38
+ - name: Run rubocop
39
+ run: bundle exec rubocop -P -fq
@@ -8,7 +8,7 @@ on:
8
8
 
9
9
  jobs:
10
10
  rspec:
11
- name: RSpec
11
+ name: rspec
12
12
  runs-on: ubuntu-latest
13
13
 
14
14
  steps:
@@ -26,7 +26,7 @@ jobs:
26
26
  ./cc-test-reporter before-build
27
27
  - name: Run rspec
28
28
  run: |
29
- GLI_DEBUG=true bundle exec rspec
29
+ bundle exec rspec
30
30
  ./cc-test-reporter after-build --exit-code $? -t simplecov
31
31
  env:
32
32
  CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
data/.rubocop.yml CHANGED
@@ -10,17 +10,17 @@
10
10
  # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
11
11
  #
12
12
  ---
13
- Metrics/MethodLength:
13
+ Layout/LineLength:
14
14
  Enabled: false
15
15
 
16
16
  Metrics/BlockLength:
17
17
  Enabled: false
18
18
 
19
- Style/Documentation:
19
+ Metrics/ClassLength:
20
20
  Enabled: false
21
21
 
22
- Layout/LineLength:
22
+ Metrics/MethodLength:
23
23
  Enabled: false
24
24
 
25
- Metrics/ClassLength:
25
+ Style/Documentation:
26
26
  Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.6.5
data/.yamllint ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ extends: default
3
+ rules:
4
+ line-length: disable
5
+ truthy: disable
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in app_store_connect_jwt.gemspec
6
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_store_connect_jwt (0.2.0)
4
+ app_store_connect_jwt (0.3.0)
5
5
  gli
6
6
  jwt
7
7
 
@@ -12,11 +12,35 @@ GEM
12
12
  coderay (1.1.2)
13
13
  diff-lcs (1.3)
14
14
  docile (1.3.2)
15
+ ffi (1.12.2)
16
+ formatador (0.2.5)
15
17
  gli (2.19.0)
18
+ guard (2.16.1)
19
+ formatador (>= 0.2.4)
20
+ listen (>= 2.7, < 4.0)
21
+ lumberjack (>= 1.0.12, < 2.0)
22
+ nenv (~> 0.1)
23
+ notiffany (~> 0.0)
24
+ pry (>= 0.9.12)
25
+ shellany (~> 0.0)
26
+ thor (>= 0.18.1)
27
+ guard-compat (1.2.1)
28
+ guard-rspec (4.7.3)
29
+ guard (~> 2.1)
30
+ guard-compat (~> 1.1)
31
+ rspec (>= 2.99.0, < 4.0)
16
32
  jaro_winkler (1.5.4)
17
33
  json (2.2.0)
18
34
  jwt (2.2.1)
35
+ listen (3.2.1)
36
+ rb-fsevent (~> 0.10, >= 0.10.3)
37
+ rb-inotify (~> 0.9, >= 0.9.10)
38
+ lumberjack (1.2.4)
19
39
  method_source (0.9.2)
40
+ nenv (0.3.0)
41
+ notiffany (0.1.3)
42
+ nenv (~> 0.1)
43
+ shellany (~> 0.0)
20
44
  parallel (1.19.1)
21
45
  parser (2.7.0.2)
22
46
  ast (~> 2.4.0)
@@ -25,6 +49,9 @@ GEM
25
49
  method_source (~> 0.9.0)
26
50
  rainbow (3.0.0)
27
51
  rake (10.5.0)
52
+ rb-fsevent (0.10.3)
53
+ rb-inotify (0.10.1)
54
+ ffi (~> 1.0)
28
55
  rspec (3.9.0)
29
56
  rspec-core (~> 3.9.0)
30
57
  rspec-expectations (~> 3.9.0)
@@ -46,11 +73,13 @@ GEM
46
73
  ruby-progressbar (~> 1.7)
47
74
  unicode-display_width (>= 1.4.0, < 1.7)
48
75
  ruby-progressbar (1.10.1)
76
+ shellany (0.0.1)
49
77
  simplecov (0.17.1)
50
78
  docile (~> 1.1)
51
79
  json (>= 1.8, < 3)
52
80
  simplecov-html (~> 0.10.0)
53
81
  simplecov-html (0.10.2)
82
+ thor (1.0.1)
54
83
  timecop (0.9.1)
55
84
  unicode-display_width (1.6.1)
56
85
 
@@ -60,6 +89,7 @@ PLATFORMS
60
89
  DEPENDENCIES
61
90
  app_store_connect_jwt!
62
91
  bundler (~> 2.0)
92
+ guard-rspec
63
93
  pry
64
94
  rake (~> 10.0)
65
95
  rspec (~> 3.0)
@@ -68,4 +98,4 @@ DEPENDENCIES
68
98
  timecop
69
99
 
70
100
  BUNDLED WITH
71
- 2.0.1
101
+ 2.0.2
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: 'bundle exec rspec' do
4
+ require 'guard/rspec/dsl'
5
+ dsl = Guard::RSpec::Dsl.new(self)
6
+
7
+ rspec = dsl.rspec
8
+ watch(rspec.spec_helper) { rspec.spec_dir }
9
+ watch(rspec.spec_support) { rspec.spec_dir }
10
+ watch(rspec.spec_files)
11
+
12
+ ruby = dsl.ruby
13
+ dsl.watch_spec_files_for(ruby.lib_files)
14
+ end
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # App Store Connect–JWT
2
2
 
3
- ![Test](https://github.com/kyledecot/app_store_connect_jwt/workflows/Test/badge.svg) [![Gem Version](https://badge.fury.io/rb/app_store_connect_jwt.svg)](https://badge.fury.io/rb/app_store_connect_jwt) [![Maintainability](https://api.codeclimate.com/v1/badges/e13c94f97898e74f34a9/maintainability)](https://codeclimate.com/github/kyledecot/hard_cider/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/e13c94f97898e74f34a9/test_coverage)](https://codeclimate.com/github/kyledecot/hard_cider/test_coverage)
3
+ ![Test](https://github.com/kyledecot/app_store_connect_jwt/workflows/Test/badge.svg) ![Lint](https://github.com/kyledecot/app_store_connect_jwt/workflows/Lint/badge.svg) [![Gem Version](https://badge.fury.io/rb/app_store_connect_jwt.svg)](https://badge.fury.io/rb/app_store_connect_jwt) [![Maintainability](https://api.codeclimate.com/v1/badges/e13c94f97898e74f34a9/maintainability)](https://codeclimate.com/github/kyledecot/hard_cider/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/e13c94f97898e74f34a9/test_coverage)](https://codeclimate.com/github/kyledecot/hard_cider/test_coverage)
4
4
 
5
- Generate App Store Connect API JWT (JSON Web Token)
5
+ Generate App Store Connect API JWT (JSON Web Token) according to Apple's App Store Connect API Documentation:
6
+
7
+ https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests
6
8
 
7
9
  ## Installation
8
10
 
@@ -25,10 +27,19 @@ Or install it yourself as:
25
27
  ### CLI
26
28
 
27
29
  ```sh
28
- app-store-connect-jwt generate \
29
- --issuer-id=$APP_STORE_CONNECT_ISSUER_ID \
30
- --key-id=$APP_STORE_CONNECT_KEY_ID \
31
- --private-key-path=$APP_STORE_CONNECT_PRIVATE_KEY_PATH
30
+ $ app-store-connect-jwt generate \
31
+ --issuer-id=$APP_STORE_CONNECT_ISSUER_ID \
32
+ --key-id=$APP_STORE_CONNECT_KEY_ID \
33
+ --private-key-path=$APP_STORE_CONNECT_PRIVATE_KEY_PATH
34
+ ```
35
+
36
+ :information_desk_person: _Pro Tip: if you have the environment variables set that are listed above you can omit the flags entirely and the CLI will automatically pick up on them, thus making the command `app-store-connect-jwt generate`!_
37
+
38
+ #### cURL
39
+
40
+ ```sh
41
+ $ curl -H "Authorization: Bearer $(app-store-connect-jwt generate)" \
42
+ https://api.appstoreconnect.apple.com/v1/apps
32
43
  ```
33
44
 
34
45
  ### Ruby
@@ -38,9 +49,11 @@ puts AppStoreConnect::JWT.new(
38
49
  issuer_id: ENV["APP_STORE_CONNECT_ISSUER_ID"],
39
50
  key_id: ENV["APP_STORE_CONNECT_KEY_ID"],
40
51
  private_key_path: ENV["APP_STORE_CONNECT_PRIVATE_KEY_PATH"]
41
- )
52
+ ).token
42
53
  ```
43
54
 
55
+ :information_desk_person: _Pro Tip: `#token` is aliased to `#to_s` so in this example the `.token` is superfolus!_
56
+
44
57
  ## Development
45
58
 
46
59
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -25,13 +25,13 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ['lib']
26
26
 
27
27
  spec.add_development_dependency 'bundler', '~> 2.0'
28
+ spec.add_development_dependency 'guard-rspec'
28
29
  spec.add_development_dependency 'pry'
29
30
  spec.add_development_dependency 'rake', '~> 10.0'
30
31
  spec.add_development_dependency 'rspec', '~> 3.0'
31
32
  spec.add_development_dependency 'rubocop'
32
- spec.add_development_dependency 'timecop'
33
33
  spec.add_development_dependency 'simplecov'
34
-
34
+ spec.add_development_dependency 'timecop'
35
35
 
36
36
  spec.add_runtime_dependency 'gli'
37
37
  spec.add_runtime_dependency 'jwt'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'jwt'
3
+ require 'app_store_connect/jwt/utils'
4
4
  require 'app_store_connect/jwt/version'
5
5
 
6
6
  module AppStoreConnect
@@ -8,14 +8,37 @@ module AppStoreConnect
8
8
  AUDIENCE = 'appstoreconnect-v1'
9
9
  ALGORITHM = 'ES256'
10
10
 
11
- attr_reader :issuer_id, :key_id, :private_key
11
+ # App Store Connect API Issuer ID
12
+ # @return [String]
13
+ attr_reader :issuer_id
12
14
 
15
+ # App Store Connect API Key ID
16
+ # @return [String]
17
+ attr_reader :key_id
18
+
19
+ # App Store Connect API Private Key
20
+ # @return [OpenSSL::PKey::EC]
21
+ attr_reader :private_key
22
+
23
+ # @param token [String]
24
+ # @param private_key_path [String] Path to App Store Connect API Private Key (.p8)
25
+ # @return [Array<Hash>]
26
+ def self.decode(token:, private_key_path:)
27
+ private_key = Utils.private_key(path: private_key_path)
28
+
29
+ Utils.decode(token, private_key, ALGORITHM)
30
+ end
31
+
32
+ # @param issuer_id [String] App Store Connect API Issuer ID
33
+ # @param key_id [String] App Store Connect API Key ID
34
+ # @param private_key_path [String] Path to App Store Connect API Private Key (.p8)
13
35
  def initialize(issuer_id:, key_id:, private_key_path:)
14
36
  @issuer_id = issuer_id
15
37
  @key_id = key_id
16
- @private_key = OpenSSL::PKey.read(File.read(File.expand_path(private_key_path)))
38
+ @private_key = Utils.private_key(path: private_key_path)
17
39
  end
18
40
 
41
+ # @return [Hash]
19
42
  def payload
20
43
  {
21
44
  exp: Time.now.to_i + 20 * 60,
@@ -24,12 +47,16 @@ module AppStoreConnect
24
47
  }
25
48
  end
26
49
 
50
+ # @return [Hash]
27
51
  def header_fields
28
52
  { kid: key_id }
29
53
  end
30
54
 
31
- def to_s
32
- ::JWT.encode(payload, private_key, ALGORITHM, header_fields)
55
+ # @return [String]
56
+ def token
57
+ Utils.encode(payload, private_key, ALGORITHM, header_fields)
33
58
  end
59
+
60
+ alias to_s token
34
61
  end
35
62
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jwt'
4
+ require 'openssl'
5
+
6
+ module AppStoreConnect
7
+ class JWT
8
+ module Utils
9
+ # @param payload [Hash]
10
+ # @param private_key [OpenSSL::PKey::EC]
11
+ # @param algorithm [String]
12
+ # @param header_fields [Hash]
13
+ # @return [String]
14
+ def self.encode(payload, private_key, algorithm, header_fields)
15
+ ::JWT.encode(payload, private_key, algorithm, header_fields)
16
+ end
17
+
18
+ # @param token [String]
19
+ # @param private_key [OpenSSL::PKey::EC]
20
+ # @param algorithm [String]
21
+ # @return [Array<Hash>]
22
+ def self.decode(token, private_key, algorithm)
23
+ ::JWT.decode(token, private_key, true, algorithm: algorithm)
24
+ end
25
+
26
+ # @param path [String]
27
+ # @return [OpenSSL::PKey::EC]
28
+ def self.private_key(path:)
29
+ OpenSSL::PKey.read(File.read(File.expand_path(path)))
30
+ end
31
+ end
32
+ end
33
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AppStoreConnect
4
4
  class JWT
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_store_connect_jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Decot
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: guard-rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: pry
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +95,7 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: timecop
98
+ name: simplecov
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -95,7 +109,7 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: simplecov
112
+ name: timecop
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -144,13 +158,19 @@ executables:
144
158
  extensions: []
145
159
  extra_rdoc_files: []
146
160
  files:
161
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
162
+ - ".github/ISSUE_TEMPLATE/config.yml"
163
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
164
+ - ".github/workflows/lint.yml"
147
165
  - ".github/workflows/test.yml"
148
166
  - ".gitignore"
149
167
  - ".rspec"
150
168
  - ".rubocop.yml"
151
- - ".travis.yml"
169
+ - ".ruby-version"
170
+ - ".yamllint"
152
171
  - Gemfile
153
172
  - Gemfile.lock
173
+ - Guardfile
154
174
  - LICENSE.txt
155
175
  - README.md
156
176
  - Rakefile
@@ -161,6 +181,7 @@ files:
161
181
  - lib/app_store_connect.rb
162
182
  - lib/app_store_connect/jwt.rb
163
183
  - lib/app_store_connect/jwt/cli.rb
184
+ - lib/app_store_connect/jwt/utils.rb
164
185
  - lib/app_store_connect/jwt/version.rb
165
186
  homepage: https://github.com/kyledecot/app_store_connect_jwt
166
187
  licenses:
@@ -181,8 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
202
  - !ruby/object:Gem::Version
182
203
  version: '0'
183
204
  requirements: []
184
- rubyforge_project:
185
- rubygems_version: 2.7.6.2
205
+ rubygems_version: 3.0.3
186
206
  signing_key:
187
207
  specification_version: 4
188
208
  summary: Generate App Store Connect JWT
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.5
7
- before_install: gem install bundler -v 2.0.1