Я создаю сервер nodejs, куда добавляю участников и создаю карты в облачном кошельке. Из того, что я узнал из игры с композитором sdk, я закончил тем, что создал функцию, которая берет данные об участнике, затем выдает удостоверение личности, а затем создает карту в облачном хранилище. Этот метод работал нормально до сегодняшнего дня.
Внезапно я получаю 413. - Слишком большой объект, когда я пытаюсь импортировать карту.
Есть предложения?
const BusinessNetworkConnection = require("composer-client")
.BusinessNetworkConnection;
const NetworkCardStoreManager = require("composer-common")
.NetworkCardStoreManager;
const IdCard = require("composer-common").IdCard;
const connectionProfile = JSON.parse(
JSON.stringify(require("./connection-profile.json"))
);
const walletType = {
type: "@ampretia/composer-wallet-cloudant",
options: {
database: "composer-wallets",
apikey: "",
host: "",
iam_apikey_description: "",
iam_apikey_name: "",
iam_serviceid_crn: "",
password: "",
port: ,
url: "",
username: ""
}
};
const AdminConnection = require("composer-admin").AdminConnection;
const cardStore = NetworkCardStoreManager.getCardStore(walletType);
const bnConnection = new BusinessNetworkConnection({ cardStore });
const adminConnection = new AdminConnection({ cardStore });
const addParticipantAndIssueIdentity = userDetails => {
return new Promise(async (resolve, reject) => {
try {
await adminConnection.connect("admin@test.com");
const definition = await bnConnection.connect(
"admin@test.com"
);
const participantRegistry = await bnConnection.getParticipantRegistry(
`org.test.bna.${userDetails.role}`
);
const factory = definition.getFactory();
let participant = factory.newResource(
"org.test.bna",
`${userDetails.role}`,
`${userDetails.uid}`
);
participant.email = userDetails.email;
participant.firstName = userDetails.firstName;
participant.lastName = userDetails.lastName;
await participantRegistry.add(participant);
const returnedCard = await bnConnection.issueIdentity(
`org.test.bna.${userDetails.role}#${userDetails.uid}`,
`${userDetails.uid}`
);
const metadata = {
userName: returnedCard.userID,
version: 1,
enrollmentSecret: returnedCard.userSecret,
businessNetwork: "test"
};
const idCard = new IdCard(metadata, connectionProfile);
console.log("Importing Card 1");
await adminConnection.importCard(
`${userDetails.uid}@test`,
idCard
); <----- This call is failing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
console.log("Request Identity");
const result = await adminConnection.requestIdentity(
`${userDetails.uid}@test`,
returnedCard.userID,
returnedCard.enrollmentSecret
);
idCard.setCredentials({
...result,
privateKey: result.key
});
console.log("Importing Card 2");
await adminConnection.importCard(
`${userDetails.uid}@test`,
idCard
);
console.log("Exporting Card");
await adminConnection.exportCard(
`${userDetails.uid}@test`
);
resolve(true);
} catch (error) {
console.log(error);
reject(error);
}
});
};
UPDATE:
Я добавил журнал ошибок ниже:
{ Error: Failed to save card: testCard@test
at card.toArchive.then.catch (/node_modules/composer-common/lib/cardstore/walletbackedcardstore.js:100:31)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
cause:
{ Error: 413 Request Entity Too Large
at Object.clientCallback (/node_modules/@cloudant/cloudant/lib/client.js:213:20)
at Request._callback (/node_modules/@cloudant/cloudant/lib/clientutils.js:154:11)
at Request.self.callback (/node_modules/request/request.js:185:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.self._source.emit (/node_modules/@cloudant/cloudant/lib/eventrelay.js:78:21)
at Request.<anonymous> (/node_modules/request/request.js:1161:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at Request.self._source.emit (/node_modules/@cloudant/cloudant/lib/eventrelay.js:78:21)
_response:
IncomingMessage {
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_eventsCount: 4,
_maxListeners: undefined,
socket: [Object],
connection: [Object],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
upgrade: false,
url: '',
method: null,
statusCode: 413,
statusMessage: 'Request Entity Too Large',
client: [Object],
_consuming: true,
_dumped: false,
req: [Object],
request: [Object],
toJSON: [Function: responseToJSON],
caseless: [Object],
read: [Function],
body: '{"error":"document_too_large","reason":"cards"}\n' },
_data: { error: 'document_too_large', reason: 'cards', statusCode: 413 } } }
{ Error: Failed to save card: pleasework52@airspace-blockchain-company
at card.toArchive.then.catch (/node_modules/composer-common/lib/cardstore/walletbackedcardstore.js:100:31)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
cause:
{ Error: 413 Request Entity Too Large
at Object.clientCallback (/node_modules/@cloudant/cloudant/lib/client.js:213:20)
at Request._callback (/node_modules/@cloudant/cloudant/lib/clientutils.js:154:11)
at Request.self.callback (/node_modules/request/request.js:185:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.self._source.emit (/node_modules/@cloudant/cloudant/lib/eventrelay.js:78:21)
at Request.<anonymous> (/node_modules/request/request.js:1161:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at Request.self._source.emit (/node_modules/@cloudant/cloudant/lib/eventrelay.js:78:21)
_response:
IncomingMessage {
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_eventsCount: 4,
_maxListeners: undefined,
socket: [Object],
connection: [Object],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
upgrade: false,
url: '',
method: null,
statusCode: 413,
statusMessage: 'Request Entity Too Large',
client: [Object],
_consuming: true,
_dumped: false,
req: [Object],
request: [Object],
toJSON: [Function: responseToJSON],
caseless: [Object],
read: [Function],
body: '{"error":"document_too_large","reason":"cards"}\n' },
_data: { error: 'document_too_large', reason: 'cards', statusCode: 413 } } }