Skip to content

Commit 1d3d1d6

Browse files
authored
Migrate installationId from objc SDK (#117)
* Make sure new installation is created after delete in migration * Make ParseConfiguration public * Migrate objc installationId * Fix applicationIdentifier in Linux build * Update certificate pinning authorization * nits
1 parent be5de49 commit 1d3d1d6

17 files changed

+408
-202
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ coverage:
55
status:
66
patch:
77
default:
8-
target: 58
8+
target: auto
99
changes: false
1010
project:
1111
default:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.3.0...main)
55
* _Contributing to this repo? Add info about your change here to be included in the next release_
66

7+
__New features__
8+
- Migrate installationId from obj-c SDK ([#117](https://github.com/parse-community/Parse-Swift/pull/117)), thanks to [Corey Baker](https://github.com/cbaker6).
9+
10+
__Improvements__
11+
- Added ability to initialize SDK with ParseConfiguration. Can now update certificate pinning authorization after SDK is initializated ([#117](https://github.com/parse-community/Parse-Swift/pull/117)), thanks to [Corey Baker](https://github.com/cbaker6).
12+
713
### 1.3.0
814
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.2.6...1.3.0)
915

ParseSwift.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@
295295
70D1BE7425BB43EB00A42E7C /* BaseConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70D1BE7225BB43EB00A42E7C /* BaseConfig.swift */; };
296296
70D1BE7525BB43EB00A42E7C /* BaseConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70D1BE7225BB43EB00A42E7C /* BaseConfig.swift */; };
297297
70D1BE7625BB43EB00A42E7C /* BaseConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70D1BE7225BB43EB00A42E7C /* BaseConfig.swift */; };
298-
70DFEA8A2618E77800F8EB4B /* MigrateOldParseInstallationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* MigrateOldParseInstallationTests.swift */; };
299-
70DFEA8B2618E77800F8EB4B /* MigrateOldParseInstallationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* MigrateOldParseInstallationTests.swift */; };
300-
70DFEA8C2618E77800F8EB4B /* MigrateOldParseInstallationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* MigrateOldParseInstallationTests.swift */; };
298+
70DFEA8A2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */; };
299+
70DFEA8B2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */; };
300+
70DFEA8C2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */; };
301301
70F2E255254F247000B2EA5C /* ParseSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AFDA7121F26D9A5002AE4FC /* ParseSwift.framework */; };
302302
70F2E2B3254F283000B2EA5C /* ParseUserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C7DC1D24D20E530050419B /* ParseUserTests.swift */; };
303303
70F2E2B4254F283000B2EA5C /* ParseQueryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C7DC1F24D20F180050419B /* ParseQueryTests.swift */; };
@@ -635,7 +635,7 @@
635635
70D1BDB925BB17A600A42E7C /* ParseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseConfig.swift; sourceTree = "<group>"; };
636636
70D1BE0625BB2BF400A42E7C /* ParseConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseConfigTests.swift; sourceTree = "<group>"; };
637637
70D1BE7225BB43EB00A42E7C /* BaseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseConfig.swift; sourceTree = "<group>"; };
638-
70DFEA892618E77800F8EB4B /* MigrateOldParseInstallationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MigrateOldParseInstallationTests.swift; sourceTree = "<group>"; };
638+
70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitializeSDKTests.swift; sourceTree = "<group>"; };
639639
70F2E23E254F246000B2EA5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
640640
70F2E250254F247000B2EA5C /* ParseSwiftTestsmacOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ParseSwiftTestsmacOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
641641
70F2E254254F247000B2EA5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -813,8 +813,8 @@
813813
911DB12D24C4837E0027F3C7 /* APICommandTests.swift */,
814814
7003957525A0EE770052CB31 /* BatchUtilsTests.swift */,
815815
705726ED2592C91C00F0ADD5 /* HashTests.swift */,
816+
70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */,
816817
4AA8076E1F794C1C008CD551 /* KeychainStoreTests.swift */,
817-
70DFEA892618E77800F8EB4B /* MigrateOldParseInstallationTests.swift */,
818818
9194657724F16E330070296B /* ParseACLTests.swift */,
819819
7044C22C25C5E4E90011F6E7 /* ParseAnonymousCombineTests.swift */,
820820
70A2D86A25B3ADB6001BEB7D /* ParseAnonymousTests.swift */,
@@ -1673,7 +1673,7 @@
16731673
70732C5A2606CCAD000CAB81 /* ParseObjectCustomObjectIdTests.swift in Sources */,
16741674
911DB12C24C3F7720027F3C7 /* MockURLResponse.swift in Sources */,
16751675
7044C24325C5EA360011F6E7 /* ParseAppleCombineTests.swift in Sources */,
1676-
70DFEA8A2618E77800F8EB4B /* MigrateOldParseInstallationTests.swift in Sources */,
1676+
70DFEA8A2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */,
16771677
7044C1DF25C5C70D0011F6E7 /* ParseObjectCombine.swift in Sources */,
16781678
89899D9F26045998002E2043 /* ParseTwitterCombineTests.swift in Sources */,
16791679
70C5504625B40D5200B5DBC2 /* ParseSessionTests.swift in Sources */,
@@ -1825,7 +1825,7 @@
18251825
70732C5C2606CCAD000CAB81 /* ParseObjectCustomObjectIdTests.swift in Sources */,
18261826
709B984D2556ECAA00507778 /* AnyDecodableTests.swift in Sources */,
18271827
7044C24525C5EA360011F6E7 /* ParseAppleCombineTests.swift in Sources */,
1828-
70DFEA8C2618E77800F8EB4B /* MigrateOldParseInstallationTests.swift in Sources */,
1828+
70DFEA8C2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */,
18291829
7044C1E125C5C70D0011F6E7 /* ParseObjectCombine.swift in Sources */,
18301830
89899DA126045998002E2043 /* ParseTwitterCombineTests.swift in Sources */,
18311831
70C5504825B40D5200B5DBC2 /* ParseSessionTests.swift in Sources */,
@@ -1880,7 +1880,7 @@
18801880
70732C5B2606CCAD000CAB81 /* ParseObjectCustomObjectIdTests.swift in Sources */,
18811881
70F2E2C2254F283000B2EA5C /* APICommandTests.swift in Sources */,
18821882
7044C24425C5EA360011F6E7 /* ParseAppleCombineTests.swift in Sources */,
1883-
70DFEA8B2618E77800F8EB4B /* MigrateOldParseInstallationTests.swift in Sources */,
1883+
70DFEA8B2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */,
18841884
7044C1E025C5C70D0011F6E7 /* ParseObjectCombine.swift in Sources */,
18851885
89899DA026045998002E2043 /* ParseTwitterCombineTests.swift in Sources */,
18861886
70C5504725B40D5200B5DBC2 /* ParseSessionTests.swift in Sources */,

