1616
1717import * as validator from '../utils/validator' ;
1818import { AuthClientErrorCode , FirebaseAuthError } from '../utils/error' ;
19- import { auth } from './index' ;
2019
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+ }
22100
23101/** Defines the email action code server request. */
24102interface EmailActionCodeRequest {
@@ -34,6 +112,8 @@ interface EmailActionCodeRequest {
34112/**
35113 * Defines the ActionCodeSettings builder class used to convert the
36114 * ActionCodeSettings object to its corresponding server request.
115+ *
116+ * @internal
37117 */
38118export class ActionCodeSettingsBuilder {
39119 private continueUrl ?: string ;
@@ -70,7 +150,7 @@ export class ActionCodeSettingsBuilder {
70150 this . continueUrl = actionCodeSettings . url ;
71151
72152 if ( typeof actionCodeSettings . handleCodeInApp !== 'undefined' &&
73- ! validator . isBoolean ( actionCodeSettings . handleCodeInApp ) ) {
153+ ! validator . isBoolean ( actionCodeSettings . handleCodeInApp ) ) {
74154 throw new FirebaseAuthError (
75155 AuthClientErrorCode . INVALID_ARGUMENT ,
76156 '"ActionCodeSettings.handleCodeInApp" must be a boolean.' ,
@@ -79,14 +159,14 @@ export class ActionCodeSettingsBuilder {
79159 this . canHandleCodeInApp = actionCodeSettings . handleCodeInApp || false ;
80160
81161 if ( typeof actionCodeSettings . dynamicLinkDomain !== 'undefined' &&
82- ! validator . isNonEmptyString ( actionCodeSettings . dynamicLinkDomain ) ) {
162+ ! validator . isNonEmptyString ( actionCodeSettings . dynamicLinkDomain ) ) {
83163 throw new FirebaseAuthError (
84164 AuthClientErrorCode . INVALID_DYNAMIC_LINK_DOMAIN ,
85165 ) ;
86166 }
87167 this . dynamicLinkDomain = actionCodeSettings . dynamicLinkDomain ;
88168
89- if ( typeof actionCodeSettings . iOS !== 'undefined' ) {
169+ if ( typeof actionCodeSettings . iOS !== 'undefined' ) {
90170 if ( ! validator . isNonNullObject ( actionCodeSettings . iOS ) ) {
91171 throw new FirebaseAuthError (
92172 AuthClientErrorCode . INVALID_ARGUMENT ,
@@ -105,7 +185,7 @@ export class ActionCodeSettingsBuilder {
105185 this . ibi = actionCodeSettings . iOS . bundleId ;
106186 }
107187
108- if ( typeof actionCodeSettings . android !== 'undefined' ) {
188+ if ( typeof actionCodeSettings . android !== 'undefined' ) {
109189 if ( ! validator . isNonNullObject ( actionCodeSettings . android ) ) {
110190 throw new FirebaseAuthError (
111191 AuthClientErrorCode . INVALID_ARGUMENT ,
@@ -121,13 +201,13 @@ export class ActionCodeSettingsBuilder {
121201 '"ActionCodeSettings.android.packageName" must be a valid non-empty string.' ,
122202 ) ;
123203 } else if ( typeof actionCodeSettings . android . minimumVersion !== 'undefined' &&
124- ! validator . isNonEmptyString ( actionCodeSettings . android . minimumVersion ) ) {
204+ ! validator . isNonEmptyString ( actionCodeSettings . android . minimumVersion ) ) {
125205 throw new FirebaseAuthError (
126206 AuthClientErrorCode . INVALID_ARGUMENT ,
127207 '"ActionCodeSettings.android.minimumVersion" must be a valid non-empty string.' ,
128208 ) ;
129209 } else if ( typeof actionCodeSettings . android . installApp !== 'undefined' &&
130- ! validator . isBoolean ( actionCodeSettings . android . installApp ) ) {
210+ ! validator . isBoolean ( actionCodeSettings . android . installApp ) ) {
131211 throw new FirebaseAuthError (
132212 AuthClientErrorCode . INVALID_ARGUMENT ,
133213 '"ActionCodeSettings.android.installApp" must be a valid boolean.' ,
@@ -146,7 +226,7 @@ export class ActionCodeSettingsBuilder {
146226 * @return {EmailActionCodeRequest } The constructed EmailActionCodeRequest request.
147227 */
148228 public buildRequest ( ) : EmailActionCodeRequest {
149- const request : { [ key : string ] : any } = {
229+ const request : { [ key : string ] : any } = {
150230 continueUrl : this . continueUrl ,
151231 canHandleCodeInApp : this . canHandleCodeInApp ,
152232 dynamicLinkDomain : this . dynamicLinkDomain ,
0 commit comments