Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = async (opts) => {
const {
browser,
query
} = opts
ow(query, ow.string.nonEmpty.label('query'))
let page
try {
const page = await browser.newPage()
await page.goto('https://outlook.live.com/mail/inbox')
await delay(1000)
// search for an input query to narrow down email results
// TODO: don't require a search query
await page.waitFor('input[aria-label=Search]', { visible: true })
await delay(2000)
let attempts = 0
do {
await page.focus('input[aria-label=Search]')
constructor(connectionString) {
ow(connectionString, ow.string.url);
super();
this._connectionString = connectionString;
}
createStorage,
removeStorage,
renameStorage,
createFolder,
removeFolder,
createNote,
updateNote,
trashNote,
untrashNote,
purgeNote
}
}
}
const storageDataPredicate = schema({
id: ow.string,
name: ow.string
})
export const {
StoreProvider: DbProvider,
useStore: useDb
} = createStoreContext(createDbStoreCreator(localLiteStorage, 'idb'))
export function getStorageDataList(
liteStorage: LiteStorage
): NoteStorageData[] | null {
const serializedStorageDataList = liteStorage.getItem(storageDataListKey)
try {
const parsedStorageDataList = JSON.parse(serializedStorageDataList || '[]')
if (!Array.isArray(parsedStorageDataList))
[ComicSettingProperties.BINDING_TYPE]: BindingTypeOptional,
[ComicSettingProperties.LAZY_LOAD]: ow.optional.any(ow.boolean, ow.number.not.negative),
});
export const ImageData = ow.object.partialShape({
fileSize: notNegativeNumber,
index: notNegativeNumber,
path: ow.optional.string,
uri: ow.optional.string,
width: notNegativeNumberOptional,
height: notNegativeNumberOptional,
});
export const ComicParsedData = ow.object.partialShape({
images: ow.optional.array.ofType(ImageData),
unzipPath: ow.string,
});
async getTaskResult (taskId, opts = { }) {
ow(taskId, ow.string.nonEmpty)
ow(opts, ow.object.plain)
const {
retries = 3,
timeout = 30000,
...rest
} = opts
return pTimeout(pRetry(async () => {
const result = await this._provider.getTaskResult(taskId)
if (result.status !== 'ready') {
throw new Error(`task is still processing (status "${result.status}")`)
}
return result
constructor(parentPath, relativeChildPath) {
ow(parentPath, ow.string);
ow(relativeChildPath, ow.string);
this.absolute = path.join(parentPath, relativeChildPath);
this.parent = parentPath;
this.relative = relativeChildPath;
}
};
async getAuthCodes (opts) {
const {
retries = 3,
minTimeout = 5000,
maxTimeout = 20000,
timestamp = this._timestamp,
number,
service,
...rest
} = opts
ow(number, ow.string.nonEmpty.label('number'))
ow(service, ow.string.nonEmpty.label('service'))
ow(opts, ow.object.plain.nonEmpty.label('opts'))
let attempt = 0
return pRetry(async () => {
const messages = await this._provider.getMessages({ number, service, ...rest, attempt })
const results = (messages || [])
.filter((m) => m.service === service)
.filter((m) => !timestamp || m.timestamp >= timestamp)
.map((m) => m.code)
if (!results.length) {
++attempt
throw new Error(`waiting for SMS message for service \`${service}\` at number \`${number}\``)
}
export default async (input) => {
ow(input, ow.any(
ow.string.nonEmpty.label('input'),
ow.object.instanceOf(global.Image).label('input')
))
const image = await loadImage(input)
return {
width: image.width,
height: image.height
}
}