workos 0.0.24 → 0.1.0
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/.claude-plugin/plugin.json +13 -0
- package/LICENSE +47 -0
- package/README.md +154 -1
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +163 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.config.d.ts +52 -0
- package/dist/cli.config.js +70 -0
- package/dist/cli.config.js.map +1 -0
- package/dist/package.json +87 -0
- package/dist/src/commands/install-skill.d.ts +20 -0
- package/dist/src/commands/install-skill.js +130 -0
- package/dist/src/commands/install-skill.js.map +1 -0
- package/dist/src/commands/install.d.ts +22 -0
- package/dist/src/commands/install.js +57 -0
- package/dist/src/commands/install.js.map +1 -0
- package/dist/src/commands/login.d.ts +1 -0
- package/dist/src/commands/login.js +141 -0
- package/dist/src/commands/login.js.map +1 -0
- package/dist/src/commands/logout.d.ts +1 -0
- package/dist/src/commands/logout.js +17 -0
- package/dist/src/commands/logout.js.map +1 -0
- package/dist/src/dashboard/components/AnimatedLogo.d.ts +8 -0
- package/dist/src/dashboard/components/AnimatedLogo.js +16 -0
- package/dist/src/dashboard/components/AnimatedLogo.js.map +1 -0
- package/dist/src/dashboard/components/CompletionView.d.ts +13 -0
- package/dist/src/dashboard/components/CompletionView.js +21 -0
- package/dist/src/dashboard/components/CompletionView.js.map +1 -0
- package/dist/src/dashboard/components/ConfirmPrompt.d.ts +9 -0
- package/dist/src/dashboard/components/ConfirmPrompt.js +25 -0
- package/dist/src/dashboard/components/ConfirmPrompt.js.map +1 -0
- package/dist/src/dashboard/components/CredentialsForm.d.ts +10 -0
- package/dist/src/dashboard/components/CredentialsForm.js +47 -0
- package/dist/src/dashboard/components/CredentialsForm.js.map +1 -0
- package/dist/src/dashboard/components/Dashboard.d.ts +3 -0
- package/dist/src/dashboard/components/Dashboard.js +100 -0
- package/dist/src/dashboard/components/Dashboard.js.map +1 -0
- package/dist/src/dashboard/components/DashboardLayout.d.ts +24 -0
- package/dist/src/dashboard/components/DashboardLayout.js +25 -0
- package/dist/src/dashboard/components/DashboardLayout.js.map +1 -0
- package/dist/src/dashboard/components/DiffPanel.d.ts +9 -0
- package/dist/src/dashboard/components/DiffPanel.js +136 -0
- package/dist/src/dashboard/components/DiffPanel.js.map +1 -0
- package/dist/src/dashboard/components/InlinePrompt.d.ts +8 -0
- package/dist/src/dashboard/components/InlinePrompt.js +19 -0
- package/dist/src/dashboard/components/InlinePrompt.js.map +1 -0
- package/dist/src/dashboard/components/OutputPanel.d.ts +10 -0
- package/dist/src/dashboard/components/OutputPanel.js +100 -0
- package/dist/src/dashboard/components/OutputPanel.js.map +1 -0
- package/dist/src/dashboard/components/Panel.d.ts +12 -0
- package/dist/src/dashboard/components/Panel.js +6 -0
- package/dist/src/dashboard/components/Panel.js.map +1 -0
- package/dist/src/dashboard/components/TextInput.d.ts +13 -0
- package/dist/src/dashboard/components/TextInput.js +57 -0
- package/dist/src/dashboard/components/TextInput.js.map +1 -0
- package/dist/src/dashboard/components/WelcomeArt.d.ts +2 -0
- package/dist/src/dashboard/components/WelcomeArt.js +9 -0
- package/dist/src/dashboard/components/WelcomeArt.js.map +1 -0
- package/dist/src/dashboard/hooks/useAnimation.d.ts +7 -0
- package/dist/src/dashboard/hooks/useAnimation.js +24 -0
- package/dist/src/dashboard/hooks/useAnimation.js.map +1 -0
- package/dist/src/dashboard/hooks/useKeyboard.d.ts +8 -0
- package/dist/src/dashboard/hooks/useKeyboard.js +18 -0
- package/dist/src/dashboard/hooks/useKeyboard.js.map +1 -0
- package/dist/src/dashboard/hooks/useTerminalSize.d.ts +8 -0
- package/dist/src/dashboard/hooks/useTerminalSize.js +23 -0
- package/dist/src/dashboard/hooks/useTerminalSize.js.map +1 -0
- package/dist/src/dashboard/index.d.ts +6 -0
- package/dist/src/dashboard/index.js +36 -0
- package/dist/src/dashboard/index.js.map +1 -0
- package/dist/src/dashboard/lib/diff-utils.d.ts +21 -0
- package/dist/src/dashboard/lib/diff-utils.js +271 -0
- package/dist/src/dashboard/lib/diff-utils.js.map +1 -0
- package/dist/src/dashboard/lib/logo-frames.d.ts +20 -0
- package/dist/src/dashboard/lib/logo-frames.js +109 -0
- package/dist/src/dashboard/lib/logo-frames.js.map +1 -0
- package/dist/src/dashboard/lib/welcome-art.d.ts +1 -0
- package/dist/src/dashboard/lib/welcome-art.js +5 -0
- package/dist/src/dashboard/lib/welcome-art.js.map +1 -0
- package/dist/src/dashboard/types.d.ts +5 -0
- package/dist/src/dashboard/types.js +2 -0
- package/dist/src/dashboard/types.js.map +1 -0
- package/dist/src/lib/__tests__/test-utils.d.ts +40 -0
- package/dist/src/lib/__tests__/test-utils.js +108 -0
- package/dist/src/lib/__tests__/test-utils.js.map +1 -0
- package/dist/src/lib/adapters/cli-adapter.d.ts +56 -0
- package/dist/src/lib/adapters/cli-adapter.js +318 -0
- package/dist/src/lib/adapters/cli-adapter.js.map +1 -0
- package/dist/src/lib/adapters/dashboard-adapter.d.ts +30 -0
- package/dist/src/lib/adapters/dashboard-adapter.js +97 -0
- package/dist/src/lib/adapters/dashboard-adapter.js.map +1 -0
- package/dist/src/lib/adapters/index.d.ts +3 -0
- package/dist/src/lib/adapters/index.js +3 -0
- package/dist/src/lib/adapters/index.js.map +1 -0
- package/dist/src/lib/adapters/types.d.ts +41 -0
- package/dist/src/lib/adapters/types.js +2 -0
- package/dist/src/lib/adapters/types.js.map +1 -0
- package/dist/src/lib/agent-interface.d.ts +75 -0
- package/dist/src/lib/agent-interface.js +563 -0
- package/dist/src/lib/agent-interface.js.map +1 -0
- package/dist/src/lib/agent-runner.d.ts +9 -0
- package/dist/src/lib/agent-runner.js +213 -0
- package/dist/src/lib/agent-runner.js.map +1 -0
- package/dist/src/lib/api.d.ts +25 -0
- package/dist/src/lib/api.js +120 -0
- package/dist/src/lib/api.js.map +1 -0
- package/dist/src/lib/config.d.ts +60 -0
- package/dist/src/lib/config.js +88 -0
- package/dist/src/lib/config.js.map +1 -0
- package/dist/src/lib/constants.d.ts +32 -0
- package/dist/src/lib/constants.js +53 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/credentials.d.ts +19 -0
- package/dist/src/lib/credentials.js +55 -0
- package/dist/src/lib/credentials.js.map +1 -0
- package/dist/src/lib/env-writer.d.ts +14 -0
- package/dist/src/lib/env-writer.js +39 -0
- package/dist/src/lib/env-writer.js.map +1 -0
- package/dist/src/lib/events.d.ts +114 -0
- package/dist/src/lib/events.js +19 -0
- package/dist/src/lib/events.js.map +1 -0
- package/dist/src/lib/framework-config.d.ts +108 -0
- package/dist/src/lib/framework-config.js +11 -0
- package/dist/src/lib/framework-config.js.map +1 -0
- package/dist/src/lib/helper-functions.d.ts +1 -0
- package/dist/src/lib/helper-functions.js +2 -0
- package/dist/src/lib/helper-functions.js.map +1 -0
- package/dist/src/lib/port-detection.d.ts +7 -0
- package/dist/src/lib/port-detection.js +112 -0
- package/dist/src/lib/port-detection.js.map +1 -0
- package/dist/src/lib/progress-tracker.d.ts +22 -0
- package/dist/src/lib/progress-tracker.js +47 -0
- package/dist/src/lib/progress-tracker.js.map +1 -0
- package/dist/src/lib/run-with-core.d.ts +2 -0
- package/dist/src/lib/run-with-core.js +266 -0
- package/dist/src/lib/run-with-core.js.map +1 -0
- package/dist/src/lib/safe-tools.d.ts +2 -0
- package/dist/src/lib/safe-tools.js +212 -0
- package/dist/src/lib/safe-tools.js.map +1 -0
- package/dist/src/lib/settings.d.ts +59 -0
- package/dist/src/lib/settings.js +36 -0
- package/dist/src/lib/settings.js.map +1 -0
- package/dist/src/lib/token-refresh.d.ts +12 -0
- package/dist/src/lib/token-refresh.js +26 -0
- package/dist/src/lib/token-refresh.js.map +1 -0
- package/dist/src/lib/validation/build-validator.d.ts +9 -0
- package/dist/src/lib/validation/build-validator.js +118 -0
- package/dist/src/lib/validation/build-validator.js.map +1 -0
- package/dist/src/lib/validation/index.d.ts +3 -0
- package/dist/src/lib/validation/index.js +3 -0
- package/dist/src/lib/validation/index.js.map +1 -0
- package/dist/src/lib/validation/types.d.ts +41 -0
- package/dist/src/lib/validation/types.js +2 -0
- package/dist/src/lib/validation/types.js.map +1 -0
- package/dist/src/lib/validation/validator.d.ts +6 -0
- package/dist/src/lib/validation/validator.js +647 -0
- package/dist/src/lib/validation/validator.js.map +1 -0
- package/dist/src/lib/wizard-core.d.ts +200 -0
- package/dist/src/lib/wizard-core.js +392 -0
- package/dist/src/lib/wizard-core.js.map +1 -0
- package/dist/src/lib/wizard-core.types.d.ts +73 -0
- package/dist/src/lib/wizard-core.types.js +2 -0
- package/dist/src/lib/wizard-core.types.js.map +1 -0
- package/dist/src/lib/workos-management.d.ts +32 -0
- package/dist/src/lib/workos-management.js +142 -0
- package/dist/src/lib/workos-management.js.map +1 -0
- package/dist/src/nextjs/nextjs-wizard-agent.d.ts +6 -0
- package/dist/src/nextjs/nextjs-wizard-agent.js +97 -0
- package/dist/src/nextjs/nextjs-wizard-agent.js.map +1 -0
- package/dist/src/nextjs/utils.d.ts +8 -0
- package/dist/src/nextjs/utils.js +53 -0
- package/dist/src/nextjs/utils.js.map +1 -0
- package/dist/src/react/react-wizard-agent.d.ts +2 -0
- package/dist/src/react/react-wizard-agent.js +47 -0
- package/dist/src/react/react-wizard-agent.js.map +1 -0
- package/dist/src/react-router/react-router-wizard-agent.d.ts +6 -0
- package/dist/src/react-router/react-router-wizard-agent.js +103 -0
- package/dist/src/react-router/react-router-wizard-agent.js.map +1 -0
- package/dist/src/react-router/utils.d.ts +19 -0
- package/dist/src/react-router/utils.js +210 -0
- package/dist/src/react-router/utils.js.map +1 -0
- package/dist/src/run.d.ts +24 -0
- package/dist/src/run.js +48 -0
- package/dist/src/run.js.map +1 -0
- package/dist/src/steps/add-or-update-environment-variables.d.ts +10 -0
- package/dist/src/steps/add-or-update-environment-variables.js +155 -0
- package/dist/src/steps/add-or-update-environment-variables.js.map +1 -0
- package/dist/src/steps/index.d.ts +3 -0
- package/dist/src/steps/index.js +4 -0
- package/dist/src/steps/index.js.map +1 -0
- package/dist/src/steps/run-prettier.d.ts +5 -0
- package/dist/src/steps/run-prettier.js +54 -0
- package/dist/src/steps/run-prettier.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +8 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js +7 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/index.d.ts +6 -0
- package/dist/src/steps/upload-environment-variables/index.js +57 -0
- package/dist/src/steps/upload-environment-variables/index.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +14 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js +104 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js.map +1 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.d.ts +2 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.js +49 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.js.map +1 -0
- package/dist/src/telemetry.d.ts +2 -0
- package/dist/src/telemetry.js +29 -0
- package/dist/src/telemetry.js.map +1 -0
- package/dist/src/utils/analytics.d.ts +24 -0
- package/dist/src/utils/analytics.js +139 -0
- package/dist/src/utils/analytics.js.map +1 -0
- package/dist/src/utils/bash.d.ts +2 -0
- package/dist/src/utils/bash.js +17 -0
- package/dist/src/utils/bash.js.map +1 -0
- package/dist/src/utils/clack-utils.d.ts +93 -0
- package/dist/src/utils/clack-utils.js +397 -0
- package/dist/src/utils/clack-utils.js.map +1 -0
- package/dist/src/utils/clack.d.ts +5 -0
- package/dist/src/utils/clack.js +34 -0
- package/dist/src/utils/clack.js.map +1 -0
- package/dist/src/utils/cli-symbols.d.ts +32 -0
- package/dist/src/utils/cli-symbols.js +46 -0
- package/dist/src/utils/cli-symbols.js.map +1 -0
- package/dist/src/utils/debug.d.ts +7 -0
- package/dist/src/utils/debug.js +88 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/src/utils/env-parser.d.ts +5 -0
- package/dist/src/utils/env-parser.js +18 -0
- package/dist/src/utils/env-parser.js.map +1 -0
- package/dist/src/utils/environment.d.ts +4 -0
- package/dist/src/utils/environment.js +69 -0
- package/dist/src/utils/environment.js.map +1 -0
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +7 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/logging.d.ts +9 -0
- package/dist/src/utils/logging.js +36 -0
- package/dist/src/utils/logging.js.map +1 -0
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +21 -0
- package/dist/src/utils/package-json.js.map +1 -0
- package/dist/src/utils/package-manager.d.ts +21 -0
- package/dist/src/utils/package-manager.js +167 -0
- package/dist/src/utils/package-manager.js.map +1 -0
- package/dist/src/utils/redact.d.ts +5 -0
- package/dist/src/utils/redact.js +29 -0
- package/dist/src/utils/redact.js.map +1 -0
- package/dist/src/utils/semver.d.ts +10 -0
- package/dist/src/utils/semver.js +43 -0
- package/dist/src/utils/semver.js.map +1 -0
- package/dist/src/utils/string.d.ts +1 -0
- package/dist/src/utils/string.js +6 -0
- package/dist/src/utils/string.js.map +1 -0
- package/dist/src/utils/telemetry-client.d.ts +15 -0
- package/dist/src/utils/telemetry-client.js +57 -0
- package/dist/src/utils/telemetry-client.js.map +1 -0
- package/dist/src/utils/telemetry-types.d.ts +51 -0
- package/dist/src/utils/telemetry-types.js +6 -0
- package/dist/src/utils/telemetry-types.js.map +1 -0
- package/dist/src/utils/types.d.ts +80 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/src/utils/types.js.map +1 -0
- package/dist/src/utils/urls.d.ts +7 -0
- package/dist/src/utils/urls.js +8 -0
- package/dist/src/utils/urls.js.map +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.d.ts +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js +21 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js.map +1 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.d.ts +2 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.js +47 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.js.map +1 -0
- package/package.json +76 -84
- package/skills/workos-authkit-base/SKILL.md +113 -0
- package/skills/workos-authkit-nextjs/SKILL.md +115 -0
- package/skills/workos-authkit-react/SKILL.md +91 -0
- package/skills/workos-authkit-react-router/SKILL.md +106 -0
- package/skills/workos-authkit-tanstack-start/SKILL.md +104 -0
- package/skills/workos-authkit-vanilla-js/SKILL.md +81 -0
- package/build/apps/index.js +0 -50
- package/build/apps/slack.js +0 -151
- package/build/cli.js +0 -42
- package/build/config.js +0 -34
- package/build/dev.js +0 -5
- package/build/enable-api-access.png +0 -0
- package/build/groups.js +0 -480
- package/build/index.js +0 -3
- package/build/info.js +0 -69
- package/build/login.js +0 -161
- package/build/main.js +0 -214
- package/build/users.js +0 -402
- package/build/util.js +0 -157
- package/coverage/clover.xml +0 -66
- package/coverage/coverage-final.json +0 -4
- package/coverage/lcov-report/base.css +0 -212
- package/coverage/lcov-report/cli.ts.html +0 -329
- package/coverage/lcov-report/config.ts.html +0 -152
- package/coverage/lcov-report/index.html +0 -119
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -1
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -158
- package/coverage/lcov-report/util.ts.html +0 -350
- package/coverage/lcov.info +0 -121
- package/package-lock.json +0 -7617
- package/tests/util.test.ts +0 -35
package/build/users.js
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (_) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
49
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
50
|
-
};
|
|
51
|
-
var _this = this;
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var got_1 = __importDefault(require("got"));
|
|
54
|
-
var inquirer_1 = __importDefault(require("inquirer"));
|
|
55
|
-
var figures_1 = __importDefault(require("figures"));
|
|
56
|
-
var xkpasswd = require('xkpasswd');
|
|
57
|
-
var email_validator_1 = __importDefault(require("email-validator"));
|
|
58
|
-
var sha1_1 = __importDefault(require("sha1"));
|
|
59
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
60
|
-
var ora_1 = __importDefault(require("ora"));
|
|
61
|
-
var clipboardy_1 = __importDefault(require("clipboardy"));
|
|
62
|
-
var columnify = require('columnify'); // TODO typings are busted
|
|
63
|
-
var cli_1 = require("./cli");
|
|
64
|
-
var util_1 = require("./util");
|
|
65
|
-
var config_1 = require("./config");
|
|
66
|
-
var util_2 = require("./util");
|
|
67
|
-
exports.userCommand = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
68
|
-
var command, userId, _a;
|
|
69
|
-
return __generator(this, function (_b) {
|
|
70
|
-
switch (_b.label) {
|
|
71
|
-
case 0:
|
|
72
|
-
command = cli_1.cli.input[0];
|
|
73
|
-
userId = util_1.addDomainToEmailName(cli_1.cli.input[1]);
|
|
74
|
-
util_2.debug("Command is " + command + " and userId is " + userId);
|
|
75
|
-
if (cli_1.cli.flags.create) { // Override if passed the create flag
|
|
76
|
-
command = 'user:create';
|
|
77
|
-
}
|
|
78
|
-
_a = command;
|
|
79
|
-
switch (_a) {
|
|
80
|
-
case 'user': return [3 /*break*/, 1];
|
|
81
|
-
case 'user:info': return [3 /*break*/, 1];
|
|
82
|
-
case 'users': return [3 /*break*/, 3];
|
|
83
|
-
case 'user:list': return [3 /*break*/, 3];
|
|
84
|
-
case 'users:list': return [3 /*break*/, 3];
|
|
85
|
-
case 'users:create': return [3 /*break*/, 7];
|
|
86
|
-
case 'user:create': return [3 /*break*/, 7];
|
|
87
|
-
case 'users:delete': return [3 /*break*/, 9];
|
|
88
|
-
case 'user:delete': return [3 /*break*/, 9];
|
|
89
|
-
case 'users:undelete': return [3 /*break*/, 11];
|
|
90
|
-
case 'user:undelete': return [3 /*break*/, 11];
|
|
91
|
-
case 'users:reset': return [3 /*break*/, 13];
|
|
92
|
-
case 'user:reset': return [3 /*break*/, 13];
|
|
93
|
-
}
|
|
94
|
-
return [3 /*break*/, 14];
|
|
95
|
-
case 1:
|
|
96
|
-
if (!userId) return [3 /*break*/, 3];
|
|
97
|
-
return [4 /*yield*/, userInfo(userId)];
|
|
98
|
-
case 2:
|
|
99
|
-
_b.sent();
|
|
100
|
-
return [3 /*break*/, 15];
|
|
101
|
-
case 3:
|
|
102
|
-
if (!cli_1.cli.flags.deleted) return [3 /*break*/, 5];
|
|
103
|
-
return [4 /*yield*/, listDeletedUsers()];
|
|
104
|
-
case 4:
|
|
105
|
-
_b.sent();
|
|
106
|
-
return [3 /*break*/, 15];
|
|
107
|
-
case 5: return [4 /*yield*/, listUsers()];
|
|
108
|
-
case 6:
|
|
109
|
-
_b.sent();
|
|
110
|
-
return [3 /*break*/, 15];
|
|
111
|
-
case 7: return [4 /*yield*/, createUser()];
|
|
112
|
-
case 8:
|
|
113
|
-
_b.sent();
|
|
114
|
-
return [3 /*break*/, 15];
|
|
115
|
-
case 9:
|
|
116
|
-
if (!userId) {
|
|
117
|
-
util_2.log("Please provide a user email address");
|
|
118
|
-
return [3 /*break*/, 15];
|
|
119
|
-
}
|
|
120
|
-
return [4 /*yield*/, deleteUser(userId)];
|
|
121
|
-
case 10:
|
|
122
|
-
_b.sent();
|
|
123
|
-
return [3 /*break*/, 15];
|
|
124
|
-
case 11:
|
|
125
|
-
if (!userId) {
|
|
126
|
-
util_2.log("Please provide a deleted user's email address");
|
|
127
|
-
return [3 /*break*/, 15];
|
|
128
|
-
}
|
|
129
|
-
return [4 /*yield*/, undeleteUser(userId)];
|
|
130
|
-
case 12:
|
|
131
|
-
_b.sent();
|
|
132
|
-
return [3 /*break*/, 15];
|
|
133
|
-
case 13:
|
|
134
|
-
console.log("reset the password for " + userId);
|
|
135
|
-
return [3 /*break*/, 15];
|
|
136
|
-
case 14:
|
|
137
|
-
util_2.logError("Unknown command " + command);
|
|
138
|
-
return [3 /*break*/, 15];
|
|
139
|
-
case 15: return [2 /*return*/];
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}); };
|
|
143
|
-
//
|
|
144
|
-
// $ workos users:list
|
|
145
|
-
//
|
|
146
|
-
var listUsers = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
147
|
-
var endpoint, apiResp, users, data, columns;
|
|
148
|
-
return __generator(this, function (_a) {
|
|
149
|
-
switch (_a.label) {
|
|
150
|
-
case 0:
|
|
151
|
-
util_2.debug('Running listUsers');
|
|
152
|
-
util_2.debug("Calling list users with header token " + config_1.API_TOKEN);
|
|
153
|
-
endpoint = config_1.API_BASE_URL + "/users";
|
|
154
|
-
util_2.debug("Endpoint: " + endpoint);
|
|
155
|
-
return [4 /*yield*/, got_1.default(endpoint, {
|
|
156
|
-
json: true,
|
|
157
|
-
headers: {
|
|
158
|
-
'Authorization': "Bearer " + config_1.API_TOKEN
|
|
159
|
-
}
|
|
160
|
-
})];
|
|
161
|
-
case 1:
|
|
162
|
-
apiResp = _a.sent();
|
|
163
|
-
util_2.debug(require('util').inspect(apiResp.body, { depth: null }));
|
|
164
|
-
users = apiResp.body;
|
|
165
|
-
data = users.map(function (user) {
|
|
166
|
-
return {
|
|
167
|
-
'Name': user.firstName + " " + user.lastName,
|
|
168
|
-
'Email': user.email,
|
|
169
|
-
'Admin': user.isAdmin ? '✅' : ''
|
|
170
|
-
};
|
|
171
|
-
});
|
|
172
|
-
console.log();
|
|
173
|
-
columns = columnify(data, {
|
|
174
|
-
// minWidth: 20,
|
|
175
|
-
columnSplitter: ' ',
|
|
176
|
-
maxLineWidth: 'auto',
|
|
177
|
-
truncate: true,
|
|
178
|
-
config: {
|
|
179
|
-
Name: { headingTransform: chalk_1.default.dim },
|
|
180
|
-
Email: { headingTransform: chalk_1.default.dim },
|
|
181
|
-
Admin: { headingTransform: chalk_1.default.dim, align: 'right' },
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
console.log(columns);
|
|
185
|
-
console.log(chalk_1.default.dim("\nTotal users: " + users.length));
|
|
186
|
-
return [2 /*return*/];
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}); };
|
|
190
|
-
var userInfo = function (userId) { return __awaiter(_this, void 0, void 0, function () {
|
|
191
|
-
var apiResp, user;
|
|
192
|
-
return __generator(this, function (_a) {
|
|
193
|
-
switch (_a.label) {
|
|
194
|
-
case 0: return [4 /*yield*/, got_1.default(config_1.API_BASE_URL + "/users/" + userId, {
|
|
195
|
-
json: true,
|
|
196
|
-
headers: {
|
|
197
|
-
'Authorization': "Bearer " + config_1.API_TOKEN
|
|
198
|
-
}
|
|
199
|
-
})];
|
|
200
|
-
case 1:
|
|
201
|
-
apiResp = _a.sent();
|
|
202
|
-
user = apiResp.body;
|
|
203
|
-
console.log(user);
|
|
204
|
-
return [2 /*return*/];
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}); };
|
|
208
|
-
var listDeletedUsers = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
209
|
-
var apiResp, _i, _a, user;
|
|
210
|
-
return __generator(this, function (_b) {
|
|
211
|
-
switch (_b.label) {
|
|
212
|
-
case 0: return [4 /*yield*/, got_1.default(config_1.API_BASE_URL + "/deleted_users", {
|
|
213
|
-
json: true,
|
|
214
|
-
headers: {
|
|
215
|
-
'Authorization': "Bearer " + config_1.API_TOKEN
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
// log(JSON.stringify(apiResp.body, undefined, 2))
|
|
219
|
-
];
|
|
220
|
-
case 1:
|
|
221
|
-
apiResp = _b.sent();
|
|
222
|
-
// log(JSON.stringify(apiResp.body, undefined, 2))
|
|
223
|
-
for (_i = 0, _a = apiResp.body; _i < _a.length; _i++) {
|
|
224
|
-
user = _a[_i];
|
|
225
|
-
console.log(user.primaryEmail);
|
|
226
|
-
util_2.debug(require('util').inspect(apiResp.body, { depth: null }));
|
|
227
|
-
}
|
|
228
|
-
return [2 /*return*/];
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
}); };
|
|
232
|
-
//
|
|
233
|
-
// $ workos user:create
|
|
234
|
-
//
|
|
235
|
-
var createUser = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
236
|
-
var alreayAskedIfFirstnameSpaceWanted, answers, temporaryPassword, form, spinner, resp, newUser;
|
|
237
|
-
var _this = this;
|
|
238
|
-
return __generator(this, function (_a) {
|
|
239
|
-
switch (_a.label) {
|
|
240
|
-
case 0:
|
|
241
|
-
alreayAskedIfFirstnameSpaceWanted = false;
|
|
242
|
-
return [4 /*yield*/, inquirer_1.default.prompt([
|
|
243
|
-
{
|
|
244
|
-
type: 'input',
|
|
245
|
-
prefix: figures_1.default.pointer,
|
|
246
|
-
name: 'firstName',
|
|
247
|
-
message: 'First name:',
|
|
248
|
-
filter: function (val) { return val.trim(); },
|
|
249
|
-
validate: function (value) {
|
|
250
|
-
if (!value) {
|
|
251
|
-
return "Please enter the user's first name";
|
|
252
|
-
}
|
|
253
|
-
if (value.indexOf(' ') > 0 && !alreayAskedIfFirstnameSpaceWanted) {
|
|
254
|
-
alreayAskedIfFirstnameSpaceWanted = true;
|
|
255
|
-
return "Are you sure you want a space in the first name? Please re-enter to confirm.";
|
|
256
|
-
}
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
259
|
-
}, {
|
|
260
|
-
type: 'input',
|
|
261
|
-
prefix: figures_1.default.pointer,
|
|
262
|
-
name: 'lastName',
|
|
263
|
-
message: 'Last name:',
|
|
264
|
-
filter: function (val) { return val.trim(); },
|
|
265
|
-
validate: function (value) {
|
|
266
|
-
if (!value) {
|
|
267
|
-
return "Please enter the user's last name";
|
|
268
|
-
}
|
|
269
|
-
return true;
|
|
270
|
-
},
|
|
271
|
-
}, {
|
|
272
|
-
type: 'input',
|
|
273
|
-
prefix: figures_1.default.pointer,
|
|
274
|
-
name: 'email',
|
|
275
|
-
message: 'Email:',
|
|
276
|
-
default: function (currentAnswers) {
|
|
277
|
-
return (currentAnswers.firstName.toLowerCase() + "@" + config_1.G_SUITE_DOMAIN).replace(' ', '.');
|
|
278
|
-
},
|
|
279
|
-
filter: function (val) {
|
|
280
|
-
return util_1.addDomainToEmailName(val.trim().toLowerCase());
|
|
281
|
-
},
|
|
282
|
-
validate: function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|
283
|
-
var isAvailable;
|
|
284
|
-
return __generator(this, function (_a) {
|
|
285
|
-
switch (_a.label) {
|
|
286
|
-
case 0:
|
|
287
|
-
if (!value) {
|
|
288
|
-
return [2 /*return*/, "Email address required"];
|
|
289
|
-
}
|
|
290
|
-
if (!email_validator_1.default.validate(value)) {
|
|
291
|
-
return [2 /*return*/, "Please enter a valid email address"];
|
|
292
|
-
}
|
|
293
|
-
if (!value.endsWith("@" + config_1.G_SUITE_DOMAIN)) {
|
|
294
|
-
return [2 /*return*/, "Email address must end with @" + config_1.G_SUITE_DOMAIN];
|
|
295
|
-
}
|
|
296
|
-
return [4 /*yield*/, util_2.checkIfEmailAvailable(value)];
|
|
297
|
-
case 1:
|
|
298
|
-
isAvailable = _a.sent();
|
|
299
|
-
if (!isAvailable) {
|
|
300
|
-
return [2 /*return*/, "The address " + value + " is already in use."];
|
|
301
|
-
}
|
|
302
|
-
return [2 /*return*/, true];
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
}); }
|
|
306
|
-
}
|
|
307
|
-
])];
|
|
308
|
-
case 1:
|
|
309
|
-
answers = _a.sent();
|
|
310
|
-
util_2.debug(JSON.stringify(answers));
|
|
311
|
-
// Auto-generate a temporary password
|
|
312
|
-
util_2.debug('Generating random password...');
|
|
313
|
-
temporaryPassword = xkpasswd({ complexity: 2, separators: '-' });
|
|
314
|
-
util_2.debug("Password: " + temporaryPassword);
|
|
315
|
-
form = __assign({}, answers, { sha1_password: sha1_1.default(temporaryPassword) });
|
|
316
|
-
util_2.debug('Sending to create user API endpoint');
|
|
317
|
-
spinner = ora_1.default("Creating user...").start();
|
|
318
|
-
return [4 /*yield*/, got_1.default.post(config_1.API_BASE_URL + '/users', { body: form,
|
|
319
|
-
json: true,
|
|
320
|
-
headers: {
|
|
321
|
-
'Authorization': "Bearer " + config_1.API_TOKEN
|
|
322
|
-
}
|
|
323
|
-
})
|
|
324
|
-
// TODO prompt about adding to teams, slack, etc. Use the Inquirer checkbox type
|
|
325
|
-
// https://github.com/clinyong/inquirer-search-checkbox
|
|
326
|
-
];
|
|
327
|
-
case 2:
|
|
328
|
-
resp = _a.sent();
|
|
329
|
-
newUser = resp.body;
|
|
330
|
-
util_2.debug(newUser);
|
|
331
|
-
util_2.debug('Created user');
|
|
332
|
-
clipboardy_1.default.writeSync(temporaryPassword);
|
|
333
|
-
spinner.succeed("Success!\n");
|
|
334
|
-
util_2.log(" Name: " + chalk_1.default.cyanBright(newUser.firstName + ' ' + newUser.lastName));
|
|
335
|
-
util_2.log(" Email address: " + newUser.email);
|
|
336
|
-
util_2.log(" Temporary password: " + chalk_1.default.yellowBright(temporaryPassword) + " " + chalk_1.default.dim('(copied to clipboard)') + "\n");
|
|
337
|
-
return [2 /*return*/];
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}); };
|
|
341
|
-
var deleteUser = function (userId) { return __awaiter(_this, void 0, void 0, function () {
|
|
342
|
-
var answers, spinner, resp;
|
|
343
|
-
return __generator(this, function (_a) {
|
|
344
|
-
switch (_a.label) {
|
|
345
|
-
case 0:
|
|
346
|
-
util_2.debug('POSTing to delete user API endpoint');
|
|
347
|
-
if (!!cli_1.cli.flags.yes) return [3 /*break*/, 2];
|
|
348
|
-
return [4 /*yield*/, inquirer_1.default.prompt([
|
|
349
|
-
{
|
|
350
|
-
type: 'confirm',
|
|
351
|
-
name: 'confirmed',
|
|
352
|
-
default: false,
|
|
353
|
-
prefix: figures_1.default.pointer,
|
|
354
|
-
message: "Are you sure you want to delete " + userId + " ?",
|
|
355
|
-
}
|
|
356
|
-
])];
|
|
357
|
-
case 1:
|
|
358
|
-
answers = _a.sent();
|
|
359
|
-
if (!answers.confirmed) {
|
|
360
|
-
process.exit();
|
|
361
|
-
}
|
|
362
|
-
_a.label = 2;
|
|
363
|
-
case 2:
|
|
364
|
-
console.log(); // space... the final frontier
|
|
365
|
-
spinner = ora_1.default("Deleting user...").start();
|
|
366
|
-
return [4 /*yield*/, got_1.default.delete(config_1.API_BASE_URL + ("/users/" + userId), { json: true,
|
|
367
|
-
headers: {
|
|
368
|
-
'Authorization': "Bearer " + config_1.API_TOKEN
|
|
369
|
-
}
|
|
370
|
-
})];
|
|
371
|
-
case 3:
|
|
372
|
-
resp = _a.sent();
|
|
373
|
-
util_2.debug(require('util').inspect(resp, { depth: null }));
|
|
374
|
-
spinner.succeed("Success! User " + userId + " was deleted.\n");
|
|
375
|
-
util_2.log("You can undo this by running " + chalk_1.default.cyanBright('$ workos user:undelete ' + userId) + "\n");
|
|
376
|
-
return [2 /*return*/];
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
}); };
|
|
380
|
-
var undeleteUser = function (userId) { return __awaiter(_this, void 0, void 0, function () {
|
|
381
|
-
var spinner, resp;
|
|
382
|
-
return __generator(this, function (_a) {
|
|
383
|
-
switch (_a.label) {
|
|
384
|
-
case 0:
|
|
385
|
-
util_2.debug('POSTing to undelete the user');
|
|
386
|
-
console.log(); // space... the final frontier
|
|
387
|
-
spinner = ora_1.default("Undeleting user...").start();
|
|
388
|
-
return [4 /*yield*/, got_1.default.post(config_1.API_BASE_URL + ("/deleted_users/" + userId + "/undelete"), { json: true,
|
|
389
|
-
headers: {
|
|
390
|
-
'Authorization': "Bearer " + config_1.API_TOKEN
|
|
391
|
-
}
|
|
392
|
-
})];
|
|
393
|
-
case 1:
|
|
394
|
-
resp = _a.sent();
|
|
395
|
-
util_2.debug(require('util').inspect(resp, { depth: null }));
|
|
396
|
-
spinner.succeed("Success! User " + userId + " was reactivated.\n");
|
|
397
|
-
util_2.log("Reset their password by running " + chalk_1.default.cyanBright('$ workos user:reset ' + userId) + "\n");
|
|
398
|
-
return [2 /*return*/];
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
}); };
|
|
402
|
-
//# sourceMappingURL=users.js.map
|
package/build/util.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
|
-
};
|
|
40
|
-
var _this = this;
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var email_validator_1 = __importDefault(require("email-validator"));
|
|
43
|
-
var got_1 = __importDefault(require("got"));
|
|
44
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
45
|
-
var figures_1 = __importDefault(require("figures"));
|
|
46
|
-
var cli_1 = require("./cli");
|
|
47
|
-
var config_1 = require("./config");
|
|
48
|
-
exports.log = function (message, color) {
|
|
49
|
-
if (color === void 0) { color = 'blue'; }
|
|
50
|
-
console.log(chalk_1.default[color](figures_1.default.pointer) + " " + message);
|
|
51
|
-
};
|
|
52
|
-
exports.logError = function (message) {
|
|
53
|
-
console.log(chalk_1.default.redBright(figures_1.default.warning) + " " + chalk_1.default.redBright(message));
|
|
54
|
-
};
|
|
55
|
-
exports.debug = function (message) {
|
|
56
|
-
if (cli_1.cli.flags.debug) {
|
|
57
|
-
console.log(chalk_1.default.gray(figures_1.default.pointer) + " " + chalk_1.default.blue(message));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
exports.checkIfEmailAvailable = function (userId) { return __awaiter(_this, void 0, void 0, function () {
|
|
61
|
-
var error_1, error_2;
|
|
62
|
-
return __generator(this, function (_a) {
|
|
63
|
-
switch (_a.label) {
|
|
64
|
-
case 0:
|
|
65
|
-
_a.trys.push([0, 2, , 3]);
|
|
66
|
-
return [4 /*yield*/, got_1.default(config_1.API_BASE_URL + "/users/" + userId, {
|
|
67
|
-
json: true,
|
|
68
|
-
headers: {
|
|
69
|
-
'Authorization': "Bearer " + config_1.API_TOKEN
|
|
70
|
-
}
|
|
71
|
-
})];
|
|
72
|
-
case 1:
|
|
73
|
-
_a.sent();
|
|
74
|
-
return [2 /*return*/, false];
|
|
75
|
-
case 2:
|
|
76
|
-
error_1 = _a.sent();
|
|
77
|
-
if (error_1 instanceof got_1.default.HTTPError && error_1.statusCode === 404) {
|
|
78
|
-
exports.debug("No user with address " + userId);
|
|
79
|
-
// Continue on
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
throw error_1;
|
|
83
|
-
}
|
|
84
|
-
return [3 /*break*/, 3];
|
|
85
|
-
case 3:
|
|
86
|
-
_a.trys.push([3, 5, , 6]);
|
|
87
|
-
return [4 /*yield*/, got_1.default(config_1.API_BASE_URL + "/groups/" + userId, {
|
|
88
|
-
json: true,
|
|
89
|
-
headers: {
|
|
90
|
-
'Authorization': "Bearer " + config_1.API_TOKEN
|
|
91
|
-
}
|
|
92
|
-
})];
|
|
93
|
-
case 4:
|
|
94
|
-
_a.sent();
|
|
95
|
-
return [2 /*return*/, false];
|
|
96
|
-
case 5:
|
|
97
|
-
error_2 = _a.sent();
|
|
98
|
-
if (error_2 instanceof got_1.default.HTTPError && error_2.statusCode === 404) {
|
|
99
|
-
exports.debug("No user with address " + userId);
|
|
100
|
-
// Continue on
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
throw error_2;
|
|
104
|
-
}
|
|
105
|
-
return [3 /*break*/, 6];
|
|
106
|
-
case 6:
|
|
107
|
-
// Didn't find user or group with email so it's availabe
|
|
108
|
-
// TODO are there other objects we should check here? G Suite still may fail creation
|
|
109
|
-
return [2 /*return*/, true];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}); };
|
|
113
|
-
/*
|
|
114
|
-
All this does is adds the domain to the end of the string
|
|
115
|
-
if the string isn't currently a valid email address.
|
|
116
|
-
*/
|
|
117
|
-
exports.addDomainToEmailName = function (objectId, domain) {
|
|
118
|
-
if (domain === void 0) { domain = config_1.G_SUITE_DOMAIN; }
|
|
119
|
-
if (!objectId || !domain) {
|
|
120
|
-
return objectId; // no-op if input is undefined or empty string
|
|
121
|
-
}
|
|
122
|
-
if (objectId.endsWith("@" + domain)) {
|
|
123
|
-
return objectId;
|
|
124
|
-
}
|
|
125
|
-
// Check if trying to add a different domain to a string that already has a domain
|
|
126
|
-
if (domain !== config_1.G_SUITE_DOMAIN && objectId.split('@')[1]) {
|
|
127
|
-
throw Error("Cannot add domain suffix " + domain + " to string " + objectId);
|
|
128
|
-
}
|
|
129
|
-
var newEmailId = objectId + "@" + domain;
|
|
130
|
-
if (!email_validator_1.default.validate(newEmailId)) {
|
|
131
|
-
throw Error("Invalid user or group ID " + objectId);
|
|
132
|
-
}
|
|
133
|
-
return newEmailId;
|
|
134
|
-
};
|
|
135
|
-
// export const verifyDomain = (objectId: string, domain: string = G_SUITE_DOMAIN) => {
|
|
136
|
-
// // Check if email is within given domain
|
|
137
|
-
// return objectId.endsWith(`@${domain}`)
|
|
138
|
-
// if (!objectId.endsWith(`@${domain}`)) {
|
|
139
|
-
// throw Error(`Invalid user or group ID ${objectId}`)
|
|
140
|
-
// }
|
|
141
|
-
// }
|
|
142
|
-
exports._waitForEnter = function () {
|
|
143
|
-
return new Promise(function (resolve) {
|
|
144
|
-
var handleKeyPress = function (ch, key) {
|
|
145
|
-
if (key.name === 'return') {
|
|
146
|
-
process.stdin.removeListener('keypress', handleKeyPress);
|
|
147
|
-
resolve();
|
|
148
|
-
}
|
|
149
|
-
else if (key.name === 'escape' || (key.name === 'c' && key.ctrl)) {
|
|
150
|
-
process.exit();
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
process.stdin.on('keypress', handleKeyPress);
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
exports.timeout = function (ms) { return new Promise(function (res) { return setTimeout(res, ms); }); };
|
|
157
|
-
//# sourceMappingURL=util.js.map
|
package/coverage/clover.xml
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="1540313475148" clover="3.2.0">
|
|
3
|
-
<project timestamp="1540313475148" name="All files">
|
|
4
|
-
<metrics statements="50" coveredstatements="31" conditionals="32" coveredconditionals="16" methods="6" coveredmethods="1" elements="88" coveredelements="48" complexity="0" loc="50" ncloc="50" packages="1" files="3" classes="3">
|
|
5
|
-
<file name="cli.ts" path="/Users/mg/workspace/cli/src/cli.ts">
|
|
6
|
-
<metrics statements="1" coveredstatements="1" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0"/>
|
|
7
|
-
<line num="5" count="1" type="stmt"/>
|
|
8
|
-
</file>
|
|
9
|
-
<file name="config.ts" path="/Users/mg/workspace/cli/src/config.ts">
|
|
10
|
-
<metrics statements="18" coveredstatements="15" conditionals="6" coveredconditionals="3" methods="1" coveredmethods="0"/>
|
|
11
|
-
<line num="5" count="1" type="stmt"/>
|
|
12
|
-
<line num="6" count="1" type="stmt"/>
|
|
13
|
-
<line num="8" count="1" type="cond" truecount="1" falsecount="1"/>
|
|
14
|
-
<line num="9" count="1" type="stmt"/>
|
|
15
|
-
<line num="10" count="1" type="stmt"/>
|
|
16
|
-
<line num="13" count="1" type="stmt"/>
|
|
17
|
-
<line num="14" count="1" type="stmt"/>
|
|
18
|
-
<line num="15" count="1" type="stmt"/>
|
|
19
|
-
<line num="17" count="1" type="stmt"/>
|
|
20
|
-
<line num="18" count="1" type="stmt"/>
|
|
21
|
-
<line num="19" count="1" type="cond" truecount="1" falsecount="1"/>
|
|
22
|
-
<line num="20" count="0" type="stmt"/>
|
|
23
|
-
<line num="21" count="0" type="stmt"/>
|
|
24
|
-
<line num="22" count="1" type="cond" truecount="1" falsecount="1"/>
|
|
25
|
-
<line num="23" count="1" type="stmt"/>
|
|
26
|
-
<line num="24" count="1" type="stmt"/>
|
|
27
|
-
<line num="28" count="1" type="stmt"/>
|
|
28
|
-
<line num="29" count="0" type="stmt"/>
|
|
29
|
-
</file>
|
|
30
|
-
<file name="util.ts" path="/Users/mg/workspace/cli/src/util.ts">
|
|
31
|
-
<metrics statements="31" coveredstatements="15" conditionals="26" coveredconditionals="13" methods="5" coveredmethods="1"/>
|
|
32
|
-
<line num="1" count="1" type="stmt"/>
|
|
33
|
-
<line num="10" count="1" type="cond" truecount="0" falsecount="2"/>
|
|
34
|
-
<line num="11" count="0" type="stmt"/>
|
|
35
|
-
<line num="14" count="1" type="stmt"/>
|
|
36
|
-
<line num="15" count="0" type="stmt"/>
|
|
37
|
-
<line num="18" count="1" type="stmt"/>
|
|
38
|
-
<line num="19" count="0" type="cond" truecount="0" falsecount="2"/>
|
|
39
|
-
<line num="20" count="0" type="stmt"/>
|
|
40
|
-
<line num="25" count="1" type="stmt"/>
|
|
41
|
-
<line num="28" count="0" type="stmt"/>
|
|
42
|
-
<line num="33" count="0" type="stmt"/>
|
|
43
|
-
<line num="35" count="0" type="cond" truecount="0" falsecount="4"/>
|
|
44
|
-
<line num="36" count="0" type="stmt"/>
|
|
45
|
-
<line num="39" count="0" type="stmt"/>
|
|
46
|
-
<line num="45" count="0" type="stmt"/>
|
|
47
|
-
<line num="50" count="0" type="stmt"/>
|
|
48
|
-
<line num="52" count="0" type="cond" truecount="0" falsecount="4"/>
|
|
49
|
-
<line num="53" count="0" type="stmt"/>
|
|
50
|
-
<line num="56" count="0" type="stmt"/>
|
|
51
|
-
<line num="62" count="0" type="stmt"/>
|
|
52
|
-
<line num="69" count="9" type="cond" truecount="2" falsecount="0"/>
|
|
53
|
-
<line num="70" count="6" type="cond" truecount="4" falsecount="0"/>
|
|
54
|
-
<line num="71" count="2" type="stmt"/>
|
|
55
|
-
<line num="73" count="4" type="cond" truecount="2" falsecount="0"/>
|
|
56
|
-
<line num="74" count="2" type="stmt"/>
|
|
57
|
-
<line num="78" count="2" type="cond" truecount="4" falsecount="0"/>
|
|
58
|
-
<line num="79" count="1" type="stmt"/>
|
|
59
|
-
<line num="81" count="1" type="stmt"/>
|
|
60
|
-
<line num="82" count="1" type="cond" truecount="1" falsecount="1"/>
|
|
61
|
-
<line num="83" count="0" type="stmt"/>
|
|
62
|
-
<line num="85" count="1" type="stmt"/>
|
|
63
|
-
</file>
|
|
64
|
-
</metrics>
|
|
65
|
-
</project>
|
|
66
|
-
</coverage>
|