@mindline/sync 1.0.69 → 1.0.71

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": "\\index.d.ts",
6
5
  "PreviewInSolutionExplorer": false
7
6
  }
package/.vs/slnx.sqlite CHANGED
Binary file
Binary file
@@ -2,14 +2,14 @@
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\\index.d.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
7
- "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.d.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
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
  },
9
+ {
10
+ "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}",
11
+ "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.d.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
12
+ },
13
13
  {
14
14
  "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}",
15
15
  "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:hybridspa.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
@@ -60,7 +60,7 @@
60
60
  },
61
61
  {
62
62
  "DockedWidth": 200,
63
- "SelectedChildIndex": 2,
63
+ "SelectedChildIndex": 1,
64
64
  "Children": [
65
65
  {
66
66
  "$type": "Document",
@@ -70,32 +70,33 @@
70
70
  "RelativeDocumentMoniker": "hybridspa.ts",
71
71
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
72
72
  "RelativeToolTip": "hybridspa.ts",
73
- "ViewState": "AQIAAO8AAAAAAAAAAAAuwAUBAAAAAAAA",
73
+ "ViewState": "AQIAANwAAAAAAAAAAAAYwOgAAAAjAAAA",
74
74
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
75
- "WhenOpened": "2023-11-25T02:18:34.862Z"
75
+ "WhenOpened": "2023-11-25T02:18:34.862Z",
76
+ "EditorCaption": ""
76
77
  },
77
78
  {
78
79
  "$type": "Document",
79
- "DocumentIndex": 1,
80
+ "DocumentIndex": 0,
80
81
  "Title": "index.ts",
81
82
  "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
82
83
  "RelativeDocumentMoniker": "index.ts",
83
84
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
84
85
  "RelativeToolTip": "index.ts",
85
- "ViewState": "AQIAAEMEAAAAAAAAAAAjwGYEAAARAAAA",
86
+ "ViewState": "AQIAABMGAAAAAAAAAAAswCYGAAAFAAAA",
86
87
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
87
88
  "WhenOpened": "2023-12-05T02:10:16.04Z",
88
89
  "EditorCaption": ""
89
90
  },
90
91
  {
91
92
  "$type": "Document",
92
- "DocumentIndex": 0,
93
+ "DocumentIndex": 1,
93
94
  "Title": "index.d.ts",
94
95
  "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts",
95
96
  "RelativeDocumentMoniker": "index.d.ts",
96
97
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts",
97
98
  "RelativeToolTip": "index.d.ts",
98
- "ViewState": "AQIAANwAAAAAAAAAAAAAAO4AAAAZAAAA",
99
+ "ViewState": "AQIAAAUBAAAAAAAAAAAnwBYBAABBAAAA",
99
100
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
100
101
  "WhenOpened": "2024-01-01T16:19:43.325Z",
101
102
  "EditorCaption": ""
package/index.d.ts CHANGED
@@ -124,8 +124,8 @@ declare module "@mindline/sync" {
124
124
  usersWritten: number;
125
125
  configId: string;
126
126
  batchId: string;
127
- isReadPermissionConsented: string;
128
- isWritePermissionConsented: string;
127
+ isReadPermissionConsented: boolean;
128
+ isWritePermissionConsented: boolean;
129
129
  }
130
130
  export class Config {
131
131
  id: string;
@@ -276,7 +276,7 @@ declare module "@mindline/sync" {
276
276
  export function signInIncrementally(user: User, scope: string): void;
277
277
  export function signOut(user: User): boolean;
278
278
  export function tenantRelationshipsGetByDomain(loggedInuser: User, tenant: Tenant, instance: IPublicClientApplication, debug: boolean): boolean;
279
- export function tenantRelationshipsGetById(user: User, ii: InitInfo, instance: IPublicClientApplication, debug: boolean): boolean;
279
+ export function tenantRelationshipsGetById(loggedInUser: User, tenant: Tenant, ii: InitInfo, instance: IPublicClientApplication, debug: boolean): boolean;
280
280
  export function tenantUnauthenticatedLookup(tenant: Tenant, debug: boolean): boolean;
281
281
  export function userDelegatedScopesGet(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant): { scopes: string, id: string, error: string };
282
282
  export function userDelegatedScopesRemove(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant, scope: string): boolean;
package/index.ts CHANGED
@@ -222,8 +222,8 @@ export class TenantConfigInfo {
222
222
  usersWritten: number;
223
223
  configId: string;
224
224
  batchId: string;
225
- isReadPermissionConsented: string;
226
- isWritePermissionConsented: string;
225
+ isReadPermissionConsented: boolean;
226
+ isWritePermissionConsented: boolean;
227
227
  constructor() {
228
228
  this.tid = "";
229
229
  this.sourceGroupId = "";
@@ -235,8 +235,8 @@ export class TenantConfigInfo {
235
235
  this.usersWritten = 0;
236
236
  this.configId = "";
237
237
  this.batchId = "";
238
- this.isReadPermissionConsented = "";
239
- this.isWritePermissionConsented = "";
238
+ this.isReadPermissionConsented = false;
239
+ this.isWritePermissionConsented = false;
240
240
  }
241
241
  }
242
242
  export class Config {
@@ -1526,17 +1526,15 @@ export async function tenantRelationshipsGetByDomain(loggedInUser: User, tenant:
1526
1526
  return false; // failed, no need for UX to re-render
1527
1527
  }
1528
1528
  //tenantRelationshipsGetById - query AAD for associated company name and domain
1529
- export async function tenantRelationshipsGetById(user: User, ii: InitInfo, instance: IPublicClientApplication, debug: boolean): Promise<boolean> {
1529
+ export async function tenantRelationshipsGetById(loggedInUser: User, tenant: Tenant, ii: InitInfo, instance: IPublicClientApplication, debug: boolean): Promise<boolean> {
1530
1530
  console.log("**** tenantRelationshipsGetById");
1531
1531
  if (debug) debugger;
1532
- // since we should mainly be called when a user has newly logged in, we can afford the performance hit of looking up the tenant name and domain again
1533
- // if (user.companyName != "") return false;
1534
1532
  // if needed, retrieve and cache access token
1535
- if (user.accessToken === "") {
1533
+ if (loggedInUser.accessToken === "") {
1536
1534
  try {
1537
- let response: AuthenticationResult = await instance.acquireTokenByCode({ code: user.spacode });
1538
- user.accessToken = response.accessToken; // cache access token
1539
- console.log("tenantRelationshipsGetById: Front end token acquired: " + user.accessToken.slice(0, 20));
1535
+ let response: AuthenticationResult = await instance.acquireTokenByCode({ code: loggedInUser.spacode });
1536
+ loggedInUser.accessToken = response.accessToken; // cache access token
1537
+ console.log("tenantRelationshipsGetById: Front end token acquired: " + loggedInUser.accessToken.slice(0, 20));
1540
1538
  }
1541
1539
  catch (error: any) {
1542
1540
  console.log("tenantRelationshipsGetById: Front end token failure: " + error);
@@ -1545,25 +1543,21 @@ export async function tenantRelationshipsGetById(user: User, ii: InitInfo, insta
1545
1543
  }
1546
1544
  // prepare Authorization headers as part of options
1547
1545
  const headers = new Headers();
1548
- const bearer = `Bearer ${user.accessToken}`;
1546
+ const bearer = `Bearer ${loggedInUser.accessToken}`;
1549
1547
  headers.append("Authorization", bearer);
1550
1548
  let options = { method: "GET", headers: headers };
1551
1549
  // make tenant endpoint call
1552
1550
  try {
1553
1551
  // create tenant info endpoint
1554
- var tenantEndpoint = getGraphEndpoint(user.authority) + graphConfig.graphTenantByIdPredicate;
1552
+ var tenantEndpoint = getGraphEndpoint(loggedInUser.authority) + graphConfig.graphTenantByIdPredicate;
1555
1553
  tenantEndpoint += "(tenantId='";
1556
- tenantEndpoint += user.tid;
1554
+ tenantEndpoint += tenant.tid;
1557
1555
  tenantEndpoint += "')";
1558
1556
  console.log("tenantRelationshipsGetById: Attempting GET from /findTenantInformationByTenantId:", tenantEndpoint);
1559
1557
  let response = await fetch(tenantEndpoint, options);
1560
1558
  let data = await response.json();
1561
1559
  if (data && typeof data.displayName !== undefined && data.displayName !== "") {
1562
- // set domain information on user
1563
- user.companyName = data.displayName;
1564
- user.companyDomain = data.defaultDomainName;
1565
1560
  // set domain information on tenant
1566
- let tenant: Tenant | undefined = ii.ts.find((t) => t.tid === user.tid);
1567
1561
  if (tenant !== undefined) {
1568
1562
  tenant.name = data.displayName;
1569
1563
  tenant.domain = data.defaultDomainName;
@@ -1805,6 +1799,7 @@ export async function initGet(instance: IPublicClientApplication, authorizedUser
1805
1799
  if (debug) debugger;
1806
1800
  // lookup authority for this user (the lookup call does it based on domain, but TID works as well to find authority)
1807
1801
  let tenant: Tenant = new Tenant();
1802
+ tenant.tid = user.tid;
1808
1803
  tenant.domain = user.tid;
1809
1804
  let bResult: boolean = await tenantUnauthenticatedLookup(tenant, debug);
1810
1805
  if (bResult) {
@@ -1815,10 +1810,12 @@ export async function initGet(instance: IPublicClientApplication, authorizedUser
1815
1810
  if (loggedInUser != null) {
1816
1811
  // get tenant name and domain from AAD to pass to Configuration API
1817
1812
  tasks.setTaskStart("GET tenant details", new Date());
1818
- result.result = await tenantRelationshipsGetById(user, ii, instance, debug);
1813
+ result.result = await tenantRelationshipsGetById(user, tenant, ii, instance, debug);
1819
1814
  tasks.setTaskEnd("GET tenant details", new Date(), "complete");
1820
- // if this is the first time, we have just gotten tenant info, then we must POST user and tenant to back end
1815
+ // store tenant name and domain on user, POST user and tenant to back end
1821
1816
  if (result.result) {
1817
+ loggedInUser.companyName = tenant.name;
1818
+ loggedInUser.companyDomain = tenant.domain;
1822
1819
  tasks.setTaskStart("POST config init", new Date());
1823
1820
  result = await initPost(instance, authorizedUser, user, debug);
1824
1821
  tasks.setTaskEnd("POST config init", new Date(), result.result ? "complete" : "failed");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
3
  "type": "module",
4
- "version": "1.0.69",
4
+ "version": "1.0.71",
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.",