1 | import { Device as NativeDevice } from 'ionic-native';
|
2 | /**
|
3 | * @hidden
|
4 | */
|
5 | export interface SemanticVersion {
|
6 | major: number;
|
7 | minor?: number;
|
8 | patch?: number;
|
9 | }
|
10 | /**
|
11 | * Represents [`DetailedError`](/api/client/detailederror/).
|
12 | */
|
13 | export interface IDetailedError<D> extends Error {
|
14 | /**
|
15 | * The error details.
|
16 | */
|
17 | details?: D;
|
18 | }
|
19 | /**
|
20 | * A function which [`Logger`](/api/client/logger/) uses to log messages. It
|
21 | * takes an optional message and any number of additional params.
|
22 | */
|
23 | export declare type LogFn = (message?: any, ...optionalParams: any[]) => void;
|
24 | /**
|
25 | * The options for [`Logger`](/api/client/logger/).
|
26 | */
|
27 | export interface LoggerOptions {
|
28 | /**
|
29 | * If silent is `true`, the `Logger`'s `infofn` and `warnfn` will not be
|
30 | * called.
|
31 | */
|
32 | silent?: boolean;
|
33 | }
|
34 | /**
|
35 | * Represents a [`Logger`](/api/client/logger/).
|
36 | */
|
37 | export interface ILogger {
|
38 | /**
|
39 | * The function to use to log info level messages.
|
40 | */
|
41 | infofn: LogFn;
|
42 | /**
|
43 | * The function to use to log warn level messages.
|
44 | */
|
45 | warnfn: LogFn;
|
46 | /**
|
47 | * The function to use to log error level messages.
|
48 | */
|
49 | errorfn: LogFn;
|
50 | /**
|
51 | * Send a log at info level.
|
52 | *
|
53 | * @param message - The message to log.
|
54 | */
|
55 | info(message?: any, ...optionalParams: any[]): any;
|
56 | /**
|
57 | * Send a log at warn level.
|
58 | *
|
59 | * @param message - The message to log.
|
60 | */
|
61 | warn(message?: any, ...optionalParams: any[]): any;
|
62 | /**
|
63 | * Send a log at error level.
|
64 | *
|
65 | * @param message - The message to log.
|
66 | */
|
67 | error(message?: any, ...optionalParams: any[]): any;
|
68 | }
|
69 | /**
|
70 | * @hidden
|
71 | */
|
72 | export interface CloudSettingsUrls {
|
73 | api?: string;
|
74 | web?: string;
|
75 | }
|
76 | /**
|
77 | * General settings for the Cloud Client.
|
78 | */
|
79 | export interface CoreSettings {
|
80 | /**
|
81 | * Your app ID.
|
82 | */
|
83 | app_id: string;
|
84 | /**
|
85 | * @hidden
|
86 | */
|
87 | urls?: CloudSettingsUrls;
|
88 | }
|
89 | /**
|
90 | * Settings for native logins with Facebook and/or Google.
|
91 | */
|
92 | export interface AuthOptions {
|
93 | /**
|
94 | * Your webClientId (aka, reverseId)
|
95 | */
|
96 | google?: {
|
97 | webClientId: string;
|
98 | scope?: GoogleScope[];
|
99 | };
|
100 | /**
|
101 | * Your facebook scopes.
|
102 | */
|
103 | facebook?: {
|
104 | scope: FacebookScope[];
|
105 | };
|
106 | }
|
107 | /**
|
108 | * The settings object for the Cloud Client.
|
109 | *
|
110 | * `CloudSettings` contains various specific configuration sections, acting more
|
111 | * like a parent object for them.
|
112 | *
|
113 | * @featured
|
114 | */
|
115 | export interface CloudSettings {
|
116 | /**
|
117 | * General settings for the Cloud Client.
|
118 | */
|
119 | core: CoreSettings;
|
120 | /**
|
121 | * Settings for Push Notifications.
|
122 | */
|
123 | push?: PushOptions;
|
124 | /**
|
125 | * Settings for native auth.
|
126 | */
|
127 | auth?: AuthOptions;
|
128 | /**
|
129 | * Log settings.
|
130 | */
|
131 | logger?: LoggerOptions;
|
132 | }
|
133 | /**
|
134 | * @hidden
|
135 | */
|
136 | export interface IConfig {
|
137 | settings: CloudSettings;
|
138 | register(settings: CloudSettings): any;
|
139 | get(name: string): any;
|
140 | getURL(name: string): string;
|
141 | }
|
142 | /**
|
143 | * Represents a [`Client`](/api/client/client/).
|
144 | */
|
145 | export interface IClient {
|
146 | baseUrl: string;
|
147 | get(endpoint: string): any;
|
148 | post(endpoint: string): any;
|
149 | put(endpoint: string): any;
|
150 | patch(endpoint: string): any;
|
151 | delete(endpoint: string): any;
|
152 | request(method: string, endpoint: string): any;
|
153 | }
|
154 | /**
|
155 | * A function which [`EventEmitter`](/api/client/eventemitter/) uses to handle
|
156 | * events.
|
157 | *
|
158 | * All event handlers have a single parameter: `data`, which is always an
|
159 | * object and which will differ depending on the event.
|
160 | */
|
161 | export declare type EventHandler = (data?: Object) => any;
|
162 | /**
|
163 | * Represents an [`EventReceiver`](/api/client/eventreceiver/).
|
164 | */
|
165 | export interface IEventReceiver {
|
166 | key: string | number;
|
167 | event: string;
|
168 | handler: EventHandler;
|
169 | }
|
170 | /**
|
171 | * Represents an [`EventEmitter`](/api/client/eventemitter/).
|
172 | */
|
173 | export interface IEventEmitter {
|
174 | on(event: string, callback: EventHandler): any;
|
175 | off(receiver: IEventReceiver): any;
|
176 | once(event: string, callback: () => void): any;
|
177 | emit(event: string, data?: Object): any;
|
178 | emitted(event: string): number;
|
179 | }
|
180 | /**
|
181 | * @hidden
|
182 | */
|
183 | export interface StorageDependencies {
|
184 | strategy: IStorageStrategy;
|
185 | }
|
186 | /**
|
187 | * @hidden
|
188 | */
|
189 | export interface StorageOptions {
|
190 | prefix?: string;
|
191 | cache?: boolean;
|
192 | }
|
193 | /**
|
194 | * Represents a [`Storage`](/api/client/storage/).
|
195 | */
|
196 | export interface IStorage<T> {
|
197 | /**
|
198 | * Get a value from the storage by the given key.
|
199 | *
|
200 | * @param key - The storage key to get.
|
201 | */
|
202 | get(key: string): T | null;
|
203 | /**
|
204 | * Set a value in the storage by the given key.
|
205 | *
|
206 | * @param key - The storage key to set.
|
207 | * @param value - The value to set. (Must be JSON-serializable).
|
208 | */
|
209 | set(key: string, value: T): void;
|
210 | /**
|
211 | * Delete a value from the storage by the given key.
|
212 | *
|
213 | * @param key - The storage key to delete.
|
214 | */
|
215 | delete(key: string): void;
|
216 | }
|
217 | /**
|
218 | * @hidden
|
219 | */
|
220 | export interface IStorageStrategy {
|
221 | get(key: string): string | null;
|
222 | set(key: string, value: string): void;
|
223 | delete(key: string): void;
|
224 | }
|
225 | /**
|
226 | * @hidden
|
227 | */
|
228 | export interface DeviceIsConnectedToNetworkOptions {
|
229 | strictMode?: boolean;
|
230 | }
|
231 | /**
|
232 | * @hidden
|
233 | */
|
234 | export interface DeviceDependencies {
|
235 | nativeDevice: typeof NativeDevice;
|
236 | emitter: IEventEmitter;
|
237 | }
|
238 | /**
|
239 | * @hidden
|
240 | */
|
241 | export interface IDevice {
|
242 | native: typeof NativeDevice;
|
243 | type: string;
|
244 | isAndroid(): boolean;
|
245 | isIOS(): boolean;
|
246 | }
|
247 | /**
|
248 | * @hidden
|
249 | */
|
250 | export interface CordovaDependencies {
|
251 | appStatus: AppStatus;
|
252 | device: IDevice;
|
253 | emitter: IEventEmitter;
|
254 | logger: ILogger;
|
255 | }
|
256 | /**
|
257 | * @hidden
|
258 | */
|
259 | export interface CordovaOptions {
|
260 | }
|
261 | /**
|
262 | * @hidden
|
263 | */
|
264 | export interface ICordova {
|
265 | app: AppStatus;
|
266 | bootstrap(): void;
|
267 | }
|
268 | /**
|
269 | * @hidden
|
270 | */
|
271 | export interface CoreDependencies {
|
272 | config: IConfig;
|
273 | logger: ILogger;
|
274 | emitter: IEventEmitter;
|
275 | insights: IInsights;
|
276 | }
|
277 | /**
|
278 | * @hidden
|
279 | */
|
280 | export interface ICore {
|
281 | version: string;
|
282 | init(): void;
|
283 | }
|
284 | /**
|
285 | * @hidden
|
286 | */
|
287 | export interface UserContextDependencies {
|
288 | config: IConfig;
|
289 | storage: IStorage<StoredUser>;
|
290 | }
|
291 | /**
|
292 | * @hidden
|
293 | */
|
294 | export interface IUserContext {
|
295 | label: string;
|
296 | load(user: IUser): IUser | null;
|
297 | store(user: IUser): void;
|
298 | unstore(): void;
|
299 | }
|
300 | /**
|
301 | * Represents a locally stored user (usually in local storage).
|
302 | */
|
303 | export interface StoredUser {
|
304 | id?: string;
|
305 | data: Object;
|
306 | details: Object;
|
307 | social: Object;
|
308 | fresh: boolean;
|
309 | }
|
310 | /**
|
311 | * @hidden
|
312 | */
|
313 | export interface IUserData {
|
314 | data: Object;
|
315 | get(key: string, defaultValue: any): any;
|
316 | set(key: string, value: any): any;
|
317 | unset(key: string): any;
|
318 | }
|
319 | /**
|
320 | * The user details common to us and you, used in email/password
|
321 | * authentication.
|
322 | *
|
323 | * We store common fields such as `email` and `password` separate from your
|
324 | * custom data to avoid name clashes.
|
325 | */
|
326 | export interface UserDetails {
|
327 | /**
|
328 | * The user's email address.
|
329 | *
|
330 | * We enforce email address correctness server-side.
|
331 | */
|
332 | email?: string;
|
333 | /**
|
334 | * The user's password.
|
335 | *
|
336 | * We enforce no password requirements and expect you to implement
|
337 | * client-side password requirements that best suit your app.
|
338 | */
|
339 | password?: string;
|
340 | /**
|
341 | * A username unique to the user.
|
342 | *
|
343 | * You can use it in addition to `email` to identify your users. Uniqueness
|
344 | * is enforced on this field.
|
345 | */
|
346 | username?: string;
|
347 | /**
|
348 | * A URL to an image for the user.
|
349 | *
|
350 | * `image` defaults to a generic user avatar hosted by us.
|
351 | */
|
352 | image?: string;
|
353 | /**
|
354 | * The user's full (first + last) name, generally used for display.
|
355 | */
|
356 | name?: string;
|
357 | /**
|
358 | * TODO: Better way to handle this?
|
359 | *
|
360 | * @hidden
|
361 | */
|
362 | custom?: Object;
|
363 | }
|
364 | /**
|
365 | * @hidden
|
366 | */
|
367 | export interface UserDependencies {
|
368 | service: ISingleUserService;
|
369 | }
|
370 | /**
|
371 | * The user social details we collect from the social networks for social
|
372 | * authentication.
|
373 | *
|
374 | * `UserSocialDetails` is a container. Depending on which social providers you
|
375 | * use, the details are accessible as their respective fields.
|
376 | */
|
377 | export interface UserSocialDetails {
|
378 | /**
|
379 | * The provider details for Facebook Authentication.
|
380 | */
|
381 | facebook?: UserSocialProviderDetails;
|
382 | /**
|
383 | * The provider details for Github Authentication.
|
384 | */
|
385 | github?: UserSocialProviderDetails;
|
386 | /**
|
387 | * The provider details for Twitter Authentication.
|
388 | */
|
389 | twitter?: UserSocialProviderDetails;
|
390 | /**
|
391 | * The provider details for Instagram Authentication.
|
392 | */
|
393 | instagram?: UserSocialProviderDetails;
|
394 | /**
|
395 | * The provider details for Google Authentication.
|
396 | */
|
397 | google?: UserSocialProviderDetails;
|
398 | /**
|
399 | * The provider details for LinkedIn Authentication.
|
400 | */
|
401 | linkedin?: UserSocialProviderDetails;
|
402 | }
|
403 | /**
|
404 | * More general information from the social network.
|
405 | *
|
406 | * Although these details have the same keys and types regardless of the social
|
407 | * providers you use, we don't guarantee every field has a value. Some networks
|
408 | * don't give us `email`, others don't give us `username`.
|
409 | */
|
410 | export interface UserSocialProviderDetailsData {
|
411 | /**
|
412 | * The email address of the user on the social network.
|
413 | */
|
414 | email: string;
|
415 | /**
|
416 | * The username of the user on the social network.
|
417 | */
|
418 | username: string;
|
419 | /**
|
420 | * The full (first + last) name of the user on the social network.
|
421 | */
|
422 | full_name: string;
|
423 | /**
|
424 | * A URL to the profile picture of the user on the social network.
|
425 | */
|
426 | profile_picture: string;
|
427 | /**
|
428 | * Raw data about this user from the network.
|
429 | *
|
430 | * It is generally unsafe to rely on raw data, as we can't promise social
|
431 | * networks won't change the format. For developers that like to live on the
|
432 | * wild side, enjoy.
|
433 | */
|
434 | raw_data: Object;
|
435 | }
|
436 | /**
|
437 | * The provider-specific user social details.
|
438 | *
|
439 | * These details have the same keys and types no matter what social providers
|
440 | * you use.
|
441 | */
|
442 | export interface UserSocialProviderDetails {
|
443 | /**
|
444 | * The ID of the user in the social network.
|
445 | */
|
446 | uid: string;
|
447 | /**
|
448 | * The access token of the user.
|
449 | */
|
450 | access_token: string;
|
451 | /**
|
452 | * More general information from the social network.
|
453 | */
|
454 | data: UserSocialProviderDetailsData;
|
455 | }
|
456 | /**
|
457 | * Represents a [`User`](/api/client/user/).
|
458 | */
|
459 | export interface IUser {
|
460 | /**
|
461 | * The UUID of this user.
|
462 | */
|
463 | id?: string;
|
464 | /**
|
465 | * Is this user fresh, meaning they haven't been persisted?
|
466 | */
|
467 | fresh: boolean;
|
468 | /**
|
469 | * The details (email, password, etc) of this user.
|
470 | */
|
471 | details: UserDetails;
|
472 | /**
|
473 | * The social details of this user.
|
474 | */
|
475 | social: UserSocialDetails;
|
476 | /**
|
477 | * The custom data of this user.
|
478 | */
|
479 | data: IUserData;
|
480 | /**
|
481 | * Check whether this user is anonymous or not.
|
482 | */
|
483 | isAnonymous(): boolean;
|
484 | /**
|
485 | * Get a value from this user's custom data.
|
486 | *
|
487 | * Optionally, a default value can be provided.
|
488 | *
|
489 | * @param key - The data key to get.
|
490 | * @param defaultValue - The value to return if the key is absent.
|
491 | */
|
492 | get(key: string, defaultValue: any): any;
|
493 | /**
|
494 | * Set a value in this user's custom data.
|
495 | *
|
496 | * @param key - The data key to set.
|
497 | * @param value - The value to set.
|
498 | */
|
499 | set(key: string, value: any): any;
|
500 | /**
|
501 | * Delete a value from this user's custom data.
|
502 | *
|
503 | * @param key - The data key to delete.
|
504 | */
|
505 | unset(key: string): any;
|
506 | /**
|
507 | * Revert this user to a fresh, anonymous state.
|
508 | */
|
509 | clear(): any;
|
510 | /**
|
511 | * Store this user in local storage.
|
512 | */
|
513 | store(): any;
|
514 | /**
|
515 | * Remove this user from local storage.
|
516 | */
|
517 | unstore(): any;
|
518 | /**
|
519 | * Save this user to the API.
|
520 | */
|
521 | save(): Promise<void>;
|
522 | /**
|
523 | * Delete this user from the API.
|
524 | */
|
525 | delete(): Promise<void>;
|
526 | /**
|
527 | * Load the user from the API, overwriting the local user's data.
|
528 | *
|
529 | * @param id - The user ID to load into this user.
|
530 | */
|
531 | load(id?: string): Promise<void>;
|
532 | serializeForAPI(): UserDetails;
|
533 | serializeForStorage(): StoredUser;
|
534 | }
|
535 | /**
|
536 | * @hidden
|
537 | */
|
538 | export interface SingleUserServiceDependencies {
|
539 | client: IClient;
|
540 | context: IUserContext;
|
541 | }
|
542 | /**
|
543 | * @hidden
|
544 | */
|
545 | export interface SingleUserServiceOptions {
|
546 | }
|
547 | /**
|
548 | * @hidden
|
549 | */
|
550 | export interface ISingleUserService {
|
551 | current(): IUser;
|
552 | store(): any;
|
553 | unstore(): any;
|
554 | load(id?: string): Promise<void>;
|
555 | delete(): Promise<void>;
|
556 | save(): Promise<void>;
|
557 | }
|
558 | /**
|
559 | * @hidden
|
560 | */
|
561 | export interface TokenContextDependencies {
|
562 | storage: IStorage<string>;
|
563 | }
|
564 | /**
|
565 | * @hidden
|
566 | */
|
567 | export interface ITokenContextStoreOptions {
|
568 | }
|
569 | /**
|
570 | * @hidden
|
571 | */
|
572 | export interface ITokenContext {
|
573 | label: string;
|
574 | get(): string | null;
|
575 | store(token: string, options: ITokenContextStoreOptions): void;
|
576 | delete(): void;
|
577 | }
|
578 | /**
|
579 | * @hidden
|
580 | */
|
581 | export interface CombinedTokenContextDependencies extends TokenContextDependencies {
|
582 | tempStorage: IStorage<string>;
|
583 | }
|
584 | /**
|
585 | * @hidden
|
586 | */
|
587 | export interface ICombinedTokenContextStoreOptions extends ITokenContextStoreOptions {
|
588 | permanent?: boolean;
|
589 | }
|
590 | /**
|
591 | * @hidden
|
592 | */
|
593 | export interface ICombinedTokenContext extends ITokenContext {
|
594 | store(token: string, options: ICombinedTokenContextStoreOptions): void;
|
595 | }
|
596 | /**
|
597 | * Facebook native login field permissions
|
598 | */
|
599 | export declare type FacebookScope = 'user_birthday' | 'user_about_me' | 'user_hometown' | 'user_website' | string;
|
600 | /**
|
601 | * Google native login field permissions. Note that we already include email and profile by default.
|
602 | */
|
603 | export declare type GoogleScope = string;
|
604 | /**
|
605 | * These are the IDs of the valid [authentication
|
606 | * providers](/services/users/#providers).
|
607 | *
|
608 | * @featured
|
609 | */
|
610 | export declare type AuthModuleId = 'basic' | 'custom' | 'facebook' | 'github' | 'google' | 'instagram' | 'linkedin' | 'twitter';
|
611 | /**
|
612 | * @hidden
|
613 | */
|
614 | export interface AuthTypeDependencies {
|
615 | config: IConfig;
|
616 | client: IClient;
|
617 | emitter: IEventEmitter;
|
618 | }
|
619 | /**
|
620 | * A container object that [`login()`](/api/client/auth#login) resolves with.
|
621 | */
|
622 | export interface AuthLoginResult {
|
623 | /**
|
624 | * The raw auth token string.
|
625 | */
|
626 | token: string;
|
627 | /**
|
628 | * For social authentication, we create a user account the first time a user
|
629 | * logs in. When `true`, this flag indicates the user has just signed up for
|
630 | * the first time.
|
631 | */
|
632 | signup?: boolean;
|
633 | }
|
634 | /**
|
635 | * @hidden
|
636 | */
|
637 | export interface IAuthType {
|
638 | authenticate(data: any, options?: AuthLoginOptions): Promise<AuthLoginResult>;
|
639 | }
|
640 | /**
|
641 | * @hidden
|
642 | */
|
643 | export interface BasicLoginCredentials {
|
644 | email: string;
|
645 | password: string;
|
646 | }
|
647 | /**
|
648 | * @hidden
|
649 | */
|
650 | export interface IBasicAuthType extends IAuthType {
|
651 | signup(data: UserDetails): Promise<void>;
|
652 | requestPasswordReset(email: string): Promise<void>;
|
653 | confirmPasswordReset(email: string, code: number, newPassword: string): Promise<void>;
|
654 | }
|
655 | /**
|
656 | * @hidden
|
657 | */
|
658 | export interface IAuthModules {
|
659 | basic: IBasicAuthType;
|
660 | custom: IAuthType;
|
661 | facebook: IAuthType;
|
662 | github: IAuthType;
|
663 | google: IAuthType;
|
664 | instagram: IAuthType;
|
665 | linkedin: IAuthType;
|
666 | twitter: IAuthType;
|
667 | }
|
668 | /**
|
669 | * Options for [`login()`](/api/client/auth/#login).
|
670 | *
|
671 | * [`Auth`](/api/client/auth/) uses the InAppBrowser plugin to redirect the
|
672 | * user through authentication. We expose settings for when we open a plugin
|
673 | * window.
|
674 | */
|
675 | export interface AuthLoginOptions {
|
676 | /**
|
677 | * If `true`, the user's session is persisted in local storage, but not
|
678 | * guaranteed to be remembered.
|
679 | */
|
680 | remember?: boolean;
|
681 | /**
|
682 | * The options for the InAppBrowser window that is opened.
|
683 | */
|
684 | inAppBrowserOptions?: InAppBrowserPluginOptions;
|
685 | }
|
686 | /**
|
687 | * @hidden
|
688 | */
|
689 | export interface AuthDependencies {
|
690 | config: IConfig;
|
691 | emitter: IEventEmitter;
|
692 | authModules: IAuthModules;
|
693 | tokenContext: ICombinedTokenContext;
|
694 | userService: ISingleUserService;
|
695 | }
|
696 | /**
|
697 | * @hidden
|
698 | */
|
699 | export interface NativeAuthDependencies {
|
700 | config: IConfig;
|
701 | userService: ISingleUserService;
|
702 | client: IClient;
|
703 | storage: IStorage<string>;
|
704 | tokenContext: ICombinedTokenContext;
|
705 | emitter: IEventEmitter;
|
706 | }
|
707 | /**
|
708 | * @hidden
|
709 | */
|
710 | export interface IGoogleData {
|
711 | webClientId: string;
|
712 | }
|
713 | /**
|
714 | * Represents Facebook Auth, which uses native login via cordova-plugin-facebook4.
|
715 | */
|
716 | export interface IFacebookAuth {
|
717 | login(): Promise<AuthLoginResult>;
|
718 | logout(): Promise<void>;
|
719 | }
|
720 | /**
|
721 | * Represents Google Auth, which uses native login via cordova-plugin-googleplus.
|
722 | */
|
723 | export interface IGoogleAuth {
|
724 | login(): Promise<AuthLoginResult>;
|
725 | logout(): Promise<void>;
|
726 | }
|
727 | /**
|
728 | * Represents [`Auth`](/api/client/auth/).
|
729 | */
|
730 | export interface IAuth {
|
731 | /**
|
732 | * Link the user to this URL for password resets. Only for email/password
|
733 | * authentication.
|
734 | */
|
735 | passwordResetUrl: string;
|
736 | /**
|
737 | * Check whether the user is logged in or not.
|
738 | */
|
739 | isAuthenticated(): boolean;
|
740 | /**
|
741 | * Attempt to log the user in with the given credentials.
|
742 | *
|
743 | * @param moduleId
|
744 | * The authentication provider module ID to use with this login.
|
745 | * @param credentials
|
746 | * Email and password object.
|
747 | * @param options
|
748 | * Options for this login such as whether to remember the login.
|
749 | */
|
750 | login(moduleId: 'basic', credentials: BasicLoginCredentials, options?: AuthLoginOptions): Promise<AuthLoginResult>;
|
751 | /**
|
752 | * Kick-off the custom authentication process.
|
753 | *
|
754 | * @param moduleId
|
755 | * The authentication provider module ID to use with this login.
|
756 | * @param credentials
|
757 | * Send whatever details you need to authenticate your custom users.
|
758 | * @param options
|
759 | * Options for this login, such as whether to remember the login and
|
760 | * InAppBrowser window options.
|
761 | */
|
762 | login(moduleId: 'custom', credentials: Object, options?: AuthLoginOptions): Promise<AuthLoginResult>;
|
763 | /**
|
764 | * Attempt to log the user in with the given credentials. For custom & social
|
765 | * logins, kick-off the authentication process.
|
766 | *
|
767 | * After login, the full user is loaded from the cloud and saved in local
|
768 | * storage along with their auth token.
|
769 | *
|
770 | * @param moduleId
|
771 | * The authentication provider module ID to use with this login.
|
772 | * @param credentials
|
773 | * For email/password authentication, give an email and password. For social
|
774 | * authentication, exclude this parameter. For custom authentication, send
|
775 | * whatever you need.
|
776 | * @param options
|
777 | * Options for this login, such as whether to remember the login and
|
778 | * InAppBrowser window options for authentication providers that make use of
|
779 | * it.
|
780 | */
|
781 | login(moduleId: AuthModuleId, credentials?: Object, options?: AuthLoginOptions): Promise<AuthLoginResult>;
|
782 | /**
|
783 | * Log the user out of the app.
|
784 | *
|
785 | * This clears the auth token out of local storage and restores the user to
|
786 | * an unauthenticated state.
|
787 | */
|
788 | logout(): void;
|
789 | /**
|
790 | * Sign up a user with the given data. Only for email/password
|
791 | * authentication.
|
792 | *
|
793 | * @param details - The details that describe a user.
|
794 | */
|
795 | signup(data: UserDetails): Promise<void>;
|
796 | /**
|
797 | * Kick-off the password reset process. Only for email/password
|
798 | * authentication.
|
799 | *
|
800 | * @param email - The email address to which to send a code.
|
801 | */
|
802 | requestPasswordReset(email: string): Promise<void>;
|
803 | /**
|
804 | * Confirm a password reset.
|
805 | *
|
806 | * @param code - The password reset code from the user.
|
807 | * @param newPassword - The requested changed password from the user.
|
808 | */
|
809 | confirmPasswordReset(code: number, newPassword: string): Promise<void>;
|
810 | }
|
811 | /**
|
812 | * Simple status flags of an app.
|
813 | */
|
814 | export interface AppStatus {
|
815 | /**
|
816 | * When `true`, the app was asleep.
|
817 | */
|
818 | asleep?: boolean;
|
819 | /**
|
820 | * When `true`, the app was closed.
|
821 | */
|
822 | closed?: boolean;
|
823 | }
|
824 | /**
|
825 | * @hidden
|
826 | */
|
827 | export interface PushPluginRegistration {
|
828 | registrationId: string;
|
829 | }
|
830 | /**
|
831 | * Additional data from the Push Plugin.
|
832 | */
|
833 | export interface PushPluginNotificationAdditionalData {
|
834 | /**
|
835 | * Whether the notification was received while the app was in the foreground.
|
836 | */
|
837 | foreground: boolean;
|
838 | /**
|
839 | * Will be `true` if the application is started by clicking on the push
|
840 | * notification, `false` if the app is already started.
|
841 | */
|
842 | coldstart: boolean;
|
843 | [key: string]: any;
|
844 | }
|
845 | /**
|
846 | * The notification object received from the Push Plugin.
|
847 | *
|
848 | * Full documentation and examples can be found on the Push Plugin's
|
849 | * [README](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushonnotification-callback).
|
850 | */
|
851 | export interface PushPluginNotification {
|
852 | /**
|
853 | * The text of the push message sent from the 3rd party service.
|
854 | */
|
855 | message: string;
|
856 | /**
|
857 | * The optional title of the push message sent from the 3rd party service.
|
858 | */
|
859 | title: string;
|
860 | /**
|
861 | * The number of messages to be displayed in the badge in iOS/Android or
|
862 | * message count in the notification shade in Android. For windows, it
|
863 | * represents the value in the badge notification which could be a number or
|
864 | * a status glyph.
|
865 | */
|
866 | count: number;
|
867 | /**
|
868 | * The name of the sound file to be played upon receipt of the notification.
|
869 | */
|
870 | sound: string;
|
871 | /**
|
872 | * The path of the image file to be displayed in the notification.
|
873 | */
|
874 | image: string;
|
875 | /**
|
876 | * The args to be passed to the application on launch from push notification.
|
877 | * This works when notification is received in background. (Windows Only)
|
878 | */
|
879 | launchArgs: string;
|
880 | /**
|
881 | * An optional collection of data sent by the 3rd party push service that
|
882 | * does not fit in the above properties.
|
883 | */
|
884 | additionalData: PushPluginNotificationAdditionalData;
|
885 | }
|
886 | /**
|
887 | * Represents a [`PushMessage`](/api/client/pushmessage/).
|
888 | */
|
889 | export interface IPushMessage {
|
890 | /**
|
891 | * Native information about the app when the push message was received.
|
892 | */
|
893 | app: AppStatus;
|
894 | /**
|
895 | * The message of this push message.
|
896 | */
|
897 | text: string;
|
898 | /**
|
899 | * The title of this push message.
|
900 | */
|
901 | title: string;
|
902 | /**
|
903 | * The badge count that was set by this push message.
|
904 | */
|
905 | count: number;
|
906 | /**
|
907 | * The sound that was played by this push message.
|
908 | */
|
909 | sound: string;
|
910 | /**
|
911 | * The image of this push message.
|
912 | */
|
913 | image: string;
|
914 | /**
|
915 | * The custom payload of this push message.
|
916 | */
|
917 | payload: Object;
|
918 | raw: PushPluginNotification;
|
919 | }
|
920 | /**
|
921 | * The object received when your app is sent a push notification. To learn how
|
922 | * to handle push notifications, [go to the Push
|
923 | * docs](/services/push/#handling-notifications).
|
924 | *
|
925 | * Internally, this is the object for the `push:notification` event from the
|
926 | * [`EventEmitter`](/api/client/eventemitter/).
|
927 | *
|
928 | * @featured
|
929 | */
|
930 | export interface PushNotificationEvent {
|
931 | /**
|
932 | * The push message.
|
933 | */
|
934 | message: IPushMessage;
|
935 | /**
|
936 | * The raw push notification from the Push Plugin.
|
937 | */
|
938 | raw: PushPluginNotification;
|
939 | }
|
940 | /**
|
941 | * Options for [`saveToken()`](/api/client/push/#saveToken).
|
942 | */
|
943 | export interface PushSaveTokenOptions {
|
944 | /**
|
945 | * When `true`, do not attempt to save the token to the active user.
|
946 | */
|
947 | ignore_user?: boolean;
|
948 | }
|
949 | /**
|
950 | * @hidden
|
951 | */
|
952 | export interface PushDependencies {
|
953 | config: IConfig;
|
954 | auth: IAuth;
|
955 | userService: ISingleUserService;
|
956 | device: IDevice;
|
957 | client: IClient;
|
958 | emitter: IEventEmitter;
|
959 | storage: IStorage<PushToken>;
|
960 | logger: ILogger;
|
961 | }
|
962 | export interface PushPluginConfigAndroid {
|
963 | senderID?: string;
|
964 | icon?: string;
|
965 | iconColor?: string;
|
966 | sound?: boolean;
|
967 | vibrate?: boolean;
|
968 | clearBadge?: boolean;
|
969 | clearNotifications?: boolean;
|
970 | forceShow?: boolean;
|
971 | topics?: string[];
|
972 | }
|
973 | export interface PushPluginConfigiOS {
|
974 | alert?: boolean | string;
|
975 | badge?: boolean | string;
|
976 | sound?: boolean | string;
|
977 | clearBadge?: boolean | string;
|
978 | categories?: any;
|
979 | }
|
980 | /**
|
981 | * The configuration options for the Push Plugin.
|
982 | *
|
983 | * Full documentation and examples can be found on the Push Plugin's
|
984 | * [README](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationinitoptions).
|
985 | */
|
986 | export interface PushPluginConfig {
|
987 | android?: PushPluginConfigAndroid;
|
988 | ios?: PushPluginConfigiOS;
|
989 | }
|
990 | /**
|
991 | * The configuration options for an InAppBrowser window.
|
992 | *
|
993 | * Full documentation and examples can be found on the InAppBrowser Plugin's
|
994 | * [README](https://github.com/apache/cordova-plugin-inappbrowser#cordovainappbrowseropen).
|
995 | */
|
996 | export interface InAppBrowserPluginOptions {
|
997 | location?: boolean;
|
998 | hidden?: boolean;
|
999 | clearcache?: boolean;
|
1000 | clearsessioncache?: boolean;
|
1001 | zoom?: boolean;
|
1002 | hardwareback?: boolean;
|
1003 | mediaPlaybackRequiresUserAction?: boolean;
|
1004 | closebuttoncaption?: string;
|
1005 | disallowoverscroll?: boolean;
|
1006 | toolbar?: boolean;
|
1007 | enableViewportScale?: boolean;
|
1008 | allowInlineMediaPlayback?: boolean;
|
1009 | keyboardDisplayRequiresUserAction?: boolean;
|
1010 | suppressesIncrementalRendering?: boolean;
|
1011 | presentationstyle?: 'pagesheet' | 'formsheet' | 'fullscreen';
|
1012 | transitionstyle?: 'fliphorizontal' | 'crossdissolve' | 'coververtical';
|
1013 | toolbarposition?: 'top' | 'bottom';
|
1014 | fullscreen?: boolean;
|
1015 | }
|
1016 | /**
|
1017 | * Settings for Push Notifications.
|
1018 | */
|
1019 | export interface PushOptions {
|
1020 | /**
|
1021 | * The GCM project ID.
|
1022 | */
|
1023 | sender_id?: string;
|
1024 | /**
|
1025 | * When `true`, debug logs for push notifications are enabled.
|
1026 | */
|
1027 | debug?: boolean;
|
1028 | /**
|
1029 | * Configuration options to pass onto the Push Plugin.
|
1030 | */
|
1031 | pluginConfig?: PushPluginConfig;
|
1032 | }
|
1033 | /**
|
1034 | * A push token which is constructed from a APNS/GCM device token.
|
1035 | *
|
1036 | * @featured
|
1037 | */
|
1038 | export interface PushToken {
|
1039 | /**
|
1040 | * The token ID on the API.
|
1041 | */
|
1042 | id?: string;
|
1043 | /**
|
1044 | * The token type (or platform), e.g. 'android' or 'ios'
|
1045 | */
|
1046 | type?: 'android' | 'ios';
|
1047 | /**
|
1048 | * Has the push token been registered with APNS/GCM?
|
1049 | */
|
1050 | registered: boolean;
|
1051 | /**
|
1052 | * Has the push token been saved to the API?
|
1053 | */
|
1054 | saved: boolean;
|
1055 | /**
|
1056 | * The raw push device token.
|
1057 | */
|
1058 | token: string;
|
1059 | }
|
1060 | /**
|
1061 | * Represents [`Push`](/api/client/push/).
|
1062 | */
|
1063 | export interface IPush {
|
1064 | options: PushOptions;
|
1065 | /**
|
1066 | * The push plugin (window.PushNotification).
|
1067 | */
|
1068 | plugin: any;
|
1069 | /**
|
1070 | * The push token of the device.
|
1071 | */
|
1072 | token?: PushToken;
|
1073 | /**
|
1074 | * Register a token with the API.
|
1075 | *
|
1076 | * When a token is saved, you can send push notifications to it. If a user is
|
1077 | * logged in, the token is linked to them by their ID.
|
1078 | *
|
1079 | * @param token - The token.
|
1080 | * @param options
|
1081 | */
|
1082 | saveToken(token: PushToken, options?: PushSaveTokenOptions): Promise<PushToken>;
|
1083 | /**
|
1084 | * Registers the device with GCM/APNS to get a push token.
|
1085 | */
|
1086 | register(): Promise<PushToken>;
|
1087 | /**
|
1088 | * Invalidate the current push token.
|
1089 | */
|
1090 | unregister(): Promise<void>;
|
1091 | }
|
1092 | /**
|
1093 | * Options for [`download()`](/api/client/deploy/#download).
|
1094 | */
|
1095 | export interface DeployDownloadOptions {
|
1096 | /**
|
1097 | * Attach a progress handler for the download.
|
1098 | *
|
1099 | * `p` is a number from 0 to 100, representing the download progress.
|
1100 | */
|
1101 | onProgress?: (p: number) => void;
|
1102 | }
|
1103 | /**
|
1104 | * Options for [`extract()`](/api/client/deploy/#extract).
|
1105 | */
|
1106 | export interface DeployExtractOptions {
|
1107 | /**
|
1108 | * Attach a progress handler for the extraction process.
|
1109 | *
|
1110 | * `p` is a number from 0 to 100, representing the extraction progress.
|
1111 | */
|
1112 | onProgress?: (p: number) => void;
|
1113 | }
|
1114 | /**
|
1115 | * These are the valid deploy channels. `DeployChannel` can also be any string,
|
1116 | * allowing for custom channel tags.
|
1117 | *
|
1118 | * @featured
|
1119 | */
|
1120 | export declare type DeployChannel = 'dev' | 'staging' | 'production' | string;
|
1121 | /**
|
1122 | * @hidden
|
1123 | */
|
1124 | export interface DeployOptions {
|
1125 | }
|
1126 | /**
|
1127 | * @hidden
|
1128 | */
|
1129 | export interface DeployDependencies {
|
1130 | config: IConfig;
|
1131 | emitter: IEventEmitter;
|
1132 | logger: ILogger;
|
1133 | }
|
1134 | /**
|
1135 | * Represents a [`Deploy`](/api/client/deploy/).
|
1136 | */
|
1137 | export interface IDeploy {
|
1138 | options: DeployOptions;
|
1139 | /**
|
1140 | * The active deploy channel. Set this to change the channel on which
|
1141 | * `Deploy` operates.
|
1142 | */
|
1143 | channel: DeployChannel;
|
1144 | /**
|
1145 | * Check for updates on the active channel.
|
1146 | *
|
1147 | * The promise resolves with a boolean. When `true`, a new snapshot exists on
|
1148 | * the channel.
|
1149 | */
|
1150 | check(): Promise<boolean>;
|
1151 | /**
|
1152 | * Download the available snapshot.
|
1153 | *
|
1154 | * @param options
|
1155 | * Options for this download, such as a progress callback.
|
1156 | */
|
1157 | download(options?: DeployDownloadOptions): Promise<void>;
|
1158 | /**
|
1159 | * Extract the downloaded snapshot.
|
1160 | *
|
1161 | * @param options
|
1162 | * Options for this extract, such as a progress callback.
|
1163 | */
|
1164 | extract(options?: DeployExtractOptions): Promise<void>;
|
1165 | /**
|
1166 | * Immediately reload the app with the latest deployed snapshot.
|
1167 | */
|
1168 | load(): any;
|
1169 | /**
|
1170 | * Get information about the current snapshot.
|
1171 | */
|
1172 | info(): Promise<any>;
|
1173 | /**
|
1174 | * List the snapshots that have been installed on this device.
|
1175 | *
|
1176 | * The promise is resolved with an array of snapshot UUIDs.
|
1177 | */
|
1178 | getSnapshots(): Promise<any>;
|
1179 | /**
|
1180 | * Remove a snapshot from this device.
|
1181 | *
|
1182 | * @param uuid
|
1183 | * The snapshot UUID to remove from the device.
|
1184 | */
|
1185 | deleteSnapshot(uuid: string): Promise<any>;
|
1186 | /**
|
1187 | * Fetches the metadata for a given snapshot. If no UUID is given, it will
|
1188 | * attempt to grab the metadata for the most recently known snapshot.
|
1189 | *
|
1190 | * @param uuid
|
1191 | * The snapshot from which to grab metadata.
|
1192 | */
|
1193 | getMetadata(uuid: string): Promise<any>;
|
1194 | }
|
1195 | /**
|
1196 | * @hidden
|
1197 | */
|
1198 | export interface IStatSerialized {
|
1199 | app_id: string;
|
1200 | stat: string;
|
1201 | value: number;
|
1202 | created: string;
|
1203 | }
|
1204 | /**
|
1205 | * @hidden
|
1206 | */
|
1207 | export interface InsightsDependencies {
|
1208 | appStatus: AppStatus;
|
1209 | storage: IStorage<string>;
|
1210 | config: IConfig;
|
1211 | client: IClient;
|
1212 | device: IDevice;
|
1213 | logger: ILogger;
|
1214 | }
|
1215 | /**
|
1216 | * @hidden
|
1217 | */
|
1218 | export interface InsightsOptions {
|
1219 | intervalSubmit?: number | boolean;
|
1220 | intervalActiveCheck?: number | boolean;
|
1221 | submitCount?: number;
|
1222 | }
|
1223 | /**
|
1224 | * @hidden
|
1225 | */
|
1226 | export interface IInsights {
|
1227 | track(stat: string, value?: number): void;
|
1228 | }
|
1229 | /**
|
1230 | * @hidden
|
1231 | */
|
1232 | export interface SuperAgentResponse {
|
1233 | body: APIResponse;
|
1234 | }
|
1235 | /**
|
1236 | * @hidden
|
1237 | */
|
1238 | export declare type APIResponse = APIResponseSuccess | APIResponseError;
|
1239 | /**
|
1240 | * @hidden
|
1241 | */
|
1242 | export interface APIResponseMeta {
|
1243 | status: number;
|
1244 | version: string;
|
1245 | request_id: string;
|
1246 | }
|
1247 | /**
|
1248 | * @hidden
|
1249 | */
|
1250 | export declare type APIResponseData = Object | Object[];
|
1251 | /**
|
1252 | * @hidden
|
1253 | */
|
1254 | export interface APIResponseErrorDetails {
|
1255 | error_type: string;
|
1256 | parameter: string;
|
1257 | errors: string[];
|
1258 | }
|
1259 | /**
|
1260 | * @hidden
|
1261 | */
|
1262 | export interface APIResponseError {
|
1263 | error: APIResponseErrorError;
|
1264 | meta: APIResponseMeta;
|
1265 | }
|
1266 | /**
|
1267 | * @hidden
|
1268 | */
|
1269 | export interface APIResponseErrorError {
|
1270 | message: string;
|
1271 | link: string;
|
1272 | type: string;
|
1273 | details?: APIResponseErrorDetails[];
|
1274 | }
|
1275 | /**
|
1276 | * @hidden
|
1277 | */
|
1278 | export interface APIResponseSuccess {
|
1279 | data: APIResponseData;
|
1280 | meta: APIResponseMeta;
|
1281 | }
|