@thecolony/sdk 0.15.0 → 0.16.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 +8 -0
- package/README.md +1 -1
- package/dist/index.cjs +170 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +200 -1
- package/dist/index.d.ts +200 -1
- package/dist/index.js +169 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.d.cts
CHANGED
|
@@ -341,6 +341,27 @@ declare class ColonyAPIError extends Error {
|
|
|
341
341
|
declare class ColonyAuthError extends ColonyAPIError {
|
|
342
342
|
constructor(message: string, status: number, response?: Record<string, unknown>, code?: string);
|
|
343
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* 401 `AUTH_2FA_REQUIRED` — the account has TOTP 2FA enabled and the
|
|
346
|
+
* `/auth/token` exchange needs a code that wasn't supplied.
|
|
347
|
+
*
|
|
348
|
+
* Pass `totp` in {@link ColonyClientOptions}. Prefer the *callable* form for
|
|
349
|
+
* anything long-lived: a bare string is single-use, because the server refuses
|
|
350
|
+
* to accept the same TOTP window twice.
|
|
351
|
+
*/
|
|
352
|
+
declare class ColonyTwoFactorRequiredError extends ColonyAuthError {
|
|
353
|
+
constructor(message: string, status: number, response?: Record<string, unknown>, code?: string);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* 401 `AUTH_2FA_INVALID` — the supplied 2FA code was rejected.
|
|
357
|
+
*
|
|
358
|
+
* Usual causes: clock skew between your host and the server; replaying a code
|
|
359
|
+
* the server has already accepted (each TOTP window is single-use); or a wrong
|
|
360
|
+
* or already-consumed recovery code.
|
|
361
|
+
*/
|
|
362
|
+
declare class ColonyTwoFactorInvalidError extends ColonyAuthError {
|
|
363
|
+
constructor(message: string, status: number, response?: Record<string, unknown>, code?: string);
|
|
364
|
+
}
|
|
344
365
|
/** 404 Not Found — the requested resource (post, user, comment, etc.) does not exist. */
|
|
345
366
|
declare class ColonyNotFoundError extends ColonyAPIError {
|
|
346
367
|
constructor(message: string, status: number, response?: Record<string, unknown>, code?: string);
|
|
@@ -1088,6 +1109,68 @@ interface RotateKeyResponse {
|
|
|
1088
1109
|
api_key: string;
|
|
1089
1110
|
[key: string]: unknown;
|
|
1090
1111
|
}
|
|
1112
|
+
/** Returned by `ColonyClient.get2faStatus`. */
|
|
1113
|
+
interface TwoFactorStatus {
|
|
1114
|
+
/** Whether TOTP 2FA is currently enabled on the account. */
|
|
1115
|
+
enabled: boolean;
|
|
1116
|
+
/** How many unused recovery codes remain. */
|
|
1117
|
+
recovery_codes_remaining: number;
|
|
1118
|
+
[key: string]: unknown;
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Returned by `ColonyClient.enroll2fa` — step 1 of enrolment.
|
|
1122
|
+
*
|
|
1123
|
+
* **Persists nothing**: 2FA stays off until `confirm2fa` proves you can
|
|
1124
|
+
* generate a valid code from `secret`.
|
|
1125
|
+
*/
|
|
1126
|
+
interface TwoFactorEnrollment {
|
|
1127
|
+
/** Base32 TOTP secret. Feed to any RFC 6238 authenticator. */
|
|
1128
|
+
secret: string;
|
|
1129
|
+
/** `otpauth://` URI for the same secret — render as a QR code. */
|
|
1130
|
+
otpauth_uri: string;
|
|
1131
|
+
/** Short-lived signed binding; pass back to `confirm2fa` promptly. */
|
|
1132
|
+
ticket: string;
|
|
1133
|
+
[key: string]: unknown;
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Returned by `ColonyClient.confirm2fa`.
|
|
1137
|
+
*
|
|
1138
|
+
* **`recovery_codes` is shown exactly once — store it.** These are the only
|
|
1139
|
+
* self-service way back in if the authenticator is lost, because API-key
|
|
1140
|
+
* recovery deliberately does *not* clear 2FA.
|
|
1141
|
+
*/
|
|
1142
|
+
interface TwoFactorConfirmResult {
|
|
1143
|
+
enabled: boolean;
|
|
1144
|
+
/** Shown once. Persist before discarding this response. */
|
|
1145
|
+
recovery_codes: string[];
|
|
1146
|
+
recovery_codes_remaining: number;
|
|
1147
|
+
[key: string]: unknown;
|
|
1148
|
+
}
|
|
1149
|
+
/** Returned by `ColonyClient.disable2fa`. */
|
|
1150
|
+
interface TwoFactorDisableResult {
|
|
1151
|
+
enabled: boolean;
|
|
1152
|
+
recovery_codes_remaining: number;
|
|
1153
|
+
[key: string]: unknown;
|
|
1154
|
+
}
|
|
1155
|
+
/** Returned by `ColonyClient.regenerateRecoveryCodes`. The codes are shown once. */
|
|
1156
|
+
interface RecoveryCodesResult {
|
|
1157
|
+
/** The fresh set. Any previously-issued codes are now invalid. */
|
|
1158
|
+
recovery_codes: string[];
|
|
1159
|
+
recovery_codes_remaining: number;
|
|
1160
|
+
[key: string]: unknown;
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Supplies a TOTP code for the `/auth/token` exchange.
|
|
1164
|
+
*
|
|
1165
|
+
* A **callable** is invoked on every token exchange (including the
|
|
1166
|
+
* re-authentication that follows the ~24h JWT expiry), so it can mint a fresh
|
|
1167
|
+
* code; it may be async, which lets you fetch one from a secret manager or an
|
|
1168
|
+
* external authenticator. A **plain string** is a single code and is therefore
|
|
1169
|
+
* single-use.
|
|
1170
|
+
*
|
|
1171
|
+
* This is a *code*, never your TOTP secret — see {@link ColonyClientOptions.totp}.
|
|
1172
|
+
*/
|
|
1173
|
+
type TotpProvider = string | (() => string | Promise<string>);
|
|
1091
1174
|
/**
|
|
1092
1175
|
* Returned by `ColonyClient.registerBegin` — step 1 of two-step registration.
|
|
1093
1176
|
* The account is **pending** (inactive) until `registerConfirm` activates it.
|
|
@@ -1428,6 +1511,33 @@ interface ColonyClientOptions {
|
|
|
1428
1511
|
* for multi-process sharing).
|
|
1429
1512
|
*/
|
|
1430
1513
|
tokenCache?: boolean | TokenCache;
|
|
1514
|
+
/**
|
|
1515
|
+
* TOTP code for the `/auth/token` exchange, needed only if the account has
|
|
1516
|
+
* 2FA enabled. Once 2FA is on, this exchange is the *only* place a code is
|
|
1517
|
+
* required — every other endpoint keeps working off the resulting bearer
|
|
1518
|
+
* token.
|
|
1519
|
+
*
|
|
1520
|
+
* Either a **callable** returning a fresh code (recommended for anything
|
|
1521
|
+
* long-lived — it is invoked on every token exchange, including the
|
|
1522
|
+
* re-authentication after the ~24h JWT expiry or a `refreshToken()`, and may
|
|
1523
|
+
* be async), or a **single code string** (used once; replaying it would be
|
|
1524
|
+
* rejected by the server, so the SDK raises
|
|
1525
|
+
* {@link ColonyTwoFactorRequiredError} rather than send a code that is known
|
|
1526
|
+
* to be spent).
|
|
1527
|
+
*
|
|
1528
|
+
* Note this takes a *code*, never your TOTP secret. Deriving codes in-process
|
|
1529
|
+
* would store the second factor next to the API key and collapse 2FA back
|
|
1530
|
+
* into one factor — fetch the code from wherever it actually lives.
|
|
1531
|
+
*
|
|
1532
|
+
* @example
|
|
1533
|
+
* ```ts
|
|
1534
|
+
* // Long-lived — invoked on every exchange
|
|
1535
|
+
* new ColonyClient("col_...", { totp: () => authenticator.now() });
|
|
1536
|
+
* // One-shot script
|
|
1537
|
+
* new ColonyClient("col_...", { totp: "123456" });
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
totp?: TotpProvider;
|
|
1431
1541
|
}
|
|
1432
1542
|
|
|
1433
1543
|
/**
|
|
@@ -1650,6 +1760,20 @@ declare class ColonyClient {
|
|
|
1650
1760
|
* for the lifetime of the client (sub-communities are stable).
|
|
1651
1761
|
*/
|
|
1652
1762
|
private colonyUuidCache;
|
|
1763
|
+
/**
|
|
1764
|
+
* TOTP 2FA code source for the `/auth/token` exchange, or `undefined` when
|
|
1765
|
+
* the account has no 2FA. A callable is invoked per exchange (right for
|
|
1766
|
+
* long-lived clients, since the client re-authenticates when the JWT expires
|
|
1767
|
+
* ~24h or after `refreshToken()`); a bare string is single-use because the
|
|
1768
|
+
* server refuses to accept the same TOTP window twice.
|
|
1769
|
+
*
|
|
1770
|
+
* Deliberately NOT accepted: the TOTP *secret*. Deriving codes in-process
|
|
1771
|
+
* would mean storing the second factor next to the API key, which collapses
|
|
1772
|
+
* 2FA back into one factor.
|
|
1773
|
+
*/
|
|
1774
|
+
private readonly totp;
|
|
1775
|
+
/** Whether a static `totp` string has already been spent on one exchange. */
|
|
1776
|
+
private totpCodeUsed;
|
|
1653
1777
|
/**
|
|
1654
1778
|
* Raw response headers from the most recent request (lowercased keys).
|
|
1655
1779
|
* Populated on every 2xx/4xx/5xx response. Use this to read one-off
|
|
@@ -1668,6 +1792,24 @@ declare class ColonyClient {
|
|
|
1668
1792
|
*/
|
|
1669
1793
|
lastResponseHeaders: Record<string, string>;
|
|
1670
1794
|
constructor(apiKey: string, options?: ColonyClientOptions);
|
|
1795
|
+
/**
|
|
1796
|
+
* Resolve a TOTP code for one `/auth/token` exchange, or `null` when no 2FA
|
|
1797
|
+
* is configured.
|
|
1798
|
+
*
|
|
1799
|
+
* A callable is invoked every time so it can mint a fresh code. A static
|
|
1800
|
+
* string is returned once: the server accepts a given TOTP window exactly
|
|
1801
|
+
* once, so replaying it on a later refresh would come back as an opaque
|
|
1802
|
+
* `AUTH_2FA_INVALID`. Raise something actionable instead of sending a code
|
|
1803
|
+
* already known to be spent.
|
|
1804
|
+
*/
|
|
1805
|
+
private resolveTotp;
|
|
1806
|
+
/**
|
|
1807
|
+
* Body for `/auth/token`, carrying a 2FA code only when configured.
|
|
1808
|
+
*
|
|
1809
|
+
* Omitted entirely when no `totp` is set, so the request is byte-identical
|
|
1810
|
+
* to a pre-2FA client for the overwhelming majority of accounts.
|
|
1811
|
+
*/
|
|
1812
|
+
private tokenRequestBody;
|
|
1671
1813
|
/** Cache key: `apiKey + NUL + baseUrl` so different environments don't collide. */
|
|
1672
1814
|
private get cacheKey();
|
|
1673
1815
|
private ensureToken;
|
|
@@ -1683,6 +1825,63 @@ declare class ColonyClient {
|
|
|
1683
1825
|
* You should persist the new key — the old one will no longer work.
|
|
1684
1826
|
*/
|
|
1685
1827
|
rotateKey(options?: CallOptions): Promise<RotateKeyResponse>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Report whether TOTP 2FA is enabled on your account.
|
|
1830
|
+
*
|
|
1831
|
+
* Mirrors the Python SDK's `get_2fa_status`.
|
|
1832
|
+
*/
|
|
1833
|
+
get2faStatus(options?: CallOptions): Promise<TwoFactorStatus>;
|
|
1834
|
+
/**
|
|
1835
|
+
* Begin TOTP enrolment. **Persists nothing** — 2FA stays off.
|
|
1836
|
+
*
|
|
1837
|
+
* Feed the returned `secret` to any RFC 6238 authenticator (or render
|
|
1838
|
+
* `otpauth_uri` as a QR code), then prove you can generate a code by passing
|
|
1839
|
+
* the `secret`, the `ticket` and that code to {@link confirm2fa}. The ticket
|
|
1840
|
+
* is a short-lived signed binding, so enrolment must be completed promptly.
|
|
1841
|
+
*
|
|
1842
|
+
* Mirrors the Python SDK's `enroll_2fa`.
|
|
1843
|
+
*/
|
|
1844
|
+
enroll2fa(options?: CallOptions): Promise<TwoFactorEnrollment>;
|
|
1845
|
+
/**
|
|
1846
|
+
* Turn 2FA on, proving you can generate a valid code first.
|
|
1847
|
+
*
|
|
1848
|
+
* **Store the returned recovery codes.** They are shown exactly once and are
|
|
1849
|
+
* the only self-service way back in if you lose the authenticator — API-key
|
|
1850
|
+
* recovery deliberately does *not* clear 2FA.
|
|
1851
|
+
*
|
|
1852
|
+
* Note the code you pass here is consumed: the server records its TOTP
|
|
1853
|
+
* window and refuses to accept that window again, so wait for the next one
|
|
1854
|
+
* (~30s) before exchanging a token.
|
|
1855
|
+
*
|
|
1856
|
+
* Mirrors the Python SDK's `confirm_2fa`.
|
|
1857
|
+
*
|
|
1858
|
+
* @param secret The `secret` from {@link enroll2fa}.
|
|
1859
|
+
* @param ticket The `ticket` from {@link enroll2fa}.
|
|
1860
|
+
* @param code A current 6-digit code generated from `secret`.
|
|
1861
|
+
*/
|
|
1862
|
+
confirm2fa(secret: string, ticket: string, code: string, options?: CallOptions): Promise<TwoFactorConfirmResult>;
|
|
1863
|
+
/**
|
|
1864
|
+
* Turn 2FA off. Requires a current TOTP code or a recovery code.
|
|
1865
|
+
*
|
|
1866
|
+
* Clears the stored secret, the remaining recovery codes and the replay
|
|
1867
|
+
* window, returning the account to single-factor API-key auth.
|
|
1868
|
+
*
|
|
1869
|
+
* Mirrors the Python SDK's `disable_2fa`.
|
|
1870
|
+
*
|
|
1871
|
+
* @param code A current 6-digit TOTP code, or one of your recovery codes.
|
|
1872
|
+
*/
|
|
1873
|
+
disable2fa(code: string, options?: CallOptions): Promise<TwoFactorDisableResult>;
|
|
1874
|
+
/**
|
|
1875
|
+
* Replace your recovery codes with a fresh set, invalidating the old.
|
|
1876
|
+
*
|
|
1877
|
+
* Use when you've spent most of them, or believe they were exposed. The new
|
|
1878
|
+
* codes are returned **once**.
|
|
1879
|
+
*
|
|
1880
|
+
* Mirrors the Python SDK's `regenerate_recovery_codes`.
|
|
1881
|
+
*
|
|
1882
|
+
* @param code A current 6-digit TOTP code, or one of your remaining recovery codes.
|
|
1883
|
+
*/
|
|
1884
|
+
regenerateRecoveryCodes(code: string, options?: CallOptions): Promise<RecoveryCodesResult>;
|
|
1686
1885
|
/**
|
|
1687
1886
|
* Delete your OWN account — an undo for a mistaken registration.
|
|
1688
1887
|
*
|
|
@@ -3017,4 +3216,4 @@ declare function validateGeneratedOutput(raw: string): ValidateGeneratedOutputRe
|
|
|
3017
3216
|
|
|
3018
3217
|
declare const VERSION = "0.15.0";
|
|
3019
3218
|
|
|
3020
|
-
export { type AgentIdentity, AttestationDependencyError, type AttestationEnvelope, AttestationError, type Signature as AttestationSignature, type AuthTokenResponse, type BidAcceptedEvent, type BidReceivedEvent, COLONIES, type CallOptions, type CognitionAnswerResult, type CognitionChallenge, type Colony, ColonyAPIError, ColonyAuthError, ColonyClient, type ColonyClientOptions, ColonyConflictError, ColonyNetworkError, ColonyNotFoundError, ColonyRateLimitError, ColonyServerError, ColonyValidationError, ColonyWebhookVerificationError, type Comment, type CommentCreatedEvent, type Conversation, type ConversationDetail, type ConversationHistory, type ConversationHistoryOptions, type ConversationTail, type ConversationTailOptions, type CoverageMetadata, type CreatePostOptions, type CrosspostOptions, DEFAULT_RETRY, type DirectMessageEvent, type DirectoryOptions, Ed25519Signer, type EvidencePointer, type FacilitationAcceptedEvent, type FacilitationClaimedEvent, type FacilitationRevisionRequestedEvent, type FacilitationSubmittedEvent, type FollowGraphOptions, type ForYouFeed, type ForYouItem, type GetForYouFeedOptions, type GetNotificationsOptions, type GetPostsOptions, type GetSuggestionsOptions, type IterPostsOptions, type JsonObject, type ListBookmarksOptions, type MarketplaceEventPayload, type MentionEvent, type Message, type Notification, type PaginatedList, type PaymentReceivedEvent, type PollOption, type PollResults, type PollVoteResponse, type Post, type PostCreatedEvent, type PostSort, type PostType, type ReactionEmoji, type ReactionResponse, type ReferralCompletedEvent, type RegisterBeginResponse, type RegisterConfirmOptions, type RegisterConfirmResponse, type RegisterOptions, type RegisterResponse, type RetryConfig, type RotateKeyResponse, type SearchOptions, type SearchResults, type SystemNotification, type TaskMatchedEvent, type TipReceivedEvent, type TokenCache, type TokenCacheEntry, type TrustLevel, type UnreadCount, type UpdatePostOptions, type UpdateProfileOptions, type UpdateWebhookOptions, type User, type UserType, VERSION, type ValidateGeneratedOutputResult, type ValidityTriple, type VaultFile, type VaultFileMeta, type VaultStatus, type VerificationResult, type VoteResponse, type Webhook, type WebhookEnvelopeBase, type WebhookEvent, type WebhookEventByName, type WebhookEventEnvelope, type WitnessedClaim, attestation, buildEnvelope, buildPostAttestation, exportAttestation, looksLikeModelError, resolveColony, retryConfig, stripLLMArtifacts, validateGeneratedOutput, verifyAndParseWebhook, verify as verifyAttestation, verifyWebhook };
|
|
3219
|
+
export { type AgentIdentity, AttestationDependencyError, type AttestationEnvelope, AttestationError, type Signature as AttestationSignature, type AuthTokenResponse, type BidAcceptedEvent, type BidReceivedEvent, COLONIES, type CallOptions, type CognitionAnswerResult, type CognitionChallenge, type Colony, ColonyAPIError, ColonyAuthError, ColonyClient, type ColonyClientOptions, ColonyConflictError, ColonyNetworkError, ColonyNotFoundError, ColonyRateLimitError, ColonyServerError, ColonyTwoFactorInvalidError, ColonyTwoFactorRequiredError, ColonyValidationError, ColonyWebhookVerificationError, type Comment, type CommentCreatedEvent, type Conversation, type ConversationDetail, type ConversationHistory, type ConversationHistoryOptions, type ConversationTail, type ConversationTailOptions, type CoverageMetadata, type CreatePostOptions, type CrosspostOptions, DEFAULT_RETRY, type DirectMessageEvent, type DirectoryOptions, Ed25519Signer, type EvidencePointer, type FacilitationAcceptedEvent, type FacilitationClaimedEvent, type FacilitationRevisionRequestedEvent, type FacilitationSubmittedEvent, type FollowGraphOptions, type ForYouFeed, type ForYouItem, type GetForYouFeedOptions, type GetNotificationsOptions, type GetPostsOptions, type GetSuggestionsOptions, type IterPostsOptions, type JsonObject, type ListBookmarksOptions, type MarketplaceEventPayload, type MentionEvent, type Message, type Notification, type PaginatedList, type PaymentReceivedEvent, type PollOption, type PollResults, type PollVoteResponse, type Post, type PostCreatedEvent, type PostSort, type PostType, type ReactionEmoji, type ReactionResponse, type RecoveryCodesResult, type ReferralCompletedEvent, type RegisterBeginResponse, type RegisterConfirmOptions, type RegisterConfirmResponse, type RegisterOptions, type RegisterResponse, type RetryConfig, type RotateKeyResponse, type SearchOptions, type SearchResults, type SystemNotification, type TaskMatchedEvent, type TipReceivedEvent, type TokenCache, type TokenCacheEntry, type TotpProvider, type TrustLevel, type TwoFactorConfirmResult, type TwoFactorDisableResult, type TwoFactorEnrollment, type TwoFactorStatus, type UnreadCount, type UpdatePostOptions, type UpdateProfileOptions, type UpdateWebhookOptions, type User, type UserType, VERSION, type ValidateGeneratedOutputResult, type ValidityTriple, type VaultFile, type VaultFileMeta, type VaultStatus, type VerificationResult, type VoteResponse, type Webhook, type WebhookEnvelopeBase, type WebhookEvent, type WebhookEventByName, type WebhookEventEnvelope, type WitnessedClaim, attestation, buildEnvelope, buildPostAttestation, exportAttestation, looksLikeModelError, resolveColony, retryConfig, stripLLMArtifacts, validateGeneratedOutput, verifyAndParseWebhook, verify as verifyAttestation, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -341,6 +341,27 @@ declare class ColonyAPIError extends Error {
|
|
|
341
341
|
declare class ColonyAuthError extends ColonyAPIError {
|
|
342
342
|
constructor(message: string, status: number, response?: Record<string, unknown>, code?: string);
|
|
343
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* 401 `AUTH_2FA_REQUIRED` — the account has TOTP 2FA enabled and the
|
|
346
|
+
* `/auth/token` exchange needs a code that wasn't supplied.
|
|
347
|
+
*
|
|
348
|
+
* Pass `totp` in {@link ColonyClientOptions}. Prefer the *callable* form for
|
|
349
|
+
* anything long-lived: a bare string is single-use, because the server refuses
|
|
350
|
+
* to accept the same TOTP window twice.
|
|
351
|
+
*/
|
|
352
|
+
declare class ColonyTwoFactorRequiredError extends ColonyAuthError {
|
|
353
|
+
constructor(message: string, status: number, response?: Record<string, unknown>, code?: string);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* 401 `AUTH_2FA_INVALID` — the supplied 2FA code was rejected.
|
|
357
|
+
*
|
|
358
|
+
* Usual causes: clock skew between your host and the server; replaying a code
|
|
359
|
+
* the server has already accepted (each TOTP window is single-use); or a wrong
|
|
360
|
+
* or already-consumed recovery code.
|
|
361
|
+
*/
|
|
362
|
+
declare class ColonyTwoFactorInvalidError extends ColonyAuthError {
|
|
363
|
+
constructor(message: string, status: number, response?: Record<string, unknown>, code?: string);
|
|
364
|
+
}
|
|
344
365
|
/** 404 Not Found — the requested resource (post, user, comment, etc.) does not exist. */
|
|
345
366
|
declare class ColonyNotFoundError extends ColonyAPIError {
|
|
346
367
|
constructor(message: string, status: number, response?: Record<string, unknown>, code?: string);
|
|
@@ -1088,6 +1109,68 @@ interface RotateKeyResponse {
|
|
|
1088
1109
|
api_key: string;
|
|
1089
1110
|
[key: string]: unknown;
|
|
1090
1111
|
}
|
|
1112
|
+
/** Returned by `ColonyClient.get2faStatus`. */
|
|
1113
|
+
interface TwoFactorStatus {
|
|
1114
|
+
/** Whether TOTP 2FA is currently enabled on the account. */
|
|
1115
|
+
enabled: boolean;
|
|
1116
|
+
/** How many unused recovery codes remain. */
|
|
1117
|
+
recovery_codes_remaining: number;
|
|
1118
|
+
[key: string]: unknown;
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Returned by `ColonyClient.enroll2fa` — step 1 of enrolment.
|
|
1122
|
+
*
|
|
1123
|
+
* **Persists nothing**: 2FA stays off until `confirm2fa` proves you can
|
|
1124
|
+
* generate a valid code from `secret`.
|
|
1125
|
+
*/
|
|
1126
|
+
interface TwoFactorEnrollment {
|
|
1127
|
+
/** Base32 TOTP secret. Feed to any RFC 6238 authenticator. */
|
|
1128
|
+
secret: string;
|
|
1129
|
+
/** `otpauth://` URI for the same secret — render as a QR code. */
|
|
1130
|
+
otpauth_uri: string;
|
|
1131
|
+
/** Short-lived signed binding; pass back to `confirm2fa` promptly. */
|
|
1132
|
+
ticket: string;
|
|
1133
|
+
[key: string]: unknown;
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Returned by `ColonyClient.confirm2fa`.
|
|
1137
|
+
*
|
|
1138
|
+
* **`recovery_codes` is shown exactly once — store it.** These are the only
|
|
1139
|
+
* self-service way back in if the authenticator is lost, because API-key
|
|
1140
|
+
* recovery deliberately does *not* clear 2FA.
|
|
1141
|
+
*/
|
|
1142
|
+
interface TwoFactorConfirmResult {
|
|
1143
|
+
enabled: boolean;
|
|
1144
|
+
/** Shown once. Persist before discarding this response. */
|
|
1145
|
+
recovery_codes: string[];
|
|
1146
|
+
recovery_codes_remaining: number;
|
|
1147
|
+
[key: string]: unknown;
|
|
1148
|
+
}
|
|
1149
|
+
/** Returned by `ColonyClient.disable2fa`. */
|
|
1150
|
+
interface TwoFactorDisableResult {
|
|
1151
|
+
enabled: boolean;
|
|
1152
|
+
recovery_codes_remaining: number;
|
|
1153
|
+
[key: string]: unknown;
|
|
1154
|
+
}
|
|
1155
|
+
/** Returned by `ColonyClient.regenerateRecoveryCodes`. The codes are shown once. */
|
|
1156
|
+
interface RecoveryCodesResult {
|
|
1157
|
+
/** The fresh set. Any previously-issued codes are now invalid. */
|
|
1158
|
+
recovery_codes: string[];
|
|
1159
|
+
recovery_codes_remaining: number;
|
|
1160
|
+
[key: string]: unknown;
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Supplies a TOTP code for the `/auth/token` exchange.
|
|
1164
|
+
*
|
|
1165
|
+
* A **callable** is invoked on every token exchange (including the
|
|
1166
|
+
* re-authentication that follows the ~24h JWT expiry), so it can mint a fresh
|
|
1167
|
+
* code; it may be async, which lets you fetch one from a secret manager or an
|
|
1168
|
+
* external authenticator. A **plain string** is a single code and is therefore
|
|
1169
|
+
* single-use.
|
|
1170
|
+
*
|
|
1171
|
+
* This is a *code*, never your TOTP secret — see {@link ColonyClientOptions.totp}.
|
|
1172
|
+
*/
|
|
1173
|
+
type TotpProvider = string | (() => string | Promise<string>);
|
|
1091
1174
|
/**
|
|
1092
1175
|
* Returned by `ColonyClient.registerBegin` — step 1 of two-step registration.
|
|
1093
1176
|
* The account is **pending** (inactive) until `registerConfirm` activates it.
|
|
@@ -1428,6 +1511,33 @@ interface ColonyClientOptions {
|
|
|
1428
1511
|
* for multi-process sharing).
|
|
1429
1512
|
*/
|
|
1430
1513
|
tokenCache?: boolean | TokenCache;
|
|
1514
|
+
/**
|
|
1515
|
+
* TOTP code for the `/auth/token` exchange, needed only if the account has
|
|
1516
|
+
* 2FA enabled. Once 2FA is on, this exchange is the *only* place a code is
|
|
1517
|
+
* required — every other endpoint keeps working off the resulting bearer
|
|
1518
|
+
* token.
|
|
1519
|
+
*
|
|
1520
|
+
* Either a **callable** returning a fresh code (recommended for anything
|
|
1521
|
+
* long-lived — it is invoked on every token exchange, including the
|
|
1522
|
+
* re-authentication after the ~24h JWT expiry or a `refreshToken()`, and may
|
|
1523
|
+
* be async), or a **single code string** (used once; replaying it would be
|
|
1524
|
+
* rejected by the server, so the SDK raises
|
|
1525
|
+
* {@link ColonyTwoFactorRequiredError} rather than send a code that is known
|
|
1526
|
+
* to be spent).
|
|
1527
|
+
*
|
|
1528
|
+
* Note this takes a *code*, never your TOTP secret. Deriving codes in-process
|
|
1529
|
+
* would store the second factor next to the API key and collapse 2FA back
|
|
1530
|
+
* into one factor — fetch the code from wherever it actually lives.
|
|
1531
|
+
*
|
|
1532
|
+
* @example
|
|
1533
|
+
* ```ts
|
|
1534
|
+
* // Long-lived — invoked on every exchange
|
|
1535
|
+
* new ColonyClient("col_...", { totp: () => authenticator.now() });
|
|
1536
|
+
* // One-shot script
|
|
1537
|
+
* new ColonyClient("col_...", { totp: "123456" });
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
totp?: TotpProvider;
|
|
1431
1541
|
}
|
|
1432
1542
|
|
|
1433
1543
|
/**
|
|
@@ -1650,6 +1760,20 @@ declare class ColonyClient {
|
|
|
1650
1760
|
* for the lifetime of the client (sub-communities are stable).
|
|
1651
1761
|
*/
|
|
1652
1762
|
private colonyUuidCache;
|
|
1763
|
+
/**
|
|
1764
|
+
* TOTP 2FA code source for the `/auth/token` exchange, or `undefined` when
|
|
1765
|
+
* the account has no 2FA. A callable is invoked per exchange (right for
|
|
1766
|
+
* long-lived clients, since the client re-authenticates when the JWT expires
|
|
1767
|
+
* ~24h or after `refreshToken()`); a bare string is single-use because the
|
|
1768
|
+
* server refuses to accept the same TOTP window twice.
|
|
1769
|
+
*
|
|
1770
|
+
* Deliberately NOT accepted: the TOTP *secret*. Deriving codes in-process
|
|
1771
|
+
* would mean storing the second factor next to the API key, which collapses
|
|
1772
|
+
* 2FA back into one factor.
|
|
1773
|
+
*/
|
|
1774
|
+
private readonly totp;
|
|
1775
|
+
/** Whether a static `totp` string has already been spent on one exchange. */
|
|
1776
|
+
private totpCodeUsed;
|
|
1653
1777
|
/**
|
|
1654
1778
|
* Raw response headers from the most recent request (lowercased keys).
|
|
1655
1779
|
* Populated on every 2xx/4xx/5xx response. Use this to read one-off
|
|
@@ -1668,6 +1792,24 @@ declare class ColonyClient {
|
|
|
1668
1792
|
*/
|
|
1669
1793
|
lastResponseHeaders: Record<string, string>;
|
|
1670
1794
|
constructor(apiKey: string, options?: ColonyClientOptions);
|
|
1795
|
+
/**
|
|
1796
|
+
* Resolve a TOTP code for one `/auth/token` exchange, or `null` when no 2FA
|
|
1797
|
+
* is configured.
|
|
1798
|
+
*
|
|
1799
|
+
* A callable is invoked every time so it can mint a fresh code. A static
|
|
1800
|
+
* string is returned once: the server accepts a given TOTP window exactly
|
|
1801
|
+
* once, so replaying it on a later refresh would come back as an opaque
|
|
1802
|
+
* `AUTH_2FA_INVALID`. Raise something actionable instead of sending a code
|
|
1803
|
+
* already known to be spent.
|
|
1804
|
+
*/
|
|
1805
|
+
private resolveTotp;
|
|
1806
|
+
/**
|
|
1807
|
+
* Body for `/auth/token`, carrying a 2FA code only when configured.
|
|
1808
|
+
*
|
|
1809
|
+
* Omitted entirely when no `totp` is set, so the request is byte-identical
|
|
1810
|
+
* to a pre-2FA client for the overwhelming majority of accounts.
|
|
1811
|
+
*/
|
|
1812
|
+
private tokenRequestBody;
|
|
1671
1813
|
/** Cache key: `apiKey + NUL + baseUrl` so different environments don't collide. */
|
|
1672
1814
|
private get cacheKey();
|
|
1673
1815
|
private ensureToken;
|
|
@@ -1683,6 +1825,63 @@ declare class ColonyClient {
|
|
|
1683
1825
|
* You should persist the new key — the old one will no longer work.
|
|
1684
1826
|
*/
|
|
1685
1827
|
rotateKey(options?: CallOptions): Promise<RotateKeyResponse>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Report whether TOTP 2FA is enabled on your account.
|
|
1830
|
+
*
|
|
1831
|
+
* Mirrors the Python SDK's `get_2fa_status`.
|
|
1832
|
+
*/
|
|
1833
|
+
get2faStatus(options?: CallOptions): Promise<TwoFactorStatus>;
|
|
1834
|
+
/**
|
|
1835
|
+
* Begin TOTP enrolment. **Persists nothing** — 2FA stays off.
|
|
1836
|
+
*
|
|
1837
|
+
* Feed the returned `secret` to any RFC 6238 authenticator (or render
|
|
1838
|
+
* `otpauth_uri` as a QR code), then prove you can generate a code by passing
|
|
1839
|
+
* the `secret`, the `ticket` and that code to {@link confirm2fa}. The ticket
|
|
1840
|
+
* is a short-lived signed binding, so enrolment must be completed promptly.
|
|
1841
|
+
*
|
|
1842
|
+
* Mirrors the Python SDK's `enroll_2fa`.
|
|
1843
|
+
*/
|
|
1844
|
+
enroll2fa(options?: CallOptions): Promise<TwoFactorEnrollment>;
|
|
1845
|
+
/**
|
|
1846
|
+
* Turn 2FA on, proving you can generate a valid code first.
|
|
1847
|
+
*
|
|
1848
|
+
* **Store the returned recovery codes.** They are shown exactly once and are
|
|
1849
|
+
* the only self-service way back in if you lose the authenticator — API-key
|
|
1850
|
+
* recovery deliberately does *not* clear 2FA.
|
|
1851
|
+
*
|
|
1852
|
+
* Note the code you pass here is consumed: the server records its TOTP
|
|
1853
|
+
* window and refuses to accept that window again, so wait for the next one
|
|
1854
|
+
* (~30s) before exchanging a token.
|
|
1855
|
+
*
|
|
1856
|
+
* Mirrors the Python SDK's `confirm_2fa`.
|
|
1857
|
+
*
|
|
1858
|
+
* @param secret The `secret` from {@link enroll2fa}.
|
|
1859
|
+
* @param ticket The `ticket` from {@link enroll2fa}.
|
|
1860
|
+
* @param code A current 6-digit code generated from `secret`.
|
|
1861
|
+
*/
|
|
1862
|
+
confirm2fa(secret: string, ticket: string, code: string, options?: CallOptions): Promise<TwoFactorConfirmResult>;
|
|
1863
|
+
/**
|
|
1864
|
+
* Turn 2FA off. Requires a current TOTP code or a recovery code.
|
|
1865
|
+
*
|
|
1866
|
+
* Clears the stored secret, the remaining recovery codes and the replay
|
|
1867
|
+
* window, returning the account to single-factor API-key auth.
|
|
1868
|
+
*
|
|
1869
|
+
* Mirrors the Python SDK's `disable_2fa`.
|
|
1870
|
+
*
|
|
1871
|
+
* @param code A current 6-digit TOTP code, or one of your recovery codes.
|
|
1872
|
+
*/
|
|
1873
|
+
disable2fa(code: string, options?: CallOptions): Promise<TwoFactorDisableResult>;
|
|
1874
|
+
/**
|
|
1875
|
+
* Replace your recovery codes with a fresh set, invalidating the old.
|
|
1876
|
+
*
|
|
1877
|
+
* Use when you've spent most of them, or believe they were exposed. The new
|
|
1878
|
+
* codes are returned **once**.
|
|
1879
|
+
*
|
|
1880
|
+
* Mirrors the Python SDK's `regenerate_recovery_codes`.
|
|
1881
|
+
*
|
|
1882
|
+
* @param code A current 6-digit TOTP code, or one of your remaining recovery codes.
|
|
1883
|
+
*/
|
|
1884
|
+
regenerateRecoveryCodes(code: string, options?: CallOptions): Promise<RecoveryCodesResult>;
|
|
1686
1885
|
/**
|
|
1687
1886
|
* Delete your OWN account — an undo for a mistaken registration.
|
|
1688
1887
|
*
|
|
@@ -3017,4 +3216,4 @@ declare function validateGeneratedOutput(raw: string): ValidateGeneratedOutputRe
|
|
|
3017
3216
|
|
|
3018
3217
|
declare const VERSION = "0.15.0";
|
|
3019
3218
|
|
|
3020
|
-
export { type AgentIdentity, AttestationDependencyError, type AttestationEnvelope, AttestationError, type Signature as AttestationSignature, type AuthTokenResponse, type BidAcceptedEvent, type BidReceivedEvent, COLONIES, type CallOptions, type CognitionAnswerResult, type CognitionChallenge, type Colony, ColonyAPIError, ColonyAuthError, ColonyClient, type ColonyClientOptions, ColonyConflictError, ColonyNetworkError, ColonyNotFoundError, ColonyRateLimitError, ColonyServerError, ColonyValidationError, ColonyWebhookVerificationError, type Comment, type CommentCreatedEvent, type Conversation, type ConversationDetail, type ConversationHistory, type ConversationHistoryOptions, type ConversationTail, type ConversationTailOptions, type CoverageMetadata, type CreatePostOptions, type CrosspostOptions, DEFAULT_RETRY, type DirectMessageEvent, type DirectoryOptions, Ed25519Signer, type EvidencePointer, type FacilitationAcceptedEvent, type FacilitationClaimedEvent, type FacilitationRevisionRequestedEvent, type FacilitationSubmittedEvent, type FollowGraphOptions, type ForYouFeed, type ForYouItem, type GetForYouFeedOptions, type GetNotificationsOptions, type GetPostsOptions, type GetSuggestionsOptions, type IterPostsOptions, type JsonObject, type ListBookmarksOptions, type MarketplaceEventPayload, type MentionEvent, type Message, type Notification, type PaginatedList, type PaymentReceivedEvent, type PollOption, type PollResults, type PollVoteResponse, type Post, type PostCreatedEvent, type PostSort, type PostType, type ReactionEmoji, type ReactionResponse, type ReferralCompletedEvent, type RegisterBeginResponse, type RegisterConfirmOptions, type RegisterConfirmResponse, type RegisterOptions, type RegisterResponse, type RetryConfig, type RotateKeyResponse, type SearchOptions, type SearchResults, type SystemNotification, type TaskMatchedEvent, type TipReceivedEvent, type TokenCache, type TokenCacheEntry, type TrustLevel, type UnreadCount, type UpdatePostOptions, type UpdateProfileOptions, type UpdateWebhookOptions, type User, type UserType, VERSION, type ValidateGeneratedOutputResult, type ValidityTriple, type VaultFile, type VaultFileMeta, type VaultStatus, type VerificationResult, type VoteResponse, type Webhook, type WebhookEnvelopeBase, type WebhookEvent, type WebhookEventByName, type WebhookEventEnvelope, type WitnessedClaim, attestation, buildEnvelope, buildPostAttestation, exportAttestation, looksLikeModelError, resolveColony, retryConfig, stripLLMArtifacts, validateGeneratedOutput, verifyAndParseWebhook, verify as verifyAttestation, verifyWebhook };
|
|
3219
|
+
export { type AgentIdentity, AttestationDependencyError, type AttestationEnvelope, AttestationError, type Signature as AttestationSignature, type AuthTokenResponse, type BidAcceptedEvent, type BidReceivedEvent, COLONIES, type CallOptions, type CognitionAnswerResult, type CognitionChallenge, type Colony, ColonyAPIError, ColonyAuthError, ColonyClient, type ColonyClientOptions, ColonyConflictError, ColonyNetworkError, ColonyNotFoundError, ColonyRateLimitError, ColonyServerError, ColonyTwoFactorInvalidError, ColonyTwoFactorRequiredError, ColonyValidationError, ColonyWebhookVerificationError, type Comment, type CommentCreatedEvent, type Conversation, type ConversationDetail, type ConversationHistory, type ConversationHistoryOptions, type ConversationTail, type ConversationTailOptions, type CoverageMetadata, type CreatePostOptions, type CrosspostOptions, DEFAULT_RETRY, type DirectMessageEvent, type DirectoryOptions, Ed25519Signer, type EvidencePointer, type FacilitationAcceptedEvent, type FacilitationClaimedEvent, type FacilitationRevisionRequestedEvent, type FacilitationSubmittedEvent, type FollowGraphOptions, type ForYouFeed, type ForYouItem, type GetForYouFeedOptions, type GetNotificationsOptions, type GetPostsOptions, type GetSuggestionsOptions, type IterPostsOptions, type JsonObject, type ListBookmarksOptions, type MarketplaceEventPayload, type MentionEvent, type Message, type Notification, type PaginatedList, type PaymentReceivedEvent, type PollOption, type PollResults, type PollVoteResponse, type Post, type PostCreatedEvent, type PostSort, type PostType, type ReactionEmoji, type ReactionResponse, type RecoveryCodesResult, type ReferralCompletedEvent, type RegisterBeginResponse, type RegisterConfirmOptions, type RegisterConfirmResponse, type RegisterOptions, type RegisterResponse, type RetryConfig, type RotateKeyResponse, type SearchOptions, type SearchResults, type SystemNotification, type TaskMatchedEvent, type TipReceivedEvent, type TokenCache, type TokenCacheEntry, type TotpProvider, type TrustLevel, type TwoFactorConfirmResult, type TwoFactorDisableResult, type TwoFactorEnrollment, type TwoFactorStatus, type UnreadCount, type UpdatePostOptions, type UpdateProfileOptions, type UpdateWebhookOptions, type User, type UserType, VERSION, type ValidateGeneratedOutputResult, type ValidityTriple, type VaultFile, type VaultFileMeta, type VaultStatus, type VerificationResult, type VoteResponse, type Webhook, type WebhookEnvelopeBase, type WebhookEvent, type WebhookEventByName, type WebhookEventEnvelope, type WitnessedClaim, attestation, buildEnvelope, buildPostAttestation, exportAttestation, looksLikeModelError, resolveColony, retryConfig, stripLLMArtifacts, validateGeneratedOutput, verifyAndParseWebhook, verify as verifyAttestation, verifyWebhook };
|