UNPKG

@aws-amplify/core

Version:
1 lines 1.32 kB
{"version":3,"file":"isClockSkewed.mjs","sources":["../../../../../../src/clients/middleware/signing/utils/isClockSkewed.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getSkewCorrectedDate } from './getSkewCorrectedDate';\n// 5 mins in milliseconds. Ref: https://github.com/aws/aws-sdk-js-v3/blob/6c0f44fab30a1bb2134af47362a31332abc3666b/packages/middleware-signing/src/utils/isClockSkewed.ts#L10\nconst SKEW_WINDOW = 5 * 60 * 1000;\n/**\n * Checks if the provided date is within the skew window of 5 minutes.\n *\n * @param clockTimeInMilliseconds Time to check for skew in milliseconds.\n * @param clockOffsetInMilliseconds Offset to check clock against in milliseconds.\n *\n * @returns True if skewed. False otherwise.\n *\n * @internal\n */\nexport const isClockSkewed = (clockTimeInMilliseconds, clockOffsetInMilliseconds) => Math.abs(getSkewCorrectedDate(clockOffsetInMilliseconds).getTime() -\n clockTimeInMilliseconds) >= SKEW_WINDOW;\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,aAAa,GAAG,CAAC,uBAAuB,EAAE,yBAAyB,KAAK,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,yBAAyB,CAAC,CAAC,OAAO,EAAE;AACvJ,IAAI,uBAAuB,CAAC,IAAI;;;;"}