@mindline/sync 1.0.0 → 1.0.1
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/README.md +44 -10
- package/auditLogs.json +14 -0
- package/babel.config.json +3 -0
- package/index.js +123 -3
- package/index.test.js +16 -0
- package/package.json +25 -12
- package/provisioningLogs.json +20 -0
- package/syncConfigs.json +26 -0
- package/syncTenants.json +34 -0
- package/virtualTenants.json +16 -0
package/README.md
CHANGED
|
@@ -1,15 +1,49 @@
|
|
|
1
1
|
# Introduction
|
|
2
2
|
sync is a node.js package encapsulating javscript classes required for configuring Mindline sync service.
|
|
3
|
-
|
|
4
3
|
# Getting Started
|
|
5
4
|
TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
|
|
6
|
-
1. Installation process
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
# 1. Installation process
|
|
6
|
+
## install Node
|
|
7
|
+
https://nodejs.org/en/download
|
|
8
|
+
## Enable jest for ES6 to enable Jest operation on my codebase
|
|
9
|
+
See this article
|
|
10
|
+
https://stackoverflow.com/questions/59879689/jest-syntaxerror-cannot-use-import-statement-outside-a-module
|
|
11
|
+
### install babel-jest
|
|
12
|
+
### `npm install --save-dev babel-jest`
|
|
13
|
+
### modify package.json file to use babel-jest
|
|
14
|
+
``` js
|
|
15
|
+
"jest": {
|
|
16
|
+
"transform": {
|
|
17
|
+
"^.+\\.[t|j]sx?$": "babel-jest"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
```
|
|
21
|
+
### create .babelrc configuration file
|
|
22
|
+
Create a babel.config.json config in your project root and enable some presets.
|
|
23
|
+
To start, you can use the env preset, which enables transforms for ES2015+
|
|
24
|
+
``` js
|
|
25
|
+
npm install @babel/preset-env --save-dev
|
|
26
|
+
```
|
|
27
|
+
In order to enable the preset you have to define it in your babel.config.json file, like this:
|
|
28
|
+
``` js
|
|
29
|
+
{
|
|
30
|
+
"presets": ["@babel/preset-env"]
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
## install class transformer packages to convert JSON file imports into class objects
|
|
34
|
+
``` js
|
|
35
|
+
npm install class-transformer --save
|
|
36
|
+
npm install reflect-metadata --save
|
|
37
|
+
```
|
|
38
|
+
# 2. Latest releases
|
|
39
|
+
# 3. API references
|
|
40
|
+
# 4. Unit Test
|
|
41
|
+
### `npm test`
|
|
42
|
+
# 6. Publish
|
|
43
|
+
### `npm login`
|
|
44
|
+
username, password, OTP code required
|
|
45
|
+
### `npm publish --access=public --otp=XXXXXX`
|
|
46
|
+
### `npm publish --dry-run`
|
|
47
|
+
publishes package
|
|
48
|
+
# 7. Contribute
|
|
15
49
|
TODO: Explain how other users and developers can contribute to make your code better.
|
package/auditLogs.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
|
|
4
|
+
"Time Stamp": "07:25 PST 25 Feb 2023",
|
|
5
|
+
"Actor": "joe@customerx.com",
|
|
6
|
+
"Action": "sync config modified"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
|
|
10
|
+
"Time Stamp": "05:47 PST 25 Feb 2023",
|
|
11
|
+
"Actor": "admin@customerx.com",
|
|
12
|
+
"Action": "sync config created"
|
|
13
|
+
}
|
|
14
|
+
]
|
package/index.js
CHANGED
|
@@ -1,7 +1,127 @@
|
|
|
1
1
|
//index.js
|
|
2
2
|
|
|
3
|
+
// called by unit test
|
|
4
|
+
function sum(a, b) {
|
|
5
|
+
return a + b;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// called by simpleclass test app
|
|
3
9
|
function helloNpm() {
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
return "hello NPM";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
import { deserializeArray } from 'class-transformer';
|
|
14
|
+
import virtualTenants from "./virtualTenants.json";
|
|
15
|
+
import syncTenants from "./syncTenants.json";
|
|
16
|
+
import syncConfigs from "./syncConfigs.json";
|
|
17
|
+
import auditLogs from "./auditLogs.json";
|
|
18
|
+
import provisioningLogs from "./provisioningLogs.json";
|
|
19
|
+
|
|
20
|
+
class User{
|
|
21
|
+
authority; // from AAD
|
|
22
|
+
oid; // from AAD
|
|
23
|
+
tid; // from AAD
|
|
24
|
+
upn; // from AAD
|
|
25
|
+
name; // from AAD
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// shared base class of virtual and sync tenants
|
|
29
|
+
class Tenant{
|
|
30
|
+
authority; // from AAD
|
|
31
|
+
tid; // from AAD
|
|
32
|
+
name; // from AAD: tenant display name
|
|
33
|
+
domain; // from AAD: tenant default domain
|
|
6
34
|
|
|
7
|
-
|
|
35
|
+
validate() {} // populate tenantId,tenantName based on tenantDomain
|
|
36
|
+
|
|
37
|
+
// TODO: can we just reference response object
|
|
38
|
+
SignIn() {} // sign in and set signinToken
|
|
39
|
+
SignOut() {} // sign out and clear signinToken
|
|
40
|
+
SignInToken() {} // session access
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// class for "hub" tenants
|
|
44
|
+
class VirtualTenant extends Tenant{
|
|
45
|
+
description; // from DB
|
|
46
|
+
|
|
47
|
+
// save or remove this tenant from our DB
|
|
48
|
+
Save() {}
|
|
49
|
+
Remove() {}
|
|
50
|
+
|
|
51
|
+
// admin console reads all tenants configured in AAD OR present in our database that connect to this virtual tenant
|
|
52
|
+
ReadSyncTenants() {}
|
|
53
|
+
|
|
54
|
+
// admin console can add sync tenants in sovereign clouds that are NOT configured in AAD to sync to/from this virtual tenant
|
|
55
|
+
AddSyncTenant() {}
|
|
56
|
+
RemoveSyncTenant() {}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// class for "spoke" tenants
|
|
60
|
+
class SyncTenant extends Tenant{
|
|
61
|
+
tenantType; // from DB: AAD | AD | Google -- always AAD for now
|
|
62
|
+
readServicePrincipal; // from AAD
|
|
63
|
+
writeServicePrincipal; // from AAD
|
|
64
|
+
virtualTenantID;
|
|
65
|
+
|
|
66
|
+
// start/stop tracking this tenant
|
|
67
|
+
Save() {}
|
|
68
|
+
Remove() {}
|
|
69
|
+
|
|
70
|
+
// service principal creation in AAD
|
|
71
|
+
CreateReadSP() {}
|
|
72
|
+
CreateWriteSP() {}
|
|
73
|
+
|
|
74
|
+
// service principal removal from AAD
|
|
75
|
+
RemoveReadSP() {}
|
|
76
|
+
RemoveWriteSP() {}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// class for sync configuration
|
|
80
|
+
class SyncConfig {
|
|
81
|
+
enabled; // from DB
|
|
82
|
+
virtualTenantID;
|
|
83
|
+
deltaLink;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// called by unit test
|
|
87
|
+
function readobjects() {
|
|
88
|
+
// convert read JSON to VirtualTenant array
|
|
89
|
+
debugger;
|
|
90
|
+
let virtuals = null;
|
|
91
|
+
var virtualTenantsString = JSON.stringify(virtualTenants);
|
|
92
|
+
try {
|
|
93
|
+
virtuals = deserializeArray(VirtualTenant, virtualTenantsString);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
debugger;
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
// make some assertion about the data we just read
|
|
99
|
+
return virtuals.length;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// retrievesync configurations based on passed user information
|
|
103
|
+
function readConfigs(user, virtuals, syncs, configs)
|
|
104
|
+
{
|
|
105
|
+
debugger;
|
|
106
|
+
// for now, just get hardcoded data from JSON
|
|
107
|
+
var virtualTenantsString = JSON.stringify(virtualTenants);
|
|
108
|
+
var syncTenantsString = JSON.stringify(syncTenants);
|
|
109
|
+
var syncConfigsString = JSON.stringify(syncConfigs);
|
|
110
|
+
try {
|
|
111
|
+
virtuals = deserializeArray(VirtualTenant, virtualTenantsString);
|
|
112
|
+
syncs = deserializeArray(SyncTenant, syncTenantsString);
|
|
113
|
+
configs = deserializeArray(SyncConfig, syncConfigsString);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
debugger;
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = {
|
|
122
|
+
sum,
|
|
123
|
+
helloNpm,
|
|
124
|
+
readobjects,
|
|
125
|
+
User, VirtualTenant, SyncTenant, SyncConfig,
|
|
126
|
+
readConfigs
|
|
127
|
+
};
|
package/index.test.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {sum, readobjects, readConfigs, User, VirtualTenant, SyncTenant, SyncConfig} from "./index.js";
|
|
2
|
+
|
|
3
|
+
test("adds 1 + 2 to equal 3", () => {
|
|
4
|
+
expect(sum(1, 2)).toBe(3);
|
|
5
|
+
});
|
|
6
|
+
test("loads array of VirtualTenants from JSON and expects 2", () => {
|
|
7
|
+
expect(readobjects()).toBe(2);
|
|
8
|
+
});
|
|
9
|
+
test("loads config based on a user and expects function to return true", () => {
|
|
10
|
+
debugger;
|
|
11
|
+
let u = new User;
|
|
12
|
+
let vts = new Array();
|
|
13
|
+
let sts = new Array();
|
|
14
|
+
let scs = new Array();
|
|
15
|
+
expect(readConfigs(u, vts, sts, scs)).toBe(true);
|
|
16
|
+
});
|
package/package.json
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mindline/sync",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "sync is a node.js package encapsulating javscript classes required for configuring Mindline sync service.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "
|
|
8
|
-
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@mindline/sync",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "sync is a node.js package encapsulating javscript classes required for configuring Mindline sync service.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest"
|
|
8
|
+
},
|
|
9
|
+
"jest": {
|
|
10
|
+
"transform": {
|
|
11
|
+
"^.+\\.[t|j]sx?$": "babel-jest"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@babel/preset-env": "^7.20.2",
|
|
19
|
+
"jest": "^29.5.0"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"class-transformer": "^0.5.1",
|
|
23
|
+
"reflect-metadata": "^0.1.13"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
|
|
4
|
+
"Time Stamp": "07:25 PST 25 Feb 2023",
|
|
5
|
+
"Actor": "ProdSync",
|
|
6
|
+
"Action": "user 'user1' created",
|
|
7
|
+
"Source": "Subsidiary Y",
|
|
8
|
+
"Target": "Customer X",
|
|
9
|
+
"Status": "Success"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
|
|
13
|
+
"Time Stamp": "07:25 PST 25 Feb 2023",
|
|
14
|
+
"Actor": "ProdSync",
|
|
15
|
+
"Action": "user 'user2' created",
|
|
16
|
+
"Source": "Subsidiary Y",
|
|
17
|
+
"Target": "Customer X",
|
|
18
|
+
"Status": "Success"
|
|
19
|
+
}
|
|
20
|
+
]
|
package/syncConfigs.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
|
|
4
|
+
"name": "ProdSync",
|
|
5
|
+
"tenantCount": "2",
|
|
6
|
+
"description": "Production Mindline Sync Configuration."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
|
|
10
|
+
"name": "TestSync",
|
|
11
|
+
"tenantCount": "2",
|
|
12
|
+
"description": "Test Mindline Sync Configuration."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
|
|
16
|
+
"name": "ProdSync",
|
|
17
|
+
"tenantCount": "2",
|
|
18
|
+
"description": "Automated sync of users from Subsidiary Y to Customer X."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
|
|
22
|
+
"name": "TestSync",
|
|
23
|
+
"tenantCount": "2",
|
|
24
|
+
"description": "Test automated sync of users from Subsidiary Y to Customer X."
|
|
25
|
+
}
|
|
26
|
+
]
|
package/syncTenants.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
|
|
4
|
+
"name": "Mindline1",
|
|
5
|
+
"direction": "Outbound",
|
|
6
|
+
"readServicePrincipal": "1234",
|
|
7
|
+
"writeServicePrincipal": "N/A",
|
|
8
|
+
"session": "Off"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
|
|
12
|
+
"name": "Mindline2",
|
|
13
|
+
"direction": "Inbound",
|
|
14
|
+
"readServicePrincipal": "9101",
|
|
15
|
+
"writeServicePrincipal": "1121",
|
|
16
|
+
"session": "Off"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
|
|
20
|
+
"name": "Customer X",
|
|
21
|
+
"direction": "Inbound",
|
|
22
|
+
"readServicePrincipal": "1234",
|
|
23
|
+
"writeServicePrincipal": "5678",
|
|
24
|
+
"session": "Off"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
|
|
28
|
+
"name": "Subisidiary Y",
|
|
29
|
+
"direction": "Outbound",
|
|
30
|
+
"readServicePrincipal": "9101",
|
|
31
|
+
"writeServicePrincipal": "N/A",
|
|
32
|
+
"session": "Off"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"tenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
|
|
4
|
+
"name": "Mindline",
|
|
5
|
+
"domain": "bellevuearvindhotmail.onmicrosoft.com",
|
|
6
|
+
"description": "Mindline virtual tenant.",
|
|
7
|
+
"session": "Off"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"tenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
|
|
11
|
+
"name": "virttenant",
|
|
12
|
+
"domain": "virttenant.onmicrosoft.com",
|
|
13
|
+
"description": "Prod virtual tenant for CustomerX.",
|
|
14
|
+
"session": "Off"
|
|
15
|
+
}
|
|
16
|
+
]
|