@fairmint/canton-node-sdk 0.0.222 → 0.0.223
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/build/src/generated/apps/common/src/main/openapi/common-external.d.ts +295 -0
- package/build/src/generated/apps/common/src/main/openapi/common-external.d.ts.map +1 -0
- package/build/src/generated/apps/common/src/main/openapi/common-external.js +7 -0
- package/build/src/generated/apps/common/src/main/openapi/common-external.js.map +1 -0
- package/build/src/generated/apps/common/src/main/openapi/common-internal.d.ts +204 -0
- package/build/src/generated/apps/common/src/main/openapi/common-internal.d.ts.map +1 -0
- package/build/src/generated/apps/common/src/main/openapi/common-internal.js +7 -0
- package/build/src/generated/apps/common/src/main/openapi/common-internal.js.map +1 -0
- package/build/src/generated/apps/scan/src/main/openapi/scan-stream-server.d.ts +73 -0
- package/build/src/generated/apps/scan/src/main/openapi/scan-stream-server.d.ts.map +1 -0
- package/build/src/generated/apps/scan/src/main/openapi/scan-stream-server.js +7 -0
- package/build/src/generated/apps/scan/src/main/openapi/scan-stream-server.js.map +1 -0
- package/build/src/generated/apps/scan/src/main/openapi/scan.d.ts +4969 -0
- package/build/src/generated/apps/scan/src/main/openapi/scan.d.ts.map +1 -0
- package/build/src/generated/apps/scan/src/main/openapi/scan.js +7 -0
- package/build/src/generated/apps/scan/src/main/openapi/scan.js.map +1 -0
- package/build/src/generated/apps/splitwell/src/main/openapi/splitwell-internal.d.ts +636 -0
- package/build/src/generated/apps/splitwell/src/main/openapi/splitwell-internal.d.ts.map +1 -0
- package/build/src/generated/apps/splitwell/src/main/openapi/splitwell-internal.js +7 -0
- package/build/src/generated/apps/splitwell/src/main/openapi/splitwell-internal.js.map +1 -0
- package/build/src/generated/apps/sv/src/main/openapi/sv-internal.d.ts +2024 -0
- package/build/src/generated/apps/sv/src/main/openapi/sv-internal.d.ts.map +1 -0
- package/build/src/generated/apps/sv/src/main/openapi/sv-internal.js +7 -0
- package/build/src/generated/apps/sv/src/main/openapi/sv-internal.js.map +1 -0
- package/build/src/generated/apps/validator/src/main/openapi/ans-external.d.ts +189 -0
- package/build/src/generated/apps/validator/src/main/openapi/ans-external.d.ts.map +1 -0
- package/build/src/generated/apps/validator/src/main/openapi/ans-external.js +7 -0
- package/build/src/generated/apps/validator/src/main/openapi/ans-external.js.map +1 -0
- package/build/src/generated/apps/validator/src/main/openapi/scan-proxy.d.ts +969 -0
- package/build/src/generated/apps/validator/src/main/openapi/scan-proxy.d.ts.map +1 -0
- package/build/src/generated/apps/validator/src/main/openapi/scan-proxy.js +7 -0
- package/build/src/generated/apps/validator/src/main/openapi/scan-proxy.js.map +1 -0
- package/build/src/generated/apps/validator/src/main/openapi/validator-internal.d.ts +1230 -0
- package/build/src/generated/apps/validator/src/main/openapi/validator-internal.d.ts.map +1 -0
- package/build/src/generated/apps/validator/src/main/openapi/validator-internal.js +7 -0
- package/build/src/generated/apps/validator/src/main/openapi/validator-internal.js.map +1 -0
- package/build/src/generated/apps/wallet/src/main/openapi/wallet-external.d.ts +535 -0
- package/build/src/generated/apps/wallet/src/main/openapi/wallet-external.d.ts.map +1 -0
- package/build/src/generated/apps/wallet/src/main/openapi/wallet-external.js +7 -0
- package/build/src/generated/apps/wallet/src/main/openapi/wallet-external.js.map +1 -0
- package/build/src/generated/apps/wallet/src/main/openapi/wallet-internal.d.ts +2521 -0
- package/build/src/generated/apps/wallet/src/main/openapi/wallet-internal.d.ts.map +1 -0
- package/build/src/generated/apps/wallet/src/main/openapi/wallet-internal.js +7 -0
- package/build/src/generated/apps/wallet/src/main/openapi/wallet-internal.js.map +1 -0
- package/package.json +5 -1
- package/.gitmodules +0 -6
- package/.nvmrc +0 -1
- package/scripts/collapse-manifest.ts +0 -66
- package/scripts/generate-all-client-methods.ts +0 -332
- package/scripts/generate-openapi-types.ts +0 -46
- package/scripts/generate-operation-tests.ts +0 -198
- package/scripts/grant-user-rights.ts +0 -213
- package/scripts/list-identity-providers.ts +0 -46
- package/scripts/localnet/localnet-cloud.sh +0 -5
- package/scripts/localnet/localnet-status.sh +0 -5
- package/scripts/localnet/setup-localnet.sh +0 -5
- package/scripts/localnet/setup-quickstart-localnet.sh +0 -5
- package/scripts/localnet/start-localnet.sh +0 -5
- package/scripts/localnet/stop-localnet.sh +0 -5
- package/scripts/localnet-cloud.sh +0 -653
- package/scripts/localnet-status.sh +0 -5
- package/scripts/prepare-release.ts +0 -222
- package/scripts/revoke-user-rights.ts +0 -219
- package/scripts/setup-localnet.sh +0 -5
- package/scripts/setup-quickstart-localnet.sh +0 -5
- package/scripts/start-localnet.sh +0 -5
- package/scripts/stop-localnet.sh +0 -5
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Prepare Release Script
|
|
5
|
-
*
|
|
6
|
-
* Prepares a new release by incrementing version and generating changelog.
|
|
7
|
-
*
|
|
8
|
-
* Usage: npm run prepare-release
|
|
9
|
-
*
|
|
10
|
-
* Features:
|
|
11
|
-
*
|
|
12
|
-
* - Increments patch version in package.json
|
|
13
|
-
* - Checks both npm registry and git tags to determine next version
|
|
14
|
-
* - Creates changelog from commits since last tag
|
|
15
|
-
* - Links commits to GitHub PRs
|
|
16
|
-
* - Safe for local testing (no git operations)
|
|
17
|
-
* - Saves changelog to CHANGELOG.md
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { execSync } from 'child_process';
|
|
21
|
-
import fs from 'fs';
|
|
22
|
-
import path from 'path';
|
|
23
|
-
|
|
24
|
-
interface PackageJson {
|
|
25
|
-
name: string;
|
|
26
|
-
version: string;
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Check if a git tag exists */
|
|
31
|
-
function tagExists(tag: string): boolean {
|
|
32
|
-
try {
|
|
33
|
-
execSync(`git rev-parse "refs/tags/${tag}"`, { stdio: 'ignore' });
|
|
34
|
-
return true;
|
|
35
|
-
} catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Get the latest version from npm registry */
|
|
41
|
-
function getNpmLatestVersion(packageName: string): string | null {
|
|
42
|
-
try {
|
|
43
|
-
const version = execSync(`npm view ${packageName} version 2>/dev/null`, {
|
|
44
|
-
encoding: 'utf8',
|
|
45
|
-
}).trim();
|
|
46
|
-
return version || null;
|
|
47
|
-
} catch {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** Check if a version exists on npm registry */
|
|
53
|
-
function npmVersionExists(packageName: string, version: string): boolean {
|
|
54
|
-
try {
|
|
55
|
-
const versions = execSync(`npm view ${packageName} versions --json 2>/dev/null`, {
|
|
56
|
-
encoding: 'utf8',
|
|
57
|
-
});
|
|
58
|
-
const versionList = JSON.parse(versions) as string[];
|
|
59
|
-
return versionList.includes(version);
|
|
60
|
-
} catch {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Parse version string into components */
|
|
66
|
-
function parseVersion(version: string): { major: number; minor: number; patch: number } | null {
|
|
67
|
-
const parts = version.split('.').map(Number);
|
|
68
|
-
if (parts.length !== 3 || parts.some(isNaN)) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
const major = parts[0];
|
|
72
|
-
const minor = parts[1];
|
|
73
|
-
const patch = parts[2];
|
|
74
|
-
if (major === undefined || minor === undefined || patch === undefined) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
return { major, minor, patch };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Find the next available version by checking both git tags and npm registry */
|
|
81
|
-
function findNextAvailableVersion(packageName: string, major: number, minor: number, startPatch: number): string {
|
|
82
|
-
let patch = startPatch;
|
|
83
|
-
let version: string;
|
|
84
|
-
|
|
85
|
-
do {
|
|
86
|
-
patch++;
|
|
87
|
-
version = `${major}.${minor}.${patch}`;
|
|
88
|
-
} while (tagExists(`v${version}`) || npmVersionExists(packageName, version));
|
|
89
|
-
|
|
90
|
-
return version;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** Get the highest version from git tags and npm, then find next available */
|
|
94
|
-
function determineNextVersion(packageName: string, currentVersion: string): string {
|
|
95
|
-
const current = parseVersion(currentVersion);
|
|
96
|
-
if (!current) {
|
|
97
|
-
throw new Error(`Invalid version format: ${currentVersion}`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Get latest version from npm registry
|
|
101
|
-
const npmVersion = getNpmLatestVersion(packageName);
|
|
102
|
-
const npm = npmVersion ? parseVersion(npmVersion) : null;
|
|
103
|
-
|
|
104
|
-
// Get latest version from git tags
|
|
105
|
-
let gitVersion: string | null = null;
|
|
106
|
-
try {
|
|
107
|
-
gitVersion = execSync('git describe --tags --abbrev=0 2>/dev/null', {
|
|
108
|
-
encoding: 'utf8',
|
|
109
|
-
}).trim();
|
|
110
|
-
if (gitVersion.startsWith('v')) {
|
|
111
|
-
gitVersion = gitVersion.slice(1);
|
|
112
|
-
}
|
|
113
|
-
} catch {
|
|
114
|
-
gitVersion = null;
|
|
115
|
-
}
|
|
116
|
-
const git = gitVersion ? parseVersion(gitVersion) : null;
|
|
117
|
-
|
|
118
|
-
// Determine the highest patch version among current, npm, and git
|
|
119
|
-
let highestPatch = current.patch;
|
|
120
|
-
|
|
121
|
-
if (npm?.major === current.major && npm.minor === current.minor) {
|
|
122
|
-
highestPatch = Math.max(highestPatch, npm.patch);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (git?.major === current.major && git.minor === current.minor) {
|
|
126
|
-
highestPatch = Math.max(highestPatch, git.patch);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
console.log(`Current version: ${currentVersion}`);
|
|
130
|
-
console.log(`NPM latest version: ${npmVersion ?? 'not found'}`);
|
|
131
|
-
console.log(`Git latest tag: ${gitVersion ? `v${gitVersion}` : 'not found'}`);
|
|
132
|
-
console.log(`Highest patch in ${current.major}.${current.minor}.x: ${highestPatch}`);
|
|
133
|
-
|
|
134
|
-
// Find next available version starting from the highest
|
|
135
|
-
return findNextAvailableVersion(packageName, current.major, current.minor, highestPatch);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Prepare release by incrementing version and generating changelog This script can be run locally to test the release
|
|
140
|
-
* process
|
|
141
|
-
*/
|
|
142
|
-
function prepareRelease(): void {
|
|
143
|
-
try {
|
|
144
|
-
// Read package.json
|
|
145
|
-
const packageJsonPath: string = path.join(process.cwd(), 'package.json');
|
|
146
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as PackageJson;
|
|
147
|
-
|
|
148
|
-
const currentVersion: string = packageJson.version;
|
|
149
|
-
const packageName: string = packageJson.name;
|
|
150
|
-
|
|
151
|
-
// Find next available version by checking both npm and git tags
|
|
152
|
-
const newVersion: string = determineNextVersion(packageName, currentVersion);
|
|
153
|
-
|
|
154
|
-
// Update version in package.json (without git tag)
|
|
155
|
-
packageJson.version = newVersion;
|
|
156
|
-
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
157
|
-
|
|
158
|
-
// Generate changelog since last tag or main branch
|
|
159
|
-
let commits: string;
|
|
160
|
-
let lastTag: string | null = null;
|
|
161
|
-
try {
|
|
162
|
-
lastTag = execSync('git describe --tags --abbrev=0 2>/dev/null', {
|
|
163
|
-
encoding: 'utf8',
|
|
164
|
-
}).trim();
|
|
165
|
-
|
|
166
|
-
commits = execSync(`git log --oneline --format="%s" ${lastTag}..HEAD`, {
|
|
167
|
-
encoding: 'utf8',
|
|
168
|
-
}).trim();
|
|
169
|
-
} catch {
|
|
170
|
-
// No previous tag, get commits ahead of main branch
|
|
171
|
-
|
|
172
|
-
commits = execSync('git log --oneline --format="%s" main..HEAD', {
|
|
173
|
-
encoding: 'utf8',
|
|
174
|
-
}).trim();
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (!commits) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Extract PR numbers and create changelog
|
|
182
|
-
const commitLines: string[] = commits.split('\n').map((commit: string): string => `- ${commit}`);
|
|
183
|
-
|
|
184
|
-
const changelog: string = commitLines.join('\n');
|
|
185
|
-
|
|
186
|
-
// Create detailed tag message
|
|
187
|
-
const _tagMessage = `Release v${newVersion}\n\nChanges:\n${changelog}`;
|
|
188
|
-
|
|
189
|
-
console.log('Release tag prepared:', _tagMessage);
|
|
190
|
-
|
|
191
|
-
// Save changelog to file for reference
|
|
192
|
-
const changelogPath: string = path.join(process.cwd(), 'CHANGELOG.md');
|
|
193
|
-
|
|
194
|
-
// Add previous version link if available
|
|
195
|
-
const previousVersionLink: string = lastTag
|
|
196
|
-
? `\n[Previous version: ${lastTag}](https://github.com/Fairmint/canton-node-sdk/releases/tag/${lastTag})`
|
|
197
|
-
: '';
|
|
198
|
-
|
|
199
|
-
const changelogContent = `# Changelog for v${newVersion}\n\n${changelog}${previousVersionLink}\n\n`;
|
|
200
|
-
|
|
201
|
-
// Prepend to existing changelog if it exists
|
|
202
|
-
if (fs.existsSync(changelogPath)) {
|
|
203
|
-
const existingChangelog: string = fs.readFileSync(changelogPath, 'utf8');
|
|
204
|
-
fs.writeFileSync(changelogPath, changelogContent + existingChangelog);
|
|
205
|
-
} else {
|
|
206
|
-
fs.writeFileSync(changelogPath, changelogContent);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
console.log('Changelog updated successfully');
|
|
210
|
-
console.log('Release preparation complete');
|
|
211
|
-
} catch (_error) {
|
|
212
|
-
console.error('Error preparing release:', _error);
|
|
213
|
-
process.exit(1);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Run the script
|
|
218
|
-
if (require.main === module) {
|
|
219
|
-
prepareRelease();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export { prepareRelease };
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
import 'dotenv/config';
|
|
3
|
-
import { CantonRuntime, EnvLoader, LedgerJsonApiClient, ValidatorApiClient } from '../src';
|
|
4
|
-
import type { RevokeUserRightsParams } from '../src/clients/ledger-json-api/schemas/operations/users';
|
|
5
|
-
import type { NetworkType } from '../src/core/types';
|
|
6
|
-
|
|
7
|
-
/** Rights type expected by grant/revoke APIs (with value wrapper) */
|
|
8
|
-
type RevokableRight = NonNullable<RevokeUserRightsParams['rights']>[number];
|
|
9
|
-
|
|
10
|
-
/** Create party-specific rights for revoke operation */
|
|
11
|
-
function createPartyRightsForRevoke(partyId: string): RevokableRight[] {
|
|
12
|
-
return [
|
|
13
|
-
{
|
|
14
|
-
kind: {
|
|
15
|
-
CanActAs: { value: { party: partyId } },
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Create admin rights for revoke operation */
|
|
22
|
-
function createAdminRightsForRevoke(): RevokableRight[] {
|
|
23
|
-
return [
|
|
24
|
-
{
|
|
25
|
-
kind: {
|
|
26
|
-
ParticipantAdmin: { value: {} },
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Create CanExecuteAsAnyParty rights for revoke operation */
|
|
33
|
-
function createExecuteAsAnyPartyRightsForRevoke(): RevokableRight[] {
|
|
34
|
-
return [
|
|
35
|
-
{
|
|
36
|
-
kind: {
|
|
37
|
-
CanExecuteAsAnyParty: { value: {} },
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Create CanReadAsAnyParty rights for revoke operation */
|
|
44
|
-
function createReadAsAnyPartyRightsForRevoke(): RevokableRight[] {
|
|
45
|
-
return [
|
|
46
|
-
{
|
|
47
|
-
kind: {
|
|
48
|
-
CanReadAsAnyParty: { value: {} },
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function main(): Promise<void> {
|
|
55
|
-
console.log('=== Revoke User Rights Utility ===\n');
|
|
56
|
-
|
|
57
|
-
// Parse command line arguments
|
|
58
|
-
const args = process.argv.slice(2);
|
|
59
|
-
|
|
60
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
61
|
-
console.log(`
|
|
62
|
-
Usage: tsx scripts/revoke-user-rights.ts [options]
|
|
63
|
-
|
|
64
|
-
Options:
|
|
65
|
-
--user-id <id> User ID to revoke rights from (defaults to authenticated user)
|
|
66
|
-
--party-id <id> Party ID for party-specific rights (optional)
|
|
67
|
-
--admin Revoke ParticipantAdmin rights
|
|
68
|
-
--execute-any-party Revoke CanExecuteAsAnyParty rights
|
|
69
|
-
--read-any-party Revoke CanReadAsAnyParty rights
|
|
70
|
-
--network <network> Target network (devnet|testnet|mainnet, defaults to CANTON_CURRENT_NETWORK)
|
|
71
|
-
--provider <provider> Target provider (defaults to CANTON_CURRENT_PROVIDER)
|
|
72
|
-
--help, -h Show this help message
|
|
73
|
-
|
|
74
|
-
Examples:
|
|
75
|
-
# Revoke admin rights from authenticated user (uses current network/provider from env)
|
|
76
|
-
npm run revoke-user-rights -- --admin
|
|
77
|
-
|
|
78
|
-
# Revoke CanExecuteAsAnyParty rights from authenticated user
|
|
79
|
-
npm run revoke-user-rights -- --execute-any-party
|
|
80
|
-
|
|
81
|
-
# Revoke CanReadAsAnyParty rights from authenticated user
|
|
82
|
-
npm run revoke-user-rights -- --read-any-party
|
|
83
|
-
|
|
84
|
-
# Revoke admin rights from specific user on devnet/intellect
|
|
85
|
-
npm run revoke-user-rights -- --user-id "5" --admin --network devnet --provider intellect
|
|
86
|
-
|
|
87
|
-
# Revoke party rights from authenticated user
|
|
88
|
-
npm run revoke-user-rights -- --party-id "alice::party1"
|
|
89
|
-
`);
|
|
90
|
-
process.exit(0);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Parse arguments
|
|
94
|
-
const userIdIndex = args.indexOf('--user-id');
|
|
95
|
-
const targetUserId = userIdIndex !== -1 ? args[userIdIndex + 1] : undefined;
|
|
96
|
-
|
|
97
|
-
const partyIdIndex = args.indexOf('--party-id');
|
|
98
|
-
const partyId = partyIdIndex !== -1 ? args[partyIdIndex + 1] : undefined;
|
|
99
|
-
|
|
100
|
-
const admin = args.includes('--admin');
|
|
101
|
-
const executeAnyParty = args.includes('--execute-any-party');
|
|
102
|
-
const readAnyParty = args.includes('--read-any-party');
|
|
103
|
-
|
|
104
|
-
const networkIndex = args.indexOf('--network');
|
|
105
|
-
const network = networkIndex !== -1 ? (args[networkIndex + 1] as NetworkType) : undefined;
|
|
106
|
-
|
|
107
|
-
const providerIndex = args.indexOf('--provider');
|
|
108
|
-
const provider = providerIndex !== -1 ? args[providerIndex + 1] : undefined;
|
|
109
|
-
|
|
110
|
-
// Determine which rights to revoke
|
|
111
|
-
let rights: RevokableRight[];
|
|
112
|
-
let rightsType: string;
|
|
113
|
-
|
|
114
|
-
if (partyId) {
|
|
115
|
-
rights = createPartyRightsForRevoke(partyId);
|
|
116
|
-
rightsType = 'Party Rights (CanActAs)';
|
|
117
|
-
} else if (executeAnyParty) {
|
|
118
|
-
rights = createExecuteAsAnyPartyRightsForRevoke();
|
|
119
|
-
rightsType = 'CanExecuteAsAnyParty';
|
|
120
|
-
} else if (readAnyParty) {
|
|
121
|
-
rights = createReadAsAnyPartyRightsForRevoke();
|
|
122
|
-
rightsType = 'CanReadAsAnyParty';
|
|
123
|
-
} else if (admin) {
|
|
124
|
-
rights = createAdminRightsForRevoke();
|
|
125
|
-
rightsType = 'ParticipantAdmin';
|
|
126
|
-
} else {
|
|
127
|
-
console.error(
|
|
128
|
-
'Error: You must specify which rights to revoke (--admin, --execute-any-party, --read-any-party, or --party-id)'
|
|
129
|
-
);
|
|
130
|
-
process.exit(1);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
console.log('Configuration:');
|
|
134
|
-
console.log(` Network: ${network ?? 'from CANTON_CURRENT_NETWORK'}`);
|
|
135
|
-
console.log(` Provider: ${provider ?? 'from CANTON_CURRENT_PROVIDER'}`);
|
|
136
|
-
if (targetUserId) {
|
|
137
|
-
console.log(` Target User ID: ${targetUserId}`);
|
|
138
|
-
} else {
|
|
139
|
-
console.log(` Target User ID: <will auto-detect from authenticated user>`);
|
|
140
|
-
}
|
|
141
|
-
if (partyId) {
|
|
142
|
-
console.log(` Party ID: ${partyId}`);
|
|
143
|
-
}
|
|
144
|
-
console.log(` Rights Type: ${rightsType}\n`);
|
|
145
|
-
|
|
146
|
-
try {
|
|
147
|
-
const configOptions = {
|
|
148
|
-
...(network !== undefined && { network }),
|
|
149
|
-
...(provider !== undefined && { provider }),
|
|
150
|
-
};
|
|
151
|
-
const runtime = new CantonRuntime(EnvLoader.getConfig('LEDGER_JSON_API', configOptions));
|
|
152
|
-
const client = new LedgerJsonApiClient(runtime);
|
|
153
|
-
const validatorClient = new ValidatorApiClient(runtime);
|
|
154
|
-
|
|
155
|
-
console.log(`Connected to Ledger JSON API`);
|
|
156
|
-
|
|
157
|
-
// If no target user ID provided, get the authenticated user
|
|
158
|
-
let resolvedUserId: string;
|
|
159
|
-
if (!targetUserId) {
|
|
160
|
-
console.log('Fetching authenticated user ID...');
|
|
161
|
-
const authenticatedUser = await validatorClient.getValidatorUserInfo();
|
|
162
|
-
resolvedUserId = authenticatedUser.user_name;
|
|
163
|
-
console.log(`Using authenticated user: ${resolvedUserId}`);
|
|
164
|
-
} else {
|
|
165
|
-
resolvedUserId = targetUserId;
|
|
166
|
-
console.log(`Target user: ${resolvedUserId}`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
console.log(`\nRights to revoke: ${JSON.stringify(rights, null, 2)}`);
|
|
170
|
-
|
|
171
|
-
// Check current rights
|
|
172
|
-
console.log('\nChecking current rights...');
|
|
173
|
-
try {
|
|
174
|
-
const currentRights = await client.listUserRights({
|
|
175
|
-
userId: resolvedUserId,
|
|
176
|
-
});
|
|
177
|
-
console.log(`Current rights count: ${currentRights.rights?.length ?? 0}`);
|
|
178
|
-
} catch (error) {
|
|
179
|
-
console.log(`Could not list current rights: ${error instanceof Error ? error.message : String(error)}`);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Revoke the rights
|
|
183
|
-
console.log('\nRevoking rights...');
|
|
184
|
-
const result = await client.revokeUserRights({
|
|
185
|
-
userId: resolvedUserId,
|
|
186
|
-
rights,
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
console.log(`\n✓ Successfully revoked ${result.newlyRevokedRights?.length ?? 0} rights`);
|
|
190
|
-
if (result.newlyRevokedRights && result.newlyRevokedRights.length > 0) {
|
|
191
|
-
console.log(`\nNewly revoked rights:`);
|
|
192
|
-
console.log(JSON.stringify(result.newlyRevokedRights, null, 2));
|
|
193
|
-
} else {
|
|
194
|
-
console.log('\n(No rights were revoked - they may not have existed)');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Verify by listing rights again
|
|
198
|
-
console.log('\nVerifying...');
|
|
199
|
-
const finalRights = await client.listUserRights({
|
|
200
|
-
userId: resolvedUserId,
|
|
201
|
-
});
|
|
202
|
-
console.log(`Final rights count: ${finalRights.rights?.length ?? 0}`);
|
|
203
|
-
|
|
204
|
-
console.log('\n✓ Done!');
|
|
205
|
-
} catch (error) {
|
|
206
|
-
console.error('\n✗ Failed to revoke rights:');
|
|
207
|
-
console.error(` ${error instanceof Error ? error.message : String(error)}`);
|
|
208
|
-
if (error instanceof Error && error.stack) {
|
|
209
|
-
console.error(`\nStack trace:`);
|
|
210
|
-
console.error(error.stack);
|
|
211
|
-
}
|
|
212
|
-
process.exit(1);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
main().catch((error) => {
|
|
217
|
-
console.error('Fatal error:', error);
|
|
218
|
-
process.exit(1);
|
|
219
|
-
});
|