updates
This commit is contained in:
@@ -1251,17 +1251,17 @@ export async function fetchFileWithCache(
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface AlibabaCloudInstanceIdentityAudienceMeta {
|
interface AlibabaCloudInstanceIdentityAudienceMeta {
|
||||||
version: 1 | number;
|
ver: 1 | number;
|
||||||
issuedAtMs: number;
|
iat: number;
|
||||||
expiresAtMs: number;
|
exp: number;
|
||||||
purpose: string;
|
aud: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AlibabaCloudInstanceIdentityMode = "normal" | "secured";
|
export type AlibabaCloudInstanceIdentityMode = "normal" | "secured";
|
||||||
|
|
||||||
// https://help.aliyun.com/zh/ecs/user-guide/use-instance-identities
|
// https://help.aliyun.com/zh/ecs/user-guide/use-instance-identities
|
||||||
export async function fetchAlibabaCloudInstanceIdentityV1(
|
export async function fetchAlibabaCloudInstanceIdentityV1(
|
||||||
purpose: string,
|
audience: string,
|
||||||
mode?: AlibabaCloudInstanceIdentityMode,
|
mode?: AlibabaCloudInstanceIdentityMode,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let metaDataToken = null;
|
let metaDataToken = null;
|
||||||
@@ -1286,10 +1286,10 @@ export async function fetchAlibabaCloudInstanceIdentityV1(
|
|||||||
metaDataToken = await tokenResponse.text();
|
metaDataToken = await tokenResponse.text();
|
||||||
}
|
}
|
||||||
const audienceMeta = {
|
const audienceMeta = {
|
||||||
version: 1,
|
ver: 1,
|
||||||
issuedAtMs: Date.now(),
|
iat: Math.floor(Date.now() / 1000),
|
||||||
expiresAtMs: Date.now() + 60 * 1000,
|
exp: Math.floor(Date.now() / 1000) + 60,
|
||||||
purpose: purpose,
|
aud: audience,
|
||||||
} as AlibabaCloudInstanceIdentityAudienceMeta;
|
} as AlibabaCloudInstanceIdentityAudienceMeta;
|
||||||
const pkcs7Options = {};
|
const pkcs7Options = {};
|
||||||
if (metaDataToken) {
|
if (metaDataToken) {
|
||||||
@@ -1328,7 +1328,7 @@ export async function getSecretValueViaAlibabaCloudInstanceIdentity(
|
|||||||
mode?: AlibabaCloudInstanceIdentityMode,
|
mode?: AlibabaCloudInstanceIdentityMode,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const pkcs7 = await fetchAlibabaCloudInstanceIdentityV1(
|
const pkcs7 = await fetchAlibabaCloudInstanceIdentityV1(
|
||||||
"access_hatter_ink",
|
"hatter.ink",
|
||||||
mode,
|
mode,
|
||||||
);
|
);
|
||||||
const httpSecretResponse = await fetchDataWithTimeout(
|
const httpSecretResponse = await fetchDataWithTimeout(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
getSecretValue,
|
getSecretValue,
|
||||||
log,
|
log,
|
||||||
stdinToArrayBuffer,
|
stdinToArrayBuffer,
|
||||||
} from "https://script.hatter.ink/@54/deno-commons-mod.ts";
|
} from "https://script.hatter.ink/@55/deno-commons-mod.ts";
|
||||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||||
|
|
||||||
// specification: https://docs.openclaw.ai/gateway/secrets
|
// specification: https://docs.openclaw.ai/gateway/secrets
|
||||||
|
|||||||
Reference in New Issue
Block a user