File Explorer

/var/runtime/node_modules/@aws-sdk/dsql-signer/dist-cjs

This explorer reads the filesystem of the server it runs on, so /workspace/user isn't present here. Browsing and the terminal still work against this server's own disk from /.

index.js2.1 KB · 65 lines
const { formatUrl } = require("@aws-sdk/core/util");const { Sha256 } = require("@smithy/core/checksum");const { HttpRequest } = require("@smithy/core/protocols");const { SignatureV4 } = require("@smithy/signature-v4");const { defaultProvider } = require("@aws-sdk/credential-provider-node");const { loadConfig, NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS } = require("@smithy/core/config"); const getRuntimeConfig = (config) => {    return {        runtime: "node",        credentials: config?.credentials ?? defaultProvider(),        region: config?.region ?? loadConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),        ...config,    };}; class DsqlSigner {    credentials;    hostname;    protocol = "https:";    region;    service = "dsql";    sha256;    expiresIn;    constructor(configuration) {        const runtimeConfiguration = getRuntimeConfig(configuration);        this.credentials = runtimeConfiguration.credentials;        this.hostname = runtimeConfiguration.hostname;        this.region = runtimeConfiguration.region;        this.sha256 = runtimeConfiguration.sha256 ?? Sha256;        this.expiresIn = runtimeConfiguration.expiresIn ?? 900;    }    async _getAuthToken(action) {        const signer = new SignatureV4({            service: this.service,            region: this.region,            credentials: this.credentials,            sha256: this.sha256,        });        const request = new HttpRequest({            method: "GET",            protocol: this.protocol,            hostname: this.hostname,            query: {                Action: action,            },            headers: {                host: `${this.hostname}`,            },        });        const presigned = await signer.presign(request, {            expiresIn: this.expiresIn,        });        return formatUrl(presigned).replace(`${this.protocol}//`, "");    }    async getDbConnectAuthToken() {        return this._getAuthToken("DbConnect");    }    async getDbConnectAdminAuthToken() {        return this._getAuthToken("DbConnectAdmin");    }} exports.DsqlSigner = DsqlSigner;