16
16
17
17
import * as validator from '../utils/validator' ;
18
18
import { AuthClientErrorCode , FirebaseAuthError } from '../utils/error' ;
19
- import { auth } from './index' ;
20
19
21
- import ActionCodeSettings = auth . ActionCodeSettings ;
20
+ /**
21
+ * This is the interface that defines the required continue/state URL with
22
+ * optional Android and iOS bundle identifiers.
23
+ */
24
+ export interface ActionCodeSettings {
25
+
26
+ /**
27
+ * Defines the link continue/state URL, which has different meanings in
28
+ * different contexts:
29
+ * <ul>
30
+ * <li>When the link is handled in the web action widgets, this is the deep
31
+ * link in the `continueUrl` query parameter.</li>
32
+ * <li>When the link is handled in the app directly, this is the `continueUrl`
33
+ * query parameter in the deep link of the Dynamic Link.</li>
34
+ * </ul>
35
+ */
36
+ url : string ;
37
+
38
+ /**
39
+ * Whether to open the link via a mobile app or a browser.
40
+ * The default is false. When set to true, the action code link is sent
41
+ * as a Universal Link or Android App Link and is opened by the app if
42
+ * installed. In the false case, the code is sent to the web widget first
43
+ * and then redirects to the app if installed.
44
+ */
45
+ handleCodeInApp ?: boolean ;
46
+
47
+ /**
48
+ * Defines the iOS bundle ID. This will try to open the link in an iOS app if it
49
+ * is installed.
50
+ */
51
+ iOS ?: {
52
+
53
+ /**
54
+ * Defines the required iOS bundle ID of the app where the link should be
55
+ * handled if the application is already installed on the device.
56
+ */
57
+ bundleId : string ;
58
+ } ;
59
+
60
+ /**
61
+ * Defines the Android package name. This will try to open the link in an
62
+ * android app if it is installed. If `installApp` is passed, it specifies
63
+ * whether to install the Android app if the device supports it and the app is
64
+ * not already installed. If this field is provided without a `packageName`, an
65
+ * error is thrown explaining that the `packageName` must be provided in
66
+ * conjunction with this field. If `minimumVersion` is specified, and an older
67
+ * version of the app is installed, the user is taken to the Play Store to
68
+ * upgrade the app.
69
+ */
70
+ android ?: {
71
+
72
+ /**
73
+ * Defines the required Android package name of the app where the link should be
74
+ * handled if the Android app is installed.
75
+ */
76
+ packageName : string ;
77
+
78
+ /**
79
+ * Whether to install the Android app if the device supports it and the app is
80
+ * not already installed.
81
+ */
82
+ installApp ?: boolean ;
83
+
84
+ /**
85
+ * The Android minimum version if available. If the installed app is an older
86
+ * version, the user is taken to the GOogle Play Store to upgrade the app.
87
+ */
88
+ minimumVersion ?: string ;
89
+ } ;
90
+
91
+ /**
92
+ * Defines the dynamic link domain to use for the current link if it is to be
93
+ * opened using Firebase Dynamic Links, as multiple dynamic link domains can be
94
+ * configured per project. This field provides the ability to explicitly choose
95
+ * configured per project. This fields provides the ability explicitly choose
96
+ * one. If none is provided, the oldest domain is used by default.
97
+ */
98
+ dynamicLinkDomain ?: string ;
99
+ }
22
100
23
101
/** Defines the email action code server request. */
24
102
interface EmailActionCodeRequest {
@@ -34,6 +112,8 @@ interface EmailActionCodeRequest {
34
112
/**
35
113
* Defines the ActionCodeSettings builder class used to convert the
36
114
* ActionCodeSettings object to its corresponding server request.
115
+ *
116
+ * @internal
37
117
*/
38
118
export class ActionCodeSettingsBuilder {
39
119
private continueUrl ?: string ;
@@ -70,7 +150,7 @@ export class ActionCodeSettingsBuilder {
70
150
this . continueUrl = actionCodeSettings . url ;
71
151
72
152
if ( typeof actionCodeSettings . handleCodeInApp !== 'undefined' &&
73
- ! validator . isBoolean ( actionCodeSettings . handleCodeInApp ) ) {
153
+ ! validator . isBoolean ( actionCodeSettings . handleCodeInApp ) ) {
74
154
throw new FirebaseAuthError (
75
155
AuthClientErrorCode . INVALID_ARGUMENT ,
76
156
'"ActionCodeSettings.handleCodeInApp" must be a boolean.' ,
@@ -79,14 +159,14 @@ export class ActionCodeSettingsBuilder {
79
159
this . canHandleCodeInApp = actionCodeSettings . handleCodeInApp || false ;
80
160
81
161
if ( typeof actionCodeSettings . dynamicLinkDomain !== 'undefined' &&
82
- ! validator . isNonEmptyString ( actionCodeSettings . dynamicLinkDomain ) ) {
162
+ ! validator . isNonEmptyString ( actionCodeSettings . dynamicLinkDomain ) ) {
83
163
throw new FirebaseAuthError (
84
164
AuthClientErrorCode . INVALID_DYNAMIC_LINK_DOMAIN ,
85
165
) ;
86
166
}
87
167
this . dynamicLinkDomain = actionCodeSettings . dynamicLinkDomain ;
88
168
89
- if ( typeof actionCodeSettings . iOS !== 'undefined' ) {
169
+ if ( typeof actionCodeSettings . iOS !== 'undefined' ) {
90
170
if ( ! validator . isNonNullObject ( actionCodeSettings . iOS ) ) {
91
171
throw new FirebaseAuthError (
92
172
AuthClientErrorCode . INVALID_ARGUMENT ,
@@ -105,7 +185,7 @@ export class ActionCodeSettingsBuilder {
105
185
this . ibi = actionCodeSettings . iOS . bundleId ;
106
186
}
107
187
108
- if ( typeof actionCodeSettings . android !== 'undefined' ) {
188
+ if ( typeof actionCodeSettings . android !== 'undefined' ) {
109
189
if ( ! validator . isNonNullObject ( actionCodeSettings . android ) ) {
110
190
throw new FirebaseAuthError (
111
191
AuthClientErrorCode . INVALID_ARGUMENT ,
@@ -121,13 +201,13 @@ export class ActionCodeSettingsBuilder {
121
201
'"ActionCodeSettings.android.packageName" must be a valid non-empty string.' ,
122
202
) ;
123
203
} else if ( typeof actionCodeSettings . android . minimumVersion !== 'undefined' &&
124
- ! validator . isNonEmptyString ( actionCodeSettings . android . minimumVersion ) ) {
204
+ ! validator . isNonEmptyString ( actionCodeSettings . android . minimumVersion ) ) {
125
205
throw new FirebaseAuthError (
126
206
AuthClientErrorCode . INVALID_ARGUMENT ,
127
207
'"ActionCodeSettings.android.minimumVersion" must be a valid non-empty string.' ,
128
208
) ;
129
209
} else if ( typeof actionCodeSettings . android . installApp !== 'undefined' &&
130
- ! validator . isBoolean ( actionCodeSettings . android . installApp ) ) {
210
+ ! validator . isBoolean ( actionCodeSettings . android . installApp ) ) {
131
211
throw new FirebaseAuthError (
132
212
AuthClientErrorCode . INVALID_ARGUMENT ,
133
213
'"ActionCodeSettings.android.installApp" must be a valid boolean.' ,
@@ -146,7 +226,7 @@ export class ActionCodeSettingsBuilder {
146
226
* @return {EmailActionCodeRequest } The constructed EmailActionCodeRequest request.
147
227
*/
148
228
public buildRequest ( ) : EmailActionCodeRequest {
149
- const request : { [ key : string ] : any } = {
229
+ const request : { [ key : string ] : any } = {
150
230
continueUrl : this . continueUrl ,
151
231
canHandleCodeInApp : this . canHandleCodeInApp ,
152
232
dynamicLinkDomain : this . dynamicLinkDomain ,
0 commit comments