@itwin/core-mobile 4.0.0-dev.46 → 4.0.0-dev.50
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.
|
@@ -1 +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;
|
|
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;IAwB5C,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;CAIpE"}
|
|
@@ -23,19 +23,27 @@ class MobileAuthorizationFrontend {
|
|
|
23
23
|
}
|
|
24
24
|
async getAccessToken() {
|
|
25
25
|
if (this._fetchingToken) {
|
|
26
|
-
|
|
26
|
+
// NOTE: This function is from the AuthorizationClient interface. That interface documents
|
|
27
|
+
// this function to return an empty string if no token is available, NOT throw an exception.
|
|
28
|
+
return ""; // short-circuits any recursive use of this function
|
|
27
29
|
}
|
|
28
30
|
if (this._accessToken && !this._hasExpired) {
|
|
29
31
|
return this._accessToken;
|
|
30
32
|
}
|
|
31
33
|
else {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this._expirationDate = new Date(result[1]);
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
try {
|
|
35
|
+
this._fetchingToken = true;
|
|
36
|
+
const result = await MobileApp_1.MobileApp.callBackend("getAccessToken");
|
|
37
|
+
this._accessToken = result[0];
|
|
38
|
+
this._expirationDate = result[1] ? new Date(result[1]) : undefined;
|
|
39
|
+
return this._accessToken;
|
|
40
|
+
}
|
|
41
|
+
catch (_ex) {
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
this._fetchingToken = false;
|
|
46
|
+
}
|
|
39
47
|
}
|
|
40
48
|
}
|
|
41
49
|
setAccessToken(accessToken, expirationDate) {
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"MobileAuthorizationFrontend.js","sourceRoot":"","sources":["../../../src/frontend/MobileAuthorizationFrontend.ts"],"names":[],"mappings":";AAAA;;;+FAG+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WAAW,IAAI,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;AAtCD,kEAsCC","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 // NOTE: This function is from the AuthorizationClient interface. That interface documents\r\n // this function to return an empty string if no token is available, NOT throw an exception.\r\n return \"\"; // 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 try {\r\n this._fetchingToken = true;\r\n const result = await MobileApp.callBackend(\"getAccessToken\");\r\n this._accessToken = result[0];\r\n this._expirationDate = result[1] ? new Date(result[1]) : undefined;\r\n return this._accessToken;\r\n } catch (_ex) {\r\n return \"\";\r\n } finally {\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-mobile",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.50",
|
|
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": "^4.0.0-dev.
|
|
25
|
-
"@itwin/core-bentley": "^4.0.0-dev.
|
|
26
|
-
"@itwin/core-common": "^4.0.0-dev.
|
|
27
|
-
"@itwin/core-frontend": "^4.0.0-dev.
|
|
28
|
-
"@itwin/presentation-common": "^4.0.0-dev.
|
|
24
|
+
"@itwin/core-backend": "^4.0.0-dev.50",
|
|
25
|
+
"@itwin/core-bentley": "^4.0.0-dev.50",
|
|
26
|
+
"@itwin/core-common": "^4.0.0-dev.50",
|
|
27
|
+
"@itwin/core-frontend": "^4.0.0-dev.50",
|
|
28
|
+
"@itwin/presentation-common": "^4.0.0-dev.50"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"deep-assign": "^2.0.0",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"ws": "^7.5.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@itwin/build-tools": "4.0.0-dev.
|
|
40
|
-
"@itwin/core-backend": "4.0.0-dev.
|
|
41
|
-
"@itwin/core-bentley": "4.0.0-dev.
|
|
42
|
-
"@itwin/core-common": "4.0.0-dev.
|
|
43
|
-
"@itwin/core-frontend": "4.0.0-dev.
|
|
39
|
+
"@itwin/build-tools": "4.0.0-dev.50",
|
|
40
|
+
"@itwin/core-backend": "4.0.0-dev.50",
|
|
41
|
+
"@itwin/core-bentley": "4.0.0-dev.50",
|
|
42
|
+
"@itwin/core-common": "4.0.0-dev.50",
|
|
43
|
+
"@itwin/core-frontend": "4.0.0-dev.50",
|
|
44
44
|
"@itwin/eslint-plugin": "nightly",
|
|
45
|
-
"@itwin/presentation-common": "4.0.0-dev.
|
|
45
|
+
"@itwin/presentation-common": "4.0.0-dev.50",
|
|
46
46
|
"@types/chai": "4.3.1",
|
|
47
47
|
"@types/deep-assign": "^0.1.0",
|
|
48
48
|
"@types/fs-extra": "^4.0.7",
|