-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
402 changed files
with
32,931 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Editor configuration, see https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
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,48 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
/dist | ||
/tmp | ||
/out-tsc | ||
*.crx | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
## third party | ||
*.pem | ||
|
||
# profiling files | ||
chrome-profiler-events.json | ||
speed-measure-plugin.json | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
.history/* | ||
|
||
# misc | ||
/.sass-cache | ||
/connect.lock | ||
/coverage | ||
/libpeerconnection.log | ||
npm-debug.log | ||
yarn-error.log | ||
testem.log | ||
/typings | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db |
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,15 @@ | ||
# NEOLine Chrome Extension | ||
|
||
NEOLine is a thin wallet chrome extension, it provides dapis for developers who want to interact easily with NEO blockchain. | ||
|
||
## Development | ||
|
||
1. Ensure you have [angular-cli](https://angular.io/cli) installed. | ||
2. Clone this repository. | ||
3. Run `yarn` to install dependencies. | ||
4. Run `yarn start` for local development. | ||
5. Run `yarn build` to build release assets for [chrome extension debug](https://developer.chrome.com/extensions/tut_debugging). | ||
|
||
## Use npm | ||
|
||
By default this project is forced to use `yarn`. To use `npm`, just remove the `preinstall` script in `package.json`. |
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,95 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"neoline": { | ||
"root": "", | ||
"sourceRoot": "src", | ||
"projectType": "application", | ||
"prefix": "app", | ||
"schematics": { | ||
"@schematics/angular:component": { | ||
"style": "sass" | ||
} | ||
}, | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-builders/custom-webpack:browser", | ||
"options": { | ||
"outputPath": "dist", | ||
"index": "src/index.html", | ||
"main": "src/main.ts", | ||
"polyfills": "src/polyfills.ts", | ||
"tsConfig": "src/tsconfig.app.json", | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/assets", | ||
"src/_locales" | ||
], | ||
"styles": [ | ||
"src/styles/theme-default.scss", | ||
"src/styles/styles.scss" | ||
], | ||
"scripts": [], | ||
"es5BrowserSupport": true | ||
}, | ||
"configurations": { | ||
"production": { | ||
"fileReplacements": [ | ||
{ | ||
"replace": "src/environments/environment.ts", | ||
"with": "src/environments/environment.prod.ts" | ||
} | ||
], | ||
"baseHref": "/", | ||
"optimization": true, | ||
"outputHashing": "all", | ||
"sourceMap": false, | ||
"extractCss": true, | ||
"namedChunks": false, | ||
"aot": true, | ||
"extractLicenses": true, | ||
"vendorChunk": false, | ||
"buildOptimizer": true, | ||
"outputPath": "dist", | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "5mb", | ||
"maximumError": "10mb" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"serve": { | ||
"builder": "@angular-builders/dev-server:generic", | ||
"options": { | ||
"browserTarget": "neoline:build" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"browserTarget": "neoline:build:production" | ||
}, | ||
"zh-cn": { | ||
"browserTarget": "neoline:build:zh-cn" | ||
} | ||
} | ||
}, | ||
"lint": { | ||
"builder": "@angular-devkit/build-angular:tslint", | ||
"options": { | ||
"tsConfig": [ | ||
"src/tsconfig.app.json" | ||
], | ||
"exclude": [ | ||
"**/node_modules/**" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"defaultProject": "neoline" | ||
} |
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,125 @@ | ||
export { getStorage, httpGet, httpPost, httpGetImage, setStorage, removeStorage, clearStorage, notification } from '../common'; | ||
import { getStorage, setStorage, notification } from '../common'; | ||
/** | ||
* Background methods support. | ||
* Call window.NEOLineBackground to use. | ||
*/ | ||
declare var chrome; | ||
|
||
let currLang = 'en'; | ||
let tabCurr: any; | ||
|
||
export function expand() { | ||
window.open('index.html#asset', '_blank'); | ||
} | ||
|
||
(function init() { | ||
chrome.webRequest.onBeforeRequest.addListener( | ||
(details: any) => { | ||
if (details.url.indexOf(chrome.runtime.getURL('/index.html/') < 0)) { | ||
return { | ||
redirectUrl: details.url.replace(chrome.runtime.getURL(''), chrome.runtime.getURL('/index.html/')) | ||
}; | ||
} else { | ||
return { | ||
redirectUrl: details.url | ||
}; | ||
} | ||
}, { | ||
urls: [ | ||
chrome.runtime.getURL('') | ||
], | ||
types: ['main_frame'] | ||
}, | ||
['blocking'] | ||
); | ||
})(); | ||
|
||
export function setPopup(lang) { | ||
switch (lang) { | ||
case 'zh_CN': | ||
currLang = 'zh_CN'; | ||
break; | ||
case 'en': | ||
currLang = 'en'; | ||
break; | ||
} | ||
} | ||
|
||
|
||
|
||
chrome.windows.onRemoved.addListener(() => { | ||
chrome.tabs.query({}, (res) => { | ||
if (res.length === 0) { // All browsers are closed | ||
setStorage({ | ||
sholudLogin: true | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { | ||
switch (request.target) { | ||
case 'transfer': { | ||
getStorage('wallet', (wallet) => { | ||
if (wallet.accounts[0].address !== request.fromAddress) { | ||
windowCallback({target: 'transferRes', data: 'default'}); | ||
} else { | ||
getStorage('authorizationWebsites', (res) => { | ||
if (res !== undefined && res[request.hostname] !== undefined) { | ||
window.open(`index.html#popup/notification/transfer?to_address=${request.toAddress}&asset_id=${request.assetId}&amount=${request.amount}`, '_blank', | ||
'height=620, width=386, resizable=no, top=0, left=0'); | ||
} else { | ||
window.open(`index.html#popup/notification/authorization?icon=${request.icon}&hostname=${request.hostname}&next=transfer&to_address=${request.toAddress}&asset_id=${request.assetId}&amount=${request.amount}`, '_blank', | ||
'height=620, width=386, resizable=no, top=0, left=0'); | ||
} | ||
}); | ||
} | ||
}); | ||
sendResponse(''); | ||
return true; | ||
} | ||
case 'authorization': { | ||
chrome.tabs.query({ | ||
active: true, | ||
currentWindow: true | ||
}, (tabs) => { | ||
tabCurr = tabs; | ||
}); | ||
getStorage('authorizationWebsites', (res: any) => { | ||
if (res !== undefined && res[request.hostname] !== undefined) { | ||
if (res[request.hostname].status === 'false') { | ||
notification(chrome.i18n.getMessage('rejected'), chrome.i18n.getMessage('rejectedTip')); | ||
return; | ||
} | ||
notification(chrome.i18n.getMessage('authorized')); | ||
} else { | ||
window.open(`/index.html#popup/notification/authorization?icon=${request.icon}&hostname=${request.hostname}&title=${request.title}`, '_blank', | ||
'height=620, width=386, resizable=no, top=0, left=0'); | ||
} | ||
}); | ||
sendResponse(''); | ||
return true; | ||
} | ||
} | ||
sendResponse(''); | ||
return true; | ||
}); | ||
|
||
export function windowCallback(data) { | ||
if (tabCurr === null || tabCurr === undefined) { | ||
chrome.tabs.query({ | ||
active: true, | ||
currentWindow: true | ||
}, (tabs) => { | ||
tabCurr = tabs; | ||
chrome.tabs.sendMessage(tabCurr[0].id, data, (response) => { | ||
tabCurr = null; | ||
}); | ||
}); | ||
} else { | ||
chrome.tabs.sendMessage(tabCurr[0].id, data, (response) => { | ||
tabCurr = null; | ||
}); | ||
} | ||
} |
Oops, something went wrong.