@mindline/sync 1.0.83 → 1.0.85
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/.vs/slnx.sqlite +0 -0
- package/.vs/sync/FileContentIndex/6b0435c7-04a6-494d-a28d-c9a2c4cab755.vsidx +0 -0
- package/.vs/sync/v17/.wsuo +0 -0
- package/.vs/sync/v17/DocumentLayout.json +40 -32
- package/hybridspa.ts +73 -26
- package/index.d.ts +4 -9
- package/index.ts +70 -3
- package/package.json +1 -1
- package/.vs/sync/FileContentIndex/9202737f-bacb-4298-9380-81bbb5a99577.vsidx +0 -0
package/.vs/slnx.sqlite
CHANGED
|
Binary file
|
package/.vs/sync/v17/.wsuo
CHANGED
|
Binary file
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
"WorkspaceRootPath": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\",
|
|
4
4
|
"Documents": [
|
|
5
5
|
{
|
|
6
|
-
"AbsoluteMoniker": "D:
|
|
7
|
-
"RelativeMoniker": "D:
|
|
6
|
+
"AbsoluteMoniker": "D:1:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
|
|
7
|
+
"RelativeMoniker": "D:1:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
|
|
8
8
|
},
|
|
9
9
|
{
|
|
10
|
-
"AbsoluteMoniker": "D:
|
|
11
|
-
"RelativeMoniker": "D:
|
|
10
|
+
"AbsoluteMoniker": "D:2:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
|
|
11
|
+
"RelativeMoniker": "D:2:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
|
-
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\
|
|
15
|
-
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:
|
|
14
|
+
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
|
|
15
|
+
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.d.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
|
-
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\
|
|
19
|
-
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:
|
|
18
|
+
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
|
|
19
|
+
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:hybridspa.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
|
|
20
20
|
}
|
|
21
21
|
],
|
|
22
22
|
"DocumentGroupContainers": [
|
|
@@ -63,42 +63,50 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
|
-
"DockedWidth":
|
|
67
|
-
"SelectedChildIndex":
|
|
66
|
+
"DockedWidth": 168,
|
|
67
|
+
"SelectedChildIndex": 1,
|
|
68
68
|
"Children": [
|
|
69
69
|
{
|
|
70
70
|
"$type": "Document",
|
|
71
71
|
"DocumentIndex": 2,
|
|
72
|
-
"Title": "
|
|
73
|
-
"DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\
|
|
74
|
-
"RelativeDocumentMoniker": "
|
|
75
|
-
"ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\
|
|
76
|
-
"RelativeToolTip": "
|
|
77
|
-
"ViewState": "
|
|
78
|
-
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.
|
|
79
|
-
"WhenOpened": "
|
|
72
|
+
"Title": "index.d.ts",
|
|
73
|
+
"DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts",
|
|
74
|
+
"RelativeDocumentMoniker": "index.d.ts",
|
|
75
|
+
"ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts",
|
|
76
|
+
"RelativeToolTip": "index.d.ts",
|
|
77
|
+
"ViewState": "AQIAABoAAAAAAAAAAAAAABoAAAAoAAAA",
|
|
78
|
+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
|
|
79
|
+
"WhenOpened": "2025-01-29T23:22:53.18Z",
|
|
80
|
+
"EditorCaption": ""
|
|
80
81
|
},
|
|
81
82
|
{
|
|
82
83
|
"$type": "Document",
|
|
83
|
-
"DocumentIndex":
|
|
84
|
-
"Title": "
|
|
85
|
-
"DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\
|
|
86
|
-
"RelativeDocumentMoniker": "
|
|
87
|
-
"ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\
|
|
88
|
-
"RelativeToolTip": "
|
|
89
|
-
"ViewState": "
|
|
90
|
-
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.
|
|
91
|
-
"WhenOpened": "
|
|
92
|
-
|
|
84
|
+
"DocumentIndex": 1,
|
|
85
|
+
"Title": "index.ts",
|
|
86
|
+
"DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
|
|
87
|
+
"RelativeDocumentMoniker": "index.ts",
|
|
88
|
+
"ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
|
|
89
|
+
"RelativeToolTip": "index.ts",
|
|
90
|
+
"ViewState": "AQIAAOIIAAAAAAAAAAAAAOcIAAAAAAAA",
|
|
91
|
+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
|
|
92
|
+
"WhenOpened": "2025-01-29T23:46:37.773Z",
|
|
93
|
+
"EditorCaption": ""
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"DockedWidth": 232,
|
|
99
|
+
"SelectedChildIndex": 1,
|
|
100
|
+
"Children": [
|
|
93
101
|
{
|
|
94
102
|
"$type": "Document",
|
|
95
|
-
"DocumentIndex":
|
|
103
|
+
"DocumentIndex": 3,
|
|
96
104
|
"Title": "hybridspa.ts",
|
|
97
105
|
"DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
|
|
98
106
|
"RelativeDocumentMoniker": "hybridspa.ts",
|
|
99
107
|
"ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
|
|
100
108
|
"RelativeToolTip": "hybridspa.ts",
|
|
101
|
-
"ViewState": "
|
|
109
|
+
"ViewState": "AQIAAAAAAAAAAAAAAAAAABQAAAAXAAAA",
|
|
102
110
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
|
|
103
111
|
"WhenOpened": "2024-11-04T14:16:26.493Z",
|
|
104
112
|
"EditorCaption": ""
|
|
@@ -111,9 +119,9 @@
|
|
|
111
119
|
"RelativeDocumentMoniker": "index.ts",
|
|
112
120
|
"ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
|
|
113
121
|
"RelativeToolTip": "index.ts",
|
|
114
|
-
"ViewState": "
|
|
122
|
+
"ViewState": "AQIAAL0HAAAAAAAAAADgv9sHAAA1AAAA",
|
|
115
123
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
|
|
116
|
-
"WhenOpened": "
|
|
124
|
+
"WhenOpened": "2025-01-29T14:51:05.763Z",
|
|
117
125
|
"EditorCaption": ""
|
|
118
126
|
}
|
|
119
127
|
]
|
package/hybridspa.ts
CHANGED
|
@@ -37,10 +37,28 @@ async function mindlineDefineHeaders(
|
|
|
37
37
|
const headers = new Headers();
|
|
38
38
|
headers.append("Content-Type", "application/json");
|
|
39
39
|
headers.append("accept", "*/*");
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
// always call acquireTokenSilent, handling expired tokens on exception
|
|
41
|
+
const apiScope: string = getAPIScope(user);
|
|
42
|
+
try {
|
|
43
|
+
let accounts: AccountInfo[] = instance.getAllAccounts();
|
|
44
|
+
let homeAccountId = user.oid + "." + user.tid;
|
|
45
|
+
let account: AccountInfo = null;
|
|
46
|
+
for (let i: number = 0; i < accounts.length; i++) {
|
|
47
|
+
if (accounts[i].homeAccountId == homeAccountId) {
|
|
48
|
+
account = accounts[i];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let response: AuthenticationResult = await instance.acquireTokenSilent({
|
|
52
|
+
scopes: [apiScope],
|
|
53
|
+
account: account
|
|
54
|
+
});
|
|
55
|
+
user.mindlineAccessToken = response.accessToken; // cache access token
|
|
56
|
+
console.log("Front end mindline token acquired silently: " + user.mindlineAccessToken.slice(0, 20));
|
|
57
|
+
}
|
|
58
|
+
catch (error: any) {
|
|
43
59
|
try {
|
|
60
|
+
console.log("Front end mindline token silent acquisition failure, triggering redirect: " + error);
|
|
61
|
+
// fallback to redirect if silent acquisition fails
|
|
44
62
|
let accounts: AccountInfo[] = instance.getAllAccounts();
|
|
45
63
|
let homeAccountId = user.oid + "." + user.tid;
|
|
46
64
|
let account: AccountInfo = null;
|
|
@@ -49,33 +67,14 @@ async function mindlineDefineHeaders(
|
|
|
49
67
|
account = accounts[i];
|
|
50
68
|
}
|
|
51
69
|
}
|
|
52
|
-
|
|
70
|
+
// assumption: this redirect will trigger login flow callbacks in program.cs
|
|
71
|
+
instance.acquireTokenRedirect({
|
|
53
72
|
scopes: [apiScope],
|
|
54
73
|
account: account
|
|
55
74
|
});
|
|
56
|
-
user.mindlineAccessToken = response.accessToken; // cache access token
|
|
57
|
-
console.log("Front end token acquired silently: " + user.mindlineAccessToken.slice(0, 20));
|
|
58
75
|
}
|
|
59
76
|
catch (error: any) {
|
|
60
|
-
|
|
61
|
-
console.log("Front end token silent acquisition failure: " + error);
|
|
62
|
-
// fallback to redirect if silent acquisition fails
|
|
63
|
-
let accounts: AccountInfo[] = instance.getAllAccounts();
|
|
64
|
-
let homeAccountId = user.oid + "." + user.tid;
|
|
65
|
-
let account: AccountInfo = null;
|
|
66
|
-
for (let i: number = 0; i < accounts.length; i++) {
|
|
67
|
-
if (accounts[i].homeAccountId == homeAccountId) {
|
|
68
|
-
account = accounts[i];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
instance.acquireTokenRedirect({
|
|
72
|
-
scopes: [apiScope],
|
|
73
|
-
account: account
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
catch (error: any) {
|
|
77
|
-
console.log("Front end token popup acquisition failure: " + error);
|
|
78
|
-
}
|
|
77
|
+
console.log("Front end mindline token redirect acquisition failure: " + error);
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
headers.append("Authorization", `Bearer ${user.mindlineAccessToken}`);
|
|
@@ -388,6 +387,55 @@ export async function configDelete(
|
|
|
388
387
|
}
|
|
389
388
|
return result;
|
|
390
389
|
}
|
|
390
|
+
//configPatch
|
|
391
|
+
export async function configPatch(
|
|
392
|
+
instance: IPublicClientApplication,
|
|
393
|
+
authorizedUser: User,
|
|
394
|
+
configurationId: string,
|
|
395
|
+
enabled: boolean,
|
|
396
|
+
debug: boolean
|
|
397
|
+
): Promise<APIResult> {
|
|
398
|
+
let result: APIResult = new APIResult();
|
|
399
|
+
if (configurationId === "") {
|
|
400
|
+
result.result = false;
|
|
401
|
+
result.error = "configPatch: invalid config ID";
|
|
402
|
+
result.status = 500;
|
|
403
|
+
return result;
|
|
404
|
+
}
|
|
405
|
+
// create parametrized config endpoint
|
|
406
|
+
let endpoint: string = mindlineConfig.configEnabledEndpoint();
|
|
407
|
+
let url: URL = new URL(endpoint);
|
|
408
|
+
url.searchParams.append("configurationId", configurationId);
|
|
409
|
+
url.searchParams.append("isEnabled", enabled.toString());
|
|
410
|
+
// create config headers
|
|
411
|
+
const headers = await mindlineDefineHeaders(instance, authorizedUser);
|
|
412
|
+
let options = { method: "PATCH", headers: headers };
|
|
413
|
+
// make config endpoint call
|
|
414
|
+
try {
|
|
415
|
+
if (debug) debugger;
|
|
416
|
+
console.log("Attempting PATCH to /config: " + url.href);
|
|
417
|
+
let response = await fetch(url.href, options);
|
|
418
|
+
if (response.status === 200 && response.statusText === "OK") {
|
|
419
|
+
console.log(`Successful PATCH to ${url.href}: ${enabled.toString()}`);
|
|
420
|
+
return result;
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
result.error = await processErrors(response);
|
|
424
|
+
console.log(`Failed PATCH to ${url.href}: ${enabled.toString()}`);
|
|
425
|
+
console.log(result.error);
|
|
426
|
+
result.status = 500;
|
|
427
|
+
result.result = false;
|
|
428
|
+
return result;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
catch (error: any) {
|
|
432
|
+
result.error = error.message;
|
|
433
|
+
result.status = 500;
|
|
434
|
+
result.result = false;
|
|
435
|
+
console.log(error.message);
|
|
436
|
+
}
|
|
437
|
+
return result;
|
|
438
|
+
}
|
|
391
439
|
//configPost
|
|
392
440
|
export async function configPost(
|
|
393
441
|
instance: IPublicClientApplication,
|
|
@@ -490,7 +538,6 @@ export async function configPut(
|
|
|
490
538
|
{
|
|
491
539
|
"name": "${config.name}",
|
|
492
540
|
"description": "${config.description}",
|
|
493
|
-
"isEnabled": ${config.isEnabled},
|
|
494
541
|
"tenants": [`;
|
|
495
542
|
config.tenants.map((tci: TenantConfigInfo) => {
|
|
496
543
|
// if last character is } we need a comma first
|
package/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ declare module "@mindline/sync" {
|
|
|
22
22
|
static adminEndpoint(): string;
|
|
23
23
|
static adminIncompleteEndpoint(): string;
|
|
24
24
|
static adminsEndpoint(): string;
|
|
25
|
+
static configConsentEndpoint(): string;
|
|
26
|
+
static configEnabledEndpoint(): string;
|
|
25
27
|
static configEndpoint(): string;
|
|
26
28
|
static configsEndpoint(): string;
|
|
27
29
|
static initEndpoint(): string;
|
|
@@ -319,15 +321,8 @@ declare module "@mindline/sync" {
|
|
|
319
321
|
// ======================= Mindline Config API ===============================
|
|
320
322
|
export function configConsentForRead(instance: IPublicClientApplication, authorizedUser: User, configId: string, tid: string, consent: boolean): Promise<APIResult>;
|
|
321
323
|
export function configConsentForWrite(instance: IPublicClientApplication, authorizedUser: User, configId: string, tid: string, consent: boolean): Promise<APIResult>;
|
|
322
|
-
export function configEdit(
|
|
323
|
-
|
|
324
|
-
authorizedUser: User,
|
|
325
|
-
config: Config,
|
|
326
|
-
setConfigId: (id: string) => void,
|
|
327
|
-
setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void,
|
|
328
|
-
workspace: Workspace,
|
|
329
|
-
ii: InitInfo,
|
|
330
|
-
debug: boolean): APIResult;
|
|
324
|
+
export function configEdit(instance: IPublicClientApplication, authorizedUser: User, config: Config, setConfigId: (id: string) => void, setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void, workspace: Workspace, ii: InitInfo, debug: boolean): APIResult;
|
|
325
|
+
export function configEnable(instance: IPublicClientApplication, authorizedUser: User, configurationId: string, enabled: boolean, debug: boolean): APIResult;
|
|
331
326
|
export function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): APIResult;
|
|
332
327
|
export function configsRefresh(instance: IPublicClientApplication, authorizedUser: User, workspaceId: string, ii: InitInfo, debug: boolean): APIResult;
|
|
333
328
|
export function initGet(instance: IPublicClientApplication, user: User, ii: InitInfo, tasks: TaskArray, debug: boolean): APIResult;
|
package/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as signalR from "@microsoft/signalr"
|
|
|
3
3
|
import { AccountInfo } from "@azure/msal-common";
|
|
4
4
|
import { IPublicClientApplication, AuthenticationResult } from "@azure/msal-browser"
|
|
5
5
|
import { deserializeArray } from 'class-transformer';
|
|
6
|
-
import { processErrors, adminDelete, adminPost, adminsGet, configConsentReadPut, configConsentWritePut, configDelete, configsGet, configPost, configPut, initPost, readerPost, tenantPost, tenantDelete, tenantsGet, workspacePut, workspacesGet } from './hybridspa';
|
|
6
|
+
import { processErrors, adminDelete, adminPost, adminsGet, configConsentReadPut, configConsentWritePut, configDelete, configsGet, configPatch, configPost, configPut, initPost, readerPost, tenantPost, tenantDelete, tenantsGet, workspacePut, workspacesGet } from './hybridspa';
|
|
7
7
|
import { version } from './package.json';
|
|
8
8
|
import users from "./users.json";
|
|
9
9
|
import tenants from "./tenants.json";
|
|
@@ -51,6 +51,9 @@ export class mindlineConfig {
|
|
|
51
51
|
static configConsentEndpoint(): string {
|
|
52
52
|
return `https://${mindlineConfig.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/consent`;
|
|
53
53
|
};
|
|
54
|
+
static configEnabledEndpoint(): string {
|
|
55
|
+
return `https://${mindlineConfig.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/status`;
|
|
56
|
+
};
|
|
54
57
|
static configEndpoint(): string {
|
|
55
58
|
return `https://${mindlineConfig.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration`;
|
|
56
59
|
};
|
|
@@ -1358,6 +1361,10 @@ export class ActorNode {
|
|
|
1358
1361
|
}
|
|
1359
1362
|
}
|
|
1360
1363
|
// ======================= Azure AD Graph API ===============================
|
|
1364
|
+
// helper functions
|
|
1365
|
+
function getGraphAPIScope(user: User): string {
|
|
1366
|
+
return "Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All";
|
|
1367
|
+
}
|
|
1361
1368
|
// TODO: this is where you want to trigger a re-authentication if token expires
|
|
1362
1369
|
async function graphDefineHeaders(
|
|
1363
1370
|
instance: IPublicClientApplication,
|
|
@@ -1366,7 +1373,8 @@ async function graphDefineHeaders(
|
|
|
1366
1373
|
const headers = new Headers();
|
|
1367
1374
|
headers.append("Content-Type", "application/json");
|
|
1368
1375
|
headers.append("accept", "*/*");
|
|
1369
|
-
|
|
1376
|
+
const graphAPIScope: string = getGraphAPIScope(user);
|
|
1377
|
+
// only call acquireTokenByCode if we have never redeemed the code
|
|
1370
1378
|
if (user.graphAccessToken == null || user.graphAccessToken === "") {
|
|
1371
1379
|
try {
|
|
1372
1380
|
let response: AuthenticationResult = await instance.acquireTokenByCode({
|
|
@@ -1379,6 +1387,47 @@ async function graphDefineHeaders(
|
|
|
1379
1387
|
console.log("Front end token failure: " + error);
|
|
1380
1388
|
}
|
|
1381
1389
|
}
|
|
1390
|
+
// otherwise, call acquireTokenSilent and deal with token expiration on exception
|
|
1391
|
+
else {
|
|
1392
|
+
try {
|
|
1393
|
+
let accounts: AccountInfo[] = instance.getAllAccounts();
|
|
1394
|
+
let homeAccountId = user.oid + "." + user.tid;
|
|
1395
|
+
let account: AccountInfo = null;
|
|
1396
|
+
for (let i: number = 0; i < accounts.length; i++) {
|
|
1397
|
+
if (accounts[i].homeAccountId == homeAccountId) {
|
|
1398
|
+
account = accounts[i];
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
let response: AuthenticationResult = await instance.acquireTokenSilent({
|
|
1402
|
+
scopes: [graphAPIScope],
|
|
1403
|
+
account: account
|
|
1404
|
+
});
|
|
1405
|
+
user.graphAccessToken = response.accessToken; // cache access token
|
|
1406
|
+
console.log("Front end token graph acquired silently: " + user.graphAccessToken.slice(0, 20));
|
|
1407
|
+
}
|
|
1408
|
+
catch (error: any) {
|
|
1409
|
+
try {
|
|
1410
|
+
console.log("Front end graph token silent acquisition failure: " + error);
|
|
1411
|
+
// fallback to redirect if silent acquisition fails
|
|
1412
|
+
let accounts: AccountInfo[] = instance.getAllAccounts();
|
|
1413
|
+
let homeAccountId = user.oid + "." + user.tid;
|
|
1414
|
+
let account: AccountInfo = null;
|
|
1415
|
+
for (let i: number = 0; i < accounts.length; i++) {
|
|
1416
|
+
if (accounts[i].homeAccountId == homeAccountId) {
|
|
1417
|
+
account = accounts[i];
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
// assumption: this redirect will trigger login flow callbacks in program.cs
|
|
1421
|
+
instance.acquireTokenRedirect({
|
|
1422
|
+
scopes: [graphAPIScope],
|
|
1423
|
+
account: account
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
catch (error: any) {
|
|
1427
|
+
console.log("Front end graph token redirect acquisition failure: " + error);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1382
1431
|
headers.append("Authorization", `Bearer ${user.graphAccessToken}`);
|
|
1383
1432
|
return headers;
|
|
1384
1433
|
}
|
|
@@ -1921,6 +1970,17 @@ export async function configEdit(
|
|
|
1921
1970
|
ii.save();
|
|
1922
1971
|
return result;
|
|
1923
1972
|
}
|
|
1973
|
+
export async function configEnable(
|
|
1974
|
+
instance: IPublicClientApplication,
|
|
1975
|
+
authorizedUser: User,
|
|
1976
|
+
configurationId: string,
|
|
1977
|
+
enabled: boolean,
|
|
1978
|
+
debug: boolean
|
|
1979
|
+
): Promise<APIResult> {
|
|
1980
|
+
let result: APIResult = new APIResult();
|
|
1981
|
+
result = await configPatch(instance, authorizedUser, configurationId, enabled, debug);
|
|
1982
|
+
return result;
|
|
1983
|
+
}
|
|
1924
1984
|
export async function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): Promise<APIResult> {
|
|
1925
1985
|
return configDelete(instance, authorizedUser, config, workspaceId, debug);
|
|
1926
1986
|
}
|
|
@@ -1942,7 +2002,14 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
|
|
|
1942
2002
|
let result: APIResult = await configsGet(instance, authorizedUser, workspace.id, debug);
|
|
1943
2003
|
if (!result.result) return result;
|
|
1944
2004
|
// process returned workspace components
|
|
1945
|
-
|
|
2005
|
+
let configSelectedId: string = "";
|
|
2006
|
+
for (let cid of workspace.associatedConfigs) {
|
|
2007
|
+
let config = ii.cs.find((c: Config) => c.id === cid);
|
|
2008
|
+
if (config != null && config.sel) {
|
|
2009
|
+
configSelectedId = config.id;
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
processReturnedConfigs(workspace, ii, result.array!, configSelectedId);
|
|
1946
2013
|
// tag components with workspaceIDs
|
|
1947
2014
|
ii.tagWithWorkspaces();
|
|
1948
2015
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindline/sync",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.85",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"exports": "./index.ts",
|
|
7
7
|
"description": "sync is a node.js package encapsulating javscript classes required for configuring Mindline sync service.",
|
|
Binary file
|