@usearete/sdk 0.26.0 → 0.27.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/dist/index.cjs +148 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +49 -3
- package/dist/index.esm.js +144 -8
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1273,18 +1273,59 @@ interface SocketIssue {
|
|
|
1273
1273
|
code: string | AuthErrorCode;
|
|
1274
1274
|
retryable: boolean;
|
|
1275
1275
|
retryAfter?: number;
|
|
1276
|
+
usage?: UsageLimit;
|
|
1277
|
+
action?: RecoveryAction;
|
|
1276
1278
|
suggestedAction?: string;
|
|
1277
1279
|
docsUrl?: string;
|
|
1278
1280
|
fatal: boolean;
|
|
1279
1281
|
subscriptionId?: string | null;
|
|
1280
1282
|
}
|
|
1283
|
+
declare const API_PROBLEM_SCHEMA_VERSION: 1;
|
|
1284
|
+
declare const CLAIM_AGENT_MATERIALIZER_PATH: "/api/agents/me/claim-links";
|
|
1285
|
+
interface UsageLimit {
|
|
1286
|
+
readonly unit: string;
|
|
1287
|
+
readonly used: number;
|
|
1288
|
+
readonly limit: number;
|
|
1289
|
+
readonly resetsAt?: string | null;
|
|
1290
|
+
}
|
|
1291
|
+
interface RecoveryAction {
|
|
1292
|
+
readonly type: string;
|
|
1293
|
+
readonly label?: string;
|
|
1294
|
+
readonly method?: string;
|
|
1295
|
+
readonly path?: string;
|
|
1296
|
+
readonly [key: string]: unknown;
|
|
1297
|
+
}
|
|
1298
|
+
interface ApiProblemV1 {
|
|
1299
|
+
readonly schemaVersion?: number;
|
|
1300
|
+
readonly error: string;
|
|
1301
|
+
readonly code?: string;
|
|
1302
|
+
readonly retryable?: boolean;
|
|
1303
|
+
readonly requestId?: string;
|
|
1304
|
+
readonly retryAfterSeconds?: number | null;
|
|
1305
|
+
readonly usage?: UsageLimit;
|
|
1306
|
+
readonly action?: RecoveryAction;
|
|
1307
|
+
readonly [key: string]: unknown;
|
|
1308
|
+
}
|
|
1309
|
+
interface ReadyRecoveryAction {
|
|
1310
|
+
readonly type: string;
|
|
1311
|
+
readonly url: string;
|
|
1312
|
+
readonly elicitationId: string;
|
|
1313
|
+
readonly expiresAt: string;
|
|
1314
|
+
}
|
|
1315
|
+
interface ReadyRecoveryActionV1 {
|
|
1316
|
+
readonly schemaVersion: 1;
|
|
1317
|
+
readonly action: ReadyRecoveryAction;
|
|
1318
|
+
}
|
|
1319
|
+
declare function isClaimAgentRecoveryAction(action: RecoveryAction | undefined): boolean;
|
|
1320
|
+
declare function parseApiProblem(value: unknown): ApiProblemV1 | undefined;
|
|
1321
|
+
declare function isSafeClaimActionUrl(action: ReadyRecoveryAction, expectedOrigin: string): boolean;
|
|
1281
1322
|
declare const DEFAULT_CONFIG: Required<Pick<AreteConfig, 'autoReconnect' | 'reconnectIntervals' | 'maxReconnectAttempts' | 'maxEntriesPerView'>>;
|
|
1282
1323
|
/**
|
|
1283
1324
|
* Machine-readable error codes for authentication and rate limiting failures
|
|
1284
1325
|
*
|
|
1285
1326
|
* These codes match the Rust AuthErrorCode enum for cross-platform consistency.
|
|
1286
1327
|
*/
|
|
1287
|
-
type AuthErrorCode = 'TOKEN_MISSING' | 'TOKEN_EXPIRED' | 'TOKEN_INVALID_SIGNATURE' | 'TOKEN_INVALID_FORMAT' | 'TOKEN_INVALID_ISSUER' | 'TOKEN_INVALID_AUDIENCE' | 'TOKEN_MISSING_CLAIM' | 'TOKEN_KEY_NOT_FOUND' | 'ORIGIN_MISMATCH' | 'ORIGIN_REQUIRED' | 'ORIGIN_NOT_ALLOWED' | 'AUTH_REQUIRED' | 'MISSING_AUTHORIZATION_HEADER' | 'INVALID_AUTHORIZATION_FORMAT' | 'INVALID_API_KEY' | 'EXPIRED_API_KEY' | 'USER_NOT_FOUND' | 'SECRET_KEY_REQUIRED' | 'DEPLOYMENT_ACCESS_DENIED' | 'RATE_LIMIT_EXCEEDED' | 'WEBSOCKET_SESSION_RATE_LIMIT_EXCEEDED' | 'CONNECTION_LIMIT_EXCEEDED' | 'SUBSCRIPTION_LIMIT_EXCEEDED' | 'SNAPSHOT_LIMIT_EXCEEDED' | 'EGRESS_LIMIT_EXCEEDED' | 'QUOTA_EXCEEDED' | 'INVALID_STATIC_TOKEN' | 'STACK_VERSION_RETIRED' | 'STACK_VERSION_UNKNOWN' | 'INTERNAL_ERROR';
|
|
1328
|
+
type AuthErrorCode = 'TOKEN_MISSING' | 'TOKEN_EXPIRED' | 'TOKEN_INVALID_SIGNATURE' | 'TOKEN_INVALID_FORMAT' | 'TOKEN_INVALID_ISSUER' | 'TOKEN_INVALID_AUDIENCE' | 'TOKEN_MISSING_CLAIM' | 'TOKEN_KEY_NOT_FOUND' | 'ORIGIN_MISMATCH' | 'ORIGIN_REQUIRED' | 'ORIGIN_NOT_ALLOWED' | 'AUTH_REQUIRED' | 'MISSING_AUTHORIZATION_HEADER' | 'INVALID_AUTHORIZATION_FORMAT' | 'INVALID_API_KEY' | 'EXPIRED_API_KEY' | 'USER_NOT_FOUND' | 'SECRET_KEY_REQUIRED' | 'DEPLOYMENT_ACCESS_DENIED' | 'RATE_LIMIT_EXCEEDED' | 'WEBSOCKET_SESSION_RATE_LIMIT_EXCEEDED' | 'CONNECTION_LIMIT_EXCEEDED' | 'SUBSCRIPTION_LIMIT_EXCEEDED' | 'SNAPSHOT_LIMIT_EXCEEDED' | 'EGRESS_LIMIT_EXCEEDED' | 'QUOTA_EXCEEDED' | 'AGENT_CLAIM_REQUIRED' | 'INVALID_STATIC_TOKEN' | 'STACK_VERSION_RETIRED' | 'STACK_VERSION_UNKNOWN' | 'INTERNAL_ERROR';
|
|
1288
1329
|
/**
|
|
1289
1330
|
* Structured fields of a `STACK_VERSION_RETIRED` / `STACK_VERSION_UNKNOWN`
|
|
1290
1331
|
* session refusal, carried on {@link AreteError.details} alongside `status`,
|
|
@@ -1324,6 +1365,9 @@ declare class AreteError extends Error {
|
|
|
1324
1365
|
code: string | AuthErrorCode;
|
|
1325
1366
|
details?: unknown | undefined;
|
|
1326
1367
|
constructor(message: string, code: string | AuthErrorCode, details?: unknown | undefined);
|
|
1368
|
+
apiProblem(): ApiProblemV1 | undefined;
|
|
1369
|
+
recoveryAction(): RecoveryAction | undefined;
|
|
1370
|
+
retryAfter(): number | undefined;
|
|
1327
1371
|
}
|
|
1328
1372
|
type TypedViews<TViews extends StackDefinition['views']> = {
|
|
1329
1373
|
[K in keyof TViews]: TypedViewGroup<TViews[K]>;
|
|
@@ -1458,6 +1502,8 @@ interface ErrorFrame {
|
|
|
1458
1502
|
replayWindow?: ReplayWindow;
|
|
1459
1503
|
/** Present on `replay-lagged`: cursor of the last record delivered before the gap. */
|
|
1460
1504
|
recoverFrom?: string;
|
|
1505
|
+
usage?: UsageLimit;
|
|
1506
|
+
action?: RecoveryAction;
|
|
1461
1507
|
}
|
|
1462
1508
|
type Frame<T = unknown> = EntityFrame<T> | SnapshotFrame<T> | SubscribedFrame | UnsubscribedFrame | ErrorFrame;
|
|
1463
1509
|
declare function isSnapshotFrame<T>(frame: Frame<T>): frame is SnapshotFrame<T>;
|
|
@@ -2968,5 +3014,5 @@ declare const Arete: typeof Arete$1 & {
|
|
|
2968
3014
|
session: typeof createSession;
|
|
2969
3015
|
};
|
|
2970
3016
|
|
|
2971
|
-
export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_INITIAL_DATA_TIMEOUT_MS, DEFAULT_MAX_ENTRIES_PER_VIEW, EXTENSION_API_VERSION, FrameProcessor, InitialDataTimeoutError, InstructionError, MemoryAdapter, OPERATION_KIND, OperationCallbackError, OperationExecutionError, PROGRAM_KEY_CONFLICT, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, StreamGapError, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TRANSACTION_RESOURCE_OPTION_KEYS, TransactionExecutionError, TransactionOptionsError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, compareProgramIdentity, createChainClient, createEntityStream, createHostedSolanaGatewayTransports, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getOperationKind, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, hostedWebsocketSuffixes, inspectPreparedOperation, instructionOperation, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isReplayErrorCode, isSameProgramSdk, isSnapshotFrame, isStackVersionRefusalCode, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, resolveTransactionBuildOptions, safeToRawAmount, serializeInstructionData, serializeViewKey, setHostedWebsocketSuffixes, stackQuery, stringifyBigints, toJsonValue, toRawAmount, toWireResourceOptions, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateProgramReadDescriptor, validateSubscriptionId, withProgramIdentity, withProgramRead, withPrograms };
|
|
2972
|
-
export type { AccountCategory, AccountLoader, AccountMeta, AccountResolutionOptions, AccountResolutionResult, AmountInput, AnyOperation, AreteConfig, AreteOptions, AreteOptionsWithStorage, ArgSchema, ArgType, AuthConfig, AuthTokenRequest, AuthTokenResult, AuthTokenTarget, BuildOptions, BuiltAccountMeta, BuiltInstruction, ChainClient, ChainClock, ChainFailedTransactionOutcome, CompositionSessionOptions, ConfirmationLevel, ConfirmedTransactionOutcome, ConnectOptions, ConnectedArete, ConnectedStackClient, ConnectionState, ConnectionStateCallback, ContextSlotOptions, CreatePreparedFlowInput, CreatePreparedInstructionInput, CreatePreparedTransactionInput, DefaultViewKey, EntityFrame, ErrorFrame, ErrorMetadata, ExecuteOptions, ExecutionResult, ExtendedProgramDefinition, ExtendedStackDefinition, FlowOperation, FlowOperationNamespace, FlowOperationReceipt, Frame, FrameMode, FrameOp, FrameProcessorConfig, FrameValidationDiagnostic, GetOptions, HostedSolanaGatewayBindings, HostedSolanaGatewayCapabilityBinding, HostedSolanaGatewayTransportOptions, HostedSolanaGatewayTransports, HttpAuthMetadata, InstructionExecutor, InstructionHandler, InstructionHandlerConfig, InstructionOperation, InstructionOperationNamespace, JsonObject, JsonPrimitive, JsonValue, LatestBlockhashResult, MergeProgramMaps, MintAccountInfo, NativeBalanceInfo, NonEmptyReadonlyArray, NotSubmittedTransactionOutcome, OperationCallbackPhase, OperationExecutionEvent, OperationExecutionHost, OperationExecutionOptions, OperationExecutionSuccessEvent, OperationInspection, OperationInspectionOptions, OperationKind, OperationKindBrand, OperationNamespace, OperationPlan, OperationReceiptFor, OperationTransactionReceipt, PdaConfig, PdaDeriveContext, PdaFactory, PdaProgram, PdaProgramSelector, PdaSeed, PreparedFlow, PreparedInstruction, PreparedOperation, PreparedOperationDescription, PreparedTransaction, PreparedTransactionBody, PreparedTransactionInstruction, PreparedTransactionOperation, ProgramAccountBatchItem, ProgramAccountBatchResult, ProgramAccountReadDefinition, ProgramError, ProgramExtensionInput, ProgramIdentityMatch, ProgramInterface, ProgramOperationContext, ProgramOperations, ProgramOperationsOf, ProgramPdas, ProgramQueryDefinition, ProgramReadBinding, ProgramReadBindingAuthTarget, ProgramReadDescriptor, ProgramReadDescriptors, ProgramReadOf, ProgramReadOverride, ProgramReadOverrides, ProgramReadRequest, ProgramReadTransport, ProgramReleaseReference, ProgramRuntimeExtensionCarrier, ProgramRuntimeExtensions, ProgramSdkDefinition, ProgramSdkIdentity, ProgramsInterface, QueriesInterface, QueryLease, QuerySnapshot, RawAccountInfo, RawInstructionsInterface, RawProgramsInterface, ReadArgumentCount, ReadArgumentCounts, ReadTransportMethod, ReplayErrorCode, ReplayWindow, ResolvedAccount, ResolvedAccounts, ResolvedTransactionBuildOptions, ResolvedTransactionResourceOptions, ResourceLamports, ResourceUnits, RichUpdate, RichUpdateCallback, Schema, SchemaResult, SeedDef, SendOptions, SendResult, Session, SessionDefinition, SessionMemberOptions, SessionOptions, SignerRegistry, SingleTransactionOperationReceipt, SnapshotEntity, SnapshotFrame, SocketIssue, SocketIssueCallback, SolanaGatewayAuthMetadata, SolanaGatewayAuthScope, SolanaGatewayBindingAuthTarget, SortConfig, SortOrder, StackConnectedExtensions, StackDefinition, StackEndpoints, StackExtensionClient, StackExtensionInput, StackQueryDefinition, StackRelease, StackRuntimeExtensionCarrier, StackRuntimeExtensions, StackVersionRefusal, StackWithAttachedPrograms, StorageAdapter, StorageAdapterConfig, StringifiedBigints, SubmittedUnknownTransactionOutcome, SubscribeCallback, SubscribedFrame, Subscription, SubscriptionIdentity, SubscriptionOptions, SubscriptionQuery, SubscriptionRequest, SubscriptionSnapshotOptions, TokenAccountInfo, TokenBalanceInfo, TokenBalanceInput, TransactionBuildCapability, TransactionBuildOptions, TransactionCommitment, TransactionFailureOutcome, TransactionFailurePhase, TransactionFailureStatus, TransactionFeeResult, TransactionInspectionOptions, TransactionInspectionResult, TransactionOperation, TransactionOperationNamespace, TransactionOptions, TransactionOptionsErrorCode, TransactionOutcome, TransactionRequestContext, TransactionResourceOptionKey, TransactionResourceOptions, TransactionSendOptions, TransactionSendResult, TransactionSignatureStatus, TransactionSimulationOptions, TransactionSimulationResult, TransactionTransport, TransactionTransportErrorBody, TransactionVersion, TypedAccountReader, TypedInstruction, TypedListView, TypedQueryExecutor, TypedStateView, TypedViewGroup, TypedViews, UnsubscribeFn, UnsubscribedFrame, Update, UpdateCallback, ViewDef, ViewGroup, ViewKeyFields, ViewKeyValue, ViewSortConfig, WaitForProcessedSlotOptions, WalletAdapter, WalletConnectOptions, WalletExecutionContext, WalletState, WatchOptions, WebSocketFactoryInit };
|
|
3017
|
+
export { API_PROBLEM_SCHEMA_VERSION, ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, CLAIM_AGENT_MATERIALIZER_PATH, ConnectionManager, DEFAULT_CONFIG, DEFAULT_INITIAL_DATA_TIMEOUT_MS, DEFAULT_MAX_ENTRIES_PER_VIEW, EXTENSION_API_VERSION, FrameProcessor, InitialDataTimeoutError, InstructionError, MemoryAdapter, OPERATION_KIND, OperationCallbackError, OperationExecutionError, PROGRAM_KEY_CONFLICT, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, StreamGapError, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TRANSACTION_RESOURCE_OPTION_KEYS, TransactionExecutionError, TransactionOptionsError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, compareProgramIdentity, createChainClient, createEntityStream, createHostedSolanaGatewayTransports, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getOperationKind, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, hostedWebsocketSuffixes, inspectPreparedOperation, instructionOperation, isClaimAgentRecoveryAction, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isReplayErrorCode, isSafeClaimActionUrl, isSameProgramSdk, isSnapshotFrame, isStackVersionRefusalCode, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseApiProblem, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, resolveTransactionBuildOptions, safeToRawAmount, serializeInstructionData, serializeViewKey, setHostedWebsocketSuffixes, stackQuery, stringifyBigints, toJsonValue, toRawAmount, toWireResourceOptions, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateProgramReadDescriptor, validateSubscriptionId, withProgramIdentity, withProgramRead, withPrograms };
|
|
3018
|
+
export type { AccountCategory, AccountLoader, AccountMeta, AccountResolutionOptions, AccountResolutionResult, AmountInput, AnyOperation, ApiProblemV1, AreteConfig, AreteOptions, AreteOptionsWithStorage, ArgSchema, ArgType, AuthConfig, AuthTokenRequest, AuthTokenResult, AuthTokenTarget, BuildOptions, BuiltAccountMeta, BuiltInstruction, ChainClient, ChainClock, ChainFailedTransactionOutcome, CompositionSessionOptions, ConfirmationLevel, ConfirmedTransactionOutcome, ConnectOptions, ConnectedArete, ConnectedStackClient, ConnectionState, ConnectionStateCallback, ContextSlotOptions, CreatePreparedFlowInput, CreatePreparedInstructionInput, CreatePreparedTransactionInput, DefaultViewKey, EntityFrame, ErrorFrame, ErrorMetadata, ExecuteOptions, ExecutionResult, ExtendedProgramDefinition, ExtendedStackDefinition, FlowOperation, FlowOperationNamespace, FlowOperationReceipt, Frame, FrameMode, FrameOp, FrameProcessorConfig, FrameValidationDiagnostic, GetOptions, HostedSolanaGatewayBindings, HostedSolanaGatewayCapabilityBinding, HostedSolanaGatewayTransportOptions, HostedSolanaGatewayTransports, HttpAuthMetadata, InstructionExecutor, InstructionHandler, InstructionHandlerConfig, InstructionOperation, InstructionOperationNamespace, JsonObject, JsonPrimitive, JsonValue, LatestBlockhashResult, MergeProgramMaps, MintAccountInfo, NativeBalanceInfo, NonEmptyReadonlyArray, NotSubmittedTransactionOutcome, OperationCallbackPhase, OperationExecutionEvent, OperationExecutionHost, OperationExecutionOptions, OperationExecutionSuccessEvent, OperationInspection, OperationInspectionOptions, OperationKind, OperationKindBrand, OperationNamespace, OperationPlan, OperationReceiptFor, OperationTransactionReceipt, PdaConfig, PdaDeriveContext, PdaFactory, PdaProgram, PdaProgramSelector, PdaSeed, PreparedFlow, PreparedInstruction, PreparedOperation, PreparedOperationDescription, PreparedTransaction, PreparedTransactionBody, PreparedTransactionInstruction, PreparedTransactionOperation, ProgramAccountBatchItem, ProgramAccountBatchResult, ProgramAccountReadDefinition, ProgramError, ProgramExtensionInput, ProgramIdentityMatch, ProgramInterface, ProgramOperationContext, ProgramOperations, ProgramOperationsOf, ProgramPdas, ProgramQueryDefinition, ProgramReadBinding, ProgramReadBindingAuthTarget, ProgramReadDescriptor, ProgramReadDescriptors, ProgramReadOf, ProgramReadOverride, ProgramReadOverrides, ProgramReadRequest, ProgramReadTransport, ProgramReleaseReference, ProgramRuntimeExtensionCarrier, ProgramRuntimeExtensions, ProgramSdkDefinition, ProgramSdkIdentity, ProgramsInterface, QueriesInterface, QueryLease, QuerySnapshot, RawAccountInfo, RawInstructionsInterface, RawProgramsInterface, ReadArgumentCount, ReadArgumentCounts, ReadTransportMethod, ReadyRecoveryAction, ReadyRecoveryActionV1, RecoveryAction, ReplayErrorCode, ReplayWindow, ResolvedAccount, ResolvedAccounts, ResolvedTransactionBuildOptions, ResolvedTransactionResourceOptions, ResourceLamports, ResourceUnits, RichUpdate, RichUpdateCallback, Schema, SchemaResult, SeedDef, SendOptions, SendResult, Session, SessionDefinition, SessionMemberOptions, SessionOptions, SignerRegistry, SingleTransactionOperationReceipt, SnapshotEntity, SnapshotFrame, SocketIssue, SocketIssueCallback, SolanaGatewayAuthMetadata, SolanaGatewayAuthScope, SolanaGatewayBindingAuthTarget, SortConfig, SortOrder, StackConnectedExtensions, StackDefinition, StackEndpoints, StackExtensionClient, StackExtensionInput, StackQueryDefinition, StackRelease, StackRuntimeExtensionCarrier, StackRuntimeExtensions, StackVersionRefusal, StackWithAttachedPrograms, StorageAdapter, StorageAdapterConfig, StringifiedBigints, SubmittedUnknownTransactionOutcome, SubscribeCallback, SubscribedFrame, Subscription, SubscriptionIdentity, SubscriptionOptions, SubscriptionQuery, SubscriptionRequest, SubscriptionSnapshotOptions, TokenAccountInfo, TokenBalanceInfo, TokenBalanceInput, TransactionBuildCapability, TransactionBuildOptions, TransactionCommitment, TransactionFailureOutcome, TransactionFailurePhase, TransactionFailureStatus, TransactionFeeResult, TransactionInspectionOptions, TransactionInspectionResult, TransactionOperation, TransactionOperationNamespace, TransactionOptions, TransactionOptionsErrorCode, TransactionOutcome, TransactionRequestContext, TransactionResourceOptionKey, TransactionResourceOptions, TransactionSendOptions, TransactionSendResult, TransactionSignatureStatus, TransactionSimulationOptions, TransactionSimulationResult, TransactionTransport, TransactionTransportErrorBody, TransactionVersion, TypedAccountReader, TypedInstruction, TypedListView, TypedQueryExecutor, TypedStateView, TypedViewGroup, TypedViews, UnsubscribeFn, UnsubscribedFrame, Update, UpdateCallback, UsageLimit, ViewDef, ViewGroup, ViewKeyFields, ViewKeyValue, ViewSortConfig, WaitForProcessedSlotOptions, WalletAdapter, WalletConnectOptions, WalletExecutionContext, WalletState, WatchOptions, WebSocketFactoryInit };
|
package/dist/index.esm.js
CHANGED
|
@@ -2,6 +2,97 @@ import { inflate } from 'pako';
|
|
|
2
2
|
import { Buffer } from 'buffer';
|
|
3
3
|
|
|
4
4
|
const DEFAULT_MAX_ENTRIES_PER_VIEW = 10000;
|
|
5
|
+
const API_PROBLEM_SCHEMA_VERSION = 1;
|
|
6
|
+
const CLAIM_AGENT_MATERIALIZER_PATH = '/api/agents/me/claim-links';
|
|
7
|
+
function isRecord$1(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function isSafeUnsignedInteger(value) {
|
|
11
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
|
|
12
|
+
}
|
|
13
|
+
function parseUsageLimit(value) {
|
|
14
|
+
if (!isRecord$1(value)
|
|
15
|
+
|| typeof value['unit'] !== 'string'
|
|
16
|
+
|| !isSafeUnsignedInteger(value['used'])
|
|
17
|
+
|| !isSafeUnsignedInteger(value['limit'])
|
|
18
|
+
|| (value['resetsAt'] !== undefined
|
|
19
|
+
&& value['resetsAt'] !== null
|
|
20
|
+
&& typeof value['resetsAt'] !== 'string')) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
unit: value['unit'],
|
|
25
|
+
used: value['used'],
|
|
26
|
+
limit: value['limit'],
|
|
27
|
+
...(value['resetsAt'] !== undefined ? { resetsAt: value['resetsAt'] } : {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function parseRecoveryAction(value) {
|
|
31
|
+
if (!isRecord$1(value) || typeof value['type'] !== 'string') {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
if ((value['label'] !== undefined && typeof value['label'] !== 'string')
|
|
35
|
+
|| (value['method'] !== undefined && typeof value['method'] !== 'string')
|
|
36
|
+
|| (value['path'] !== undefined && typeof value['path'] !== 'string')) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function isClaimAgentRecoveryAction(action) {
|
|
42
|
+
return action?.type === 'claim_agent'
|
|
43
|
+
&& action.method === 'POST'
|
|
44
|
+
&& action.path === CLAIM_AGENT_MATERIALIZER_PATH;
|
|
45
|
+
}
|
|
46
|
+
function parseApiProblem(value) {
|
|
47
|
+
if (!isRecord$1(value) || typeof value['error'] !== 'string') {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
if (value['schemaVersion'] !== undefined
|
|
51
|
+
&& (!isSafeUnsignedInteger(value['schemaVersion']) || value['schemaVersion'] < 1)) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if ((value['code'] !== undefined && typeof value['code'] !== 'string')
|
|
55
|
+
|| (value['retryable'] !== undefined && typeof value['retryable'] !== 'boolean')
|
|
56
|
+
|| (value['requestId'] !== undefined && typeof value['requestId'] !== 'string')
|
|
57
|
+
|| (value['retryAfterSeconds'] !== undefined
|
|
58
|
+
&& value['retryAfterSeconds'] !== null
|
|
59
|
+
&& !isSafeUnsignedInteger(value['retryAfterSeconds']))) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const usage = value['usage'] === undefined ? undefined : parseUsageLimit(value['usage']);
|
|
63
|
+
const action = value['action'] === undefined ? undefined : parseRecoveryAction(value['action']);
|
|
64
|
+
if ((value['usage'] !== undefined && !usage) || (value['action'] !== undefined && !action)) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
...value,
|
|
69
|
+
error: value['error'],
|
|
70
|
+
...(usage ? { usage } : {}),
|
|
71
|
+
...(action ? { action } : {}),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function isSafeClaimActionUrl(action, expectedOrigin) {
|
|
75
|
+
if (action.type !== 'claim_agent')
|
|
76
|
+
return false;
|
|
77
|
+
try {
|
|
78
|
+
const url = new URL(action.url);
|
|
79
|
+
const origin = new URL(expectedOrigin);
|
|
80
|
+
const loopback = url.hostname === 'localhost'
|
|
81
|
+
|| url.hostname === '127.0.0.1'
|
|
82
|
+
|| url.hostname === '[::1]';
|
|
83
|
+
const secure = url.protocol === 'https:' || (url.protocol === 'http:' && loopback);
|
|
84
|
+
return secure
|
|
85
|
+
&& url.origin === origin.origin
|
|
86
|
+
&& url.username === ''
|
|
87
|
+
&& url.password === ''
|
|
88
|
+
&& url.pathname === '/claim'
|
|
89
|
+
&& url.search === ''
|
|
90
|
+
&& url.hash.length > 1;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
5
96
|
const DEFAULT_CONFIG = {
|
|
6
97
|
autoReconnect: true,
|
|
7
98
|
reconnectIntervals: [1000, 2000, 4000, 8000, 16000],
|
|
@@ -43,6 +134,17 @@ class AreteError extends Error {
|
|
|
43
134
|
this.details = details;
|
|
44
135
|
this.name = 'AreteError';
|
|
45
136
|
}
|
|
137
|
+
apiProblem() {
|
|
138
|
+
if (!isRecord$1(this.details))
|
|
139
|
+
return undefined;
|
|
140
|
+
return parseApiProblem(this.details['apiProblem']);
|
|
141
|
+
}
|
|
142
|
+
recoveryAction() {
|
|
143
|
+
return this.apiProblem()?.action;
|
|
144
|
+
}
|
|
145
|
+
retryAfter() {
|
|
146
|
+
return this.apiProblem()?.retryAfterSeconds ?? undefined;
|
|
147
|
+
}
|
|
46
148
|
}
|
|
47
149
|
/**
|
|
48
150
|
* Parse a kebab-case error code string (from X-Error-Code header) to AuthErrorCode.
|
|
@@ -107,6 +209,7 @@ const AUTH_ERROR_CODES_BY_WIRE = {
|
|
|
107
209
|
'secret-key-required': 'SECRET_KEY_REQUIRED',
|
|
108
210
|
'deployment-access-denied': 'DEPLOYMENT_ACCESS_DENIED',
|
|
109
211
|
'quota-exceeded': 'QUOTA_EXCEEDED',
|
|
212
|
+
'agent-claim-required': 'AGENT_CLAIM_REQUIRED',
|
|
110
213
|
'stack-version-retired': 'STACK_VERSION_RETIRED',
|
|
111
214
|
'stack-version-unknown': 'STACK_VERSION_UNKNOWN',
|
|
112
215
|
};
|
|
@@ -1185,9 +1288,11 @@ class ConnectionManager {
|
|
|
1185
1288
|
if (!response.ok) {
|
|
1186
1289
|
const rawError = await response.text();
|
|
1187
1290
|
let parsedError;
|
|
1291
|
+
let parsedValue;
|
|
1188
1292
|
if (rawError) {
|
|
1189
1293
|
try {
|
|
1190
|
-
|
|
1294
|
+
parsedValue = JSON.parse(rawError);
|
|
1295
|
+
parsedError = parsedValue;
|
|
1191
1296
|
}
|
|
1192
1297
|
catch {
|
|
1193
1298
|
parsedError = undefined;
|
|
@@ -1203,19 +1308,32 @@ class ConnectionManager {
|
|
|
1203
1308
|
const errorMessage = typeof parsedError?.error === 'string' && parsedError.error.length > 0
|
|
1204
1309
|
? parsedError.error
|
|
1205
1310
|
: rawError || response.statusText || 'Authentication request failed';
|
|
1311
|
+
const retryAfterHeader = response.headers.get('Retry-After');
|
|
1312
|
+
const retryAfterSeconds = retryAfterHeader && /^\d+$/.test(retryAfterHeader)
|
|
1313
|
+
? Number(retryAfterHeader)
|
|
1314
|
+
: undefined;
|
|
1315
|
+
const parsedProblem = parseApiProblem(parsedValue);
|
|
1316
|
+
const apiProblem = parsedProblem
|
|
1317
|
+
? {
|
|
1318
|
+
...parsedProblem,
|
|
1319
|
+
...(retryAfterSeconds !== undefined ? { retryAfterSeconds } : {}),
|
|
1320
|
+
}
|
|
1321
|
+
: undefined;
|
|
1206
1322
|
if (isStackVersionRefusalCode(errorCode)) {
|
|
1207
1323
|
const refusal = parseStackVersionRefusal(parsedError);
|
|
1208
1324
|
throw new AreteError(describeStackVersionRefusal(`Token endpoint returned ${response.status}: ${errorMessage}`, refusal), errorCode, {
|
|
1209
1325
|
status: response.status,
|
|
1210
1326
|
wireErrorCode,
|
|
1211
1327
|
responseBody: rawError || null,
|
|
1328
|
+
apiProblem,
|
|
1212
1329
|
...refusal,
|
|
1213
1330
|
});
|
|
1214
1331
|
}
|
|
1215
1332
|
throw new AreteError(`Token endpoint returned ${response.status}: ${errorMessage}`, errorCode, {
|
|
1216
1333
|
status: response.status,
|
|
1217
1334
|
wireErrorCode,
|
|
1218
|
-
|
|
1335
|
+
apiProblem,
|
|
1336
|
+
retryAfterSeconds,
|
|
1219
1337
|
});
|
|
1220
1338
|
}
|
|
1221
1339
|
const data = (await response.json());
|
|
@@ -1476,6 +1594,8 @@ class ConnectionManager {
|
|
|
1476
1594
|
code: parseWireErrorCode(message.code),
|
|
1477
1595
|
retryable: message.retryable ?? false,
|
|
1478
1596
|
retryAfter: message.retryAfter ?? message.retry_after,
|
|
1597
|
+
usage: message.usage,
|
|
1598
|
+
action: message.action,
|
|
1479
1599
|
suggestedAction: message.suggestedAction ?? message.suggested_action,
|
|
1480
1600
|
docsUrl: message.docsUrl ?? message.docs_url,
|
|
1481
1601
|
fatal: message.fatal,
|
|
@@ -1837,7 +1957,12 @@ class ConnectionManager {
|
|
|
1837
1957
|
* with the `reconnecting` state and kept for the terminal error if the
|
|
1838
1958
|
* attempts run out, so a server's close reason is never dropped.
|
|
1839
1959
|
*/
|
|
1840
|
-
handleReconnect(
|
|
1960
|
+
handleReconnect(error) {
|
|
1961
|
+
const reason = typeof error === 'string'
|
|
1962
|
+
? error
|
|
1963
|
+
: error instanceof Error
|
|
1964
|
+
? error.message
|
|
1965
|
+
: undefined;
|
|
1841
1966
|
if (reason !== undefined) {
|
|
1842
1967
|
this.lastDisconnectReason = reason;
|
|
1843
1968
|
}
|
|
@@ -1845,6 +1970,13 @@ class ConnectionManager {
|
|
|
1845
1970
|
this.updateState('error', 'Automatic reconnection is disabled');
|
|
1846
1971
|
return;
|
|
1847
1972
|
}
|
|
1973
|
+
if (error instanceof AreteError) {
|
|
1974
|
+
const problem = error.apiProblem();
|
|
1975
|
+
if (problem?.action || problem?.retryable === false) {
|
|
1976
|
+
this.updateState('error', error.message);
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1848
1980
|
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
1849
1981
|
const lastReason = this.lastDisconnectReason;
|
|
1850
1982
|
this.updateState('error', `Max reconnection attempts (${this.reconnectAttempts}) reached`
|
|
@@ -1853,14 +1985,18 @@ class ConnectionManager {
|
|
|
1853
1985
|
}
|
|
1854
1986
|
this.updateState('reconnecting', this.lastDisconnectReason);
|
|
1855
1987
|
const attemptIndex = Math.min(this.reconnectAttempts, this.reconnectIntervals.length - 1);
|
|
1856
|
-
const
|
|
1988
|
+
const configuredDelay = this.reconnectIntervals[attemptIndex] ?? 1000;
|
|
1989
|
+
const serverDelay = error instanceof AreteError
|
|
1990
|
+
? (error.retryAfter() ?? 0) * 1000
|
|
1991
|
+
: 0;
|
|
1992
|
+
const delay = Math.max(configuredDelay, serverDelay);
|
|
1857
1993
|
this.reconnectAttempts++;
|
|
1858
1994
|
this.reconnectTimeout = setTimeout(() => {
|
|
1859
|
-
this.connect(true).catch((
|
|
1995
|
+
this.connect(true).catch((connectError) => {
|
|
1860
1996
|
// Once a socket exists, its close event owns the next retry. Token
|
|
1861
1997
|
// acquisition and socket construction can fail before that point.
|
|
1862
1998
|
if (this.ws === null && this.currentState !== 'disconnected') {
|
|
1863
|
-
this.recoverFromFailedConnect(
|
|
1999
|
+
this.recoverFromFailedConnect(connectError);
|
|
1864
2000
|
}
|
|
1865
2001
|
});
|
|
1866
2002
|
}, delay);
|
|
@@ -1871,7 +2007,7 @@ class ConnectionManager {
|
|
|
1871
2007
|
// connect() already reported the refusal as the terminal error state.
|
|
1872
2008
|
return;
|
|
1873
2009
|
}
|
|
1874
|
-
this.handleReconnect(error
|
|
2010
|
+
this.handleReconnect(error);
|
|
1875
2011
|
}
|
|
1876
2012
|
clearReconnectTimeout() {
|
|
1877
2013
|
if (this.reconnectTimeout) {
|
|
@@ -8661,5 +8797,5 @@ function stringifyBigints(value) {
|
|
|
8661
8797
|
|
|
8662
8798
|
const Arete = Object.assign(Arete$1, { session: createSession });
|
|
8663
8799
|
|
|
8664
|
-
export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_INITIAL_DATA_TIMEOUT_MS, DEFAULT_MAX_ENTRIES_PER_VIEW, EXTENSION_API_VERSION, FrameProcessor, InitialDataTimeoutError, InstructionError, MemoryAdapter, OPERATION_KIND, OperationCallbackError, OperationExecutionError, PROGRAM_KEY_CONFLICT, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, StreamGapError, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TRANSACTION_RESOURCE_OPTION_KEYS, TransactionExecutionError, TransactionOptionsError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, compareProgramIdentity, createChainClient, createEntityStream, createHostedSolanaGatewayTransports, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getOperationKind, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, hostedWebsocketSuffixes, inspectPreparedOperation, instructionOperation, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isReplayErrorCode, isSameProgramSdk, isSnapshotFrame, isStackVersionRefusalCode, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, resolveTransactionBuildOptions, safeToRawAmount, serializeInstructionData, serializeViewKey, setHostedWebsocketSuffixes, stackQuery, stringifyBigints, toJsonValue, toRawAmount, toWireResourceOptions, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateProgramReadDescriptor, validateSubscriptionId, withProgramIdentity, withProgramRead, withPrograms };
|
|
8800
|
+
export { API_PROBLEM_SCHEMA_VERSION, ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, CLAIM_AGENT_MATERIALIZER_PATH, ConnectionManager, DEFAULT_CONFIG, DEFAULT_INITIAL_DATA_TIMEOUT_MS, DEFAULT_MAX_ENTRIES_PER_VIEW, EXTENSION_API_VERSION, FrameProcessor, InitialDataTimeoutError, InstructionError, MemoryAdapter, OPERATION_KIND, OperationCallbackError, OperationExecutionError, PROGRAM_KEY_CONFLICT, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, StreamGapError, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TRANSACTION_RESOURCE_OPTION_KEYS, TransactionExecutionError, TransactionOptionsError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, compareProgramIdentity, createChainClient, createEntityStream, createHostedSolanaGatewayTransports, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getOperationKind, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, hostedWebsocketSuffixes, inspectPreparedOperation, instructionOperation, isClaimAgentRecoveryAction, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isReplayErrorCode, isSafeClaimActionUrl, isSameProgramSdk, isSnapshotFrame, isStackVersionRefusalCode, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseApiProblem, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, resolveTransactionBuildOptions, safeToRawAmount, serializeInstructionData, serializeViewKey, setHostedWebsocketSuffixes, stackQuery, stringifyBigints, toJsonValue, toRawAmount, toWireResourceOptions, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateProgramReadDescriptor, validateSubscriptionId, withProgramIdentity, withProgramRead, withPrograms };
|
|
8665
8801
|
//# sourceMappingURL=index.esm.js.map
|