@degengineering/web3pgp-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/commands/blockchain/addSubkey.d.ts +9 -0
- package/dist/commands/blockchain/addSubkey.d.ts.map +1 -0
- package/dist/commands/blockchain/addSubkey.js +49 -0
- package/dist/commands/blockchain/addSubkey.js.map +1 -0
- package/dist/commands/blockchain/certify.d.ts +13 -0
- package/dist/commands/blockchain/certify.d.ts.map +1 -0
- package/dist/commands/blockchain/certify.js +75 -0
- package/dist/commands/blockchain/certify.js.map +1 -0
- package/dist/commands/blockchain/challenge.d.ts +13 -0
- package/dist/commands/blockchain/challenge.d.ts.map +1 -0
- package/dist/commands/blockchain/challenge.js +58 -0
- package/dist/commands/blockchain/challenge.js.map +1 -0
- package/dist/commands/blockchain/generateKey.d.ts +7 -0
- package/dist/commands/blockchain/generateKey.d.ts.map +1 -0
- package/dist/commands/blockchain/generateKey.js +36 -0
- package/dist/commands/blockchain/generateKey.js.map +1 -0
- package/dist/commands/blockchain/getPublicKey.d.ts +9 -0
- package/dist/commands/blockchain/getPublicKey.d.ts.map +1 -0
- package/dist/commands/blockchain/getPublicKey.js +37 -0
- package/dist/commands/blockchain/getPublicKey.js.map +1 -0
- package/dist/commands/blockchain/index.d.ts +12 -0
- package/dist/commands/blockchain/index.d.ts.map +1 -0
- package/dist/commands/blockchain/index.js +33 -0
- package/dist/commands/blockchain/index.js.map +1 -0
- package/dist/commands/blockchain/keccak256.d.ts +7 -0
- package/dist/commands/blockchain/keccak256.d.ts.map +1 -0
- package/dist/commands/blockchain/keccak256.js +38 -0
- package/dist/commands/blockchain/keccak256.js.map +1 -0
- package/dist/commands/blockchain/listen.d.ts +9 -0
- package/dist/commands/blockchain/listen.d.ts.map +1 -0
- package/dist/commands/blockchain/listen.js +30 -0
- package/dist/commands/blockchain/listen.js.map +1 -0
- package/dist/commands/blockchain/prove.d.ts +13 -0
- package/dist/commands/blockchain/prove.d.ts.map +1 -0
- package/dist/commands/blockchain/prove.js +123 -0
- package/dist/commands/blockchain/prove.js.map +1 -0
- package/dist/commands/blockchain/register.d.ts +13 -0
- package/dist/commands/blockchain/register.d.ts.map +1 -0
- package/dist/commands/blockchain/register.js +65 -0
- package/dist/commands/blockchain/register.js.map +1 -0
- package/dist/commands/blockchain/revoke-certification.d.ts +13 -0
- package/dist/commands/blockchain/revoke-certification.d.ts.map +1 -0
- package/dist/commands/blockchain/revoke-certification.js +75 -0
- package/dist/commands/blockchain/revoke-certification.js.map +1 -0
- package/dist/commands/blockchain/revoke.d.ts +19 -0
- package/dist/commands/blockchain/revoke.d.ts.map +1 -0
- package/dist/commands/blockchain/revoke.js +118 -0
- package/dist/commands/blockchain/revoke.js.map +1 -0
- package/dist/commands/blockchain/sync.d.ts +20 -0
- package/dist/commands/blockchain/sync.d.ts.map +1 -0
- package/dist/commands/blockchain/sync.js +246 -0
- package/dist/commands/blockchain/sync.js.map +1 -0
- package/dist/commands/blockchain/update.d.ts +13 -0
- package/dist/commands/blockchain/update.d.ts.map +1 -0
- package/dist/commands/blockchain/update.js +60 -0
- package/dist/commands/blockchain/update.js.map +1 -0
- package/dist/commands/configuration/display.d.ts +10 -0
- package/dist/commands/configuration/display.d.ts.map +1 -0
- package/dist/commands/configuration/display.js +58 -0
- package/dist/commands/configuration/display.js.map +1 -0
- package/dist/commands/configuration/generate.d.ts +14 -0
- package/dist/commands/configuration/generate.d.ts.map +1 -0
- package/dist/commands/configuration/generate.js +222 -0
- package/dist/commands/configuration/generate.js.map +1 -0
- package/dist/commands/configuration/index.d.ts +6 -0
- package/dist/commands/configuration/index.d.ts.map +1 -0
- package/dist/commands/configuration/index.js +21 -0
- package/dist/commands/configuration/index.js.map +1 -0
- package/dist/commands/configuration/validate.d.ts +10 -0
- package/dist/commands/configuration/validate.d.ts.map +1 -0
- package/dist/commands/configuration/validate.js +45 -0
- package/dist/commands/configuration/validate.js.map +1 -0
- package/dist/commands/factory.d.ts +33 -0
- package/dist/commands/factory.d.ts.map +1 -0
- package/dist/commands/factory.js +48 -0
- package/dist/commands/factory.js.map +1 -0
- package/dist/config/defaults.d.ts +8 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +11 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/loader.d.ts +12 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +205 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/testnet.d.ts +6 -0
- package/dist/config/testnet.d.ts.map +1 -0
- package/dist/config/testnet.js +26 -0
- package/dist/config/testnet.js.map +1 -0
- package/dist/config/transport.d.ts +17 -0
- package/dist/config/transport.d.ts.map +1 -0
- package/dist/config/transport.js +46 -0
- package/dist/config/transport.js.map +1 -0
- package/dist/config/types.d.ts +92 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +12 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/validator.d.ts +14 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +156 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +28 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/services/web3pgpServiceFactory.d.ts +14 -0
- package/dist/services/web3pgpServiceFactory.d.ts.map +1 -0
- package/dist/services/web3pgpServiceFactory.js +228 -0
- package/dist/services/web3pgpServiceFactory.js.map +1 -0
- package/dist/setup.d.ts +14 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +46 -0
- package/dist/setup.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/clients.d.ts +49373 -0
- package/dist/utils/clients.d.ts.map +1 -0
- package/dist/utils/clients.js +129 -0
- package/dist/utils/clients.js.map +1 -0
- package/dist/utils/input.d.ts +24 -0
- package/dist/utils/input.d.ts.map +1 -0
- package/dist/utils/input.js +138 -0
- package/dist/utils/input.js.map +1 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +35 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Cryptogram Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Web3PGP CLI
|
|
2
|
+
|
|
3
|
+
A command-line interface for decentralized OpenPGP key infrastructure on Ethereum. Register, manage, and verify cryptographic identities directly from your terminal through the Web3PGP smart contract.
|
|
4
|
+
|
|
5
|
+
## Related CLIs
|
|
6
|
+
|
|
7
|
+
This is one of two CLIs in the DEXES project:
|
|
8
|
+
|
|
9
|
+
- **[Web3PGP CLI](web3pgp/)** - Manage OpenPGP keys on Ethereum
|
|
10
|
+
- **[Web3Sign CLI](web3sign/)** - Timestamp documents with cryptographic verification
|
|
11
|
+
|
|
12
|
+
## What is Web3PGP?
|
|
13
|
+
|
|
14
|
+
Web3PGP enables a decentralized public key infrastructure (PKI) using OpenPGP and Ethereum. It allows:
|
|
15
|
+
|
|
16
|
+
- **Decentralized Key Registry**: Store and retrieve OpenPGP public keys on the blockchain
|
|
17
|
+
- **Identity Certification**: Establish trust chains by certifying keys on-chain
|
|
18
|
+
- **Key Revocation**: Revoke compromised or expired keys transparently
|
|
19
|
+
- **Transparent Auditing**: Immutable record of all key operations via blockchain events
|
|
20
|
+
- **Cost Efficiency**: Uses event logs for gas-optimized storage instead of contract state
|
|
21
|
+
|
|
22
|
+
The Web3PGP protocol is implemented as a set of smart contracts that provide a composable foundation for building decentralized PKI applications. The CLI is the primary tool for interacting with these contracts.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- 🔐 **Key Management**: Register, revoke, and manage OpenPGP keys on-chain
|
|
27
|
+
- ⛓️ **Blockchain Sync**: Listen to blockchain events and listen to key changes and revocations in real-time
|
|
28
|
+
- 🔍 **Key Lookup**: Retrieve public keys by fingerprint from the blockchain
|
|
29
|
+
- ✅ **Key Certification**: Establish and revoke trust chains for identity verification
|
|
30
|
+
- ⚙️ **Configuration**: Flexible YAML-based and environment-variable configuration
|
|
31
|
+
- 🛡️ **Security**: Easy wallet coonfiiguration with private key management
|
|
32
|
+
- 🧩 **SDK-Powered**: Built on the Web3PGP TypeScript SDK for robust blockchain interaction
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
### Global Installation (Recommended)
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install -g @degengineering/web3pgp-cli
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then use directly:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
web3pgp --help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Local Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install --save-dev @degengineering/web3pgp-cli
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then use with npx:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx web3pgp --help
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Direct Execution (No Installation)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx @degengineering/web3pgp-cli --help
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Create and fund your Ethereum key
|
|
67
|
+
|
|
68
|
+
Generate an Ethereum private key for signing transactions:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
web3pgp generate-key
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The CLI uses this approach for automation-friendly, low-risk operations. A small amount of ETH woorth a few dollars covers severall dozens of write operations; read operations are free unless using private RPC endpoints.
|
|
75
|
+
|
|
76
|
+
Fund your key on the target blockchain (Sepolia for testing, Scroll for production).
|
|
77
|
+
|
|
78
|
+
## Quick Start
|
|
79
|
+
|
|
80
|
+
Guides about how to use the CLI can be found [in the 'examples' folder](clis/web3pgp/examples/USE_WITH_GPG.md).
|
|
81
|
+
|
|
82
|
+
## Configuration
|
|
83
|
+
|
|
84
|
+
The CLI uses a flexible configuration system with multiple sources (defaults, YAML file, environment variables, CLI flags). See [CONFIGURATION.md](documentation/CONFIGURATION.md) for the complete reference.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
## Getting Started with Development
|
|
88
|
+
|
|
89
|
+
See [DEV.md](documentation/DEV.md) for detailed information about:
|
|
90
|
+
- Project architecture and code structure
|
|
91
|
+
- How to set up the development environment
|
|
92
|
+
- Guidelines for adding new features and commands
|
|
93
|
+
- Configuration system design
|
|
94
|
+
|
|
95
|
+
## Running Tests
|
|
96
|
+
|
|
97
|
+
See [TEST.md](documentation/TEST.md) for comprehensive testing documentation:
|
|
98
|
+
- Unit tests: `npm test`
|
|
99
|
+
- Integration tests: `npm run test:integration`
|
|
100
|
+
- Test coverage: `npm run test:coverage`
|
|
101
|
+
- Watch mode: `npm run test:watch`
|
|
102
|
+
|
|
103
|
+
## Architecture
|
|
104
|
+
|
|
105
|
+
The Web3PGP CLI is built on top of the Web3PGP TypeScript SDK (`sdks/typescript/`), which provides:
|
|
106
|
+
|
|
107
|
+
- Smart contract abstractions for key operations
|
|
108
|
+
- OpenPGP message handling and validation
|
|
109
|
+
- Ethereum wallet integration
|
|
110
|
+
- Event listening and blockchain synchronization
|
|
111
|
+
|
|
112
|
+
The CLI layer adds:
|
|
113
|
+
- User-friendly command-line interface
|
|
114
|
+
- Configuration management
|
|
115
|
+
- Command routing and error handling
|
|
116
|
+
- Structured logging
|
|
117
|
+
|
|
118
|
+
## Documentation
|
|
119
|
+
|
|
120
|
+
- **[CONFIGURATION.md](documentation/CONFIGURATION.md)** - Complete configuration reference with examples
|
|
121
|
+
- **[TRANSPORT.md](documentation/TRANSPORT.md)** - RPC configuration, batching, and retry strategies
|
|
122
|
+
- **[DEV.md](documentation/DEV.md)** - Development guide and architecture overview
|
|
123
|
+
- **[TEST.md](documentation/TEST.md)** - Testing guide and test structure
|
|
124
|
+
- **[DEMO.md](../../DEMO.md)** - Complete end-to-end tutorial with timestamping and certification
|
|
125
|
+
|
|
126
|
+
## Requirements
|
|
127
|
+
|
|
128
|
+
- **Node.js**: 18.x or higher
|
|
129
|
+
- **npm**: 8.x or higher
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT License - see LICENSE file for details
|
|
134
|
+
|
|
135
|
+
## Support
|
|
136
|
+
|
|
137
|
+
For issues, questions, or contributions:
|
|
138
|
+
- GitHub: https://github.com/degengineering/dexes
|
|
139
|
+
- Documentation: https://github.com/degengineering/dexes
|
|
140
|
+
- Issues: https://github.com/degengineering/dexes/issues
|
|
141
|
+
|
|
142
|
+
## Contributing
|
|
143
|
+
|
|
144
|
+
Contributions are welcome! Please:
|
|
145
|
+
1. Fork the repository
|
|
146
|
+
2. Create a feature branch
|
|
147
|
+
3. Commit your changes
|
|
148
|
+
4. Push to the branch
|
|
149
|
+
5. Create a Pull Request
|
|
150
|
+
|
|
151
|
+
See [DEV.md](documentation/DEV.md) for development setup and [TEST.md](documentation/TEST.md) for testing guidelines.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Logger } from 'pino';
|
|
3
|
+
import { IWeb3PGPService } from '@degengineering/dexes';
|
|
4
|
+
export interface AddSubkeyDeps {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
service: IWeb3PGPService;
|
|
7
|
+
}
|
|
8
|
+
export declare function createAddSubkeyCommand(deps: AddSubkeyDeps): Command;
|
|
9
|
+
//# sourceMappingURL=addSubkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addSubkey.d.ts","sourceRoot":"","sources":["../../../src/commands/blockchain/addSubkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAQ,MAAM,uBAAuB,CAAC;AAK9D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CA6CnE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAddSubkeyCommand = createAddSubkeyCommand;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const dexes_1 = require("@degengineering/dexes");
|
|
6
|
+
const factory_1 = require("../factory");
|
|
7
|
+
const input_1 = require("../../utils/input");
|
|
8
|
+
function createAddSubkeyCommand(deps) {
|
|
9
|
+
const { logger, service } = deps;
|
|
10
|
+
const cmdLogger = logger.child({ command: 'add-subkey' });
|
|
11
|
+
return new commander_1.Command('add-subkey')
|
|
12
|
+
.arguments('<subkeyFingerprint>')
|
|
13
|
+
.description('Add a subkey to an existing key on the blockchain')
|
|
14
|
+
.option('--key <path>', 'Path to PGP key file containing the subkey (armored or binary)')
|
|
15
|
+
.action(async (subkeyFingerprintArg, options) => {
|
|
16
|
+
try {
|
|
17
|
+
// Subkey fingerprint is mandatory
|
|
18
|
+
const subkeyFingerprint = subkeyFingerprintArg.replaceAll(/\s/g, '');
|
|
19
|
+
cmdLogger.debug({ subkeyFingerprint: subkeyFingerprint }, 'Processing subkey fingerprint');
|
|
20
|
+
let keyData;
|
|
21
|
+
if (options.key) {
|
|
22
|
+
cmdLogger.info({ path: options.key }, 'Reading key from file');
|
|
23
|
+
keyData = (0, input_1.readInputFromFile)(options.key);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
cmdLogger.info('Reading key from stdin');
|
|
27
|
+
keyData = await (0, input_1.readInputFromStdin)();
|
|
28
|
+
}
|
|
29
|
+
cmdLogger.debug({ dataLength: keyData.length }, 'Key data received');
|
|
30
|
+
// Parse the key - tries armored format first, then binary
|
|
31
|
+
const key = (await (0, input_1.readKeyData)(keyData));
|
|
32
|
+
cmdLogger.info({ subkeyFingerprint: subkeyFingerprint }, 'Adding subkey to blockchain');
|
|
33
|
+
const result = await service.addSubkey(key, (0, dexes_1.to0x)(subkeyFingerprint));
|
|
34
|
+
(0, factory_1.outputJson)({
|
|
35
|
+
success: true,
|
|
36
|
+
message: 'Subkey added successfully',
|
|
37
|
+
subkeyFingerprint: subkeyFingerprint,
|
|
38
|
+
transaction: { hash: result.transactionHash, blockNumber: result.blockNumber.toString() },
|
|
39
|
+
});
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
44
|
+
cmdLogger.error({ error: msg }, 'Failed to add subkey');
|
|
45
|
+
(0, factory_1.exitWithError)(msg);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=addSubkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addSubkey.js","sourceRoot":"","sources":["../../../src/commands/blockchain/addSubkey.ts"],"names":[],"mappings":";;AAYA,wDA6CC;AAzDD,yCAAoC;AAEpC,iDAA8D;AAE9D,wCAAuD;AACvD,6CAAuF;AAOvF,SAAgB,sBAAsB,CAAC,IAAmB;IACxD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IAE1D,OAAO,IAAI,mBAAO,CAAC,YAAY,CAAC;SAC7B,SAAS,CAAC,qBAAqB,CAAC;SAChC,WAAW,CAAC,mDAAmD,CAAC;SAChE,MAAM,CAAC,cAAc,EAAE,gEAAgE,CAAC;SACxF,MAAM,CAAC,KAAK,EAAE,oBAA4B,EAAE,OAAyB,EAAE,EAAE;QACxE,IAAI,CAAC;YACH,kCAAkC;YAClC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACrE,SAAS,CAAC,KAAK,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,EAAE,+BAA+B,CAAC,CAAC;YAE3F,IAAI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AS,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,sBAAsB,CAAC,CAAC;YACxD,IAAA,uBAAa,EAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Logger } from 'pino';
|
|
3
|
+
import { IWeb3PGPService } from '@degengineering/dexes';
|
|
4
|
+
export interface CertifyDeps {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
service: IWeb3PGPService;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Certify a public key on the blockchain
|
|
10
|
+
* Usage: web3pgp certify <issuerFingerprint> --key <path> | read from stdin
|
|
11
|
+
*/
|
|
12
|
+
export declare function createCertifyCommand(deps: CertifyDeps): Command;
|
|
13
|
+
//# sourceMappingURL=certify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"certify.d.ts","sourceRoot":"","sources":["../../../src/commands/blockchain/certify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAmB,MAAM,uBAAuB,CAAC;AAKzE,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAgF/D"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCertifyCommand = createCertifyCommand;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const dexes_1 = require("@degengineering/dexes");
|
|
6
|
+
const factory_1 = require("../factory");
|
|
7
|
+
const input_1 = require("../../utils/input");
|
|
8
|
+
/**
|
|
9
|
+
* Certify a public key on the blockchain
|
|
10
|
+
* Usage: web3pgp certify <issuerFingerprint> --key <path> | read from stdin
|
|
11
|
+
*/
|
|
12
|
+
function createCertifyCommand(deps) {
|
|
13
|
+
const { logger, service } = deps;
|
|
14
|
+
const cmdLogger = logger.child({ command: 'certify' });
|
|
15
|
+
return new commander_1.Command('certify')
|
|
16
|
+
.description('Add a third-party key certification attached to the provided key on the blockchain')
|
|
17
|
+
.argument('<issuerFingerprint>', 'Hex string fingerprint of the issuer')
|
|
18
|
+
.option('--key <path>', 'Path to PGP public key file to certify (armored or binary)')
|
|
19
|
+
.action(async (issuerFingerprint, options) => {
|
|
20
|
+
try {
|
|
21
|
+
// Convert issuer fingerprint to bytes32 format
|
|
22
|
+
const issuerFp = (0, dexes_1.toBytes32)((0, dexes_1.to0x)(issuerFingerprint.replaceAll(/\s/g, '')));
|
|
23
|
+
cmdLogger.info({ issuerFp }, 'Fetching issuer public key');
|
|
24
|
+
let keyData;
|
|
25
|
+
// Determine source and read input
|
|
26
|
+
if (options.key) {
|
|
27
|
+
cmdLogger.info({ path: options.key }, 'Reading PGP key to certify from file');
|
|
28
|
+
keyData = (0, input_1.readInputFromFile)(options.key);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
cmdLogger.info('Reading PGP key to certify from stdin');
|
|
32
|
+
keyData = await (0, input_1.readInputFromStdin)();
|
|
33
|
+
}
|
|
34
|
+
cmdLogger.debug({ dataLength: keyData.length }, 'Key data received');
|
|
35
|
+
// Parse key - tries armor format first, then binary
|
|
36
|
+
cmdLogger.info('Parsing and validating PGP key to certify');
|
|
37
|
+
const certifiedKey = (await (0, input_1.readKeyData)(keyData));
|
|
38
|
+
cmdLogger.debug({ fingerprint: certifiedKey.getFingerprint() }, 'Key to certify parsed successfully');
|
|
39
|
+
// Fetch issuer's public key from blockchain
|
|
40
|
+
const issuerPk = await service.getPublicKey(issuerFp);
|
|
41
|
+
cmdLogger.debug({ issuerFingerprint: issuerPk.getFingerprint() }, 'Issuer public key retrieved');
|
|
42
|
+
// Certify the key on the blockchain
|
|
43
|
+
const result = await service.certify(issuerPk, certifiedKey);
|
|
44
|
+
cmdLogger.info({
|
|
45
|
+
issuerFingerprint: issuerPk.getFingerprint(),
|
|
46
|
+
certifiedFingerprint: certifiedKey.getFingerprint(),
|
|
47
|
+
transactionHash: result.transactionHash,
|
|
48
|
+
blockNumber: result.blockNumber,
|
|
49
|
+
}, 'Key certification successful');
|
|
50
|
+
// Output result as JSON
|
|
51
|
+
(0, factory_1.outputJson)({
|
|
52
|
+
success: true,
|
|
53
|
+
message: 'Public key certified successfully',
|
|
54
|
+
issuer: {
|
|
55
|
+
fingerprint: issuerFp,
|
|
56
|
+
},
|
|
57
|
+
certified: {
|
|
58
|
+
fingerprint: certifiedKey.getFingerprint(),
|
|
59
|
+
subkeys: certifiedKey.getSubkeys().map((sk) => sk.getFingerprint()),
|
|
60
|
+
},
|
|
61
|
+
transaction: {
|
|
62
|
+
hash: result.transactionHash,
|
|
63
|
+
blockNumber: result.blockNumber.toString(),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
70
|
+
cmdLogger.error({ error: msg }, 'Failed to certify key');
|
|
71
|
+
(0, factory_1.exitWithError)(msg);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=certify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"certify.js","sourceRoot":"","sources":["../../../src/commands/blockchain/certify.ts"],"names":[],"mappings":";;AAgBA,oDAgFC;AAhGD,yCAAoC;AAEpC,iDAAyE;AAEzE,wCAAuD;AACvD,6CAAuF;AAOvF;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,IAAiB;IACpD,MAAM,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G,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,SAAS,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,uBAAuB,CAAC,CAAC;YACzD,IAAA,uBAAa,EAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Logger } from 'pino';
|
|
3
|
+
import { IWeb3PGPService } from '@degengineering/dexes';
|
|
4
|
+
export interface ChallengeDeps {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
service: IWeb3PGPService;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Challenge the ownership of a key on the blockchain
|
|
10
|
+
* Usage: web3pgp challenge <fingerprint> <hash>
|
|
11
|
+
*/
|
|
12
|
+
export declare function createChallengeCommand(deps: ChallengeDeps): Command;
|
|
13
|
+
//# sourceMappingURL=challenge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"challenge.d.ts","sourceRoot":"","sources":["../../../src/commands/blockchain/challenge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAmB,MAAM,uBAAuB,CAAC;AAIzE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAyDnE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createChallengeCommand = createChallengeCommand;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const dexes_1 = require("@degengineering/dexes");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const factory_1 = require("../factory");
|
|
8
|
+
/**
|
|
9
|
+
* Challenge the ownership of a key on the blockchain
|
|
10
|
+
* Usage: web3pgp challenge <fingerprint> <hash>
|
|
11
|
+
*/
|
|
12
|
+
function createChallengeCommand(deps) {
|
|
13
|
+
const { logger, service } = deps;
|
|
14
|
+
const cmdLogger = logger.child({ command: 'challenge' });
|
|
15
|
+
return new commander_1.Command('challenge')
|
|
16
|
+
.description('Challenge the owner of the target key to sign the bytes of the keccak256 hash of a random challenge on the blockchain')
|
|
17
|
+
.argument('<fingerprint>', 'Hex string fingerprint of the challenged key')
|
|
18
|
+
.argument('<hash>', 'Keccak256 hash of the challenge as hex string')
|
|
19
|
+
.action(async (fingerprint, hash) => {
|
|
20
|
+
try {
|
|
21
|
+
// Process fingerprint - remove whitespaces and convert to bytes32
|
|
22
|
+
const fp = (0, dexes_1.toBytes32)((0, dexes_1.to0x)(fingerprint.replaceAll(/\s/g, '')));
|
|
23
|
+
cmdLogger.debug({ fingerprint: fp }, 'Fingerprint processed');
|
|
24
|
+
// Process hash - convert hex string to proper format
|
|
25
|
+
const challengeHash = (0, viem_1.toHex)(hash);
|
|
26
|
+
cmdLogger.debug({ hash: challengeHash }, 'Challenge hash processed');
|
|
27
|
+
cmdLogger.info({
|
|
28
|
+
fingerprint: fp,
|
|
29
|
+
hash: challengeHash,
|
|
30
|
+
}, 'Submitting challenge');
|
|
31
|
+
// Challenge the ownership on the blockchain
|
|
32
|
+
const result = await service.challengeOwnership(fp, challengeHash);
|
|
33
|
+
cmdLogger.info({
|
|
34
|
+
fingerprint: fp,
|
|
35
|
+
transactionHash: result.transactionHash,
|
|
36
|
+
blockNumber: result.blockNumber,
|
|
37
|
+
}, 'Key ownership challenge submitted successfully');
|
|
38
|
+
// Output result as JSON
|
|
39
|
+
(0, factory_1.outputJson)({
|
|
40
|
+
success: true,
|
|
41
|
+
message: 'Key ownership challenge submitted successfully',
|
|
42
|
+
fingerprint: fp,
|
|
43
|
+
hash: challengeHash,
|
|
44
|
+
transaction: {
|
|
45
|
+
hash: result.transactionHash,
|
|
46
|
+
blockNumber: result.blockNumber.toString(),
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
53
|
+
cmdLogger.error({ error: msg }, 'Failed to submit challenge');
|
|
54
|
+
(0, factory_1.exitWithError)(msg);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=challenge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"challenge.js","sourceRoot":"","sources":["../../../src/commands/blockchain/challenge.ts"],"names":[],"mappings":";;AAeA,wDAyDC;AAxED,yCAAoC;AAEpC,iDAAyE;AACzE,+BAA6B;AAC7B,wCAAuD;AAOvD;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,IAAmB;IACxD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IAEzD,OAAO,IAAI,mBAAO,CAAC,WAAW,CAAC;SAC5B,WAAW,CAAC,uHAAuH,CAAC;SACpI,QAAQ,CAAC,eAAe,EAAE,8CAA8C,CAAC;SACzE,QAAQ,CAAC,QAAQ,EAAE,+CAA+C,CAAC;SACnE,MAAM,CAAC,KAAK,EAAE,WAAmB,EAAE,IAAY,EAAE,EAAE;QAClD,IAAI,CAAC;YACH,kEAAkE;YAClE,MAAM,EAAE,GAAG,IAAA,iBAAS,EAAC,IAAA,YAAI,EAAC,WAAW,CAAC,UAAU,CAAC,KAA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C,CAAC;YAC9D,IAAA,uBAAa,EAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateKey.d.ts","sourceRoot":"","sources":["../../../src/commands/blockchain/generateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAK9B,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAgCvE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGenerateKeyCommand = createGenerateKeyCommand;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const accounts_1 = require("viem/accounts");
|
|
6
|
+
const accounts_2 = require("viem/accounts");
|
|
7
|
+
const factory_1 = require("../factory");
|
|
8
|
+
function createGenerateKeyCommand(deps) {
|
|
9
|
+
const { logger } = deps;
|
|
10
|
+
const cmdLogger = logger.child({ command: 'generate-key' });
|
|
11
|
+
return new commander_1.Command('generate-key')
|
|
12
|
+
.description('Generate a new Ethereum private key and display the private key and address')
|
|
13
|
+
.action(async () => {
|
|
14
|
+
try {
|
|
15
|
+
cmdLogger.info('Generating new Ethereum key');
|
|
16
|
+
// Generate a random private key
|
|
17
|
+
const privateKey = (0, accounts_2.generatePrivateKey)();
|
|
18
|
+
// Derive the account/address from the private key
|
|
19
|
+
const account = (0, accounts_1.privateKeyToAccount)(privateKey);
|
|
20
|
+
// Output the key and address in hex format
|
|
21
|
+
const output = {
|
|
22
|
+
privateKey: privateKey,
|
|
23
|
+
address: account.address,
|
|
24
|
+
};
|
|
25
|
+
cmdLogger.info({ address: account.address }, 'Key generated');
|
|
26
|
+
console.log(JSON.stringify(output, null, 2));
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
31
|
+
cmdLogger.error({ error: msg }, 'Failed to generate key');
|
|
32
|
+
(0, factory_1.exitWithError)(msg);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=generateKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateKey.js","sourceRoot":"","sources":["../../../src/commands/blockchain/generateKey.ts"],"names":[],"mappings":";;AAUA,4DAgCC;AA1CD,yCAAoC;AAEpC,4CAAoD;AACpD,4CAAmD;AACnD,wCAA2C;AAM3C,SAAgB,wBAAwB,CAAC,IAAqB;IAC5D,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;IAE5D,OAAO,IAAI,mBAAO,CAAC,cAAc,CAAC;SAC/B,WAAW,CAAC,6EAA6E,CAAC;SAC1F,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,SAAS,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;YAE9C,gCAAgC;YAChC,MAAM,UAAU,GAAG,IAAA,6BAAkB,GAAE,CAAC;YAExC,kDAAkD;YAClD,MAAM,OAAO,GAAG,IAAA,8BAAmB,EAAC,UAAU,CAAC,CAAC;YAEhD,2CAA2C;YAC3C,MAAM,MAAM,GAAG;gBACb,UAAU,EAAE,UAAU;gBACtB,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC;YAEF,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,eAAe,CAAC,CAAC;YAC9D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAE7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,SAAS,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,wBAAwB,CAAC,CAAC;YAC1D,IAAA,uBAAa,EAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Logger } from 'pino';
|
|
3
|
+
import { IWeb3PGPService } from '@degengineering/dexes';
|
|
4
|
+
export interface GetPublicKeyDeps {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
service: IWeb3PGPService;
|
|
7
|
+
}
|
|
8
|
+
export declare function createGetPublicKeyCommand(deps: GetPublicKeyDeps): Command;
|
|
9
|
+
//# sourceMappingURL=getPublicKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPublicKey.d.ts","sourceRoot":"","sources":["../../../src/commands/blockchain/getPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAQ,MAAM,uBAAuB,CAAC;AAG9D,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAmCzE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGetPublicKeyCommand = createGetPublicKeyCommand;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const dexes_1 = require("@degengineering/dexes");
|
|
6
|
+
const factory_1 = require("../factory");
|
|
7
|
+
function createGetPublicKeyCommand(deps) {
|
|
8
|
+
const { logger, service } = deps;
|
|
9
|
+
const cmdLogger = logger.child({ command: 'get' });
|
|
10
|
+
return new commander_1.Command('get')
|
|
11
|
+
.description('Retrieve a public key from the blockchain by fingerprint')
|
|
12
|
+
.argument('<fingerprint>', 'Key fingerprint')
|
|
13
|
+
.option('--insecure', 'Disable public key verification when retrieving keys')
|
|
14
|
+
.action(async (fingerprintArg, options) => {
|
|
15
|
+
try {
|
|
16
|
+
const fp = fingerprintArg.replaceAll(/\s/g, '');
|
|
17
|
+
const insecure = options.insecure || false;
|
|
18
|
+
cmdLogger.info({ fingerprint: fp, insecure }, 'Retrieving public key');
|
|
19
|
+
if (insecure) {
|
|
20
|
+
cmdLogger.warn('Insecure mode enabled - public key verification disabled');
|
|
21
|
+
}
|
|
22
|
+
const publicKey = await service.getPublicKey((0, dexes_1.to0x)(fp), insecure);
|
|
23
|
+
if (!publicKey) {
|
|
24
|
+
throw new Error(`No key found for fingerprint: ${fp}`);
|
|
25
|
+
}
|
|
26
|
+
cmdLogger.info({ fingerprint: fp }, 'Key retrieved');
|
|
27
|
+
console.log(publicKey.armor());
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
32
|
+
cmdLogger.error({ error: msg }, 'Failed to retrieve public key');
|
|
33
|
+
(0, factory_1.exitWithError)(msg);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=getPublicKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AC,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;YAE/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,SAAS,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,+BAA+B,CAAC,CAAC;YACjE,IAAA,uBAAa,EAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Logger } from 'pino';
|
|
3
|
+
import { IWeb3PGPService } from '@degengineering/dexes';
|
|
4
|
+
export interface BlockchainCommandsDeps {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
service: IWeb3PGPService;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create all blockchain commands as direct subcommands
|
|
10
|
+
*/
|
|
11
|
+
export declare function createBlockchainCommands(deps: BlockchainCommandsDeps): Command[];
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/blockchain/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAaxD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,EAAE,CAchF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBlockchainCommands = createBlockchainCommands;
|
|
4
|
+
const getPublicKey_1 = require("./getPublicKey");
|
|
5
|
+
const register_1 = require("./register");
|
|
6
|
+
const addSubkey_1 = require("./addSubkey");
|
|
7
|
+
const revoke_1 = require("./revoke");
|
|
8
|
+
const sync_1 = require("./sync");
|
|
9
|
+
const generateKey_1 = require("./generateKey");
|
|
10
|
+
const update_1 = require("./update");
|
|
11
|
+
const certify_1 = require("./certify");
|
|
12
|
+
const revoke_certification_1 = require("./revoke-certification");
|
|
13
|
+
const challenge_1 = require("./challenge");
|
|
14
|
+
const prove_1 = require("./prove");
|
|
15
|
+
/**
|
|
16
|
+
* Create all blockchain commands as direct subcommands
|
|
17
|
+
*/
|
|
18
|
+
function createBlockchainCommands(deps) {
|
|
19
|
+
return [
|
|
20
|
+
(0, getPublicKey_1.createGetPublicKeyCommand)(deps),
|
|
21
|
+
(0, register_1.createRegisterCommand)(deps),
|
|
22
|
+
(0, update_1.createUpdateCommand)(deps),
|
|
23
|
+
(0, addSubkey_1.createAddSubkeyCommand)(deps),
|
|
24
|
+
(0, revoke_1.createRevokeCommand)(deps),
|
|
25
|
+
(0, certify_1.createCertifyCommand)(deps),
|
|
26
|
+
(0, revoke_certification_1.createRevokeCertificationCommand)(deps),
|
|
27
|
+
(0, sync_1.createSyncCommand)(deps),
|
|
28
|
+
(0, generateKey_1.createGenerateKeyCommand)({ logger: deps.logger }),
|
|
29
|
+
(0, challenge_1.createChallengeCommand)(deps),
|
|
30
|
+
(0, prove_1.createProveCommand)(deps),
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/blockchain/index.ts"],"names":[],"mappings":";;AAuBA,4DAcC;AAlCD,iDAA2D;AAC3D,yCAAmD;AACnD,2CAAqD;AACrD,qCAA+C;AAC/C,iCAA2C;AAC3C,+CAAyD;AACzD,qCAA+C;AAC/C,uCAAiD;AACjD,iEAA0E;AAC1E,2CAAqD;AACrD,mCAA6C;AAO7C;;GAEG;AACH,SAAgB,wBAAwB,CAAC,IAA4B;IACnE,OAAO;QACL,IAAA,wCAAyB,EAAC,IAAI,CAAC;QAC/B,IAAA,gCAAqB,EAAC,IAAI,CAAC;QAC3B,IAAA,4BAAmB,EAAC,IAAI,CAAC;QACzB,IAAA,kCAAsB,EAAC,IAAI,CAAC;QAC5B,IAAA,4BAAmB,EAAC,IAAI,CAAC;QACzB,IAAA,8BAAoB,EAAC,IAAI,CAAC;QAC1B,IAAA,uDAAgC,EAAC,IAAI,CAAC;QACtC,IAAA,wBAAiB,EAAC,IAAI,CAAC;QACvB,IAAA,sCAAwB,EAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACjD,IAAA,kCAAsB,EAAC,IAAI,CAAC;QAC5B,IAAA,0BAAkB,EAAC,IAAI,CAAC;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keccak256.d.ts","sourceRoot":"","sources":["../../../src/commands/blockchain/keccak256.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAI9B,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAmC1E"}
|