aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.bowerrc3
-rw-r--r--.editorconfig24
-rw-r--r--.gitattributes1
-rw-r--r--.gitignore8
-rw-r--r--.jshintrc27
-rw-r--r--.yo-rc.json3
-rw-r--r--Gruntfile.js329
-rw-r--r--app/_locales/en/messages.json10
-rw-r--r--app/images/icon-128.pngbin0 -> 5356 bytes
-rw-r--r--app/images/icon-16.pngbin0 -> 758 bytes
-rw-r--r--app/images/icon-19.pngbin0 -> 1967 bytes
-rw-r--r--app/images/icon-38.pngbin0 -> 4265 bytes
-rw-r--r--app/manifest.json41
-rw-r--r--app/popup.html25
-rw-r--r--app/scripts/background.js9
-rw-r--r--app/scripts/chromereload.js22
-rw-r--r--app/scripts/contentscript.js8
-rw-r--r--app/scripts/popup.js3
-rw-r--r--app/scripts/web3.js2
-rw-r--r--app/styles/main.css3
-rw-r--r--bower.json6
-rw-r--r--package.json34
-rw-r--r--test/index.html29
-rw-r--r--test/spec/test.js11
24 files changed, 598 insertions, 0 deletions
diff --git a/.bowerrc b/.bowerrc
new file mode 100644
index 000000000..5773025bf
--- /dev/null
+++ b/.bowerrc
@@ -0,0 +1,3 @@
+{
+ "directory": "app/bower_components"
+}
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..609f684a0
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,24 @@
+# EditorConfig helps developers define and maintain consistent
+# coding styles between different editors and IDEs
+# editorconfig.org
+
+root = true
+
+
+[*]
+
+# Change these settings to your own preference
+indent_style = space
+indent_size = 2
+
+[*.json]
+indent_size = 2
+
+# We recommend you to keep these unchanged
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 000000000..212566614
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto \ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..5a889698a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+node_modules
+temp
+.tmp
+dist
+.sass-cache
+app/bower_components
+test/bower_components
+package
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 000000000..6dc5ecc6b
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,27 @@
+{
+ "node": true,
+ "browser": true,
+ "esnext": true,
+ "bitwise": true,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "indent": 2,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "quotmark": "single",
+ "regexp": true,
+ "undef": true,
+ "unused": true,
+ "strict": true,
+ "trailing": true,
+ "smarttabs": true,
+ "globals" : {
+ "chrome": true,
+ "crypto": true,
+ "describe": true,
+ "it": true
+ }
+}
diff --git a/.yo-rc.json b/.yo-rc.json
new file mode 100644
index 000000000..7a2135249
--- /dev/null
+++ b/.yo-rc.json
@@ -0,0 +1,3 @@
+{
+ "generator-mocha": {}
+} \ No newline at end of file
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 000000000..5f9b271ee
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,329 @@
+// Generated on 2015-07-31 using generator-chrome-extension 0.3.1
+'use strict';
+
+// # Globbing
+// for performance reasons we're only matching one level down:
+// 'test/spec/{,*/}*.js'
+// use this if you want to recursively match all subfolders:
+// 'test/spec/**/*.js'
+
+module.exports = function (grunt) {
+
+ // Load grunt tasks automatically
+ require('load-grunt-tasks')(grunt);
+
+ // Time how long tasks take. Can help when optimizing build times
+ require('time-grunt')(grunt);
+
+ // Configurable paths
+ var config = {
+ app: 'app',
+ dist: 'dist'
+ };
+
+ grunt.initConfig({
+
+ // Project settings
+ config: config,
+
+ // Watches files for changes and runs tasks based on the changed files
+ watch: {
+ bower: {
+ files: ['bower.json'],
+ tasks: ['bowerInstall']
+ },
+ js: {
+ files: ['<%= config.app %>/scripts/{,*/}*.js'],
+ options: {
+ livereload: '<%= connect.options.livereload %>'
+ }
+ },
+ gruntfile: {
+ files: ['Gruntfile.js']
+ },
+ styles: {
+ files: ['<%= config.app %>/styles/{,*/}*.css'],
+ tasks: [],
+ options: {
+ livereload: '<%= connect.options.livereload %>'
+ }
+ },
+ livereload: {
+ options: {
+ livereload: '<%= connect.options.livereload %>'
+ },
+ files: [
+ '<%= config.app %>/*.html',
+ '<%= config.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
+ '<%= config.app %>/manifest.json',
+ '<%= config.app %>/_locales/{,*/}*.json'
+ ]
+ }
+ },
+
+ // Grunt server and debug server setting
+ connect: {
+ options: {
+ port: 9000,
+ livereload: 35729,
+ // change this to '0.0.0.0' to access the server from outside
+ hostname: 'localhost'
+ },
+ chrome: {
+ options: {
+ open: false,
+ base: [
+ '<%= config.app %>'
+ ]
+ }
+ },
+ test: {
+ options: {
+ open: false,
+ base: [
+ 'test',
+ '<%= config.app %>'
+ ]
+ }
+ }
+ },
+
+ // Empties folders to start fresh
+ clean: {
+ chrome: {
+ },
+ dist: {
+ files: [{
+ dot: true,
+ src: [
+ '<%= config.dist %>/*',
+ '!<%= config.dist %>/.git*'
+ ]
+ }]
+ }
+ },
+
+ // Make sure code styles are up to par and there are no obvious mistakes
+ jshint: {
+ options: {
+ jshintrc: '.jshintrc',
+ reporter: require('jshint-stylish')
+ },
+ all: [
+ 'Gruntfile.js',
+ '<%= config.app %>/scripts/{,*/}*.js',
+ '!<%= config.app %>/scripts/vendor/*',
+ 'test/spec/{,*/}*.js'
+ ]
+ },
+ mocha: {
+ all: {
+ options: {
+ run: true,
+ urls: ['http://localhost:<%= connect.options.port %>/index.html']
+ }
+ }
+ },
+
+ // Automatically inject Bower components into the HTML file
+ bowerInstall: {
+ app: {
+ src: [
+ '<%= config.app %>/*.html'
+ ]
+ }
+ },
+
+ // Reads HTML for usemin blocks to enable smart builds that automatically
+ // concat, minify and revision files. Creates configurations in memory so
+ // additional tasks can operate on them
+ useminPrepare: {
+ options: {
+ dest: '<%= config.dist %>'
+ },
+ html: [
+ '<%= config.app %>/popup.html',
+ '<%= config.app %>/options.html'
+ ]
+ },
+
+ // Performs rewrites based on rev and the useminPrepare configuration
+ usemin: {
+ options: {
+ assetsDirs: ['<%= config.dist %>', '<%= config.dist %>/images']
+ },
+ html: ['<%= config.dist %>/{,*/}*.html'],
+ css: ['<%= config.dist %>/styles/{,*/}*.css']
+ },
+
+ // The following *-min tasks produce minifies files in the dist folder
+ imagemin: {
+ dist: {
+ files: [{
+ expand: true,
+ cwd: '<%= config.app %>/images',
+ src: '{,*/}*.{gif,jpeg,jpg,png}',
+ dest: '<%= config.dist %>/images'
+ }]
+ }
+ },
+
+ svgmin: {
+ dist: {
+ files: [{
+ expand: true,
+ cwd: '<%= config.app %>/images',
+ src: '{,*/}*.svg',
+ dest: '<%= config.dist %>/images'
+ }]
+ }
+ },
+
+ htmlmin: {
+ dist: {
+ options: {
+ // removeCommentsFromCDATA: true,
+ // collapseWhitespace: true,
+ // collapseBooleanAttributes: true,
+ // removeAttributeQuotes: true,
+ // removeRedundantAttributes: true,
+ // useShortDoctype: true,
+ // removeEmptyAttributes: true,
+ // removeOptionalTags: true
+ },
+ files: [{
+ expand: true,
+ cwd: '<%= config.app %>',
+ src: '*.html',
+ dest: '<%= config.dist %>'
+ }]
+ }
+ },
+
+ // By default, your `index.html`'s <!-- Usemin block --> will take care of
+ // minification. These next options are pre-configured if you do not wish
+ // to use the Usemin blocks.
+ // cssmin: {
+ // dist: {
+ // files: {
+ // '<%= config.dist %>/styles/main.css': [
+ // '<%= config.app %>/styles/{,*/}*.css'
+ // ]
+ // }
+ // }
+ // },
+ // uglify: {
+ // dist: {
+ // files: {
+ // '<%= config.dist %>/scripts/scripts.js': [
+ // '<%= config.dist %>/scripts/scripts.js'
+ // ]
+ // }
+ // }
+ // },
+ // concat: {
+ // dist: {}
+ // },
+
+ // Copies remaining files to places other tasks can use
+ copy: {
+ dist: {
+ files: [{
+ expand: true,
+ dot: true,
+ cwd: '<%= config.app %>',
+ dest: '<%= config.dist %>',
+ src: [
+ '*.{ico,png,txt}',
+ 'images/{,*/}*.{webp,gif}',
+ '{,*/}*.html',
+ 'styles/{,*/}*.css',
+ 'styles/fonts/{,*/}*.*',
+ '_locales/{,*/}*.json',
+ ]
+ }]
+ }
+ },
+
+ // Run some tasks in parallel to speed up build process
+ concurrent: {
+ chrome: [
+ ],
+ dist: [
+ 'imagemin',
+ 'svgmin'
+ ],
+ test: [
+ ]
+ },
+
+ // Auto buildnumber, exclude debug files. smart builds that event pages
+ chromeManifest: {
+ dist: {
+ options: {
+ buildnumber: true,
+ indentSize: 2,
+ background: {
+ target: 'scripts/background.js',
+ exclude: [
+ 'scripts/chromereload.js'
+ ]
+ }
+ },
+ src: '<%= config.app %>',
+ dest: '<%= config.dist %>'
+ }
+ },
+
+ // Compres dist files to package
+ compress: {
+ dist: {
+ options: {
+ archive: function() {
+ var manifest = grunt.file.readJSON('app/manifest.json');
+ return 'package/metamask-' + manifest.version + '.zip';
+ }
+ },
+ files: [{
+ expand: true,
+ cwd: 'dist/',
+ src: ['**'],
+ dest: ''
+ }]
+ }
+ }
+ });
+
+ grunt.registerTask('debug', function () {
+ grunt.task.run([
+ 'concurrent:chrome',
+ 'connect:chrome',
+ 'watch'
+ ]);
+ });
+
+ grunt.registerTask('test', [
+ 'jshint',
+ 'connect:test',
+ 'mocha'
+ ]);
+
+ grunt.registerTask('build', [
+ 'clean:dist',
+ 'chromeManifest:dist',
+ 'useminPrepare',
+ 'concurrent:dist',
+ 'cssmin',
+ 'concat',
+ 'uglify',
+ 'copy',
+ 'usemin',
+ 'compress'
+ ]);
+
+ grunt.registerTask('default', [
+ 'jshint',
+ 'test',
+ 'build'
+ ]);
+};
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json
new file mode 100644
index 000000000..4414e6533
--- /dev/null
+++ b/app/_locales/en/messages.json
@@ -0,0 +1,10 @@
+{
+ "appName": {
+ "message": "metamask",
+ "description": "The name of the application"
+ },
+ "appDescription": {
+ "message": "Ethereum Identity Management",
+ "description": "The description of the application"
+ }
+}
diff --git a/app/images/icon-128.png b/app/images/icon-128.png
new file mode 100644
index 000000000..75c023a53
--- /dev/null
+++ b/app/images/icon-128.png
Binary files differ
diff --git a/app/images/icon-16.png b/app/images/icon-16.png
new file mode 100644
index 000000000..7df748fba
--- /dev/null
+++ b/app/images/icon-16.png
Binary files differ
diff --git a/app/images/icon-19.png b/app/images/icon-19.png
new file mode 100644
index 000000000..20c54d41f
--- /dev/null
+++ b/app/images/icon-19.png
Binary files differ
diff --git a/app/images/icon-38.png b/app/images/icon-38.png
new file mode 100644
index 000000000..c453adcc1
--- /dev/null
+++ b/app/images/icon-38.png
Binary files differ
diff --git a/app/manifest.json b/app/manifest.json
new file mode 100644
index 000000000..f053ef594
--- /dev/null
+++ b/app/manifest.json
@@ -0,0 +1,41 @@
+{
+ "name": "__MSG_appName__",
+ "version": "0.0.1",
+ "manifest_version": 2,
+ "description": "__MSG_appDescription__",
+ "icons": {
+ "16": "images/icon-16.png",
+ "128": "images/icon-128.png"
+ },
+ "default_locale": "en",
+ "background": {
+ "scripts": [
+ "scripts/chromereload.js",
+ "scripts/background.js"
+ ]
+ },
+ "browser_action": {
+ "default_icon": {
+ "19": "images/icon-19.png",
+ "38": "images/icon-38.png"
+ },
+ "default_title": "metamask",
+ "default_popup": "popup.html"
+ },
+ "content_scripts": [
+ {
+ "matches": [
+ "http://*/*",
+ "https://*/*"
+ ],
+ "js": [
+ "scripts/contentscript.js"
+ ],
+ "run_at": "document_start",
+ "all_frames": false
+ }
+ ],
+ "web_accessible_resources": [
+ "scripts/web3.js"
+ ]
+}
diff --git a/app/popup.html b/app/popup.html
new file mode 100644
index 000000000..bc8b6411b
--- /dev/null
+++ b/app/popup.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <!-- build:css styles/vendor.css -->
+ <!-- bower:css -->
+ <!-- endbower -->
+ <!-- endbuild -->
+ <!-- build:css styles/main.css -->
+ <link href="styles/main.css" rel="stylesheet">
+ <!-- endbuild -->
+ </head>
+ <body>
+ <h1>'Allo, 'Allo!</h1>
+
+ <!-- build:js scripts/vendor.js -->
+ <!-- bower:js -->
+ <!-- endbower -->
+ <!-- endbuild -->
+
+ <!-- build:js scripts/popup.js -->
+ <script src="scripts/popup.js"></script>
+ <!-- endbuild -->
+ </body>
+</html>
diff --git a/app/scripts/background.js b/app/scripts/background.js
new file mode 100644
index 000000000..87a27d0db
--- /dev/null
+++ b/app/scripts/background.js
@@ -0,0 +1,9 @@
+'use strict';
+
+chrome.runtime.onInstalled.addListener(function (details) {
+ console.log('previousVersion', details.previousVersion);
+});
+
+chrome.browserAction.setBadgeText({text: '2'});
+
+console.log('\'Allo \'Allo! Event Page for Browser Action');
diff --git a/app/scripts/chromereload.js b/app/scripts/chromereload.js
new file mode 100644
index 000000000..a01466484
--- /dev/null
+++ b/app/scripts/chromereload.js
@@ -0,0 +1,22 @@
+'use strict';
+
+// Reload client for Chrome Apps & Extensions.
+// The reload client has a compatibility with livereload.
+// WARNING: only supports reload command.
+
+var LIVERELOAD_HOST = 'localhost:';
+var LIVERELOAD_PORT = 35729;
+var connection = new WebSocket('ws://' + LIVERELOAD_HOST + LIVERELOAD_PORT + '/livereload');
+
+connection.onerror = function (error) {
+ console.log('reload connection got error:', error);
+};
+
+connection.onmessage = function (e) {
+ if (e.data) {
+ var data = JSON.parse(e.data);
+ if (data && data.command === 'reload') {
+ chrome.runtime.reload();
+ }
+ }
+};
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
new file mode 100644
index 000000000..30cf50ef9
--- /dev/null
+++ b/app/scripts/contentscript.js
@@ -0,0 +1,8 @@
+console.log('\'Allo \'Allo! Content script')
+
+var scriptTag = document.createElement('script')
+// TODO: add "script.js" to web_accessible_resources in manifest.json
+scriptTag.src = chrome.extension.getURL('scripts/web3.js')
+
+// scriptTag.onload = function() { this.parentNode.removeChild(this) }
+;(document.head||document.documentElement).appendChild(scriptTag) \ No newline at end of file
diff --git a/app/scripts/popup.js b/app/scripts/popup.js
new file mode 100644
index 000000000..815abcb42
--- /dev/null
+++ b/app/scripts/popup.js
@@ -0,0 +1,3 @@
+'use strict';
+
+console.log('\'Allo \'Allo! Popup');
diff --git a/app/scripts/web3.js b/app/scripts/web3.js
new file mode 100644
index 000000000..2bbf95ac3
--- /dev/null
+++ b/app/scripts/web3.js
@@ -0,0 +1,2 @@
+console.log('injecting web3....')
+window.web3 = {} \ No newline at end of file
diff --git a/app/styles/main.css b/app/styles/main.css
new file mode 100644
index 000000000..41c133c89
--- /dev/null
+++ b/app/styles/main.css
@@ -0,0 +1,3 @@
+body {
+ padding: 20px;
+}
diff --git a/bower.json b/bower.json
new file mode 100644
index 000000000..450275da3
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,6 @@
+{
+ "name": "metamask",
+ "version": "0.0.0",
+ "dependencies": {},
+ "devDependencies": {}
+}
diff --git a/package.json b/package.json
new file mode 100644
index 000000000..4ffa7eab7
--- /dev/null
+++ b/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "metamask",
+ "version": "0.0.0",
+ "dependencies": {
+ "web3": "^0.9.2"
+ },
+ "devDependencies": {
+ "grunt": "~0.4.1",
+ "grunt-bower-install": "~1.0.0",
+ "grunt-browserify": "^4.0.0",
+ "grunt-chrome-manifest": "~0.2.0",
+ "grunt-concurrent": "~0.5.0",
+ "grunt-contrib-clean": "~0.5.0",
+ "grunt-contrib-compress": "~0.9.1",
+ "grunt-contrib-concat": "~0.3.0",
+ "grunt-contrib-connect": "~0.7.1",
+ "grunt-contrib-copy": "~0.5.0",
+ "grunt-contrib-cssmin": "~0.9.0",
+ "grunt-contrib-htmlmin": "~0.2.0",
+ "grunt-contrib-imagemin": "~0.7.1",
+ "grunt-contrib-jshint": "~0.9.2",
+ "grunt-contrib-uglify": "~0.4.0",
+ "grunt-contrib-watch": "~0.6.1",
+ "grunt-mocha": "~0.4.10",
+ "grunt-svgmin": "~0.4.0",
+ "grunt-usemin": "~2.1.0",
+ "jshint-stylish": "~0.1.5",
+ "load-grunt-tasks": "~0.4.0",
+ "time-grunt": "~0.3.1"
+ },
+ "engines": {
+ "node": ">=0.8.0"
+ }
+}
diff --git a/test/index.html b/test/index.html
new file mode 100644
index 000000000..6498d5fcc
--- /dev/null
+++ b/test/index.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Mocha Spec Runner</title>
+ <link rel="stylesheet" href="../bower_components/mocha/mocha.css">
+</head>
+<body>
+ <div id="mocha"></div>
+ <script src="../bower_components/mocha/mocha.js"></script>
+ <script>mocha.setup('bdd');</script>
+ <script src="../bower_components/chai/chai.js"></script>
+ <script>
+ var assert = chai.assert;
+ var expect = chai.expect;
+ var should = chai.should();
+ </script>
+ <!-- bower:js -->
+ <!-- endbower -->
+ <!-- include source files here... -->
+ <!-- include spec files here... -->
+ <script src="spec/test.js"></script>
+ <script>
+ if (navigator.userAgent.indexOf('PhantomJS') === -1) {
+ mocha.run();
+ }
+ </script>
+</body>
+</html>
diff --git a/test/spec/test.js b/test/spec/test.js
new file mode 100644
index 000000000..0fca0fb57
--- /dev/null
+++ b/test/spec/test.js
@@ -0,0 +1,11 @@
+(function () {
+ 'use strict';
+
+ describe('Give it some context', function () {
+ describe('maybe a bit more context here', function () {
+ it('should run here few assertions', function () {
+
+ });
+ });
+ });
+})();