@transcend-io/cli 4.35.0 → 4.37.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/README.md +56 -0
- package/build/api-keys/generateCrossAccountApiKeys.d.ts +45 -0
- package/build/api-keys/generateCrossAccountApiKeys.d.ts.map +1 -0
- package/build/api-keys/generateCrossAccountApiKeys.js +90 -0
- package/build/api-keys/generateCrossAccountApiKeys.js.map +1 -0
- package/build/api-keys/index.d.ts +2 -0
- package/build/api-keys/index.d.ts.map +1 -0
- package/build/api-keys/index.js +14 -0
- package/build/api-keys/index.js.map +1 -0
- package/build/cli-generate-cross-account-api-keys.d.ts +3 -0
- package/build/cli-generate-cross-account-api-keys.d.ts.map +1 -0
- package/build/cli-generate-cross-account-api-keys.js +87 -0
- package/build/cli-generate-cross-account-api-keys.js.map +1 -0
- package/build/graphql/buildTranscendGraphQLClient.d.ts +8 -0
- package/build/graphql/buildTranscendGraphQLClient.d.ts.map +1 -1
- package/build/graphql/buildTranscendGraphQLClient.js +17 -4
- package/build/graphql/buildTranscendGraphQLClient.js.map +1 -1
- package/build/graphql/fetchApiKeys.d.ts +8 -0
- package/build/graphql/fetchApiKeys.d.ts.map +1 -1
- package/build/graphql/fetchApiKeys.js +23 -11
- package/build/graphql/fetchApiKeys.js.map +1 -1
- package/build/graphql/gqls/apiKey.d.ts +2 -0
- package/build/graphql/gqls/apiKey.d.ts.map +1 -1
- package/build/graphql/gqls/apiKey.js +19 -1
- package/build/graphql/gqls/apiKey.js.map +1 -1
- package/build/graphql/gqls/auth.d.ts +4 -0
- package/build/graphql/gqls/auth.d.ts.map +1 -0
- package/build/graphql/gqls/auth.js +45 -0
- package/build/graphql/gqls/auth.js.map +1 -0
- package/build/graphql/gqls/consentManager.d.ts +1 -1
- package/build/graphql/gqls/consentManager.d.ts.map +1 -1
- package/build/graphql/gqls/consentManager.js +6 -8
- package/build/graphql/gqls/consentManager.js.map +1 -1
- package/build/graphql/gqls/index.d.ts +1 -0
- package/build/graphql/gqls/index.d.ts.map +1 -1
- package/build/graphql/gqls/index.js +1 -0
- package/build/graphql/gqls/index.js.map +1 -1
- package/build/graphql/index.d.ts +3 -0
- package/build/graphql/index.d.ts.map +1 -1
- package/build/graphql/index.js +3 -0
- package/build/graphql/index.js.map +1 -1
- package/build/graphql/loginUser.d.ts +46 -0
- package/build/graphql/loginUser.d.ts.map +1 -0
- package/build/graphql/loginUser.js +51 -0
- package/build/graphql/loginUser.js.map +1 -0
- package/build/graphql/manageApiKeys.d.ts +31 -0
- package/build/graphql/manageApiKeys.d.ts.map +1 -0
- package/build/graphql/manageApiKeys.js +28 -0
- package/build/graphql/manageApiKeys.js.map +1 -0
- package/build/graphql/syncConfigurationToTranscend.d.ts.map +1 -1
- package/build/graphql/syncConfigurationToTranscend.js +7 -3
- package/build/graphql/syncConfigurationToTranscend.js.map +1 -1
- package/build/graphql/syncCookies.d.ts +18 -0
- package/build/graphql/syncCookies.d.ts.map +1 -0
- package/build/graphql/syncCookies.js +83 -0
- package/build/graphql/syncCookies.js.map +1 -0
- package/build/graphql/syncDataFlows.d.ts.map +1 -1
- package/build/graphql/syncDataFlows.js +6 -0
- package/build/graphql/syncDataFlows.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/tsbuildinfo +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -53,6 +53,10 @@
|
|
|
53
53
|
- [Authentication](#authentication-10)
|
|
54
54
|
- [Arguments](#arguments-10)
|
|
55
55
|
- [Usage](#usage-11)
|
|
56
|
+
- [tr-generate-api-keys](#tr-generate-api-keys)
|
|
57
|
+
- [Authentication](#authentication-11)
|
|
58
|
+
- [Arguments](#arguments-11)
|
|
59
|
+
- [Usage](#usage-12)
|
|
56
60
|
|
|
57
61
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
58
62
|
|
|
@@ -1068,3 +1072,55 @@ Specifying the backend URL, needed for US hosted backend infrastructure.
|
|
|
1068
1072
|
yarn tr-retry-request-data-silos --auth=$TRANSCEND_API_KEY --dataSiloId=70810f2e-cf90-43f6-9776-901a5950599f --actions=ACCESS \
|
|
1069
1073
|
--transcendUrl=https://api.us.transcend.io
|
|
1070
1074
|
```
|
|
1075
|
+
|
|
1076
|
+
### tr-generate-api-keys
|
|
1077
|
+
|
|
1078
|
+
This command allows for creating API keys across multiple Transcend instances. This is useful for customers that are managing many Transcend instances and need to regularly create, cycle or delete API keys across all of their instances. Unlike the other commands that rely on API key authentication, this command relies upon username/password authentication. This command will spit out the API keys into a [JSON file](./examples/api-keys.json), and that JSON file can be used in subsequent cli commands.
|
|
1079
|
+
|
|
1080
|
+
#### Authentication
|
|
1081
|
+
|
|
1082
|
+
In order to use this command, you will need to provide your email and password for the Transcend account. This command will only generate API keys for Transcend instances where you have the permission to "Manage API Keys".
|
|
1083
|
+
|
|
1084
|
+
#### Arguments
|
|
1085
|
+
|
|
1086
|
+
| Argument | Description | Type | Default | Required |
|
|
1087
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------ | ------------------------ | -------- |
|
|
1088
|
+
| email | The email address that you use to [log into Transcend](https://app.transcend.io/login). | string | N/A | true |
|
|
1089
|
+
| password | The password for your account login. | string | N/A | true |
|
|
1090
|
+
| apiKeyTitle | The title of the API key being generated or destroyed. | string | N/A | true |
|
|
1091
|
+
| file | The file where API keys should be written to. | string - file-path | N/A | true |
|
|
1092
|
+
| scopes | The list of [scopes](https://docs.transcend.io/docs/security/access-control#scopes) that should be given to the API key. | string[] | N/A | true |
|
|
1093
|
+
| deleteExistingApiKey | When true, if an API key exists with the specified "apiKeyTitle", the existing API key is deleted. When false, an error is thrown if API key already exists. | boolean | true | false |
|
|
1094
|
+
| createNewApiKey | When true, new API keys will be created. Set to false if you simply want to delete all API keys with a title. | boolean | true | false |
|
|
1095
|
+
| transcendUrl | URL of the Transcend backend. Use https://api.us.transcend.io for US hosting. | string - URL | https://api.transcend.io | false |
|
|
1096
|
+
|
|
1097
|
+
#### Usage
|
|
1098
|
+
|
|
1099
|
+
```sh
|
|
1100
|
+
yarn tr-generate-api-keys --email=test@transcend.io --password=$TRANSCEND_PASSWORD \
|
|
1101
|
+
--scopes="View Email Templates,View Data Map" --apiKeyTitle="CLI Usage Cross Instance Sync" -file=./working/auth.json
|
|
1102
|
+
```
|
|
1103
|
+
|
|
1104
|
+
Specifying the backend URL, needed for US hosted backend infrastructure.
|
|
1105
|
+
|
|
1106
|
+
```sh
|
|
1107
|
+
yarn tr-generate-api-keys --email=test@transcend.io --password=$TRANSCEND_PASSWORD \
|
|
1108
|
+
--scopes="View Email Templates,View Data Map" --apiKeyTitle="CLI Usage Cross Instance Sync" -file=./working/auth.json \
|
|
1109
|
+
--transcendUrl=https://api.us.transcend.io
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
Delete all API keys with a certain title.
|
|
1113
|
+
|
|
1114
|
+
```sh
|
|
1115
|
+
yarn tr-generate-api-keys --email=test@transcend.io --password=$TRANSCEND_PASSWORD \
|
|
1116
|
+
--scopes="View Email Templates,View Data Map" --apiKeyTitle="CLI Usage Cross Instance Sync" -file=./working/auth.json \
|
|
1117
|
+
--createNewApiKey=false
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
Throw error if an API key already exists with that title, default behavior is to delete the existing API key and create a new one with that same title.
|
|
1121
|
+
|
|
1122
|
+
```sh
|
|
1123
|
+
yarn tr-generate-api-keys --email=test@transcend.io --password=$TRANSCEND_PASSWORD \
|
|
1124
|
+
--scopes="View Email Templates,View Data Map" --apiKeyTitle="CLI Usage Cross Instance Sync" -file=./working/auth.json \
|
|
1125
|
+
--deleteExistingApiKey=false
|
|
1126
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ScopeName } from '@transcend-io/privacy-types';
|
|
2
|
+
export interface ApiKeyAndOrganization {
|
|
3
|
+
/** Name of instance */
|
|
4
|
+
organizationName: string;
|
|
5
|
+
/** API key */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** Organization ID API key is for */
|
|
8
|
+
organizationId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ApiKeyGenerateError {
|
|
11
|
+
/** Name of instance */
|
|
12
|
+
organizationName: string;
|
|
13
|
+
/** Error */
|
|
14
|
+
error: string;
|
|
15
|
+
/** Organization ID API key is for */
|
|
16
|
+
organizationId: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generate API keys across multiple transcend accounts
|
|
20
|
+
*
|
|
21
|
+
* @param options - Options
|
|
22
|
+
* @returns Number of API keys created
|
|
23
|
+
*/
|
|
24
|
+
export declare function generateCrossAccountApiKeys({ email, password, scopes, apiKeyTitle, deleteExistingApiKey, createNewApiKey, transcendUrl, }: {
|
|
25
|
+
/** Email address of user generating API keys */
|
|
26
|
+
email: string;
|
|
27
|
+
/** Password of user generating API keys */
|
|
28
|
+
password: string;
|
|
29
|
+
/** Title of the API create to create */
|
|
30
|
+
apiKeyTitle: string;
|
|
31
|
+
/** Title of the API create to create */
|
|
32
|
+
scopes: ScopeName[];
|
|
33
|
+
/** API URL for Transcend backend */
|
|
34
|
+
transcendUrl?: string;
|
|
35
|
+
/** When true delete existing API keys with that title, if set to false an API key exists with that title, an error is thrown */
|
|
36
|
+
deleteExistingApiKey?: boolean;
|
|
37
|
+
/** When true, generate new API keys, otherwise only will delete past API keys */
|
|
38
|
+
createNewApiKey?: boolean;
|
|
39
|
+
}): Promise<{
|
|
40
|
+
/** Successfully generated */
|
|
41
|
+
apiKeys: ApiKeyAndOrganization[];
|
|
42
|
+
/** Error results */
|
|
43
|
+
errors: ApiKeyGenerateError[];
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=generateCrossAccountApiKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateCrossAccountApiKeys.d.ts","sourceRoot":"","sources":["../../src/api-keys/generateCrossAccountApiKeys.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAIxD,MAAM,WAAW,qBAAqB;IACpC,uBAAuB;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,uBAAuB;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAAC,EAChD,KAAK,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,oBAA2B,EAC3B,eAAsB,EACtB,YAAyC,GAC1C,EAAE;IACD,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gIAAgI;IAChI,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,iFAAiF;IACjF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC;IACV,6BAA6B;IAC7B,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,oBAAoB;IACpB,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B,CAAC,CA8HD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateCrossAccountApiKeys = void 0;
|
|
7
|
+
const bluebird_1 = require("bluebird");
|
|
8
|
+
const graphql_1 = require("../graphql");
|
|
9
|
+
const colors_1 = __importDefault(require("colors"));
|
|
10
|
+
const logger_1 = require("../logger");
|
|
11
|
+
/**
|
|
12
|
+
* Generate API keys across multiple transcend accounts
|
|
13
|
+
*
|
|
14
|
+
* @param options - Options
|
|
15
|
+
* @returns Number of API keys created
|
|
16
|
+
*/
|
|
17
|
+
async function generateCrossAccountApiKeys({ email, password, scopes, apiKeyTitle, deleteExistingApiKey = true, createNewApiKey = true, transcendUrl = 'https://api.transcend.io', }) {
|
|
18
|
+
// Create GraphQL client
|
|
19
|
+
const client = await (0, graphql_1.buildTranscendGraphQLClientGeneric)(transcendUrl, {});
|
|
20
|
+
// Login the user
|
|
21
|
+
logger_1.logger.info(colors_1.default.magenta('Logging in using email and password.'));
|
|
22
|
+
const { roles, loginCookie } = await (0, graphql_1.loginUser)(client, { email, password });
|
|
23
|
+
logger_1.logger.info(colors_1.default.green(`Successfully logged in and found ${roles.length} role${roles.length === 1 ? '' : 's'}!`));
|
|
24
|
+
// Save cookie to call route subsequent times
|
|
25
|
+
client.setHeaders({
|
|
26
|
+
Cookie: loginCookie,
|
|
27
|
+
});
|
|
28
|
+
// Save the resulting API keys
|
|
29
|
+
const results = [];
|
|
30
|
+
const errors = [];
|
|
31
|
+
// Generate API keys
|
|
32
|
+
logger_1.logger.info(colors_1.default.magenta(`Generating API keys with title: ${apiKeyTitle}, scopes: ${scopes.join(',')}.`));
|
|
33
|
+
// Map over each role
|
|
34
|
+
await (0, bluebird_1.mapSeries)(roles, async (role) => {
|
|
35
|
+
try {
|
|
36
|
+
// Log into the other instance
|
|
37
|
+
await (0, graphql_1.assumeRole)(client, { roleId: role.id, email });
|
|
38
|
+
// Grab API keys with that title
|
|
39
|
+
logger_1.logger.info(colors_1.default.magenta(`Checking if API key already exists in organization "${role.organization.name}" with title: "${apiKeyTitle}".`));
|
|
40
|
+
// Delete existing API key
|
|
41
|
+
const [apiKeyWithTitle] = await (0, graphql_1.fetchAllApiKeys)(client, [apiKeyTitle]);
|
|
42
|
+
if (apiKeyWithTitle && deleteExistingApiKey) {
|
|
43
|
+
logger_1.logger.info(colors_1.default.yellow(`Deleting existing API key in "${role.organization.name}" with title: "${apiKeyTitle}".`));
|
|
44
|
+
await (0, graphql_1.deleteApiKey)(client, apiKeyWithTitle.id);
|
|
45
|
+
logger_1.logger.info(colors_1.default.green(`Successfully deleted API key in "${role.organization.name}" with title: "${apiKeyTitle}".`));
|
|
46
|
+
}
|
|
47
|
+
else if (apiKeyWithTitle) {
|
|
48
|
+
// throw error if one exists but not configured to delete
|
|
49
|
+
throw new Error(`API key already exists with title: "${apiKeyTitle}"`);
|
|
50
|
+
}
|
|
51
|
+
// Create the API key
|
|
52
|
+
if (createNewApiKey) {
|
|
53
|
+
logger_1.logger.info(colors_1.default.magenta(`Creating API key in "${role.organization.name}" with title: "${apiKeyTitle}".`));
|
|
54
|
+
const { apiKey } = await (0, graphql_1.createApiKey)(client, {
|
|
55
|
+
title: apiKeyTitle,
|
|
56
|
+
scopes,
|
|
57
|
+
});
|
|
58
|
+
results.push({
|
|
59
|
+
organizationName: role.organization.name,
|
|
60
|
+
organizationId: role.organization.id,
|
|
61
|
+
apiKey,
|
|
62
|
+
});
|
|
63
|
+
logger_1.logger.info(colors_1.default.green(`Successfully created API key in "${role.organization.name}" with title: "${apiKeyTitle}".`));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Delete only
|
|
67
|
+
results.push({
|
|
68
|
+
organizationName: role.organization.name,
|
|
69
|
+
organizationId: role.organization.id,
|
|
70
|
+
apiKey: '',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
logger_1.logger.error(colors_1.default.red(`Failed to create API key in organization "${role.organization.name}"! - ${err.message}`));
|
|
76
|
+
errors.push({
|
|
77
|
+
organizationName: role.organization.name,
|
|
78
|
+
organizationId: role.organization.id,
|
|
79
|
+
error: err.message,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
logger_1.logger.info(colors_1.default.green(`Successfully created ${results.length} API keys${results.length === 1 ? '' : 's'}`));
|
|
84
|
+
if (errors.length > 0) {
|
|
85
|
+
logger_1.logger.error(colors_1.default.red(`Failed to create ${errors.length} API key${errors.length === 1 ? '' : 's'}!`));
|
|
86
|
+
}
|
|
87
|
+
return { errors, apiKeys: results };
|
|
88
|
+
}
|
|
89
|
+
exports.generateCrossAccountApiKeys = generateCrossAccountApiKeys;
|
|
90
|
+
//# sourceMappingURL=generateCrossAccountApiKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateCrossAccountApiKeys.js","sourceRoot":"","sources":["../../src/api-keys/generateCrossAccountApiKeys.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAqC;AACrC,wCAOoB;AAEpB,oDAA4B;AAC5B,sCAAmC;AAoBnC;;;;;GAKG;AACI,KAAK,UAAU,2BAA2B,CAAC,EAChD,KAAK,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,oBAAoB,GAAG,IAAI,EAC3B,eAAe,GAAG,IAAI,EACtB,YAAY,GAAG,0BAA0B,GAgB1C;IAMC,wBAAwB;IACxB,MAAM,MAAM,GAAG,MAAM,IAAA,4CAAkC,EAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAE1E,iBAAiB;IACjB,eAAM,CAAC,IAAI,CAAC,gBAAM,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,CAAC;IACpE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,mBAAS,EAAC,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC5E,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,KAAK,CACV,oCAAoC,KAAK,CAAC,MAAM,QAC9C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c,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE;gBACpC,KAAK,EAAE,GAAG,CAAC,OAAO;aACnB,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;IACH,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,KAAK,CACV,wBAAwB,OAAO,CAAC,MAAM,YACpC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC9B,EAAE,CACH,CACF,CAAC;IAEF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACrB,eAAM,CAAC,KAAK,CACV,gBAAM,CAAC,GAAG,CACR,oBAAoB,MAAM,CAAC,MAAM,WAC/B,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC7B,GAAG,CACJ,CACF,CAAC;KACH;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC;AA1JD,kEA0JC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api-keys/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./generateCrossAccountApiKeys"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api-keys/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAA8C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-generate-cross-account-api-keys.d.ts","sourceRoot":"","sources":["../src/cli-generate-cross-account-api-keys.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
8
|
+
const colors_1 = __importDefault(require("colors"));
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const keyBy_1 = __importDefault(require("lodash/keyBy"));
|
|
11
|
+
const privacy_types_1 = require("@transcend-io/privacy-types");
|
|
12
|
+
const logger_1 = require("./logger");
|
|
13
|
+
const api_keys_1 = require("./api-keys");
|
|
14
|
+
const SCOPES_BY_TITLE = (0, keyBy_1.default)(Object.entries(privacy_types_1.TRANSCEND_SCOPES).map(([name, value]) => ({
|
|
15
|
+
...value,
|
|
16
|
+
name,
|
|
17
|
+
})), 'title');
|
|
18
|
+
const SCOPE_TITLES = Object.keys(SCOPES_BY_TITLE);
|
|
19
|
+
/**
|
|
20
|
+
* Create API keys with the same set of scopes across multiple Transcend instances
|
|
21
|
+
*
|
|
22
|
+
* Requires the username and password of user with access to multiple instances.
|
|
23
|
+
*
|
|
24
|
+
* Dev Usage:
|
|
25
|
+
* yarn ts-node ./src/cli-generate-cross-account-api-keys.ts --email=test@transcend.io --email=NE8pGp$s8Gm4Mzb5 \
|
|
26
|
+
* --apiKeyTitle="My Test Key" --scopes="View Email Templates,View Data Map" --file=./secrets.json
|
|
27
|
+
*
|
|
28
|
+
* Standard usage:
|
|
29
|
+
* yarn tr-generate-api-keys --email=test@transcend.io --password=NE8pGp$s8Gm4Mzb5 \
|
|
30
|
+
* --apiKeyTitle="My Test Key" --scopes="View Email Templates,View Data Map" --file=./secrets.json
|
|
31
|
+
*/
|
|
32
|
+
async function main() {
|
|
33
|
+
// Parse command line arguments
|
|
34
|
+
const { transcendUrl = 'https://api.transcend.io', file, email, password, apiKeyTitle, scopes, deleteExistingApiKey = 'true', createNewApiKey = 'true', } = (0, yargs_parser_1.default)(process.argv.slice(2));
|
|
35
|
+
// Ensure file is passed
|
|
36
|
+
if (!file) {
|
|
37
|
+
logger_1.logger.error(colors_1.default.red('A file must be provided. You can specify using --file=./secrets.json'));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
// Ensure email is passed
|
|
41
|
+
if (!email) {
|
|
42
|
+
logger_1.logger.error(colors_1.default.red('An email must be provided. You can specify using --email=asd123@test.com'));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
// Ensure password is passed
|
|
46
|
+
if (!password) {
|
|
47
|
+
logger_1.logger.error(colors_1.default.red('A password must be provided. You can specify using --password=asd123'));
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
// Ensure apiKeyTitle is passed
|
|
51
|
+
if (!apiKeyTitle) {
|
|
52
|
+
logger_1.logger.error(colors_1.default.red('An API key title must be provided. You can specify using --apiKeyTitle="My Title"'));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
// Ensure scopes is passed
|
|
56
|
+
if (!scopes) {
|
|
57
|
+
logger_1.logger.error(colors_1.default.red('Scopes must be provided. You can specify using --scopes="View Email Templates,View Data Map". ' +
|
|
58
|
+
`Expected one of: \n${SCOPE_TITLES.join('\n')}`));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
// Validate scopes
|
|
62
|
+
const splitScopes = scopes.split(',');
|
|
63
|
+
const invalidScopes = splitScopes.filter((scopeTitle) => !SCOPES_BY_TITLE[scopeTitle]);
|
|
64
|
+
if (invalidScopes.length > 0) {
|
|
65
|
+
logger_1.logger.error(colors_1.default.red(`Failed to parse scopes:"${invalidScopes.join(',')}".\n` +
|
|
66
|
+
`Expected one of: \n${SCOPE_TITLES.join('\n')}`));
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
const scopeNames = splitScopes.map((scopeTitle) => SCOPES_BY_TITLE[scopeTitle].name);
|
|
70
|
+
// Upload privacy requests
|
|
71
|
+
const { errors, apiKeys } = await (0, api_keys_1.generateCrossAccountApiKeys)({
|
|
72
|
+
transcendUrl,
|
|
73
|
+
password,
|
|
74
|
+
email,
|
|
75
|
+
deleteExistingApiKey: deleteExistingApiKey !== 'false',
|
|
76
|
+
createNewApiKey: createNewApiKey !== 'false',
|
|
77
|
+
apiKeyTitle,
|
|
78
|
+
scopes: scopeNames,
|
|
79
|
+
});
|
|
80
|
+
// Write to disk
|
|
81
|
+
(0, fs_1.writeFileSync)(file, `${JSON.stringify(apiKeys, null, 2)}\n`);
|
|
82
|
+
if (errors.length > 0) {
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
main();
|
|
87
|
+
//# sourceMappingURL=cli-generate-cross-account-api-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-generate-cross-account-api-keys.js","sourceRoot":"","sources":["../src/cli-generate-cross-account-api-keys.ts"],"names":[],"mappings":";;;;;;AAEA,gEAAiC;AACjC,oDAA4B;AAC5B,2BAAmC;AACnC,yDAAiC;AACjC,+DAA0E;AAE1E,qCAAkC;AAClC,yCAAyD;AAEzD,MAAM,eAAe,GAAG,IAAA,eAAK,EAC3B,MAAM,CAAC,OAAO,CA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;IAC7D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -3,6 +3,14 @@ import { GraphQLClient } from 'graphql-request';
|
|
|
3
3
|
* Create a GraphQL client
|
|
4
4
|
*
|
|
5
5
|
* @param transcendUrl - Transcend API URL
|
|
6
|
+
* @param headers - Request headers to include in each request
|
|
7
|
+
* @returns GraphQL client
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildTranscendGraphQLClientGeneric(transcendUrl: string, headers: Record<string, string>): GraphQLClient;
|
|
10
|
+
/**
|
|
11
|
+
* Create a GraphQL client capable of submitting requests with an API key
|
|
12
|
+
*
|
|
13
|
+
* @param transcendUrl - Transcend API URL
|
|
6
14
|
* @param auth - API key to authenticate to API
|
|
7
15
|
* @returns GraphQL client
|
|
8
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTranscendGraphQLClient.d.ts","sourceRoot":"","sources":["../../src/graphql/buildTranscendGraphQLClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,GACX,aAAa,
|
|
1
|
+
{"version":3,"file":"buildTranscendGraphQLClient.d.ts","sourceRoot":"","sources":["../../src/graphql/buildTranscendGraphQLClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CAChD,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,aAAa,CAUf;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,GACX,aAAa,CAIf"}
|
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildTranscendGraphQLClient = void 0;
|
|
3
|
+
exports.buildTranscendGraphQLClient = exports.buildTranscendGraphQLClientGeneric = void 0;
|
|
4
4
|
const graphql_request_1 = require("graphql-request");
|
|
5
5
|
/**
|
|
6
6
|
* Create a GraphQL client
|
|
7
7
|
*
|
|
8
8
|
* @param transcendUrl - Transcend API URL
|
|
9
|
-
* @param
|
|
9
|
+
* @param headers - Request headers to include in each request
|
|
10
10
|
* @returns GraphQL client
|
|
11
11
|
*/
|
|
12
|
-
function
|
|
12
|
+
function buildTranscendGraphQLClientGeneric(transcendUrl, headers) {
|
|
13
13
|
// Create a GraphQL client
|
|
14
14
|
// eslint-disable-next-line global-require
|
|
15
15
|
const { version } = require('../../package.json');
|
|
16
16
|
return new graphql_request_1.GraphQLClient(`${transcendUrl}/graphql`, {
|
|
17
17
|
headers: {
|
|
18
|
-
|
|
18
|
+
...headers,
|
|
19
19
|
version,
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
+
exports.buildTranscendGraphQLClientGeneric = buildTranscendGraphQLClientGeneric;
|
|
24
|
+
/**
|
|
25
|
+
* Create a GraphQL client capable of submitting requests with an API key
|
|
26
|
+
*
|
|
27
|
+
* @param transcendUrl - Transcend API URL
|
|
28
|
+
* @param auth - API key to authenticate to API
|
|
29
|
+
* @returns GraphQL client
|
|
30
|
+
*/
|
|
31
|
+
function buildTranscendGraphQLClient(transcendUrl, auth) {
|
|
32
|
+
return buildTranscendGraphQLClientGeneric(transcendUrl, {
|
|
33
|
+
Authorization: `Bearer ${auth}`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
23
36
|
exports.buildTranscendGraphQLClient = buildTranscendGraphQLClient;
|
|
24
37
|
//# sourceMappingURL=buildTranscendGraphQLClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTranscendGraphQLClient.js","sourceRoot":"","sources":["../../src/graphql/buildTranscendGraphQLClient.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;GAMG;AACH,SAAgB,
|
|
1
|
+
{"version":3,"file":"buildTranscendGraphQLClient.js","sourceRoot":"","sources":["../../src/graphql/buildTranscendGraphQLClient.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;GAMG;AACH,SAAgB,kCAAkC,CAChD,YAAoB,EACpB,OAA+B;IAE/B,0BAA0B;IAC1B,0CAA0C;IAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAClD,OAAO,IAAI,+BAAa,CAAC,GAAG,YAAY,UAAU,EAAE;QAClD,OAAO,EAAE;YACP,GAAG,OAAO;YACV,OAAO;SACR;KACF,CAAC,CAAC;AACL,CAAC;AAbD,gFAaC;AAED;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,YAAoB,EACpB,IAAY;IAEZ,OAAO,kCAAkC,CAAC,YAAY,EAAE;QACtD,aAAa,EAAE,UAAU,IAAI,EAAE;KAChC,CAAC,CAAC;AACL,CAAC;AAPD,kEAOC"}
|
|
@@ -6,6 +6,14 @@ export interface ApiKey {
|
|
|
6
6
|
/** Title of API key */
|
|
7
7
|
title: string;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Fetch all API keys in an organization
|
|
11
|
+
*
|
|
12
|
+
* @param client - Client
|
|
13
|
+
* @param titles - Filter on titles
|
|
14
|
+
* @returns API keys
|
|
15
|
+
*/
|
|
16
|
+
export declare function fetchAllApiKeys(client: GraphQLClient, titles?: string[]): Promise<ApiKey[]>;
|
|
9
17
|
/**
|
|
10
18
|
* Fetch all apiKeys and if any are found in the config that are
|
|
11
19
|
* missing, create those apiKeys.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchApiKeys.d.ts","sourceRoot":"","sources":["../../src/graphql/fetchApiKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,WAAW,MAAM;IACrB,oBAAoB;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAMD;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,EACE,UAAU,EAAE,YAAiB,EAC7B,YAAY,EAAE,SAAc,GAC7B,EAAE,cAAc,EACjB,MAAM,EAAE,aAAa,EACrB,QAAQ,UAAQ,GACf,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,GAAG,MAAM;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"fetchApiKeys.d.ts","sourceRoot":"","sources":["../../src/graphql/fetchApiKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,WAAW,MAAM;IACrB,oBAAoB;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAMD;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,EACE,UAAU,EAAE,YAAiB,EAC7B,YAAY,EAAE,SAAc,GAC7B,EAAE,cAAc,EACjB,MAAM,EAAE,aAAa,EACrB,QAAQ,UAAQ,GACf,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,GAAG,MAAM;CAAE,CAAC,CAiCpC"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchApiKeys = void 0;
|
|
6
|
+
exports.fetchApiKeys = exports.fetchAllApiKeys = void 0;
|
|
7
7
|
const gqls_1 = require("./gqls");
|
|
8
8
|
const keyBy_1 = __importDefault(require("lodash/keyBy"));
|
|
9
9
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
@@ -14,17 +14,13 @@ const makeGraphQLRequest_1 = require("./makeGraphQLRequest");
|
|
|
14
14
|
const PAGE_SIZE = 20;
|
|
15
15
|
const ADMIN_LINK = 'https://app.transcend.io/infrastructure/api-keys';
|
|
16
16
|
/**
|
|
17
|
-
* Fetch all
|
|
18
|
-
* missing, create those apiKeys.
|
|
17
|
+
* Fetch all API keys in an organization
|
|
19
18
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
23
|
-
* @returns A map from apiKey title to Identifier
|
|
19
|
+
* @param client - Client
|
|
20
|
+
* @param titles - Filter on titles
|
|
21
|
+
* @returns API keys
|
|
24
22
|
*/
|
|
25
|
-
async function
|
|
26
|
-
logger_1.logger.info(colors_1.default.magenta(`Fetching ${fetchAll ? 'all' : apiKeyInputs.length} API keys...`));
|
|
27
|
-
const titles = apiKeyInputs.map(({ title }) => title);
|
|
23
|
+
async function fetchAllApiKeys(client, titles) {
|
|
28
24
|
const apiKeys = [];
|
|
29
25
|
let offset = 0;
|
|
30
26
|
// Paginate
|
|
@@ -35,12 +31,28 @@ async function fetchApiKeys({ 'api-keys': apiKeyInputs = [], 'data-silos': dataS
|
|
|
35
31
|
} = await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.API_KEYS, {
|
|
36
32
|
first: PAGE_SIZE,
|
|
37
33
|
offset,
|
|
38
|
-
titles
|
|
34
|
+
titles,
|
|
39
35
|
});
|
|
40
36
|
apiKeys.push(...nodes);
|
|
41
37
|
offset += PAGE_SIZE;
|
|
42
38
|
shouldContinue = nodes.length === PAGE_SIZE;
|
|
43
39
|
} while (shouldContinue);
|
|
40
|
+
return apiKeys;
|
|
41
|
+
}
|
|
42
|
+
exports.fetchAllApiKeys = fetchAllApiKeys;
|
|
43
|
+
/**
|
|
44
|
+
* Fetch all apiKeys and if any are found in the config that are
|
|
45
|
+
* missing, create those apiKeys.
|
|
46
|
+
*
|
|
47
|
+
* @param apiKeyInputs - API keys to fetch metadata on
|
|
48
|
+
* @param client - GraphQL client
|
|
49
|
+
* @param fetchAll - When true, fetch all API keys
|
|
50
|
+
* @returns A map from apiKey title to Identifier
|
|
51
|
+
*/
|
|
52
|
+
async function fetchApiKeys({ 'api-keys': apiKeyInputs = [], 'data-silos': dataSilos = [], }, client, fetchAll = false) {
|
|
53
|
+
logger_1.logger.info(colors_1.default.magenta(`Fetching ${fetchAll ? 'all' : apiKeyInputs.length} API keys...`));
|
|
54
|
+
const titles = apiKeyInputs.map(({ title }) => title);
|
|
55
|
+
const apiKeys = await fetchAllApiKeys(client, fetchAll ? undefined : titles);
|
|
44
56
|
// Create a map
|
|
45
57
|
const apiKeysByTitle = (0, keyBy_1.default)(apiKeys, 'title');
|
|
46
58
|
// Determine expected set of apiKeys expected
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchApiKeys.js","sourceRoot":"","sources":["../../src/graphql/fetchApiKeys.ts"],"names":[],"mappings":";;;;;;AACA,iCAAkC;AAClC,yDAAiC;AACjC,uDAA+B;AAC/B,mEAA2C;AAC3C,sCAAmC;AACnC,oDAA4B;AAE5B,6DAA0D;AAS1D,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAM,UAAU,GAAG,kDAAkD,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"fetchApiKeys.js","sourceRoot":"","sources":["../../src/graphql/fetchApiKeys.ts"],"names":[],"mappings":";;;;;;AACA,iCAAkC;AAClC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AC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAE7E,eAAe;IACf,MAAM,cAAc,GAAG,IAAA,eAAK,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE/C,6CAA6C;IAC7C,MAAM,oBAAoB,GAAG,IAAA,cAAI,EAC/B,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAClE,CAAC;IACF,MAAM,cAAc,GAAG,IAAA,oBAAU,EAC/B,oBAAoB,EACpB,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAClC,CAAC;IAEF,+CAA+C;IAC/C,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,GAAG,CACR,4BAA4B,cAAc,CAAC,IAAI,CAC7C,MAAM,CACP,+CAA+C,UAAU,EAAE,CAC7D,CACF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAxCD,oCAwCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiKey.d.ts","sourceRoot":"","sources":["../../../src/graphql/gqls/apiKey.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,QASpB,CAAC"}
|
|
1
|
+
{"version":3,"file":"apiKey.d.ts","sourceRoot":"","sources":["../../../src/graphql/gqls/apiKey.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,QASpB,CAAC;AAEF,eAAO,MAAM,cAAc,QAU1B,CAAC;AAEF,eAAO,MAAM,cAAc,QAM1B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.API_KEYS = void 0;
|
|
3
|
+
exports.DELETE_API_KEY = exports.CREATE_API_KEY = exports.API_KEYS = void 0;
|
|
4
4
|
const graphql_request_1 = require("graphql-request");
|
|
5
5
|
exports.API_KEYS = (0, graphql_request_1.gql) `
|
|
6
6
|
query TranscendCliApiKeys($first: Int!, $offset: Int!, $titles: [String!]) {
|
|
@@ -12,4 +12,22 @@ exports.API_KEYS = (0, graphql_request_1.gql) `
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
`;
|
|
15
|
+
exports.CREATE_API_KEY = (0, graphql_request_1.gql) `
|
|
16
|
+
mutation TranscendCliCreateApiKey($input: ApiKeyInput!) {
|
|
17
|
+
createApiKey(input: $input) {
|
|
18
|
+
apiKey {
|
|
19
|
+
id
|
|
20
|
+
apiKey
|
|
21
|
+
title
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
exports.DELETE_API_KEY = (0, graphql_request_1.gql) `
|
|
27
|
+
mutation TranscendCliDeleteApiKey($id: ID!) {
|
|
28
|
+
deleteApiKey(id: $id) {
|
|
29
|
+
clientMutationId
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
15
33
|
//# sourceMappingURL=apiKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiKey.js","sourceRoot":"","sources":["../../../src/graphql/gqls/apiKey.ts"],"names":[],"mappings":";;;AAAA,qDAAsC;AAEzB,QAAA,QAAQ,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;CAS1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"apiKey.js","sourceRoot":"","sources":["../../../src/graphql/gqls/apiKey.ts"],"names":[],"mappings":";;;AAAA,qDAAsC;AAEzB,QAAA,QAAQ,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;CAS1B,CAAC;AAEW,QAAA,cAAc,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;CAUhC,CAAC;AAEW,QAAA,cAAc,GAAG,IAAA,qBAAG,EAAA;;;;;;CAMhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/graphql/gqls/auth.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,QASlC,CAAC;AAEF,eAAO,MAAM,KAAK,QAsBjB,CAAC;AAEF,eAAO,MAAM,WAAW,QAMvB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ASSUME_ROLE = exports.LOGIN = exports.DETERMINE_LOGIN_METHOD = void 0;
|
|
4
|
+
const graphql_request_1 = require("graphql-request");
|
|
5
|
+
exports.DETERMINE_LOGIN_METHOD = (0, graphql_request_1.gql) `
|
|
6
|
+
mutation TranscendCliDetermineLoginMethod($email: String!) {
|
|
7
|
+
determineLoginMethod(input: { email: $email }) {
|
|
8
|
+
loginMethod {
|
|
9
|
+
email
|
|
10
|
+
sombraPublicKey
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
exports.LOGIN = (0, graphql_request_1.gql) `
|
|
16
|
+
mutation TranscendCliLogin(
|
|
17
|
+
$email: String!
|
|
18
|
+
$password: String!
|
|
19
|
+
$publicKey: String!
|
|
20
|
+
) {
|
|
21
|
+
login(
|
|
22
|
+
input: { email: $email, password: $password }
|
|
23
|
+
publicKey: $publicKey
|
|
24
|
+
) {
|
|
25
|
+
user {
|
|
26
|
+
roles {
|
|
27
|
+
id
|
|
28
|
+
organization {
|
|
29
|
+
name
|
|
30
|
+
id
|
|
31
|
+
uri
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
exports.ASSUME_ROLE = (0, graphql_request_1.gql) `
|
|
39
|
+
mutation TranscendCliAssumeRole($id: ID!, $publicKey: String!) {
|
|
40
|
+
assumeRole(id: $id, publicKey: $publicKey) {
|
|
41
|
+
clientMutationId
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/graphql/gqls/auth.ts"],"names":[],"mappings":";;;AAAA,qDAAsC;AAEzB,QAAA,sBAAsB,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;CASxC,CAAC;AAEW,QAAA,KAAK,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;CAsBvB,CAAC;AAEW,QAAA,WAAW,GAAG,IAAA,qBAAG,EAAA;;;;;;CAM7B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const PURPOSES: string;
|
|
2
2
|
export declare const CREATE_DATA_FLOWS: string;
|
|
3
3
|
export declare const UPDATE_DATA_FLOWS: string;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const UPDATE_OR_CREATE_COOKIES: string;
|
|
5
5
|
export declare const DATA_FLOWS: string;
|
|
6
6
|
export declare const COOKIES: string;
|
|
7
7
|
export declare const FETCH_CONSENT_MANAGER_ID: string;
|