@terros-inc/sdk 1.0.14 → 1.0.15
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/index.d.mts +2 -0
- package/dist/index.mjs +13 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -16,6 +16,7 @@ type TerrosHeaderMetadata = {
|
|
|
16
16
|
//#region ../packages/connect-common/dist/terrosApiClient.d.ts
|
|
17
17
|
type TerrosClientConfig = {
|
|
18
18
|
apiKey?: string;
|
|
19
|
+
authType?: 'ApiKey' | 'ConnectKey';
|
|
19
20
|
baseUrl?: string;
|
|
20
21
|
analytics?: TerrosHeaderMetadata;
|
|
21
22
|
impersonateUserId?: string;
|
|
@@ -1458,6 +1459,7 @@ type ConnectExecutionConfig = {
|
|
|
1458
1459
|
scriptConfig: Record<string, string>;
|
|
1459
1460
|
secrets: Record<string, string>;
|
|
1460
1461
|
authorization?: string;
|
|
1462
|
+
authType?: 'ApiKey' | 'ConnectKey';
|
|
1461
1463
|
};
|
|
1462
1464
|
type ConnectExecutionContext<Payload> = {
|
|
1463
1465
|
payload: Payload;
|
package/dist/index.mjs
CHANGED
|
@@ -123,20 +123,23 @@ var TerrosApiClient = class {
|
|
|
123
123
|
return output;
|
|
124
124
|
}
|
|
125
125
|
async getAuthorizationHeader() {
|
|
126
|
-
if (this.authStrategy.type === "apikey") return
|
|
126
|
+
if (this.authStrategy.type === "apikey") return `${this.authStrategy.authType} ${this.authStrategy.apiKey}`;
|
|
127
127
|
const cliTokens = await getTokens();
|
|
128
128
|
if (cliTokens === null) throw new Error("No authorization found. Log in with Terros CLI or provide an API key via environment variables or client config.");
|
|
129
129
|
return `Bearer ${cliTokens.access_token}`;
|
|
130
130
|
}
|
|
131
131
|
determineAuthStrategy(config) {
|
|
132
|
+
const authType = config.authType ?? "ApiKey";
|
|
132
133
|
if (config.apiKey) return {
|
|
133
134
|
type: "apikey",
|
|
134
|
-
apiKey: config.apiKey
|
|
135
|
+
apiKey: config.apiKey,
|
|
136
|
+
authType
|
|
135
137
|
};
|
|
136
138
|
const apiKeyFromEnv = readProcessEnv("TERROS_API_KEY");
|
|
137
139
|
if (apiKeyFromEnv) return {
|
|
138
140
|
type: "apikey",
|
|
139
|
-
apiKey: apiKeyFromEnv
|
|
141
|
+
apiKey: apiKeyFromEnv,
|
|
142
|
+
authType
|
|
140
143
|
};
|
|
141
144
|
return { type: "oauth" };
|
|
142
145
|
}
|
|
@@ -153,7 +156,7 @@ function readProcessEnv(key) {
|
|
|
153
156
|
}
|
|
154
157
|
//#endregion
|
|
155
158
|
//#region package.json
|
|
156
|
-
var version = "1.0.
|
|
159
|
+
var version = "1.0.15";
|
|
157
160
|
//#endregion
|
|
158
161
|
//#region src/clients/account.ts
|
|
159
162
|
var AccountStatusClient = class {
|
|
@@ -424,9 +427,13 @@ var TerrosClient = class {
|
|
|
424
427
|
//#region src/connect/handler.ts
|
|
425
428
|
function wrapConnectHandler(handler) {
|
|
426
429
|
return async (input) => {
|
|
427
|
-
const
|
|
430
|
+
const auth = input.context.config.authorization;
|
|
431
|
+
const authType = input.context.config.authType;
|
|
428
432
|
delete input.context.config.authorization;
|
|
429
|
-
return await handler(input, new TerrosClient({
|
|
433
|
+
return await handler(input, new TerrosClient({
|
|
434
|
+
apiKey: auth?.replace(/^(ApiKey|ConnectKey) /, ""),
|
|
435
|
+
authType
|
|
436
|
+
}));
|
|
430
437
|
};
|
|
431
438
|
}
|
|
432
439
|
//#endregion
|