Class: AppStoreConnect::JWT

Inherits:
Object
  • Object
show all
Defined in:
lib/app_store_connect/jwt.rb,
lib/app_store_connect/jwt/cli.rb,
lib/app_store_connect/jwt/utils.rb,
lib/app_store_connect/jwt/version.rb

Defined Under Namespace

Modules: Utils Classes: CLI

Constant Summary collapse

AUDIENCE =
'appstoreconnect-v1'
ALGORITHM =
'ES256'
VERSION =
'0.9.0'

Class Method Summary collapse

Class Method Details

.decode(token:, private_key_path:) ⇒ Array<Hash>

Parameters:

  • token (String)
  • private_key_path (String)

    Path to App Store Connect API Private Key (.p8)

Returns:

  • (Array<Hash>)


26
27
28
29
30
# File 'lib/app_store_connect/jwt.rb', line 26

def self.decode(token:, private_key_path:)
  private_key = Utils.private_key(private_key_path)

  Utils.decode(token, private_key, ALGORITHM)
end

.encode(issuer_id:, key_id:, private_key_path:) ⇒ String

Parameters:

  • issuer_id (String)

    App Store Connect API Issuer ID

  • key_id (String)

    App Store Connect API Key ID

  • private_key_path (String)

    Path to App Store Connect API Private Key (.p8)

Returns:

  • (String)


15
16
17
18
19
20
21
# File 'lib/app_store_connect/jwt.rb', line 15

def self.encode(issuer_id:, key_id:, private_key_path:)
  payload = Utils.payload(issuer_id, AUDIENCE)
  header_fields = Utils.header_fields(key_id)
  private_key = Utils.private_key(private_key_path)

  Utils.encode(payload, private_key, ALGORITHM, header_fields)
end