comprodls-sdk 2.123.2-security → 2.123.4-oidc-poc.2

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.
Files changed (36) hide show
  1. package/.eslintrc +28 -28
  2. package/.github/workflows/npm-publish.yml +76 -0
  3. package/README.md +235 -235
  4. package/dist/comprodls-sdk.js +13543 -13543
  5. package/docs/npm-oidc-publishing-runbook.md +229 -0
  6. package/lib/comprodls.js +132 -132
  7. package/lib/config/index.js +356 -356
  8. package/lib/helpers/index.js +31 -31
  9. package/lib/helpers/lib/api/converter.js +129 -129
  10. package/lib/helpers/lib/api/index.js +46 -46
  11. package/lib/helpers/lib/errors.js +122 -122
  12. package/lib/helpers/lib/requestLayer.js +154 -154
  13. package/lib/helpers/lib/validator.js +192 -192
  14. package/lib/open_access/index.js +116 -116
  15. package/lib/services/analytics/index.js +1365 -1365
  16. package/lib/services/attempts/index.js +389 -389
  17. package/lib/services/auth/index.js +3708 -3708
  18. package/lib/services/authextn/index.js +1032 -1032
  19. package/lib/services/datasyncmanager/index.js +275 -275
  20. package/lib/services/drive/index.js +270 -270
  21. package/lib/services/integrations/index.js +525 -525
  22. package/lib/services/invitations/index.js +282 -282
  23. package/lib/services/product/index.js +343 -343
  24. package/lib/services/pub/index.js +530 -530
  25. package/lib/services/pushX/index.js +251 -251
  26. package/lib/services/pushX/pubnubClientWrapper.js +438 -438
  27. package/lib/services/rules/index.js +416 -416
  28. package/lib/services/spaces/index.js +999 -999
  29. package/lib/services/spacesextn/index.js +131 -131
  30. package/lib/services/superuser/index.js +160 -160
  31. package/lib/services/taxonomy/index.js +405 -405
  32. package/lib/services/workflows/index.js +406 -406
  33. package/lib/services/xapi/index.js +114 -114
  34. package/lib/token/index.js +120 -120
  35. package/lib/token/validations.js +85 -85
  36. package/package.json +5 -1
