Skip to content

Commit

Permalink
Merge pull request #209 from qgustavor/fixing-issue-205
Browse files Browse the repository at this point in the history
Handle `ssl` in API's pull request so Storage works in browsers
  • Loading branch information
qgustavor authored Sep 6, 2024
2 parents c8b6395 + 5acf2aa commit 9913351
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ class API extends EventEmitter {

pull (sn, retryno = 0) {
const controller = new AbortController()
const ssl = API.handleForceHttps() ? 1 : 0
this.sn = controller
this.fetch(`${this.gateway}sc?${new URLSearchParams({ sn, sid: this.sid })}`, {
this.fetch(`${this.gateway}sc?${new URLSearchParams({ sn, ssl, sid: this.sid })}`, {
method: 'POST',
signal: controller.signal
}).then(handleApiResponse).then(resp => {
Expand Down
2 changes: 2 additions & 0 deletions types/cjs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ declare namespace megajs {
sn?: AbortController
static globalApi?: API
static getGlobalApi (): API
static handleForceHttps (userOpt?: boolean): boolean
static getShouldAvoidUA (): boolean
constructor (keepalive: boolean, opts?: APIOpts)
close (): void
pull (sn: AbortController, retryno?: number): void
Expand Down
2 changes: 2 additions & 0 deletions types/es.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export declare class API extends EventEmitter {
sn?: AbortController
static globalApi?: API
static getGlobalApi (): API
static handleForceHttps (userOpt?: boolean): boolean
static getShouldAvoidUA (): boolean
constructor (keepalive: boolean, opts?: APIOpts)
close (): void
pull (sn: AbortController, retryno?: number): void
Expand Down

0 comments on commit 9913351

Please sign in to comment.