fabric-shim
Advanced tools
Comparing version 1.4.4 to 1.4.5
@@ -258,2 +258,16 @@ /* | ||
// add 'argN' parameters, skipping the first (stub) parameter | ||
if (propValue.length > 1) { | ||
transaction.parameters = []; | ||
for (let param = 1; param < propValue.length; param++) { | ||
transaction.parameters.push({ | ||
name: `arg${param - 1}`, | ||
description: `Argument ${param - 1}`, | ||
schema: { | ||
type: 'string' | ||
} | ||
}); | ||
} | ||
} | ||
transactions.push(transaction); | ||
@@ -260,0 +274,0 @@ } |
{ | ||
"name": "fabric-shim", | ||
"version": "1.4.4", | ||
"tag": "latest", | ||
"version": "1.4.5", | ||
"tag": "latest-1.4", | ||
"description": "A node.js implementation of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other", | ||
@@ -14,3 +14,3 @@ "main": "index.js", | ||
"test": "nyc mocha --recursive 'test/unit/**/*.js' ", | ||
"tgzpack": "npm pack" | ||
"tgzpack": "../ci/tgzpack.sh" | ||
}, | ||
@@ -27,4 +27,4 @@ "repository": { | ||
"engines": { | ||
"node": "^8.9.0", | ||
"npm": "^5.5.1" | ||
"node": "^8.17.0", | ||
"npm": "^6.13.4" | ||
}, | ||
@@ -37,3 +37,3 @@ "yargs": { | ||
"dependencies": { | ||
"@ampretia/x509": "^0.4.0", | ||
"@ampretia/x509": "^0.4.7", | ||
"@types/google-protobuf": "^3.2.7", | ||
@@ -43,3 +43,3 @@ "@types/node": "^8.9.4", | ||
"fs-extra": "^7.0.1", | ||
"grpc": "1.17.0", | ||
"grpc": "1.23.3", | ||
"jsrsasign": "^8.0.4", | ||
@@ -46,0 +46,0 @@ "reflect-metadata": "^0.1.12", |
@@ -67,16 +67,16 @@ /* | ||
const certWithoutAttrs = '-----BEGIN CERTIFICATE-----' + | ||
'MIICXTCCAgSgAwIBAgIUeLy6uQnq8wwyElU/jCKRYz3tJiQwCgYIKoZIzj0EAwIw' + | ||
'eTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWEx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wHhcNMTcwOTA4MDAxNTAwWhcNMTgw' + | ||
'OTA4MDAxNTAwWjBdMQswCQYDVQQGEwJVUzEXMBUGA1UECBMOTm9ydGggQ2Fyb2xp' + | ||
'bmExFDASBgNVBAoTC0h5cGVybGVkZ2VyMQ8wDQYDVQQLEwZGYWJyaWMxDjAMBgNV' + | ||
'BAMTBWFkbWluMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFq/90YMuH4tWugHa' + | ||
'oyZtt4Mbwgv6CkBSDfYulVO1CVInw1i/k16DocQ/KSDTeTfgJxrX1Ree1tjpaodG' + | ||
'1wWyM6OBhTCBgjAOBgNVHQ8BAf8EBAMCB4AwDAYDVR0TAQH/BAIwADAdBgNVHQ4E' + | ||
'FgQUhKs/VJ9IWJd+wer6sgsgtZmxZNwwHwYDVR0jBBgwFoAUIUd4i/sLTwYWvpVr' + | ||
'TApzcT8zv/kwIgYDVR0RBBswGYIXQW5pbHMtTWFjQm9vay1Qcm8ubG9jYWwwCgYI' + | ||
'KoZIzj0EAwIDRwAwRAIgCoXaCdU8ZiRKkai0QiXJM/GL5fysLnmG2oZ6XOIdwtsC' + | ||
'IEmCsI8Mhrvx1doTbEOm7kmIrhQwUVDBNXCWX1t3kJVN' + | ||
'-----END CERTIFICATE-----'; | ||
@@ -449,4 +449,6 @@ describe('chaincodefromcontract', () => { | ||
const mockStub = {getBufferArgs: sandbox.stub().returns([Buffer.from('arg1'), Buffer.from('args2')]), | ||
getTxID: sandbox.stub().returns(12345)}; | ||
const mockStub = { | ||
getBufferArgs: sandbox.stub().returns([Buffer.from('arg1'), Buffer.from('args2')]), | ||
getTxID: sandbox.stub().returns(12345) | ||
}; | ||
cc.invokeFunctionality = sandbox.stub(); | ||
@@ -463,3 +465,3 @@ return cc.Invoke(mockStub); | ||
}; | ||
const tempClass = class extends Contract { | ||
const tempClass = class extends Contract { | ||
constructor() { | ||
@@ -484,10 +486,10 @@ super('logging'); | ||
}, | ||
'logging':{ | ||
'logging': { | ||
contractInstance: appClass, | ||
transactions: [ | ||
{ | ||
name:'alpha' | ||
name: 'alpha' | ||
} | ||
], | ||
dataMarshall:{ | ||
dataMarshall: { | ||
handleParameters: sandbox.stub().returns([]), | ||
@@ -506,3 +508,4 @@ toWireBuffer: sandbox.stub() | ||
const cc = new ChaincodeFromContract([tempClass], defaultSerialization); | ||
const mockStub = {getBufferArgs: sandbox.stub().returns(['logging:alpha']), | ||
const mockStub = { | ||
getBufferArgs: sandbox.stub().returns(['logging:alpha']), | ||
getTxID: sandbox.stub().returns('12345897asd7a7a77v7b77'), | ||
@@ -539,3 +542,3 @@ getChannelID: sandbox.stub().returns('channel-id-fake'), | ||
describe ('#_splitFunctionName', () => { | ||
describe('#_splitFunctionName', () => { | ||
it('should handle the usual case of ns:fn', () => { | ||
@@ -628,3 +631,3 @@ const result = ChaincodeFromContract.prototype._splitFunctionName('name:function'); | ||
it ('should handle valid contract name, but missing function', async () => { | ||
it('should handle valid contract name, but missing function', async () => { | ||
@@ -914,3 +917,3 @@ const idBytes = { | ||
it ('should return empty array when no issue', () => { | ||
it('should return empty array when no issue', () => { | ||
const cc = ChaincodeFromContract.prototype; | ||
@@ -929,3 +932,3 @@ cc.contractImplementations = contractImpls; | ||
it ('should return empty array when metadata has no field contracts', () => { | ||
it('should return empty array when metadata has no field contracts', () => { | ||
const cc = ChaincodeFromContract.prototype; | ||
@@ -939,3 +942,3 @@ cc.contractImplementations = contractImpls; | ||
it ('should return empty array when missing a contract', () => { | ||
it('should return empty array when missing a contract', () => { | ||
const cc = ChaincodeFromContract.prototype; | ||
@@ -955,3 +958,3 @@ cc.contractImplementations = contractImpls; | ||
describe('#_processContractInfo', () => { | ||
it ('should be able to handle no annotations suppled', () => { | ||
it('should be able to handle no annotations suppled', () => { | ||
mockery.registerMock('SCAlpha', SCDelta); | ||
@@ -968,7 +971,7 @@ SCDelta.prototype.foo = 'foo'; | ||
data.should.deep.equal({ | ||
title:'', | ||
version:'' | ||
title: '', | ||
version: '' | ||
}); | ||
}); | ||
it ('should be able to handle no annotations suppled', () => { | ||
it('should be able to handle no annotations suppled', () => { | ||
mockery.registerMock('SCAlpha', SCDelta); | ||
@@ -980,6 +983,8 @@ SCDelta.prototype.foo = 'foo'; | ||
const getMetadataStub = sandbox.stub(Reflect, 'getMetadata'); | ||
getMetadataStub.returns({SCAlpha:{ | ||
title:'contract info', | ||
version:'3333' | ||
}}); | ||
getMetadataStub.returns({ | ||
SCAlpha: { | ||
title: 'contract info', | ||
version: '3333' | ||
} | ||
}); | ||
const cc = new ChaincodeFromContract([SCAlpha], defaultSerialization); | ||
@@ -990,4 +995,4 @@ const data = cc._processContractInfo(cc.contractImplementations.alpha.contractInstance); | ||
data.should.deep.equal({ | ||
title:'contract info', | ||
version:'3333' | ||
title: 'contract info', | ||
version: '3333' | ||
}); | ||
@@ -1009,3 +1014,3 @@ }); | ||
it ('should handle no transaction annotations used, ignoring functions that match in name to ignore array', () => { | ||
it('should handle no transaction annotations used, ignoring functions that match in name to ignore array', () => { | ||
const getMetadataStub = sandbox.stub(Reflect, 'getMetadata').returns(null); | ||
@@ -1015,3 +1020,3 @@ | ||
Object.getPrototypeOf(ci).property = 'value'; | ||
Object.getPrototypeOf(ci).ignoreMe = () => {}; | ||
Object.getPrototypeOf(ci).ignoreMe = () => { }; | ||
@@ -1024,2 +1029,18 @@ const transactions = ChaincodeFromContract.prototype._processContractTransactions(ci, ['ignoreMe']); | ||
name: 'alpha', | ||
parameters: [ | ||
{ | ||
description: 'Argument 0', | ||
name: 'arg0', | ||
schema: { | ||
type: 'string' | ||
} | ||
}, | ||
{ | ||
description: 'Argument 1', | ||
name: 'arg1', | ||
schema: { | ||
type: 'string' | ||
} | ||
} | ||
], | ||
tags: ['submitTx'] | ||
@@ -1032,3 +1053,3 @@ }]); | ||
it ('should handle no transaction annotations used, ignoring functions that start with _', () => { | ||
it('should handle no transaction annotations used, ignoring functions that start with _', () => { | ||
const getMetadataStub = sandbox.stub(Reflect, 'getMetadata').returns(null); | ||
@@ -1038,3 +1059,3 @@ | ||
Object.getPrototypeOf(ci).property = 'value'; | ||
Object.getPrototypeOf(ci)._ignoreMe = () => {}; | ||
Object.getPrototypeOf(ci)._ignoreMe = () => { }; | ||
@@ -1047,2 +1068,18 @@ const transactions = ChaincodeFromContract.prototype._processContractTransactions(ci, []); | ||
name: 'alpha', | ||
parameters: [ | ||
{ | ||
description: 'Argument 0', | ||
name: 'arg0', | ||
schema: { | ||
type: 'string' | ||
} | ||
}, | ||
{ | ||
description: 'Argument 1', | ||
name: 'arg1', | ||
schema: { | ||
type: 'string' | ||
} | ||
} | ||
], | ||
tags: ['submitTx'] | ||
@@ -1055,3 +1092,3 @@ }]); | ||
it ('should not add submitTx to the system contract functions', () => { | ||
it('should not add submitTx to the system contract functions', () => { | ||
const getMetadataStub = sandbox.stub(Reflect, 'getMetadata').returns(null); | ||
@@ -1069,7 +1106,24 @@ | ||
transactions.should.deep.equal([{ | ||
name: 'alpha' | ||
name: 'alpha', | ||
'parameters': [ | ||
{ | ||
'description': 'Argument 0', | ||
'name': 'arg0', | ||
'schema': { | ||
'type': 'string' | ||
} | ||
}, | ||
{ | ||
'description': 'Argument 1', | ||
'name': 'arg1', | ||
'schema': { | ||
'type': 'string' | ||
} | ||
} | ||
] | ||
}]); | ||
}); | ||
it ('should handle transaction annotations being used', () => { | ||
it('should handle transaction annotations being used', () => { | ||
const getMetadataStub = sandbox.stub(Reflect, 'getMetadata').returns([{some: 'transaction'}]); | ||
@@ -1087,5 +1141,46 @@ | ||
}); | ||
it('should handle transactions with no arguments', () => { | ||
const getMetadataStub = sandbox.stub(Reflect, 'getMetadata').returns(null); | ||
const ci = cc.contractImplementations.alpha.contractInstance; | ||
Object.getPrototypeOf(ci).conga = (api) => { }; | ||
const transactions = ChaincodeFromContract.prototype._processContractTransactions(ci, []); | ||
sinon.assert.calledOnce(getMetadataStub); | ||
sinon.assert.calledWith(getMetadataStub, 'fabric:transactions', ci); | ||
transactions.should.deep.equal([ | ||
{ | ||
name: 'alpha', | ||
parameters: [ | ||
{ | ||
description: 'Argument 0', | ||
name: 'arg0', | ||
schema: { | ||
type: 'string' | ||
} | ||
}, | ||
{ | ||
description: 'Argument 1', | ||
name: 'arg1', | ||
schema: { | ||
type: 'string' | ||
} | ||
} | ||
], | ||
tags: ['submitTx'] | ||
}, | ||
{ | ||
name: 'conga', | ||
tags: ['submitTx'] | ||
} | ||
]); | ||
delete Object.getPrototypeOf(ci).conga; | ||
}); | ||
}); | ||
describe ('#_augmentMetadataFromCode', () => { | ||
describe('#_augmentMetadataFromCode', () => { | ||
const exampleMetadata = { | ||
@@ -1169,3 +1264,3 @@ $schema: 'my schema link', | ||
it ('should handle contracts and remove underscore lead properties of contractInstance', () => { | ||
it('should handle contracts and remove underscore lead properties of contractInstance', () => { | ||
const metadataToSend = { | ||
@@ -1238,3 +1333,3 @@ info: exampleMetadata.info, | ||
it ('should fill in components field when not set', () => { | ||
it('should fill in components field when not set', () => { | ||
const metadataToSend = { | ||
@@ -1255,3 +1350,3 @@ contracts: exampleMetadata.contracts, | ||
it ('should fill in components field when not set and reflect fails', () => { | ||
it('should fill in components field when not set and reflect fails', () => { | ||
const metadataToSend = { | ||
@@ -1272,3 +1367,3 @@ contracts: exampleMetadata.contracts, | ||
it ('should fill in schema when not set', () => { | ||
it('should fill in schema when not set', () => { | ||
const metadataToSend = { | ||
@@ -1275,0 +1370,0 @@ components: exampleMetadata.components, |
Sorry, the diff of this file is too big to display
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
0
591541
11202
56
+ Added@types/bytebuffer@5.0.49(transitive)
+ Added@types/long@3.0.32(transitive)
+ Addedgrpc@1.23.3(transitive)
- Removedgrpc@1.17.0(transitive)
Updated@ampretia/x509@^0.4.7
Updatedgrpc@1.23.3