@oneuptime/common 14.0.104 → 14.0.105

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 (88) hide show
  1. package/Models/DatabaseModels/CloudAccount.d.mts +1 -0
  2. package/Models/DatabaseModels/CloudAccount.d.ts +1 -0
  3. package/Models/DatabaseModels/CloudAccount.js +21 -0
  4. package/Models/DatabaseModels/CloudBudget.d.mts +1 -0
  5. package/Models/DatabaseModels/CloudBudget.d.ts +1 -0
  6. package/Models/DatabaseModels/CloudBudget.js +38 -3
  7. package/Models/DatabaseModels/CloudCostRecommendation.d.mts +2 -0
  8. package/Models/DatabaseModels/CloudCostRecommendation.d.ts +2 -0
  9. package/Models/DatabaseModels/CloudCostRecommendation.js +30 -2
  10. package/Models/DatabaseModels/DetectionRule.js +8 -7
  11. package/Types/AI/ResourceAiAccessApi.d.mts +1 -0
  12. package/Types/AI/ResourceAiAccessApi.d.ts +1 -0
  13. package/Types/AI/ResourceAiAccessApi.js +6 -1
  14. package/Types/AI/ResourceAiAccessApi.mjs +1 -0
  15. package/Types/AI/ResourceAiAccessPermissions.d.mts +2 -0
  16. package/Types/AI/ResourceAiAccessPermissions.d.ts +2 -0
  17. package/Types/AI/ResourceAiAccessPermissions.js +13 -0
  18. package/Types/AI/ResourceAiAccessPermissions.mjs +2 -0
  19. package/Types/Cloud/CloudCost.d.mts +8 -0
  20. package/Types/Cloud/CloudCost.d.ts +8 -0
  21. package/Types/Cloud/CloudCost.js +37 -0
  22. package/Types/Cloud/CloudCost.mjs +1 -0
  23. package/Types/Cloud/CloudCostAnomaly.d.mts +34 -0
  24. package/Types/Cloud/CloudCostAnomaly.d.ts +34 -0
  25. package/Types/Cloud/CloudCostAnomaly.js +236 -0
  26. package/Types/Cloud/CloudCostAnomaly.mjs +18 -0
  27. package/Types/Cloud/CloudLogGroups.d.mts +6 -1
  28. package/Types/Cloud/CloudLogGroups.d.ts +6 -1
  29. package/Types/Cloud/CloudLogGroups.js +59 -3
  30. package/Types/Cloud/CloudLogGroups.mjs +1 -0
  31. package/Types/Cloud/CloudPlatform.js +9 -8
  32. package/Types/Cloud/CloudRightSizing.d.mts +140 -0
  33. package/Types/Cloud/CloudRightSizing.d.ts +140 -0
  34. package/Types/Cloud/CloudRightSizing.js +867 -0
  35. package/Types/Cloud/CloudRightSizing.mjs +53 -0
  36. package/Types/CloudConnection/CloudAiAgentKey.d.mts +65 -0
  37. package/Types/CloudConnection/CloudAiAgentKey.d.ts +65 -0
  38. package/Types/CloudConnection/CloudAiAgentKey.js +289 -0
  39. package/Types/CloudConnection/CloudAiAgentKey.mjs +18 -0
  40. package/Types/CloudConnection/CloudAiAgentSetupCommands.d.mts +5 -2
  41. package/Types/CloudConnection/CloudAiAgentSetupCommands.d.ts +5 -2
  42. package/Types/CloudConnection/CloudAiAgentSetupCommands.js +114 -43
  43. package/Types/CloudConnection/CloudAiAgentSetupCommands.mjs +4 -1
  44. package/Types/CloudConnection/CloudStream.d.mts +4 -0
  45. package/Types/CloudConnection/CloudStream.d.ts +4 -0
  46. package/Types/CloudConnection/CloudStream.js +18 -1
  47. package/Types/CloudConnection/CloudStream.mjs +4 -0
  48. package/Types/CloudConnection/CloudStreamTemplate.d.mts +2 -0
  49. package/Types/CloudConnection/CloudStreamTemplate.d.ts +2 -0
  50. package/Types/CloudConnection/CloudStreamTemplate.js +89 -6
  51. package/Types/CloudConnection/CloudStreamTemplate.mjs +2 -0
  52. package/Types/InstallScripts/InstallScripts.js +1 -1
  53. package/Types/ResourceAiAgent/CloudAiAgentNames.d.mts +6 -0
  54. package/Types/ResourceAiAgent/CloudAiAgentNames.d.ts +6 -0
  55. package/Types/ResourceAiAgent/CloudAiAgentNames.js +11 -1
  56. package/Types/ResourceAiAgent/CloudAiAgentNames.mjs +3 -0
  57. package/Types/ResourceAiAgent/ResourceAiAccess.d.mts +3 -1
  58. package/Types/ResourceAiAgent/ResourceAiAccess.d.ts +3 -1
  59. package/Types/ResourceAiAgent/ResourceAiAccess.js +13 -2
  60. package/Types/ResourceAiAgent/ResourceAiAccess.mjs +2 -0
  61. package/Types/SecurityCase/SecurityCaseContext.d.mts +2 -1
  62. package/Types/SecurityCase/SecurityCaseContext.d.ts +2 -1
  63. package/Types/SecurityCase/SecurityConnection.d.mts +2 -1
  64. package/Types/SecurityCase/SecurityConnection.d.ts +2 -1
  65. package/Types/SecurityEvent/RealTimeDetection.d.mts +14 -5
  66. package/Types/SecurityEvent/RealTimeDetection.d.ts +14 -5
  67. package/Types/SecurityEvent/RealTimeDetection.js +75 -25
  68. package/Types/SecurityEvent/RealTimeDetection.mjs +3 -3
  69. package/Types/SecurityPlaybook/SecurityPlaybookAction.d.mts +4 -2
  70. package/Types/SecurityPlaybook/SecurityPlaybookAction.d.ts +4 -2
  71. package/Types/SecurityPlaybook/SecurityPlaybookAction.js +22 -3
  72. package/Types/SecurityPlaybook/SecurityPlaybookStep.d.mts +7 -2
  73. package/Types/SecurityPlaybook/SecurityPlaybookStep.d.ts +7 -2
  74. package/Types/SecurityPlaybook/SecurityPlaybookStep.js +96 -39
  75. package/Types/SecurityPlaybook/SecurityPlaybookStep.mjs +2 -0
  76. package/Types/SecurityPlaybook/SecurityPlaybookStepCondition.d.mts +17 -2
  77. package/Types/SecurityPlaybook/SecurityPlaybookStepCondition.d.ts +17 -2
  78. package/Types/SecurityPlaybook/SecurityPlaybookStepCondition.js +174 -33
  79. package/Types/SecurityPlaybook/SecurityPlaybookStepCondition.mjs +7 -0
  80. package/Utils/SecurityCase/SecurityCaseMarkdown.d.mts +5 -0
  81. package/Utils/SecurityCase/SecurityCaseMarkdown.d.ts +5 -0
  82. package/Utils/SecurityCase/SecurityCaseMarkdown.js +10 -0
  83. package/Utils/SecurityCase/SecurityCaseMarkdown.mjs +1 -0
  84. package/Utils/Telemetry/CloudChangeTitle.d.mts +37 -0
  85. package/Utils/Telemetry/CloudChangeTitle.d.ts +37 -0
  86. package/Utils/Telemetry/CloudChangeTitle.js +315 -3
  87. package/Utils/Telemetry/CloudChangeTitle.mjs +13 -0
  88. package/package.json +1 -1
