-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from VirgilSecurity/feature/storage-adapter
Feature/storage adapter
- Loading branch information
Showing
73 changed files
with
25,227 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const path = require('path'); | ||
const noPythiaCryptoPath = require.resolve('virgil-crypto'); | ||
const pythiaCryptoPath = path.resolve(noPythiaCryptoPath, '../virgil-crypto-pythia.es.js'); | ||
const pythiaCryptoBrowserPath = path.resolve(noPythiaCryptoPath, '../virgil-crypto-pythia.browser.es.js'); | ||
|
||
class Paths { | ||
constructor() { | ||
this.PLATFORM = process.env.PLATFORM || 'node'; | ||
this.IS_BROWSER = this.PLATFORM === 'browser'; | ||
this.NAME = 'e3kit'; | ||
|
||
this.input = path.join(process.cwd(), 'src', 'index.ts'); | ||
this.outputDir = path.join(process.cwd(), 'dist'); | ||
|
||
this.formats = { | ||
umd: 'umd', | ||
es: 'es', | ||
cjs: 'cjs' | ||
} | ||
this.pythiaCryptoPath = this.IS_BROWSER ? pythiaCryptoBrowserPath : pythiaCryptoPath; | ||
} | ||
|
||
getFileName(format) { | ||
const parts = [this.NAME, this.PLATFORM, format]; | ||
|
||
if (format === this.formats.umd) { | ||
parts.push('min'); | ||
} | ||
const ext = (format === this.formats.es && this.PLATFORM === 'node') ? 'mjs' : 'js'; | ||
parts.push(ext); | ||
return parts.join('.'); | ||
} | ||
} | ||
|
||
module.exports = new Paths(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const paths = require('./paths'); | ||
|
||
const commonjs = require('rollup-plugin-commonjs'); | ||
const inject = require('rollup-plugin-inject'); | ||
const nodeGlobals = require('rollup-plugin-node-globals'); | ||
const resolve = require('rollup-plugin-node-resolve'); | ||
const typescript = require('rollup-plugin-typescript2'); | ||
const { uglify } = require('rollup-plugin-uglify'); | ||
const sourcemap = require('rollup-plugin-sourcemaps'); | ||
|
||
|
||
function resolveVirgilCrypto () { | ||
return { | ||
name: 'resolve-virgil-crypto', | ||
resolveId (importee, b) { | ||
if (importee === 'virgil-crypto') { | ||
return paths.pythiaCryptoPath; | ||
} | ||
return null; | ||
} | ||
} | ||
} | ||
|
||
class RollupPluginsResolver { | ||
|
||
constructor() { | ||
this.commonjs = commonjs; | ||
this.nodeGlobals = nodeGlobals; | ||
this.resolve = resolve; | ||
this.sourcemap = sourcemap; | ||
this.uglify = uglify; | ||
this.resolveVirgilCrypto = resolveVirgilCrypto; | ||
this.typescriptResolved = typescript({ | ||
exclude: ['**/*.test.ts', '**/*.spec.ts', '**/__mocks__/*.ts'], | ||
useTsconfigDeclarationDir: true, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = new RollupPluginsResolver(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const paths = require('./paths'); | ||
const plugins = require('./rollup-plugins'); | ||
|
||
const format = paths.formats.es; | ||
|
||
module.exports = { | ||
input: paths.input, | ||
output: { | ||
format: format, | ||
file: paths.getFileName(format, false), | ||
dir: paths.outputDir, | ||
sourcemap: true, | ||
}, | ||
plugins: [ | ||
plugins.resolveVirgilCrypto(), | ||
plugins.resolve({ browser: true }), | ||
plugins.commonjs(), | ||
plugins.typescriptResolved, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const paths = require('./paths'); | ||
const plugins = require('./rollup-plugins'); | ||
|
||
const UMD_NAME = 'E3kit'; | ||
|
||
module.exports = { | ||
input: paths.input, | ||
output: { | ||
format: paths.formats.umd, | ||
file: paths.getFileName(paths.formats.umd, true), | ||
dir: paths.outputDir, | ||
sourcemap: true, | ||
name: UMD_NAME | ||
}, | ||
plugins: [ | ||
plugins.sourcemap(), | ||
plugins.resolveVirgilCrypto(), | ||
plugins.resolve({ browser: true }), | ||
plugins.commonjs(), | ||
plugins.typescriptResolved, | ||
plugins.uglify(), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["module:metro-react-native-babel-preset"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
[android] | ||
target = Google Inc.:Google APIs:23 | ||
|
||
[maven_repositories] | ||
central = https://repo1.maven.org/maven2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
[ignore] | ||
; We fork some components by platform | ||
.*/*[.]android.js | ||
|
||
; Ignore "BUCK" generated dirs | ||
<PROJECT_ROOT>/\.buckd/ | ||
|
||
; Ignore unexpected extra "@providesModule" | ||
.*/node_modules/.*/node_modules/fbjs/.* | ||
|
||
; Ignore duplicate module providers | ||
; For RN Apps installed via npm, "Libraries" folder is inside | ||
; "node_modules/react-native" but in the source repo it is in the root | ||
.*/Libraries/react-native/React.js | ||
|
||
; Ignore polyfills | ||
.*/Libraries/polyfills/.* | ||
|
||
; Ignore metro | ||
.*/node_modules/metro/.* | ||
|
||
[include] | ||
|
||
[libs] | ||
node_modules/react-native/Libraries/react-native/react-native-interface.js | ||
node_modules/react-native/flow/ | ||
node_modules/react-native/flow-github/ | ||
|
||
[options] | ||
emoji=true | ||
|
||
esproposal.optional_chaining=enable | ||
esproposal.nullish_coalescing=enable | ||
|
||
module.system=haste | ||
module.system.haste.use_name_reducers=true | ||
# get basename | ||
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' | ||
# strip .js or .js.flow suffix | ||
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' | ||
# strip .ios suffix | ||
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' | ||
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' | ||
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' | ||
module.system.haste.paths.blacklist=.*/__tests__/.* | ||
module.system.haste.paths.blacklist=.*/__mocks__/.* | ||
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.* | ||
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.* | ||
|
||
munge_underscores=true | ||
|
||
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' | ||
|
||
module.file_ext=.js | ||
module.file_ext=.jsx | ||
module.file_ext=.json | ||
module.file_ext=.native.js | ||
|
||
suppress_type=$FlowIssue | ||
suppress_type=$FlowFixMe | ||
suppress_type=$FlowFixMeProps | ||
suppress_type=$FlowFixMeState | ||
|
||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError | ||
|
||
[version] | ||
^0.78.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pbxproj -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
# Android/IntelliJ | ||
# | ||
build/ | ||
.idea | ||
.gradle | ||
local.properties | ||
*.iml | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
*.keystore | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
# screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/ | ||
|
||
*/fastlane/report.xml | ||
*/fastlane/Preview.html | ||
*/fastlane/screenshots | ||
|
||
# Bundle artifact | ||
*.jsbundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Sample React Native App | ||
* https://github.com/facebook/react-native | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
import React, {Component} from 'react'; | ||
import {Platform, StyleSheet, Text, View} from 'react-native'; | ||
import { EThree } from '@virgilsecurity/e3kit'; | ||
import createNativeKeyEntryStorage from '@virgilsecurity/key-storage-rn/native'; | ||
const keyEntryStorage = createNativeKeyEntryStorage(); | ||
import 'whatwg-fetch'; | ||
import 'es6-symbol' | ||
|
||
const instructions = Platform.select({ | ||
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', | ||
android: | ||
'Double tap R on your keyboard to reload,\n' + | ||
'Shake or press menu button for dev menu', | ||
}); | ||
|
||
export default class App extends Component { | ||
|
||
state = { | ||
message: null | ||
} | ||
|
||
componentDidMount() { | ||
const getToken = () => fetch("http://localhost:3000/get-virgil-jwt") | ||
.then(res => res.json()) | ||
.then(data => data.token); | ||
|
||
EThree.initialize(getToken, { keyEntryStorage: keyEntryStorage }) | ||
.then(client => sdk = client) | ||
.then(() => sdk.register()) | ||
.then(() => sdk.encrypt('success!')) | ||
.then((encryptedMessage) => sdk.decrypt(encryptedMessage)) | ||
.then((message) => this.setState({ message: message })) | ||
.then(() => sdk.cleanup()) | ||
.catch((error) => { | ||
this.setState({ message: error.toString() }) | ||
}); | ||
} | ||
render() { | ||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.welcome}>Welcome to React Native!</Text> | ||
<Text style={styles.instructions}>To get started, edit App.js</Text> | ||
<Text style={styles.instructions}>{instructions}</Text> | ||
{this.state.message && <Text style={styles.instructions}>{this.state.message}</Text>} | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '#F5FCFF', | ||
}, | ||
welcome: { | ||
fontSize: 20, | ||
textAlign: 'center', | ||
margin: 10, | ||
}, | ||
instructions: { | ||
textAlign: 'center', | ||
color: '#333333', | ||
marginBottom: 5, | ||
}, | ||
}); |
Oops, something went wrong.