UNPKG

eks-iam-auth

Version:

Authenticate with AWS EKS clusters using AWS IAM

24 lines 938 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const aws4_1 = require("aws4"); const b64 = (str) => Buffer.from(str.toString(), 'binary').toString('base64'), prepend = (prep) => (str) => prep + str, replace = (search, substitution) => (str) => str.replace(search, substitution), pipe = (fns) => (thing) => fns.reduce((val, fn) => fn(val), thing), removePadding = replace(/=+$/, ''), makeUrlSafe = pipe([ replace('+', '-'), replace('/', '_'), ]); exports.getBearerToken = pipe([ (clusterId) => ({ host: `sts.amazonaws.com`, path: `/?Action=GetCallerIdentity&Version=2011-06-15&X-Amz-Expires=60`, headers: { 'x-k8s-aws-id': clusterId, }, signQuery: true, }), aws4_1.sign, (signed) => `https://${signed.host}${signed.path}`, b64, removePadding, makeUrlSafe, prepend('k8s-aws-v1.'), ]); //# sourceMappingURL=index.js.map