-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utils/aws for fetching the keyset from S3
- Loading branch information
1 parent
8f5a2fa
commit c3cda7d
Showing
7 changed files
with
5,413 additions
and
2,295 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
{ | ||
"files": [], | ||
"references": [{ "path": "agent-core" }, { "path": "rotators/postgres" }, { "path": "apps/http-postgres-rotator" }] | ||
"references": [ | ||
{ "path": "agent-core" }, | ||
{ "path": "rotators/postgres" }, | ||
{ "path": "apps/http-postgres-rotator" }, | ||
{ "path": "utils/aws" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { Readable } from "stream"; | ||
import { S3 } from "@aws-sdk/client-s3"; | ||
|
||
async function streamToBuffer(stream: Readable) { | ||
return new Promise<Buffer>((resolve, reject) => { | ||
const chunks: Buffer[] = []; | ||
stream.on("data", (chunk) => chunks.push(chunk)); | ||
stream.once("end", () => resolve(Buffer.concat(chunks))); | ||
stream.once("error", reject); | ||
}); | ||
} | ||
|
||
export async function fetchS3KeySet(bucket = "doppler-keys") { | ||
const s3Client = new S3({ forcePathStyle: true }); | ||
const keyFile = await s3Client.getObject({ Bucket: bucket, Key: "secret-agents-jwks.json" }); | ||
const bodyBuffer = await streamToBuffer(keyFile.Body as Readable); | ||
return JSON.parse(new TextDecoder().decode(bodyBuffer)) as Record<string, unknown>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "aws-utils", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"engines": { | ||
"node": "16.x" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@aws-sdk/client-s3": "^3.128.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "lib", | ||
"outDir": "dist" | ||
} | ||
} |