@@ -0,0 +1,53 @@
1
+ import commonJsModule from "./CloudRightSizing.js";
2
+ export const CLOUD_DAYS_IN_AVERAGE_MONTH = commonJsModule.CLOUD_DAYS_IN_AVERAGE_MONTH;
3
+ export const CLOUD_RIGHT_SIZING_CPU_HOT_PERCENT = commonJsModule.CLOUD_RIGHT_SIZING_CPU_HOT_PERCENT;
4
+ export const CLOUD_RIGHT_SIZING_CPU_PEAK_PERCENT = commonJsModule.CLOUD_RIGHT_SIZING_CPU_PEAK_PERCENT;
5
+ export const CLOUD_RIGHT_SIZING_CPU_TARGET_PERCENT = commonJsModule.CLOUD_RIGHT_SIZING_CPU_TARGET_PERCENT;
6
+ export const CLOUD_RIGHT_SIZING_MAX_STEPS_DOWN = commonJsModule.CLOUD_RIGHT_SIZING_MAX_STEPS_DOWN;
7
+ export const CLOUD_RIGHT_SIZING_MEMORY_HOT_PERCENT = commonJsModule.CLOUD_RIGHT_SIZING_MEMORY_HOT_PERCENT;
8
+ export const CLOUD_RIGHT_SIZING_MEMORY_TARGET_PERCENT = commonJsModule.CLOUD_RIGHT_SIZING_MEMORY_TARGET_PERCENT;
9
+ export const CLOUD_RIGHT_SIZING_MIN_OBSERVED_HOURS = commonJsModule.CLOUD_RIGHT_SIZING_MIN_OBSERVED_HOURS;
10
+ export const CLOUD_RIGHT_SIZING_MIN_SAMPLES = commonJsModule.CLOUD_RIGHT_SIZING_MIN_SAMPLES;
11
+ export const CLOUD_RIGHT_SIZING_PROFILES = commonJsModule.CLOUD_RIGHT_SIZING_PROFILES;
12
+ export const CLOUD_RIGHT_SIZING_RECOMMENDATION_PREFIX = commonJsModule.CLOUD_RIGHT_SIZING_RECOMMENDATION_PREFIX;
13
+ export const CLOUD_RIGHT_SIZING_VERDICT_LABELS = commonJsModule.CLOUD_RIGHT_SIZING_VERDICT_LABELS;
14
+ export const CLOUD_RIGHT_SIZING_WINDOW_DAYS = commonJsModule.CLOUD_RIGHT_SIZING_WINDOW_DAYS;
15
+ export const CLOUD_SAVINGS_SOURCE_ONEUPTIME = commonJsModule.CLOUD_SAVINGS_SOURCE_ONEUPTIME;
16
+ export const CLOUD_SIZE_RECOMMENDATION_KINDS = commonJsModule.CLOUD_SIZE_RECOMMENDATION_KINDS;
17
+ export const CloudRightSizingSkipReason = commonJsModule.CloudRightSizingSkipReason;
18
+ export const CloudRightSizingVerdict = commonJsModule.CloudRightSizingVerdict;
19
+ export const CloudSizeLadder = commonJsModule.CloudSizeLadder;
20
+ export const MEMORY_NEEDS_CLOUDWATCH_AGENT = commonJsModule.MEMORY_NEEDS_CLOUDWATCH_AGENT;
21
+ export const MEMORY_NEEDS_OPS_AGENT = commonJsModule.MEMORY_NEEDS_OPS_AGENT;
22
+ export const MEMORY_NOT_REPORTED = commonJsModule.MEMORY_NOT_REPORTED;
23
+ export const MEMORY_REPORTED_AS_FREE = commonJsModule.MEMORY_REPORTED_AS_FREE;
24
+ export const RIGHT_SIZING_AT_NEW_SIZE = commonJsModule.RIGHT_SIZING_AT_NEW_SIZE;
25
+ export const RIGHT_SIZING_AT_NEW_SIZE_WITH_MEMORY = commonJsModule.RIGHT_SIZING_AT_NEW_SIZE_WITH_MEMORY;
26
+ export const RIGHT_SIZING_COSTS_MORE = commonJsModule.RIGHT_SIZING_COSTS_MORE;
27
+ export const RIGHT_SIZING_CPU_MAX_LABEL = commonJsModule.RIGHT_SIZING_CPU_MAX_LABEL;
28
+ export const RIGHT_SIZING_CPU_P95_LABEL = commonJsModule.RIGHT_SIZING_CPU_P95_LABEL;
29
+ export const RIGHT_SIZING_DAYS_READ_LABEL = commonJsModule.RIGHT_SIZING_DAYS_READ_LABEL;
30
+ export const RIGHT_SIZING_FITS = commonJsModule.RIGHT_SIZING_FITS;
31
+ export const RIGHT_SIZING_HALF_SIZE = commonJsModule.RIGHT_SIZING_HALF_SIZE;
32
+ export const RIGHT_SIZING_LEARNING = commonJsModule.RIGHT_SIZING_LEARNING;
33
+ export const RIGHT_SIZING_MEMORY_PEAK_LABEL = commonJsModule.RIGHT_SIZING_MEMORY_PEAK_LABEL;
34
+ export const RIGHT_SIZING_NOT_READ = commonJsModule.RIGHT_SIZING_NOT_READ;
35
+ export const RIGHT_SIZING_NO_LARGER_SIZE = commonJsModule.RIGHT_SIZING_NO_LARGER_SIZE;
36
+ export const RIGHT_SIZING_NO_SMALLER_SIZE = commonJsModule.RIGHT_SIZING_NO_SMALLER_SIZE;
37
+ export const RIGHT_SIZING_QUARTER_SIZE = commonJsModule.RIGHT_SIZING_QUARTER_SIZE;
38
+ export const RIGHT_SIZING_SAVES = commonJsModule.RIGHT_SIZING_SAVES;
39
+ export const RIGHT_SIZING_SAVES_UP_TO = commonJsModule.RIGHT_SIZING_SAVES_UP_TO;
40
+ export const RIGHT_SIZING_SAVING_NOT_KNOWN = commonJsModule.RIGHT_SIZING_SAVING_NOT_KNOWN;
41
+ export const RIGHT_SIZING_TITLE = commonJsModule.RIGHT_SIZING_TITLE;
42
+ export const RIGHT_SIZING_TWICE_SIZE = commonJsModule.RIGHT_SIZING_TWICE_SIZE;
43
+ export const buildCloudRightSizing = commonJsModule.buildCloudRightSizing;
44
+ export const getCloudReadingsP95 = commonJsModule.getCloudReadingsP95;
45
+ export const getCloudRightSizingProfile = commonJsModule.getCloudRightSizingProfile;
46
+ export const getCloudRightSizingRecommendationId = commonJsModule.getCloudRightSizingRecommendationId;
47
+ export const getCloudSizeSteps = commonJsModule.getCloudSizeSteps;
48
+ export const hasCloudRightSizingChange = commonJsModule.hasCloudRightSizingChange;
49
+ export const isCloudRightSizingRecommendationId = commonJsModule.isCloudRightSizingRecommendationId;
50
+ export const isRecommenderSizeRecommendation = commonJsModule.isRecommenderSizeRecommendation;
51
+ export const readCloudResourceSize = commonJsModule.readCloudResourceSize;
52
+ export const readCloudRightSizingEvidence = commonJsModule.readCloudRightSizingEvidence;
53
+ export const toCloudRightSizingEvidence = commonJsModule.toCloudRightSizingEvidence;
@@ -0,0 +1,65 @@
1
+ export declare const CLOUD_AI_AGENT_KEY_PREFIX: string;
2
+ export declare const CLOUD_AI_AGENT_KEY_SECRET_LENGTH: number;
3
+ export declare const CLOUD_AI_AGENT_KEY_MAX_LENGTH: number;
4
+ export declare const CLOUD_AI_AGENT_PENDING_KEY_LIFETIME_MS: number;
5
+ export declare const CLOUD_AI_AGENT_MAX_PENDING_KEYS: number;
6
+ export declare function buildCloudAiAgentKey(data: {
7
+ cloudAccountId: string;
8
+ secret: string;
9
+ }): string;
10
+ export declare function parseCloudAiAgentKey(value: unknown): {
11
+ cloudAccountId: string;
12
+ secret: string;
13
+ } | null;
14
+ export declare function isCloudAiAgentKey(value: unknown): boolean;
15
+ export interface CloudAiAgentKeyRecord {
16
+ hash: string;
17
+ madeAt: string;
18
+ madeByUserId?: string | undefined;
19
+ firstUsedAt?: string | undefined;
20
+ }
21
+ export interface CloudAiAgentKeys {
22
+ current: CloudAiAgentKeyRecord | null;
23
+ pending: Array<CloudAiAgentKeyRecord>;
24
+ isOwnKeyRequired: boolean;
25
+ revokedAt?: string | undefined;
26
+ }
27
+ export type CloudAiAgentKeyMatch = "current" | "pending";
28
+ export declare function readCloudAiAgentKeys(value: unknown): CloudAiAgentKeys | null;
29
+ export declare function isPendingCloudAiAgentKeyUsable(data: {
30
+ record: CloudAiAgentKeyRecord;
31
+ now: Date;
32
+ }): boolean;
33
+ export declare function getLiveCloudAiAgentKeyHashes(data: {
34
+ keys: CloudAiAgentKeys | null;
35
+ now: Date;
36
+ }): Array<{
37
+ hash: string;
38
+ match: CloudAiAgentKeyMatch;
39
+ }>;
40
+ export declare function addCloudAiAgentKey(data: {
41
+ keys: CloudAiAgentKeys | null;
42
+ record: CloudAiAgentKeyRecord;
43
+ now: Date;
44
+ }): CloudAiAgentKeys;
45
+ export declare function useCloudAiAgentKey(data: {
46
+ keys: CloudAiAgentKeys | null;
47
+ hash: string;
48
+ now: Date;
49
+ }): CloudAiAgentKeys | null;
50
+ export declare function revokeCloudAiAgentKeys(data: {
51
+ now: Date;
52
+ }): CloudAiAgentKeys;
53
+ export interface CloudAiAgentKeyTaken {
54
+ isUsable: boolean;
55
+ isNewKey: boolean;
56
+ replacedAgentKey: boolean;
57
+ madeByUserId?: string | undefined;
58
+ }
59
+ export declare function isOwnCloudAiAgentKeyRequired(keys: CloudAiAgentKeys | null): boolean;
60
+ export interface CloudAiAgentKeyResponse {
61
+ agentKey: string;
62
+ worksUntilConnectedBy: string;
63
+ }
64
+ export declare const CLOUD_AI_AGENT_KEY_REFUSED_MESSAGE: string;
65
+ export declare const CLOUD_AI_AGENT_INGESTION_KEY_REFUSED_MESSAGE: string;
@@ -0,0 +1,65 @@
1
+ export declare const CLOUD_AI_AGENT_KEY_PREFIX: string;
2
+ export declare const CLOUD_AI_AGENT_KEY_SECRET_LENGTH: number;
3
+ export declare const CLOUD_AI_AGENT_KEY_MAX_LENGTH: number;
4
+ export declare const CLOUD_AI_AGENT_PENDING_KEY_LIFETIME_MS: number;
5
+ export declare const CLOUD_AI_AGENT_MAX_PENDING_KEYS: number;
6
+ export declare function buildCloudAiAgentKey(data: {
7
+ cloudAccountId: string;
8
+ secret: string;
9
+ }): string;
10
+ export declare function parseCloudAiAgentKey(value: unknown): {
11
+ cloudAccountId: string;
12
+ secret: string;
13
+ } | null;
14
+ export declare function isCloudAiAgentKey(value: unknown): boolean;
15
+ export interface CloudAiAgentKeyRecord {
16
+ hash: string;
17
+ madeAt: string;
18
+ madeByUserId?: string | undefined;
19
+ firstUsedAt?: string | undefined;
20
+ }
21
+ export interface CloudAiAgentKeys {
22
+ current: CloudAiAgentKeyRecord | null;
23
+ pending: Array<CloudAiAgentKeyRecord>;
24
+ isOwnKeyRequired: boolean;
25
+ revokedAt?: string | undefined;
26
+ }
27
+ export type CloudAiAgentKeyMatch = "current" | "pending";
28
+ export declare function readCloudAiAgentKeys(value: unknown): CloudAiAgentKeys | null;
29
+ export declare function isPendingCloudAiAgentKeyUsable(data: {
30
+ record: CloudAiAgentKeyRecord;
31
+ now: Date;
32
+ }): boolean;
33
+ export declare function getLiveCloudAiAgentKeyHashes(data: {
34
+ keys: CloudAiAgentKeys | null;
35
+ now: Date;
36
+ }): Array<{
37
+ hash: string;
38
+ match: CloudAiAgentKeyMatch;
39
+ }>;
40
+ export declare function addCloudAiAgentKey(data: {
41
+ keys: CloudAiAgentKeys | null;
42
+ record: CloudAiAgentKeyRecord;
43
+ now: Date;
44
+ }): CloudAiAgentKeys;
45
+ export declare function useCloudAiAgentKey(data: {
46
+ keys: CloudAiAgentKeys | null;
47
+ hash: string;
48
+ now: Date;
49
+ }): CloudAiAgentKeys | null;
50
+ export declare function revokeCloudAiAgentKeys(data: {
51
+ now: Date;
52
+ }): CloudAiAgentKeys;
53
+ export interface CloudAiAgentKeyTaken {
54
+ isUsable: boolean;
55
+ isNewKey: boolean;
56
+ replacedAgentKey: boolean;
57
+ madeByUserId?: string | undefined;
58
+ }
59
+ export declare function isOwnCloudAiAgentKeyRequired(keys: CloudAiAgentKeys | null): boolean;
60
+ export interface CloudAiAgentKeyResponse {
61
+ agentKey: string;
62
+ worksUntilConnectedBy: string;
63
+ }
64
+ export declare const CLOUD_AI_AGENT_KEY_REFUSED_MESSAGE: string;
65
+ export declare const CLOUD_AI_AGENT_INGESTION_KEY_REFUSED_MESSAGE: string;
@@ -0,0 +1,289 @@
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.CLOUD_AI_AGENT_INGESTION_KEY_REFUSED_MESSAGE = exports.CLOUD_AI_AGENT_KEY_REFUSED_MESSAGE = exports.CLOUD_AI_AGENT_MAX_PENDING_KEYS = exports.CLOUD_AI_AGENT_PENDING_KEY_LIFETIME_MS = exports.CLOUD_AI_AGENT_KEY_MAX_LENGTH = exports.CLOUD_AI_AGENT_KEY_SECRET_LENGTH = exports.CLOUD_AI_AGENT_KEY_PREFIX = void 0;
7
+ exports.buildCloudAiAgentKey = buildCloudAiAgentKey;
8
+ exports.parseCloudAiAgentKey = parseCloudAiAgentKey;
9
+ exports.isCloudAiAgentKey = isCloudAiAgentKey;
10
+ exports.readCloudAiAgentKeys = readCloudAiAgentKeys;
11
+ exports.isPendingCloudAiAgentKeyUsable = isPendingCloudAiAgentKeyUsable;
12
+ exports.getLiveCloudAiAgentKeyHashes = getLiveCloudAiAgentKeyHashes;
13
+ exports.addCloudAiAgentKey = addCloudAiAgentKey;
14
+ exports.useCloudAiAgentKey = useCloudAiAgentKey;
15
+ exports.revokeCloudAiAgentKeys = revokeCloudAiAgentKeys;
16
+ exports.isOwnCloudAiAgentKeyRequired = isOwnCloudAiAgentKeyRequired;
17
+ const ObjectID_1 = __importDefault(require("../ObjectID"));
18
+ /*
19
+ * THE KEY A CLOUD AI AGENT CONNECTS WITH: ONE ACCOUNT'S, AND NOTHING ELSE.
20
+ *
21
+ * A Cloud AI agent (the resource AI agent in an AWS account, an Azure
22
+ * subscription or a Google Cloud project) used to register with one of the
23
+ * project's telemetry ingestion keys, kept as a secret of its cloud. That key
24
+ * also sends telemetry for the whole project and registers the AI agent of
25
+ * any of its resources, so whoever could read the secret could do both.
26
+ *
27
+ * Now the setup command carries a key made for that one cloud account: the
28
+ * account's "Let AI fix problems" makes it (POST
29
+ * /resource-ai-access/agent-key, RESOURCE_AI_ACCESS_AGENT_KEY_PATH) and the
30
+ * command puts it in the cloud's secret. It names its account - "ouca_<cloud account id>_<64 hex>" - and it
31
+ * registers that account's agent and nothing else: no other account's agent,
32
+ * no other resource's, and no telemetry anywhere (an ingestion route never
33
+ * knows it). Only its SHA-256 is kept (CloudAccount.aiAgentKeys, which nobody
34
+ * may read), and it is shown once, in the command.
35
+ *
36
+ * A key that has not connected yet is pending: the command may not have run.
37
+ * The agent's key so far keeps working beside it, so opening the dialog never
38
+ * disconnects anything. The first registration with a pending key makes it
39
+ * the agent's key, and the key it replaces stops working. A pending key that
40
+ * never connects stops working a day after it was made, and at most
41
+ * CLOUD_AI_AGENT_MAX_PENDING_KEYS are kept (each opening of the dialog makes
42
+ * one; two admins setting the agent up at once both get a key that works).
43
+ *
44
+ * Once an agent has connected with a key of its own, the project's ingestion
45
+ * key no longer registers that account's agent (isOwnKeyRequired). Reset
46
+ * agent revokes every key at once and keeps that rule: the agent stays
47
+ * disconnected until its setup command runs again, with a new key. Removing
48
+ * the account removes its keys with it.
49
+ *
50
+ * An agent set up before this keeps connecting with the ingestion key it was
51
+ * given until its setup command runs again (Change on its AI agent page) or
52
+ * it is reset.
53
+ *
54
+ * Shared by the server (the key route, registration, Reset agent), the
55
+ * dashboard and the setup commands (which check a key before writing it into
56
+ * a command). React-free and Node-free.
57
+ */
58
+ exports.CLOUD_AI_AGENT_KEY_PREFIX = "ouca";
59
+ exports.CLOUD_AI_AGENT_KEY_SECRET_LENGTH = 64;
60
+ // ouca_ + a 36-character id + _ + 64 hex: 106 characters. Nothing longer is read.
61
+ exports.CLOUD_AI_AGENT_KEY_MAX_LENGTH = 128;
62
+ // How long a key that has not connected yet keeps working.
63
+ exports.CLOUD_AI_AGENT_PENDING_KEY_LIFETIME_MS = 24 * 60 * 60 * 1000;
64
+ // How many keys that have not connected yet an account keeps, newest first.
65
+ exports.CLOUD_AI_AGENT_MAX_PENDING_KEYS = 5;
66
+ function buildCloudAiAgentKey(data) {
67
+ return `${exports.CLOUD_AI_AGENT_KEY_PREFIX}_${data.cloudAccountId.toLowerCase()}_${data.secret.toLowerCase()}`;
68
+ }
69
+ function isLowerHex(value) {
70
+ for (let index = 0; index < value.length; index++) {
71
+ const code = value.charCodeAt(index);
72
+ const isDigit = code >= 48 && code <= 57;
73
+ const isLetter = code >= 97 && code <= 102;
74
+ if (!isDigit && !isLetter) {
75
+ return false;
76
+ }
77
+ }
78
+ return value.length > 0;
79
+ }
80
+ /*
81
+ * The account a key names and its secret, or null for anything that is not
82
+ * a Cloud AI agent key. Never throws, and reads nothing past
83
+ * CLOUD_AI_AGENT_KEY_MAX_LENGTH characters.
84
+ */
85
+ function parseCloudAiAgentKey(value) {
86
+ if (typeof value !== "string") {
87
+ return null;
88
+ }
89
+ if (value.length === 0 || value.length > exports.CLOUD_AI_AGENT_KEY_MAX_LENGTH) {
90
+ return null;
91
+ }
92
+ const key = value.trim();
93
+ const parts = key.split("_");
94
+ if (parts.length !== 3 || parts[0] !== exports.CLOUD_AI_AGENT_KEY_PREFIX) {
95
+ return null;
96
+ }
97
+ const cloudAccountId = parts[1];
98
+ const secret = parts[2];
99
+ if (!ObjectID_1.default.isValidUUID(cloudAccountId) ||
100
+ cloudAccountId !== cloudAccountId.toLowerCase() ||
101
+ secret.length !== exports.CLOUD_AI_AGENT_KEY_SECRET_LENGTH ||
102
+ !isLowerHex(secret)) {
103
+ return null;
104
+ }
105
+ return { cloudAccountId, secret };
106
+ }
107
+ function isCloudAiAgentKey(value) {
108
+ return parseCloudAiAgentKey(value) !== null;
109
+ }
110
+ const SHA256_HEX_LENGTH = 64;
111
+ function readTime(value) {
112
+ if (typeof value !== "string" || !value || value.length > 64) {
113
+ return null;
114
+ }
115
+ const time = Date.parse(value);
116
+ return Number.isFinite(time) ? new Date(time).toISOString() : null;
117
+ }
118
+ function readRecord(value) {
119
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
120
+ return null;
121
+ }
122
+ const stored = value;
123
+ const hash = stored["hash"];
124
+ const madeAt = readTime(stored["madeAt"]);
125
+ if (typeof hash !== "string" ||
126
+ hash.length !== SHA256_HEX_LENGTH ||
127
+ !isLowerHex(hash) ||
128
+ !madeAt) {
129
+ return null;
130
+ }
131
+ const record = { hash, madeAt };
132
+ const madeByUserId = stored["madeByUserId"];
133
+ const firstUsedAt = readTime(stored["firstUsedAt"]);
134
+ if (typeof madeByUserId === "string" && ObjectID_1.default.isValidUUID(madeByUserId)) {
135
+ record.madeByUserId = madeByUserId.toLowerCase();
136
+ }
137
+ if (firstUsedAt) {
138
+ record.firstUsedAt = firstUsedAt;
139
+ }
140
+ return record;
141
+ }
142
+ /*
143
+ * The keys an account keeps, as they are - or null when it never had one,
144
+ * so its agent still registers with the project's ingestion key, as every
145
+ * agent set up before keys of their own did. A stored value of the wrong
146
+ * shape fails closed: its keys match nothing, and the ingestion key is not
147
+ * taken for the account (isOwnKeyRequired). Never throws.
148
+ */
149
+ function readCloudAiAgentKeys(value) {
150
+ if (value === null || value === undefined) {
151
+ return null;
152
+ }
153
+ if (typeof value !== "object" || Array.isArray(value)) {
154
+ return { current: null, pending: [], isOwnKeyRequired: true };
155
+ }
156
+ const stored = value;
157
+ const current = readRecord(stored["current"]);
158
+ const pending = [];
159
+ if (Array.isArray(stored["pending"])) {
160
+ for (const item of stored["pending"]) {
161
+ const record = readRecord(item);
162
+ if (record) {
163
+ pending.push(record);
164
+ }
165
+ if (pending.length >= exports.CLOUD_AI_AGENT_MAX_PENDING_KEYS) {
166
+ break;
167
+ }
168
+ }
169
+ }
170
+ const revokedAt = readTime(stored["revokedAt"]);
171
+ const keys = {
172
+ current,
173
+ pending,
174
+ /*
175
+ * Not required only while it says so plainly and no key ever connected
176
+ * nor was revoked: anything else requires the account's own key.
177
+ */
178
+ isOwnKeyRequired: stored["isOwnKeyRequired"] !== false ||
179
+ current !== null ||
180
+ revokedAt !== null,
181
+ };
182
+ if (revokedAt) {
183
+ keys.revokedAt = revokedAt;
184
+ }
185
+ return keys;
186
+ }
187
+ // Whether a pending key still works at `now`.
188
+ function isPendingCloudAiAgentKeyUsable(data) {
189
+ const madeAt = Date.parse(data.record.madeAt);
190
+ return (Number.isFinite(madeAt) &&
191
+ madeAt <= data.now.getTime() + 60 * 1000 &&
192
+ data.now.getTime() - madeAt < exports.CLOUD_AI_AGENT_PENDING_KEY_LIFETIME_MS);
193
+ }
194
+ /*
195
+ * The hashes a presented key may match at `now`: the agent's key, and the
196
+ * pending keys that still work.
197
+ */
198
+ function getLiveCloudAiAgentKeyHashes(data) {
199
+ if (!data.keys) {
200
+ return [];
201
+ }
202
+ const hashes = [];
203
+ if (data.keys.current) {
204
+ hashes.push({ hash: data.keys.current.hash, match: "current" });
205
+ }
206
+ for (const record of data.keys.pending) {
207
+ if (isPendingCloudAiAgentKeyUsable({ record, now: data.now })) {
208
+ hashes.push({ hash: record.hash, match: "pending" });
209
+ }
210
+ }
211
+ return hashes;
212
+ }
213
+ /*
214
+ * The keys once a new one is made: it goes first among the pending ones,
215
+ * the pending keys that no longer work go, and at most
216
+ * CLOUD_AI_AGENT_MAX_PENDING_KEYS stay. The agent's own key is untouched.
217
+ */
218
+ function addCloudAiAgentKey(data) {
219
+ const keys = data.keys || {
220
+ current: null,
221
+ pending: [],
222
+ isOwnKeyRequired: false,
223
+ };
224
+ const next = {
225
+ current: keys.current,
226
+ pending: [
227
+ data.record,
228
+ ...keys.pending.filter((record) => {
229
+ return (record.hash !== data.record.hash &&
230
+ isPendingCloudAiAgentKeyUsable({ record, now: data.now }));
231
+ }),
232
+ ].slice(0, exports.CLOUD_AI_AGENT_MAX_PENDING_KEYS),
233
+ isOwnKeyRequired: keys.isOwnKeyRequired,
234
+ };
235
+ if (keys.revokedAt) {
236
+ next.revokedAt = keys.revokedAt;
237
+ }
238
+ return next;
239
+ }
240
+ /*
241
+ * The keys once an agent connected with the pending key of this hash: it is
242
+ * the agent's key now, the key it replaces stops working, the project's
243
+ * ingestion key no longer registers the account's agent, and the other
244
+ * pending keys that still work keep working (another admin's command may be
245
+ * on its way). Null when no pending key that still works has this hash.
246
+ */
247
+ function useCloudAiAgentKey(data) {
248
+ if (!data.keys) {
249
+ return null;
250
+ }
251
+ const used = data.keys.pending.find((record) => {
252
+ return (record.hash === data.hash &&
253
+ isPendingCloudAiAgentKeyUsable({ record, now: data.now }));
254
+ });
255
+ if (!used) {
256
+ return null;
257
+ }
258
+ return {
259
+ current: Object.assign(Object.assign({}, used), { firstUsedAt: data.now.toISOString() }),
260
+ pending: data.keys.pending.filter((record) => {
261
+ return (record.hash !== data.hash &&
262
+ isPendingCloudAiAgentKeyUsable({ record, now: data.now }));
263
+ }),
264
+ isOwnKeyRequired: true,
265
+ };
266
+ }
267
+ /*
268
+ * Reset agent: every key stops working at once, and the project's ingestion
269
+ * key never registers the account's agent again. A new key connects it.
270
+ */
271
+ function revokeCloudAiAgentKeys(data) {
272
+ return {
273
+ current: null,
274
+ pending: [],
275
+ isOwnKeyRequired: true,
276
+ revokedAt: data.now.toISOString(),
277
+ };
278
+ }
279
+ // Whether the project's ingestion key may still register the account's agent.
280
+ function isOwnCloudAiAgentKeyRequired(keys) {
281
+ return Boolean(keys && keys.isOwnKeyRequired);
282
+ }
283
+ /*
284
+ * Why a registration with a Cloud AI agent key was refused, in words for
285
+ * the agent's log (and so for whoever reads it in the cloud). Never names
286
+ * the key.
287
+ */
288
+ exports.CLOUD_AI_AGENT_KEY_REFUSED_MESSAGE = "This Cloud AI agent key is not the cloud account's: it was replaced by a newer one, revoked by Reset agent, never connected within a day of being made, or its account was removed. Run the agent's setup command again: Change on the account's AI agent page in OneUptime shows it.";
289
+ exports.CLOUD_AI_AGENT_INGESTION_KEY_REFUSED_MESSAGE = "This cloud account's Cloud AI agent connects with a key of its own, so the project's telemetry ingestion key no longer connects it. Run the agent's setup command again: Change on the account's AI agent page in OneUptime shows it, with its key.";
@@ -0,0 +1,18 @@
1
+ import commonJsModule from "./CloudAiAgentKey.js";
2
+ export const CLOUD_AI_AGENT_INGESTION_KEY_REFUSED_MESSAGE = commonJsModule.CLOUD_AI_AGENT_INGESTION_KEY_REFUSED_MESSAGE;
3
+ export const CLOUD_AI_AGENT_KEY_MAX_LENGTH = commonJsModule.CLOUD_AI_AGENT_KEY_MAX_LENGTH;
4
+ export const CLOUD_AI_AGENT_KEY_PREFIX = commonJsModule.CLOUD_AI_AGENT_KEY_PREFIX;
5
+ export const CLOUD_AI_AGENT_KEY_REFUSED_MESSAGE = commonJsModule.CLOUD_AI_AGENT_KEY_REFUSED_MESSAGE;
6
+ export const CLOUD_AI_AGENT_KEY_SECRET_LENGTH = commonJsModule.CLOUD_AI_AGENT_KEY_SECRET_LENGTH;
7
+ export const CLOUD_AI_AGENT_MAX_PENDING_KEYS = commonJsModule.CLOUD_AI_AGENT_MAX_PENDING_KEYS;
8
+ export const CLOUD_AI_AGENT_PENDING_KEY_LIFETIME_MS = commonJsModule.CLOUD_AI_AGENT_PENDING_KEY_LIFETIME_MS;
9
+ export const addCloudAiAgentKey = commonJsModule.addCloudAiAgentKey;
10
+ export const buildCloudAiAgentKey = commonJsModule.buildCloudAiAgentKey;
11
+ export const getLiveCloudAiAgentKeyHashes = commonJsModule.getLiveCloudAiAgentKeyHashes;
12
+ export const isCloudAiAgentKey = commonJsModule.isCloudAiAgentKey;
13
+ export const isOwnCloudAiAgentKeyRequired = commonJsModule.isOwnCloudAiAgentKeyRequired;
14
+ export const isPendingCloudAiAgentKeyUsable = commonJsModule.isPendingCloudAiAgentKeyUsable;
15
+ export const parseCloudAiAgentKey = commonJsModule.parseCloudAiAgentKey;
16
+ export const readCloudAiAgentKeys = commonJsModule.readCloudAiAgentKeys;
17
+ export const revokeCloudAiAgentKeys = commonJsModule.revokeCloudAiAgentKeys;
18
+ export const useCloudAiAgentKey = commonJsModule.useCloudAiAgentKey;
@@ -6,7 +6,7 @@ export declare const CLOUD_AI_AGENT_DEFAULT_FIXES_MODE: CloudAiAgentFixesMode;
6
6
  export interface CloudAiAgentSetupOptions {
7
7
  provider: CloudProvider;
8
8
  oneuptimeUrl: string;
9
- ingestionKey: string;
9
+ agentKey: string;
10
10
  cloudAccountId: string;
11
11
  accountId: string;
12
12
  fixesMode: CloudAiAgentFixesMode;
@@ -31,7 +31,7 @@ export interface CloudAiAgentSize {
31
31
  export declare const CLOUD_AI_AGENT_SIZES: Readonly<Record<CloudProvider, CloudAiAgentSize>>;
32
32
  export declare const CLOUD_AI_AGENT_STARTED_MESSAGE: string;
33
33
  export declare const CLOUD_AI_AGENT_ONEUPTIME_URL_ENV: string;
34
- export declare const CLOUD_AI_AGENT_INGESTION_KEY_ENV: string;
34
+ export declare const CLOUD_AI_AGENT_KEY_ENV: string;
35
35
  export declare const CLOUD_AI_AGENT_HEALTH_HOST_ENV: string;
36
36
  export declare const AWS_CLOUD_AI_AGENT_TEMPLATE_FILE: string;
37
37
  export declare const GCP_CLOUD_AI_AGENT_ENV_FILE: string;
@@ -40,6 +40,7 @@ export declare const AZURE_CLOUD_AI_AGENT_SECRET_NAME: string;
40
40
  export declare const GCP_CLOUD_AI_AGENT_SECRET_NAME: string;
41
41
  export declare const GCP_CLOUD_AI_AGENT_KEY_FILE_END: string;
42
42
  export declare const GCP_SECRET_ACCESSOR_ROLE: string;
43
+ export declare const GCP_TOKEN_CREATOR_ROLE: string;
43
44
  export declare const GCP_CLOUD_AI_AGENT_DEPLOY_ATTEMPTS: number;
44
45
  export declare const GCP_CLOUD_AI_AGENT_DEPLOY_RETRY_SECONDS: number;
45
46
  export declare const GCP_CLOUD_AI_AGENT_DEPLOY_RETRY_MESSAGE: string;
@@ -61,8 +62,10 @@ export declare function getCloudAiAgentMaxProtectedTargets(provider: CloudProvid
61
62
  export declare function describeCloudAiAgentSetupProblem(options: CloudAiAgentSetupOptions): string | null;
62
63
  export declare function getCloudAiAgentImage(imageTag?: string): string;
63
64
  export declare function getAwsCloudAiAgentWriteRoleArn(accountId: string): string;
65
+ export declare function getGcpCloudAiAgentWriteServiceAccount(projectId: string): string;
64
66
  export declare function getCloudAiAgentEnvironment(options: CloudAiAgentSetupOptions): Array<CloudAiAgentEnvironmentVariable>;
65
67
  export declare function getCloudAiAgentRolePermissions(provider: CloudProvider, enabledOperations?: Array<string> | undefined): Array<string>;
68
+ export declare function getGcpCloudAiAgentReaderPermissions(enabledOperations?: Array<string> | undefined): Array<string>;
66
69
  export declare function getAwsCloudAiAgentTemplate(options: CloudAiAgentSetupOptions): string;
67
70
  export declare function getAwsCloudAiAgentSetupCommand(options: CloudAiAgentSetupOptions): string;
68
71
  export declare function getAzureCloudAiAgentRoleName(subscriptionId: string): string;
@@ -6,7 +6,7 @@ export declare const CLOUD_AI_AGENT_DEFAULT_FIXES_MODE: CloudAiAgentFixesMode;
6
6
  export interface CloudAiAgentSetupOptions {
7
7
  provider: CloudProvider;
8
8
  oneuptimeUrl: string;
9
- ingestionKey: string;
9
+ agentKey: string;
10
10
  cloudAccountId: string;
11
11
  accountId: string;
12
12
  fixesMode: CloudAiAgentFixesMode;
@@ -31,7 +31,7 @@ export interface CloudAiAgentSize {
31
31
  export declare const CLOUD_AI_AGENT_SIZES: Readonly<Record<CloudProvider, CloudAiAgentSize>>;
32
32
  export declare const CLOUD_AI_AGENT_STARTED_MESSAGE: string;
33
33
  export declare const CLOUD_AI_AGENT_ONEUPTIME_URL_ENV: string;
34
- export declare const CLOUD_AI_AGENT_INGESTION_KEY_ENV: string;
34
+ export declare const CLOUD_AI_AGENT_KEY_ENV: string;
35
35
  export declare const CLOUD_AI_AGENT_HEALTH_HOST_ENV: string;
36
36
  export declare const AWS_CLOUD_AI_AGENT_TEMPLATE_FILE: string;
37
37
  export declare const GCP_CLOUD_AI_AGENT_ENV_FILE: string;
@@ -40,6 +40,7 @@ export declare const AZURE_CLOUD_AI_AGENT_SECRET_NAME: string;
40
40
  export declare const GCP_CLOUD_AI_AGENT_SECRET_NAME: string;
41
41
  export declare const GCP_CLOUD_AI_AGENT_KEY_FILE_END: string;
42
42
  export declare const GCP_SECRET_ACCESSOR_ROLE: string;
43
+ export declare const GCP_TOKEN_CREATOR_ROLE: string;
43
44
  export declare const GCP_CLOUD_AI_AGENT_DEPLOY_ATTEMPTS: number;
44
45
  export declare const GCP_CLOUD_AI_AGENT_DEPLOY_RETRY_SECONDS: number;
45
46
  export declare const GCP_CLOUD_AI_AGENT_DEPLOY_RETRY_MESSAGE: string;
@@ -61,8 +62,10 @@ export declare function getCloudAiAgentMaxProtectedTargets(provider: CloudProvid
61
62
  export declare function describeCloudAiAgentSetupProblem(options: CloudAiAgentSetupOptions): string | null;
62
63
  export declare function getCloudAiAgentImage(imageTag?: string): string;
63
64
  export declare function getAwsCloudAiAgentWriteRoleArn(accountId: string): string;
65
+ export declare function getGcpCloudAiAgentWriteServiceAccount(projectId: string): string;
64
66
  export declare function getCloudAiAgentEnvironment(options: CloudAiAgentSetupOptions): Array<CloudAiAgentEnvironmentVariable>;
65
67
  export declare function getCloudAiAgentRolePermissions(provider: CloudProvider, enabledOperations?: Array<string> | undefined): Array<string>;
68
+ export declare function getGcpCloudAiAgentReaderPermissions(enabledOperations?: Array<string> | undefined): Array<string>;
66
69
  export declare function getAwsCloudAiAgentTemplate(options: CloudAiAgentSetupOptions): string;
67
70
  export declare function getAwsCloudAiAgentSetupCommand(options: CloudAiAgentSetupOptions): string;
68
71
  export declare function getAzureCloudAiAgentRoleName(subscriptionId: string): string;