Share
Embed
Fastest trip to AppStore Connect
Transcript
49 slides
-
• ৄղFastfile • iOSDC 2018 2ϨΪϡϥʔτʔΫ • https://speakerdeck.com/giginet/xiang-jie-fastfile • •
iOSDC 2018 3LT • https://speakerdeck.com/giginet/-15 • ୀ۶ͳ͜ͱAppStore Connect APIʹΒͤΑ͏ • iOSDC Reject Conference 2018 -
• What's New in App Store Connect • https://developer.apple.com/videos/play/ wwdc2018/301/
• Automating App Store Connect • https://developer.apple.com/videos/play/ wwdc2018/303/ -
New Feature Summary App Store Connect API Unified user management
App delivery on Linux TestFlight public links Sales and Trends overview App Store Connect for iOS Free trials for paid apps NEW -
Lifecycle Manage Users Design and Develop Deliver Provision Analyze Prepare
App Store Metadata Distribute App Store Connect API Beta Test -
apps betaLicenseAgreements builds buildBetaDetails betaAppReviewSubmissions betaAppLocalizations betaBuildLocalizations betaAppReviewDetails appEncryptionDeclarations userInvitations
bundleIds devices certificates salesReports financeReports betaTesterInvitations buildDeliveries betaGroups users profiles betaTesters -
> api.appstoreconnect.apple.com/v1/users/17cbd794-94a3-c7b0-1051 > GET HTTP/1.1 200 OK { "data": {
"type": "users", "id": "17cbd794-94a3-c7b0-1051", "attributes": { "firstName": "Kate", "lastName": "Bell", "email": "[email protected]", … }, "relationships": {…}, "links": { "self": "…/v1/users/17cbd794-94a3-c7b0-1051" } } ] -
{ "data": { "type": "userInvitations", "attributes": { "firstName": "John", "lastName":
"Appleseed", "email": "[email protected]", "roles": ["DEVELOPER"], "allAppsVisible": true } } } > > POST /v1/userInvitations -
{ "data": { "type": "users", "id": "24e811a2-2ad0-46e4-b632", "attributes": { "roles":
["DEVELOPER", "MARKETING"] } } } > > PATCH /v1/users/24e811a2-2ad0-46e4-b632 -
// swift-tools-version:4.2 // The swift-tools-version declares the minimum version of
Swift required to build this package. import PackageDescription let package = Package( name: "MyExecutable", dependencies: [ .package(url: "https://github.com/giginet/ Wormhole.git", .from("0.1.0")), ], targets: [ .target( name: "MyExecutable", dependencies: ["Wormhole"]), ] ) EFQFOEFODZՃ -
import Foundation import Wormhole import Result let client = try!
Client( p8Path: URL(fileURLWithPath: "key.p8"), issuerID: UUID(uuidString: "b91d85c7- b7db-4451-8f3f-9a3c8af9a392")!, keyID: “100000" ) *TTVFS*% ,FZ*% 1SJWBUF,FZ͕ඞཁ -
HTTP/1.1 200 OK { "data": [{ "type": "users", "id": "17cbd794-94a3-c7b0-1051",
"attributes": { "firstName": "Kate", "lastName": "Bell", "email": "[email protected]", … }, "relationships": {…}, "links": { "self": "https://api.appstoreconnect.apple.com/v1/users/17cbd794-94a3-c7b0-1 } }, { api.appstoreconnect.apple.com/v1/users/17cbd794-94a3-c7b0-1 > GET api.appstoreconnect.apple.com/v1/users -
enum Role: String, Codable { case developer = "DEVELOPER" case
marketing = "MARKETING" } struct User: AttributeType { let firstName: String let lastName: String let email: String let roles: [Role] } -
HTTP/1.1 200 OK { "data": [{ "type": "users", "id": "17cbd794-94a3-c7b0-1051",
"attributes": { "firstName": "Kate", "lastName": "Bell", "email": "[email protected]", … }, "relationships": {…}, "links": { "self": "https://api.appstoreconnect.apple.com/v1/users/17cbd794-94a3-c7b0-1 } }, { api.appstoreconnect.apple.com/v1/users/17cbd794-94a3-c7b0-1 > GET api.appstoreconnect.apple.com/v1/users -
struct GetUsersRequest: RequestType { typealias Response = CollectionContainer<User> let method:
HTTPMethod = .get let path = "/users" let payload: RequestPayload = .void } ෳͷ݁ՌΛड͚औΔܕ 3FRVFTUCPEZۭ -
let request = GetUsersRequest() client.send(request) { (result: Result<CollectionContainer<User>, ClientError>) in
switch result { case .success(let container): let firstUser: User = container.data.first! print("Name: \(firstUser.firstName) \ (firstUser.lastName)") print("Email: \(firstUser.email)") print("Roles: \(firstUser.roles)") case .failure(let error): print("Something went wrong") print(String(describing: error)) } } ϢʔβʔͷҰཡ͕औΕΔ -
{ "data": { "type": "users", "id": "24e811a2-2ad0-46e4-b632", "attributes": { "roles":
["DEVELOPER", "MARKETING"] } } } > > PATCH /v1/users/24e811a2-2ad0-46e4-b632 -
struct RoleModificationRequest: RequestType { typealias Response = SingleContainer<User> let method:
HTTPMethod = .patch var path: String { return "/users/\(id.uuidString.lowercased())" } let id: UUID let roles: [Role] var payload: RequestPayload { return .init(id: id, type: "users", attributes: roles) } } ͭͷ݁ՌΛड͚औΔܕ 3FRVFTUCPEZΛఆٛ -
{ "data": { "type": "users", "id": "24e811a2-2ad0-46e4-b632", "attributes": { "roles":
["DEVELOPER", "MARKETING"] } } } > > PATCH /v1/users/24e811a2-2ad0-46e4-b632 -
let uuid = UUID(uuidString: “588ec36e- ba74-11e8-8879-93c782f9ccb3")! let request = RoleModificationRequest(
id: uuid, roles: [.developer, .marketing] ) client.send(request) { result in switch result { case .success(let container): let modifiedUser: User = container.data print("Name: \(modifiedUser.firstName) \(modifiedUser.lastName)") print("Email: \(modifiedUser.email)") print("Roles: \(modifiedUser.roles)") case .failure(let error): print("Something went wrong") print(String(describing: error)) } } -
JSON Web Token • JSON Web Token • https://jwt.io/ •
JSONΛbase64Τϯίʔυͯ͠ɺൿີ伴Λͬͯ҉߸Խ • ެ։伴Λͬͯ෮߸ -
JWT on Swift • Swiftͷ·ͱͳϥΠϒϥϦ͕ͳ͍ • ͋ͬͯػೳ͕Γͳ͍ • ECDSA(ES256)ʹඇରԠ •
ҙͷϔομʔΛ࣋ͨͤΒΕͳ͍ • OpenSSLͰࣗͰ࣮͢Δͱେม -
JWT on Swift • libjwtͱ͍͏CͷϥΠϒϥϦΛSwiftPMܦ༝ͰೖΕͯͬͯ ͍Δ • libjwtࣗମͷ࠷৽൛HomebrewͰग़ͯͳ͍ͷͰࣗͰ Formulaॻ͍ͨ •
SwiftPM 4.2ͷsystemLibraryͱ͍͏ΈΛ͍ͬͯΔ • See Wormhole/JWTEncoder.swift -
import JWT struct JWTEncoder { func encode(issuerID: UUID, keyID: String)
throws -> String { let object = UnsafeMutablePointer<OpaquePointer?>.allocate(capacity: MemoryLayout<OpaquePointer>.size) jwt_new(object) defer { jwt_free(object.pointee) } let keyPointer = convertToCString(privateKey) defer { keyPointer.deallocate() } jwt_set_alg(object.pointee, JWT_ALG_ES256, keyPointer, Int32(privateKey.utf16.count + 1)) // https://github.com/benmcollins/libjwt/pull/71 jwt_add_header(object.pointee, "kid", keyID) jwt_add_grant(object.pointee, "iss", issuerID.uuidString.lowercased()) let expirationDate = Date().addingTimeInterval(expirationInterval) jwt_add_grant_int(object.pointee, "exp", Int(expirationDate.timeIntervalSince1970)) jwt_add_grant(object.pointee, "aud", "appstoreconnect-v1") guard let encodedCString = jwt_encode_str(object.pointee) else { throw Error.decodeError } return String(cString: encodedCString) } } 4ZTUFN-JCSBSZͱͯ͠ެ։ $ͷ͕ؔ4XJGU͔Β͑Δ -
͍ಓʢΞΠσΟΞʣ • App Store ConnectͷݖݶཧࣗಈԽʁ • TestFlightͷট৴ͷࣗಈԽʁ • Wormhole +
VaporͰొϖʔδͱ͔࡞Εͦ͏ • ূ໌ॻProvisioning ProfileͷੜࣗಈԽʁ -
·ͱΊ • App Store Connect API͕·ͳ͘དྷͦ͏ • APIΫϥΠΞϯτ࡞ͬͨ • giginet/Wormhole
• ͑ΔΑ͏ʹͳͬͨΒ͍ͬͯ͘