serverless-spy
Version:
CDK-based library for writing elegant integration tests on AWS serverless architecture and an additional web console to monitor events in real time.
8 lines (7 loc) • 324 B
JavaScript
import { TokenProviderError } from "@smithy/property-provider";
import { REFRESH_MESSAGE } from "./constants";
export const validateTokenExpiry = (token) => {
if (token.expiration && token.expiration.getTime() < Date.now()) {
throw new TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
}
};