Skip to content

Instantly share code, notes, and snippets.

@carnesen
Created June 16, 2019 13:27
Show Gist options
  • Save carnesen/5a09fd4899f2c1b7c4121307e487c644 to your computer and use it in GitHub Desktop.
Save carnesen/5a09fd4899f2c1b7c4121307e487c644 to your computer and use it in GitHub Desktop.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference lib="dom" />
global.fetch = require('node-fetch');
// ^^ Attaches `fetch` polyfill to global scope
const aws_amplify_1 = require("aws-amplify");
const run_and_exit_1 = require("@carnesen/run-and-exit");
// Workaround https://github.com/aws-amplify/amplify-js/issues/3109
aws_amplify_1.Analytics.configure({ disabled: true });
async function signInAsChris(userPoolId, userPoolWebClientId) {
let persisted = {};
aws_amplify_1.Auth.configure({
userPoolId,
userPoolWebClientId,
region: 'us-west-2',
storage: {
setItem(key, value) {
persisted[key] = value;
},
getItem(key) {
return persisted[key];
},
removeItem(key) {
delete persisted[key];
},
clear() {
persisted = {};
},
},
authenticationFlowType: 'USER_PASSWORD_AUTH',
});
await aws_amplify_1.Auth.signIn('[email protected]', 'alwaysai');
console.log(`User pool ${userPoolId} has persisted the following keys:`);
Object.keys(persisted).forEach(key => console.log(` - ${key}`));
console.log();
}
exports.signInAsChris = signInAsChris;
run_and_exit_1.runAndExit(async () => {
await signInAsChris('us-west-2_rEKRyJubT', '7ebmcv9biv7qh4k23cs0d1guoc');
await signInAsChris('us-west-2_0uQVvAYKk', '1ebs5shhsl190bmdllpbj6e7kb');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment