@invisible-labs/sdk 0.9.0-devnet → 0.11.0-devnet

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.
Files changed (38) hide show
  1. package/README.md +25 -5
  2. package/dist/.invisible-sdk-build-target.json +2 -2
  3. package/dist/{chunk-RWKG7N7I.js → chunk-A4R3DHKN.js} +2 -2
  4. package/dist/chunk-A4R3DHKN.js.map +1 -0
  5. package/dist/{chunk-6AKBRYKO.js → chunk-DOTYDYVB.js} +3 -3
  6. package/dist/{chunk-6AKBRYKO.js.map → chunk-DOTYDYVB.js.map} +1 -1
  7. package/dist/{chunk-EOPZVOVP.js → chunk-LVCDODTN.js} +582 -19
  8. package/dist/chunk-LVCDODTN.js.map +1 -0
  9. package/dist/{chunk-QF5TSUQE.js → chunk-M45APS7S.js} +405 -51
  10. package/dist/chunk-M45APS7S.js.map +1 -0
  11. package/dist/{chunk-ISIWWGSR.js → chunk-NOKBFHDP.js} +5 -5
  12. package/dist/{chunk-ISIWWGSR.js.map → chunk-NOKBFHDP.js.map} +1 -1
  13. package/dist/{chunk-HWRMSK7E.js → chunk-TNLSUQGJ.js} +4 -4
  14. package/dist/{chunk-HWRMSK7E.js.map → chunk-TNLSUQGJ.js.map} +1 -1
  15. package/dist/{chunk-EPWTRF5U.js → chunk-TYTVF3A4.js} +3 -3
  16. package/dist/{chunk-EPWTRF5U.js.map → chunk-TYTVF3A4.js.map} +1 -1
  17. package/dist/{chunk-AIKC2XQS.js → chunk-YYTRFM2F.js} +3 -3
  18. package/dist/{chunk-AIKC2XQS.js.map → chunk-YYTRFM2F.js.map} +1 -1
  19. package/dist/coordinator-EQEL23A3.js +4 -0
  20. package/dist/{coordinator-DHL3AP7V.js.map → coordinator-EQEL23A3.js.map} +1 -1
  21. package/dist/events.js +3 -3
  22. package/dist/index.d.ts +4 -4
  23. package/dist/index.js +9 -9
  24. package/dist/index.js.map +1 -1
  25. package/dist/lp.d.ts +46 -5
  26. package/dist/lp.js +675 -212
  27. package/dist/lp.js.map +1 -1
  28. package/dist/stats.js +1 -1
  29. package/dist/storage.js +2 -2
  30. package/dist/{types.generated-DrM2M4DZ.d.ts → types.generated-BpbFQlYB.d.ts} +75 -1
  31. package/dist/user.d.ts +9 -4
  32. package/dist/user.js +53 -22
  33. package/dist/user.js.map +1 -1
  34. package/package.json +2 -2
  35. package/dist/chunk-EOPZVOVP.js.map +0 -1
  36. package/dist/chunk-QF5TSUQE.js.map +0 -1
  37. package/dist/chunk-RWKG7N7I.js.map +0 -1
  38. package/dist/coordinator-DHL3AP7V.js +0 -4
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/errors.ts"],"names":[],"mappings":";AA8DO,IAAM,oCAAA,GAAuC;AAC7C,IAAM,sCAAA,GACX;AA0GK,IAAe,cAAA,GAAf,cAAsC,KAAA,CAAM;AAAA,EAIjD,WAAA,CAAY,SAAiB,OAAA,EAAiC;AAC5D,IAAA,KAAA,CAAM,OAAO,CAAA;AAGb,IAAA,IAAI,OAAA,EAAS,UAAU,MAAA,EAAW;AAChC,MAAC,IAAA,CAA6B,QAAQ,OAAA,CAAQ,KAAA;AAAA,IAChD;AACA,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AAGvB,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF;AAGO,IAAM,gBAAA,GAAN,cAA+B,cAAA,CAAe;AAAA,EAEnD,WAAA,CAAY,IAAA,EAA4B,OAAA,EAAiB,OAAA,EAAiC;AACxF,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AACF;AAGO,IAAM,cAAA,GAAN,cAA6B,cAAA,CAAe;AAAA,EAEjD,WAAA,CAAY,IAAA,EAA0B,OAAA,EAAiB,OAAA,EAAiC;AACtF,IAAA,KAAA,CAAM,S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AA,CAAK,OAAO,CAAA;AACvF","file":"chunk-RWKG7N7I.js","sourcesContent":["/**\n * The closed error taxonomy from docs/sdk-specification.md section 8.3.\n *\n * Every error the SDK throws extends {@link InvisibleError} and carries a\n * `code` drawn from a closed, per-class string-literal union. Consumers can\n * branch on `error instanceof CommandError` and then exhaustively `switch` on\n * `error.code` with compile-time completeness.\n *\n * Error classes are the one deliberate exception to the SDK's \"no classes\"\n * rule: JavaScript errors must extend `Error` to carry a stack and support\n * `instanceof`. This mirrors @solana/kit, whose only class is `SolanaError`.\n * The conformance lint allowlists this file for that reason.\n */\n\n// ---------------------------------------------------------------------------\n// Code unions (closed sets, section 8.3)\n// ---------------------------------------------------------------------------\n\n/** Attestation verification failures. Stop; do not retry without a new pin. */\nexport type AttestationErrorCode =\n | \"CERT_CHAIN_INVALID\"\n | \"TCB_REJECTED\"\n | \"FRESHNESS_NONCE_MISMATCH\"\n | \"NOISE_BINDING_MISMATCH\"\n | \"DEBUG_BIT_SET\"\n | \"MRTD_MISMATCH\"\n | \"RUNTIME_MEASUREMENTS_MISMATCH\"\n | \"RUNTIME_PROFILE_MISMATCH\"\n | \"AZURE_MAA_ISSUER_MISMATCH\"\n | \"AZURE_MAA_JWKS_INVALID\"\n | \"AZURE_MAA_POLICY_HASH_MISMATCH\"\n | \"AZURE_MAA_NOT_COMPLIANT\"\n | \"AZURE_MAA_DCAP_MISMATCH\"\n | \"AZURE_HCL_KEYS_MISMATCH\"\n | \"AZURE_AK_PUB_INVALID\"\n | \"AZURE_TPM_AK_QUOTE_INVALID\"\n | \"AZURE_TPM_QUALIFYING_DATA_MISMATCH\"\n | \"NOT_ATTESTED\";\n\n/** Transport-level failures. Reconnect through the pool and re-attest. */\nexport type TransportErrorCode =\n | \"WS_HANDSHAKE_FAILED\"\n | \"NOISE_HANDSHAKE_FAILED\"\n | \"NOISE_FRAME_TOO_LARGE\"\n | \"CONNECTION_LOST\";\n\n/** Leader/role routing failures. Failover and re-attest. */\nexport type RoutingErrorCode =\n | \"WRONG_ROLE\"\n | \"STALE_LEADER_EPOCH\"\n | \"POOL_DEGRADED\"\n | \"VERSION_NOT_SUPPORTED\";\n\n/** Coordinator-side command rejections. Product decides whether to retry. */\nexport type CommandErrorCode =\n | \"REJECTED_GUARD\"\n | \"REJECTED_STATE\"\n | \"REJECTED_EXPIRED\"\n | \"REJECTED_STALE_JOB\"\n | \"REJECTED_RESOURCE_CAP\"\n | \"RETRYABLE_BUSY\";\n\nexport const COORDINATOR_CAPACITY_FULL_ERROR_CODE = \"ERR_ADMISSION_CAPACITY_FULL\" as const;\nexport const COORDINATOR_CAPACITY_FULL_USER_MESSAGE =\n \"The transfer service is temporarily at capacity. This transfer was not started. Please try again later.\";\n\n/** Coordinator wire error code preserved on command rejections. */\nexport type CoordinatorWireErrorCode =\n | \"ERR_INVALID_PAYLOAD\"\n | \"ERR_UNEXPECTED_TYPE\"\n | \"ERR_UNKNOWN_SWAP\"\n | \"ERR_POLICY_VIOLATION\"\n | \"ERR_INVALID_RECOVERY_CODE\"\n | \"ERR_SWAP_NOT_REFUNDABLE\"\n | \"ERR_DKG_FAILURE\"\n | \"ERR_INTERNAL\"\n | \"ERR_PRESEAL_ADMISSION_BUSY\"\n | \"ERR_INITIALIZATION_BUSY\"\n | typeof COORDINATOR_CAPACITY_FULL_ERROR_CODE\n | \"ERR_INVALID_DEPOSIT\"\n | \"ERR_SETTLEMENT_FAILED\";\n\n/** Local input-validation failures. Never sent on the wire; fix the input. */\nexport type PolicyValidationErrorCode =\n | \"INVALID_PAYOUT_PLAN\"\n | \"INVALID_WITHDRAWAL_PLAN\"\n | \"INVALID_POSITION_AUTH\"\n | \"INVALID_REDEMPTION_PLAN\"\n | \"INVALID_DESTINATION_ADDRESS\"\n | \"INVALID_AMOUNT\";\n\n/** Storage-adapter failures. */\nexport type StorageErrorCode =\n | \"STORAGE_NOT_AVAILABLE\"\n | \"STORAGE_INVALID_ADAPTER\"\n | \"STORAGE_QUOTA_EXCEEDED\"\n | \"STORAGE_KEY_MISSING\"\n | \"STORAGE_DECRYPT_FAILED\";\n\n/** Wallet-adapter failures. Bubble to the integrator UX. */\nexport type WalletErrorCode =\n | \"WALLET_NOT_CONNECTED\"\n | \"WALLET_USER_REJECTED\"\n | \"WALLET_INVALID_SIGNATURE\";\n\n/** LP lifecycle local state that callers can branch on. */\nexport type LpLifecycleErrorCode = \"LP_POSITION_AUTH_MISSING\" | \"LP_REDEMPTION_RECONCILING\";\n\n/** Skeleton-only: a surface that exists but has no implementation yet. */\nexport type NotImplementedErrorCode = \"NOT_IMPLEMENTED\";\n\n/** Every code the SDK can surface, across all classes. */\nexport type InvisibleErrorCode =\n | AttestationErrorCode\n | TransportErrorCode\n | RoutingErrorCode\n | CommandErrorCode\n | PolicyValidationErrorCode\n | StorageErrorCode\n | WalletErrorCode\n | LpLifecycleErrorCode\n | NotImplementedErrorCode;\n\n// ---------------------------------------------------------------------------\n// Error classes\n// ---------------------------------------------------------------------------\n\n/** Options accepted by every {@link InvisibleError}. */\nexport interface InvisibleErrorOptions {\n /** The underlying error, preserved for debugging. */\n readonly cause?: unknown;\n}\n\n/** Context attached to a client-persistence storage failure. */\nexport type StorageErrorPhase =\n | \"session-init\"\n | \"write\"\n | \"allocation\"\n | \"recovery-code\"\n | \"ready\"\n | \"sync\"\n | \"refund\"\n | \"read\"\n | \"remove\"\n | \"purge\";\n\n/** Options accepted by {@link StorageError}. */\nexport interface StorageErrorOptions extends InvisibleErrorOptions {\n /** The affected normal-user swap, when known. */\n readonly swapId?: string;\n /** The client-persistence lifecycle phase that failed. */\n readonly phase?: StorageErrorPhase;\n /** True when the coordinator accepted the command before local failure. */\n readonly remoteAccepted?: boolean;\n}\n\n/** Options accepted by {@link CommandError}. */\nexport interface CommandErrorOptions extends InvisibleErrorOptions {\n /** Exact coordinator `Error` envelope code, when the rejection came from the wire. */\n readonly coordinatorCode?: CoordinatorWireErrorCode;\n /** Exact coordinator `Error` envelope message, when `message` is user-facing copy. */\n readonly coordinatorMessage?: string;\n /** Request id rejected by the coordinator, when present in the `Error` envelope. */\n readonly failedReqId?: number;\n}\n\n/**\n * Base class for every error the SDK throws. Carries a closed `code` and sets\n * `name` to the concrete subclass name so logs and `instanceof` agree.\n */\nexport abstract class InvisibleError extends Error {\n /** The closed error code for this error's class. */\n abstract readonly code: InvisibleErrorCode;\n\n constructor(message: string, options?: InvisibleErrorOptions) {\n super(message);\n // Set `cause` directly rather than through the Error constructor option so\n // the package stays on the ES2020 lib (the option is ES2022).\n if (options?.cause !== undefined) {\n (this as { cause?: unknown }).cause = options.cause;\n }\n this.name = new.target.name;\n // Restore the prototype chain across the transpiled `Error` boundary so\n // `instanceof` works for subclasses.\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Attestation verification failure. */\nexport class AttestationError extends InvisibleError {\n readonly code: AttestationErrorCode;\n constructor(code: AttestationErrorCode, message: string, options?: InvisibleErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Transport-level failure. */\nexport class TransportError extends InvisibleError {\n readonly code: TransportErrorCode;\n constructor(code: TransportErrorCode, message: string, options?: InvisibleErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Leader/role routing failure. */\nexport class RoutingError extends InvisibleError {\n readonly code: RoutingErrorCode;\n constructor(code: RoutingErrorCode, message: string, options?: InvisibleErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Coordinator-side command rejection. */\nexport class CommandError extends InvisibleError {\n readonly code: CommandErrorCode;\n readonly coordinatorCode?: CoordinatorWireErrorCode;\n readonly coordinatorMessage?: string;\n readonly failedReqId?: number;\n\n constructor(code: CommandErrorCode, message: string, options?: CommandErrorOptions) {\n super(message, options);\n this.code = code;\n if (options?.coordinatorCode !== undefined) this.coordinatorCode = options.coordinatorCode;\n if (options?.coordinatorMessage !== undefined)\n this.coordinatorMessage = options.coordinatorMessage;\n if (options?.failedReqId !== undefined) this.failedReqId = options.failedReqId;\n }\n}\n\n/** User deposit did not match the coordinator policy amount. */\nexport class InvalidDepositAmountError extends CommandError {\n readonly receivedLamports: bigint;\n readonly expectedLamports: bigint;\n\n constructor(receivedLamports: bigint, expectedLamports: bigint) {\n super(\n \"REJECTED_GUARD\",\n `on-chain deposit balance ${receivedLamports.toString()} does not match expected ${expectedLamports.toString()} lamports`,\n );\n this.name = \"InvalidDepositAmountError\";\n this.receivedLamports = receivedLamports;\n this.expectedLamports = expectedLamports;\n }\n}\n\n/** Local input-validation failure; never reaches the wire. */\nexport class PolicyValidationError extends InvisibleError {\n readonly code: PolicyValidationErrorCode;\n constructor(code: PolicyValidationErrorCode, message: string, options?: InvisibleErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Storage-adapter failure. */\nexport class StorageError extends InvisibleError {\n readonly code: StorageErrorCode;\n readonly swapId?: string;\n readonly phase?: StorageErrorPhase;\n readonly remoteAccepted?: boolean;\n\n constructor(code: StorageErrorCode, message: string, options?: StorageErrorOptions) {\n super(message, options);\n this.code = code;\n if (options?.swapId !== undefined) this.swapId = options.swapId;\n if (options?.phase !== undefined) this.phase = options.phase;\n if (options?.remoteAccepted !== undefined) this.remoteAccepted = options.remoteAccepted;\n }\n}\n\n/** Wallet-adapter failure. */\nexport class WalletError extends InvisibleError {\n readonly code: WalletErrorCode;\n constructor(code: WalletErrorCode, message: string, options?: InvisibleErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** LP lifecycle state that is local to the SDK client. */\nexport class LpLifecycleError extends InvisibleError {\n readonly code: LpLifecycleErrorCode;\n constructor(code: LpLifecycleErrorCode, message: string, options?: InvisibleErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/**\n * A surface that exists in the typed contract but has no runtime behavior yet.\n * The skeleton throws this from every command that is not the connection layer.\n * The message carries the fully-qualified command name (e.g. `user.contractRequest`).\n */\nexport class NotImplementedError extends InvisibleError {\n readonly code = \"NOT_IMPLEMENTED\" as const;\n /** The command that is not yet implemented, e.g. `lp.redeem`. */\n readonly command: string;\n constructor(command: string, options?: InvisibleErrorOptions) {\n super(`${command} is not implemented in this SDK build`, options);\n this.command = command;\n }\n}\n\n/** Type guard: is `value` any SDK error. */\nexport function isInvisibleError(value: unknown): value is InvisibleError {\n return value instanceof InvisibleError;\n}\n\n// ---------------------------------------------------------------------------\n// Normalization (analog of web/src/lib/user-facing-error.ts)\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_ERROR_MESSAGE = \"Something went wrong. Please try again.\";\n\ninterface MessageLike {\n readonly message?: unknown;\n readonly reason?: unknown;\n readonly error?: unknown;\n readonly code?: unknown;\n}\n\n/**\n * Reduce any thrown value to a readable, single-line message. Guarantees the\n * SDK never surfaces `[object Object]` / `[object ErrorEvent]` (spec section\n * 8.3). For an {@link InvisibleError} the code is prefixed as `[CODE] message`.\n */\nexport function normalizeError(error: unknown, fallback: string = DEFAULT_ERROR_MESSAGE): string {\n const direct = extractMessage(error);\n if (isReadable(direct)) return direct;\n if (isReadable(fallback)) return fallback.trim();\n return DEFAULT_ERROR_MESSAGE;\n}\n\nfunction extractMessage(error: unknown): string | null {\n if (\n error instanceof CommandError &&\n error.coordinatorCode === COORDINATOR_CAPACITY_FULL_ERROR_CODE\n ) {\n return error.message;\n }\n if (error instanceof CommandError && error.coordinatorCode !== undefined) {\n return formatCode(error.coordinatorCode, error.message);\n }\n if (error instanceof InvisibleError) return formatCode(error.code, error.message);\n if (error instanceof Error) return error.message;\n if (typeof error === \"string\") return error;\n if (error === null || error === undefined) return null;\n\n if (isMessageLike(error)) {\n if (typeof error.message === \"string\" && isReadable(error.message)) {\n return formatCode(error.code, error.message);\n }\n const nested = extractMessage(error.error);\n if (isReadable(nested)) return formatCode(error.code, nested);\n const reason = extractMessage(error.reason);\n if (isReadable(reason)) return formatCode(error.code, reason);\n }\n\n return null;\n}\n\nfunction isMessageLike(value: unknown): value is MessageLike {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction formatCode(code: unknown, message: string): string {\n if (typeof code !== \"string\" || code.trim().length === 0) return message.trim();\n const trimmed = code.trim();\n return message.includes(`[${trimmed}]`) ? message.trim() : `[${trimmed}] ${message.trim()}`;\n}\n\nfunction isReadable(value: string | null): value is string {\n if (value === null) return false;\n const trimmed = value.trim();\n if (trimmed.length === 0) return false;\n return !/^\\[object (?:Object|Event|ErrorEvent|PromiseRejectionEvent)\\]$/.test(trimmed);\n}\n"]}
@@ -1,4 +0,0 @@
1
- export { COORDINATOR_BINARY_FIELD_NAMES, COORDINATOR_ENVELOPE_SCHEMA, COORDINATOR_SCHEMA_PAYLOAD_CATEGORIES, CoordinatorError, CoordinatorMessageType, DEFAULT_PAYOUT_WINDOW_ID, DIRECTION_BY_TYPE, ENVELOPE_VERSION, EnvelopeKind, ErrorCode, INITIAL_STATE, MAX_ENCODED_JSON_BYTES_KEYWORD, MAX_FRAME_SIZE, MessageDirection, PAYOUT_WINDOW_OPTIONS, TERMINAL_STATES, TRANSITIONS, VALID_SWAP_STATES, asDelegateAckPayload, asDelegateSharePayload, asDelegateShareResponsePayload, asDepositConfirmedPayload, asDkgCompletePayload, asDkgInitPayload, asDkgInitResponsePayload, asDkgRound1Payload, asDkgRound1ResponsePayload, asDkgRound2Payload, asDkgRound2ResponsePayload, asErrorPayload, asLpCommandResponsePayload, asPayoutExecutedPayload, asSwapRequestPayload, asSwapRequestResponsePayload, asSyncRequiredPayload, asSyncUserRequestPayload, asSyncUserResponsePayload, asWithdrawAcceptedPayload, asWithdrawExecutedPayload, asWithdrawRequestPayload, createCoordinatorSchemaValidator, decode, encode, encodeLpCommandForSigning, encodeValidated, isAllowedInState, isAllowedKindForType, isPayoutWindowId, isValidEnvelopeKind, isValidErrorCode, isValidMessageType, isValidSwapState, lpSignedCommandEnvelope, nextState, payloadCategory, payoutWindowLabelForId, payoutWindowOptionById, safeEncode, scheduledPayoutWindowOptions, scheduledPayoutWindowSeconds } from './chunk-QF5TSUQE.js';
2
- import './chunk-VR6T6OJS.js';
3
- //# sourceMappingURL=coordinator-DHL3AP7V.js.map
4
- //# sourceMappingURL=coordinator-DHL3AP7V.js.map