@itwin/core-mobile 3.2.0-dev.71 → 3.2.0-dev.75
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/lib/cjs/backend/MobileAuthorizationBackend.d.ts +8 -55
- package/lib/cjs/backend/MobileAuthorizationBackend.d.ts.map +1 -1
- package/lib/cjs/backend/MobileAuthorizationBackend.js +31 -102
- package/lib/cjs/backend/MobileAuthorizationBackend.js.map +1 -1
- package/lib/cjs/backend/MobileHost.d.ts +7 -13
- package/lib/cjs/backend/MobileHost.d.ts.map +1 -1
- package/lib/cjs/backend/MobileHost.js +47 -12
- package/lib/cjs/backend/MobileHost.js.map +1 -1
- package/lib/cjs/common/MobileAppProps.d.ts +4 -1
- package/lib/cjs/common/MobileAppProps.d.ts.map +1 -1
- package/lib/cjs/common/MobileAppProps.js.map +1 -1
- package/lib/cjs/frontend/IOSApp.d.ts +5 -1
- package/lib/cjs/frontend/IOSApp.d.ts.map +1 -1
- package/lib/cjs/frontend/IOSApp.js.map +1 -1
- package/lib/cjs/frontend/MobileApp.d.ts +1 -0
- package/lib/cjs/frontend/MobileApp.d.ts.map +1 -1
- package/lib/cjs/frontend/MobileApp.js +14 -1
- package/lib/cjs/frontend/MobileApp.js.map +1 -1
- package/lib/cjs/frontend/MobileAuthorizationFrontend.d.ts +18 -0
- package/lib/cjs/frontend/MobileAuthorizationFrontend.d.ts.map +1 -0
- package/lib/cjs/frontend/MobileAuthorizationFrontend.js +47 -0
- package/lib/cjs/frontend/MobileAuthorizationFrontend.js.map +1 -0
- package/package.json +14 -14
|
@@ -3,63 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { AccessToken } from "@itwin/core-bentley";
|
|
5
5
|
import { AuthorizationClient } from "@itwin/core-common";
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @beta
|
|
9
|
-
*/
|
|
10
|
-
export interface MobileAppAuthorizationConfiguration {
|
|
11
|
-
/**
|
|
12
|
-
* The OAuth token issuer URL. Defaults to Bentley's auth URL if undefined.
|
|
13
|
-
*/
|
|
14
|
-
issuerUrl?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Upon signing in, the client application receives a response from the Bentley IMS OIDC/OAuth2 provider at this URI
|
|
17
|
-
* For mobile/desktop applications, must start with `http://localhost:${redirectPort}` or `https://localhost:${redirectPort}`
|
|
18
|
-
*/
|
|
19
|
-
readonly redirectUri?: string;
|
|
20
|
-
/** Client application's identifier as registered with the OIDC/OAuth2 provider. */
|
|
21
|
-
readonly clientId: string;
|
|
22
|
-
/** List of space separated scopes to request access to various resources. */
|
|
23
|
-
readonly scope: string;
|
|
24
|
-
/**
|
|
25
|
-
* Time in seconds that's used as a buffer to check the token for validity/expiry.
|
|
26
|
-
* The checks for authorization, and refreshing access tokens all use this buffer - i.e., the token is considered expired if the current time is within the specified
|
|
27
|
-
* time of the actual expiry.
|
|
28
|
-
* @note If unspecified this defaults to 10 minutes.
|
|
29
|
-
*/
|
|
30
|
-
readonly expiryBuffer?: number;
|
|
31
|
-
}
|
|
32
|
-
/** Utility to provide OIDC/OAuth tokens from native ios app to frontend
|
|
33
|
-
* @beta
|
|
6
|
+
/** Utility to provide and cache auth tokens from native mobile apps to IModelHost.
|
|
7
|
+
* @internal
|
|
34
8
|
*/
|
|
35
9
|
export declare class MobileAuthorizationBackend implements AuthorizationClient {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
get redirectUri(): string;
|
|
42
|
-
protected _baseUrl: string;
|
|
43
|
-
protected _url?: string;
|
|
44
|
-
constructor(config?: MobileAppAuthorizationConfiguration);
|
|
45
|
-
/** Used to initialize the client - must be awaited before any other methods are called */
|
|
46
|
-
initialize(config?: MobileAppAuthorizationConfiguration): Promise<void>;
|
|
47
|
-
/** Start the sign-in process */
|
|
48
|
-
signIn(): Promise<void>;
|
|
49
|
-
/** Start the sign-out process */
|
|
50
|
-
signOut(): Promise<void>;
|
|
51
|
-
setAccessToken(token?: AccessToken): void;
|
|
10
|
+
private _accessToken;
|
|
11
|
+
private _expirationDate;
|
|
12
|
+
private _expiryBuffer;
|
|
13
|
+
private _fetchingToken;
|
|
14
|
+
private get _hasExpired();
|
|
52
15
|
getAccessToken(): Promise<AccessToken>;
|
|
53
|
-
|
|
54
|
-
refreshToken(): Promise<AccessToken>;
|
|
55
|
-
/**
|
|
56
|
-
* Gets the URL of the service. Uses the default URL provided by client implementations.
|
|
57
|
-
* If defined, the value of `IMJS_URL_PREFIX` will be used as a prefix to all urls provided
|
|
58
|
-
* by the client implementations.
|
|
59
|
-
*
|
|
60
|
-
* Note that for consistency sake, the URL is stripped of any trailing "/".
|
|
61
|
-
* @returns URL for the service
|
|
62
|
-
*/
|
|
63
|
-
private getUrl;
|
|
16
|
+
setAccessToken(accessToken?: string, expirationDate?: string): void;
|
|
64
17
|
}
|
|
65
18
|
//# sourceMappingURL=MobileAuthorizationBackend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileAuthorizationBackend.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"MobileAuthorizationBackend.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD;;GAEG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IACpE,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,KAAK,WAAW,GAEtB;IAEY,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IA2B5C,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;CAIpE"}
|
|
@@ -8,118 +8,47 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.MobileAuthorizationBackend = void 0;
|
|
11
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
-
const core_common_1 = require("@itwin/core-common");
|
|
13
11
|
const MobileHost_1 = require("./MobileHost");
|
|
14
|
-
/** Utility to provide
|
|
15
|
-
* @
|
|
12
|
+
/** Utility to provide and cache auth tokens from native mobile apps to IModelHost.
|
|
13
|
+
* @internal
|
|
16
14
|
*/
|
|
17
15
|
class MobileAuthorizationBackend {
|
|
18
|
-
constructor(
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
16
|
+
constructor() {
|
|
17
|
+
this._accessToken = "";
|
|
18
|
+
this._expiryBuffer = 60 * 10; // ten minutes
|
|
19
|
+
this._fetchingToken = false;
|
|
22
20
|
}
|
|
23
|
-
get
|
|
24
|
-
|
|
25
|
-
async initialize(config) {
|
|
26
|
-
var _a;
|
|
27
|
-
this.config = config !== null && config !== void 0 ? config : this.config;
|
|
28
|
-
if (!this.config)
|
|
29
|
-
throw new core_common_1.IModelError(core_bentley_1.AuthStatus.Error, "Must specify a valid configuration when initializing authorization");
|
|
30
|
-
if (this.config.expiryBuffer)
|
|
31
|
-
this.expireSafety = this.config.expiryBuffer;
|
|
32
|
-
this.issuerUrl = (_a = this.config.issuerUrl) !== null && _a !== void 0 ? _a : this.getUrl();
|
|
33
|
-
if (!this.issuerUrl)
|
|
34
|
-
throw new core_common_1.IModelError(core_bentley_1.AuthStatus.Error, "The URL of the authorization provider was not initialized");
|
|
35
|
-
MobileHost_1.MobileHost.device.authStateChanged = (tokenString) => {
|
|
36
|
-
this.setAccessToken(tokenString);
|
|
37
|
-
};
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
(0, core_bentley_1.assert)(this.config !== undefined);
|
|
40
|
-
MobileHost_1.MobileHost.device.authInit({ ...this.config, issuerUrl: this.issuerUrl }, (err) => {
|
|
41
|
-
if (!err) {
|
|
42
|
-
resolve();
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
reject(new Error(err));
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/** Start the sign-in process */
|
|
51
|
-
async signIn() {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
MobileHost_1.MobileHost.device.authSignIn((err) => {
|
|
54
|
-
if (!err) {
|
|
55
|
-
resolve();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
reject(new Error(err));
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/** Start the sign-out process */
|
|
64
|
-
async signOut() {
|
|
65
|
-
return new Promise((resolve, reject) => {
|
|
66
|
-
MobileHost_1.MobileHost.device.authSignOut((err) => {
|
|
67
|
-
if (!err) {
|
|
68
|
-
resolve();
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
reject(new Error(err));
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
setAccessToken(token) {
|
|
77
|
-
if (token === this._accessToken)
|
|
78
|
-
return;
|
|
79
|
-
this._accessToken = token;
|
|
21
|
+
get _hasExpired() {
|
|
22
|
+
return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;
|
|
80
23
|
}
|
|
81
24
|
async getAccessToken() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return (_a = this._accessToken) !== null && _a !== void 0 ? _a : "";
|
|
86
|
-
}
|
|
87
|
-
/** return accessToken */
|
|
88
|
-
async refreshToken() {
|
|
25
|
+
if (this._fetchingToken) {
|
|
26
|
+
return Promise.reject(); // short-circuits any recursive use of this function
|
|
27
|
+
}
|
|
89
28
|
return new Promise((resolve, reject) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
29
|
+
if (this._accessToken && !this._hasExpired) {
|
|
30
|
+
resolve(this._accessToken);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this._fetchingToken = true;
|
|
34
|
+
MobileHost_1.MobileHost.device.authGetAccessToken((tokenString, expirationDate, error) => {
|
|
35
|
+
if (error) {
|
|
36
|
+
this._accessToken = "";
|
|
37
|
+
reject(error);
|
|
38
|
+
}
|
|
39
|
+
this._accessToken = tokenString !== null && tokenString !== void 0 ? tokenString : "";
|
|
40
|
+
if (expirationDate !== undefined)
|
|
41
|
+
this._expirationDate = new Date(expirationDate);
|
|
42
|
+
resolve(this._accessToken);
|
|
43
|
+
});
|
|
44
|
+
this._fetchingToken = false;
|
|
45
|
+
}
|
|
98
46
|
});
|
|
99
47
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* by the client implementations.
|
|
104
|
-
*
|
|
105
|
-
* Note that for consistency sake, the URL is stripped of any trailing "/".
|
|
106
|
-
* @returns URL for the service
|
|
107
|
-
*/
|
|
108
|
-
getUrl() {
|
|
109
|
-
var _a, _b, _c;
|
|
110
|
-
if (this._url)
|
|
111
|
-
return this._url;
|
|
112
|
-
if (!this._baseUrl) {
|
|
113
|
-
throw new Error("The client is missing a default url.");
|
|
114
|
-
}
|
|
115
|
-
const prefix = process.env.IMJS_URL_PREFIX;
|
|
116
|
-
const authority = new URL((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.issuerUrl) !== null && _b !== void 0 ? _b : this._baseUrl);
|
|
117
|
-
if (prefix && !((_c = this.config) === null || _c === void 0 ? void 0 : _c.issuerUrl))
|
|
118
|
-
authority.hostname = prefix + authority.hostname;
|
|
119
|
-
this._url = authority.href.replace(/\/$/, "");
|
|
120
|
-
return this._url;
|
|
48
|
+
setAccessToken(accessToken, expirationDate) {
|
|
49
|
+
this._accessToken = accessToken !== null && accessToken !== void 0 ? accessToken : "";
|
|
50
|
+
this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;
|
|
121
51
|
}
|
|
122
52
|
}
|
|
123
53
|
exports.MobileAuthorizationBackend = MobileAuthorizationBackend;
|
|
124
|
-
MobileAuthorizationBackend.defaultRedirectUri = "imodeljs://app/signin-callback";
|
|
125
54
|
//# sourceMappingURL=MobileAuthorizationBackend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileAuthorizationBackend.js","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"MobileAuthorizationBackend.js","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,6CAA0C;AAE1C;;GAEG;AACH,MAAa,0BAA0B;IAAvC;QACU,iBAAY,GAAgB,EAAE,CAAC;QAE/B,kBAAa,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,cAAc;QACvC,mBAAc,GAAG,KAAK,CAAC;IAqCjC,CAAC;IAnCC,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,eAAe,KAAK,SAAS,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IACxH,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,oDAAoD;SAC9E;QAED,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClD,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBAC1C,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aAC5B;iBAAM;gBACL,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;gBAC3B,uBAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,WAAyB,EAAE,cAAuB,EAAE,KAAc,EAAE,EAAE;oBAC1G,IAAI,KAAK,EAAE;wBACT,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;wBACvB,MAAM,CAAC,KAAK,CAAC,CAAC;qBACf;oBAED,IAAI,CAAC,YAAY,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC;oBACtC,IAAI,cAAc,KAAK,SAAS;wBAC9B,IAAI,CAAC,eAAe,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC;oBAElD,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBAC7B,CAAC,CAAC,CAAC;gBACH,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;aAC7B;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,cAAc,CAAC,WAAoB,EAAE,cAAuB;QACjE,IAAI,CAAC,YAAY,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;CACF;AAzCD,gEAyCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module OIDC\r\n */\r\n\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient } from \"@itwin/core-common\";\r\nimport { MobileHost } from \"./MobileHost\";\r\n\r\n/** Utility to provide and cache auth tokens from native mobile apps to IModelHost.\r\n * @internal\r\n */\r\nexport class MobileAuthorizationBackend implements AuthorizationClient {\r\n private _accessToken: AccessToken = \"\";\r\n private _expirationDate: Date | undefined;\r\n private _expiryBuffer = 60 * 10; // ten minutes\r\n private _fetchingToken = false;\r\n\r\n private get _hasExpired(): boolean {\r\n return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;\r\n }\r\n\r\n public async getAccessToken(): Promise<AccessToken> {\r\n if (this._fetchingToken) {\r\n return Promise.reject(); // short-circuits any recursive use of this function\r\n }\r\n\r\n return new Promise<AccessToken>((resolve, reject) => {\r\n if (this._accessToken && !this._hasExpired) {\r\n resolve(this._accessToken);\r\n } else {\r\n this._fetchingToken = true;\r\n MobileHost.device.authGetAccessToken((tokenString?: AccessToken, expirationDate?: string, error?: string) => {\r\n if (error) {\r\n this._accessToken = \"\";\r\n reject(error);\r\n }\r\n\r\n this._accessToken = tokenString ?? \"\";\r\n if (expirationDate !== undefined)\r\n this._expirationDate = new Date(expirationDate);\r\n\r\n resolve(this._accessToken);\r\n });\r\n this._fetchingToken = false;\r\n }\r\n });\r\n }\r\n\r\n public setAccessToken(accessToken?: string, expirationDate?: string) {\r\n this._accessToken = accessToken ?? \"\";\r\n this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;\r\n }\r\n}\r\n"]}
|
|
@@ -3,8 +3,7 @@ import { NativeHostOpts } from "@itwin/core-backend";
|
|
|
3
3
|
import { RpcInterfaceDefinition } from "@itwin/core-common";
|
|
4
4
|
import { CancelRequest } from "./MobileFileHandler";
|
|
5
5
|
import { ProgressCallback } from "./Request";
|
|
6
|
-
import { BatteryState, DeviceEvents, Orientation } from "../common/MobileAppProps";
|
|
7
|
-
import { MobileAppAuthorizationConfiguration } from "./MobileAuthorizationBackend";
|
|
6
|
+
import { BatteryState, DeviceEvents, MobileNotifications, Orientation } from "../common/MobileAppProps";
|
|
8
7
|
/** @beta */
|
|
9
8
|
export declare type MobileCompletionCallback = (downloadUrl: string, downloadFileUrl: string, cancelled: boolean, err?: string) => void;
|
|
10
9
|
/** @beta */
|
|
@@ -37,11 +36,7 @@ export declare abstract class MobileDevice {
|
|
|
37
36
|
abstract resumeDownloadInForeground(requestId: number): boolean;
|
|
38
37
|
abstract resumeDownloadInBackground(requestId: number): boolean;
|
|
39
38
|
abstract reconnect(connection: number): void;
|
|
40
|
-
abstract
|
|
41
|
-
abstract authSignOut(callback: (err?: string) => void): void;
|
|
42
|
-
abstract authGetAccessToken(callback: (accessToken?: string, err?: string) => void): void;
|
|
43
|
-
authInit(_config: MobileAppAuthorizationConfiguration, callback: (err?: string) => void): void;
|
|
44
|
-
abstract authStateChanged(accessToken?: string, err?: string): void;
|
|
39
|
+
abstract authGetAccessToken(callback: (accessToken?: string, expirationDate?: string, err?: string) => void): void;
|
|
45
40
|
}
|
|
46
41
|
/** @beta */
|
|
47
42
|
export interface MobileHostOpts extends NativeHostOpts {
|
|
@@ -49,10 +44,6 @@ export interface MobileHostOpts extends NativeHostOpts {
|
|
|
49
44
|
device?: MobileDevice;
|
|
50
45
|
/** list of RPC interface definitions to register */
|
|
51
46
|
rpcInterfaces?: RpcInterfaceDefinition[];
|
|
52
|
-
/** if present, [[IModelHost.authorizationClient]] will be set to an instance of [[MobileAuthorizationBackend]]. */
|
|
53
|
-
authConfig?: MobileAppAuthorizationConfiguration;
|
|
54
|
-
/** if true, do not attempt to initialize AuthorizationClient on startup */
|
|
55
|
-
noInitializeAuthClient?: boolean;
|
|
56
47
|
};
|
|
57
48
|
}
|
|
58
49
|
/**
|
|
@@ -66,11 +57,14 @@ export declare class MobileHost {
|
|
|
66
57
|
static readonly onEnterForeground: BeEvent<import("@itwin/core-bentley").Listener>;
|
|
67
58
|
static readonly onEnterBackground: BeEvent<import("@itwin/core-bentley").Listener>;
|
|
68
59
|
static readonly onWillTerminate: BeEvent<import("@itwin/core-bentley").Listener>;
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
static readonly onAuthAccessTokenChanged: BeEvent<(accessToken: string | undefined, expirationDate: string | undefined) => void>;
|
|
61
|
+
/** Send a notification to the MobileApp connected to this MobileHost. */
|
|
62
|
+
static notifyMobileFrontend<T extends keyof MobileNotifications>(methodName: T, ...args: Parameters<MobileNotifications[T]>): void;
|
|
71
63
|
/** @internal */
|
|
72
64
|
static reconnect(connection: number): void;
|
|
73
65
|
/** @internal */
|
|
66
|
+
static authGetAccessToken(): Promise<[string, string]>;
|
|
67
|
+
/** @internal */
|
|
74
68
|
static downloadFile(downloadUrl: string, downloadTo: string, progress?: ProgressCallback, cancelRequest?: CancelRequest): Promise<void>;
|
|
75
69
|
static get isValid(): boolean;
|
|
76
70
|
/** Start the backend of a mobile app. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileHost.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileHost.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"MobileHost.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileHost.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,OAAO,EAAmB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAA4D,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/G,OAAO,EAC2C,sBAAsB,EAEvE,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAsC,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAsB,mBAAmB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAK5H,YAAY;AACZ,oBAAY,wBAAwB,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAChI,YAAY;AACZ,oBAAY,sBAA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.onWillTerminate.raiseEvent(...args);
|
|
35
35
|
break;
|
|
36
|
+
case "authAccessTokenChanged":
|
|
37
|
+
MobileHost.onAuthAccessTokenChanged.raiseEvent(args[0], args[1]);
|
|
38
|
+
break;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
authInit(_config, callback) { callback(); }
|
|
39
41
|
}
|
|
40
42
|
exports.MobileDevice = MobileDevice;
|
|
41
43
|
class MobileAppHandler extends core_backend_1.IpcHandler {
|
|
@@ -43,19 +45,35 @@ class MobileAppHandler extends core_backend_1.IpcHandler {
|
|
|
43
45
|
async reconnect(connection) {
|
|
44
46
|
MobileHost.reconnect(connection);
|
|
45
47
|
}
|
|
48
|
+
async getAccessToken() {
|
|
49
|
+
return MobileHost.authGetAccessToken();
|
|
50
|
+
}
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
48
53
|
* @beta
|
|
49
54
|
*/
|
|
50
55
|
class MobileHost {
|
|
51
56
|
static get device() { return this._device; }
|
|
52
|
-
/**
|
|
53
|
-
static
|
|
57
|
+
/** Send a notification to the MobileApp connected to this MobileHost. */
|
|
58
|
+
static notifyMobileFrontend(methodName, ...args) {
|
|
59
|
+
return core_backend_1.IpcHost.send(MobileAppChannel_1.mobileAppNotify, methodName, ...args);
|
|
60
|
+
}
|
|
54
61
|
/** @internal */
|
|
55
62
|
static reconnect(connection) {
|
|
56
63
|
this.device.reconnect(connection);
|
|
57
64
|
}
|
|
58
65
|
/** @internal */
|
|
66
|
+
static async authGetAccessToken() {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
MobileHost.device.authGetAccessToken((tokenString, expirationDate, error) => {
|
|
69
|
+
if (error) {
|
|
70
|
+
reject(error);
|
|
71
|
+
}
|
|
72
|
+
resolve([tokenString !== null && tokenString !== void 0 ? tokenString : "", expirationDate !== null && expirationDate !== void 0 ? expirationDate : ""]);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** @internal */
|
|
59
77
|
static async downloadFile(downloadUrl, downloadTo, progress, cancelRequest) {
|
|
60
78
|
return new Promise((resolve, reject) => {
|
|
61
79
|
let progressCb;
|
|
@@ -91,30 +109,46 @@ class MobileHost {
|
|
|
91
109
|
static get isValid() { return undefined !== this._device; }
|
|
92
110
|
/** Start the backend of a mobile app. */
|
|
93
111
|
static async startup(opt) {
|
|
94
|
-
var _a, _b, _c, _d, _e
|
|
112
|
+
var _a, _b, _c, _d, _e;
|
|
113
|
+
const authorizationClient = new MobileAuthorizationBackend_1.MobileAuthorizationBackend();
|
|
95
114
|
if (!this.isValid) {
|
|
96
115
|
this._device = (_b = (_a = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _a === void 0 ? void 0 : _a.device) !== null && _b !== void 0 ? _b : new MobileDevice();
|
|
97
116
|
// set global device interface.
|
|
98
117
|
global.__iTwinJsNativeBridge = this._device;
|
|
118
|
+
this.onMemoryWarning.addListener(() => {
|
|
119
|
+
MobileHost.notifyMobileFrontend("notifyMemoryWarning");
|
|
120
|
+
});
|
|
121
|
+
this.onOrientationChanged.addListener(() => {
|
|
122
|
+
MobileHost.notifyMobileFrontend("notifyOrientationChanged");
|
|
123
|
+
});
|
|
124
|
+
this.onEnterForeground.addListener(() => {
|
|
125
|
+
MobileHost.notifyMobileFrontend("notifyEnterForeground");
|
|
126
|
+
});
|
|
127
|
+
this.onEnterBackground.addListener(() => {
|
|
128
|
+
MobileHost.notifyMobileFrontend("notifyEnterBackground");
|
|
129
|
+
});
|
|
130
|
+
this.onWillTerminate.addListener(() => {
|
|
131
|
+
MobileHost.notifyMobileFrontend("notifyWillTerminate");
|
|
132
|
+
});
|
|
133
|
+
this.onAuthAccessTokenChanged.addListener((accessToken, expirationDate) => {
|
|
134
|
+
authorizationClient.setAccessToken(accessToken, expirationDate);
|
|
135
|
+
MobileHost.notifyMobileFrontend("notifyAuthAccessTokenChanged", accessToken, expirationDate);
|
|
136
|
+
});
|
|
99
137
|
// following will provide impl for device specific api.
|
|
100
138
|
(0, MobileRpcServer_1.setupMobileRpc)();
|
|
101
139
|
}
|
|
102
|
-
|
|
140
|
+
const iModelHostConfiguration = (_c = opt === null || opt === void 0 ? void 0 : opt.iModelHost) !== null && _c !== void 0 ? _c : new core_backend_1.IModelHostConfiguration();
|
|
141
|
+
iModelHostConfiguration.authorizationClient = authorizationClient;
|
|
142
|
+
await core_backend_1.NativeHost.startup({ ...opt, iModelHost: iModelHostConfiguration });
|
|
103
143
|
if (core_backend_1.IpcHost.isValid)
|
|
104
144
|
MobileAppHandler.register();
|
|
105
|
-
const rpcInterfaces = (
|
|
145
|
+
const rpcInterfaces = (_e = (_d = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _d === void 0 ? void 0 : _d.rpcInterfaces) !== null && _e !== void 0 ? _e : [
|
|
106
146
|
core_common_1.IModelReadRpcInterface,
|
|
107
147
|
core_common_1.IModelTileRpcInterface,
|
|
108
148
|
core_common_1.SnapshotIModelRpcInterface,
|
|
109
149
|
presentation_common_1.PresentationRpcInterface,
|
|
110
150
|
];
|
|
111
151
|
MobileRpcManager_1.MobileRpcManager.initializeImpl(rpcInterfaces);
|
|
112
|
-
const authorizationBackend = new MobileAuthorizationBackend_1.MobileAuthorizationBackend((_e = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _e === void 0 ? void 0 : _e.authConfig);
|
|
113
|
-
const connectivityStatus = core_backend_1.NativeHost.checkInternetConnectivity();
|
|
114
|
-
if (((_f = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _f === void 0 ? void 0 : _f.authConfig) && true !== ((_g = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _g === void 0 ? void 0 : _g.noInitializeAuthClient) && connectivityStatus === core_common_1.InternetConnectivityStatus.Online) {
|
|
115
|
-
await authorizationBackend.initialize((_h = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _h === void 0 ? void 0 : _h.authConfig);
|
|
116
|
-
}
|
|
117
|
-
core_backend_1.IModelHost.authorizationClient = authorizationBackend;
|
|
118
152
|
}
|
|
119
153
|
}
|
|
120
154
|
exports.MobileHost = MobileHost;
|
|
@@ -123,4 +157,5 @@ MobileHost.onOrientationChanged = new core_bentley_1.BeEvent();
|
|
|
123
157
|
MobileHost.onEnterForeground = new core_bentley_1.BeEvent();
|
|
124
158
|
MobileHost.onEnterBackground = new core_bentley_1.BeEvent();
|
|
125
159
|
MobileHost.onWillTerminate = new core_bentley_1.BeEvent();
|
|
160
|
+
MobileHost.onAuthAccessTokenChanged = new core_bentley_1.BeEvent();
|
|
126
161
|
//# sourceMappingURL=MobileHost.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileHost.js","sourceRoot":"","sources":["../../../src/backend/MobileHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA+D;AAC/D,sDAAkG;AAClG,oDAG4B;AAC5B,2DAAwF;AAExF,oEAAsE;AACtE,iEAA8D;AAE9D,iEAA8D;AAC9D,6EAA+G;AAC/G,uDAAmD;AAwBnD,YAAY;AACZ,MAAsB,YAAY;IACzB,IAAI,CAAC,SAAuB,EAAE,GAAG,IAAW;QACjD,QAAQ,SAAS,EAAE;YACjB,KAAK,eAAe;gBAClB,UAAU,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YACxD,KAAK,oBAAoB;gBACvB,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC7D,KAAK,iBAAiB;gBACpB,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC1D,KAAK,iBAAiB;gBACpB,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC1D,KAAK,eAAe;gBAClB,UAAU,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAA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CAAC;AAChC,+BAAoB,GAAG,IAAI,sBAAO,EAAE,CAAC;AACrC,4BAAiB,GAAG,IAAI,sBAAO,EAAE,CAAC;AAClC,4BAAiB,GAAG,IAAI,sBAAO,EAAE,CAAC;AAClC,0BAAe,GAAG,IAAI,sBAAO,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { BeEvent, BriefcaseStatus } from \"@itwin/core-bentley\";\r\nimport { IModelHost, IpcHandler, IpcHost, NativeHost, NativeHostOpts } from \"@itwin/core-backend\";\r\nimport {\r\n IModelReadRpcInterface, IModelTileRpcInterface, InternetConnectivityStatus, RpcInterfaceDefinition,\r\n SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { CancelRequest, DownloadFailed, UserCancelledError } from \"./MobileFileHandler\";\r\nimport { ProgressCallback } from \"./Request\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { mobileAppChannel } from \"../common/MobileAppChannel\";\r\nimport { BatteryState, DeviceEvents, MobileAppFunctions, Orientation } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\r\nimport { MobileAppAuthorizationConfiguration, MobileAuthorizationBackend } from \"./MobileAuthorizationBackend\";\r\nimport { setupMobileRpc } from \"./MobileRpcServer\";\r\n\r\n/** @beta */\r\nexport type MobileCompletionCallback = (downloadUrl: string, downloadFileUrl: string, cancelled: boolean, err?: string) => void;\r\n/** @beta */\r\nexport type MobileProgressCallback = (bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => void;\r\n/** @beta */\r\nexport type MobileCancelCallback = () => boolean;\r\n\r\n/** @beta */\r\nexport interface DownloadTask {\r\n url: string;\r\n downloadPath: string;\r\n isDetached: boolean;\r\n isRunning: boolean;\r\n totalBytes?: number;\r\n doneBytes?: number;\r\n cancelId?: number;\r\n isBackground?: boolean;\r\n cancel?: MobileCancelCallback;\r\n toBackground: () => boolean;\r\n toForeground: () => boolean;\r\n}\r\n\r\n/** @beta */\r\nexport abstract class MobileDevice {\r\n public emit(eventName: DeviceEvents, ...args: any[]) {\r\n switch (eventName) {\r\n case \"memoryWarning\":\r\n MobileHost.onMemoryWarning.raiseEvent(...args); break;\r\n case \"orientationChanged\":\r\n MobileHost.onOrientationChanged.raiseEvent(...args); break;\r\n case \"enterForeground\":\r\n MobileHost.onEnterForeground.raiseEvent(...args); break;\r\n case \"enterBackground\":\r\n MobileHost.onEnterBackground.raiseEvent(...args); break;\r\n case \"willTerminate\":\r\n MobileHost.onWillTerminate.raiseEvent(...args); break;\r\n }\r\n }\r\n\r\n public abstract getOrientation(): Orientation;\r\n public abstract getBatteryState(): BatteryState;\r\n public abstract getBatteryLevel(): number;\r\n public abstract createDownloadTask(downloadUrl: string, isBackground: boolean, downloadTo: string, completion: MobileCompletionCallback, progress?: MobileProgressCallback): number;\r\n public abstract cancelDownloadTask(cancelId: number): boolean;\r\n public abstract getDownloadTasks(): DownloadTask[];\r\n public abstract resumeDownloadInForeground(requestId: number): boolean;\r\n public abstract resumeDownloadInBackground(requestId: number): boolean;\r\n public abstract reconnect(connection: number): void;\r\n public abstract authSignIn(callback: (err?: string) => void): void;\r\n public abstract authSignOut(callback: (err?: string) => void): void;\r\n public abstract authGetAccessToken(callback: (accessToken?: string, err?: string) => void): void;\r\n public authInit(_config: MobileAppAuthorizationConfiguration, callback: (err?: string) => void): void { callback(); }\r\n public abstract authStateChanged(accessToken?: string, err?: string): void;\r\n}\r\n\r\nclass MobileAppHandler extends IpcHandler implements MobileAppFunctions {\r\n public get channelName() { return mobileAppChannel; }\r\n public async reconnect(connection: number) {\r\n MobileHost.reconnect(connection);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport interface MobileHostOpts extends NativeHostOpts {\r\n mobileHost?: {\r\n device?: MobileDevice;\r\n /** list of RPC interface definitions to register */\r\n rpcInterfaces?: RpcInterfaceDefinition[];\r\n /** if present, [[IModelHost.authorizationClient]] will be set to an instance of [[MobileAuthorizationBackend]]. */\r\n authConfig?: MobileAppAuthorizationConfiguration;\r\n /** if true, do not attempt to initialize AuthorizationClient on startup */\r\n noInitializeAuthClient?: boolean;\r\n };\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class MobileHost {\r\n private static _device?: MobileDevice;\r\n public static get device() { return this._device!; }\r\n public static readonly onMemoryWarning = new BeEvent();\r\n public static readonly onOrientationChanged = new BeEvent();\r\n public static readonly onEnterForeground = new BeEvent();\r\n public static readonly onEnterBackground = new BeEvent();\r\n public static readonly onWillTerminate = new BeEvent();\r\n\r\n /** @internal */\r\n public static get authorization() { return IModelHost.authorizationClient; }\r\n\r\n /** @internal */\r\n public static reconnect(connection: number) {\r\n this.device.reconnect(connection);\r\n }\r\n\r\n /** @internal */\r\n public static async downloadFile(downloadUrl: string, downloadTo: string, progress?: ProgressCallback, cancelRequest?: CancelRequest): Promise<void> {\r\n return new Promise<void>((resolve, reject) => {\r\n\r\n let progressCb: MobileProgressCallback | undefined;\r\n let lastReportedOn = Date.now();\r\n const minTimeBeforeReportingProgress = 1000;\r\n if (progress) {\r\n progressCb = (_bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => {\r\n const currentTime = Date.now();\r\n const timeSinceLastEvent = currentTime - lastReportedOn;\r\n // report all event for last 5 Mbs so we never miss 100% progress event\r\n const lastEvent = (totalBytesExpectedToWrite - totalBytesWritten) < 1024 * 1024 * 5;\r\n if (timeSinceLastEvent < minTimeBeforeReportingProgress && !lastEvent)\r\n return;\r\n\r\n lastReportedOn = currentTime;\r\n const percent = Number((100 * (totalBytesWritten / totalBytesExpectedToWrite)).toFixed(2));\r\n progress({ total: totalBytesExpectedToWrite, loaded: totalBytesWritten, percent });\r\n };\r\n }\r\n const requestId = this.device.createDownloadTask(downloadUrl, false, downloadTo, (_downloadUrl: string, _downloadFileUrl: string, cancelled: boolean, err?: string) => {\r\n if (cancelled)\r\n reject(new UserCancelledError(BriefcaseStatus.DownloadCancelled, \"User cancelled download\"));\r\n else if (err)\r\n reject(new DownloadFailed(400, \"Download failed\"));\r\n else\r\n resolve();\r\n }, progressCb);\r\n if (cancelRequest) {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n cancelRequest.cancel = () => { return this.device.cancelDownloadTask(requestId); };\r\n }\r\n });\r\n }\r\n\r\n public static get isValid() { return undefined !== this._device; }\r\n\r\n /** Start the backend of a mobile app. */\r\n public static async startup(opt?: MobileHostOpts): Promise<void> {\r\n if (!this.isValid) {\r\n this._device = opt?.mobileHost?.device ?? new (MobileDevice as any)();\r\n // set global device interface.\r\n (global as any).__iTwinJsNativeBridge = this._device;\r\n // following will provide impl for device specific api.\r\n setupMobileRpc();\r\n }\r\n\r\n await NativeHost.startup(opt);\r\n if (IpcHost.isValid)\r\n MobileAppHandler.register();\r\n\r\n const rpcInterfaces = opt?.mobileHost?.rpcInterfaces ?? [\r\n IModelReadRpcInterface,\r\n IModelTileRpcInterface,\r\n SnapshotIModelRpcInterface,\r\n PresentationRpcInterface,\r\n ];\r\n\r\n MobileRpcManager.initializeImpl(rpcInterfaces);\r\n\r\n const authorizationBackend = new MobileAuthorizationBackend(opt?.mobileHost?.authConfig);\r\n const connectivityStatus = NativeHost.checkInternetConnectivity();\r\n if (opt?.mobileHost?.authConfig && true !== opt?.mobileHost?.noInitializeAuthClient && connectivityStatus === InternetConnectivityStatus.Online) {\r\n await authorizationBackend.initialize(opt?.mobileHost?.authConfig);\r\n }\r\n IModelHost.authorizationClient = authorizationBackend;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"MobileHost.js","sourceRoot":"","sources":["../../../src/backend/MobileHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA4E;AAC5E,sDAA+G;AAC/G,oDAG4B;AAC5B,2DAAwF;AAExF,oEAAsE;AACtE,i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AE,WAAW,EAAE,cAAc,CAAC,CAAC;YAC/F,CAAC,CAAC,CAAC;YAEH,uDAAuD;YACvD,IAAA,gCAAc,GAAE,CAAC;SAClB;QACD,MAAM,uBAAuB,GAAG,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,mCAAI,IAAI,sCAAuB,EAAE,CAAC;QACjF,uBAAuB,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAClE,MAAM,yBAAU,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,EAAE,UAAU,EAAE,uBAAuB,EAAE,CAAC,CAAC;QAE1E,IAAI,sBAAO,CAAC,OAAO;YACjB,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAE9B,MAAM,aAAa,GAAG,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,aAAa,mCAAI;YACtD,oCAAsB;YACtB,oCAAsB;YACtB,wCAA0B;YAC1B,8CAAwB;SACzB,CAAC;QAEF,mCAAgB,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IACjD,CAAC;;AAnHH,gCAoHC;AAjHwB,0BAAe,GAAG,IAAI,sBAAO,EAAE,CAAC;AAChC,+BAAoB,GAAG,IAAI,sBAAO,EAAE,CAAC;AACrC,4BAAiB,GAAG,IAAI,sBAAO,EAAE,CAAC;AAClC,4BAAiB,GAAG,IAAI,sBAAO,EAAE,CAAC;AAClC,0BAAe,GAAG,IAAI,sBAAO,EAAE,CAAC;AAChC,mCAAwB,GAAG,IAAI,sBAAO,EAAiF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { AccessToken, BeEvent, BriefcaseStatus } from \"@itwin/core-bentley\";\r\nimport { IModelHostConfiguration, IpcHandler, IpcHost, NativeHost, NativeHostOpts } from \"@itwin/core-backend\";\r\nimport {\r\n IModelReadRpcInterface, IModelTileRpcInterface, RpcInterfaceDefinition,\r\n SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { CancelRequest, DownloadFailed, UserCancelledError } from \"./MobileFileHandler\";\r\nimport { ProgressCallback } from \"./Request\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { mobileAppChannel, mobileAppNotify } from \"../common/MobileAppChannel\";\r\nimport { BatteryState, DeviceEvents, MobileAppFunctions, MobileNotifications, Orientation } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\r\nimport { MobileAuthorizationBackend } from \"./MobileAuthorizationBackend\";\r\nimport { setupMobileRpc } from \"./MobileRpcServer\";\r\n\r\n/** @beta */\r\nexport type MobileCompletionCallback = (downloadUrl: string, downloadFileUrl: string, cancelled: boolean, err?: string) => void;\r\n/** @beta */\r\nexport type MobileProgressCallback = (bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => void;\r\n/** @beta */\r\nexport type MobileCancelCallback = () => boolean;\r\n\r\n/** @beta */\r\nexport interface DownloadTask {\r\n url: string;\r\n downloadPath: string;\r\n isDetached: boolean;\r\n isRunning: boolean;\r\n totalBytes?: number;\r\n doneBytes?: number;\r\n cancelId?: number;\r\n isBackground?: boolean;\r\n cancel?: MobileCancelCallback;\r\n toBackground: () => boolean;\r\n toForeground: () => boolean;\r\n}\r\n\r\n/** @beta */\r\nexport abstract class MobileDevice {\r\n public emit(eventName: DeviceEvents, ...args: any[]) {\r\n switch (eventName) {\r\n case \"memoryWarning\":\r\n MobileHost.onMemoryWarning.raiseEvent(...args); break;\r\n case \"orientationChanged\":\r\n MobileHost.onOrientationChanged.raiseEvent(...args); break;\r\n case \"enterForeground\":\r\n MobileHost.onEnterForeground.raiseEvent(...args); break;\r\n case \"enterBackground\":\r\n MobileHost.onEnterBackground.raiseEvent(...args); break;\r\n case \"willTerminate\":\r\n MobileHost.onWillTerminate.raiseEvent(...args); break;\r\n case \"authAccessTokenChanged\":\r\n MobileHost.onAuthAccessTokenChanged.raiseEvent(args[0], args[1]); break;\r\n }\r\n }\r\n\r\n public abstract getOrientation(): Orientation;\r\n public abstract getBatteryState(): BatteryState;\r\n public abstract getBatteryLevel(): number;\r\n public abstract createDownloadTask(downloadUrl: string, isBackground: boolean, downloadTo: string, completion: MobileCompletionCallback, progress?: MobileProgressCallback): number;\r\n public abstract cancelDownloadTask(cancelId: number): boolean;\r\n public abstract getDownloadTasks(): DownloadTask[];\r\n public abstract resumeDownloadInForeground(requestId: number): boolean;\r\n public abstract resumeDownloadInBackground(requestId: number): boolean;\r\n public abstract reconnect(connection: number): void;\r\n public abstract authGetAccessToken(callback: (accessToken?: string, expirationDate?: string, err?: string) => void): void;\r\n}\r\n\r\nclass MobileAppHandler extends IpcHandler implements MobileAppFunctions {\r\n public get channelName() { return mobileAppChannel; }\r\n public async reconnect(connection: number) {\r\n MobileHost.reconnect(connection);\r\n }\r\n public async getAccessToken() {\r\n return MobileHost.authGetAccessToken();\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport interface MobileHostOpts extends NativeHostOpts {\r\n mobileHost?: {\r\n device?: MobileDevice;\r\n /** list of RPC interface definitions to register */\r\n rpcInterfaces?: RpcInterfaceDefinition[];\r\n };\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class MobileHost {\r\n private static _device?: MobileDevice;\r\n public static get device() { return this._device!; }\r\n public static readonly onMemoryWarning = new BeEvent();\r\n public static readonly onOrientationChanged = new BeEvent();\r\n public static readonly onEnterForeground = new BeEvent();\r\n public static readonly onEnterBackground = new BeEvent();\r\n public static readonly onWillTerminate = new BeEvent();\r\n public static readonly onAuthAccessTokenChanged = new BeEvent<(accessToken: string | undefined, expirationDate: string | undefined) => void>();\r\n\r\n /** Send a notification to the MobileApp connected to this MobileHost. */\r\n public static notifyMobileFrontend<T extends keyof MobileNotifications>(methodName: T, ...args: Parameters<MobileNotifications[T]>) {\r\n return IpcHost.send(mobileAppNotify, methodName, ...args);\r\n }\r\n\r\n /** @internal */\r\n public static reconnect(connection: number) {\r\n this.device.reconnect(connection);\r\n }\r\n\r\n /** @internal */\r\n public static async authGetAccessToken() {\r\n return new Promise<[AccessToken, string]>((resolve, reject) => {\r\n MobileHost.device.authGetAccessToken((tokenString?: AccessToken, expirationDate?: string, error?: string) => {\r\n if (error) {\r\n reject(error);\r\n }\r\n resolve([tokenString ?? \"\", expirationDate ?? \"\"]);\r\n });\r\n });\r\n }\r\n\r\n /** @internal */\r\n public static async downloadFile(downloadUrl: string, downloadTo: string, progress?: ProgressCallback, cancelRequest?: CancelRequest): Promise<void> {\r\n return new Promise<void>((resolve, reject) => {\r\n\r\n let progressCb: MobileProgressCallback | undefined;\r\n let lastReportedOn = Date.now();\r\n const minTimeBeforeReportingProgress = 1000;\r\n if (progress) {\r\n progressCb = (_bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => {\r\n const currentTime = Date.now();\r\n const timeSinceLastEvent = currentTime - lastReportedOn;\r\n // report all event for last 5 Mbs so we never miss 100% progress event\r\n const lastEvent = (totalBytesExpectedToWrite - totalBytesWritten) < 1024 * 1024 * 5;\r\n if (timeSinceLastEvent < minTimeBeforeReportingProgress && !lastEvent)\r\n return;\r\n\r\n lastReportedOn = currentTime;\r\n const percent = Number((100 * (totalBytesWritten / totalBytesExpectedToWrite)).toFixed(2));\r\n progress({ total: totalBytesExpectedToWrite, loaded: totalBytesWritten, percent });\r\n };\r\n }\r\n const requestId = this.device.createDownloadTask(downloadUrl, false, downloadTo, (_downloadUrl: string, _downloadFileUrl: string, cancelled: boolean, err?: string) => {\r\n if (cancelled)\r\n reject(new UserCancelledError(BriefcaseStatus.DownloadCancelled, \"User cancelled download\"));\r\n else if (err)\r\n reject(new DownloadFailed(400, \"Download failed\"));\r\n else\r\n resolve();\r\n }, progressCb);\r\n if (cancelRequest) {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n cancelRequest.cancel = () => { return this.device.cancelDownloadTask(requestId); };\r\n }\r\n });\r\n }\r\n\r\n public static get isValid() { return undefined !== this._device; }\r\n\r\n /** Start the backend of a mobile app. */\r\n public static async startup(opt?: MobileHostOpts): Promise<void> {\r\n const authorizationClient = new MobileAuthorizationBackend();\r\n if (!this.isValid) {\r\n this._device = opt?.mobileHost?.device ?? new (MobileDevice as any)();\r\n // set global device interface.\r\n (global as any).__iTwinJsNativeBridge = this._device;\r\n this.onMemoryWarning.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyMemoryWarning\");\r\n });\r\n this.onOrientationChanged.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyOrientationChanged\");\r\n });\r\n this.onEnterForeground.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyEnterForeground\");\r\n });\r\n this.onEnterBackground.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyEnterBackground\");\r\n });\r\n this.onWillTerminate.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyWillTerminate\");\r\n });\r\n this.onAuthAccessTokenChanged.addListener((accessToken: string | undefined, expirationDate: string | undefined) => {\r\n authorizationClient.setAccessToken(accessToken, expirationDate);\r\n MobileHost.notifyMobileFrontend(\"notifyAuthAccessTokenChanged\", accessToken, expirationDate);\r\n });\r\n\r\n // following will provide impl for device specific api.\r\n setupMobileRpc();\r\n }\r\n const iModelHostConfiguration = opt?.iModelHost ?? new IModelHostConfiguration();\r\n iModelHostConfiguration.authorizationClient = authorizationClient;\r\n await NativeHost.startup({ ...opt, iModelHost: iModelHostConfiguration });\r\n\r\n if (IpcHost.isValid)\r\n MobileAppHandler.register();\r\n\r\n const rpcInterfaces = opt?.mobileHost?.rpcInterfaces ?? [\r\n IModelReadRpcInterface,\r\n IModelTileRpcInterface,\r\n SnapshotIModelRpcInterface,\r\n PresentationRpcInterface,\r\n ];\r\n\r\n MobileRpcManager.initializeImpl(rpcInterfaces);\r\n }\r\n}\r\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AccessToken } from "@itwin/core-bentley";
|
|
1
2
|
/** @beta */
|
|
2
3
|
export declare enum Orientation {
|
|
3
4
|
Unknown = 0,
|
|
@@ -22,14 +23,16 @@ export interface MobileNotifications {
|
|
|
22
23
|
notifyEnterForeground: () => void;
|
|
23
24
|
notifyEnterBackground: () => void;
|
|
24
25
|
notifyWillTerminate: () => void;
|
|
26
|
+
notifyAuthAccessTokenChanged: (accessToken: string | undefined, expirationDate: string | undefined) => void;
|
|
25
27
|
}
|
|
26
28
|
/** @beta */
|
|
27
|
-
export declare type DeviceEvents = "memoryWarning" | "orientationChanged" | "enterForeground" | "enterBackground" | "willTerminate";
|
|
29
|
+
export declare type DeviceEvents = "memoryWarning" | "orientationChanged" | "enterForeground" | "enterBackground" | "willTerminate" | "authAccessTokenChanged";
|
|
28
30
|
/**
|
|
29
31
|
* The methods that may be invoked via Ipc from the frontend of a Mobile App that are implemented on its backend.
|
|
30
32
|
* @beta
|
|
31
33
|
*/
|
|
32
34
|
export interface MobileAppFunctions {
|
|
33
35
|
reconnect: (connection: number) => Promise<void>;
|
|
36
|
+
getAccessToken: () => Promise<[AccessToken, string]>;
|
|
34
37
|
}
|
|
35
38
|
//# sourceMappingURL=MobileAppProps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileAppProps.d.ts","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":"AAKA,YAAY;AACZ,oBAAY,WAAW;IACrB,OAAO,IAAI;IACX,QAAQ,IAAM;IACd,kBAAkB,IAAM;IACxB,aAAa,IAAM;IACnB,cAAc,IAAM;IACpB,MAAM,KAAO;IACb,QAAQ,KAAO;CAChB;AAED,YAAY;AACZ,oBAAY,YAAY;IACtB,OAAO,IAAI;IACX,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,IAAI,IAAI;CACT;AAED,YAAY;AACZ,MAAM,WAAW,mBAAmB;IAClC,mBAAmB,EAAE,M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AAC,CAAC,CAAC;CACtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileAppProps.js","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;
|
|
1
|
+
{"version":3,"file":"MobileAppProps.js","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAI/F,YAAY;AACZ,IAAY,WAQX;AARD,WAAY,WAAW;IACrB,mDAAW,CAAA;IACX,qDAAc,CAAA;IACd,yEAAwB,CAAA;IACxB,+DAAmB,CAAA;IACnB,iEAAoB,CAAA;IACpB,kDAAa,CAAA;IACb,sDAAe,CAAA;AACjB,CAAC,EARW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAQtB;AAED,YAAY;AACZ,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,yDAAa,CAAA;IACb,uDAAY,CAAA;IACZ,+CAAQ,CAAA;AACV,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\n\r\n/** @beta */\r\nexport enum Orientation {\r\n Unknown = 0,\r\n Portrait = 0x1,\r\n PortraitUpsideDown = 0x2,\r\n LandscapeLeft = 0x4,\r\n LandscapeRight = 0x8,\r\n FaceUp = 0x10,\r\n FaceDown = 0x20,\r\n}\r\n\r\n/** @beta */\r\nexport enum BatteryState {\r\n Unknown = 0,\r\n Unplugged = 1,\r\n Charging = 2,\r\n Full = 3,\r\n}\r\n\r\n/** @beta */\r\nexport interface MobileNotifications {\r\n notifyMemoryWarning: () => void;\r\n notifyOrientationChanged: () => void;\r\n notifyEnterForeground: () => void;\r\n notifyEnterBackground: () => void;\r\n notifyWillTerminate: () => void;\r\n notifyAuthAccessTokenChanged: (accessToken: string | undefined, expirationDate: string | undefined) => void;\r\n}\r\n\r\n/** @beta */\r\nexport type DeviceEvents = \"memoryWarning\" | \"orientationChanged\" | \"enterForeground\" | \"enterBackground\" | \"willTerminate\" | \"authAccessTokenChanged\";\r\n\r\n/**\r\n* The methods that may be invoked via Ipc from the frontend of a Mobile App that are implemented on its backend.\r\n* @beta\r\n*/\r\nexport interface MobileAppFunctions {\r\n reconnect: (connection: number) => Promise<void>;\r\n getAccessToken: () => Promise<[AccessToken, string]>;\r\n}\r\n"]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { NativeAppOpts } from "@itwin/core-frontend";
|
|
2
2
|
/** @beta */
|
|
3
|
-
export declare type IOSAppOpts = NativeAppOpts
|
|
3
|
+
export declare type IOSAppOpts = NativeAppOpts & {
|
|
4
|
+
iModelApp: {
|
|
5
|
+
authorizationClient?: never;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
4
8
|
/** @beta */
|
|
5
9
|
export declare class IOSApp {
|
|
6
10
|
private static _isValid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IOSApp.d.ts","sourceRoot":"","sources":["../../../src/frontend/IOSApp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,YAAY;AACZ,oBAAY,UAAU,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"IOSApp.d.ts","sourceRoot":"","sources":["../../../src/frontend/IOSApp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,YAAY;AACZ,oBAAY,UAAU,GAAG,aAAa,GAAG;IAAE,SAAS,EAAE;QAAE,mBAAmB,CAAC,EAAE,KAAK,CAAA;KAAE,CAAA;CAAE,CAAC;AAExF,YAAY;AACZ,qBAAa,MAAM;IAEjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,WAAkB,OAAO,YAA4B;WACjC,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU;CAM9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IOSApp.js","sourceRoot":"","sources":["../../../src/frontend/IOSApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAG/F,2CAAwC;AAKxC,YAAY;AACZ,MAAa,MAAM;IAGV,MAAM,KAAK,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACtB;QACD,MAAM,qBAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;;AATH,wBAUC;AARgB,eAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { NativeAppOpts } from \"@itwin/core-frontend\";\r\nimport { MobileApp } from \"./MobileApp\";\r\n\r\n/** @beta */\r\nexport type IOSAppOpts = NativeAppOpts;\r\n\r\n/** @beta */\r\nexport class IOSApp {\r\n\r\n private static _isValid = false;\r\n public static get isValid() { return this._isValid; }\r\n public static async startup(opts?: IOSAppOpts) {\r\n if (!this._isValid) {\r\n this._isValid = true;\r\n }\r\n await MobileApp.startup(opts);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"IOSApp.js","sourceRoot":"","sources":["../../../src/frontend/IOSApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAG/F,2CAAwC;AAKxC,YAAY;AACZ,MAAa,MAAM;IAGV,MAAM,KAAK,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACtB;QACD,MAAM,qBAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;;AATH,wBAUC;AARgB,eAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { NativeAppOpts } from \"@itwin/core-frontend\";\r\nimport { MobileApp } from \"./MobileApp\";\r\n\r\n/** @beta */\r\nexport type IOSAppOpts = NativeAppOpts & { iModelApp: { authorizationClient?: never } };\r\n\r\n/** @beta */\r\nexport class IOSApp {\r\n\r\n private static _isValid = false;\r\n public static get isValid() { return this._isValid; }\r\n public static async startup(opts?: IOSAppOpts) {\r\n if (!this._isValid) {\r\n this._isValid = true;\r\n }\r\n await MobileApp.startup(opts);\r\n }\r\n}\r\n"]}
|
|
@@ -8,6 +8,7 @@ export declare class MobileApp {
|
|
|
8
8
|
static onEnterForeground: BeEvent<() => void>;
|
|
9
9
|
static onEnterBackground: BeEvent<() => void>;
|
|
10
10
|
static onWillTerminate: BeEvent<() => void>;
|
|
11
|
+
static onAuthAccessTokenChanged: BeEvent<(accessToken: string | undefined, expirationDate: string | undefined) => void>;
|
|
11
12
|
static callBackend<T extends AsyncMethodsOf<MobileAppFunctions>>(methodName: T, ...args: Parameters<MobileAppFunctions[T]>): Promise<PromiseReturnType<MobileAppFunctions[T]>>;
|
|
12
13
|
private static _isValid;
|
|
13
14
|
static get isValid(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileApp.d.ts","sourceRoot":"","sources":["../../../src/frontend/MobileApp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAU,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAqB,aAAa,EAAuB,MAAM,sBAAsB,CAAC;AAE7F,OAAO,EAAE,kBAAkB,EAAuB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"MobileApp.d.ts","sourceRoot":"","sources":["../../../src/frontend/MobileApp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAU,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAqB,aAAa,EAAuB,MAAM,sBAAsB,CAAC;AAE7F,OAAO,EAAE,kBAAkB,EAAuB,MAAM,0BAA0B,CAAC;AAwBnF,YAAY;AACZ,qBAAa,SAAS;IACpB,OAAc,eAAe,gBAAqB,IAAI,EAAI;IAC1D,OAAc,oBAAoB,gBAAqB,IAAI,EAAI;IAC/D,OAAc,iBAAiB,gBAAqB,IAAI,EAAI;IAC5D,OAAc,iBAAiB,gBAAqB,IAAI,EAAI;IAC5D,OAAc,eAAe,gBAAqB,IAAI,EAAI;IAC1D,OAAc,wBAAwB,wBAA6B,MAAM,GAAG,SAAS,kBAAkB,MAAM,GAAG,SAAS,KAAK,IAAI,EAAI;WAClH,WAAW,CAAC,CAAC,SAAS,cAAc,CAAC,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAIvI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,WAAkB,OAAO,YAA4B;IACrD;;;OAGG;WACiB,OAAO,CAAC,IAAI,CAAC,EAAE,aAAa;CAsBjD"}
|
|
@@ -10,6 +10,7 @@ const core_common_1 = require("@itwin/core-common");
|
|
|
10
10
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
11
11
|
const MobileAppChannel_1 = require("../common/MobileAppChannel");
|
|
12
12
|
const MobileRpcManager_1 = require("../common/MobileRpcManager");
|
|
13
|
+
const MobileAuthorizationFrontend_1 = require("./MobileAuthorizationFrontend");
|
|
13
14
|
/** receive notifications from backend */
|
|
14
15
|
class MobileAppNotifyHandler extends core_frontend_1.NotificationHandler {
|
|
15
16
|
get channelName() { return MobileAppChannel_1.mobileAppNotify; }
|
|
@@ -24,6 +25,9 @@ class MobileAppNotifyHandler extends core_frontend_1.NotificationHandler {
|
|
|
24
25
|
notifyEnterForeground() { MobileApp.onEnterBackground.raiseEvent(); }
|
|
25
26
|
notifyEnterBackground() { MobileApp.onEnterBackground.raiseEvent(); }
|
|
26
27
|
notifyWillTerminate() { MobileApp.onWillTerminate.raiseEvent(); }
|
|
28
|
+
notifyAuthAccessTokenChanged(accessToken, expirationDate) {
|
|
29
|
+
MobileApp.onAuthAccessTokenChanged.raiseEvent(accessToken, expirationDate);
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
/** @beta */
|
|
29
33
|
class MobileApp {
|
|
@@ -37,13 +41,21 @@ class MobileApp {
|
|
|
37
41
|
*/
|
|
38
42
|
static async startup(opts) {
|
|
39
43
|
var _a, _b;
|
|
44
|
+
const iModelAppOpts = {
|
|
45
|
+
...opts === null || opts === void 0 ? void 0 : opts.iModelApp,
|
|
46
|
+
};
|
|
47
|
+
const authorizationClient = new MobileAuthorizationFrontend_1.MobileAuthorizationFrontend();
|
|
48
|
+
iModelAppOpts.authorizationClient = authorizationClient;
|
|
40
49
|
if (!this._isValid) {
|
|
50
|
+
this.onAuthAccessTokenChanged.addListener((accessToken, expirationDate) => {
|
|
51
|
+
authorizationClient.setAccessToken(accessToken, expirationDate);
|
|
52
|
+
});
|
|
41
53
|
const rpcInterfaces = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.iModelApp) === null || _a === void 0 ? void 0 : _a.rpcInterfaces) !== null && _b !== void 0 ? _b : [core_common_1.IModelReadRpcInterface, core_common_1.IModelTileRpcInterface];
|
|
42
54
|
MobileRpcManager_1.MobileRpcManager.initializeClient(rpcInterfaces);
|
|
43
55
|
this._isValid = true;
|
|
44
56
|
}
|
|
45
57
|
const socket = new core_common_1.IpcWebSocketFrontend(); // needs work
|
|
46
|
-
await core_frontend_1.NativeApp.startup(socket, opts);
|
|
58
|
+
await core_frontend_1.NativeApp.startup(socket, { ...opts, iModelApp: iModelAppOpts });
|
|
47
59
|
MobileAppNotifyHandler.register(); // receives notifications from backend
|
|
48
60
|
}
|
|
49
61
|
}
|
|
@@ -53,5 +65,6 @@ MobileApp.onOrientationChanged = new core_bentley_1.BeEvent();
|
|
|
53
65
|
MobileApp.onEnterForeground = new core_bentley_1.BeEvent();
|
|
54
66
|
MobileApp.onEnterBackground = new core_bentley_1.BeEvent();
|
|
55
67
|
MobileApp.onWillTerminate = new core_bentley_1.BeEvent();
|
|
68
|
+
MobileApp.onAuthAccessTokenChanged = new core_bentley_1.BeEvent();
|
|
56
69
|
MobileApp._isValid = false;
|
|
57
70
|
//# sourceMappingURL=MobileApp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileApp.js","sourceRoot":"","sources":["../../../src/frontend/MobileApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAyF;AACzF,oDAA0G;AAC1G,wDAA6F;AAC7F,iEAA+E;AAE/E,iEAA8D;
|
|
1
|
+
{"version":3,"file":"MobileApp.js","sourceRoot":"","sources":["../../../src/frontend/MobileApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAyF;AACzF,oDAA0G;AAC1G,wDAA6F;AAC7F,iEAA+E;AAE/E,iEAA8D;AAC9D,+EAA4E;AAE5E,yCAAyC;AACzC,MAAM,sBAAuB,SAAQ,mCAAmB;IACtD,IAAW,WAAW,KAAK,OAAO,kCAAe,CAAC,CAAC,CAAC;IAE7C,mBAAmB;QACxB,qBAAM,CAAC,UAAU,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAA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,WAA+B,EAAE,cAAkC,EAAE,EAAE;gBAChH,mBAAmB,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAClE,CAAC,CAAC,CAAC;YAEH,MAAM,aAAa,GAAG,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,0CAAE,aAAa,mCAAI,CAAC,oCAAsB,EAAE,oCAAsB,CAAC,CAAC;YACzG,mCAAgB,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;YACjD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACtB;QAED,MAAM,MAAM,GAAG,IAAI,kCAAoB,EAAE,CAAC,CAAC,aAAa;QACxD,MAAM,yBAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;QAEvE,sBAAsB,CAAC,QAAQ,EAAE,CAAC,CAAC,sCAAsC;IAC3E,CAAC;;AAtCH,8BAuCC;AAtCe,yBAAe,GAAG,IAAI,sBAAO,EAAc,CAAC;AAC5C,8BAAoB,GAAG,IAAI,sBAAO,EAAc,CAAC;AACjD,2BAAiB,GAAG,IAAI,sBAAO,EAAc,CAAC;AAC9C,2BAAiB,GAAG,IAAI,sBAAO,EAAc,CAAC;AAC9C,yBAAe,GAAG,IAAI,sBAAO,EAAc,CAAC;AAC5C,kCAAwB,GAAG,IAAI,sBAAO,EAAiF,CAAC;AAKvH,kBAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { AsyncMethodsOf, BeEvent, Logger, PromiseReturnType } from \"@itwin/core-bentley\";\r\nimport { IModelReadRpcInterface, IModelTileRpcInterface, IpcWebSocketFrontend } from \"@itwin/core-common\";\r\nimport { IpcApp, NativeApp, NativeAppOpts, NotificationHandler } from \"@itwin/core-frontend\";\r\nimport { mobileAppChannel, mobileAppNotify } from \"../common/MobileAppChannel\";\r\nimport { MobileAppFunctions, MobileNotifications } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\r\nimport { MobileAuthorizationFrontend } from \"./MobileAuthorizationFrontend\";\r\n\r\n/** receive notifications from backend */\r\nclass MobileAppNotifyHandler extends NotificationHandler implements MobileNotifications {\r\n public get channelName() { return mobileAppNotify; }\r\n\r\n public notifyMemoryWarning() {\r\n Logger.logWarning(\"mobileApp\", \"Low memory warning\");\r\n if (MobileApp.onMemoryWarning.numberOfListeners === 0) {\r\n alert(\"Low memory warning\");\r\n }\r\n MobileApp.onMemoryWarning.raiseEvent();\r\n }\r\n public notifyOrientationChanged() { MobileApp.onOrientationChanged.raiseEvent(); }\r\n public notifyEnterForeground() { MobileApp.onEnterBackground.raiseEvent(); }\r\n public notifyEnterBackground() { MobileApp.onEnterBackground.raiseEvent(); }\r\n public notifyWillTerminate() { MobileApp.onWillTerminate.raiseEvent(); }\r\n public notifyAuthAccessTokenChanged(accessToken: string | undefined, expirationDate: string | undefined) {\r\n MobileApp.onAuthAccessTokenChanged.raiseEvent(accessToken, expirationDate);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport class MobileApp {\r\n public static onMemoryWarning = new BeEvent<() => void>();\r\n public static onOrientationChanged = new BeEvent<() => void>();\r\n public static onEnterForeground = new BeEvent<() => void>();\r\n public static onEnterBackground = new BeEvent<() => void>();\r\n public static onWillTerminate = new BeEvent<() => void>();\r\n public static onAuthAccessTokenChanged = new BeEvent<(accessToken: string | undefined, expirationDate: string | undefined) => void>();\r\n public static async callBackend<T extends AsyncMethodsOf<MobileAppFunctions>>(methodName: T, ...args: Parameters<MobileAppFunctions[T]>) {\r\n return IpcApp.callIpcChannel(mobileAppChannel, methodName, ...args) as PromiseReturnType<MobileAppFunctions[T]>;\r\n }\r\n\r\n private static _isValid = false;\r\n public static get isValid() { return this._isValid; }\r\n /**\r\n * This is called by either AndroidApp.startup or IOSApp.startup - it should not be called directly\r\n * @internal\r\n */\r\n public static async startup(opts?: NativeAppOpts) {\r\n const iModelAppOpts = {\r\n ...opts?.iModelApp,\r\n };\r\n const authorizationClient = new MobileAuthorizationFrontend();\r\n iModelAppOpts.authorizationClient = authorizationClient;\r\n\r\n if (!this._isValid) {\r\n this.onAuthAccessTokenChanged.addListener((accessToken: string | undefined, expirationDate: string | undefined) => {\r\n authorizationClient.setAccessToken(accessToken, expirationDate);\r\n });\r\n\r\n const rpcInterfaces = opts?.iModelApp?.rpcInterfaces ?? [IModelReadRpcInterface, IModelTileRpcInterface];\r\n MobileRpcManager.initializeClient(rpcInterfaces);\r\n this._isValid = true;\r\n }\r\n\r\n const socket = new IpcWebSocketFrontend(); // needs work\r\n await NativeApp.startup(socket, { ...opts, iModelApp: iModelAppOpts });\r\n\r\n MobileAppNotifyHandler.register(); // receives notifications from backend\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module OIDC
|
|
3
|
+
*/
|
|
4
|
+
import { AccessToken } from "@itwin/core-bentley";
|
|
5
|
+
import { AuthorizationClient } from "@itwin/core-common";
|
|
6
|
+
/** Utility to provide and cache auth tokens from native mobile apps to IModelApp.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare class MobileAuthorizationFrontend implements AuthorizationClient {
|
|
10
|
+
private _accessToken;
|
|
11
|
+
private _expirationDate;
|
|
12
|
+
private _expiryBuffer;
|
|
13
|
+
private _fetchingToken;
|
|
14
|
+
private get _hasExpired();
|
|
15
|
+
getAccessToken(): Promise<AccessToken>;
|
|
16
|
+
setAccessToken(accessToken?: string, expirationDate?: string): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=MobileAuthorizationFrontend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileAuthorizationFrontend.d.ts","sourceRoot":"","sources":["../../../src/frontend/MobileAuthorizationFrontend.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD;;GAEG;AACH,qBAAa,2BAA4B,YAAW,mBAAmB;IACrE,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,KAAK,WAAW,GAEtB;IAEY,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAkB5C,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;CAIpE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module OIDC
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MobileAuthorizationFrontend = void 0;
|
|
11
|
+
const MobileApp_1 = require("./MobileApp");
|
|
12
|
+
/** Utility to provide and cache auth tokens from native mobile apps to IModelApp.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
class MobileAuthorizationFrontend {
|
|
16
|
+
constructor() {
|
|
17
|
+
this._accessToken = "";
|
|
18
|
+
this._expiryBuffer = 60 * 10; // ten minutes
|
|
19
|
+
this._fetchingToken = false;
|
|
20
|
+
}
|
|
21
|
+
get _hasExpired() {
|
|
22
|
+
return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;
|
|
23
|
+
}
|
|
24
|
+
async getAccessToken() {
|
|
25
|
+
if (this._fetchingToken) {
|
|
26
|
+
return Promise.reject(); // short-circuits any recursive use of this function
|
|
27
|
+
}
|
|
28
|
+
if (this._accessToken && !this._hasExpired) {
|
|
29
|
+
return this._accessToken;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this._fetchingToken = true;
|
|
33
|
+
const result = await MobileApp_1.MobileApp.callBackend("getAccessToken");
|
|
34
|
+
this._accessToken = result[0];
|
|
35
|
+
if (result[1])
|
|
36
|
+
this._expirationDate = new Date(result[1]);
|
|
37
|
+
this._fetchingToken = false;
|
|
38
|
+
return this._accessToken;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
setAccessToken(accessToken, expirationDate) {
|
|
42
|
+
this._accessToken = accessToken !== null && accessToken !== void 0 ? accessToken : "";
|
|
43
|
+
this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.MobileAuthorizationFrontend = MobileAuthorizationFrontend;
|
|
47
|
+
//# sourceMappingURL=MobileAuthorizationFrontend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileAuthorizationFrontend.js","sourceRoot":"","sources":["../../../src/frontend/MobileAuthorizationFrontend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,2CAAwC;AAExC;;GAEG;AACH,MAAa,2BAA2B;IAAxC;QACU,iBAAY,GAAgB,EAAE,CAAC;QAE/B,kBAAa,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,cAAc;QACvC,mBAAc,GAAG,KAAK,CAAC;IA4BjC,CAAC;IA1BC,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,eAAe,KAAK,SAAS,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IACxH,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,oDAAoD;SAC9E;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YAC1C,OAAO,IAAI,CAAC,YAAY,CAAC;SAC1B;aAAM;YACL,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,MAAM,MAAM,GAAG,MAAM,qBAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;YAC7D,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,MAAM,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,eAAe,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;YAC5B,OAAO,IAAI,CAAC,YAAY,CAAC;SAC1B;IACH,CAAC;IAEM,cAAc,CAAC,WAAoB,EAAE,cAAuB;QACjE,IAAI,CAAC,YAAY,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;CACF;AAhCD,kEAgCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module OIDC\r\n */\r\n\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient } from \"@itwin/core-common\";\r\nimport { MobileApp } from \"./MobileApp\";\r\n\r\n/** Utility to provide and cache auth tokens from native mobile apps to IModelApp.\r\n * @internal\r\n */\r\nexport class MobileAuthorizationFrontend implements AuthorizationClient {\r\n private _accessToken: AccessToken = \"\";\r\n private _expirationDate: Date | undefined;\r\n private _expiryBuffer = 60 * 10; // ten minutes\r\n private _fetchingToken = false;\r\n\r\n private get _hasExpired(): boolean {\r\n return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;\r\n }\r\n\r\n public async getAccessToken(): Promise<AccessToken> {\r\n if (this._fetchingToken) {\r\n return Promise.reject(); // short-circuits any recursive use of this function\r\n }\r\n\r\n if (this._accessToken && !this._hasExpired) {\r\n return this._accessToken;\r\n } else {\r\n this._fetchingToken = true;\r\n const result = await MobileApp.callBackend(\"getAccessToken\");\r\n this._accessToken = result[0];\r\n if (result[1])\r\n this._expirationDate = new Date(result[1]);\r\n this._fetchingToken = false;\r\n return this._accessToken;\r\n }\r\n }\r\n\r\n public setAccessToken(accessToken?: string, expirationDate?: string) {\r\n this._accessToken = accessToken ?? \"\";\r\n this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-mobile",
|
|
3
|
-
"version": "3.2.0-dev.
|
|
3
|
+
"version": "3.2.0-dev.75",
|
|
4
4
|
"description": "iTwin.js MobileHost and MobileApp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"url": "http://www.bentley.com"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@itwin/core-backend": "^3.2.0-dev.
|
|
25
|
-
"@itwin/core-bentley": "^3.2.0-dev.
|
|
26
|
-
"@itwin/core-common": "^3.2.0-dev.
|
|
27
|
-
"@itwin/core-frontend": "^3.2.0-dev.
|
|
28
|
-
"@itwin/presentation-common": "^3.2.0-dev.
|
|
24
|
+
"@itwin/core-backend": "^3.2.0-dev.75",
|
|
25
|
+
"@itwin/core-bentley": "^3.2.0-dev.75",
|
|
26
|
+
"@itwin/core-common": "^3.2.0-dev.75",
|
|
27
|
+
"@itwin/core-frontend": "^3.2.0-dev.75",
|
|
28
|
+
"@itwin/presentation-common": "^3.2.0-dev.75"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"deep-assign": "^2.0.0",
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
"ws": "^7.5.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@itwin/build-tools": "3.2.0-dev.
|
|
40
|
-
"@itwin/core-backend": "3.2.0-dev.
|
|
41
|
-
"@itwin/core-bentley": "3.2.0-dev.
|
|
42
|
-
"@itwin/core-common": "3.2.0-dev.
|
|
43
|
-
"@itwin/core-frontend": "3.2.0-dev.
|
|
44
|
-
"@itwin/eslint-plugin": "3.2.0-dev.
|
|
45
|
-
"@itwin/presentation-common": "3.2.0-dev.
|
|
39
|
+
"@itwin/build-tools": "3.2.0-dev.75",
|
|
40
|
+
"@itwin/core-backend": "3.2.0-dev.75",
|
|
41
|
+
"@itwin/core-bentley": "3.2.0-dev.75",
|
|
42
|
+
"@itwin/core-common": "3.2.0-dev.75",
|
|
43
|
+
"@itwin/core-frontend": "3.2.0-dev.75",
|
|
44
|
+
"@itwin/eslint-plugin": "3.2.0-dev.75",
|
|
45
|
+
"@itwin/presentation-common": "3.2.0-dev.75",
|
|
46
46
|
"@types/chai": "^4.1.4",
|
|
47
47
|
"@types/deep-assign": "^0.1.0",
|
|
48
48
|
"@types/fs-extra": "^4.0.7",
|
|
49
49
|
"@types/lodash": "^4.14.0",
|
|
50
50
|
"@types/mocha": "^8.2.2",
|
|
51
|
-
"@types/node": "
|
|
51
|
+
"@types/node": "16.11.7",
|
|
52
52
|
"@types/qs": "^6.5.0",
|
|
53
53
|
"@types/superagent": "^4.1.14",
|
|
54
54
|
"@types/ws": "^7.0.0",
|