@@ -0,0 +1,229 @@
1
+ # Runbook: Publishing `comprodls-sdk` to npm with OIDC (Trusted Publishing) via GitHub Actions
2
+
3
+ This runbook replaces the npm granular tokens that bypass 2FA with npm **Trusted Publishing (OIDC)** from GitHub Actions. Every release is published directly with `npm publish`; no staging or extra approval is needed on npmjs.com. You can still release different npm dist-tags for different environments; `latest` is the production tag.
4
+
5
+ - GitHub organization: `comprodls`
6
+ - Repository: `comprodls-sdk-js` (<https://github.com/comprodls/comprodls-sdk-js>)
7
+ - npm package: `comprodls-sdk`
8
+
9
+ ## Things in this setup that affect the move to OIDC
10
+
11
+ - **Missing `repository` field:** [package.json](../package.json) has none. npm requires `repository.url` to match the GitHub repo exactly, or OIDC publishing fails.
12
+ - **Private repo:** the repo is private, so npm won't create provenance attestations (signed records of where the package was built). This needs no action, but on private repos GitHub environments need the Team plan, and required reviewers need Enterprise (see Phase 4).
13
+ - **npm version:** OIDC needs npm **11.5.1 or later**, which needs Node **22.14.0 or later**. The workflow uses Node 22 and upgrades npm before publishing.
14
+ - **Publish command stays the same:** [grunt/publish.js](../grunt/publish.js) already runs `npm publish --tag <tag>`, which works with OIDC as-is. The version goes live as soon as the job finishes.
15
+ - **Git push URL:** `publish.js` pushes using `https://<token>@github.com/...`. With the `GITHUB_TOKEN` that Actions provides, the URL should be `https://x-access-token:<token>@...`. That form also works with a personal access token.
16
+ - **Env branches:** releases are made from branches like `master`, `env-qa`, `env-thor` and `env-valky`. A manually run workflow uses the workflow file from the branch you pick, so all release changes must exist on every release branch.
17
+ - **Grunt runs on new Node:** the Grunt 0.4.5 build has been tested on Node 22 using `npx grunt-cli`.
18
+ - **Current npm dist-tags:** `latest`, `qa`, `thor`, `valky`.
19
+
20
+ ---
21
+
22
+ ## Phase 1 — How each tag is published
23
+
24
+ | npm tag | Command | Allowed from | When it goes live |
25
+ |---|---|---|---|
26
+ | `latest` (production) | `npm publish --tag latest` | `master` only, no prerelease versions | As soon as the job finishes |
27
+ | `qa`, `thor`, `valky`, … | `npm publish --tag <tag>` | Any release branch | As soon as the job finishes |
28
+
29
+ Because there's no staging step, the safeguards for `latest` are the **Validate inputs** step in the workflow and, if your GitHub plan supports it, required reviewers on the `npm-production` environment (Phase 4).
30
+
31
+ ---
32
+
33
+ ## Phase 2 — Code changes (commit to `master` and every env branch)
34
+
35
+ ### 2a. `package.json` — add a `repository` field
36
+
37
+ The URL is case-sensitive.
38
+
39
+ ```json
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/comprodls/comprodls-sdk-js.git"
43
+ },
44
+ ```
45
+
46
+ ### 2b. `grunt/publish.js` — fix the git push URL
47
+
48
+ Replace the token and URL lines at the top of the task:
49
+
50
+ ```js
51
+ // Fail early if the token is missing, and use a URL that works with GITHUB_TOKEN and personal tokens
52
+ var token = process.env[options.github_access_token];
53
+ if (!token) {
54
+ grunt.fatal(options.github_access_token + " environment variable is not set");
55
+ }
56
+ var url = "https://x-access-token:" + token + "@github.com/comprodls/comprodls-sdk-js.git";
57
+ ```
58
+
59
+ `publishToNPM()` doesn't need to change.
60
+
61
+ ### 2c. Create `.github/workflows/npm-publish.yml`
62
+
63
+ ```yaml
64
+ name: Publish SDK to npm
65
+
66
+ on:
67
+ workflow_dispatch:
68
+ inputs:
69
+ version:
70
+ description: "Version without 'v' (e.g. 2.127.0 or 2.127.0-qa.1)"
71
+ required: true
72
+ type: string
73
+ npm_tag:
74
+ description: "npm dist-tag ('latest' = production)"
75
+ required: false
76
+ default: latest
77
+ type: choice
78
+ options: [qa, thor, valky, test, latest] # adjust to your envs
79
+
80
+ permissions:
81
+ contents: write # push the release commit and git tag
82
+ id-token: write # required for npm OIDC
83
+
84
+ concurrency:
85
+ group: npm-publish
86
+ cancel-in-progress: false
87
+
88
+ jobs:
89
+ publish:
90
+ runs-on: ubuntu-latest # must be GitHub-hosted; self-hosted runners aren't supported
91
+ environment: ${{ inputs.npm_tag == 'latest' && 'npm-production' || 'npm-non-production' }}
92
+ env:
93
+ VERSION: ${{ inputs.version }}
94
+ NPM_TAG: ${{ inputs.npm_tag }}
95
+ steps:
96
+ - name: Validate inputs
97
+ run: |
98
+ if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
99
+ echo "::error::Invalid semver: $VERSION"; exit 1; fi
100
+ if [[ "$NPM_TAG" == "latest" && "$VERSION" == *-* ]]; then
101
+ echo "::error::Prerelease versions cannot go to 'latest'"; exit 1; fi
102
+ if [[ "$NPM_TAG" == "latest" && "$GITHUB_REF_NAME" != "master" ]]; then
103
+ echo "::error::'latest' must be released from master"; exit 1; fi
104
+
105
+ - uses: actions/checkout@v6
106
+ with:
107
+ fetch-depth: 0
108
+
109
+ - uses: actions/setup-node@v6
110
+ with:
111
+ node-version: "22"
112
+ registry-url: "https://registry.npmjs.org"
113
+ package-manager-cache: false
114
+
115
+ - name: Upgrade npm (OIDC needs 11.5.1 or later)
116
+ run: npm install -g npm@latest && npm --version
117
+
118
+ - name: Install dependencies
119
+ run: npm install --no-package-lock --no-audit --no-fund # keeps the release commit free of a lockfile
120
+
121
+ - name: Configure git identity
122
+ run: |
123
+ git config user.name "github-actions[bot]"
124
+ git config user.email "41898828+github-actions[bot]@users.noreply.github.com"
125
+
126
+ - name: Build, commit, tag, push, publish
127
+ env:
128
+ GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129
+ NPM_CONFIG_PROVENANCE: "false" # private repo: provenance isn't supported
130
+ run: |
131
+ npx --yes grunt-cli@1.5.0 "release:$VERSION" \
132
+ --TAG="$NPM_TAG" \
133
+ --SDK_RELEASE_BRANCH="$GITHUB_REF_NAME"
134
+ ```
135
+
136
+ Notes:
137
+
138
+ - No npm token is set anywhere. npm detects the GitHub OIDC token and exchanges it automatically.
139
+ - `npm_tag` defaults to `latest`, so check the tag before you click **Run workflow** on an env branch. If you forget, the **Validate inputs** step stops `latest` releases that don't come from `master` or that use a prerelease version.
140
+ - `node-version: "22"` installs the newest Node 22.x, which meets the 22.14.0 minimum.
141
+ - **Configure git identity** sets the author name and email for the release commit and git tag that Grunt creates. A fresh runner has no git identity, so `git commit` would fail without it. The values are GitHub's standard bot identity (`41898828` is the bot's user ID), so commits show up as made by `github-actions[bot]`.
142
+ - Commit this file to `master` first, because the **Run workflow** button only appears once the file is on the default branch. Then merge it into each env branch.
143
+
144
+ ---
145
+
146
+ ## Phase 3 — Set up the trusted publisher on npmjs.com
147
+
148
+ 1. Sign in as an owner of `comprodls-sdk`, then go to **Packages → comprodls-sdk → Settings → Trusted publishing**.
149
+ 2. Select **GitHub Actions** and fill in:
150
+ - **Organization or user:** `comprodls`
151
+ - **Repository:** `comprodls-sdk-js`
152
+ - **Workflow filename:** `npm-publish.yml` (filename only, not the path)
153
+ - **Environment name:** leave blank, because two GitHub environments share this one config.
154
+ - **Allowed actions:** tick **Allow npm publish**. This is required, because every release is published directly. Optionally tick **Allow npm dist-tag** if you want to fix tags from CI later.
155
+ 3. Save. npm doesn't check these values when you save, so re-read them for typos.
156
+ 4. ⚠️ The config expires if it isn't used for a successful publish within **2 days**. Do Phase 5 straight away.
157
+
158
+ ---
159
+
160
+ ## Phase 4 — GitHub repo settings
161
+
162
+ 1. **Environments:** open the repo on GitHub, click the **Settings** tab (you need admin access), then click **Environments** in the left sidebar under *Code and automation*. Direct link: <https://github.com/comprodls/comprodls-sdk-js/settings/environments>. Click **New environment** to create each one:
163
+ - `npm-production`: add **Required reviewers**, and under **Deployment branches and tags** choose *Selected branches and tags* and add `master`.
164
+ - `npm-non-production`: no restrictions, or limit it to your `env-*` branches.
165
+ - On a private repo, what you can set up depends on the org's GitHub plan:
166
+ - **Free:** the **Environments** page doesn't appear. Delete the `environment:` line from the workflow; the **Validate inputs** step is then your only production check.
167
+ - **Team:** you can create environments and limit their deployment branches, but you can't add required reviewers.
168
+ - **Enterprise:** everything above is available.
169
+ - If you skip this step, the first workflow run creates both environments automatically, but with no rules.
170
+ 2. **Actions permissions** (Settings → Actions → General): make sure your org policy doesn't stop workflows from getting `contents: write`.
171
+ 3. **Branch protection or rulesets:** if `master` or the env branches block direct pushes, the release commit push will fail. Either allow the Actions bot to bypass the rule, or use a GitHub App token as `GITHUB_ACCESS_TOKEN`.
172
+
173
+ ---
174
+
175
+ ## Phase 5 — First test release (non-production)
176
+
177
+ 1. Go to **Actions → Publish SDK to npm → Run workflow**.
178
+ - Branch: an env branch such as `env-qa`.
179
+ - Version: a throwaway version, e.g. `2.126.6-test`.
180
+ - Tag: `test` or `qa`. Change it from the default `latest`.
181
+ 2. You can also start it from the command line:
182
+
183
+ ```sh
184
+ gh workflow run npm-publish.yml --ref env-qa -f version=2.126.6-test -f npm_tag=qa
185
+ ```
186
+
187
+ 3. Check that it worked by running `npm view comprodls-sdk dist-tags`. The git tag `v2.126.6-test` and the release commit should also be on the branch.
188
+
189
+ ---
190
+
191
+ ## Phase 6 — Production release (`latest`)
192
+
193
+ 1. Run the workflow with branch `master`, a version like `2.127.0` and tag `latest`.
194
+ 2. If you set up required reviewers, approve the `npm-production` deployment in GitHub.
195
+ 3. The job publishes the version straight to npm.
196
+ 4. Confirm with `npm view comprodls-sdk dist-tags`; `latest` should now be `2.127.0`.
197
+
198
+ ---
199
+
200
+ ## Phase 7 — Lock down
201
+
202
+ Only do this after Phases 5 and 6 succeed.
203
+
204
+ 1. In npm package **Settings → Publishing access**, select **Require two-factor authentication and disallow tokens**. OIDC publishing keeps working.
205
+ 2. Revoke the old granular tokens that bypass 2FA.
206
+ 3. Delete any `GITHUB_ACCESS_TOKEN` or `NPM_TOKEN` secrets you no longer need.
207
+
208
+ ---
209
+
210
+ ## Troubleshooting
211
+
212
+ | Symptom | Cause / fix |
213
+ |---|---|
214
+ | `ENEEDAUTH` / "Unable to authenticate" | The workflow filename, org or repo doesn't match the npm config (all case-sensitive), `id-token: write` is missing, npm is older than 11.5.1, or the runner is self-hosted |
215
+ | `E422` / repository mismatch | `repository.url` in `package.json` is missing or wrong on that branch |
216
+ | `E403` on `npm publish` | **Allow npm publish** isn't ticked in the trusted publisher config (Phase 3) |
217
+ | Git push 403 / rejected | Branch protection is blocking the push (Phase 4, step 3) |
218
+ | Rerun fails with "already present" | The git tag was pushed before npm failed. Use the next version, or delete the tag first: `git push origin :refs/tags/vX.Y.Z` |
219
+ | Wrong version went to `latest` | npm doesn't let you republish a version. Point `latest` back with `npm dist-tag add comprodls-sdk@<good-version> latest` (locally with 2FA, or from CI if **Allow npm dist-tag** is ticked, npm 11.21.0 or later), then release a fixed version |
220
+
221
+ Local releases still work: the `x-access-token` URL accepts a personal access token, and `npm publish` works after `npm login`. After Phase 7 you'll be asked for a 2FA code when publishing locally.
222
+
223
+ ---
224
+
225
+ ## References
226
+
227
+ - [npm: Trusted publishing for npm packages](https://docs.npmjs.com/trusted-publishers)
228
+ - [GitHub: About security hardening with OpenID Connect](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
229
+ - [GitHub: Using environments for deployment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment)
package/lib/comprodls.js CHANGED
@@ -1,132 +1,132 @@
1
- /*************************************************************************
2
- *
3
- * COMPRO CONFIDENTIAL
4
- * __________________
5
- *
6
- * [2015] - [2020] Compro Technologies Private Limited
7
- * All Rights Reserved.
8
- *
9
- * NOTICE: All information contained herein is, and remains
10
- * the property of Compro Technologies Private Limited. The
11
- * intellectual and technical concepts contained herein are
12
- * proprietary to Compro Technologies Private Limited and may
13
- * be covered by U.S. and Foreign Patents, patents in process,
14
- * and are protected by trade secret or copyright law.
15
- *
16
- * Dissemination of this information or reproduction of this material
17
- * is strictly forbidden unless prior written permission is obtained
18
- * from Compro Technologies Pvt. Ltd..
19
- ***************************************************************************/
20
-
21
- /***********************************************************
22
- * comproDLS SDK Main Module
23
- * This module provides definition of SDK for Javascript
24
- ************************************************************/
25
- var token_manager = require('./token');
26
- var auth = require('./services/auth');
27
- var authextn = require('./services/authextn');
28
- var analytics = require('./services/analytics');
29
- var product = require('./services/product');
30
- var xapi = require('./services/xapi');
31
- var attempts = require('./services/attempts');
32
- var pushX = require('./services/pushX');
33
- var pub = require('./services/pub');
34
- var spaces = require('./services/spaces');
35
- var spacesextn = require('./services/spacesextn');
36
- var config = require('./config');
37
- var open_access = require('./open_access');
38
- var superuser = require('./services/superuser');
39
- var invitations = require('./services/invitations');
40
- var workflows = require('./services/workflows');
41
- var integrations = require('./services/integrations');
42
- var validations = require('./token/validations');
43
- var drive = require('./services/drive');
44
- var taxonomy = require('./services/taxonomy');
45
- var rules = require('./services/rules');
46
- var datasyncmanager = require('./services/datasyncmanager');
47
-
48
- exports.init = init;
49
-
50
- //Factory function to create and return a new SDK object/instance
51
- function init(environment, realm, options) {
52
- return new comproDLS(environment, realm, options);
53
- };
54
-
55
- // Constructor for the SDK object
56
- function comproDLS(environment, realm, options) {
57
- options = options || {};
58
- environment = environment || 'production';
59
- realm = realm || 'global';
60
- /*
61
- * Instance level parameters, used across all API calls. These are set to null.
62
- * Either authWithToken or authWithCredentials must be called to set these
63
- * with valid values.
64
- *
65
- * API Token is a JSON Object with following structure: {access_token : 'string'}
66
- */
67
- this.token = null;
68
- this.orgId = null;
69
- this.traceid = options.traceid;
70
-
71
- try {
72
- config.DEFAULT_HOSTS = config.REALM_HOSTS[realm.toUpperCase()][environment.toUpperCase()];
73
- if(!config.DEFAULT_HOSTS){ throw 'Invalid Environment'; }
74
- }
75
- catch (e) {
76
- var realmObj = config.REALM_HOSTS[realm.toUpperCase()];
77
- var err;
78
-
79
- if(!realmObj) { err = new Error('Invalid Realm: ' + realm); }
80
- else if(!realmObj[environment.toUpperCase()]) {
81
- err = new Error('Invalid Environment: ' + environment);
82
- }
83
- throw err;
84
- }
85
-
86
- this.config = config;
87
- this.environment = environment;
88
-
89
- if(options.orgid && options.token) {
90
- var err = validations.authWithToken(options.orgid, options.token, {});
91
- if (err) { throw err; }
92
- else {
93
- this.token = options.token;
94
- this.orgId = options.orgid;
95
- }
96
- }
97
- // This is the case when api requires orgid but not token
98
- else if(options.orgid) {
99
- this.orgId = options.orgid;
100
- }
101
- }
102
-
103
- /****************************************
104
- * Setting Up SDK Public Functions/Objects
105
- *****************************************/
106
- //Token Management
107
- comproDLS.prototype.authWithToken = token_manager.authWithToken;
108
- comproDLS.prototype.authWithExtUser = token_manager.authWithExtUser;
109
-
110
- //Open Access SDK Functions
111
- comproDLS.prototype.getClassEnrolmentsStat = open_access.getClassEnrolmentsStat;
112
- comproDLS.prototype.getSingleInvitation = open_access.getSingleInvitation;
113
-
114
- //Custom Service Adaptors
115
- comproDLS.prototype.Auth = auth;
116
- comproDLS.prototype.AuthExtn = authextn;
117
- comproDLS.prototype.Analytics = analytics;
118
- comproDLS.prototype.Product = product;
119
- comproDLS.prototype.Xapi = xapi;
120
- comproDLS.prototype.Attempts = attempts;
121
- comproDLS.prototype.Pub = pub;
122
- comproDLS.prototype.PushX = pushX;
123
- comproDLS.prototype.Spaces = spaces;
124
- comproDLS.prototype.SpacesExtn = spacesextn;
125
- comproDLS.prototype.Superuser = superuser;
126
- comproDLS.prototype.Invitations = invitations;
127
- comproDLS.prototype.Workflows = workflows;
128
- comproDLS.prototype.Integrations = integrations;
129
- comproDLS.prototype.Drive = drive;
130
- comproDLS.prototype.Taxonomy = taxonomy;
131
- comproDLS.prototype.Rules = rules;
132
- comproDLS.prototype.Datasyncmanager = datasyncmanager;
1
+ /*************************************************************************
2
+ *
3
+ * COMPRO CONFIDENTIAL
4
+ * __________________
5
+ *
6
+ * [2015] - [2020] Compro Technologies Private Limited
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Compro Technologies Private Limited. The
11
+ * intellectual and technical concepts contained herein are
12
+ * proprietary to Compro Technologies Private Limited and may
13
+ * be covered by U.S. and Foreign Patents, patents in process,
14
+ * and are protected by trade secret or copyright law.
15
+ *
16
+ * Dissemination of this information or reproduction of this material
17
+ * is strictly forbidden unless prior written permission is obtained
18
+ * from Compro Technologies Pvt. Ltd..
19
+ ***************************************************************************/
20
+
21
+ /***********************************************************
22
+ * comproDLS SDK Main Module
23
+ * This module provides definition of SDK for Javascript
24
+ ************************************************************/
25
+ var token_manager = require('./token');
26
+ var auth = require('./services/auth');
27
+ var authextn = require('./services/authextn');
28
+ var analytics = require('./services/analytics');
29
+ var product = require('./services/product');
30
+ var xapi = require('./services/xapi');
31
+ var attempts = require('./services/attempts');
32
+ var pushX = require('./services/pushX');
33
+ var pub = require('./services/pub');
34
+ var spaces = require('./services/spaces');
35
+ var spacesextn = require('./services/spacesextn');
36
+ var config = require('./config');
37
+ var open_access = require('./open_access');
38
+ var superuser = require('./services/superuser');
39
+ var invitations = require('./services/invitations');
40
+ var workflows = require('./services/workflows');
41
+ var integrations = require('./services/integrations');
42
+ var validations = require('./token/validations');
43
+ var drive = require('./services/drive');
44
+ var taxonomy = require('./services/taxonomy');
45
+ var rules = require('./services/rules');
46
+ var datasyncmanager = require('./services/datasyncmanager');
47
+
48
+ exports.init = init;
49
+
50
+ //Factory function to create and return a new SDK object/instance
51
+ function init(environment, realm, options) {
52
+ return new comproDLS(environment, realm, options);
53
+ };
54
+
55
+ // Constructor for the SDK object
56
+ function comproDLS(environment, realm, options) {
57
+ options = options || {};
58
+ environment = environment || 'production';
59
+ realm = realm || 'global';
60
+ /*
61
+ * Instance level parameters, used across all API calls. These are set to null.
62
+ * Either authWithToken or authWithCredentials must be called to set these
63
+ * with valid values.
64
+ *
65
+ * API Token is a JSON Object with following structure: {access_token : 'string'}
66
+ */
67
+ this.token = null;
68
+ this.orgId = null;
69
+ this.traceid = options.traceid;
70
+
71
+ try {
72
+ config.DEFAULT_HOSTS = config.REALM_HOSTS[realm.toUpperCase()][environment.toUpperCase()];
73
+ if(!config.DEFAULT_HOSTS){ throw 'Invalid Environment'; }
74
+ }
75
+ catch (e) {
76
+ var realmObj = config.REALM_HOSTS[realm.toUpperCase()];
77
+ var err;
78
+
79
+ if(!realmObj) { err = new Error('Invalid Realm: ' + realm); }
80
+ else if(!realmObj[environment.toUpperCase()]) {
81
+ err = new Error('Invalid Environment: ' + environment);
82
+ }
83
+ throw err;
84
+ }
85
+
86
+ this.config = config;
87
+ this.environment = environment;
88
+
89
+ if(options.orgid && options.token) {
90
+ var err = validations.authWithToken(options.orgid, options.token, {});
91
+ if (err) { throw err; }
92
+ else {
93
+ this.token = options.token;
94
+ this.orgId = options.orgid;
95
+ }
96
+ }
97
+ // This is the case when api requires orgid but not token
98
+ else if(options.orgid) {
99
+ this.orgId = options.orgid;
100
+ }
101
+ }
102
+
103
+ /****************************************
104
+ * Setting Up SDK Public Functions/Objects
105
+ *****************************************/
106
+ //Token Management
107
+ comproDLS.prototype.authWithToken = token_manager.authWithToken;
108
+ comproDLS.prototype.authWithExtUser = token_manager.authWithExtUser;
109
+
110
+ //Open Access SDK Functions
111
+ comproDLS.prototype.getClassEnrolmentsStat = open_access.getClassEnrolmentsStat;
112
+ comproDLS.prototype.getSingleInvitation = open_access.getSingleInvitation;
113
+
114
+ //Custom Service Adaptors
115
+ comproDLS.prototype.Auth = auth;
116
+ comproDLS.prototype.AuthExtn = authextn;
117
+ comproDLS.prototype.Analytics = analytics;
118
+ comproDLS.prototype.Product = product;
119
+ comproDLS.prototype.Xapi = xapi;
120
+ comproDLS.prototype.Attempts = attempts;
121
+ comproDLS.prototype.Pub = pub;
122
+ comproDLS.prototype.PushX = pushX;
123
+ comproDLS.prototype.Spaces = spaces;
124
+ comproDLS.prototype.SpacesExtn = spacesextn;
125
+ comproDLS.prototype.Superuser = superuser;
126
+ comproDLS.prototype.Invitations = invitations;
127
+ comproDLS.prototype.Workflows = workflows;
128
+ comproDLS.prototype.Integrations = integrations;
129
+ comproDLS.prototype.Drive = drive;
130
+ comproDLS.prototype.Taxonomy = taxonomy;
131
+ comproDLS.prototype.Rules = rules;
132
+ comproDLS.prototype.Datasyncmanager = datasyncmanager;