Sha256: e2fd2ea61e590830bf1a0c4503a5f3fa0685f897cf8ac6c99809ceec6414f8b6

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'app_store_connect/jwt/utils'
require 'app_store_connect/jwt/version'

module AppStoreConnect
  class JWT
    AUDIENCE = 'appstoreconnect-v1'
    ALGORITHM = 'ES256'

    # @param issuer_id [String] App Store Connect API Issuer ID
    # @param key_id [String] App Store Connect API Key ID
    # @param private_key_path [String] Path to App Store Connect API Private Key (.p8)
    # @return [String]
    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

    # @param token [String]
    # @param private_key_path [String] Path to App Store Connect API Private Key (.p8)
    # @return [Array<Hash>]
    def self.decode(token:, private_key_path:)
      private_key = Utils.private_key(private_key_path)

      Utils.decode(token, private_key, ALGORITHM)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
app_store_connect_jwt-0.9.0 lib/app_store_connect/jwt.rb
app_store_connect_jwt-0.8.0 lib/app_store_connect/jwt.rb
app_store_connect_jwt-0.7.0 lib/app_store_connect/jwt.rb
app_store_connect_jwt-0.6.0 lib/app_store_connect/jwt.rb
app_store_connect_jwt-0.5.0 lib/app_store_connect/jwt.rb
app_store_connect_jwt-0.4.0 lib/app_store_connect/jwt.rb