Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(async () => {
const storeOptions = {fileExtension: '.json'};
const storeEngine = new FileEngine(storagePath, storeOptions);
await storeEngine.init(storagePath, storeOptions);
const config = {
store: storeEngine,
urls: APIClient.BACKEND.STAGING,
};
const apiClient = new APIClient(config);
apiClient.on(APIClient.TOPIC.ACCESS_TOKEN_REFRESH, async (accessToken: AccessTokenData) => {
await storeEngine.updateOrCreate(AUTH_TABLE_NAME, AUTH_ACCESS_TOKEN_KEY, accessToken);
logger.log(`Saved access token`, accessToken);
});
apiClient.on(APIClient.TOPIC.COOKIE_REFRESH, async (cookie?: Cookie) => {
if (cookie) {
const storeEngineProvider = async (storeName: string) => {
const engine = new FileEngine(directory);
await engine.init(storeName, {fileExtension: '.json'});
return engine;
};
(async () => {
const CONVERSATION_ID = program.conversationId || process.env.WIRE_CONVERSATION_ID;
const MESSAGE_TIMER = TimeUtil.TimeInMillis.SECOND * 5;
const login = {
clientType: ClientType.TEMPORARY,
email: process.env.WIRE_EMAIL,
password: process.env.WIRE_PASSWORD,
};
const backend = process.env.WIRE_BACKEND === 'staging' ? APIClient.BACKEND.STAGING : APIClient.BACKEND.PRODUCTION;
const engine = new FileEngine(path.join(__dirname, '.tmp', 'sender'));
await engine.init(undefined, {fileExtension: '.json'});
const apiClient = new APIClient({store: engine, urls: backend});
const account = new Account(apiClient);
await account.login(login);
await account.listen();
account.on('error', error => logger.error(error));
const name = await account.service.self.getName();
logger.log('Name', name);
logger.log('User ID', account.apiClient.context.userId);
logger.log('Client ID', account.apiClient.context.clientId);
async function sendAndDeleteMessage() {