@p0security/cli 0.8.1 → 0.8.3

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 (48) hide show
  1. package/dist/commands/__tests__/grant.test.d.ts +1 -0
  2. package/dist/commands/__tests__/grant.test.js +55 -0
  3. package/dist/commands/grant.d.ts +4 -0
  4. package/dist/commands/grant.js +17 -0
  5. package/dist/commands/index.js +2 -0
  6. package/dist/commands/request.d.ts +0 -8
  7. package/dist/commands/request.js +3 -102
  8. package/dist/commands/scp.d.ts +1 -1
  9. package/dist/commands/scp.js +5 -4
  10. package/dist/commands/shared/index.d.ts +4 -0
  11. package/dist/commands/shared/index.js +67 -0
  12. package/dist/commands/shared/request.d.ts +14 -0
  13. package/dist/commands/shared/request.js +115 -0
  14. package/dist/commands/{shared.d.ts → shared/ssh.d.ts} +12 -22
  15. package/dist/commands/{shared.js → shared/ssh.js} +21 -75
  16. package/dist/commands/ssh.d.ts +1 -1
  17. package/dist/commands/ssh.js +3 -3
  18. package/dist/common/retry.d.ts +9 -0
  19. package/dist/common/retry.js +50 -0
  20. package/dist/drivers/auth.d.ts +1 -1
  21. package/dist/drivers/auth.js +7 -3
  22. package/dist/plugins/aws/config.d.ts +1 -1
  23. package/dist/plugins/aws/idc/index.d.ts +16 -0
  24. package/dist/plugins/aws/idc/index.js +150 -0
  25. package/dist/plugins/aws/ssh.d.ts +3 -3
  26. package/dist/plugins/aws/ssh.js +75 -11
  27. package/dist/plugins/aws/types.d.ts +29 -5
  28. package/dist/plugins/google/ssh.d.ts +5 -13
  29. package/dist/plugins/google/ssh.js +71 -10
  30. package/dist/plugins/google/types.d.ts +11 -3
  31. package/dist/plugins/login.d.ts +3 -0
  32. package/dist/plugins/login.js +10 -0
  33. package/dist/plugins/oidc/login.d.ts +33 -2
  34. package/dist/plugins/oidc/login.js +100 -60
  35. package/dist/plugins/okta/aws.d.ts +1 -1
  36. package/dist/plugins/okta/aws.js +2 -2
  37. package/dist/plugins/okta/login.js +11 -1
  38. package/dist/plugins/ping/login.d.ts +2 -1
  39. package/dist/plugins/ping/login.js +11 -1
  40. package/dist/plugins/ssh/index.d.ts +3 -2
  41. package/dist/plugins/ssh/index.js +65 -84
  42. package/dist/types/aws/oidc.d.ts +36 -0
  43. package/dist/types/aws/oidc.js +12 -0
  44. package/dist/types/oidc.d.ts +21 -0
  45. package/dist/types/request.d.ts +2 -7
  46. package/dist/types/ssh.d.ts +47 -0
  47. package/dist/types/ssh.js +5 -0
  48. package/package.json +4 -3
