@casual-simulation/aux-vm 2.0.28 → 2.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/auth/AuxAuth.d.ts CHANGED
@@ -1,5 +1,45 @@
1
1
  import { AuthData } from '@casual-simulation/aux-common';
2
2
  import { CreatePublicRecordKeyResult } from '@casual-simulation/aux-records';
3
+ /**
4
+ * Defines an interface that represents the login state of the user.
5
+ */
6
+ export interface LoginStatus {
7
+ /**
8
+ * Whether the auth services are loading.
9
+ */
10
+ isLoading?: boolean;
11
+ /**
12
+ * Whether the user is in the process of logging in.
13
+ */
14
+ isLoggingIn?: boolean;
15
+ /**
16
+ * The auth data for the user.
17
+ */
18
+ authData?: AuthData;
19
+ }
20
+ export declare type LoginUIStatus = LoginUINoStatus | LoginUIEmailStatus | LoginUICheckEmailStatus;
21
+ export interface LoginUINoStatus {
22
+ page: false;
23
+ }
24
+ export interface LoginUIEmailStatus {
25
+ page: 'enter_email';
26
+ /**
27
+ * The page that should be linked to as the terms of service.
28
+ */
29
+ termsOfServiceUrl: string;
30
+ /**
31
+ * The name of the site that is being logged into.
32
+ */
33
+ siteName: string;
34
+ showAcceptTermsOfServiceError?: boolean;
35
+ showEnterEmailError?: boolean;
36
+ showInvalidEmailError?: boolean;
37
+ errorCode?: string;
38
+ errorMessage?: string;
39
+ }
40
+ export interface LoginUICheckEmailStatus {
41
+ page: 'check_email';
42
+ }
3
43
  /**
4
44
  * Defines an interface for an object that is able to communicate with an authentication service.
5
45
  */
@@ -23,5 +63,45 @@ export interface AuxAuth {
23
63
  * Gets the auth token for the user.
24
64
  */
25
65
  getAuthToken(): Promise<string>;
66
+ /**
67
+ * Gets the protocol version that this object supports.
68
+ */
69
+ getProtocolVersion(): Promise<number>;
70
+ /**
71
+ * Requests that the account page or login page (if not authenticated) be opened in a new tab.
72
+ * Only supported on protocol version 2 or more.
73
+ */
74
+ openAccountPage(): Promise<void>;
75
+ /**
76
+ * Adds the given function as a callback for login status information.
77
+ * Only supported on protocol version 2 or more.
78
+ * @param callback The function that should be called when the login status changes.
79
+ */
80
+ addLoginStatusCallback(callback: (status: LoginStatus) => void): Promise<void>;
81
+ /**
82
+ * Adds the given function as a callback for login UI status information.
83
+ * Only supported on protocol version 2 or more.
84
+ * @param callback The function that should be called when the login UI should change.
85
+ */
86
+ addLoginUICallback(callback: (status: LoginUIStatus) => void): Promise<void>;
87
+ /**
88
+ * Sets whether a custom user interface should be used for the login process.
89
+ * If set to true, then there should be at least one callback registered for the login UI.
90
+ * Only supported on protocol version 2 or more.
91
+ * @param useCustomUI Whether a custom user interface should be used instead of the new tab login flow.
92
+ */
93
+ setUseCustomUI(useCustomUI: boolean): Promise<void>;
94
+ /**
95
+ * Specifies the email address and whether the user accepted the terms of service during the login process.
96
+ * Resolves with a validation result that indicates whether an error occurred and what should be shown to the user.
97
+ * Only supported on protocol version 2 or more.
98
+ * @param email The email address that should be used to login.
99
+ * @param acceptedTermsOfService Whether the user accepted the terms of service.
100
+ */
101
+ provideEmailAddress(email: string, acceptedTermsOfService: boolean): Promise<void>;
102
+ /**
103
+ * Cancels the in-progress login attempt.
104
+ */
105
+ cancelLogin(): Promise<void>;
26
106
  }
27
107
  //# sourceMappingURL=AuxAuth.d.ts.map
@@ -1,10 +1,23 @@
1
1
  import { AuthData } from '@casual-simulation/aux-common';
2
2
  import { CreatePublicRecordKeyResult } from '@casual-simulation/aux-records';
3
- import { SubscriptionLike } from 'rxjs';
3
+ import { Observable, SubscriptionLike } from 'rxjs';
4
+ import { LoginStatus, LoginUIStatus } from '../auth/AuxAuth';
4
5
  /**
5
6
  * Defines an interface for objects that are able to keep track of the user's authentication state.
6
7
  */
7
8
  export interface AuthHelperInterface extends SubscriptionLike {
9
+ /**
10
+ * Gets whether this inst supports authentication.
11
+ */
12
+ supportsAuthentication: boolean;
13
+ /**
14
+ * Gets an observable that resolves whenever a login status is available.
15
+ */
16
+ loginStatus: Observable<LoginStatus>;
17
+ /**
18
+ * Gets an observable that resolves whenever the login UI should be updated.
19
+ */
20
+ loginUIStatus: Observable<LoginUIStatus>;
8
21
  /**
9
22
  * Determines whether the user is currently authenticated.
10
23
  * Returns true if the user is logged in, false otherwise.
@@ -23,5 +36,24 @@ export interface AuthHelperInterface extends SubscriptionLike {
23
36
  * @param recordName The name of the record that the key should be created for.
24
37
  */
25
38
  createPublicRecordKey(recordName: string): Promise<CreatePublicRecordKeyResult>;
39
+ /**
40
+ * Opens the user account page or the login page in a new tab.
41
+ */
42
+ openAccountPage(): Promise<void>;
43
+ /**
44
+ * Sets whether a custom login UI should be used.
45
+ * @param useCustomUI Whether the custom login UI should be used.
46
+ */
47
+ setUseCustomUI(useCustomUI: boolean): Promise<void>;
48
+ /**
49
+ * Provides the given email address and whether the user accepted the terms of service for the login flow.
50
+ * @param email The email address that the user provided.
51
+ * @param acceptedTermsOfService Whether the user accepted the terms of service.
52
+ */
53
+ provideEmailAddress(email: string, acceptedTermsOfService: boolean): Promise<void>;
54
+ /**
55
+ * Cancels the current login if it is using the custom UI flow.
56
+ */
57
+ cancelLogin(): Promise<void>;
26
58
  }
27
59
  //# sourceMappingURL=AuthHelperInterface.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casual-simulation/aux-vm",
3
- "version": "2.0.28",
3
+ "version": "2.0.29",
4
4
  "description": "A set of abstractions required to securely run an AUX.",
5
5
  "keywords": [
6
6
  "aux"
@@ -40,7 +40,7 @@
40
40
  "url": "https://github.com/casual-simulation/casualos/issues"
41
41
  },
42
42
  "dependencies": {
43
- "@casual-simulation/aux-common": "^2.0.28",
43
+ "@casual-simulation/aux-common": "^2.0.29",
44
44
  "@casual-simulation/aux-records": "^2.0.28",
45
45
  "@casual-simulation/causal-tree-client-socketio": "^2.0.22",
46
46
  "@casual-simulation/causal-trees": "^2.0.22",
@@ -54,5 +54,5 @@
54
54
  "rxjs": "^6.5.2",
55
55
  "uuid": "^8.3.2"
56
56
  },
57
- "gitHead": "e1f6accd3dd4725ad13655550bbab3aa200afdb7"
57
+ "gitHead": "e0c65922931f9a2ac9bda7827460113930a1ad6d"
58
58
  }