mirror of
https://github.com/logto-io/logto.git
synced 2025-03-17 22:31:28 -05:00
fix(aliyun): skip undefined fields (#208)
This commit is contained in:
parent
30ce91810f
commit
3cb1cae486
1 changed files with 5 additions and 6 deletions
|
@ -3,8 +3,6 @@ import { createHmac } from 'crypto';
|
|||
import { has } from '@silverhand/essentials';
|
||||
import got from 'got';
|
||||
|
||||
import { ConnectorError } from '../types';
|
||||
|
||||
// Aliyun has special excape rules.
|
||||
// https://help.aliyun.com/document_detail/29442.html
|
||||
const escaper = (string_: string) =>
|
||||
|
@ -28,12 +26,13 @@ export const getSignature = (
|
|||
.map((key) => {
|
||||
const value = parameters[key];
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
throw new ConnectorError('Invalid value');
|
||||
if (value === undefined || value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return `${escaper(key)}=${escaper(value)}`;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join('&');
|
||||
|
||||
const stringToSign = `${method.toUpperCase()}&${escaper('/')}&${escaper(canonicalizedQuery)}`;
|
||||
|
@ -71,8 +70,8 @@ export const request = async <T>(
|
|||
if (has(finalParameters, key)) {
|
||||
const value = finalParameters[key];
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
throw new ConnectorError('Invalid value');
|
||||
if (value === undefined || value === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
payload.append(key, value);
|
||||
|
|
Loading…
Add table
Reference in a new issue