fix: page.authenticate

This commit is contained in:
orion 2023-10-08 11:21:23 -05:00
parent 9977c83259
commit b40bcdb92d
Signed by: orion
GPG Key ID: 6D4165AE4C928719
2 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,9 @@ export const _newPage = b => () => b.newPage()
/** @type {(_: Browser | BrowserContext) => () => Promise<Array<Page>>} */
export const _all = b => () => b.pages()
/** @type {(_: {username: string, password: string}) => (_: Page) => () => Promise<void>} */
export const _authenticate = creds => p => () => p.authenticate(creds)
/**
* @type {(_1: string) => (_2: Page) => () => Promise<Array<ElementHandle<any>>>}
*/

View File

@ -1,5 +1,6 @@
module Puppeteer.Page
( module X
, authenticate
, new
, all
, findAll
@ -102,6 +103,7 @@ foreign import mouse :: Page -> Effect Unit
foreign import touchscreen :: Page -> Effect Unit
foreign import isClosed :: Page -> Effect Boolean
foreign import _authenticate :: { username :: String, password :: String } -> Page -> Effect (Promise Unit)
foreign import _newPage :: Foreign -> Effect (Promise Page)
foreign import _all :: Foreign -> Effect (Promise (Array Page))
foreign import _findAll :: forall a. String -> Page -> Effect (Promise (Array (Handle a)))
@ -118,6 +120,9 @@ foreign import _viewport :: Page -> Foreign
new :: forall b. PageProducer b => b -> Aff Page
new = Promise.toAffE <<< _newPage <<< unsafeToForeign
authenticate :: { username :: String, password :: String } -> Page -> Aff Unit
authenticate creds = Promise.toAffE <<< _authenticate creds
all :: forall b. PageProducer b => b -> Aff (Array Page)
all = Promise.toAffE <<< _all <<< unsafeToForeign