Signed-off-by: Matthias Sieber <matthias.sieber@loxeinc.com>
This commit is contained in:
Matthias Sieber 2022-10-30 21:28:49 -07:00
parent a0e767d838
commit 2c9f8fbc20
8 changed files with 15 additions and 16 deletions

View file

@ -10,7 +10,7 @@ import * as path from 'path';
async function main() { async function main() {
try { try {
// load the network configuration // load the network configuration
const ccpPath = path.resolve(__dirname, '..', '..', '..','test-network','organizations','peerOrganizations','org1.example.com', 'connection-org1.json'); const ccpPath = path.resolve(__dirname, '..', '..', '..', 'test-network', 'organizations', 'peerOrganizations', 'org1.example.com', 'connection-org1.json');
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8')); const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
// Create a new CA client for interacting with the CA. // Create a new CA client for interacting with the CA.

View file

@ -3,13 +3,13 @@
*/ */
import { Gateway, Wallets } from 'fabric-network'; import { Gateway, Wallets } from 'fabric-network';
import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path';
async function main() { async function main() {
try { try {
// load the network configuration // load the network configuration
const ccpPath = path.resolve(__dirname, '..', '..', '..','test-network','organizations','peerOrganizations','org1.example.com', 'connection-org1.json'); const ccpPath = path.resolve(__dirname, '..', '..', '..', 'test-network', 'organizations', 'peerOrganizations', 'org1.example.com', 'connection-org1.json');
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8')); const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
// Create a new file system based wallet for managing identities. // Create a new file system based wallet for managing identities.

View file

@ -3,14 +3,13 @@
*/ */
import { Gateway, Wallets } from 'fabric-network'; import { Gateway, Wallets } from 'fabric-network';
import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path';
async function main() { async function main() {
try { try {
// load the network configuration // load the network configuration
const ccpPath = path.resolve(__dirname, '..', '..', '..','test-network','organizations','peerOrganizations','org1.example.com', 'connection-org1.json'); const ccpPath = path.resolve(__dirname, '..', '..', '..', 'test-network', 'organizations', 'peerOrganizations', 'org1.example.com', 'connection-org1.json');
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8')); const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
// Create a new file system based wallet for managing identities. // Create a new file system based wallet for managing identities.

View file

@ -2,16 +2,16 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import { Wallets, X509Identity } from 'fabric-network';
import * as FabricCAServices from 'fabric-ca-client'; import * as FabricCAServices from 'fabric-ca-client';
import * as path from 'path'; import { Wallets, X509Identity } from 'fabric-network';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path';
async function main() { async function main() {
try { try {
// load the network configuration // load the network configuration
const ccpPath = path.resolve(__dirname, '..', '..', '..','test-network','organizations','peerOrganizations','org1.example.com', 'connection-org1.json'); const ccpPath = path.resolve(__dirname, '..', '..', '..', 'test-network', 'organizations', 'peerOrganizations', 'org1.example.com', 'connection-org1.json');
let ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8')); const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
// Create a new CA client for interacting with the CA. // Create a new CA client for interacting with the CA.
const caURL = ccp.certificateAuthorities['ca.org1.example.com'].url; const caURL = ccp.certificateAuthorities['ca.org1.example.com'].url;
@ -38,8 +38,8 @@ async function main() {
} }
// build a user object for authenticating with the CA // build a user object for authenticating with the CA
const provider = wallet.getProviderRegistry().getProvider(adminIdentity.type); const provider = wallet.getProviderRegistry().getProvider(adminIdentity.type);
const adminUser = await provider.getUserContext(adminIdentity, 'admin'); const adminUser = await provider.getUserContext(adminIdentity, 'admin');
// Register the user, enroll the user, and import the new identity into the wallet. // Register the user, enroll the user, and import the new identity into the wallet.
const secret = await ca.register({ affiliation: 'org1.department1', enrollmentID: 'appUser', role: 'client' }, adminUser); const secret = await ca.register({ affiliation: 'org1.department1', enrollmentID: 'appUser', role: 'client' }, adminUser);