-
-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathParseApple+combine.swift
87 lines (79 loc) · 3.37 KB
/
ParseApple+combine.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// ParseApple+combine.swift
// ParseApple+combine
//
// Created by Corey Baker on 8/7/21.
// Copyright © 2021 Parse Community. All rights reserved.
//
#if canImport(Combine)
import Foundation
import Combine
public extension ParseApple {
// MARK: Login - Combine
/**
Login a `ParseUser` *asynchronously* using Apple authentication. Publishes when complete.
- parameter user: The `user` from `ASAuthorizationAppleIDCredential`.
- parameter identityToken: The `identityToken` from `ASAuthorizationAppleIDCredential`.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(user: String,
identityToken: Data,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(user: user,
identityToken: identityToken,
options: options,
completion: promise)
}
}
/**
Login a `ParseUser` *asynchronously* using Apple authentication. Publishes when complete.
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(authData: [String: String],
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(authData: authData,
options: options,
completion: promise)
}
}
}
public extension ParseApple {
// MARK: Link - Combine
/**
Link the *current* `ParseUser` *asynchronously* using Apple authentication. Publishes when complete.
- parameter user: The `user` from `ASAuthorizationAppleIDCredential`.
- parameter identityToken: The `identityToken` from `ASAuthorizationAppleIDCredential`.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(user: String,
identityToken: Data,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(user: user,
identityToken: identityToken,
options: options,
completion: promise)
}
}
/**
Link the *current* `ParseUser` *asynchronously* using Apple authentication. Publishes when complete.
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(authData: [String: String],
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(authData: authData,
options: options,
completion: promise)
}
}
}
#endif