@@ -37,7 +37,7 @@ enum ResponseType {
3737 Binary = 3
3838}
3939
40- type Part = string | number [ ]
40+ type Part = string | Uint8Array
4141
4242/** The body object to be used on POST and PUT requests. */
4343class Body {
@@ -58,7 +58,14 @@ class Body {
5858 * @return The body object ready to be used on the POST and PUT requests.
5959 */
6060 static form ( data : Record < string , Part > ) : Body {
61- return new Body ( 'Form' , data )
61+ const form : Record < string , string | number [ ] > = { }
62+ for ( const key in data ) {
63+ // eslint-disable-next-line security/detect-object-injection
64+ const v = data [ key ]
65+ // eslint-disable-next-line security/detect-object-injection
66+ form [ key ] = typeof v === 'string' ? v : Array . from ( v )
67+ }
68+ return new Body ( 'Form' , form )
6269 }
6370
6471 /**
@@ -90,8 +97,9 @@ class Body {
9097 *
9198 * @return The body object ready to be used on the POST and PUT requests.
9299 */
93- static bytes ( bytes : number [ ] ) : Body {
94- return new Body ( 'Bytes' , bytes )
100+ static bytes ( bytes : Uint8Array ) : Body {
101+ // stringifying Uint8Array doesn't return an array of numbers, so we create one here
102+ return new Body ( 'Bytes' , Array . from ( bytes ) )
95103 }
96104}
97105
0 commit comments