Sha256: e0fe523429557085ac248a39a4f1201a7c57958a7ed6dcbcdb8c1fb6ec607149
Contents?: true
Size: 954 Bytes
Versions: 25
Compression:
Stored size: 954 Bytes
Contents
require 'jwt' require 'openssl' # extract pem from .p8 # openssl pkcs8 -topk8 -outform PEM -in AuthKey.p8 -out key.pem -nocrypt # compute public key # openssl ec -in key.pem -pubout -out public_key.pem -aes256 module Spaceship module ConnectAPI class Token # maximum expiration supported by AppStore (20 minutes) MAX_TOKEN_DURATION = 1200 attr_reader :key_id attr_reader :issuer_id attr_reader :text def initialize(key_id: nil, issuer_id: nil, key: nil) @expiration = Time.now + MAX_TOKEN_DURATION @key_id = key_id @key = key @issuer_id = issuer_id header = { kid: key_id } payload = { iss: issuer_id, exp: @expiration.to_i, aud: 'appstoreconnect-v1' } @text = JWT.encode(payload, key, 'ES256', header) end def expired? @expiration < Time.now end end end end
Version data entries
25 entries across 25 versions & 1 rubygems