@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,198 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
|
|
3
|
-
import * as fs from 'fs';
|
|
4
|
-
import { glob } from 'glob';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
|
|
7
|
-
interface OperationInfo {
|
|
8
|
-
name: string;
|
|
9
|
-
filePath: string;
|
|
10
|
-
testPath: string;
|
|
11
|
-
paramsSchema: string;
|
|
12
|
-
method: string;
|
|
13
|
-
endpoint: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function findOperations(): Promise<OperationInfo[]> {
|
|
17
|
-
const operations: OperationInfo[] = [];
|
|
18
|
-
|
|
19
|
-
// Find all operation files
|
|
20
|
-
const operationFiles = await glob('src/clients/**/*.ts', {
|
|
21
|
-
ignore: ['**/index.ts', '**/register.ts', '**/schemas/**', '**/*.generated.ts'],
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
for (const file of operationFiles) {
|
|
25
|
-
const content = fs.readFileSync(file, 'utf-8');
|
|
26
|
-
|
|
27
|
-
// Check if this is an operation file by looking for createApiOperation
|
|
28
|
-
if (content.includes('createApiOperation')) {
|
|
29
|
-
const nameMatch = content.match(/export const (\w+) = createApiOperation/);
|
|
30
|
-
if (nameMatch?.[1]) {
|
|
31
|
-
const name = nameMatch[1];
|
|
32
|
-
const methodMatch = content.match(/method:\s*['"`]([A-Z]+)['"`]/);
|
|
33
|
-
const endpointMatch = content.match(/endpoint\s*=\s*['"`]([^'"`]+)['"`]/);
|
|
34
|
-
const paramsSchemaMatch = content.match(/paramsSchema:\s*(\w+)/);
|
|
35
|
-
|
|
36
|
-
const method = methodMatch?.[1] ?? 'GET';
|
|
37
|
-
const endpoint = endpointMatch?.[1] ?? '/unknown';
|
|
38
|
-
const paramsSchema = paramsSchemaMatch?.[1] ?? 'z.any()';
|
|
39
|
-
|
|
40
|
-
// Generate test path
|
|
41
|
-
const relativePath = path.relative('src', file);
|
|
42
|
-
const testPath = `test/${relativePath.replace('.ts', '.test.ts')}`;
|
|
43
|
-
|
|
44
|
-
operations.push({
|
|
45
|
-
name,
|
|
46
|
-
filePath: file,
|
|
47
|
-
testPath,
|
|
48
|
-
paramsSchema,
|
|
49
|
-
method,
|
|
50
|
-
endpoint,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return operations;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function generateTestContent(operation: OperationInfo): string {
|
|
60
|
-
const importPath = path
|
|
61
|
-
.relative(path.dirname(operation.testPath), path.dirname(operation.filePath))
|
|
62
|
-
.replace(/\\/g, '/');
|
|
63
|
-
const mockClientPath = path.relative(path.dirname(operation.testPath), 'test/utils').replace(/\\/g, '/');
|
|
64
|
-
const configPath = path.relative(path.dirname(operation.testPath), 'test/config').replace(/\\/g, '/');
|
|
65
|
-
|
|
66
|
-
const isValidatorApi = operation.filePath.includes('validator-api');
|
|
67
|
-
|
|
68
|
-
let mockClientClass = 'MockLedgerJsonApiClient';
|
|
69
|
-
let apiUrlKey = 'LEDGER_JSON_API';
|
|
70
|
-
|
|
71
|
-
if (isValidatorApi) {
|
|
72
|
-
mockClientClass = 'MockValidatorApiClient';
|
|
73
|
-
apiUrlKey = 'VALIDATOR_API';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return `import { ${mockClientClass} } from '${mockClientPath}';
|
|
77
|
-
import { ${operation.name} } from '${importPath}/${operation.name}';
|
|
78
|
-
import { mockClientConfig, mockApiUrls } from '${configPath}/testConfig';
|
|
79
|
-
|
|
80
|
-
describe('${operation.name} Operation', () => {
|
|
81
|
-
let mockClient: ${mockClientClass};
|
|
82
|
-
let operation: InstanceType<typeof ${operation.name}>;
|
|
83
|
-
|
|
84
|
-
beforeEach(() => {
|
|
85
|
-
mockClient = new ${mockClientClass}(mockClientConfig);
|
|
86
|
-
operation = new ${operation.name}(mockClient);
|
|
87
|
-
mockClient.clearMocks();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe('Network Activity Validation', () => {
|
|
91
|
-
it('should make a ${operation.method} request to the correct endpoint', async () => {
|
|
92
|
-
// Arrange
|
|
93
|
-
const params = ${operation.paramsSchema === 'z.any()' ? '{}' : '{}'};
|
|
94
|
-
const mockResponse = {};
|
|
95
|
-
const expectedUrl = \`\${mockApiUrls.${apiUrlKey}}${operation.endpoint}\`;
|
|
96
|
-
|
|
97
|
-
mockClient.setMockResponse(expectedUrl, mockResponse);
|
|
98
|
-
|
|
99
|
-
// Act
|
|
100
|
-
const result = await operation.execute(params);
|
|
101
|
-
|
|
102
|
-
// Assert
|
|
103
|
-
expect(result).toEqual(mockResponse);
|
|
104
|
-
|
|
105
|
-
const requests = mockClient.getRequests();
|
|
106
|
-
expect(requests).toHaveLength(1);
|
|
107
|
-
|
|
108
|
-
const request = requests[0];
|
|
109
|
-
expect(request).toBeDefined();
|
|
110
|
-
expect(request!.method).toBe('${operation.method}');
|
|
111
|
-
expect(request!.url).toBe(expectedUrl);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('should include proper headers in the request', async () => {
|
|
115
|
-
// Arrange
|
|
116
|
-
const params = ${operation.paramsSchema === 'z.any()' ? '{}' : '{}'};
|
|
117
|
-
const mockResponse = {};
|
|
118
|
-
const expectedUrl = \`\${mockApiUrls.${apiUrlKey}}${operation.endpoint}\`;
|
|
119
|
-
|
|
120
|
-
mockClient.setMockResponse(expectedUrl, mockResponse);
|
|
121
|
-
|
|
122
|
-
// Act
|
|
123
|
-
await operation.execute(params);
|
|
124
|
-
|
|
125
|
-
// Assert
|
|
126
|
-
const request = mockClient.getLastRequest();
|
|
127
|
-
expect(request).toBeDefined();
|
|
128
|
-
expect(request?.headers).toBeDefined();
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe('Error Handling', () => {
|
|
133
|
-
it('should propagate network errors', async () => {
|
|
134
|
-
// Arrange
|
|
135
|
-
const params = ${operation.paramsSchema === 'z.any()' ? '{}' : '{}'};
|
|
136
|
-
const expectedUrl = \`\${mockApiUrls.${apiUrlKey}}${operation.endpoint}\`;
|
|
137
|
-
const networkError = new Error('Network error');
|
|
138
|
-
|
|
139
|
-
mockClient.setMockError(expectedUrl, networkError);
|
|
140
|
-
|
|
141
|
-
// Act & Assert
|
|
142
|
-
await expect(operation.execute(params)).rejects.toThrow('Network error');
|
|
143
|
-
|
|
144
|
-
const requests = mockClient.getRequests();
|
|
145
|
-
expect(requests).toHaveLength(1);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
describe('Parameter Validation', () => {
|
|
150
|
-
it('should accept valid parameters', async () => {
|
|
151
|
-
// Arrange
|
|
152
|
-
const params = ${operation.paramsSchema === 'z.any()' ? '{}' : '{}'};
|
|
153
|
-
const mockResponse = {};
|
|
154
|
-
const expectedUrl = \`\${mockApiUrls.${apiUrlKey}}${operation.endpoint}\`;
|
|
155
|
-
|
|
156
|
-
mockClient.setMockResponse(expectedUrl, mockResponse);
|
|
157
|
-
|
|
158
|
-
// Act & Assert
|
|
159
|
-
await expect(operation.execute(params)).resolves.toEqual(mockResponse);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
`;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async function generateTests(): Promise<void> {
|
|
167
|
-
console.log('Finding operations...');
|
|
168
|
-
const operations = await findOperations();
|
|
169
|
-
|
|
170
|
-
console.log(`Found ${operations.length} operations`);
|
|
171
|
-
|
|
172
|
-
for (const operation of operations) {
|
|
173
|
-
// Create test directory if it doesn't exist
|
|
174
|
-
const testDir = path.dirname(operation.testPath);
|
|
175
|
-
if (!fs.existsSync(testDir)) {
|
|
176
|
-
fs.mkdirSync(testDir, { recursive: true });
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Check if test already exists
|
|
180
|
-
if (fs.existsSync(operation.testPath)) {
|
|
181
|
-
console.log(`Test already exists: ${operation.testPath}`);
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const testContent = generateTestContent(operation);
|
|
186
|
-
fs.writeFileSync(operation.testPath, testContent);
|
|
187
|
-
console.log(`Generated test: ${operation.testPath}`);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
console.log('Test generation complete');
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (require.main === module) {
|
|
194
|
-
generateTests().catch((error) => {
|
|
195
|
-
console.error('Error generating tests:', error);
|
|
196
|
-
process.exit(1);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
import 'dotenv/config';
|
|
3
|
-
import { CantonRuntime, EnvLoader, LedgerJsonApiClient, ValidatorApiClient } from '../src';
|
|
4
|
-
import type { GrantUserRightsParams } 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 GrantableRight = NonNullable<GrantUserRightsParams['rights']>[number];
|
|
9
|
-
|
|
10
|
-
/** Create default admin rights for a user */
|
|
11
|
-
function createAdminRights(): GrantableRight[] {
|
|
12
|
-
return [
|
|
13
|
-
{
|
|
14
|
-
kind: {
|
|
15
|
-
ParticipantAdmin: { value: {} },
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Create CanExecuteAsAnyParty rights for a user */
|
|
22
|
-
function createExecuteAsAnyPartyRights(): GrantableRight[] {
|
|
23
|
-
return [
|
|
24
|
-
{
|
|
25
|
-
kind: {
|
|
26
|
-
CanExecuteAsAnyParty: { value: {} },
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Create CanReadAsAnyParty rights for a user */
|
|
33
|
-
function createReadAsAnyPartyRights(): GrantableRight[] {
|
|
34
|
-
return [
|
|
35
|
-
{
|
|
36
|
-
kind: {
|
|
37
|
-
CanReadAsAnyParty: { value: {} },
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Create party-specific rights for a user */
|
|
44
|
-
function createPartyRights(partyId: string): GrantableRight[] {
|
|
45
|
-
return [
|
|
46
|
-
{
|
|
47
|
-
kind: {
|
|
48
|
-
CanActAs: { value: { party: partyId } },
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function main(): Promise<void> {
|
|
55
|
-
console.log('=== Grant 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/grant-user-rights.ts [options]
|
|
63
|
-
|
|
64
|
-
Options:
|
|
65
|
-
--user-id <id> User ID to grant rights to (defaults to authenticated user)
|
|
66
|
-
--party-id <id> Party ID for party-specific rights (optional)
|
|
67
|
-
--admin Grant ParticipantAdmin rights (default if no other right specified)
|
|
68
|
-
--execute-any-party Grant CanExecuteAsAnyParty rights
|
|
69
|
-
--read-any-party Grant 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
|
-
# Grant admin rights to authenticated user (uses current network/provider from env)
|
|
76
|
-
npm run grant-user-rights -- --admin
|
|
77
|
-
|
|
78
|
-
# Grant CanExecuteAsAnyParty rights to authenticated user
|
|
79
|
-
npm run grant-user-rights -- --execute-any-party
|
|
80
|
-
|
|
81
|
-
# Grant CanReadAsAnyParty rights to authenticated user
|
|
82
|
-
npm run grant-user-rights -- --read-any-party
|
|
83
|
-
|
|
84
|
-
# Grant admin rights to specific user on devnet/intellect
|
|
85
|
-
npm run grant-user-rights -- --user-id "5" --admin --network devnet --provider intellect
|
|
86
|
-
|
|
87
|
-
# Grant party rights to authenticated user
|
|
88
|
-
npm run grant-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 executeAnyParty = args.includes('--execute-any-party');
|
|
101
|
-
const readAnyParty = args.includes('--read-any-party');
|
|
102
|
-
|
|
103
|
-
const networkIndex = args.indexOf('--network');
|
|
104
|
-
const network = networkIndex !== -1 ? (args[networkIndex + 1] as NetworkType) : undefined;
|
|
105
|
-
|
|
106
|
-
const providerIndex = args.indexOf('--provider');
|
|
107
|
-
const provider = providerIndex !== -1 ? args[providerIndex + 1] : undefined;
|
|
108
|
-
|
|
109
|
-
// Determine which rights to grant
|
|
110
|
-
let rights: GrantableRight[];
|
|
111
|
-
let rightsType: string;
|
|
112
|
-
|
|
113
|
-
if (partyId) {
|
|
114
|
-
rights = createPartyRights(partyId);
|
|
115
|
-
rightsType = 'Party Rights (CanActAs)';
|
|
116
|
-
} else if (executeAnyParty) {
|
|
117
|
-
rights = createExecuteAsAnyPartyRights();
|
|
118
|
-
rightsType = 'CanExecuteAsAnyParty';
|
|
119
|
-
} else if (readAnyParty) {
|
|
120
|
-
rights = createReadAsAnyPartyRights();
|
|
121
|
-
rightsType = 'CanReadAsAnyParty';
|
|
122
|
-
} else {
|
|
123
|
-
rights = createAdminRights();
|
|
124
|
-
rightsType = 'ParticipantAdmin';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
console.log('Configuration:');
|
|
128
|
-
console.log(` Network: ${network ?? 'from CANTON_CURRENT_NETWORK'}`);
|
|
129
|
-
console.log(` Provider: ${provider ?? 'from CANTON_CURRENT_PROVIDER'}`);
|
|
130
|
-
if (targetUserId) {
|
|
131
|
-
console.log(` Target User ID: ${targetUserId}`);
|
|
132
|
-
} else {
|
|
133
|
-
console.log(` Target User ID: <will auto-detect from authenticated user>`);
|
|
134
|
-
}
|
|
135
|
-
if (partyId) {
|
|
136
|
-
console.log(` Party ID: ${partyId}`);
|
|
137
|
-
}
|
|
138
|
-
console.log(` Rights Type: ${rightsType}\n`);
|
|
139
|
-
|
|
140
|
-
try {
|
|
141
|
-
const configOptions = {
|
|
142
|
-
...(network !== undefined && { network }),
|
|
143
|
-
...(provider !== undefined && { provider }),
|
|
144
|
-
};
|
|
145
|
-
const runtime = new CantonRuntime(EnvLoader.getConfig('LEDGER_JSON_API', configOptions));
|
|
146
|
-
const client = new LedgerJsonApiClient(runtime);
|
|
147
|
-
const validatorClient = new ValidatorApiClient(runtime);
|
|
148
|
-
|
|
149
|
-
console.log(`Connected to Ledger JSON API`);
|
|
150
|
-
|
|
151
|
-
// If no target user ID provided, get the authenticated user
|
|
152
|
-
let resolvedUserId: string;
|
|
153
|
-
if (!targetUserId) {
|
|
154
|
-
console.log('Fetching authenticated user ID...');
|
|
155
|
-
const authenticatedUser = await validatorClient.getValidatorUserInfo();
|
|
156
|
-
resolvedUserId = authenticatedUser.user_name;
|
|
157
|
-
console.log(`Using authenticated user: ${resolvedUserId}`);
|
|
158
|
-
} else {
|
|
159
|
-
resolvedUserId = targetUserId;
|
|
160
|
-
console.log(`Target user: ${resolvedUserId}`);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
console.log(`\nRights to grant: ${JSON.stringify(rights, null, 2)}`);
|
|
164
|
-
|
|
165
|
-
// Check current rights
|
|
166
|
-
console.log('\nChecking current rights...');
|
|
167
|
-
try {
|
|
168
|
-
const currentRights = await client.listUserRights({
|
|
169
|
-
userId: resolvedUserId,
|
|
170
|
-
});
|
|
171
|
-
console.log(`Current rights count: ${currentRights.rights?.length ?? 0}`);
|
|
172
|
-
} catch (error) {
|
|
173
|
-
console.log(`Could not list current rights: ${error instanceof Error ? error.message : String(error)}`);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Grant the rights
|
|
177
|
-
console.log('\nGranting rights...');
|
|
178
|
-
const result = await client.grantUserRights({
|
|
179
|
-
userId: resolvedUserId,
|
|
180
|
-
rights,
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
console.log(`\n✓ Successfully granted ${result.newlyGrantedRights?.length ?? 0} new rights`);
|
|
184
|
-
if (result.newlyGrantedRights && result.newlyGrantedRights.length > 0) {
|
|
185
|
-
console.log(`\nNewly granted rights:`);
|
|
186
|
-
console.log(JSON.stringify(result.newlyGrantedRights, null, 2));
|
|
187
|
-
} else {
|
|
188
|
-
console.log('\n(Rights may have already existed)');
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Verify by listing rights again
|
|
192
|
-
console.log('\nVerifying...');
|
|
193
|
-
const finalRights = await client.listUserRights({
|
|
194
|
-
userId: resolvedUserId,
|
|
195
|
-
});
|
|
196
|
-
console.log(`Final rights count: ${finalRights.rights?.length ?? 0}`);
|
|
197
|
-
|
|
198
|
-
console.log('\n✓ Done!');
|
|
199
|
-
} catch (error) {
|
|
200
|
-
console.error('\n✗ Failed to grant rights:');
|
|
201
|
-
console.error(` ${error instanceof Error ? error.message : String(error)}`);
|
|
202
|
-
if (error instanceof Error && error.stack) {
|
|
203
|
-
console.error(`\nStack trace:`);
|
|
204
|
-
console.error(error.stack);
|
|
205
|
-
}
|
|
206
|
-
process.exit(1);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
main().catch((error) => {
|
|
211
|
-
console.error('Fatal error:', error);
|
|
212
|
-
process.exit(1);
|
|
213
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
import 'dotenv/config';
|
|
3
|
-
import { CantonRuntime, EnvLoader, LedgerJsonApiClient } from '../src';
|
|
4
|
-
|
|
5
|
-
/** List all configured identity providers in the Canton system */
|
|
6
|
-
async function main(): Promise<void> {
|
|
7
|
-
console.log('=== List Identity Providers ===\n');
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
const client = new LedgerJsonApiClient(new CantonRuntime(EnvLoader.getConfig('LEDGER_JSON_API')));
|
|
11
|
-
|
|
12
|
-
console.log('Fetching identity provider configs...\n');
|
|
13
|
-
const result = await client.listIdentityProviderConfigs({});
|
|
14
|
-
|
|
15
|
-
if (result.identityProviderConfigs.length === 0) {
|
|
16
|
-
console.log('No identity providers configured.');
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
console.log(`Found ${result.identityProviderConfigs.length} identity provider(s):\n`);
|
|
21
|
-
|
|
22
|
-
result.identityProviderConfigs.forEach((config, index) => {
|
|
23
|
-
console.log(`${index + 1}. Identity Provider ID: "${config.identityProviderId}"`);
|
|
24
|
-
console.log(` Issuer: ${config.issuer}`);
|
|
25
|
-
console.log(` JWKS URL: ${config.jwksUrl}`);
|
|
26
|
-
console.log(` Audience: ${config.audience ?? 'N/A'}`);
|
|
27
|
-
console.log(` Is Deactivated: ${config.isDeactivated}`);
|
|
28
|
-
console.log('');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
console.log('✓ Done!');
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error('\n✗ Failed to list identity providers:');
|
|
34
|
-
console.error(` ${error instanceof Error ? error.message : String(error)}`);
|
|
35
|
-
if (error instanceof Error && error.stack) {
|
|
36
|
-
console.error(`\nStack trace:`);
|
|
37
|
-
console.error(error.stack);
|
|
38
|
-
}
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
main().catch((error) => {
|
|
44
|
-
console.error('Fatal error:', error);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
});
|