opal-security 3.1.1-beta.778ef29 → 3.1.1-beta.7e1cc21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -26
- package/lib/commands/login.js +6 -2
- package/lib/commands/request/create.d.ts +6 -1
- package/lib/commands/request/create.js +63 -19
- package/lib/commands/request/get.d.ts +7 -2
- package/lib/commands/request/get.js +105 -7
- package/lib/commands/request/list.d.ts +8 -2
- package/lib/commands/request/list.js +112 -8
- package/lib/commands/whoami.d.ts +8 -0
- package/lib/commands/whoami.js +34 -0
- package/lib/graphql/gql.d.ts +37 -2
- package/lib/graphql/gql.js +8 -1
- package/lib/graphql/graphql.d.ts +426 -118
- package/lib/graphql/graphql.js +2057 -208
- package/lib/lib/apollo.js +3 -4
- package/lib/lib/credentials/index.d.ts +2 -1
- package/lib/lib/credentials/index.js +2 -1
- package/lib/lib/flags.js +1 -1
- package/lib/lib/requests.d.ts +45 -14
- package/lib/lib/requests.js +919 -115
- package/lib/utils/displays.d.ts +8 -3
- package/lib/utils/displays.js +199 -45
- package/oclif.manifest.json +167 -46
- package/package.json +4 -1
package/lib/lib/apollo.js
CHANGED
|
@@ -155,7 +155,7 @@ const initClient = async (command, fetchAccessToken = true) => {
|
|
|
155
155
|
return response;
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
|
-
const errorLink = (0, error_1.onError)(({ networkError, operation }) => {
|
|
158
|
+
const errorLink = (0, error_1.onError)(({ networkError, operation, forward }) => {
|
|
159
159
|
var _a;
|
|
160
160
|
// There's a few GQL operations where we don't want to use this error handler:
|
|
161
161
|
const customErrorOperations = [
|
|
@@ -186,7 +186,7 @@ const initClient = async (command, fetchAccessToken = true) => {
|
|
|
186
186
|
case 401: {
|
|
187
187
|
command.log("Your session is invalid or expired. Authenticating now...\n");
|
|
188
188
|
const loginCommand = new login_1.default([], command.config);
|
|
189
|
-
loginCommand.run().then(() => {
|
|
189
|
+
return (0, core_1.fromPromise)(loginCommand.run().then(() => {
|
|
190
190
|
if (cmd_1.mostRecentCommandTime && cmd_1.mostRecentCommand) {
|
|
191
191
|
const lastCommandReexecutionDuration = moment.duration(2, "minutes");
|
|
192
192
|
const lastCommandReexecutionDurationHasElapsed = cmd_1.mostRecentCommandTime.add(lastCommandReexecutionDuration) >
|
|
@@ -195,8 +195,7 @@ const initClient = async (command, fetchAccessToken = true) => {
|
|
|
195
195
|
cmd_1.mostRecentCommand.run();
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
});
|
|
199
|
-
break;
|
|
198
|
+
})).flatMap(() => forward(operation));
|
|
200
199
|
}
|
|
201
200
|
default:
|
|
202
201
|
return (0, exports.handleError)(command, `Received status code ${networkError.statusCode} from server${errorMessage ? ` with message "${errorMessage}"` : ""}`);
|
|
@@ -5,12 +5,13 @@ interface OpalCredentials {
|
|
|
5
5
|
clientIDCandidate?: string;
|
|
6
6
|
secret?: string;
|
|
7
7
|
secretType?: SecretType;
|
|
8
|
+
organizationName?: string;
|
|
8
9
|
}
|
|
9
10
|
export declare enum SecretType {
|
|
10
11
|
Cookie = "COOKIE",
|
|
11
12
|
ApiToken = "API_TOKEN"
|
|
12
13
|
}
|
|
13
|
-
export declare const setOpalCredentials: (command: Command, email: string | undefined, organizationID: string, clientIDCandidate: string | undefined | null, secret: string, secretType: SecretType) => Promise<void>;
|
|
14
|
+
export declare const setOpalCredentials: (command: Command, email: string | undefined, organizationID: string, clientIDCandidate: string | undefined | null, secret: string, secretType: SecretType, organizationName?: string) => Promise<void>;
|
|
14
15
|
export declare const getOpalCredentials: (command: Command, includeAuthSecret?: boolean) => Promise<OpalCredentials>;
|
|
15
16
|
export declare const removeOpalCredentials: (command: Command) => Promise<void>;
|
|
16
17
|
export {};
|
|
@@ -9,13 +9,14 @@ var SecretType;
|
|
|
9
9
|
SecretType["Cookie"] = "COOKIE";
|
|
10
10
|
SecretType["ApiToken"] = "API_TOKEN";
|
|
11
11
|
})(SecretType || (exports.SecretType = SecretType = {}));
|
|
12
|
-
const setOpalCredentials = async (command, email, organizationID, clientIDCandidate, secret, secretType) => {
|
|
12
|
+
const setOpalCredentials = async (command, email, organizationID, clientIDCandidate, secret, secretType, organizationName) => {
|
|
13
13
|
const givenEmail = email || "email-unset";
|
|
14
14
|
const configData = (0, config_1.getOrCreateConfigData)(command.config.configDir);
|
|
15
15
|
configData.creds = {
|
|
16
16
|
clientIDCandidate,
|
|
17
17
|
email,
|
|
18
18
|
organizationID,
|
|
19
|
+
organizationName,
|
|
19
20
|
secretType,
|
|
20
21
|
};
|
|
21
22
|
(0, config_1.writeConfigData)(command.config.configDir, configData);
|
package/lib/lib/flags.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.SHARED_FLAGS = {
|
|
|
7
7
|
id: core_1.Flags.string({
|
|
8
8
|
multiple: false,
|
|
9
9
|
char: "i",
|
|
10
|
-
description: "The Opal ID of the
|
|
10
|
+
description: "The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]",
|
|
11
11
|
}),
|
|
12
12
|
accessLevelRemoteId: core_1.Flags.string({
|
|
13
13
|
multiple: false,
|
package/lib/lib/requests.d.ts
CHANGED
|
@@ -1,22 +1,53 @@
|
|
|
1
1
|
import type { NormalizedCacheObject } from "@apollo/client/core";
|
|
2
2
|
import type { ApolloClient } from "@apollo/client/core/ApolloClient";
|
|
3
3
|
import type { Command } from "@oclif/core/lib/command";
|
|
4
|
-
|
|
4
|
+
import { type AppType, type ConnectionType, EntityType } from "../graphql/graphql";
|
|
5
|
+
type AppNode = {
|
|
6
|
+
appId: string;
|
|
5
7
|
appName: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
appType?: AppType | ConnectionType;
|
|
9
|
+
assets: Record<string, AssetNode>;
|
|
10
|
+
};
|
|
11
|
+
type AssetNode = {
|
|
12
|
+
assetId: string;
|
|
9
13
|
assetName: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
type: EntityType;
|
|
15
|
+
roles?: Record<string, RoleNode>;
|
|
16
|
+
};
|
|
17
|
+
type RoleNode = {
|
|
18
|
+
roleId: string;
|
|
13
19
|
roleName: string;
|
|
14
|
-
}
|
|
15
|
-
export type RequestMap =
|
|
20
|
+
};
|
|
21
|
+
export type RequestMap = Record<string, AppNode>;
|
|
22
|
+
export declare const DISPLAY_LABELS: Partial<Record<EntityType, string>>;
|
|
23
|
+
type DurationOption = {
|
|
24
|
+
durationInMinutes: number;
|
|
25
|
+
label: string;
|
|
26
|
+
};
|
|
27
|
+
type RequestDefaults = {
|
|
28
|
+
durationOptions?: DurationOption[];
|
|
29
|
+
recommendedDurationInMinutes?: number | null;
|
|
30
|
+
defaultDurationInMinutes?: number;
|
|
31
|
+
maxDurationInMinutes?: number | null;
|
|
32
|
+
requireSupportTicket?: boolean;
|
|
33
|
+
reasonOptional?: boolean;
|
|
34
|
+
requesterIsAdmin?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type RequestMetadata = {
|
|
37
|
+
requestMap: RequestMap;
|
|
38
|
+
requestDefaults: RequestDefaults;
|
|
39
|
+
durationLabel: string;
|
|
40
|
+
durationInMinutes?: number;
|
|
41
|
+
reason: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function initEmptyRequestMetadata(): RequestMetadata;
|
|
16
44
|
export declare function selectRequestableItems(cmd: Command, client: ApolloClient<NormalizedCacheObject>, requestMap: RequestMap): Promise<void>;
|
|
17
|
-
export declare function chooseAssets(cmd: Command, client: ApolloClient<NormalizedCacheObject>, appId: string, requestMap: RequestMap): Promise<void>;
|
|
18
|
-
export declare function chooseRoles(cmd: Command, client: ApolloClient<NormalizedCacheObject>, appId: string, assetId: string, requestMap: RequestMap): Promise<void>;
|
|
19
45
|
export declare function doneSelectingAssets(): Promise<boolean>;
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
46
|
+
export declare function setRequestDefaults(cmd: Command, client: ApolloClient<NormalizedCacheObject>, metadata: RequestMetadata): Promise<void>;
|
|
47
|
+
export declare function promptForReason(metadata: RequestMetadata): Promise<void>;
|
|
48
|
+
export declare function promptForExpiration(metadata: RequestMetadata): Promise<void>;
|
|
49
|
+
export declare function promptRequestSubmission(cmd: Command, metadata: RequestMetadata): Promise<boolean>;
|
|
50
|
+
export declare function submitFinalRequest(cmd: Command, client: ApolloClient<NormalizedCacheObject>, metadata: RequestMetadata): Promise<void>;
|
|
51
|
+
export declare function bypassRequestSelection(cmd: Command, client: ApolloClient<NormalizedCacheObject>, flagValue: string[], metadata: RequestMetadata): Promise<void>;
|
|
52
|
+
export declare function bypassDuration(cmd: Command, duration: number, metadata: RequestMetadata): void;
|
|
53
|
+
export {};
|