@replayio/app-building 1.13.0 → 1.14.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/dist/secrets.d.ts +10 -3
- package/dist/secrets.js +28 -6
- package/package.json +1 -1
package/dist/secrets.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ export interface InfisicalConfig {
|
|
|
3
3
|
projectId: string;
|
|
4
4
|
environment: string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Log in to Infisical using Universal Auth (Client ID + Client Secret).
|
|
8
|
+
* Returns a short-lived access token (default 30 day TTL).
|
|
9
|
+
*/
|
|
10
|
+
export declare function infisicalLogin(clientId: string, clientSecret: string): Promise<string>;
|
|
6
11
|
/**
|
|
7
12
|
* Fetch secrets from an Infisical folder path.
|
|
8
13
|
* Returns a key-value record of secret names to values.
|
|
@@ -23,7 +28,9 @@ export declare function fetchBranchSecrets(config: InfisicalConfig, branch: stri
|
|
|
23
28
|
*/
|
|
24
29
|
export declare function resolveContainerSecrets(config: InfisicalConfig): Promise<Record<string, string>>;
|
|
25
30
|
/**
|
|
26
|
-
* Extract Infisical config from environment variables.
|
|
27
|
-
*
|
|
31
|
+
* Extract Infisical config from environment variables and log in.
|
|
32
|
+
* Reads INFISICAL_CLIENT_ID, INFISICAL_CLIENT_SECRET, INFISICAL_PROJECT_ID,
|
|
33
|
+
* and INFISICAL_ENVIRONMENT from the env vars.
|
|
34
|
+
* Throws if any required var is missing.
|
|
28
35
|
*/
|
|
29
|
-
export declare function getInfisicalConfig(envVars: Record<string, string>): InfisicalConfig
|
|
36
|
+
export declare function getInfisicalConfig(envVars: Record<string, string>): Promise<InfisicalConfig>;
|
package/dist/secrets.js
CHANGED
|
@@ -12,6 +12,23 @@ function getRequiredSecretKeys() {
|
|
|
12
12
|
.filter((l) => l && l.includes("="))
|
|
13
13
|
.map((l) => l.split("=")[0].trim());
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Log in to Infisical using Universal Auth (Client ID + Client Secret).
|
|
17
|
+
* Returns a short-lived access token (default 30 day TTL).
|
|
18
|
+
*/
|
|
19
|
+
export async function infisicalLogin(clientId, clientSecret) {
|
|
20
|
+
const res = await fetch(`${INFISICAL_API_BASE}/api/v1/auth/universal-auth/login`, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: { "Content-Type": "application/json" },
|
|
23
|
+
body: JSON.stringify({ clientId, clientSecret }),
|
|
24
|
+
});
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
const body = await res.text().catch(() => "");
|
|
27
|
+
throw new Error(`Infisical login failed → ${res.status}: ${body}`);
|
|
28
|
+
}
|
|
29
|
+
const data = (await res.json());
|
|
30
|
+
return data.accessToken;
|
|
31
|
+
}
|
|
15
32
|
async function infisicalFetch(path, config) {
|
|
16
33
|
const res = await fetch(`${INFISICAL_API_BASE}${path}`, {
|
|
17
34
|
headers: {
|
|
@@ -76,20 +93,25 @@ export async function resolveContainerSecrets(config) {
|
|
|
76
93
|
return secrets;
|
|
77
94
|
}
|
|
78
95
|
/**
|
|
79
|
-
* Extract Infisical config from environment variables.
|
|
80
|
-
*
|
|
96
|
+
* Extract Infisical config from environment variables and log in.
|
|
97
|
+
* Reads INFISICAL_CLIENT_ID, INFISICAL_CLIENT_SECRET, INFISICAL_PROJECT_ID,
|
|
98
|
+
* and INFISICAL_ENVIRONMENT from the env vars.
|
|
99
|
+
* Throws if any required var is missing.
|
|
81
100
|
*/
|
|
82
|
-
export function getInfisicalConfig(envVars) {
|
|
83
|
-
const
|
|
101
|
+
export async function getInfisicalConfig(envVars) {
|
|
102
|
+
const clientId = envVars.INFISICAL_CLIENT_ID;
|
|
103
|
+
const clientSecret = envVars.INFISICAL_CLIENT_SECRET;
|
|
84
104
|
const projectId = envVars.INFISICAL_PROJECT_ID;
|
|
85
105
|
const environment = envVars.INFISICAL_ENVIRONMENT;
|
|
86
106
|
const missing = [
|
|
87
|
-
!
|
|
107
|
+
!clientId && "INFISICAL_CLIENT_ID",
|
|
108
|
+
!clientSecret && "INFISICAL_CLIENT_SECRET",
|
|
88
109
|
!projectId && "INFISICAL_PROJECT_ID",
|
|
89
110
|
!environment && "INFISICAL_ENVIRONMENT",
|
|
90
111
|
].filter(Boolean);
|
|
91
112
|
if (missing.length > 0) {
|
|
92
113
|
throw new Error(`Missing Infisical config in .env: ${missing.join(", ")}`);
|
|
93
114
|
}
|
|
94
|
-
|
|
115
|
+
const token = await infisicalLogin(clientId, clientSecret);
|
|
116
|
+
return { token, projectId: projectId, environment: environment };
|
|
95
117
|
}
|