aelf-bridge
Advanced tools
Comparing version 0.0.10 to 0.0.11-alpha.0
{ | ||
"name": "aelf-bridge", | ||
"version": "0.0.10", | ||
"version": "0.0.11-alpha.0", | ||
"description": "A library to interact with native apps", | ||
@@ -9,4 +9,5 @@ "main": "dist/aelf-bridge.js", | ||
"jsdelivr": "dist/aelf-bridge.js", | ||
"type": "module", | ||
"scripts": { | ||
"build": "npm run clean && webpack --progress --colors --display-chunks --config ./build/webpack.prod.js", | ||
"build": "npm run clean && webpack --progress --stats=verbose --config ./build/webpack.prod.js", | ||
"release": "standard-version -a", | ||
@@ -16,3 +17,5 @@ "commit": "git-cz", | ||
"analyze": "npm run clean && webpack --config ./build/webpack.analyze.js", | ||
"clean": "rimraf dist/*" | ||
"clean": "rimraf dist/*", | ||
"prepare": "husky", | ||
"lint-staged": "lint-staged" | ||
}, | ||
@@ -34,47 +37,58 @@ "author": "atom-yang", | ||
"license": "MIT", | ||
"devEngines": { | ||
"node": ">=18.18.0" | ||
}, | ||
"engines": { | ||
"node": ">=18.18.0" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.6.3", | ||
"@babel/runtime": "^7.24.7", | ||
"browserify-cipher": "^1.0.1", | ||
"create-hmac": "^1.1.7", | ||
"elliptic": "^6.5.1", | ||
"socket.io-client": "^2.3.0", | ||
"uuid": "^3.3.3" | ||
"elliptic": "^6.5.5", | ||
"socket.io-client": "^4.7.5", | ||
"stream-browserify": "^3.0.0", | ||
"uuid": "^10.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.6.4", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-transform-runtime": "^7.6.2", | ||
"@babel/preset-env": "^7.6.3", | ||
"babel-eslint": "^10.0.3", | ||
"babel-loader": "^8.0.6", | ||
"@babel/core": "^7.24.7", | ||
"@babel/eslint-parser": "^7.24.7", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/plugin-syntax-import-attributes": "^7.24.7", | ||
"@babel/plugin-transform-runtime": "^7.24.7", | ||
"@babel/preset-env": "^7.24.7", | ||
"@commitlint/cli": "^19.3.0", | ||
"@commitlint/config-conventional": "^19.2.2", | ||
"@eslint/compat": "^1.1.0", | ||
"babel-eslint": "^10.1.0", | ||
"babel-loader": "^9.1.3", | ||
"babel-plugin-transform-import-meta": "^2.2.1", | ||
"bundle-analyzer": "^0.0.6", | ||
"chalk": "^2.4.2", | ||
"commitizen": "^4.0.3", | ||
"cross-env": "^6.0.3", | ||
"cz-conventional-changelog": "^3.0.2", | ||
"eslint": "^6.5.1", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-plugin-babel": "^5.3.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"file-loader": "^4.2.0", | ||
"git-cz": "^3.2.1", | ||
"glob": "^7.1.4", | ||
"husky": "^3.0.9", | ||
"lint-staged": "^9.4.2", | ||
"rimraf": "^3.0.0", | ||
"standard-version": "^9.1.1", | ||
"chalk": "^5.3.0", | ||
"commitizen": "^4.3.0", | ||
"commitlint": "^19.3.0", | ||
"cross-env": "^7.0.3", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^9.5.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-babel": "^5.3.1", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"file-loader": "^6.2.0", | ||
"git-cz": "^4.9.0", | ||
"glob": "^10.4.1", | ||
"husky": "^9.0.11", | ||
"lint-staged": "^15.2.7", | ||
"prettier": "^3.3.2", | ||
"rimraf": "^5.0.7", | ||
"standard-version": "^9.5.0", | ||
"unused-files-webpack-plugin": "^3.4.0", | ||
"webpack": "^4.41.1", | ||
"webpack-bundle-analyzer": "^3.5.2", | ||
"webpack-cli": "^3.3.9", | ||
"webpack-merge": "^4.2.2" | ||
"webpack": "^5.92.0", | ||
"webpack-bundle-analyzer": "^4.10.2", | ||
"webpack-cli": "^5.1.4", | ||
"webpack-merge": "^5.10.0" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged", | ||
"commit-msg": "node scripts/verify-commit-msg.js" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.js": "eslint" | ||
"src/*.js": "eslint" | ||
}, | ||
@@ -81,0 +95,0 @@ "config": { |
@@ -5,10 +5,7 @@ /** | ||
*/ | ||
import { | ||
CHAIN_METHODS | ||
} from '../common/constants'; | ||
import ChainMethod from './method'; | ||
import { CHAIN_METHODS } from '../common/constants.js'; | ||
import ChainMethod from './method.js'; | ||
export default class Chain { | ||
constructor(instance) { | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (const method of CHAIN_METHODS) { | ||
@@ -15,0 +12,0 @@ const chainMethod = new ChainMethod({ |
@@ -7,10 +7,3 @@ /** | ||
export default class ChainMethod { | ||
constructor( | ||
{ | ||
methodName, | ||
api, | ||
params = [], | ||
request | ||
} | ||
) { | ||
constructor({ methodName, api, params = [], request }) { | ||
this.methodName = methodName; | ||
@@ -17,0 +10,0 @@ this.api = api; |
@@ -7,3 +7,2 @@ /** | ||
postMessage: 'POST_MESSAGE', | ||
webSocket: 'WEB_SOCKET', | ||
socketIo: 'SOCKET.IO' | ||
@@ -10,0 +9,0 @@ }; |
@@ -5,4 +5,4 @@ /** | ||
*/ | ||
import ContractMethod from './method'; | ||
import Contract from './contract'; | ||
import ContractMethod from './method.js'; | ||
import Contract from './contract.js'; | ||
@@ -9,0 +9,0 @@ export default class ContractFactory { |
@@ -40,5 +40,5 @@ /** | ||
send.send = this.send; | ||
// eslint-disable-next-line no-param-reassign | ||
contract[this.method] = send; | ||
} | ||
} |
@@ -5,16 +5,9 @@ /** | ||
*/ | ||
import MessageChannel from './messageChannel'; | ||
import Proxy from './proxy'; | ||
import { | ||
getUUIDForUrl | ||
} from './utils/utils'; | ||
import StorageService from './utils/storage'; | ||
import { | ||
PROXY_TYPE, | ||
CHANNEL_TYPE, | ||
CHAIN_APIS, | ||
CHAIN_METHODS | ||
} from './common/constants'; | ||
import Chain from './chain'; | ||
import ContractFactory from './contract'; | ||
import MessageChannel from './messageChannel/index.js'; | ||
import Proxy from './proxy/index.js'; | ||
import { getUUIDForUrl } from './utils/utils.js'; | ||
import StorageService from './utils/storage.js'; | ||
import { PROXY_TYPE, CHANNEL_TYPE, CHAIN_APIS, CHAIN_METHODS } from './common/constants.js'; | ||
import Chain from './chain/index.js'; | ||
import ContractFactory from './contract/index.js'; | ||
@@ -103,6 +96,3 @@ const defaultOptions = { | ||
}); | ||
const { | ||
code, | ||
data | ||
} = res; | ||
const { code, data } = res; | ||
if (+code === 0) { | ||
@@ -109,0 +99,0 @@ return data || 'null'; |
@@ -7,9 +7,4 @@ /** | ||
import { createCipheriv, createDecipheriv } from 'browserify-cipher'; | ||
import { | ||
randomId, | ||
serializeMessage, | ||
deserializeMessage, | ||
getUnixTimestamp | ||
} from '../utils/utils'; | ||
import HKDF from '../utils/hkdf'; | ||
import { randomId, serializeMessage, deserializeMessage, getUnixTimestamp } from '../utils/utils.js'; | ||
import HKDF from '../utils/hkdf.js'; | ||
@@ -43,6 +38,3 @@ const encryptAlgorithm = 'curve25519'; | ||
const aesCipher = createCipheriv(this.cipher, passpharse, Buffer.from(iv, 'hex')); | ||
const encrypted = Buffer.concat([ | ||
aesCipher.update(Buffer.from(data, 'base64')), | ||
aesCipher.final() | ||
]); | ||
const encrypted = Buffer.concat([aesCipher.update(Buffer.from(data, 'base64')), aesCipher.final()]); | ||
return { | ||
@@ -63,6 +55,3 @@ encrypted: encrypted.toString('base64'), | ||
const decipher = createDecipheriv(this.cipher, passpharse, Buffer.from(iv, 'hex')); | ||
const decrypted = Buffer.concat([ | ||
decipher.update(Buffer.from(encrypted, 'base64')), | ||
decipher.final() | ||
]).toString('base64'); | ||
const decrypted = Buffer.concat([decipher.update(Buffer.from(encrypted, 'base64')), decipher.final()]).toString('base64'); | ||
return decrypted; | ||
@@ -101,6 +90,3 @@ } | ||
} | ||
const { | ||
publicKey: remotePublicKey, | ||
random | ||
} = result.data; | ||
const { publicKey: remotePublicKey, random } = result.data; | ||
this.remotePublicKeyEncoded = remotePublicKey; | ||
@@ -129,6 +115,3 @@ // todo: 修改为对应的ec | ||
}); | ||
const { | ||
encrypted, | ||
iv | ||
} = this.encrypt(originalParams, this.derivedKey); | ||
const { encrypted, iv } = this.encrypt(originalParams, this.derivedKey); | ||
const params = { | ||
@@ -142,6 +125,4 @@ encryptedParams: encrypted, // base64 encoded | ||
}); | ||
const { result = {} } = response; | ||
const { | ||
result = {} | ||
} = response; | ||
const { | ||
encryptedResult, // base64 encoded | ||
@@ -148,0 +129,0 @@ iv: remoteIv // hex encoded |
@@ -5,8 +5,6 @@ /** | ||
*/ | ||
import Proxy from '../proxy'; | ||
import Sign from './sign'; | ||
import Encrypt from './encrypt'; | ||
import { | ||
CHANNEL_TYPE | ||
} from '../common/constants'; | ||
import Proxy from '../proxy/index.js'; | ||
import Sign from './sign.js'; | ||
import Encrypt from './encrypt.js'; | ||
import { CHANNEL_TYPE } from '../common/constants.js'; | ||
@@ -13,0 +11,0 @@ const MESSAGE_CHANNELS = { |
@@ -6,7 +6,3 @@ /** | ||
import * as elliptic from 'elliptic'; | ||
import { | ||
getUnixTimestamp, | ||
serializeMessage, | ||
deserializeMessage | ||
} from '../utils/utils'; | ||
import { getUnixTimestamp, serializeMessage, deserializeMessage } from '../utils/utils.js'; | ||
@@ -58,7 +54,3 @@ const encryptAlgorithm = 'secp256k1'; | ||
} | ||
const { | ||
random: remoteRandom, | ||
signature: remoteSignature, | ||
publicKey: remotePublicKey | ||
} = result.data; | ||
const { random: remoteRandom, signature: remoteSignature, publicKey: remotePublicKey } = result.data; | ||
this.remotePublicKeyEncoded = remotePublicKey; | ||
@@ -80,7 +72,3 @@ this.remoteKeyPair = ec.keyFromPublic(remotePublicKey, 'hex'); | ||
const signedMsg = this.keypair.sign(msg); | ||
return [ | ||
signedMsg.r.toString(16, 64), | ||
signedMsg.s.toString(16, 64), | ||
`0${signedMsg.recoveryParam.toString()}` | ||
].join(''); | ||
return [signedMsg.r.toString(16, 64), signedMsg.s.toString(16, 64), `0${signedMsg.recoveryParam.toString()}`].join(''); | ||
} | ||
@@ -122,9 +110,4 @@ | ||
}); | ||
const { | ||
result = {} | ||
} = response; | ||
const { | ||
originalResult, | ||
signature: remoteSignature | ||
} = result; | ||
const { result = {} } = response; | ||
const { originalResult, signature: remoteSignature } = result; | ||
const responseData = deserializeMessage(originalResult); | ||
@@ -131,0 +114,0 @@ if (!this.verify(Buffer.from(originalResult, 'base64'), remoteSignature)) { |
@@ -5,5 +5,3 @@ /** | ||
*/ | ||
import { | ||
PROXY_TYPE | ||
} from '../common/constants'; | ||
import { PROXY_TYPE } from '../common/constants.js'; | ||
@@ -10,0 +8,0 @@ const defaultProxyType = PROXY_TYPE.postMessage; |
@@ -5,11 +5,9 @@ /** | ||
*/ | ||
import PostMessage from './postMessage'; | ||
import SocketIO from './socketIO'; | ||
import WS from './ws'; | ||
import { PROXY_TYPE } from '../common/constants'; | ||
import PostMessage from './postMessage.js'; | ||
import SocketIO from './socketIO.js'; | ||
import { PROXY_TYPE } from '../common/constants.js'; | ||
const PROXIES = { | ||
[PROXY_TYPE.postMessage]: PostMessage, | ||
[PROXY_TYPE.socketIo]: SocketIO, | ||
[PROXY_TYPE.webSocket]: WS | ||
[PROXY_TYPE.socketIo]: SocketIO | ||
}; | ||
@@ -26,5 +24,3 @@ | ||
constructor( | ||
options = defaultOptions | ||
) { | ||
constructor(options = defaultOptions) { | ||
this.options = { | ||
@@ -31,0 +27,0 @@ ...defaultOptions, |
@@ -5,11 +5,5 @@ /** | ||
*/ | ||
import Base from './base'; | ||
import { | ||
PROXY_TYPE | ||
} from '../common/constants'; | ||
import { | ||
randomId, | ||
serializeMessage, | ||
deserializeMessage | ||
} from '../utils/utils'; | ||
import Base from './base.js'; | ||
import { PROXY_TYPE } from '../common/constants.js'; | ||
import { randomId, serializeMessage, deserializeMessage } from '../utils/utils.js'; | ||
@@ -93,9 +87,12 @@ const eventType = 'message'; | ||
if (timeout && timeout > 0 && !this.isCheckingInjectedPostMessage) { | ||
timer = setTimeout(() => { | ||
reject('Time out'); | ||
window.removeEventListener(eventType, this.eventHandlers[id]); | ||
delete this.eventHandlers[id]; | ||
}, parseInt(timeout, 10)); | ||
timer = setTimeout( | ||
() => { | ||
reject('Time out'); | ||
window.removeEventListener(eventType, this.eventHandlers[id]); | ||
delete this.eventHandlers[id]; | ||
}, | ||
parseInt(timeout, 10) | ||
); | ||
} | ||
} | ||
} |
@@ -6,9 +6,5 @@ /** | ||
import io from 'socket.io-client'; | ||
import Base from './base'; | ||
import { | ||
PROXY_TYPE | ||
} from '../common/constants'; | ||
import { | ||
randomId | ||
} from '../utils/utils'; | ||
import Base from './base.js'; | ||
import { PROXY_TYPE } from '../common/constants.js'; | ||
import { randomId } from '../utils/utils.js'; | ||
@@ -40,3 +36,3 @@ const defaultOptions = { | ||
if (data !== 'success') { | ||
throw new Error('can\'t connect to socket'); | ||
throw new Error("can't connect to socket"); | ||
} | ||
@@ -43,0 +39,0 @@ }); |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
import createHmac from 'create-hmac/browser'; | ||
import createHmac from 'create-hmac/browser.js'; | ||
@@ -9,0 +9,0 @@ export default class HKDF { |
@@ -5,4 +5,3 @@ /** | ||
*/ | ||
import uuidv4 from 'uuid/v4'; | ||
import uuidv5 from 'uuid/v5'; | ||
import { v4 as uuidv4, v5 as uuidv5 } from 'uuid'; | ||
@@ -9,0 +8,0 @@ export const randomId = () => uuidv4().replace(/-/g, ''); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Yes
1486363
7
37
1
80
2013
+ Addedstream-browserify@^3.0.0
+ Added@socket.io/component-emitter@3.1.2(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedengine.io-client@6.6.2(transitive)
+ Addedengine.io-parser@5.2.3(transitive)
+ Addedms@2.1.3(transitive)
+ Addedsocket.io-client@4.8.1(transitive)
+ Addedsocket.io-parser@4.2.4(transitive)
+ Addedstream-browserify@3.0.0(transitive)
+ Addeduuid@10.0.0(transitive)
+ Addedws@8.17.1(transitive)
+ Addedxmlhttprequest-ssl@2.1.2(transitive)
- Removedafter@0.8.2(transitive)
- Removedarraybuffer.slice@0.0.7(transitive)
- Removedbacko2@1.0.2(transitive)
- Removedbase64-arraybuffer@0.1.4(transitive)
- Removedblob@0.0.5(transitive)
- Removedcomponent-bind@1.0.0(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcomponent-inherit@0.0.3(transitive)
- Removeddebug@3.1.0(transitive)
- Removedengine.io-client@3.5.4(transitive)
- Removedengine.io-parser@2.2.1(transitive)
- Removedhas-binary2@1.0.3(transitive)
- Removedhas-cors@1.1.0(transitive)
- Removedindexof@0.0.1(transitive)
- Removedisarray@2.0.1(transitive)
- Removedms@2.0.0(transitive)
- Removedparseqs@0.0.6(transitive)
- Removedparseuri@0.0.6(transitive)
- Removedsocket.io-client@2.5.0(transitive)
- Removedsocket.io-parser@3.3.4(transitive)
- Removedto-array@0.1.4(transitive)
- Removeduuid@3.4.0(transitive)
- Removedws@7.5.10(transitive)
- Removedxmlhttprequest-ssl@1.6.3(transitive)
- Removedyeast@0.1.2(transitive)
Updated@babel/runtime@^7.24.7
Updatedelliptic@^6.5.5
Updatedsocket.io-client@^4.7.5
Updateduuid@^10.0.0