@certen.io/sdk 0.2.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/CHANGELOG.md +65 -0
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/dist/client.d.ts +79 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +179 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +35 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +61 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +10 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +16 -0
- package/dist/internal.js.map +1 -0
- package/dist/resources/admin.d.ts +34 -0
- package/dist/resources/admin.d.ts.map +1 -0
- package/dist/resources/admin.js +64 -0
- package/dist/resources/admin.js.map +1 -0
- package/dist/resources/execute.d.ts +117 -0
- package/dist/resources/execute.d.ts.map +1 -0
- package/dist/resources/execute.js +158 -0
- package/dist/resources/execute.js.map +1 -0
- package/dist/resources/governance.d.ts +16 -0
- package/dist/resources/governance.d.ts.map +1 -0
- package/dist/resources/governance.js +35 -0
- package/dist/resources/governance.js.map +1 -0
- package/dist/resources/identity.d.ts +32 -0
- package/dist/resources/identity.d.ts.map +1 -0
- package/dist/resources/identity.js +59 -0
- package/dist/resources/identity.js.map +1 -0
- package/dist/resources/pending.d.ts +8 -0
- package/dist/resources/pending.d.ts.map +1 -0
- package/dist/resources/pending.js +19 -0
- package/dist/resources/pending.js.map +1 -0
- package/dist/resources/portfolio.d.ts +8 -0
- package/dist/resources/portfolio.d.ts.map +1 -0
- package/dist/resources/portfolio.js +13 -0
- package/dist/resources/portfolio.js.map +1 -0
- package/dist/resources/sign.d.ts +9 -0
- package/dist/resources/sign.d.ts.map +1 -0
- package/dist/resources/sign.js +26 -0
- package/dist/resources/sign.js.map +1 -0
- package/dist/resources/transaction.d.ts +22 -0
- package/dist/resources/transaction.d.ts.map +1 -0
- package/dist/resources/transaction.js +51 -0
- package/dist/resources/transaction.js.map +1 -0
- package/dist/types.d.ts +327 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import type { CreateOrgParams, OrgResponse, CreateApiKeyParams, ApiKeyResponse, ApiKeyListItem, AuditLogResponse, UsageSummaryResponse } from '../types.js';
|
|
3
|
+
export declare class AdminResource {
|
|
4
|
+
private http;
|
|
5
|
+
constructor(http: AxiosInstance);
|
|
6
|
+
createOrg(params: CreateOrgParams): Promise<OrgResponse>;
|
|
7
|
+
createApiKey(params: CreateApiKeyParams): Promise<ApiKeyResponse>;
|
|
8
|
+
listApiKeys(): Promise<{
|
|
9
|
+
apiKeys: ApiKeyListItem[];
|
|
10
|
+
}>;
|
|
11
|
+
revokeApiKey(id: string): Promise<{
|
|
12
|
+
success: boolean;
|
|
13
|
+
message: string;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Rotate an api key: the gateway provisions a fresh key with the same
|
|
17
|
+
* permissions and revokes the old one. The new plaintext key is returned
|
|
18
|
+
* ONCE — clients must persist it now.
|
|
19
|
+
*/
|
|
20
|
+
rotateApiKey(id: string): Promise<ApiKeyResponse>;
|
|
21
|
+
getAuditLog(params?: {
|
|
22
|
+
resourceType?: string;
|
|
23
|
+
action?: string;
|
|
24
|
+
from?: string;
|
|
25
|
+
to?: string;
|
|
26
|
+
limit?: number;
|
|
27
|
+
offset?: number;
|
|
28
|
+
}): Promise<AuditLogResponse>;
|
|
29
|
+
getUsage(params?: {
|
|
30
|
+
from?: string;
|
|
31
|
+
to?: string;
|
|
32
|
+
}): Promise<UsageSummaryResponse>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=admin.d.ts.map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0,0 +1,64 @@
|
|
|
1
|
+
export class AdminResource {
|
|
2
|
+
http;
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
}
|
|
6
|
+
async createOrg(params) {
|
|
7
|
+
const { data } = await this.http.post('/v1/admin/org', {
|
|
8
|
+
name: params.name,
|
|
9
|
+
plan: params.plan,
|
|
10
|
+
webhook_url: params.webhookUrl,
|
|
11
|
+
});
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
async createApiKey(params) {
|
|
15
|
+
const { data } = await this.http.post('/v1/admin/api-keys', {
|
|
16
|
+
name: params.name,
|
|
17
|
+
org_id: params.orgId,
|
|
18
|
+
permissions: params.permissions,
|
|
19
|
+
rate_limit_rpm: params.rateLimitRpm,
|
|
20
|
+
expires_at: params.expiresAt,
|
|
21
|
+
});
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
async listApiKeys() {
|
|
25
|
+
const { data } = await this.http.get('/v1/admin/api-keys');
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
async revokeApiKey(id) {
|
|
29
|
+
const { data } = await this.http.delete(`/v1/admin/api-keys/${id}`);
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Rotate an api key: the gateway provisions a fresh key with the same
|
|
34
|
+
* permissions and revokes the old one. The new plaintext key is returned
|
|
35
|
+
* ONCE — clients must persist it now.
|
|
36
|
+
*/
|
|
37
|
+
async rotateApiKey(id) {
|
|
38
|
+
const { data } = await this.http.post(`/v1/admin/api-keys/${id}/rotate`);
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
async getAuditLog(params) {
|
|
42
|
+
const { data } = await this.http.get('/v1/admin/audit-log', {
|
|
43
|
+
params: {
|
|
44
|
+
resource_type: params?.resourceType,
|
|
45
|
+
action: params?.action,
|
|
46
|
+
from: params?.from,
|
|
47
|
+
to: params?.to,
|
|
48
|
+
limit: params?.limit,
|
|
49
|
+
offset: params?.offset,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
async getUsage(params) {
|
|
55
|
+
const { data } = await this.http.get('/v1/admin/usage', {
|
|
56
|
+
params: {
|
|
57
|
+
from: params?.from,
|
|
58
|
+
to: params?.to,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=admin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/resources/admin.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,KAAK,CAAC,SAAS,CAAC,MAAuB;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACrD,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,WAAW,EAAE,MAAM,CAAC,UAAU;SAC/B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAA0B;QAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC1D,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM,EAAE,MAAM,CAAC,KAAK;YACpB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,cAAc,EAAE,MAAM,CAAC,YAAY;YACnC,UAAU,EAAE,MAAM,CAAC,SAAS;SAC7B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAA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+
import type { ContractCall, TransactionResponse } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The proof-gated execution flow, as one call instead of four.
|
|
5
|
+
*
|
|
6
|
+
* The raw resources mirror the API: open an intent, sign what comes back, post the signature, poll, fetch
|
|
7
|
+
* the proof. Every integration writes that same sequence, and every integration gets the same details
|
|
8
|
+
* wrong — signing the ASCII of the hex instead of its bytes, dropping the idempotency key on a retry,
|
|
9
|
+
* treating a `202` as completion, giving up during a proof cycle that legitimately takes two minutes.
|
|
10
|
+
*
|
|
11
|
+
* This existed twice already: once in the CARP escrow adapter and once in the example scripts, both
|
|
12
|
+
* hand-rolled. Neither is escrow-shaped — it is just how you use the gateway — so it belongs here.
|
|
13
|
+
*
|
|
14
|
+
* YOUR KEY NEVER REACHES THIS CODE. You pass a `sign` function; the SDK hands it bytes and takes back a
|
|
15
|
+
* signature. It cannot act without you.
|
|
16
|
+
*/
|
|
17
|
+
export interface SignFn {
|
|
18
|
+
/** Sign the RAW BYTES of this hex string (do not hash it again, do not sign the ASCII). Return 128 hex. */
|
|
19
|
+
(hashToSign: string): string | Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
export interface ProofGatedCallParams {
|
|
22
|
+
identityId: string;
|
|
23
|
+
/** The signing identity's ADI, e.g. `acc://your-org.acme`. */
|
|
24
|
+
adiUrl: string;
|
|
25
|
+
/** The identity's abstract account — `msg.sender` on the destination chain. */
|
|
26
|
+
fromAddress: string;
|
|
27
|
+
chain: string;
|
|
28
|
+
chainId?: number;
|
|
29
|
+
contractCall: ContractCall;
|
|
30
|
+
sign: SignFn;
|
|
31
|
+
publicKey: string;
|
|
32
|
+
/** Nominate a seat on the page. Defaults to `publicKey`. */
|
|
33
|
+
signerPublicKey?: string;
|
|
34
|
+
/** Nominate which page of the book signs, e.g. `acc://panel.acme/book/2`. */
|
|
35
|
+
signerKeyPage?: string;
|
|
36
|
+
idempotencyKey?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface TransferParams {
|
|
39
|
+
identityId: string;
|
|
40
|
+
fromChain: string;
|
|
41
|
+
toChain: string;
|
|
42
|
+
fromAddress: string;
|
|
43
|
+
toAddress: string;
|
|
44
|
+
/** Base units (wei) as a STRING — a JSON number silently loses precision past 2^53. */
|
|
45
|
+
amount: string;
|
|
46
|
+
tokenSymbol?: string;
|
|
47
|
+
sign: SignFn;
|
|
48
|
+
publicKey: string;
|
|
49
|
+
signerPublicKey?: string;
|
|
50
|
+
signerKeyPage?: string;
|
|
51
|
+
idempotencyKey?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface OpenedIntent {
|
|
54
|
+
intentId: string;
|
|
55
|
+
accumTxHash?: string;
|
|
56
|
+
signingMode?: string;
|
|
57
|
+
}
|
|
58
|
+
export declare class ExecuteResource {
|
|
59
|
+
private http;
|
|
60
|
+
private newIdempotencyKey;
|
|
61
|
+
constructor(http: AxiosInstance, newIdempotencyKey: () => string);
|
|
62
|
+
/**
|
|
63
|
+
* Authorize an arbitrary contract call, gated on proof.
|
|
64
|
+
*
|
|
65
|
+
* Opens the intent, signs what the gateway returns, and posts the signature back. Resolves once YOUR
|
|
66
|
+
* signature is in — which on an M-of-N page is not the same as executed. Follow with `wait()`.
|
|
67
|
+
*/
|
|
68
|
+
contractCall(p: ProofGatedCallParams): Promise<OpenedIntent>;
|
|
69
|
+
/** Authorize a native transfer, gated on proof. Same flow, simpler intent. */
|
|
70
|
+
transfer(p: TransferParams): Promise<OpenedIntent>;
|
|
71
|
+
/**
|
|
72
|
+
* Add a co-signature to a transaction another seat opened — the second half of an M-of-N panel.
|
|
73
|
+
*
|
|
74
|
+
* `vote` is a lowercase string: `approve`, `reject`, or `abstain`. Not `accept`, and not a number. The
|
|
75
|
+
* vote is folded into the signature preimage, so it is fixed when the signing data is created — you
|
|
76
|
+
* cannot ask for signing data and decide the vote afterwards.
|
|
77
|
+
*/
|
|
78
|
+
cosign(p: {
|
|
79
|
+
accumTxHash: string;
|
|
80
|
+
identity: string;
|
|
81
|
+
signerUrl: string;
|
|
82
|
+
publicKey: string;
|
|
83
|
+
sign: SignFn;
|
|
84
|
+
vote?: 'approve' | 'reject' | 'abstain';
|
|
85
|
+
}): Promise<Record<string, unknown>>;
|
|
86
|
+
/**
|
|
87
|
+
* Poll an intent to a terminal state.
|
|
88
|
+
*
|
|
89
|
+
* A real proof cycle is 60–110 seconds of validator work, so the default budget is generous. This is not
|
|
90
|
+
* a delay that can be tuned away, and a 30-second timeout around it will simply always fire.
|
|
91
|
+
*/
|
|
92
|
+
wait(intentId: string, { timeoutMs, intervalMs, onPoll }?: {
|
|
93
|
+
timeoutMs?: number;
|
|
94
|
+
intervalMs?: number;
|
|
95
|
+
onPoll?: (tx: TransactionResponse) => void;
|
|
96
|
+
}): Promise<TransactionResponse>;
|
|
97
|
+
/**
|
|
98
|
+
* The evidence to hand a counterparty, so they verify rather than trust.
|
|
99
|
+
*
|
|
100
|
+
* Falls back to the Accumulate merkle receipt when there is no cross-chain `proof_id` — which is the
|
|
101
|
+
* normal case for a governance or authorization transaction, and the case where a naive lookup returns
|
|
102
|
+
* empty and looks like a bug.
|
|
103
|
+
*/
|
|
104
|
+
proof(intentId: string): Promise<{
|
|
105
|
+
kind: 'certen-proof';
|
|
106
|
+
proofId: string;
|
|
107
|
+
proof: unknown;
|
|
108
|
+
intent: TransactionResponse;
|
|
109
|
+
} | {
|
|
110
|
+
kind: 'accumulate-receipt';
|
|
111
|
+
txHash: string;
|
|
112
|
+
receipt: unknown;
|
|
113
|
+
intent: TransactionResponse;
|
|
114
|
+
}>;
|
|
115
|
+
private open;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/resources/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAqB,mBAAmB,EAAE,MAAM,aAAa,CA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@@
|
|
|
1
|
+
import { omitUndefined } from '../internal.js';
|
|
2
|
+
/** Terminal states. `wait()` stops on these rather than polling forever. */
|
|
3
|
+
const DONE = ['completed', 'delivered', 'proven'];
|
|
4
|
+
const FAILED = ['failed', 'error'];
|
|
5
|
+
export class ExecuteResource {
|
|
6
|
+
http;
|
|
7
|
+
newIdempotencyKey;
|
|
8
|
+
constructor(http, newIdempotencyKey) {
|
|
9
|
+
this.http = http;
|
|
10
|
+
this.newIdempotencyKey = newIdempotencyKey;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Authorize an arbitrary contract call, gated on proof.
|
|
14
|
+
*
|
|
15
|
+
* Opens the intent, signs what the gateway returns, and posts the signature back. Resolves once YOUR
|
|
16
|
+
* signature is in — which on an M-of-N page is not the same as executed. Follow with `wait()`.
|
|
17
|
+
*/
|
|
18
|
+
async contractCall(p) {
|
|
19
|
+
const intent = {
|
|
20
|
+
adiUrl: p.adiUrl,
|
|
21
|
+
legs: [{
|
|
22
|
+
legId: 'leg-1',
|
|
23
|
+
chain: p.chain,
|
|
24
|
+
chainId: p.chainId,
|
|
25
|
+
fromAddress: p.fromAddress,
|
|
26
|
+
toAddress: p.contractCall.target,
|
|
27
|
+
// The leg's value must match the call's, or a payable call goes out with the wrong wei attached
|
|
28
|
+
// and the proof faithfully proves the wrong call.
|
|
29
|
+
amount: p.contractCall.value ?? '0',
|
|
30
|
+
contractCall: p.contractCall,
|
|
31
|
+
}],
|
|
32
|
+
};
|
|
33
|
+
return this.open({
|
|
34
|
+
identity_id: p.identityId,
|
|
35
|
+
intent,
|
|
36
|
+
contract_addresses: [p.contractCall.target],
|
|
37
|
+
signer_public_key: p.signerPublicKey ?? p.publicKey,
|
|
38
|
+
signer_key_page: p.signerKeyPage,
|
|
39
|
+
}, p.sign, p.signerPublicKey ?? p.publicKey, p.idempotencyKey);
|
|
40
|
+
}
|
|
41
|
+
/** Authorize a native transfer, gated on proof. Same flow, simpler intent. */
|
|
42
|
+
async transfer(p) {
|
|
43
|
+
return this.open({
|
|
44
|
+
identity_id: p.identityId,
|
|
45
|
+
intent: {
|
|
46
|
+
fromChain: p.fromChain,
|
|
47
|
+
toChain: p.toChain,
|
|
48
|
+
fromAddress: p.fromAddress,
|
|
49
|
+
toAddress: p.toAddress,
|
|
50
|
+
amount: p.amount,
|
|
51
|
+
tokenSymbol: p.tokenSymbol,
|
|
52
|
+
},
|
|
53
|
+
signer_public_key: p.signerPublicKey ?? p.publicKey,
|
|
54
|
+
signer_key_page: p.signerKeyPage,
|
|
55
|
+
}, p.sign, p.signerPublicKey ?? p.publicKey, p.idempotencyKey);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Add a co-signature to a transaction another seat opened — the second half of an M-of-N panel.
|
|
59
|
+
*
|
|
60
|
+
* `vote` is a lowercase string: `approve`, `reject`, or `abstain`. Not `accept`, and not a number. The
|
|
61
|
+
* vote is folded into the signature preimage, so it is fixed when the signing data is created — you
|
|
62
|
+
* cannot ask for signing data and decide the vote afterwards.
|
|
63
|
+
*/
|
|
64
|
+
async cosign(p) {
|
|
65
|
+
const { data: prep } = await this.http.post('/v1/sign', omitUndefined({
|
|
66
|
+
type: 'pending_tx',
|
|
67
|
+
target_id: p.accumTxHash,
|
|
68
|
+
identity: p.identity,
|
|
69
|
+
signer_url: p.signerUrl,
|
|
70
|
+
public_key: p.publicKey,
|
|
71
|
+
vote: p.vote ?? 'approve',
|
|
72
|
+
}));
|
|
73
|
+
const toSign = prep?.signing_data?.data_for_signature ?? prep?.signing_data?.hash_to_sign;
|
|
74
|
+
if (!toSign)
|
|
75
|
+
throw new Error(`certen: no signing data returned for ${p.accumTxHash}`);
|
|
76
|
+
const signature = await p.sign(toSign);
|
|
77
|
+
// A spent sign_request_id 404s rather than replaying, so never retry by resubmitting — request fresh
|
|
78
|
+
// signing data instead.
|
|
79
|
+
const url = prep.submit_url ?? `/v1/sign/${prep.sign_request_id}/signature`;
|
|
80
|
+
const { data } = await this.http.post(url, { signature, public_key: p.publicKey });
|
|
81
|
+
return data;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Poll an intent to a terminal state.
|
|
85
|
+
*
|
|
86
|
+
* A real proof cycle is 60–110 seconds of validator work, so the default budget is generous. This is not
|
|
87
|
+
* a delay that can be tuned away, and a 30-second timeout around it will simply always fire.
|
|
88
|
+
*/
|
|
89
|
+
async wait(intentId, { timeoutMs = 360_000, intervalMs = 8_000, onPoll } = {}) {
|
|
90
|
+
const deadline = Date.now() + timeoutMs;
|
|
91
|
+
let last;
|
|
92
|
+
while (Date.now() < deadline) {
|
|
93
|
+
const { data } = await this.http.get(`/v1/transaction/${intentId}`);
|
|
94
|
+
last = data;
|
|
95
|
+
onPoll?.(last);
|
|
96
|
+
const status = String(last.status ?? '');
|
|
97
|
+
if (DONE.includes(status))
|
|
98
|
+
return last;
|
|
99
|
+
if (FAILED.includes(status)) {
|
|
100
|
+
const msg = last.error_message ?? '';
|
|
101
|
+
throw new Error(`certen: intent ${intentId} ${status}${msg ? `: ${msg}` : ''}`);
|
|
102
|
+
}
|
|
103
|
+
await sleep(intervalMs);
|
|
104
|
+
}
|
|
105
|
+
// Deliberately neither success nor failure — the intent may still complete. Say which it is.
|
|
106
|
+
const status = String(last?.status ?? 'unknown');
|
|
107
|
+
throw new Error(`certen: intent ${intentId} still ${status} after ${timeoutMs}ms`);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The evidence to hand a counterparty, so they verify rather than trust.
|
|
111
|
+
*
|
|
112
|
+
* Falls back to the Accumulate merkle receipt when there is no cross-chain `proof_id` — which is the
|
|
113
|
+
* normal case for a governance or authorization transaction, and the case where a naive lookup returns
|
|
114
|
+
* empty and looks like a bug.
|
|
115
|
+
*/
|
|
116
|
+
async proof(intentId) {
|
|
117
|
+
const { data: intent } = await this.http.get(`/v1/transaction/${intentId}`);
|
|
118
|
+
const proofId = intent.proof_id;
|
|
119
|
+
if (proofId) {
|
|
120
|
+
const { data: proof } = await this.http.get(`/v1/proof/${proofId}`);
|
|
121
|
+
return { kind: 'certen-proof', proofId, proof, intent };
|
|
122
|
+
}
|
|
123
|
+
const hash = String(intent.accum_tx_hash ?? '').match(/([a-f0-9]{64})/)?.[1];
|
|
124
|
+
if (!hash) {
|
|
125
|
+
throw new Error(`certen: intent ${intentId} has neither a proof_id nor an Accumulate transaction hash`);
|
|
126
|
+
}
|
|
127
|
+
const { data: receipt } = await this.http.get(`/v1/proof/tx/${hash}/receipt`);
|
|
128
|
+
return { kind: 'accumulate-receipt', txHash: hash, receipt, intent };
|
|
129
|
+
}
|
|
130
|
+
// ── shared open-and-sign ──────────────────────────────────────────────────────────────────────────
|
|
131
|
+
async open(body, sign, publicKey, idempotencyKey) {
|
|
132
|
+
// An Idempotency-Key is not optional. A network error here is indistinguishable from success, and a
|
|
133
|
+
// retry without one opens a SECOND intent — which on a value transfer means paying twice.
|
|
134
|
+
const key = idempotencyKey ?? this.newIdempotencyKey();
|
|
135
|
+
const { data: prep } = await this.http.post('/v1/transaction', omitUndefined(body), {
|
|
136
|
+
headers: { 'Idempotency-Key': key },
|
|
137
|
+
});
|
|
138
|
+
const sd = prep.signing_data;
|
|
139
|
+
if (!sd?.hash_to_sign) {
|
|
140
|
+
// Provider mode (the gateway holds a key) returns no signing data. Continuing would let the caller
|
|
141
|
+
// believe they authorized something they never signed.
|
|
142
|
+
throw new Error(`certen: no signing_data on intent ${prep.intent_id} `
|
|
143
|
+
+ `(signing_mode=${prep.signing_mode}). This flow requires external `
|
|
144
|
+
+ 'mode, where you hold the key.');
|
|
145
|
+
}
|
|
146
|
+
const signature = await sign(sd.hash_to_sign);
|
|
147
|
+
const submitUrl = prep.submit_url
|
|
148
|
+
?? `/v1/transaction/${prep.intent_id}/signature`;
|
|
149
|
+
await this.http.post(submitUrl, { signature, public_key: publicKey });
|
|
150
|
+
return {
|
|
151
|
+
intentId: prep.intent_id,
|
|
152
|
+
accumTxHash: sd.transaction_hash,
|
|
153
|
+
signingMode: prep.signing_mode,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
158
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/resources/execute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA+D/C,4EAA4E;AAC5E,MAAM,IAAI,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;AAClD,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAEnC,MAAM,OAAO,eAAe;IAEhB;IACA;IAFV,YACU,IAAmB,EACnB,iBAA+B;QAD/B,SAAI,GAAJ,IAAI,CAAe;QACnB,sBAAiB,GAAjB,iBAAiB,CAAc;IACtC,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,CAAuB;QACxC,MAAM,MAAM,GAAsB;YAChC,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,IAAI,EAAE,CAAC;oBACL,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,CAAC,CAAC,KAAK;oBACd,OAAO,EAAE,CAAC,CAAC,OAAO;oBAClB,WAAW,EAAE,CAAC,CAAC,WAAW;oBAC1B,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;oBAChC,gGAAgG;oBAChG,kDAAkD;oBAClD,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,KAAK,IAAI,GAAG;oBACnC,YAAY,EAAE,CAAC,CAAC,YAAY;iBAC7B,CAAC;SACH,CAAC;QAEF,OAAO,IAAI,CAAC,IAAI,CAAC;YACf,WAAW,EAAE,CAAC,CAAC,UAAU;YACzB,MAAM;YACN,kBAAkB,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC;YAC3C,iBAAiB,EAA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,EAAE,CAAC,gBAAgB;YAChC,WAAW,EAAG,IAAkC,CAAC,YAAY;SAC9D,CAAC;IACJ,CAAC;CACF;AAED,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import type { GovernanceParams, GovernanceResponse, SubmitGovernanceSignatureParams } from '../types.js';
|
|
3
|
+
export declare class GovernanceResource {
|
|
4
|
+
private http;
|
|
5
|
+
constructor(http: AxiosInstance);
|
|
6
|
+
/**
|
|
7
|
+
* Submit one or more governance operations.
|
|
8
|
+
*
|
|
9
|
+
* This previously sent `{ identity_id, operation_type, payload }` and omitted BOTH fields the API
|
|
10
|
+
* requires (`identity` — the ADI, not a uuid — and `operations`, an array), so every call 400'd.
|
|
11
|
+
*/
|
|
12
|
+
create(params: GovernanceParams): Promise<GovernanceResponse>;
|
|
13
|
+
submitSignature(id: string, params: SubmitGovernanceSignatureParams): Promise<GovernanceResponse>;
|
|
14
|
+
get(id: string): Promise<GovernanceResponse>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=governance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../../src/resources/governance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,+BAA+B,EAChC,MAAM,aAAa,CAAC;AAErB,qBAAa,kBAAkB;IACjB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAW7D,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,+BAA+B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQjG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAInD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { omitUndefined } from '../internal.js';
|
|
2
|
+
export class GovernanceResource {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Submit one or more governance operations.
|
|
9
|
+
*
|
|
10
|
+
* This previously sent `{ identity_id, operation_type, payload }` and omitted BOTH fields the API
|
|
11
|
+
* requires (`identity` — the ADI, not a uuid — and `operations`, an array), so every call 400'd.
|
|
12
|
+
*/
|
|
13
|
+
async create(params) {
|
|
14
|
+
const { data } = await this.http.post('/v1/governance', omitUndefined({
|
|
15
|
+
identity: params.identity,
|
|
16
|
+
operations: params.operations,
|
|
17
|
+
key_page_url: params.keyPageUrl,
|
|
18
|
+
signer_key_page: params.signerKeyPage,
|
|
19
|
+
signer_public_key: params.signerPublicKey,
|
|
20
|
+
}));
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
async submitSignature(id, params) {
|
|
24
|
+
const { data } = await this.http.post(`/v1/governance/${id}/signature`, {
|
|
25
|
+
signature: params.signature,
|
|
26
|
+
public_key: params.publicKey,
|
|
27
|
+
});
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
async get(id) {
|
|
31
|
+
const { data } = await this.http.get(`/v1/governance/${id}`);
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=governance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/resources/governance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,MAAM,OAAO,kBAAkB;IACT;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,MAAwB;QACnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,aAAa,CAAC;YACpE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,YAAY,EAAE,MAAM,CAAC,UAAU;YAC/B,eAAe,EAAE,MAAM,CAAC,aAAa;YACrC,iBAAiB,EAAE,MAAM,CAAC,eAAe;SAC1C,CAAC,CAAC,CAAC;QACJ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,EAAU,EAAE,MAAuC;QACvE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,YAAY,EAAE;YACtE,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU,EAAE,MAAM,CAAC,SAAS;SAC7B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import type { CreateIdentityParams, IdentityResponse, UpdateIdentityParams } from '../types.js';
|
|
3
|
+
export declare class IdentityResource {
|
|
4
|
+
private http;
|
|
5
|
+
constructor(http: AxiosInstance);
|
|
6
|
+
/**
|
|
7
|
+
* Create an identity.
|
|
8
|
+
*
|
|
9
|
+
* ASYNCHRONOUS: this returns 202 and provisioning continues in the background. Poll `get()` until the
|
|
10
|
+
* status is terminal, and check `can_sign` before building anything on it.
|
|
11
|
+
*
|
|
12
|
+
* `webhookUrl` used to be sent here. POST /v1/identity does not accept one — Fastify strips unknown
|
|
13
|
+
* properties, so the option silently did nothing. Set it with `update()`, which does accept it.
|
|
14
|
+
*/
|
|
15
|
+
create(params: CreateIdentityParams): Promise<IdentityResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Fetch one identity.
|
|
18
|
+
*
|
|
19
|
+
* The route takes no query parameters. An `include` list was previously accepted by this method and sent
|
|
20
|
+
* as a query string, where it was silently ignored — so the signature promised a capability the API does
|
|
21
|
+
* not have.
|
|
22
|
+
*/
|
|
23
|
+
get(id: string): Promise<IdentityResponse>;
|
|
24
|
+
/** Link or unlink chains, set a webhook, or supply a `publicKey` to repair an identity created without one. */
|
|
25
|
+
update(id: string, params: UpdateIdentityParams): Promise<IdentityResponse>;
|
|
26
|
+
/** Retire an identity, freeing the slot it occupies against the org quota. Soft delete inside Certen only:
|
|
27
|
+
* the on-chain ADI, key book, and key page are untouched and keep existing on Accumulate. */
|
|
28
|
+
retire(id: string): Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/resources/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,qBAAa,gBAAgB;IACf,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC;;;;;;;;OAQG;IACG,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAerE;;;;;;OAMG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAKhD,+GAA+G;IACzG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAUjF;kGAC8F;IACxF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAYxD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { omitUndefined } from '../internal.js';
|
|
2
|
+
export class IdentityResource {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create an identity.
|
|
9
|
+
*
|
|
10
|
+
* ASYNCHRONOUS: this returns 202 and provisioning continues in the background. Poll `get()` until the
|
|
11
|
+
* status is terminal, and check `can_sign` before building anything on it.
|
|
12
|
+
*
|
|
13
|
+
* `webhookUrl` used to be sent here. POST /v1/identity does not accept one — Fastify strips unknown
|
|
14
|
+
* properties, so the option silently did nothing. Set it with `update()`, which does accept it.
|
|
15
|
+
*/
|
|
16
|
+
async create(params) {
|
|
17
|
+
const headers = {};
|
|
18
|
+
if (params.idempotencyKey)
|
|
19
|
+
headers['Idempotency-Key'] = params.idempotencyKey;
|
|
20
|
+
const { data } = await this.http.post('/v1/identity', omitUndefined({
|
|
21
|
+
name: params.name,
|
|
22
|
+
public_key: params.publicKey,
|
|
23
|
+
public_key_hash: params.publicKeyHash,
|
|
24
|
+
chains: params.chains,
|
|
25
|
+
credits: params.credits,
|
|
26
|
+
signing_mode: params.signingMode,
|
|
27
|
+
signing_provider: params.signingProvider,
|
|
28
|
+
}), { headers });
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Fetch one identity.
|
|
33
|
+
*
|
|
34
|
+
* The route takes no query parameters. An `include` list was previously accepted by this method and sent
|
|
35
|
+
* as a query string, where it was silently ignored — so the signature promised a capability the API does
|
|
36
|
+
* not have.
|
|
37
|
+
*/
|
|
38
|
+
async get(id) {
|
|
39
|
+
const { data } = await this.http.get(`/v1/identity/${id}`);
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
/** Link or unlink chains, set a webhook, or supply a `publicKey` to repair an identity created without one. */
|
|
43
|
+
async update(id, params) {
|
|
44
|
+
const { data } = await this.http.patch(`/v1/identity/${id}`, omitUndefined({
|
|
45
|
+
link_chains: params.linkChains,
|
|
46
|
+
unlink_chains: params.unlinkChains,
|
|
47
|
+
webhook_url: params.webhookUrl,
|
|
48
|
+
public_key: params.publicKey,
|
|
49
|
+
}));
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
/** Retire an identity, freeing the slot it occupies against the org quota. Soft delete inside Certen only:
|
|
53
|
+
* the on-chain ADI, key book, and key page are untouched and keep existing on Accumulate. */
|
|
54
|
+
async retire(id) {
|
|
55
|
+
const { data } = await this.http.delete(`/v1/identity/${id}`);
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/resources/identity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,MAAM,OAAO,gBAAgB;IACP;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,CAAC,MAA4B;QACvC,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,IAAI,MAAM,CAAC,cAAc;YAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC;QAC9E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,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axios';
|
|
2
|
+
import type { PendingActionsResponse, ListPendingParams } from '../types.js';
|
|
3
|
+
export declare class PendingResource {
|
|
4
|
+
private http;
|
|
5
|
+
constructor(http: AxiosInstance);
|
|
6
|
+
list(params?: ListPendingParams): Promise<PendingActionsResponse>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=pending.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending.d.ts","sourceRoot":"","sources":["../../src/resources/pending.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE7E,qBAAa,eAAe;IACd,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEjC,IAAI,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAYxE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class PendingResource {
|
|
2
|
+
http;
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
}
|
|
6
|
+
async list(params) {
|
|
7
|
+
const { data } = await this.http.get('/v1/pending', {
|
|
8
|
+
params: {
|
|
9
|
+
identity: params?.identity,
|
|
10
|
+
status: params?.status,
|
|
11
|
+
category: params?.category,
|
|
12
|
+
limit: params?.limit,
|
|
13
|
+
offset: params?.offset,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=pending.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending.js","sourceRoot":"","sources":["../../src/resources/pending.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,eAAe;IACN;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,KAAK,CAAC,IAAI,CAAC,MAA0B;QACnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE;YAClD,MAAM,EAAE;gBACN,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,MAAM,EAAE,MAAM,EAAE,MAAM;gBACtB,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,KAAK,EAAE,MAAM,EAAE,KAAK;gBACpB,MAAM,EAAE,MAAM,EAAE,MAAM;aACvB;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import type { PortfolioResponse } from '../types.js';
|
|
3
|
+
export declare class PortfolioResource {
|
|
4
|
+
private http;
|
|
5
|
+
constructor(http: AxiosInstance);
|
|
6
|
+
get(identity?: string): Promise<PortfolioResponse>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=portfolio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../../src/resources/portfolio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,qBAAa,iBAAiB;IAChB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEjC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAMzD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class PortfolioResource {
|
|
2
|
+
http;
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
}
|
|
6
|
+
async get(identity) {
|
|
7
|
+
const { data } = await this.http.get('/v1/portfolio', {
|
|
8
|
+
params: identity ? { identity } : undefined,
|
|
9
|
+
});
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=portfolio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portfolio.js","sourceRoot":"","sources":["../../src/resources/portfolio.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,iBAAiB;IACR;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,KAAK,CAAC,GAAG,CAAC,QAAiB;QACzB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE;YACpD,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;SAC5C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import type { SignRequestParams, SignResponse, SubmitSignSignatureParams } from '../types.js';
|
|
3
|
+
export declare class SignResource {
|
|
4
|
+
private http;
|
|
5
|
+
constructor(http: AxiosInstance);
|
|
6
|
+
create(params: SignRequestParams): Promise<SignResponse>;
|
|
7
|
+
submitSignature(id: string, params: SubmitSignSignatureParams): Promise<SignResponse>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=sign.d.ts.map
|