File Explorer

/proc/self/root/proc/self/root/var/runtime/node_modules/@aws-sdk/middleware-token/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.0 KB · 61 lines
'use strict'; var protocols = require('@smithy/core/protocols');var types = require('@smithy/types');var client = require('@smithy/core/client');var config = require('@smithy/core/config');var tokenDefaultProvider = require('./tokenDefaultProvider'); const tokenMiddlewareOptions = {    name: "tokenMiddleware",    tags: ["TOKEN", "AUTH"],    relation: "after",    toMiddleware: "retryMiddleware",    override: true,};const tokenMiddleware = (options) => (next, context) => async (args) => {    if (!protocols.HttpRequest.isInstance(args.request) || context.currentAuthConfig)        return next(args);    const token = options.token && (await options.token());    if (token?.token) {        const authConfig = {            in: types.HttpAuthLocation.HEADER,            name: "authorization",            scheme: "Bearer",        };        context.currentAuthConfig = authConfig;        args.request.headers[authConfig.name] = `${authConfig.scheme} ${token.token}`;    }    else {        context.currentAuthConfig = undefined;    }    return next(args);}; const getTokenPlugin = (options) => ({    applyToStack: (clientStack) => {        clientStack.addRelativeTo(tokenMiddleware(options), tokenMiddlewareOptions);    },}); const isTokenWithExpiry = (token) => token.expiration !== undefined;const isTokenExpiringWithinFiveMins = (token) => isTokenWithExpiry(token) && token.expiration.getTime() - Date.now() < 300000;const normalizeTokenProvider = (token) => {    if (typeof token === "function") {        return config.memoize(token, isTokenExpiringWithinFiveMins, isTokenWithExpiry);    }    return client.normalizeProvider(token);}; const resolveTokenConfig = (input) => {    const { token } = input;    return Object.assign(input, {        token: token ? normalizeTokenProvider(token) : tokenDefaultProvider.tokenDefaultProvider(input),    });}; exports.getTokenPlugin = getTokenPlugin;exports.resolveTokenConfig = resolveTokenConfig;exports.tokenMiddleware = tokenMiddleware;exports.tokenMiddlewareOptions = tokenMiddlewareOptions;