Module: AppStoreConnect::JWT::Utils
- Defined in:
- lib/app_store_connect/jwt/utils.rb
Class Method Summary collapse
- .decode(token, private_key, algorithm) ⇒ Array<Hash>
- .encode(payload, private_key, algorithm, header_fields) ⇒ String
- .header_fields(key_id) ⇒ Hash
- .payload(issuer_id, audience) ⇒ Hash
- .private_key(path) ⇒ OpenSSL::PKey::EC
Class Method Details
.decode(token, private_key, algorithm) ⇒ Array<Hash>
22 23 24 |
# File 'lib/app_store_connect/jwt/utils.rb', line 22 def self.decode(token, private_key, algorithm) ::JWT.decode(token, private_key, true, algorithm: algorithm) end |
.encode(payload, private_key, algorithm, header_fields) ⇒ String
14 15 16 |
# File 'lib/app_store_connect/jwt/utils.rb', line 14 def self.encode(payload, private_key, algorithm, header_fields) ::JWT.encode(payload, private_key, algorithm, header_fields) end |
.header_fields(key_id) ⇒ Hash
28 29 30 |
# File 'lib/app_store_connect/jwt/utils.rb', line 28 def self.header_fields(key_id) { kid: key_id } end |
.payload(issuer_id, audience) ⇒ Hash
35 36 37 38 39 40 41 |
# File 'lib/app_store_connect/jwt/utils.rb', line 35 def self.payload(issuer_id, audience) { exp: Time.now.to_i + 20 * 60, iss: issuer_id, aud: audience } end |
.private_key(path) ⇒ OpenSSL::PKey::EC
45 46 47 |
# File 'lib/app_store_connect/jwt/utils.rb', line 45 def self.private_key(path) OpenSSL::PKey.read(File.read(File.(path))) end |