Skip to content

Instantly share code, notes, and snippets.

View majirosstefan's full-sized avatar
🏠
Working from home

Stefan Majiros majirosstefan

🏠
Working from home
View GitHub Profile
@majirosstefan
majirosstefan / Remote Mobile App Development Studio
Created October 21, 2021 10:04
It does not matter, if you are in New York, Chicago, Boston or Barcelona... I can always help you!
See more at stefan-majiros.com!
@majirosstefan
majirosstefan / verify.safetynet.webauthn.js
Created October 10, 2021 23:16 — forked from yackermann/verify.safetynet.webauthn.js
WebAuthn Android SafetyNet attestation verification sample in NodeJS
const crypto = require('crypto');
const base64url = require('base64url');
const cbor = require('cbor');
const jsrsasign = require('jsrsasign');
let gsr2 = 'MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9iYWxzaWduLm5ldC9yb290LXI
node makeTranslations.js
// 💖 or if you used global installation of translate-json-object library, you would need to use
NODE_PATH=$(npm root -g) node ./scripts/makeTranslations.js
// 💖 or add it as npm script into package.json, so you would run it w/ npm run checkTranslations command
"checkTranslations": "NODE_PATH=$(npm root -g) node ./scripts/makeTranslations.js"
module.exports = [
'af', 'am','az', 'be', 'bg', 'bn', 'bs', 'ca',
'co', 'cs', 'cy', 'da', 'de', 'el', 'en', 'eo',
'es', 'et', 'eu', 'fa', 'fi', 'fr', 'fy', 'ga',
'gd', 'gl', 'gu', 'ha', 'hi', 'hr', 'ht', 'hu',
'hy', 'id', 'ig', 'is', 'it', 'iw', 'ja', 'jw',
'ka', 'kk', 'km', 'kn', 'ko', 'ku', 'ky', 'la',
'lb', 'lo', 'lt', 'lv', 'mg', 'mi', 'mk', 'ml',
'mn', 'mr', 'ms', 'mt', 'my', 'ne', 'nl', 'no',
'ny', 'pl', 'ps', 'pt', 'ro', 'ru', 'sd', 'si',
const {createWriteStream} = require('fs');
// installed from my own repository , globally
var TJO = require('translate-json-object')();
// 💖
var json_SOURCE_OF_TRUTH = require('../src/localization/translations/en.json');
var supportedLanguages = require('./supportedLanguages');
var fs = require('fs');
var path = require('path');
import React from 'react';
import {
FlatList,
InteractionManager,
StyleSheet,
TouchableOpacity,
View,
} from 'react-native';
import * as Animatable from 'react-native-animatable';
import {currentLocale, translate} from '../localization';
import moment from 'moment';
import {momentLocalesFileMappings} from './translationFileMappings';
const DATE_FORMAT = 'YYYY-DD-MM';
// 💖 Here we tell moment to change locale in runtime
export const setMomentLocale = async locale => {
momentLocalesFileMappings[locale]();
return moment().locale(locale);
};
export const momentLocalesFileMappings = {
// lazy requires (metro bundler does not support symlinks)
af: () => require('moment/locale/af'),
ar: () => require('moment/locale/ar'),
az: () => require('moment/locale/az'),
be: () => require('moment/locale/be'),
bg: () => require('moment/locale/bg'),
bn: () => require('moment/locale/bn'),
bs: () => require('moment/locale/bs'),
ca: () => require('moment/locale/ca'),
export const translationFileMappings = {
// lazy requires (metro bundler does not support symlinks)
af: () => require('./translations/af.json'),
am: () => require('./translations/am.json'),
az: () => require('./translations/az.json'),
be: () => require('./translations/be.json'),
bg: () => require('./translations/bg.json'),
bn: () => require('./translations/bn.json'),
bs: () => require('./translations/bs.json'),
ca: () => require('./translations/ca.json'),
import i18n from 'i18n-js';
import memoize from 'lodash.memoize';
// 💖 we will use translate in our components
export const translate = memoize((key, config) => i18n.t(key, config));
export const currentLocale = () => i18n.locale;
// 💖 this is function responsinble for changing locale
export const setI18nConfig = async languageTag => {