Skip to content

Commit 165d1df

Browse files
committed
platform improvement
1 parent a7df21e commit 165d1df

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

keeperapi/src/node/platform.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as crypto from 'crypto'
22
import { createECDH, hkdfSync } from 'crypto'
33
import * as https from 'https'
4-
import * as FormData from 'form-data'
4+
import * as FormDataModule from 'form-data'
55
import NodeRSA from 'node-rsa'
66
import * as WebSocket from 'faye-websocket'
77

@@ -13,6 +13,12 @@ import { normal64 } from '../utils'
1313
import { logger } from '../log'
1414
import type { KeeperHttpResponse } from '../commands'
1515

16+
// `form-data` uses CommonJS `export =`. Depending on the consumer/build target,
17+
// a namespace import may expose the constructor as either the module itself or
18+
// its `default` property.
19+
const FormData =
20+
(FormDataModule as unknown as { default?: typeof FormDataModule }).default || FormDataModule
21+
1622
const base64ToBytes = (data: string): Uint8Array => {
1723
return Buffer.from(data, 'base64')
1824
}

0 commit comments

Comments
 (0)