@profullstack/coinpay 0.6.1 → 0.6.3
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/bin/coinpay.js +96 -0
- package/package.json +1 -1
- package/src/reputation.d.ts +17 -0
- package/src/reputation.js +53 -0
package/bin/coinpay.js
CHANGED
|
@@ -227,6 +227,10 @@ ${colors.cyan}Commands:${colors.reset}
|
|
|
227
227
|
badge [did] Get embeddable reputation badge URL
|
|
228
228
|
verify <id> Verify a credential
|
|
229
229
|
revocations List revoked credentials
|
|
230
|
+
issuer register Register platform issuer (--name, --domain)
|
|
231
|
+
issuer list List your platform issuers
|
|
232
|
+
issuer rotate Rotate issuer API key (--id)
|
|
233
|
+
issuer deactivate Deactivate an issuer (--id)
|
|
230
234
|
|
|
231
235
|
${colors.bright}webhook${colors.reset}
|
|
232
236
|
logs <business-id> Get webhook logs
|
|
@@ -1863,6 +1867,98 @@ async function handleReputation(subcommand, args, flags) {
|
|
|
1863
1867
|
break;
|
|
1864
1868
|
}
|
|
1865
1869
|
|
|
1870
|
+
case 'issuer': {
|
|
1871
|
+
const issuerSubcommand = args[0];
|
|
1872
|
+
const client = createClient();
|
|
1873
|
+
|
|
1874
|
+
switch (issuerSubcommand) {
|
|
1875
|
+
case 'register': {
|
|
1876
|
+
const name = flags.name;
|
|
1877
|
+
const domain = flags.domain;
|
|
1878
|
+
if (!name || !domain) {
|
|
1879
|
+
print.error('Required: --name <name> --domain <domain>');
|
|
1880
|
+
return;
|
|
1881
|
+
}
|
|
1882
|
+
const { registerPlatformIssuer } = await import('../src/reputation.js');
|
|
1883
|
+
const result = await registerPlatformIssuer(client, { name, domain, did: flags.did });
|
|
1884
|
+
|
|
1885
|
+
if (result.success) {
|
|
1886
|
+
print.success(`Issuer registered: ${result.issuer.name}`);
|
|
1887
|
+
print.info(` ID: ${result.issuer.id}`);
|
|
1888
|
+
print.info(` DID: ${result.issuer.did}`);
|
|
1889
|
+
print.info(` Domain: ${result.issuer.domain}`);
|
|
1890
|
+
console.log(`\n ${colors.bright}${colors.yellow}⚠️ API Key (shown only once):${colors.reset}`);
|
|
1891
|
+
console.log(` ${colors.yellow}${result.api_key}${colors.reset}\n`);
|
|
1892
|
+
} else {
|
|
1893
|
+
print.error(result.error || 'Registration failed');
|
|
1894
|
+
}
|
|
1895
|
+
if (flags.json) print.json(result);
|
|
1896
|
+
break;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
case 'list': {
|
|
1900
|
+
const { listPlatformIssuers } = await import('../src/reputation.js');
|
|
1901
|
+
const result = await listPlatformIssuers(client);
|
|
1902
|
+
|
|
1903
|
+
if (result.success) {
|
|
1904
|
+
print.info(`Platform issuers (${result.issuers.length}):`);
|
|
1905
|
+
for (const iss of result.issuers) {
|
|
1906
|
+
const status = iss.active ? `${colors.green}active${colors.reset}` : `${colors.red}inactive${colors.reset}`;
|
|
1907
|
+
console.log(` ${iss.id} | ${iss.name} | ${iss.domain} | ${status} | key: ${iss.api_key || 'none'}`);
|
|
1908
|
+
}
|
|
1909
|
+
} else {
|
|
1910
|
+
print.error(result.error || 'Failed to list issuers');
|
|
1911
|
+
}
|
|
1912
|
+
if (flags.json) print.json(result);
|
|
1913
|
+
break;
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
case 'rotate': {
|
|
1917
|
+
const id = flags.id || args[1];
|
|
1918
|
+
if (!id) {
|
|
1919
|
+
print.error('Required: --id <issuer-id>');
|
|
1920
|
+
return;
|
|
1921
|
+
}
|
|
1922
|
+
const { rotatePlatformApiKey } = await import('../src/reputation.js');
|
|
1923
|
+
const result = await rotatePlatformApiKey(client, id);
|
|
1924
|
+
|
|
1925
|
+
if (result.success) {
|
|
1926
|
+
print.success(`API key rotated for: ${result.issuer.name}`);
|
|
1927
|
+
console.log(`\n ${colors.bright}${colors.yellow}⚠️ New API Key (shown only once):${colors.reset}`);
|
|
1928
|
+
console.log(` ${colors.yellow}${result.api_key}${colors.reset}\n`);
|
|
1929
|
+
} else {
|
|
1930
|
+
print.error(result.error || 'Rotation failed');
|
|
1931
|
+
}
|
|
1932
|
+
if (flags.json) print.json(result);
|
|
1933
|
+
break;
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
case 'deactivate': {
|
|
1937
|
+
const id = flags.id || args[1];
|
|
1938
|
+
if (!id) {
|
|
1939
|
+
print.error('Required: --id <issuer-id>');
|
|
1940
|
+
return;
|
|
1941
|
+
}
|
|
1942
|
+
const { deactivatePlatformIssuer } = await import('../src/reputation.js');
|
|
1943
|
+
const result = await deactivatePlatformIssuer(client, id);
|
|
1944
|
+
|
|
1945
|
+
if (result.success) {
|
|
1946
|
+
print.success(`Issuer deactivated: ${result.issuer.name}`);
|
|
1947
|
+
} else {
|
|
1948
|
+
print.error(result.error || 'Deactivation failed');
|
|
1949
|
+
}
|
|
1950
|
+
if (flags.json) print.json(result);
|
|
1951
|
+
break;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
default:
|
|
1955
|
+
print.error(`Unknown issuer command: ${issuerSubcommand}`);
|
|
1956
|
+
print.info('Available: register, list, rotate, deactivate');
|
|
1957
|
+
process.exit(1);
|
|
1958
|
+
}
|
|
1959
|
+
break;
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1866
1962
|
case 'badge': {
|
|
1867
1963
|
const did = args[0];
|
|
1868
1964
|
if (!did) {
|
package/package.json
CHANGED
package/src/reputation.d.ts
CHANGED
|
@@ -113,3 +113,20 @@ export interface DidInfo {
|
|
|
113
113
|
export function getMyDid(client: CoinPayClient): Promise<DidInfo>;
|
|
114
114
|
export function claimDid(client: CoinPayClient): Promise<DidInfo>;
|
|
115
115
|
export function linkDid(client: CoinPayClient, params: { did: string; publicKey: string; signature: string }): Promise<DidInfo>;
|
|
116
|
+
|
|
117
|
+
// Platform Issuer Self-Service
|
|
118
|
+
|
|
119
|
+
export interface PlatformIssuer {
|
|
120
|
+
id: string;
|
|
121
|
+
did: string;
|
|
122
|
+
name: string;
|
|
123
|
+
domain: string;
|
|
124
|
+
active: boolean;
|
|
125
|
+
api_key: string | null;
|
|
126
|
+
created_at: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function registerPlatformIssuer(client: CoinPayClient, params: { name: string; domain: string; did?: string }): Promise<{ success: boolean; issuer: PlatformIssuer; api_key: string }>;
|
|
130
|
+
export function listPlatformIssuers(client: CoinPayClient): Promise<{ success: boolean; issuers: PlatformIssuer[] }>;
|
|
131
|
+
export function rotatePlatformApiKey(client: CoinPayClient, issuerId: string): Promise<{ success: boolean; issuer: PlatformIssuer; api_key: string }>;
|
|
132
|
+
export function deactivatePlatformIssuer(client: CoinPayClient, issuerId: string): Promise<{ success: boolean; issuer: PlatformIssuer }>;
|
package/src/reputation.js
CHANGED
|
@@ -180,3 +180,56 @@ export async function getTrustProfile(client, agentDid) {
|
|
|
180
180
|
export function getBadgeUrl(baseUrl, did) {
|
|
181
181
|
return `${baseUrl}/api/reputation/badge/${encodeURIComponent(did)}`;
|
|
182
182
|
}
|
|
183
|
+
|
|
184
|
+
// ═══════════════════════════════════════════════════════════
|
|
185
|
+
// Platform Issuer Self-Service
|
|
186
|
+
// ═══════════════════════════════════════════════════════════
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Register a new platform issuer
|
|
190
|
+
* @param {import('./client.js').CoinPayClient} client
|
|
191
|
+
* @param {Object} params
|
|
192
|
+
* @param {string} params.name - Issuer name (alphanumeric, dots, hyphens, underscores)
|
|
193
|
+
* @param {string} params.domain - Issuer domain
|
|
194
|
+
* @param {string} [params.did] - Optional DID (auto-generated from domain if omitted)
|
|
195
|
+
* @returns {Promise<Object>} { success, issuer, api_key }
|
|
196
|
+
*/
|
|
197
|
+
export async function registerPlatformIssuer(client, { name, domain, did }) {
|
|
198
|
+
return client.request('/reputation/issuers', {
|
|
199
|
+
method: 'POST',
|
|
200
|
+
body: JSON.stringify({ name, domain, did }),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* List merchant's registered platform issuers (keys masked)
|
|
206
|
+
* @param {import('./client.js').CoinPayClient} client
|
|
207
|
+
* @returns {Promise<Object>} { success, issuers }
|
|
208
|
+
*/
|
|
209
|
+
export async function listPlatformIssuers(client) {
|
|
210
|
+
return client.request('/reputation/issuers');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Rotate a platform issuer's API key
|
|
215
|
+
* @param {import('./client.js').CoinPayClient} client
|
|
216
|
+
* @param {string} issuerId - The issuer ID
|
|
217
|
+
* @returns {Promise<Object>} { success, issuer, api_key }
|
|
218
|
+
*/
|
|
219
|
+
export async function rotatePlatformApiKey(client, issuerId) {
|
|
220
|
+
return client.request(`/reputation/issuers/${issuerId}/rotate`, {
|
|
221
|
+
method: 'POST',
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Deactivate a platform issuer (soft delete)
|
|
227
|
+
* @param {import('./client.js').CoinPayClient} client
|
|
228
|
+
* @param {string} issuerId - The issuer ID
|
|
229
|
+
* @returns {Promise<Object>} { success, issuer }
|
|
230
|
+
*/
|
|
231
|
+
export async function deactivatePlatformIssuer(client, issuerId) {
|
|
232
|
+
return client.request(`/reputation/issuers/${issuerId}`, {
|
|
233
|
+
method: 'DELETE',
|
|
234
|
+
});
|
|
235
|
+
}
|