Sources/ParseSwift/API/API+Commands.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ internal extension API {
6060
case .success(let urlRequest):
6161
if method == .POST || method == .PUT {
6262
let task = URLSession.parse.uploadTask(withStreamedRequest: urlRequest)
63-
ParseConfiguration.sessionDelegate.uploadDelegates[task] = uploadProgress
64-
ParseConfiguration.sessionDelegate.streamDelegates[task] = stream
65-
ParseConfiguration.sessionDelegate.taskCallbackQueues[task] = callbackQueue
63+
ParseSwift.sessionDelegate.uploadDelegates[task] = uploadProgress
64+
ParseSwift.sessionDelegate.streamDelegates[task] = stream
65+
ParseSwift.sessionDelegate.taskCallbackQueues[task] = callbackQueue
6666
task.resume()
6767
return
6868
}
@@ -208,7 +208,7 @@ internal extension API {
208208
headers.removeValue(forKey: "X-Parse-Request-Id")
209209
}
210210
let url = parseURL == nil ?
211-
ParseConfiguration.serverURL.appendingPathComponent(path.urlComponent) : parseURL!
211+
ParseSwift.configuration.serverURL.appendingPathComponent(path.urlComponent) : parseURL!
212212

213213
guard var components = URLComponents(url: url, resolvingAgainstBaseURL: false) else {
214214
return .failure(ParseError(code: .unknownError,
@@ -314,7 +314,7 @@ internal extension API.Command {
314314

315315
// MARK: Saving ParseObjects
316316
static func saveCommand<T>(_ object: T) throws -> API.Command<T, T> where T: ParseObject {
317-
if ParseConfiguration.allowCustomObjectId && object.objectId == nil {
317+
if ParseSwift.configuration.allowCustomObjectId && object.objectId == nil {
318318
throw ParseError(code: .missingObjectId, message: "objectId must not be nil")
319319
}
320320
if object.isSaved {
@@ -349,7 +349,7 @@ internal extension API.Command {
349349
guard let objectable = object as? Objectable else {
350350
throw ParseError(code: .unknownError, message: "Not able to cast to objectable. Not saving")
351351
}
352-
if ParseConfiguration.allowCustomObjectId && objectable.objectId == nil {
352+
if ParseSwift.configuration.allowCustomObjectId && objectable.objectId == nil {
353353
throw ParseError(code: .missingObjectId, message: "objectId must not be nil")
354354
}
355355
if objectable.isSaved {
@@ -421,7 +421,7 @@ extension API.Command where T: ParseObject {
421421

422422
static func batch(commands: [API.Command<T, T>], transaction: Bool) -> RESTBatchCommandType<T> {
423423
let batchCommands = commands.compactMap { (command) -> API.Command<T, T>? in
424-
let path = ParseConfiguration.mountPath + command.path.urlComponent
424+
let path = ParseSwift.configuration.mountPath + command.path.urlComponent
425425
guard let body = command.body else {
426426
return nil
427427
}
@@ -463,7 +463,7 @@ extension API.Command where T: ParseObject {
463463
static func batch(commands: [API.NonParseBodyCommand<NoBody, NoBody>],
464464
transaction: Bool) -> RESTBatchCommandNoBodyType<NoBody> {
465465
let commands = commands.compactMap { (command) -> API.NonParseBodyCommand<NoBody, NoBody>? in
466-
let path = ParseConfiguration.mountPath + command.path.urlComponent
466+
let path = ParseSwift.configuration.mountPath + command.path.urlComponent
467467
return API.NonParseBodyCommand<NoBody, NoBody>(
468468
method: command.method,
469469
path: .any(path), mapper: command.mapper)
@@ -525,7 +525,7 @@ extension API.NonParseBodyCommand {
525525
return try objectable.toPointer()
526526
}
527527

528-
let path = ParseConfiguration.mountPath + objectable.endpoint.urlComponent
528+
let path = ParseSwift.configuration.mountPath + objectable.endpoint.urlComponent
529529
let encoded = try ParseCoding.parseEncoder().encode(object)
530530
let body = try ParseCoding.jsonDecoder().decode(AnyCodable.self, from: encoded)
531531
return API.BatchCommand<AnyCodable, PointerType>(method: method,
@@ -632,7 +632,7 @@ internal extension API {
632632
if !(method == .POST) && !(method == .PUT) {
633633
headers.removeValue(forKey: "X-Parse-Request-Id")
634634
}
635-
let url = ParseConfiguration.serverURL.appendingPathComponent(path.urlComponent)
635+
let url = ParseSwift.configuration.serverURL.appendingPathComponent(path.urlComponent)
636636

637637
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
638638
let urlComponents = components.url else {

Sources/ParseSwift/API/API.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ public struct API {
142142

143143
// swiftlint:disable:next cyclomatic_complexity
144144
internal static func getHeaders(options: API.Options) -> [String: String] {
145-
var headers: [String: String] = ["X-Parse-Application-Id": ParseConfiguration.applicationId,
145+
var headers: [String: String] = ["X-Parse-Application-Id": ParseSwift.configuration.applicationId,
146146
"Content-Type": "application/json"]
147-
if let clientKey = ParseConfiguration.clientKey {
147+
if let clientKey = ParseSwift.configuration.clientKey {
148148
headers["X-Parse-Client-Key"] = clientKey
149149
}
150150

@@ -161,7 +161,7 @@ public struct API {
161161
options.forEach { (option) in
162162
switch option {
163163
case .useMasterKey:
164-
headers["X-Parse-Master-Key"] = ParseConfiguration.masterKey
164+
headers["X-Parse-Master-Key"] = ParseSwift.configuration.masterKey
165165
case .sessionToken(let sessionToken):
166166
headers["X-Parse-Session-Token"] = sessionToken
167167
case .installationId(let installationId):

Sources/ParseSwift/API/URLSession+extensions.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import FoundationNetworking
1414

1515
extension URLSession {
1616
static let parse: URLSession = {
17-
if !ParseConfiguration.isTestingSDK {
17+
if !ParseSwift.configuration.isTestingSDK {
1818
return URLSession(configuration: .default,
19-
delegate: ParseConfiguration.sessionDelegate,
19+
delegate: ParseSwift.sessionDelegate,
2020
delegateQueue: nil)
2121
} else {
2222
return URLSession.shared
@@ -134,8 +134,8 @@ extension URLSession {
134134
completion(.failure(ParseError(code: .unknownError, message: "data and file both can't be nil")))
135135
}
136136
if let task = task {
137-
ParseConfiguration.sessionDelegate.uploadDelegates[task] = progress
138-
ParseConfiguration.sessionDelegate.taskCallbackQueues[task] = callbackQueue
137+
ParseSwift.sessionDelegate.uploadDelegates[task] = progress
138+
ParseSwift.sessionDelegate.taskCallbackQueues[task] = callbackQueue
139139
task.resume()
140140
}
141141
}
@@ -152,8 +152,8 @@ extension URLSession {
152152
urlResponse: urlResponse,
153153
responseError: responseError, mapper: mapper))
154154
}
155-
ParseConfiguration.sessionDelegate.downloadDelegates[task] = progress
156-
ParseConfiguration.sessionDelegate.taskCallbackQueues[task] = callbackQueue
155+
ParseSwift.sessionDelegate.downloadDelegates[task] = progress
156+
ParseSwift.sessionDelegate.taskCallbackQueues[task] = callbackQueue
157157
task.resume()
158158
}
159159

Sources/ParseSwift/Coding/ParseEncoder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public struct ParseEncoder {
103103
objectsSavedBeforeThisOne: [String: PointerType]?,
104104
filesSavedBeforeThisOne: [UUID: ParseFile]?) throws -> (encoded: Data, unique: Set<UniqueObject>, unsavedChildren: [Encodable]) {
105105
let keysToSkip: Set<String>!
106-
if !ParseConfiguration.allowCustomObjectId {
106+
if !ParseSwift.configuration.allowCustomObjectId {
107107
keysToSkip = SkippedKeys.object.keys()
108108
} else {
109109
keysToSkip = SkippedKeys.customObjectId.keys()
@@ -120,7 +120,7 @@ public struct ParseEncoder {
120120
objectsSavedBeforeThisOne: [String: PointerType]?,
121121
filesSavedBeforeThisOne: [UUID: ParseFile]?) throws -> (encoded: Data, unique: Set<UniqueObject>, unsavedChildren: [Encodable]) {
122122
let keysToSkip: Set<String>!
123-
if !ParseConfiguration.allowCustomObjectId {
123+
if !ParseSwift.configuration.allowCustomObjectId {
124124
keysToSkip = SkippedKeys.object.keys()
125125
} else {
126126
keysToSkip = SkippedKeys.customObjectId.keys()

Sources/ParseSwift/LiveQuery/Messages.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ struct StandardMessage: LiveQueryable, Codable {
2121
init(operation: ClientOperation, additionalProperties: Bool = false) {
2222
self.op = operation
2323
if additionalProperties {
24-
self.applicationId = ParseConfiguration.applicationId
25-
self.masterKey = ParseConfiguration.masterKey
26-
self.clientKey = ParseConfiguration.clientKey
24+
self.applicationId = ParseSwift.configuration.applicationId
25+
self.masterKey = ParseSwift.configuration.masterKey
26+
self.clientKey = ParseSwift.configuration.clientKey
2727
self.sessionToken = BaseParseUser.currentUserContainer?.sessionToken
2828
self.installationId = BaseParseInstallation.currentInstallationContainer.installationId
2929
}

Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,10 @@ public final class ParseLiveQuery: NSObject {
179179

180180
if let userSuppliedURL = serverURL {
181181
url = userSuppliedURL
182-
} else if let liveQueryConfigURL = ParseConfiguration.liveQuerysServerURL {
182+
} else if let liveQueryConfigURL = ParseSwift.configuration.liveQuerysServerURL {
183183
url = liveQueryConfigURL
184-
} else if let parseServerConfigURL = ParseConfiguration.serverURL {
185-
url = parseServerConfigURL
186184
} else {
187-
let error = ParseError(code: .unknownError, message: "ParseLiveQuery Error: no url specified.")
188-
throw error
185+
url = ParseSwift.configuration.serverURL
189186
}
190187

191188
guard var components = URLComponents(url: url,
@@ -467,7 +464,7 @@ extension ParseLiveQuery: LiveQuerySocketDelegate {
467464
notificationQueue.async {
468465
if let delegate = self.authenticationDelegate {
469466
delegate.received(challenge, completionHandler: completionHandler)
470-
} else if let parseAuthentication = ParseConfiguration.sessionDelegate.authentication {
467+
} else if let parseAuthentication = ParseSwift.sessionDelegate.authentication {
471468
parseAuthentication(challenge, completionHandler)
472469
} else {
473470
completionHandler(.performDefaultHandling, nil)

Sources/ParseSwift/Objects/ParseInstallation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ extension ParseInstallation {
9393
}
9494

9595
func endpoint(_ method: API.Method) -> API.Endpoint {
96-
if !ParseConfiguration.allowCustomObjectId || method != .POST {
96+
if !ParseSwift.configuration.allowCustomObjectId || method != .POST {
9797
return endpoint
9898
} else {
9999
return .installations
@@ -517,7 +517,7 @@ extension ParseInstallation {
517517
}
518518

519519
func saveCommand() throws -> API.Command<Self, Self> {
520-
if ParseConfiguration.allowCustomObjectId && objectId == nil {
520+
if ParseSwift.configuration.allowCustomObjectId && objectId == nil {
521521
throw ParseError(code: .missingObjectId, message: "objectId must not be nil")
522522
}
523523
if isSaved {

0 commit comments

Comments
 (0)