crx_appid 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +5 -0
- data/crx_appid.gemspec +24 -0
- data/lib/crx_appid.rb +23 -0
- data/lib/crx_appid/version.rb +3 -0
- data/spec/crx_appid_spec.rb +39 -0
- data/spec/fixtures/appid.txt +1 -0
- data/spec/fixtures/extension.crx +0 -0
- data/spec/fixtures/extension.pem +16 -0
- data/spec/fixtures/extension/icon.png +0 -0
- data/spec/fixtures/extension/manifest.json +15 -0
- data/spec/fixtures/extension/popup.html +31 -0
- data/spec/fixtures/extension/popup.js +83 -0
- data/spec/spec_helper.rb +4 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6e340108a5258191e519a3420118e8414c14a1d3
|
4
|
+
data.tar.gz: 6148e5347e335d13d6b37a980c57d03b6a66a49d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0ec64030c870125d1e11d7359bf9645a7f01decbbe554607b16d7167f5ea07913aca4c827de8c50a7429f32ca1b8032ad1bdde6f0d61e03bf2868b9089d6aef5
|
7
|
+
data.tar.gz: bd9def4c560c157f14a65ed1854261e009bf9b434e68d72a88cfa416a93a5aaab3555602f89ec2520c04bd52ebf542dced2f21ad8ecb03fe258b88dc32bb59ab
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kensuke Nagae
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# CrxAppid
|
2
|
+
|
3
|
+
Calculate Chrome extension appid from pem
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'crx_appid'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install crx_appid
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
pem = open("extension.pem").read
|
23
|
+
CrxAppid.calculate(pem)
|
24
|
+
|
25
|
+
CrxAppid.calculate_from_file("extension.pem")
|
26
|
+
```
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/crx_appid.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'crx_appid/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "crx_appid"
|
8
|
+
spec.version = CrxAppid::VERSION
|
9
|
+
spec.authors = ["Kensuke Nagae"]
|
10
|
+
spec.email = ["kyanny@gmail.com"]
|
11
|
+
spec.description = %q{Calculate Chrome extension appid from pem}
|
12
|
+
spec.summary = %q{Calculate Chrome extension appid from pem}
|
13
|
+
spec.homepage = "https://github.com/kyanny/crx_appid"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
data/lib/crx_appid.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "crx_appid/version"
|
2
|
+
require "openssl"
|
3
|
+
require "digest/sha2"
|
4
|
+
|
5
|
+
class CrxAppid
|
6
|
+
def calculate(pem)
|
7
|
+
Digest::SHA256.hexdigest(OpenSSL::PKey::RSA.new(pem).public_key.to_der)[0...32].tr('0-9a-f', 'a-p')
|
8
|
+
end
|
9
|
+
|
10
|
+
def calculate_from_file(pem)
|
11
|
+
calculate(open(pem).read)
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def calculate(pem)
|
16
|
+
new.calculate(pem)
|
17
|
+
end
|
18
|
+
|
19
|
+
def calculate_from_file(pem)
|
20
|
+
new.calculate_from_file(pem)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'crx_appid'
|
2
|
+
|
3
|
+
describe CrxAppid do
|
4
|
+
let(:appid) do
|
5
|
+
open(File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "appid.txt"))).read.chomp
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:pem_file) do
|
9
|
+
File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "extension.pem"))
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:pem) do
|
13
|
+
open(pem_file).read
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#calculate' do
|
17
|
+
it "calculates appid from pem string" do
|
18
|
+
expect(subject.calculate(pem)).to eq(appid)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#calculate_from_file' do
|
23
|
+
it "calculates appid from pem file" do
|
24
|
+
expect(subject.calculate_from_file(pem_file)).to eq(appid)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.calculate' do
|
29
|
+
it "calculates appid from pem string" do
|
30
|
+
expect(described_class.calculate(pem)).to eq(appid)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.calculate_from_file' do
|
35
|
+
it "calculates appid from pem file" do
|
36
|
+
expect(described_class.calculate_from_file(pem_file)).to eq(appid)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
fkehabcmmclnikogbaalepnnhaefpiic
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
-----BEGIN PRIVATE KEY-----
|
2
|
+
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANoWkO6F5q8aWpR5L
|
3
|
+
oarBgYm8OJptssUZWCf8+VZby0ilefp99VTAUwSOzZH6nz+393I3fadAxqBtC2R/z
|
4
|
+
39Ugo/ximdYH+GL7y/N6u7LHGROeyqMBGqfPw7qCKC83567+admdbDIn+RQLECoIZ
|
5
|
+
bYpTEiLDzFtmNWRKQoG459XQHAgMBAAECgYArKeo3e0MEBxhEaJOfzbucfhqRBVFL
|
6
|
+
clb6P84652+MpFq9Et6dVxdbogQcIzGy2ZMfR0E/LSZPGbq6hjnZYAjbZuerqQpIz
|
7
|
+
LEOUuk0qdCPeBGttMsbGOz/569Fgc4oQjxAKYnn2OCiHDwYGgOp0/9C3s2nzoGpFN
|
8
|
+
sILqrRu3qG0QJBAO9qrxaZnmAM4Owy/6VH+rlTsPsEpvYzeoFOXkLriwj3OHY1gva
|
9
|
+
LRXN+tYocI4CzYOZsJCVbwrBzUPCnVtQO248CQQDpMa+GNKLruC75YA9RxJ+5gKKK
|
10
|
+
bJurYlahSDKOEz0nFOpGYGl0R+gscAK7Si/SoVSg8DDAC1hqs2iAZRSrJoQJAkEAv
|
11
|
+
idpsPWKCJex/Wf0C/5DcPa71mM3iMwSPKlVzKjv4MsaGSkfP1oWa0j0PyFiQVI3YE
|
12
|
+
v72YAr/aFZZApEuGCkmQJBAL7zeZh6x6If+w8nMsQxLt220OJq1vn7F5cPyJ4AcQX
|
13
|
+
soX4pepDGRP8GZaY5tHlUtDjpFfJcF/WfnYXtv4P6kQkCQEfhJUuq9WYwuKlk24KJ
|
14
|
+
lUwvR7kikRV8wYBsC9CImuAd8ZUS1wlqUu4UU/HIQpgfu1MDQX44mY09AEEEmAr14
|
15
|
+
Mc=
|
16
|
+
-----END PRIVATE KEY-----
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"manifest_version": 2,
|
3
|
+
|
4
|
+
"name": "One-click Kittens",
|
5
|
+
"description": "This extension demonstrates a 'browser action' with kittens.",
|
6
|
+
"version": "1.0",
|
7
|
+
|
8
|
+
"browser_action": {
|
9
|
+
"default_icon": "icon.png",
|
10
|
+
"default_popup": "popup.html"
|
11
|
+
},
|
12
|
+
"permissions": [
|
13
|
+
"https://secure.flickr.com/"
|
14
|
+
]
|
15
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Getting Started Extension's Popup</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
min-width: 357px;
|
8
|
+
overflow-x: hidden;
|
9
|
+
}
|
10
|
+
|
11
|
+
img {
|
12
|
+
margin: 5px;
|
13
|
+
border: 2px solid black;
|
14
|
+
vertical-align: middle;
|
15
|
+
width: 75px;
|
16
|
+
height: 75px;
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
|
20
|
+
<!--
|
21
|
+
- JavaScript and HTML must be in separate files: see our Content Security
|
22
|
+
- Policy documentation[1] for details and explanation.
|
23
|
+
-
|
24
|
+
- [1]: http://developer.chrome.com/extensions/contentSecurityPolicy.html
|
25
|
+
-->
|
26
|
+
<script src="popup.js"></script>
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
</body>
|
30
|
+
</html>
|
31
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
3
|
+
// found in the LICENSE file.
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Global variable containing the query we'd like to pass to Flickr. In this
|
7
|
+
* case, kittens!
|
8
|
+
*
|
9
|
+
* @type {string}
|
10
|
+
*/
|
11
|
+
var QUERY = 'kittens';
|
12
|
+
|
13
|
+
var kittenGenerator = {
|
14
|
+
/**
|
15
|
+
* Flickr URL that will give us lots and lots of whatever we're looking for.
|
16
|
+
*
|
17
|
+
* See http://www.flickr.com/services/api/flickr.photos.search.html for
|
18
|
+
* details about the construction of this URL.
|
19
|
+
*
|
20
|
+
* @type {string}
|
21
|
+
* @private
|
22
|
+
*/
|
23
|
+
searchOnFlickr_: 'https://secure.flickr.com/services/rest/?' +
|
24
|
+
'method=flickr.photos.search&' +
|
25
|
+
'api_key=90485e931f687a9b9c2a66bf58a3861a&' +
|
26
|
+
'text=' + encodeURIComponent(QUERY) + '&' +
|
27
|
+
'safe_search=1&' +
|
28
|
+
'content_type=1&' +
|
29
|
+
'sort=interestingness-desc&' +
|
30
|
+
'per_page=20',
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Sends an XHR GET request to grab photos of lots and lots of kittens. The
|
34
|
+
* XHR's 'onload' event is hooks up to the 'showPhotos_' method.
|
35
|
+
*
|
36
|
+
* @public
|
37
|
+
*/
|
38
|
+
requestKittens: function() {
|
39
|
+
var req = new XMLHttpRequest();
|
40
|
+
req.open("GET", this.searchOnFlickr_, true);
|
41
|
+
req.onload = this.showPhotos_.bind(this);
|
42
|
+
req.send(null);
|
43
|
+
},
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Handle the 'onload' event of our kitten XHR request, generated in
|
47
|
+
* 'requestKittens', by generating 'img' elements, and stuffing them into
|
48
|
+
* the document for display.
|
49
|
+
*
|
50
|
+
* @param {ProgressEvent} e The XHR ProgressEvent.
|
51
|
+
* @private
|
52
|
+
*/
|
53
|
+
showPhotos_: function (e) {
|
54
|
+
var kittens = e.target.responseXML.querySelectorAll('photo');
|
55
|
+
for (var i = 0; i < kittens.length; i++) {
|
56
|
+
var img = document.createElement('img');
|
57
|
+
img.src = this.constructKittenURL_(kittens[i]);
|
58
|
+
img.setAttribute('alt', kittens[i].getAttribute('title'));
|
59
|
+
document.body.appendChild(img);
|
60
|
+
}
|
61
|
+
},
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Given a photo, construct a URL using the method outlined at
|
65
|
+
* http://www.flickr.com/services/api/misc.urlKittenl
|
66
|
+
*
|
67
|
+
* @param {DOMElement} A kitten.
|
68
|
+
* @return {string} The kitten's URL.
|
69
|
+
* @private
|
70
|
+
*/
|
71
|
+
constructKittenURL_: function (photo) {
|
72
|
+
return "http://farm" + photo.getAttribute("farm") +
|
73
|
+
".static.flickr.com/" + photo.getAttribute("server") +
|
74
|
+
"/" + photo.getAttribute("id") +
|
75
|
+
"_" + photo.getAttribute("secret") +
|
76
|
+
"_s.jpg";
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
// Run our kitten generation script as soon as the document's DOM is ready.
|
81
|
+
document.addEventListener('DOMContentLoaded', function () {
|
82
|
+
kittenGenerator.requestKittens();
|
83
|
+
});
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crx_appid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kensuke Nagae
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Calculate Chrome extension appid from pem
|
56
|
+
email:
|
57
|
+
- kyanny@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- crx_appid.gemspec
|
68
|
+
- lib/crx_appid.rb
|
69
|
+
- lib/crx_appid/version.rb
|
70
|
+
- spec/crx_appid_spec.rb
|
71
|
+
- spec/fixtures/appid.txt
|
72
|
+
- spec/fixtures/extension.crx
|
73
|
+
- spec/fixtures/extension.pem
|
74
|
+
- spec/fixtures/extension/icon.png
|
75
|
+
- spec/fixtures/extension/manifest.json
|
76
|
+
- spec/fixtures/extension/popup.html
|
77
|
+
- spec/fixtures/extension/popup.js
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
homepage: https://github.com/kyanny/crx_appid
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.0.3
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Calculate Chrome extension appid from pem
|
103
|
+
test_files:
|
104
|
+
- spec/crx_appid_spec.rb
|
105
|
+
- spec/fixtures/appid.txt
|
106
|
+
- spec/fixtures/extension.crx
|
107
|
+
- spec/fixtures/extension.pem
|
108
|
+
- spec/fixtures/extension/icon.png
|
109
|
+
- spec/fixtures/extension/manifest.json
|
110
|
+
- spec/fixtures/extension/popup.html
|
111
|
+
- spec/fixtures/extension/popup.js
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
has_rdoc:
|