@mindline/sync 1.0.81 → 1.0.83

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.
@@ -2,6 +2,5 @@
2
2
  "ExpandedNodes": [
3
3
  ""
4
4
  ],
5
- "SelectedNode": "\\package.json",
6
5
  "PreviewInSolutionExplorer": false
7
6
  }
package/.vs/slnx.sqlite CHANGED
Binary file
Binary file
@@ -2,21 +2,21 @@
2
2
  "Version": 1,
3
3
  "WorkspaceRootPath": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\",
4
4
  "Documents": [
5
- {
6
- "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\package.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
7
- "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:package.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
8
- },
9
5
  {
10
6
  "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
11
7
  "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
12
8
  },
13
- {
14
- "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\users.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
15
- "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:users.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
16
- },
17
9
  {
18
10
  "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
11
  "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:hybridspa.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
12
+ },
13
+ {
14
+ "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\package.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
15
+ "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:package.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
16
+ },
17
+ {
18
+ "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\users.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
19
+ "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:users.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
20
20
  }
21
21
  ],
22
22
  "DocumentGroupContainers": [
@@ -64,11 +64,11 @@
64
64
  },
65
65
  {
66
66
  "DockedWidth": 200,
67
- "SelectedChildIndex": 0,
67
+ "SelectedChildIndex": 3,
68
68
  "Children": [
69
69
  {
70
70
  "$type": "Document",
71
- "DocumentIndex": 0,
71
+ "DocumentIndex": 2,
72
72
  "Title": "package.json",
73
73
  "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\package.json",
74
74
  "RelativeDocumentMoniker": "package.json",
@@ -76,12 +76,11 @@
76
76
  "RelativeToolTip": "package.json",
77
77
  "ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
78
78
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
79
- "WhenOpened": "2024-11-06T06:24:37.385Z",
80
- "EditorCaption": ""
79
+ "WhenOpened": "2024-11-06T06:24:37.385Z"
81
80
  },
82
81
  {
83
82
  "$type": "Document",
84
- "DocumentIndex": 2,
83
+ "DocumentIndex": 3,
85
84
  "Title": "users.json",
86
85
  "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\users.json",
87
86
  "RelativeDocumentMoniker": "users.json",
@@ -89,31 +88,30 @@
89
88
  "RelativeToolTip": "users.json",
90
89
  "ViewState": "AQIAAAAAAAAAAAAAAAAAAAUAAAASAAAA",
91
90
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
92
- "WhenOpened": "2024-11-05T22:57:19.003Z",
93
- "EditorCaption": ""
91
+ "WhenOpened": "2024-11-05T22:57:19.003Z"
94
92
  },
95
93
  {
96
94
  "$type": "Document",
97
- "DocumentIndex": 3,
95
+ "DocumentIndex": 1,
98
96
  "Title": "hybridspa.ts",
99
97
  "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
100
98
  "RelativeDocumentMoniker": "hybridspa.ts",
101
99
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
102
100
  "RelativeToolTip": "hybridspa.ts",
103
- "ViewState": "AQIAAPgAAAAAAAAAAAAAAFECAAAXAAAA",
101
+ "ViewState": "AQIAACEAAAAAAAAAAAAtwDMAAABOAAAA",
104
102
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
105
103
  "WhenOpened": "2024-11-04T14:16:26.493Z",
106
104
  "EditorCaption": ""
107
105
  },
108
106
  {
109
107
  "$type": "Document",
110
- "DocumentIndex": 1,
108
+ "DocumentIndex": 0,
111
109
  "Title": "index.ts",
112
110
  "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
113
111
  "RelativeDocumentMoniker": "index.ts",
114
112
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
115
113
  "RelativeToolTip": "index.ts",
116
- "ViewState": "AQIAAFgBAAAAAAAAAAAuwHMBAAAAAAAA",
114
+ "ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
117
115
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
118
116
  "WhenOpened": "2024-05-12T20:20:11.888Z",
119
117
  "EditorCaption": ""
package/hybridspa.ts CHANGED
@@ -17,6 +17,18 @@ import {
17
17
  import { deserializeArray } from "class-transformer";
18
18
 
19
19
  // helper functions
20
+ function getAPIScope(user: User): string {
21
+ let apiAppID: string = "8d95d21c-c378-4bb0-9f52-88c30d271e7a";
22
+ let authority: string = user.authority.toLowerCase();
23
+ if (authority.startsWith("https://login.microsoftonline.com/"))
24
+ apiAppID = "8d95d21c-c378-4bb0-9f52-88c30d271e7a";
25
+ else if (authority.startsWith("https://login.microsoftonline.us/"))
26
+ apiAppID = "48da942e-ea3d-49e4-a054-81649012f8f2";
27
+ else if (authority.startsWith("https://login.partner.microsoftonline.cn/"))
28
+ apiAppID = "c91d32e4-dcc5-4d77-826a-16e93ffce666";
29
+ let apiScope: string = `api://${apiAppID}/Config.Write`;
30
+ return apiScope;
31
+ }
20
32
  // TODO: this is where you want to trigger a re-authentication if token expires
21
33
  async function mindlineDefineHeaders(
22
34
  instance: IPublicClientApplication,
@@ -27,6 +39,7 @@ async function mindlineDefineHeaders(
27
39
  headers.append("accept", "*/*");
28
40
  // authorization header - if needed, retrieve and cache access token
29
41
  if (user.mindlineAccessToken == null || user.mindlineAccessToken === "") {
42
+ const apiScope: string = getAPIScope(user);
30
43
  try {
31
44
  let accounts: AccountInfo[] = instance.getAllAccounts();
32
45
  let homeAccountId = user.oid + "." + user.tid;
@@ -37,7 +50,7 @@ async function mindlineDefineHeaders(
37
50
  }
38
51
  }
39
52
  let response: AuthenticationResult = await instance.acquireTokenSilent({
40
- scopes: ["api://8d95d21c-c378-4bb0-9f52-88c30d271e7a/Config.Write"],
53
+ scopes: [apiScope],
41
54
  account: account
42
55
  });
43
56
  user.mindlineAccessToken = response.accessToken; // cache access token
@@ -56,7 +69,7 @@ async function mindlineDefineHeaders(
56
69
  }
57
70
  }
58
71
  instance.acquireTokenRedirect({
59
- scopes: ["api://8d95d21c-c378-4bb0-9f52-88c30d271e7a/Config.Write"],
72
+ scopes: [apiScope],
60
73
  account: account
61
74
  });
62
75
  }
@@ -75,8 +88,9 @@ export async function processErrors(response: Response): Promise<string> {
75
88
  if (errorString != "") return errorString;
76
89
  }
77
90
  let data = await response.json();
91
+ // process errors from Mindline Config API
78
92
  if (data.error !== undefined) {
79
- errorString = `Error: ${data.error.code} Message: ${data.error.message}`;
93
+ errorString = `Error: ${data.error} Message: ${data.message}`;
80
94
  } else if (data.errors !== undefined) {
81
95
  let errorArray = Object.keys(data.errors);
82
96
  let errorlist: string = "";
package/index.ts CHANGED
@@ -1525,7 +1525,7 @@ export async function signIn(user: User, tasks: TaskArray): Promise<boolean> {
1525
1525
  return false;
1526
1526
  }
1527
1527
  }
1528
- // SignIn by an admin consents the app, Challenge adds incremental permissions dynamically, but requires a consented app - TEST THIS
1528
+ // SignIn by an admin consents the app, Challenge adds incremental permissions dynamically, but requires a consented app - TODO: TEST FRESH CONSENT EXPERIENCE
1529
1529
  let signinURL: string = window.location.href;
1530
1530
  switch (user.authority) {
1531
1531
  case graphConfig.authorityWW:
@@ -1543,11 +1543,17 @@ export async function signIn(user: User, tasks: TaskArray): Promise<boolean> {
1543
1543
  }
1544
1544
  let url: URL = new URL(signinURL);
1545
1545
  url.searchParams.append("redirectUri", window.location.origin);
1546
- url.searchParams.append("domainHint", "organizations");
1547
- // "1" is the OID that is set by default when reading the user objects from the JSON initialization file.
1548
- // This means this user has not been created by the admin. If it had been, oid and mail would be the same and not == "1".
1549
1546
  if (user.oid !== "1") {
1550
1547
  url.searchParams.append("loginHint", user.mail);
1548
+ const regex = /@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/;
1549
+ const regexMatch = user.mail.match(regex);
1550
+ let domain: string = regexMatch ? regexMatch[1] : "organizations";
1551
+ url.searchParams.append("domainHint", domain);
1552
+ }
1553
+ else {
1554
+ // "1" is the dummy OID set when initializing the application from JSON. No need to provide any specific hint.
1555
+ // This means that a user has not yet been specified by the admin. If it had been, oid would not be "1".
1556
+ url.searchParams.append("domainHint", "organizations");
1551
1557
  }
1552
1558
  tasks.setTaskStart("initialization", new Date());
1553
1559
  tasks.setTaskStart("authenticate user", new Date());
@@ -1555,6 +1561,7 @@ export async function signIn(user: User, tasks: TaskArray): Promise<boolean> {
1555
1561
  return true;
1556
1562
  }
1557
1563
  export function signInIncrementally(user: User, scope: string): void {
1564
+ debugger;
1558
1565
  if (user.oid == "1") return;
1559
1566
  // for dynamic delegated permissions, we can use the Microsoft Identity Web Account Controller Challenge method
1560
1567
  let challengeURL: string = window.location.href;
@@ -1653,7 +1660,8 @@ export async function tenantRelationshipsGetByDomain(loggedInUser: User, tenant:
1653
1660
  tenantEndpoint += "')";
1654
1661
  console.log("tenantRelationshipsGetByDomain: Attempting GET from /findTenantInformationByDomainName:", tenantEndpoint);
1655
1662
  let response = await fetch(tenantEndpoint, options);
1656
- if (response.status == 200 && response.statusText == "OK") {
1663
+ // status IS 200, but statusText no longer returns "OK" 1/26/2025
1664
+ if (response.status == 200) { // && response.statusText == "OK") {
1657
1665
  let data = await response.json();
1658
1666
  if (data) {
1659
1667
  if (data.error != null) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
3
  "type": "module",
4
- "version": "1.0.81",
4
+ "version": "1.0.83",
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.",