Skip to content

Instantly share code, notes, and snippets.

View xlewkanx's full-sized avatar

Oleksii Smirnov xlewkanx

View GitHub Profile
@xlewkanx
xlewkanx / index.js
Last active March 17, 2020 09:34
Migrate from v4 to e3kit-js v0.4.1
// to load private keys created with sdk v4, you can use the `KeyStorage` class from sdk v5 - https://github.com/VirgilSecurity/virgil-sdk-javascript/blob/master/src/Storage/KeyStorage.ts
// (ignore the deprecation warning)
// note, if you used the default key storage name with sdk v4 (i.e. didn't provide `keyStorageName` option to the `API` function),
// then you will have to provide a `name` config parameter equal to "VirgilSecurityKeys" into the `KeyStorage` constructor - `new KeyStorage({ name: "VirgilSecurityKeys" })`
// otherwise, provide the same value as you did for the `keyStorageName` option
// One caveat is that the `KeyStorage` from v5 sdk only uses IndexedDB as a storage backend, whereas in v4 we used the localforage (https://github.com/localForage/localForage)
// library, which aslo uses IndexedDB, but falls back to using WebSQL or localStorage if IndexedDB is not available.
// So if you can verify that all of your users have devices that support IndexedDB (https://caniuse.com/#search=Indexe
@xlewkanx
xlewkanx / main.js
Created May 3, 2019 10:24
Back4App and Virgil server
const axios = require("axios");
const { JwtGenerator } = require("virgil-sdk");
const { VirgilCrypto, VirgilAccessTokenSigner } = require("virgil-crypto");
const crypto = new VirgilCrypto();
const APP_ID = "YOUR_VIRGIL_APP_ID";
const API_KEY = "YOUR_VIRGIL_API_KEY";
const API_KEY_ID = "YOUR_VIRGIL_APP_ID";
const PARSE_APP_ID = "YOUR_PARSE_APP_ID";
const PARSE_REST_API_KEY = "YOUR_PARSE_REST_API_KEY";
@xlewkanx
xlewkanx / channel.js
Last active December 22, 2018 15:59
e3kit twilio js
async function createChannel(twilioChat, uniqueName, friendlyName) {
return await twilioChat.createChannel({
uniqueName,
friendlyName
});
}
async function joinChannel(twilioChat, name) {
const paginator = await twilioChat.getPublicChannelDescriptors();
for (i = 0; i < paginator.items.length; i++) {
@xlewkanx
xlewkanx / index.js
Last active November 23, 2018 11:56
Dmytro authentications strategies
// Single Device
// User sign up
async function onUserSignUp(user) {
const getToken = () => fetchToken(user.token);
// Initialize e3kit - see full sample in EThree.initialize page
const eThree = await EThree.initialize(getToken);
// Bootstrap user (i.e.create private key if user with this identity doesn't exists yet)
eThree.bootstrap();
@xlewkanx
xlewkanx / hello.js
Last active July 4, 2018 08:44
medium demo
console.log(new String('hello world').toString())
var fs = require('fs');
var watch = fs.watch('./', (event, filename) => {
console.log(`event is: ${event}`);
if (filename) {
console.log(`filename provided: ${filename}`);
} else {
console.log('filename not provided');
}
});
var props = Ti.App.Properties.listProperties();
for (var i=0, ilen=props.length; i<ilen; i++){
var value = Ti.App.Properties.removeProperty(props[i]);
Ti.API.info(props[i] + 'cleared');
}
@xlewkanx
xlewkanx / directive
Last active October 12, 2015 19:28
image on load
function imageOnLoad($q) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var dfd = $q.defered();
element.bind('load', function(e) {
dfd.resolve();
});
return dfd;
}
var $posterService = require('../../service/posters');
router.get('/posters/:id', function(req, res, next) {
var id = new Number(req.params.id).toString();
if (id != "NaN")
res.render('sliders',{
posters: $posterService.pull(id)
});