用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
666 B

3 months ago
  1. import dateFormat from 'dateformat';
  2. import { getStandardRegion } from '../utils/getStandardRegion';
  3. import { policy2Str } from '../utils/policy2Str';
  4. import { getSignatureV4 } from '../signUtils';
  5. export function signPostObjectPolicyV4(this: any, policy: string | object, date: Date): string {
  6. const policyStr = Buffer.from(policy2Str(policy), 'utf8').toString('base64');
  7. const formattedDate = dateFormat(date, "UTC:yyyymmdd'T'HHMMss'Z'");
  8. const onlyDate = formattedDate.split('T')[0];
  9. const signature = getSignatureV4(
  10. this.options.accessKeySecret,
  11. onlyDate,
  12. getStandardRegion(this.options.region),
  13. policyStr
  14. );
  15. return signature;
  16. }