@@ -1,13 +1,74 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gcpRequestToSsh = void 0;
4
- const gcpRequestToSsh = (request) => {
5
- return {
6
- id: request.permission.spec.instanceName,
7
- projectId: request.permission.spec.projectId,
8
- zone: request.permission.spec.zone,
9
- linuxUserName: request.cliLocalData.linuxUserName,
10
- type: "gcloud",
11
- };
12
+ exports.gcpSshProvider = void 0;
13
+ /** Copyright © 2024-present P0 Security
14
+
15
+ This file is part of @p0security/cli
16
+
17
+ @p0security/cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
18
+
19
+ @p0security/cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
+
21
+ You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
22
+ **/
23
+ const ssh_1 = require("../../commands/shared/ssh");
24
+ const ssh_key_1 = require("./ssh-key");
25
+ /** Maximum number of attempts to start an SSH session
26
+ *
27
+ * The length of each attempt varies based on the type of error from a few seconds to < 1s
28
+ */
29
+ const MAX_SSH_RETRIES = 120;
30
+ exports.gcpSshProvider = {
31
+ requestToSsh: (request) => {
32
+ return {
33
+ id: request.permission.spec.instanceName,
34
+ projectId: request.permission.spec.projectId,
35
+ zone: request.permission.spec.zone,
36
+ linuxUserName: request.cliLocalData.linuxUserName,
37
+ type: "gcloud",
38
+ };
39
+ },
40
+ toCliRequest: (request, options) => __awaiter(void 0, void 0, void 0, function* () {
41
+ return (Object.assign(Object.assign({}, request), { cliLocalData: {
42
+ linuxUserName: yield (0, ssh_key_1.importSshKey)(request.permission.spec.publicKey, options),
43
+ } }));
44
+ }),
45
+ cloudProviderLogin: () => __awaiter(void 0, void 0, void 0, function* () { return undefined; }),
46
+ proxyCommand: (request) => {
47
+ return [
48
+ "gcloud",
49
+ "compute",
50
+ "start-iap-tunnel",
51
+ request.id,
52
+ "%p",
53
+ // --listen-on-stdin flag is required for interactive SSH session.
54
+ // It is undocumented on page https://cloud.google.com/sdk/gcloud/reference/compute/start-iap-tunnel
55
+ // but mention on page https://cloud.google.com/iap/docs/tcp-by-host
56
+ // and also found in `gcloud ssh --dry-run` output
57
+ "--listen-on-stdin",
58
+ `--zone=${request.zone}`,
59
+ `--project=${request.projectId}`,
60
+ ];
61
+ },
62
+ reproCommands: () => undefined,
63
+ preTestAccessPropagationArgs: (cmdArgs) => {
64
+ if ((0, ssh_1.isSudoCommand)(cmdArgs)) {
65
+ return Object.assign(Object.assign({}, cmdArgs), {
66
+ // `sudo -v` prints `Sorry, user <user> may not run sudo on <hostname>.` to stderr when user is not a sudoer.
67
+ // It prints nothing to stdout when user is a sudoer - which is important because we don't want any output from the pre-test.
68
+ command: "sudo", arguments: ["-v"] });
69
+ }
70
+ return undefined;
71
+ },
72
+ maxRetries: MAX_SSH_RETRIES,
73
+ friendlyName: "Google Cloud",
12
74
  };
13
- exports.gcpRequestToSsh = gcpRequestToSsh;
@@ -8,7 +8,8 @@ This file is part of @p0security/cli
8
8
 
9
9
  You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
10
10
  **/
11
- import { CliPermissionSpec, PermissionSpec } from "../../types/request";
11
+ import { PermissionSpec } from "../../types/request";
12
+ import { CliPermissionSpec } from "../../types/ssh";
12
13
  import { CommonSshPermissionSpec } from "../ssh/types";
13
14
  export declare type GcpSshPermission = {
14
15
  spec: CommonSshPermissionSpec & {
@@ -19,10 +20,17 @@ export declare type GcpSshPermission = {
19
20
  };
20
21
  type: "session";
21
22
  };
22
- export declare type GcpPermissionSpec = PermissionSpec<"ssh", GcpSshPermission>;
23
- export declare type GcpSsh = CliPermissionSpec<GcpPermissionSpec, {
23
+ export declare type GcpSshPermissionSpec = PermissionSpec<"ssh", GcpSshPermission>;
24
+ export declare type GcpSsh = CliPermissionSpec<GcpSshPermissionSpec, {
24
25
  linuxUserName: string;
25
26
  }>;
27
+ export declare type GcpSshRequest = {
28
+ linuxUserName: string;
29
+ projectId: string;
30
+ zone: string;
31
+ id: string;
32
+ type: "gcloud";
33
+ };
26
34
  declare type PosixAccount = {
27
35
  username: string;
28
36
  uid: string;
@@ -10,4 +10,7 @@ You should have received a copy of the GNU General Public License along with @p0
10
10
  **/
11
11
  import { TokenResponse } from "../types/oidc";
12
12
  import { OrgData } from "../types/org";
13
+ declare const loginPlugins: readonly ["google", "okta", "ping", "oidc-pkce", "microsoft", "azure-oidc", "google-oidc", "aws-oidc"];
14
+ export declare type LoginPluginType = (typeof loginPlugins)[number];
13
15
  export declare const pluginLoginMap: Record<string, (org: OrgData) => Promise<TokenResponse>>;
16
+ export {};
@@ -13,6 +13,16 @@ exports.pluginLoginMap = void 0;
13
13
  const login_1 = require("./google/login");
14
14
  const login_2 = require("./okta/login");
15
15
  const login_3 = require("./ping/login");
16
+ const loginPlugins = [
17
+ "google",
18
+ "okta",
19
+ "ping",
20
+ "oidc-pkce",
21
+ "microsoft",
22
+ "azure-oidc",
23
+ "google-oidc",
24
+ "aws-oidc",
25
+ ];
16
26
  exports.pluginLoginMap = {
17
27
  google: login_1.googleLogin,
18
28
  okta: login_2.oktaLogin,
@@ -1,5 +1,36 @@
1
- import { TokenResponse } from "../../types/oidc";
1
+ import { AuthorizeResponse, OidcLoginSteps } from "../../types/oidc";
2
2
  import { OrgData } from "../../types/org";
3
+ export declare const DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
3
4
  export declare const validateProviderDomain: (org: OrgData) => void;
5
+ /** Executes the first step of a device-authorization grant flow */
6
+ export declare const authorize: <T>(request: {
7
+ url: string;
8
+ init: RequestInit;
9
+ }, validateResponse: (response: Response) => Promise<Response>) => Promise<T>;
10
+ /** Attempts to fetch this device's OIDC token
11
+ *
12
+ * The authorization may or may not be granted at this stage. If it is not, the
13
+ * authorization server will return "authorization_pending", in which case this
14
+ * function will return undefined.
15
+ */
16
+ export declare const fetchOidcToken: <T>(request: {
17
+ url: string;
18
+ init: RequestInit;
19
+ }) => Promise<T | undefined>;
20
+ /** Waits until user device authorization is complete
21
+ *
22
+ * Returns the OIDC token after completion.
23
+ */
24
+ export declare const waitForActivation: <A, T>(authorize: A, extractExpiryInterval: (authorize: A) => {
25
+ expires_in: number;
26
+ interval: number;
27
+ }, tokenRequest: {
28
+ url: string;
29
+ init: RequestInit;
30
+ }) => Promise<NonNullable<Awaited<T>>>;
31
+ export declare const oidcLoginSteps: (org: OrgData, scope: string, urls: () => {
32
+ deviceAuthorizationUrl: string;
33
+ tokenUrl: string;
34
+ }) => OidcLoginSteps<AuthorizeResponse>;
4
35
  /** Logs in to an Identity Provider via OIDC */
5
- export declare const oidcLogin: (org: OrgData, scope: string) => Promise<TokenResponse>;
36
+ export declare const oidcLogin: <A, T>(steps: OidcLoginSteps<A>) => Promise<NonNullable<Awaited<T>>>;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.oidcLogin = exports.validateProviderDomain = void 0;
15
+ exports.oidcLogin = exports.oidcLoginSteps = exports.waitForActivation = exports.fetchOidcToken = exports.authorize = exports.validateProviderDomain = exports.DEVICE_GRANT_TYPE = void 0;
16
16
  /** Copyright © 2024-present P0 Security
17
17
 
18
18
  This file is part of @p0security/cli
@@ -27,107 +27,147 @@ const oidc_1 = require("../../common/auth/oidc");
27
27
  const fetch_1 = require("../../common/fetch");
28
28
  const stdio_1 = require("../../drivers/stdio");
29
29
  const util_1 = require("../../util");
30
- const lodash_1 = require("lodash");
31
30
  const open_1 = __importDefault(require("open"));
32
- const DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
31
+ exports.DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
33
32
  const validateProviderDomain = (org) => {
34
33
  if (!org.providerDomain)
35
34
  throw "Login requires a configured provider domain.";
36
35
  };
37
36
  exports.validateProviderDomain = validateProviderDomain;
37
+ const oidcProviderLabels = (providerType) => {
38
+ switch (providerType) {
39
+ case "okta":
40
+ return "Okta";
41
+ case "ping":
42
+ return "PingOne";
43
+ case "google":
44
+ case "google-oidc":
45
+ return "Google";
46
+ case "oidc-pkce":
47
+ return "OIDC";
48
+ case "aws-oidc":
49
+ return "AWS";
50
+ case "azure-oidc":
51
+ case "microsoft":
52
+ return "Entra ID";
53
+ default:
54
+ (0, util_1.throwAssertNever)(providerType);
55
+ }
56
+ throw "Invalid provider type";
57
+ };
38
58
  /** Executes the first step of a device-authorization grant flow */
39
59
  // cf. https://developer.okta.com/docs/guides/device-authorization-grant/main/
40
- const authorize = (org, scope) => __awaiter(void 0, void 0, void 0, function* () {
41
- if (org.providerType === undefined) {
42
- throw "Login requires a configured provider type.";
43
- }
44
- const init = {
45
- method: "POST",
46
- headers: oidc_1.OIDC_HEADERS,
47
- body: (0, fetch_1.urlEncode)({
48
- client_id: org.clientId,
49
- scope,
50
- }),
51
- };
52
- (0, exports.validateProviderDomain)(org);
53
- // This is the "org" authorization server; the okta.apps.* scopes are not
54
- // available with custom authorization servers
55
- const url = org.providerType === "okta"
56
- ? `https:${org.providerDomain}/oauth2/v1/device/authorize`
57
- : org.providerType === "ping"
58
- ? `https://${org.providerDomain}/${org.environmentId}/as/device_authorization`
59
- : (0, util_1.throwAssertNever)(org.providerType);
60
+ const authorize = (request, validateResponse) => __awaiter(void 0, void 0, void 0, function* () {
61
+ const { url, init } = request;
60
62
  const response = yield fetch(url, init);
61
- yield (0, fetch_1.validateResponse)(response);
63
+ yield validateResponse(response);
62
64
  return (yield response.json());
63
65
  });
66
+ exports.authorize = authorize;
64
67
  /** Attempts to fetch this device's OIDC token
65
68
  *
66
69
  * The authorization may or may not be granted at this stage. If it is not, the
67
70
  * authorization server will return "authorization_pending", in which case this
68
71
  * function will return undefined.
69
72
  */
70
- const fetchOidcToken = (org, authorize) => __awaiter(void 0, void 0, void 0, function* () {
71
- if (org.providerType === undefined) {
72
- throw "Login requires a configured provider type.";
73
- }
74
- const init = {
75
- method: "POST",
76
- headers: oidc_1.OIDC_HEADERS,
77
- body: (0, fetch_1.urlEncode)({
78
- client_id: org.clientId,
79
- device_code: authorize.device_code,
80
- grant_type: DEVICE_GRANT_TYPE,
81
- }),
82
- };
83
- (0, exports.validateProviderDomain)(org);
84
- const url = org.providerType === "okta"
85
- ? `https:${org.providerDomain}/oauth2/v1/token`
86
- : org.providerType === "ping"
87
- ? `https://${org.providerDomain}/${org.environmentId}/as/token`
88
- : (0, util_1.throwAssertNever)(org.providerType);
73
+ const fetchOidcToken = (request) => __awaiter(void 0, void 0, void 0, function* () {
74
+ const { url, init } = request;
89
75
  const response = yield fetch(url, init);
90
76
  if (!response.ok) {
91
77
  if (response.status === 400) {
92
78
  const data = yield response.json();
93
79
  if (data.error === "authorization_pending")
94
80
  return undefined;
81
+ if (data.error === "access_denied")
82
+ throw "Access denied, try again";
95
83
  }
96
84
  yield (0, fetch_1.validateResponse)(response);
97
85
  }
98
86
  return (yield response.json());
99
87
  });
88
+ exports.fetchOidcToken = fetchOidcToken;
100
89
  /** Waits until user device authorization is complete
101
90
  *
102
91
  * Returns the OIDC token after completion.
103
92
  */
104
- const waitForActivation = (org, authorize) => __awaiter(void 0, void 0, void 0, function* () {
93
+ const waitForActivation = (authorize, extractExpiryInterval, // Aws implementation differs from standard OIDC response, need function to extract expiry
94
+ tokenRequest) => __awaiter(void 0, void 0, void 0, function* () {
105
95
  const start = Date.now();
106
- while (Date.now() - start <= authorize.expires_in * 1e3) {
107
- const response = yield fetchOidcToken(org, authorize);
96
+ const { expires_in, interval } = extractExpiryInterval(authorize);
97
+ while (Date.now() - start <= expires_in * 1e3) {
98
+ const response = yield (0, exports.fetchOidcToken)(tokenRequest);
108
99
  if (!response)
109
- yield (0, util_1.sleep)(authorize.interval * 1e3);
100
+ yield (0, util_1.sleep)(interval * 1e3);
110
101
  else
111
102
  return response;
112
103
  }
113
104
  throw "Expired awaiting in-browser authorization.";
114
105
  });
115
- /** Logs in to an Identity Provider via OIDC */
116
- const oidcLogin = (org, scope) => __awaiter(void 0, void 0, void 0, function* () {
106
+ exports.waitForActivation = waitForActivation;
107
+ const oidcLoginSteps = (org, scope, urls) => {
108
+ const { deviceAuthorizationUrl, tokenUrl } = urls();
117
109
  if (org.providerType === undefined) {
118
- throw "Login requires a configured provider type.";
110
+ throw "Your organization's login configuration does not support this access. Your P0 admin will need to install a supported OIDC provider in order for you to use this command.";
119
111
  }
120
- const authorizeResponse = yield authorize(org, scope);
112
+ const buildOidcAuthorizeRequest = () => {
113
+ (0, exports.validateProviderDomain)(org);
114
+ return {
115
+ init: {
116
+ method: "POST",
117
+ headers: oidc_1.OIDC_HEADERS,
118
+ body: (0, fetch_1.urlEncode)({
119
+ client_id: org.clientId,
120
+ scope,
121
+ }),
122
+ },
123
+ url: deviceAuthorizationUrl,
124
+ };
125
+ };
126
+ const buildOidcTokenRequest = (authorize) => {
127
+ (0, exports.validateProviderDomain)(org);
128
+ return {
129
+ url: tokenUrl,
130
+ init: {
131
+ method: "POST",
132
+ headers: oidc_1.OIDC_HEADERS,
133
+ body: (0, fetch_1.urlEncode)({
134
+ client_id: org.clientId,
135
+ device_code: authorize.device_code,
136
+ grant_type: exports.DEVICE_GRANT_TYPE,
137
+ }),
138
+ },
139
+ };
140
+ };
141
+ return {
142
+ providerType: org.providerType,
143
+ validateResponse: fetch_1.validateResponse,
144
+ buildAuthorizeRequest: buildOidcAuthorizeRequest,
145
+ buildTokenRequest: buildOidcTokenRequest,
146
+ processAuthzExpiry: (authorize) => ({
147
+ expires_in: authorize.expires_in,
148
+ interval: authorize.interval,
149
+ }),
150
+ processAuthzResponse: (authorize) => ({
151
+ user_code: authorize.user_code,
152
+ verification_uri_complete: authorize.verification_uri_complete,
153
+ }),
154
+ };
155
+ };
156
+ exports.oidcLoginSteps = oidcLoginSteps;
157
+ /** Logs in to an Identity Provider via OIDC */
158
+ const oidcLogin = (steps) => __awaiter(void 0, void 0, void 0, function* () {
159
+ const { providerType, buildAuthorizeRequest, buildTokenRequest, processAuthzExpiry, processAuthzResponse, validateResponse, } = steps;
160
+ const deviceAuthorizationResponse = yield (0, exports.authorize)(buildAuthorizeRequest(), validateResponse);
161
+ const { user_code, verification_uri_complete } = processAuthzResponse(deviceAuthorizationResponse);
121
162
  (0, stdio_1.print2)(`Please use the opened browser window to continue your P0 login.
122
-
123
- When prompted, confirm that ${(0, lodash_1.capitalize)(org.providerType)} displays this code:
124
-
125
- ${authorizeResponse.user_code}
126
163
 
127
- Waiting for authorization...
128
- `);
129
- void (0, open_1.default)(authorizeResponse.verification_uri_complete);
130
- const oidcResponse = yield waitForActivation(org, authorizeResponse);
131
- return oidcResponse;
164
+ When prompted, confirm that ${oidcProviderLabels(providerType)} displays this code:
165
+
166
+ ${user_code}
167
+
168
+ Waiting for authorization...
169
+ `);
170
+ void (0, open_1.default)(verification_uri_complete);
171
+ return yield (0, exports.waitForActivation)(deviceAuthorizationResponse, processAuthzExpiry, buildTokenRequest(deviceAuthorizationResponse));
132
172
  });
133
173
  exports.oidcLogin = oidcLogin;
@@ -1,5 +1,5 @@
1
1
  import { Authn } from "../../types/identity";
2
2
  export declare const assumeRoleWithOktaSaml: (authn: Authn, args: {
3
- account?: string;
3
+ accountId?: string;
4
4
  role: string;
5
5
  }) => Promise<import("../aws/types").AwsCredentials>;
@@ -24,8 +24,8 @@ const role_1 = require("../../commands/aws/role");
24
24
  const auth_1 = require("../../drivers/auth");
25
25
  const assumeRole_1 = require("../aws/assumeRole");
26
26
  const assumeRoleWithOktaSaml = (authn, args) => __awaiter(void 0, void 0, void 0, function* () {
27
- return yield (0, auth_1.cached)(`aws-okta-${args.account}-${args.role}`, () => __awaiter(void 0, void 0, void 0, function* () {
28
- const { account, config, samlResponse } = yield (0, role_1.initOktaSaml)(authn, args.account);
27
+ return yield (0, auth_1.cached)(`aws-okta-${args.accountId}-${args.role}`, () => __awaiter(void 0, void 0, void 0, function* () {
28
+ const { account, config, samlResponse } = yield (0, role_1.initOktaSaml)(authn, args.accountId);
29
29
  const { roles } = (0, role_1.rolesFromSaml)(account, samlResponse);
30
30
  if (!roles.includes(args.role))
31
31
  throw `Role not available. Available roles:\n${roles.map((r) => ` ${r}`).join("\n")}`;
@@ -66,7 +66,17 @@ const fetchSamlResponse = (org, { access_token }) => __awaiter(void 0, void 0, v
66
66
  return samlInput === null || samlInput === void 0 ? void 0 : samlInput.value;
67
67
  });
68
68
  /** Logs in to Okta via OIDC */
69
- const oktaLogin = (org) => __awaiter(void 0, void 0, void 0, function* () { return (0, login_1.oidcLogin)(org, "openid email profile okta.apps.sso"); });
69
+ const oktaLogin = (org) => __awaiter(void 0, void 0, void 0, function* () {
70
+ return (0, login_1.oidcLogin)((0, login_1.oidcLoginSteps)(org, "openid email profile okta.apps.sso", () => {
71
+ if (org.providerType !== "okta") {
72
+ throw `Invalid provider type ${org.providerType} (expected "okta")`;
73
+ }
74
+ return {
75
+ deviceAuthorizationUrl: `https://${org.providerDomain}/oauth2/v1/device/authorize`,
76
+ tokenUrl: `https://${org.providerDomain}/oauth2/v1/token`,
77
+ };
78
+ }));
79
+ });
70
80
  exports.oktaLogin = oktaLogin;
71
81
  /** Retrieves a SAML response for an okta app */
72
82
  // TODO: Inject Okta app
@@ -8,6 +8,7 @@ This file is part of @p0security/cli
8
8
 
9
9
  You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
10
10
  **/
11
+ import { TokenResponse } from "../../types/oidc";
11
12
  import { OrgData } from "../../types/org";
12
13
  /** Logs in to PingOne via OIDC */
13
- export declare const pingLogin: (org: OrgData) => Promise<import("../../types/oidc").TokenResponse>;
14
+ export declare const pingLogin: (org: OrgData) => Promise<TokenResponse>;
@@ -12,5 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.pingLogin = void 0;
13
13
  const login_1 = require("../oidc/login");
14
14
  /** Logs in to PingOne via OIDC */
15
- const pingLogin = (org) => __awaiter(void 0, void 0, void 0, function* () { return (0, login_1.oidcLogin)(org, "openid email profile"); });
15
+ const pingLogin = (org) => __awaiter(void 0, void 0, void 0, function* () {
16
+ return (0, login_1.oidcLogin)((0, login_1.oidcLoginSteps)(org, "openid email profile", () => {
17
+ if (org.providerType !== "ping" || org.providerType === undefined) {
18
+ throw `Invalid provider type ${org.providerType} (expected "ping")`;
19
+ }
20
+ return {
21
+ deviceAuthorizationUrl: `https://${org.providerDomain}/${org.environmentId}/as/device_authorization`,
22
+ tokenUrl: `https://${org.providerDomain}/${org.environmentId}/as/token`,
23
+ };
24
+ }));
25
+ });
16
26
  exports.pingLogin = pingLogin;
@@ -8,6 +8,7 @@ This file is part of @p0security/cli
8
8
 
9
9
  You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
10
10
  **/
11
- import { ScpCommandArgs, SshCommandArgs, SshRequest } from "../../commands/shared";
11
+ import { CommandArgs } from "../../commands/shared/ssh";
12
12
  import { Authn } from "../../types/identity";
13
- export declare const sshOrScp: (authn: Authn, data: SshRequest, cmdArgs: ScpCommandArgs | SshCommandArgs, privateKey: string) => Promise<number | null>;
13
+ import { SshRequest } from "../../types/ssh";
14
+ export declare const sshOrScp: (authn: Authn, request: SshRequest, cmdArgs: CommandArgs, privateKey: string) => Promise<number | null>;