Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const appNamePrefix = getDataOrDefault(
data.cozyAppNamePrefix || require('../../../manifest.webapp').name_prefix,
''
)
const appName = getDataOrDefault(
data.cozyAppName,
require('../../../manifest.webapp').name
)
appLocale = getDataOrDefault(data.cozyLocale, 'en')
const protocol = window.location ? window.location.protocol : 'https:'
// initialize the client to interact with the cozy stack
const client = new CozyClient({
uri: `${protocol}//${data.cozyDomain}`,
token: data.cozyToken,
schema
})
// initialize the bar, common of all applications, it allows
// platform features like apps navigation without doing anything
cozy.bar.init({
appName: appName,
appNamePrefix: appNamePrefix,
iconPath: appIcon,
lang: appLocale,
replaceTitleOnMobile: true
})
renderApp(client)
'https://downcloud.cozycloud.cc/upload/cozy-banks/email-assets/logo-bank.png',
notificationPlatform: 'firebase'
},
links: getLinks({
pouchLink: {
// TODO: the revocation check via cozy-pouch-link should not be
// done in the app. We should find a way to have this in a shared
// repository, possibly in cozy-client or cozy-pouch-link
onSyncError: async () => {
checkForRevocation(client)
}
}
})
}
client = new CozyClient(merge(manifestOptions, banksOptions))
registerPluginsAndHandlers(client)
return client
}
)
})
const appInfo = {
name: 'Example bar',
slug: 'example-bar',
softwareID: 'io.cozy.example',
redirectURI: 'http://localhost:1234/auth',
protocol: 'cozyexample://',
universalLinkDomain: 'https://links.cozyexample.com'
}
const client = new CozyClient({
scope: ['io.cozy.apps', 'io.cozy.konnectors'],
// TODO client: All the oauth information could come from the manifest
oauth: {
clientName: appInfo.name,
softwareID: appInfo.softwareID,
redirectURI: appInfo.redirectURI
}
})
// TODO bar: should only need a correctly configured client
client.on('login', () => {
const oldOptions = {
token: client.stackClient.token.accessToken,
cozyURL: client.stackClient.uri
}
const newOptions = {
describe('intents', () => {
const stackClient = {
token: { token: 'mytoken' },
uri: 'https://test.mycozy.cloud'
}
const cozyClient = new CozyClient({
stackClient
})
const params = {
cozyClient,
onCreateApp: function() {},
onDeleteApp: function() {}
}
beforeAll(async () => {
await stack.init(params)
})
it('should return correctly the Intents instance', () => {
const intents = stack.get.intents()
expect(intents).toBeInstanceOf(Intents)
const setup = () => {
const client = new CozyClient({})
client.query = jest.fn(() => flagRemoteResponse)
return { client }
}
import { removeStats } from './accounts'
import CozyClient from 'cozy-client'
const client = new CozyClient({})
describe('removeStats', () => {
beforeEach(() => {
client.query = jest.fn()
client.destroy = jest.fn()
})
afterEach(() => {
jest.resetAllMocks()
})
it('should remove the stats doc corresponding to the account if it exists', async () => {
const account = { _id: 'account' }
const stats = { _id: 'stats' }
client.query.mockResolvedValueOnce({ data: [stats] })
import React from 'react'
import PropTypes from 'prop-types'
import contacts from '../ContactsList/data.json'
import CozyClient from 'cozy-client'
const mockClient = new CozyClient({
uri: 'http://cozy.tools:8080',
token: 'faketoken'
})
mockClient.__proto__.requestQuery = ({ doctype }) => {
if (doctype === 'io.cozy.contacts') {
return Promise.resolve({
fetchStatus: 'loaded',
data: contacts
})
}
if (doctype === 'io.cozy.apps') {
return Promise.resolve({
fetchStatus: 'loaded',
data: [
const setup = ({ pinSetting }) => {
const client = new CozyClient({})
client.query = jest.fn()
const root = mount(
)
return { root }
}