@outlayer/sdk 0.1.0-alpha.2 → 0.1.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +17 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -1
- package/dist/index.d.ts +144 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/spec/openapi.yaml +121 -0
package/dist/index.cjs
CHANGED
|
@@ -368,6 +368,23 @@ var OutlayerClient = class {
|
|
|
368
368
|
this.retry
|
|
369
369
|
);
|
|
370
370
|
}
|
|
371
|
+
// ------- Cross-chain deposit (1Click) -------
|
|
372
|
+
/**
|
|
373
|
+
* Create a one-time deposit address on a source chain. Send funds there,
|
|
374
|
+
* then poll {@link getDepositStatus} until `success`.
|
|
375
|
+
*/
|
|
376
|
+
createDepositIntent(opts) {
|
|
377
|
+
return runWithRetry(
|
|
378
|
+
() => this.client.POST("/wallet/v1/deposit-intent", { body: opts }),
|
|
379
|
+
this.retry
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
getDepositStatus(intentId) {
|
|
383
|
+
return runWithRetry(
|
|
384
|
+
() => this.client.GET("/wallet/v1/deposit-status", { params: { query: { id: intentId } } }),
|
|
385
|
+
this.retry
|
|
386
|
+
);
|
|
387
|
+
}
|
|
371
388
|
// ------- Async request tracking -------
|
|
372
389
|
getRequest(id) {
|
|
373
390
|
return runWithRetry(
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/client.ts"],"names":["createClient"],"mappings":";;;;;;;;;;;AAkBO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAC9B,IAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,IAAA,EAA4B;AACtC,IAAA,KAAA,CAAM,KAAK,OAAO,CAAA;AAClB,IAA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C9B,IAAA,OAAO,YAAA;AAAA,MACL,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,qBAAA,EAAuB,EAAE,MAAA,EAAQ,EAAE,KAAA,EAAO,IAAA,EAAK,EAAG,CAAA;AAAA,MACxE,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AACF","file":"index.cjs","sourcesContent":["import type { components } from './types.js';\n\nexport type ApiErrorCode = components['schemas']['ErrorCode'];\nexport type ErrorCode = ApiErrorCode | 'network_error' | 'parse_error';\n\nexport type ErrorBody = {\n error?: ApiErrorCode;\n message?: string;\n details?: unknown;\n};\n\nexport interface OutlayerErrorOptions {\n code: ErrorCode;\n message: string;\n status: number;\n details?: unknown;\n}\n\nexport class OutlayerError extends Error {\n readonly code: ErrorCode;\n readonly status: number;\n readonly details: unknown;\n\n constructor(opts: OutlayerErrorOptions) {\n super(opts.message);\n this.name = 'OutlayerError';\n this.code = opts.code;\n this.status = opts.status;\n this.details = opts.details;\n }\n}\n\nexport class PolicyDeniedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'PolicyDeniedError';\n }\n}\n\nexport class WalletFrozenError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'WalletFrozenError';\n }\n}\n\nexport class UnauthorizedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'UnauthorizedError';\n }\n}\n\nexport class RateLimitedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'RateLimitedError';\n }\n}\n\nexport class NotFoundError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'NotFoundError';\n }\n}\n\nexport class BadRequestError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'BadRequestError';\n }\n}\n\nconst codeToCtor: Partial<Record<ErrorCode, new (opts: OutlayerErrorOptions) => OutlayerError>> = {\n policy_denied: PolicyDeniedError,\n wallet_frozen: WalletFrozenError,\n missing_auth: UnauthorizedError,\n invalid_api_key: UnauthorizedError,\n timestamp_expired: UnauthorizedError,\n rate_limited: RateLimitedError,\n request_not_found: NotFoundError,\n approval_not_found: NotFoundError,\n bad_request: BadRequestError,\n invalid_address: BadRequestError,\n insufficient_balance: BadRequestError,\n unsupported_chain: BadRequestError,\n unsupported_token: BadRequestError,\n};\n\nexport function makeError(body: ErrorBody, status: number): OutlayerError {\n const code: ErrorCode = body.error ?? 'parse_error';\n const message = body.message ?? `HTTP ${status}`;\n const opts: OutlayerErrorOptions = body.details !== undefined\n ? { code, message, status, details: body.details }\n : { code, message, status };\n const Ctor = codeToCtor[code] ?? OutlayerError;\n return new Ctor(opts);\n}\n\nexport async function errorFromResponse(response: Response, parsed?: unknown): Promise<OutlayerError> {\n let body: ErrorBody;\n if (parsed && typeof parsed === 'object') {\n body = parsed as ErrorBody;\n } else {\n try {\n body = (await response.clone().json()) as ErrorBody;\n } catch {\n body = { error: 'internal_error', message: response.statusText };\n }\n }\n return makeError(body, response.status);\n}\n","import createClient, { type Client } from 'openapi-fetch';\nimport type { paths } from './types.js';\nimport { OutlayerError, errorFromResponse } from './errors.js';\n\nexport type Network = 'mainnet' | 'testnet';\n\nexport const NETWORK_BASE_URLS: Record<Network, string> = {\n mainnet: 'https://api.outlayer.fastnear.com',\n testnet: 'https://api.testnet.outlayer.fastnear.com',\n};\n\nexport const DEFAULT_BASE_URL = NETWORK_BASE_URLS.mainnet;\n\nexport type RetryConfig = {\n maxAttempts?: number;\n initialDelayMs?: number;\n maxDelayMs?: number;\n};\n\nexport type ClientOptions = {\n apiKey: string;\n /**\n * NEAR network to target. Defaults to `mainnet`. NEAR Intents (cross-chain\n * swaps + gasless withdrawals) only work on mainnet — use testnet for the\n * register / policy / sign-message flow while developing.\n */\n network?: Network;\n /** Overrides `network` for self-hosted or staging deployments. */\n baseUrl?: string;\n fetch?: typeof fetch;\n retry?: RetryConfig;\n};\n\nexport type UnauthenticatedOptions = {\n network?: Network;\n baseUrl?: string;\n fetch?: typeof fetch;\n};\n\nfunction resolveBaseUrl(opts: { network?: Network; baseUrl?: string }): string {\n if (opts.baseUrl) return opts.baseUrl;\n if (opts.network) return NETWORK_BASE_URLS[opts.network];\n return DEFAULT_BASE_URL;\n}\n\nexport const DEFAULT_RETRY: Required<RetryConfig> = {\n maxAttempts: 3,\n initialDelayMs: 100,\n maxDelayMs: 1600,\n};\n\nexport type FetchClient = Client<paths, `${string}/${string}`>;\n\nexport function makeClient(opts: ClientOptions): { client: FetchClient; retry: Required<RetryConfig> } {\n const init: Parameters<typeof createClient<paths>>[0] = {\n baseUrl: resolveBaseUrl(opts),\n headers: { Authorization: `Bearer ${opts.apiKey}` },\n };\n if (opts.fetch) init.fetch = opts.fetch;\n const client = createClient<paths>(init);\n const retry: Required<RetryConfig> = { ...DEFAULT_RETRY, ...opts.retry };\n return { client, retry };\n}\n\nexport function makeUnauthenticatedClient(opts: UnauthenticatedOptions = {}): FetchClient {\n const init: Parameters<typeof createClient<paths>>[0] = {\n baseUrl: resolveBaseUrl(opts),\n };\n if (opts.fetch) init.fetch = opts.fetch;\n return createClient<paths>(init);\n}\n\nexport type FetchCall<T> = () => Promise<{\n data?: T;\n error?: unknown;\n response: Response;\n}>;\n\nexport async function runWithRetry<T>(\n call: FetchCall<T>,\n retry: Required<RetryConfig>,\n): Promise<T> {\n let lastError: unknown;\n for (let attempt = 1; attempt <= retry.maxAttempts; attempt++) {\n try {\n const { data, error, response } = await call();\n if (response.ok) {\n return data as T;\n }\n const err = await errorFromResponse(response, error);\n if (err.status >= 500 && attempt < retry.maxAttempts) {\n lastError = err;\n await sleep(backoff(attempt, retry));\n continue;\n }\n throw err;\n } catch (e) {\n if (e instanceof OutlayerError) throw e;\n lastError = e;\n if (attempt < retry.maxAttempts && isNetworkError(e)) {\n await sleep(backoff(attempt, retry));\n continue;\n }\n throw new OutlayerError({\n code: 'network_error',\n message: e instanceof Error ? e.message : String(e),\n status: 0,\n });\n }\n }\n throw lastError;\n}\n\nfunction backoff(attempt: number, cfg: Required<RetryConfig>): number {\n return Math.min(cfg.maxDelayMs, cfg.initialDelayMs * 2 ** (attempt - 1));\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nfunction isNetworkError(e: unknown): boolean {\n return e instanceof TypeError;\n}\n\nexport function newIdempotencyKey(): string {\n return crypto.randomUUID();\n}\n","import type { components } from './types.js';\nimport {\n type ClientOptions,\n type FetchClient,\n type RetryConfig,\n type UnauthenticatedOptions,\n DEFAULT_RETRY,\n makeClient,\n makeUnauthenticatedClient,\n newIdempotencyKey,\n runWithRetry,\n} from './http.js';\nimport { errorFromResponse } from './errors.js';\n\ntype Schemas = components['schemas'];\n\n// ---------------------------------------------------------------------------\n// Re-exported user-facing types (so consumers don't import paths/components)\n// ---------------------------------------------------------------------------\n\nexport type Chain = Schemas['Chain'];\nexport type RequestType = Schemas['RequestType'];\nexport type RequestStatus = Schemas['RequestStatus'];\n\nexport type RegisterRequest = Schemas['RegisterRequest'];\nexport type RegisterResponse = Schemas['RegisterResponse'];\nexport type AddressResponse = Schemas['AddressResponse'];\nexport type BalanceResponse = Schemas['BalanceResponse'];\nexport type TokensResponse = Schemas['TokensResponse'];\n\nexport type CallRequest = Schemas['CallRequest'];\nexport type CallResponse = Schemas['CallResponse'];\nexport type TransferRequest = Schemas['TransferRequest'];\nexport type IntentsDepositRequest = Schemas['IntentsDepositRequest'];\nexport type IntentsDepositResponse = Schemas['IntentsDepositResponse'];\n\nexport type WithdrawRequest = Schemas['WithdrawRequest'];\nexport type WithdrawResponse = Schemas['WithdrawResponse'];\nexport type DryRunResponse = Schemas['DryRunResponse'];\n\nexport type SwapRequest = Schemas['SwapRequest'];\nexport type SwapResponse = Schemas['SwapResponse'];\nexport type SwapQuoteResponse = Schemas['SwapQuoteResponse'];\n\nexport type SignMessageRequest = Schemas['SignMessageRequest'];\nexport type SignMessageResponse = Schemas['SignMessageResponse'];\n\nexport type RequestStatusResponse = Schemas['RequestStatusResponse'];\nexport type RequestListResponse = Schemas['RequestListResponse'];\n\nexport type PolicyResponse = Schemas['PolicyResponse'];\nexport type PolicyRules = Schemas['PolicyRules'];\nexport type ApprovalConfig = Schemas['ApprovalConfig'];\nexport type EncryptPolicyRequest = Schemas['EncryptPolicyRequest'];\nexport type EncryptPolicyResponse = Schemas['EncryptPolicyResponse'];\nexport type SignPolicyResponse = Schemas['SignPolicyResponse'];\n\nexport type PendingApproval = Schemas['PendingApproval'];\nexport type PendingApprovalsResponse = Schemas['PendingApprovalsResponse'];\nexport type Nep413Auth = Schemas['Nep413Auth'];\nexport type ApproveResponse = Schemas['ApproveResponse'];\n\nexport type AuditEvent = Schemas['AuditEvent'];\nexport type AuditResponse = Schemas['AuditResponse'];\n\n// ---------------------------------------------------------------------------\n// Shared helpers\n// ---------------------------------------------------------------------------\n\ntype Idempotent = { idempotencyKey?: string };\n\nfunction idempotencyHeader(key: string | undefined): Record<string, string> {\n return { 'Idempotency-Key': key ?? newIdempotencyKey() };\n}\n\n// ---------------------------------------------------------------------------\n// Sub-namespaces\n// ---------------------------------------------------------------------------\n\nexport class PolicyAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n get(): Promise<PolicyResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/policy'), this.retry);\n }\n\n encrypt(body: EncryptPolicyRequest): Promise<EncryptPolicyResponse> {\n return runWithRetry(() => this.client.POST('/wallet/v1/encrypt-policy', { body }), this.retry);\n }\n\n sign(encryptedData: string): Promise<SignPolicyResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/sign-policy', { body: { encrypted_data: encryptedData } }),\n this.retry,\n );\n }\n\n invalidateCache(walletId: string): Promise<void> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/invalidate-cache', { body: { wallet_id: walletId } }),\n this.retry,\n ).then(() => undefined);\n }\n}\n\nexport class ApprovalsAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n listPending(): Promise<PendingApprovalsResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/pending_approvals'), this.retry);\n }\n\n approve(approvalId: string, auth: Nep413Auth): Promise<ApproveResponse> {\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/approve/{id}', {\n params: { path: { id: approvalId } },\n body: auth,\n }),\n this.retry,\n );\n }\n\n reject(approvalId: string, auth: Nep413Auth, reason?: string): Promise<ApproveResponse> {\n const body = reason !== undefined ? { ...auth, reason } : auth;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/reject/{id}', {\n params: { path: { id: approvalId } },\n body,\n }),\n this.retry,\n );\n }\n}\n\nexport class AuditAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n list(opts: { limit?: number; offset?: number } = {}): Promise<AuditResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/audit', { params: { query: opts } }),\n this.retry,\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Main client\n// ---------------------------------------------------------------------------\n\nexport class OutlayerClient {\n private readonly client: FetchClient;\n private readonly retry: Required<RetryConfig>;\n\n readonly policy: PolicyAPI;\n readonly approvals: ApprovalsAPI;\n readonly audit: AuditAPI;\n\n constructor(opts: ClientOptions) {\n const { client, retry } = makeClient(opts);\n this.client = client;\n this.retry = retry;\n this.policy = new PolicyAPI(client, retry);\n this.approvals = new ApprovalsAPI(client, retry);\n this.audit = new AuditAPI(client, retry);\n }\n\n // ------- Static factory: register a new wallet (no auth) -------\n\n /**\n * Register a new wallet and obtain an API key.\n *\n * - Empty call: anonymous wallet on OutLayer's shared master. Convenient, no setup.\n * - With `vaultId`: bind to a deployed customer vault so keys derive through\n * the per-vault master. Vault binding is permanent.\n * - With `body`: full control — pass any `RegisterRequest` field (e.g., NEP-413\n * account-binding fields). `vaultId` is merged into `body.vault_id` if not\n * already set.\n *\n * Vault deployment is NOT done here — use the dashboard\n * (https://outlayer.fastnear.com/vault) or `outlayer vault init` CLI.\n * See docs/vaults.md for the full flow.\n */\n static async register(\n opts: {\n vaultId?: string;\n body?: RegisterRequest;\n } & UnauthenticatedOptions = {},\n ): Promise<RegisterResponse> {\n const client = makeUnauthenticatedClient(opts);\n const body: RegisterRequest = { ...(opts.body ?? {}) };\n if (opts.vaultId !== undefined && body.vault_id === undefined) {\n body.vault_id = opts.vaultId;\n }\n const { data, error, response } = await client.POST('/register', { body });\n if (!response.ok) throw await errorFromResponse(response, error);\n return data as RegisterResponse;\n }\n\n // ------- Wallet read -------\n\n getAddress(chain: Chain): Promise<AddressResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/address', { params: { query: { chain } } }),\n this.retry,\n );\n }\n\n getBalance(\n opts: { chain?: Chain; token?: string; source?: 'chain' | 'intents' } = {},\n ): Promise<BalanceResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/balance', { params: { query: opts } }),\n this.retry,\n );\n }\n\n listTokens(): Promise<TokensResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/tokens'), this.retry);\n }\n\n // ------- Wallet write -------\n\n call(opts: CallRequest & Idempotent): Promise<CallResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/call', {\n body: body as CallRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n transfer(opts: TransferRequest & Idempotent): Promise<CallResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/transfer', {\n body: body as TransferRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n intentsDeposit(opts: IntentsDepositRequest & Idempotent): Promise<IntentsDepositResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/deposit', {\n body: body as IntentsDepositRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n withdraw(opts: WithdrawRequest & Idempotent): Promise<WithdrawResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/withdraw', {\n body: body as WithdrawRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n withdrawDryRun(opts: WithdrawRequest): Promise<DryRunResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/intents/withdraw/dry-run', { body: opts }),\n this.retry,\n );\n }\n\n swap(opts: SwapRequest & Idempotent): Promise<SwapResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/swap', {\n body: body as SwapRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n swapQuote(opts: SwapRequest): Promise<SwapQuoteResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/intents/swap/quote', { body: opts }),\n this.retry,\n );\n }\n\n signMessage(opts: SignMessageRequest): Promise<SignMessageResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/sign-message', { body: opts }),\n this.retry,\n );\n }\n\n // ------- Async request tracking -------\n\n getRequest(id: string): Promise<RequestStatusResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/requests/{id}', { params: { path: { id } } }),\n this.retry,\n );\n }\n\n listRequests(\n opts: { type?: RequestType; status?: RequestStatus; limit?: number; offset?: number } = {},\n ): Promise<RequestListResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/requests', { params: { query: opts } }),\n this.retry,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/client.ts"],"names":["createClient"],"mappings":";;;;;;;;;;;AAkBO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAC9B,IAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,IAAA,EAA4B;AACtC,IAAA,K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jE,IAAA,OAAO,YAAA;AAAA,MACL,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,6BAA6B,EAAE,MAAA,EAAQ,EAAE,KAAA,EAAO,EAAE,EAAA,EAAI,QAAA,EAAS,IAAK,CAAA;AAAA,MAC1F,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AAAA;AAAA,EAIA,WAAW,EAAA,EAA4C;AACrD,IAAA,OAAO,YAAA;AAAA,MACL,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,0BAAA,EAA4B,EAAE,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,EAAA,EAAG,IAAK,CAAA;AAAA,MAC9E,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AAAA,EAEA,YAAA,CACE,IAAA,GAAwF,EAAC,EAC3D;AAC9B,IAAA,OAAO,YAAA;AAAA,MACL,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,qBAAA,EAAuB,EAAE,MAAA,EAAQ,EAAE,KAAA,EAAO,IAAA,EAAK,EAAG,CAAA;AAAA,MACxE,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AACF","file":"index.cjs","sourcesContent":["import type { components } from './types.js';\n\nexport type ApiErrorCode = components['schemas']['ErrorCode'];\nexport type ErrorCode = ApiErrorCode | 'network_error' | 'parse_error';\n\nexport type ErrorBody = {\n error?: ApiErrorCode;\n message?: string;\n details?: unknown;\n};\n\nexport interface OutlayerErrorOptions {\n code: ErrorCode;\n message: string;\n status: number;\n details?: unknown;\n}\n\nexport class OutlayerError extends Error {\n readonly code: ErrorCode;\n readonly status: number;\n readonly details: unknown;\n\n constructor(opts: OutlayerErrorOptions) {\n super(opts.message);\n this.name = 'OutlayerError';\n this.code = opts.code;\n this.status = opts.status;\n this.details = opts.details;\n }\n}\n\nexport class PolicyDeniedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'PolicyDeniedError';\n }\n}\n\nexport class WalletFrozenError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'WalletFrozenError';\n }\n}\n\nexport class UnauthorizedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'UnauthorizedError';\n }\n}\n\nexport class RateLimitedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'RateLimitedError';\n }\n}\n\nexport class NotFoundError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'NotFoundError';\n }\n}\n\nexport class BadRequestError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'BadRequestError';\n }\n}\n\nconst codeToCtor: Partial<Record<ErrorCode, new (opts: OutlayerErrorOptions) => OutlayerError>> = {\n policy_denied: PolicyDeniedError,\n wallet_frozen: WalletFrozenError,\n missing_auth: UnauthorizedError,\n invalid_api_key: UnauthorizedError,\n timestamp_expired: UnauthorizedError,\n rate_limited: RateLimitedError,\n request_not_found: NotFoundError,\n approval_not_found: NotFoundError,\n bad_request: BadRequestError,\n invalid_address: BadRequestError,\n insufficient_balance: BadRequestError,\n unsupported_chain: BadRequestError,\n unsupported_token: BadRequestError,\n};\n\nexport function makeError(body: ErrorBody, status: number): OutlayerError {\n const code: ErrorCode = body.error ?? 'parse_error';\n const message = body.message ?? `HTTP ${status}`;\n const opts: OutlayerErrorOptions = body.details !== undefined\n ? { code, message, status, details: body.details }\n : { code, message, status };\n const Ctor = codeToCtor[code] ?? OutlayerError;\n return new Ctor(opts);\n}\n\nexport async function errorFromResponse(response: Response, parsed?: unknown): Promise<OutlayerError> {\n let body: ErrorBody;\n if (parsed && typeof parsed === 'object') {\n body = parsed as ErrorBody;\n } else {\n try {\n body = (await response.clone().json()) as ErrorBody;\n } catch {\n body = { error: 'internal_error', message: response.statusText };\n }\n }\n return makeError(body, response.status);\n}\n","import createClient, { type Client } from 'openapi-fetch';\nimport type { paths } from './types.js';\nimport { OutlayerError, errorFromResponse } from './errors.js';\n\nexport type Network = 'mainnet' | 'testnet';\n\nexport const NETWORK_BASE_URLS: Record<Network, string> = {\n mainnet: 'https://api.outlayer.fastnear.com',\n testnet: 'https://api.testnet.outlayer.fastnear.com',\n};\n\nexport const DEFAULT_BASE_URL = NETWORK_BASE_URLS.mainnet;\n\nexport type RetryConfig = {\n maxAttempts?: number;\n initialDelayMs?: number;\n maxDelayMs?: number;\n};\n\nexport type ClientOptions = {\n apiKey: string;\n /**\n * NEAR network to target. Defaults to `mainnet`. NEAR Intents (cross-chain\n * swaps + gasless withdrawals) only work on mainnet — use testnet for the\n * register / policy / sign-message flow while developing.\n */\n network?: Network;\n /** Overrides `network` for self-hosted or staging deployments. */\n baseUrl?: string;\n fetch?: typeof fetch;\n retry?: RetryConfig;\n};\n\nexport type UnauthenticatedOptions = {\n network?: Network;\n baseUrl?: string;\n fetch?: typeof fetch;\n};\n\nfunction resolveBaseUrl(opts: { network?: Network; baseUrl?: string }): string {\n if (opts.baseUrl) return opts.baseUrl;\n if (opts.network) return NETWORK_BASE_URLS[opts.network];\n return DEFAULT_BASE_URL;\n}\n\nexport const DEFAULT_RETRY: Required<RetryConfig> = {\n maxAttempts: 3,\n initialDelayMs: 100,\n maxDelayMs: 1600,\n};\n\nexport type FetchClient = Client<paths, `${string}/${string}`>;\n\nexport function makeClient(opts: ClientOptions): { client: FetchClient; retry: Required<RetryConfig> } {\n const init: Parameters<typeof createClient<paths>>[0] = {\n baseUrl: resolveBaseUrl(opts),\n headers: { Authorization: `Bearer ${opts.apiKey}` },\n };\n if (opts.fetch) init.fetch = opts.fetch;\n const client = createClient<paths>(init);\n const retry: Required<RetryConfig> = { ...DEFAULT_RETRY, ...opts.retry };\n return { client, retry };\n}\n\nexport function makeUnauthenticatedClient(opts: UnauthenticatedOptions = {}): FetchClient {\n const init: Parameters<typeof createClient<paths>>[0] = {\n baseUrl: resolveBaseUrl(opts),\n };\n if (opts.fetch) init.fetch = opts.fetch;\n return createClient<paths>(init);\n}\n\nexport type FetchCall<T> = () => Promise<{\n data?: T;\n error?: unknown;\n response: Response;\n}>;\n\nexport async function runWithRetry<T>(\n call: FetchCall<T>,\n retry: Required<RetryConfig>,\n): Promise<T> {\n let lastError: unknown;\n for (let attempt = 1; attempt <= retry.maxAttempts; attempt++) {\n try {\n const { data, error, response } = await call();\n if (response.ok) {\n return data as T;\n }\n const err = await errorFromResponse(response, error);\n if (err.status >= 500 && attempt < retry.maxAttempts) {\n lastError = err;\n await sleep(backoff(attempt, retry));\n continue;\n }\n throw err;\n } catch (e) {\n if (e instanceof OutlayerError) throw e;\n lastError = e;\n if (attempt < retry.maxAttempts && isNetworkError(e)) {\n await sleep(backoff(attempt, retry));\n continue;\n }\n throw new OutlayerError({\n code: 'network_error',\n message: e instanceof Error ? e.message : String(e),\n status: 0,\n });\n }\n }\n throw lastError;\n}\n\nfunction backoff(attempt: number, cfg: Required<RetryConfig>): number {\n return Math.min(cfg.maxDelayMs, cfg.initialDelayMs * 2 ** (attempt - 1));\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nfunction isNetworkError(e: unknown): boolean {\n return e instanceof TypeError;\n}\n\nexport function newIdempotencyKey(): string {\n return crypto.randomUUID();\n}\n","import type { components } from './types.js';\nimport {\n type ClientOptions,\n type FetchClient,\n type RetryConfig,\n type UnauthenticatedOptions,\n DEFAULT_RETRY,\n makeClient,\n makeUnauthenticatedClient,\n newIdempotencyKey,\n runWithRetry,\n} from './http.js';\nimport { errorFromResponse } from './errors.js';\n\ntype Schemas = components['schemas'];\n\n// ---------------------------------------------------------------------------\n// Re-exported user-facing types (so consumers don't import paths/components)\n// ---------------------------------------------------------------------------\n\nexport type Chain = Schemas['Chain'];\nexport type RequestType = Schemas['RequestType'];\nexport type RequestStatus = Schemas['RequestStatus'];\n\nexport type RegisterRequest = Schemas['RegisterRequest'];\nexport type RegisterResponse = Schemas['RegisterResponse'];\nexport type AddressResponse = Schemas['AddressResponse'];\nexport type BalanceResponse = Schemas['BalanceResponse'];\nexport type TokensResponse = Schemas['TokensResponse'];\n\nexport type CallRequest = Schemas['CallRequest'];\nexport type CallResponse = Schemas['CallResponse'];\nexport type TransferRequest = Schemas['TransferRequest'];\nexport type IntentsDepositRequest = Schemas['IntentsDepositRequest'];\nexport type IntentsDepositResponse = Schemas['IntentsDepositResponse'];\n\nexport type WithdrawRequest = Schemas['WithdrawRequest'];\nexport type WithdrawResponse = Schemas['WithdrawResponse'];\nexport type DryRunResponse = Schemas['DryRunResponse'];\n\nexport type SwapRequest = Schemas['SwapRequest'];\nexport type SwapResponse = Schemas['SwapResponse'];\nexport type SwapQuoteResponse = Schemas['SwapQuoteResponse'];\n\nexport type SignMessageRequest = Schemas['SignMessageRequest'];\nexport type SignMessageResponse = Schemas['SignMessageResponse'];\n\nexport type DepositIntentRequest = Schemas['DepositIntentRequest'];\nexport type DepositIntentResponse = Schemas['DepositIntentResponse'];\nexport type DepositStatusResponse = Schemas['DepositStatusResponse'];\n\nexport type RequestStatusResponse = Schemas['RequestStatusResponse'];\nexport type RequestListResponse = Schemas['RequestListResponse'];\n\nexport type PolicyResponse = Schemas['PolicyResponse'];\nexport type PolicyRules = Schemas['PolicyRules'];\nexport type ApprovalConfig = Schemas['ApprovalConfig'];\nexport type EncryptPolicyRequest = Schemas['EncryptPolicyRequest'];\nexport type EncryptPolicyResponse = Schemas['EncryptPolicyResponse'];\nexport type SignPolicyResponse = Schemas['SignPolicyResponse'];\n\nexport type PendingApproval = Schemas['PendingApproval'];\nexport type PendingApprovalsResponse = Schemas['PendingApprovalsResponse'];\nexport type Nep413Auth = Schemas['Nep413Auth'];\nexport type ApproveResponse = Schemas['ApproveResponse'];\n\nexport type AuditEvent = Schemas['AuditEvent'];\nexport type AuditResponse = Schemas['AuditResponse'];\n\n// ---------------------------------------------------------------------------\n// Shared helpers\n// ---------------------------------------------------------------------------\n\ntype Idempotent = { idempotencyKey?: string };\n\nfunction idempotencyHeader(key: string | undefined): Record<string, string> {\n return { 'Idempotency-Key': key ?? newIdempotencyKey() };\n}\n\n// ---------------------------------------------------------------------------\n// Sub-namespaces\n// ---------------------------------------------------------------------------\n\nexport class PolicyAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n get(): Promise<PolicyResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/policy'), this.retry);\n }\n\n encrypt(body: EncryptPolicyRequest): Promise<EncryptPolicyResponse> {\n return runWithRetry(() => this.client.POST('/wallet/v1/encrypt-policy', { body }), this.retry);\n }\n\n sign(encryptedData: string): Promise<SignPolicyResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/sign-policy', { body: { encrypted_data: encryptedData } }),\n this.retry,\n );\n }\n\n invalidateCache(walletId: string): Promise<void> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/invalidate-cache', { body: { wallet_id: walletId } }),\n this.retry,\n ).then(() => undefined);\n }\n}\n\nexport class ApprovalsAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n listPending(): Promise<PendingApprovalsResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/pending_approvals'), this.retry);\n }\n\n approve(approvalId: string, auth: Nep413Auth): Promise<ApproveResponse> {\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/approve/{id}', {\n params: { path: { id: approvalId } },\n body: auth,\n }),\n this.retry,\n );\n }\n\n reject(approvalId: string, auth: Nep413Auth, reason?: string): Promise<ApproveResponse> {\n const body = reason !== undefined ? { ...auth, reason } : auth;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/reject/{id}', {\n params: { path: { id: approvalId } },\n body,\n }),\n this.retry,\n );\n }\n}\n\nexport class AuditAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n list(opts: { limit?: number; offset?: number } = {}): Promise<AuditResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/audit', { params: { query: opts } }),\n this.retry,\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Main client\n// ---------------------------------------------------------------------------\n\nexport class OutlayerClient {\n private readonly client: FetchClient;\n private readonly retry: Required<RetryConfig>;\n\n readonly policy: PolicyAPI;\n readonly approvals: ApprovalsAPI;\n readonly audit: AuditAPI;\n\n constructor(opts: ClientOptions) {\n const { client, retry } = makeClient(opts);\n this.client = client;\n this.retry = retry;\n this.policy = new PolicyAPI(client, retry);\n this.approvals = new ApprovalsAPI(client, retry);\n this.audit = new AuditAPI(client, retry);\n }\n\n // ------- Static factory: register a new wallet (no auth) -------\n\n /**\n * Register a new wallet and obtain an API key.\n *\n * - Empty call: anonymous wallet on OutLayer's shared master. Convenient, no setup.\n * - With `vaultId`: bind to a deployed customer vault so keys derive through\n * the per-vault master. Vault binding is permanent.\n * - With `body`: full control — pass any `RegisterRequest` field (e.g., NEP-413\n * account-binding fields). `vaultId` is merged into `body.vault_id` if not\n * already set.\n *\n * Vault deployment is NOT done here — use the dashboard\n * (https://outlayer.fastnear.com/vault) or `outlayer vault init` CLI.\n * See docs/vaults.md for the full flow.\n */\n static async register(\n opts: {\n vaultId?: string;\n body?: RegisterRequest;\n } & UnauthenticatedOptions = {},\n ): Promise<RegisterResponse> {\n const client = makeUnauthenticatedClient(opts);\n const body: RegisterRequest = { ...(opts.body ?? {}) };\n if (opts.vaultId !== undefined && body.vault_id === undefined) {\n body.vault_id = opts.vaultId;\n }\n const { data, error, response } = await client.POST('/register', { body });\n if (!response.ok) throw await errorFromResponse(response, error);\n return data as RegisterResponse;\n }\n\n // ------- Wallet read -------\n\n getAddress(chain: Chain): Promise<AddressResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/address', { params: { query: { chain } } }),\n this.retry,\n );\n }\n\n getBalance(\n opts: { chain?: Chain; token?: string; source?: 'chain' | 'intents' } = {},\n ): Promise<BalanceResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/balance', { params: { query: opts } }),\n this.retry,\n );\n }\n\n listTokens(): Promise<TokensResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/tokens'), this.retry);\n }\n\n // ------- Wallet write -------\n\n call(opts: CallRequest & Idempotent): Promise<CallResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/call', {\n body: body as CallRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n transfer(opts: TransferRequest & Idempotent): Promise<CallResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/transfer', {\n body: body as TransferRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n intentsDeposit(opts: IntentsDepositRequest & Idempotent): Promise<IntentsDepositResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/deposit', {\n body: body as IntentsDepositRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n withdraw(opts: WithdrawRequest & Idempotent): Promise<WithdrawResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/withdraw', {\n body: body as WithdrawRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n withdrawDryRun(opts: WithdrawRequest): Promise<DryRunResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/intents/withdraw/dry-run', { body: opts }),\n this.retry,\n );\n }\n\n swap(opts: SwapRequest & Idempotent): Promise<SwapResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/swap', {\n body: body as SwapRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n swapQuote(opts: SwapRequest): Promise<SwapQuoteResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/intents/swap/quote', { body: opts }),\n this.retry,\n );\n }\n\n signMessage(opts: SignMessageRequest): Promise<SignMessageResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/sign-message', { body: opts }),\n this.retry,\n );\n }\n\n // ------- Cross-chain deposit (1Click) -------\n\n /**\n * Create a one-time deposit address on a source chain. Send funds there,\n * then poll {@link getDepositStatus} until `success`.\n */\n createDepositIntent(opts: DepositIntentRequest): Promise<DepositIntentResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/deposit-intent', { body: opts }),\n this.retry,\n );\n }\n\n getDepositStatus(intentId: string): Promise<DepositStatusResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/deposit-status', { params: { query: { id: intentId } } }),\n this.retry,\n );\n }\n\n // ------- Async request tracking -------\n\n getRequest(id: string): Promise<RequestStatusResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/requests/{id}', { params: { path: { id } } }),\n this.retry,\n );\n }\n\n listRequests(\n opts: { type?: RequestType; status?: RequestStatus; limit?: number; offset?: number } = {},\n ): Promise<RequestListResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/requests', { params: { query: opts } }),\n this.retry,\n );\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -261,6 +261,49 @@ interface paths {
|
|
|
261
261
|
patch?: never;
|
|
262
262
|
trace?: never;
|
|
263
263
|
};
|
|
264
|
+
"/wallet/v1/deposit-intent": {
|
|
265
|
+
parameters: {
|
|
266
|
+
query?: never;
|
|
267
|
+
header?: never;
|
|
268
|
+
path?: never;
|
|
269
|
+
cookie?: never;
|
|
270
|
+
};
|
|
271
|
+
get?: never;
|
|
272
|
+
put?: never;
|
|
273
|
+
/**
|
|
274
|
+
* Create a cross-chain deposit intent (1Click)
|
|
275
|
+
* @description Requests a one-time deposit address on a source chain via NEAR Intents
|
|
276
|
+
* 1Click. The caller sends `amount` of `token` to the returned
|
|
277
|
+
* `deposit_address` on `chain`; the solver bridges it and credits the
|
|
278
|
+
* wallet's intents.near balance. Poll `getDepositStatus` until `success`.
|
|
279
|
+
*
|
|
280
|
+
* Amounts are in the token's smallest unit. There's a small bridge fee,
|
|
281
|
+
* so `amount_out` < `amount`.
|
|
282
|
+
*/
|
|
283
|
+
post: operations["createDepositIntent"];
|
|
284
|
+
delete?: never;
|
|
285
|
+
options?: never;
|
|
286
|
+
head?: never;
|
|
287
|
+
patch?: never;
|
|
288
|
+
trace?: never;
|
|
289
|
+
};
|
|
290
|
+
"/wallet/v1/deposit-status": {
|
|
291
|
+
parameters: {
|
|
292
|
+
query?: never;
|
|
293
|
+
header?: never;
|
|
294
|
+
path?: never;
|
|
295
|
+
cookie?: never;
|
|
296
|
+
};
|
|
297
|
+
/** Poll a cross-chain deposit intent's status */
|
|
298
|
+
get: operations["getDepositStatus"];
|
|
299
|
+
put?: never;
|
|
300
|
+
post?: never;
|
|
301
|
+
delete?: never;
|
|
302
|
+
options?: never;
|
|
303
|
+
head?: never;
|
|
304
|
+
patch?: never;
|
|
305
|
+
trace?: never;
|
|
306
|
+
};
|
|
264
307
|
"/wallet/v1/sign-message": {
|
|
265
308
|
parameters: {
|
|
266
309
|
query?: never;
|
|
@@ -677,6 +720,37 @@ interface components {
|
|
|
677
720
|
deadline?: string;
|
|
678
721
|
time_estimate_seconds?: number;
|
|
679
722
|
};
|
|
723
|
+
DepositIntentRequest: {
|
|
724
|
+
/**
|
|
725
|
+
* @description Source chain to bridge from. Common values: `ethereum`, `solana`,
|
|
726
|
+
* `base`, `arbitrum`, `polygon`, `optimism`, `avalanche`.
|
|
727
|
+
*/
|
|
728
|
+
chain: string;
|
|
729
|
+
/** @description Amount in the token's smallest unit (e.g. `5000000` = 5 USDC). */
|
|
730
|
+
amount: string;
|
|
731
|
+
/** @description Token symbol to deposit, e.g. `USDC`. */
|
|
732
|
+
token: string;
|
|
733
|
+
};
|
|
734
|
+
DepositIntentResponse: {
|
|
735
|
+
intent_id: string;
|
|
736
|
+
/** @description One-time address on the source chain — send funds here. */
|
|
737
|
+
deposit_address: string;
|
|
738
|
+
amount: string;
|
|
739
|
+
/** @description Amount credited after the bridge fee. */
|
|
740
|
+
amount_out: string;
|
|
741
|
+
min_amount_out: string;
|
|
742
|
+
/** Format: date-time */
|
|
743
|
+
expires_at: string;
|
|
744
|
+
estimated_time_secs: number;
|
|
745
|
+
};
|
|
746
|
+
DepositStatusResponse: {
|
|
747
|
+
intent_id: string;
|
|
748
|
+
/** @enum {string} */
|
|
749
|
+
status: "pending" | "bridging" | "success" | "failed" | "expired";
|
|
750
|
+
result?: {
|
|
751
|
+
[key: string]: unknown;
|
|
752
|
+
} | null;
|
|
753
|
+
};
|
|
680
754
|
SignMessageRequest: {
|
|
681
755
|
message: string;
|
|
682
756
|
recipient: string;
|
|
@@ -1323,6 +1397,66 @@ interface operations {
|
|
|
1323
1397
|
500: components["responses"]["InternalError"];
|
|
1324
1398
|
};
|
|
1325
1399
|
};
|
|
1400
|
+
createDepositIntent: {
|
|
1401
|
+
parameters: {
|
|
1402
|
+
query?: never;
|
|
1403
|
+
header?: never;
|
|
1404
|
+
path?: never;
|
|
1405
|
+
cookie?: never;
|
|
1406
|
+
};
|
|
1407
|
+
requestBody: {
|
|
1408
|
+
content: {
|
|
1409
|
+
/**
|
|
1410
|
+
* @example {
|
|
1411
|
+
* "chain": "ethereum",
|
|
1412
|
+
* "amount": "5000000",
|
|
1413
|
+
* "token": "USDC"
|
|
1414
|
+
* }
|
|
1415
|
+
*/
|
|
1416
|
+
"application/json": components["schemas"]["DepositIntentRequest"];
|
|
1417
|
+
};
|
|
1418
|
+
};
|
|
1419
|
+
responses: {
|
|
1420
|
+
/** @description Deposit intent created */
|
|
1421
|
+
200: {
|
|
1422
|
+
headers: {
|
|
1423
|
+
[name: string]: unknown;
|
|
1424
|
+
};
|
|
1425
|
+
content: {
|
|
1426
|
+
"application/json": components["schemas"]["DepositIntentResponse"];
|
|
1427
|
+
};
|
|
1428
|
+
};
|
|
1429
|
+
400: components["responses"]["BadRequest"];
|
|
1430
|
+
401: components["responses"]["Unauthorized"];
|
|
1431
|
+
500: components["responses"]["InternalError"];
|
|
1432
|
+
};
|
|
1433
|
+
};
|
|
1434
|
+
getDepositStatus: {
|
|
1435
|
+
parameters: {
|
|
1436
|
+
query: {
|
|
1437
|
+
/** @description The `intent_id` from `createDepositIntent`. */
|
|
1438
|
+
id: string;
|
|
1439
|
+
};
|
|
1440
|
+
header?: never;
|
|
1441
|
+
path?: never;
|
|
1442
|
+
cookie?: never;
|
|
1443
|
+
};
|
|
1444
|
+
requestBody?: never;
|
|
1445
|
+
responses: {
|
|
1446
|
+
/** @description Deposit status */
|
|
1447
|
+
200: {
|
|
1448
|
+
headers: {
|
|
1449
|
+
[name: string]: unknown;
|
|
1450
|
+
};
|
|
1451
|
+
content: {
|
|
1452
|
+
"application/json": components["schemas"]["DepositStatusResponse"];
|
|
1453
|
+
};
|
|
1454
|
+
};
|
|
1455
|
+
401: components["responses"]["Unauthorized"];
|
|
1456
|
+
404: components["responses"]["NotFound"];
|
|
1457
|
+
500: components["responses"]["InternalError"];
|
|
1458
|
+
};
|
|
1459
|
+
};
|
|
1326
1460
|
signMessage: {
|
|
1327
1461
|
parameters: {
|
|
1328
1462
|
query?: never;
|
|
@@ -1670,6 +1804,9 @@ type SwapResponse = Schemas['SwapResponse'];
|
|
|
1670
1804
|
type SwapQuoteResponse = Schemas['SwapQuoteResponse'];
|
|
1671
1805
|
type SignMessageRequest = Schemas['SignMessageRequest'];
|
|
1672
1806
|
type SignMessageResponse = Schemas['SignMessageResponse'];
|
|
1807
|
+
type DepositIntentRequest = Schemas['DepositIntentRequest'];
|
|
1808
|
+
type DepositIntentResponse = Schemas['DepositIntentResponse'];
|
|
1809
|
+
type DepositStatusResponse = Schemas['DepositStatusResponse'];
|
|
1673
1810
|
type RequestStatusResponse = Schemas['RequestStatusResponse'];
|
|
1674
1811
|
type RequestListResponse = Schemas['RequestListResponse'];
|
|
1675
1812
|
type PolicyResponse = Schemas['PolicyResponse'];
|
|
@@ -1753,6 +1890,12 @@ declare class OutlayerClient {
|
|
|
1753
1890
|
swap(opts: SwapRequest & Idempotent): Promise<SwapResponse>;
|
|
1754
1891
|
swapQuote(opts: SwapRequest): Promise<SwapQuoteResponse>;
|
|
1755
1892
|
signMessage(opts: SignMessageRequest): Promise<SignMessageResponse>;
|
|
1893
|
+
/**
|
|
1894
|
+
* Create a one-time deposit address on a source chain. Send funds there,
|
|
1895
|
+
* then poll {@link getDepositStatus} until `success`.
|
|
1896
|
+
*/
|
|
1897
|
+
createDepositIntent(opts: DepositIntentRequest): Promise<DepositIntentResponse>;
|
|
1898
|
+
getDepositStatus(intentId: string): Promise<DepositStatusResponse>;
|
|
1756
1899
|
getRequest(id: string): Promise<RequestStatusResponse>;
|
|
1757
1900
|
listRequests(opts?: {
|
|
1758
1901
|
type?: RequestType;
|
|
@@ -1795,4 +1938,4 @@ declare class BadRequestError extends OutlayerError {
|
|
|
1795
1938
|
constructor(opts: OutlayerErrorOptions);
|
|
1796
1939
|
}
|
|
1797
1940
|
|
|
1798
|
-
export { type AddressResponse, type ApiErrorCode, type ApprovalConfig, ApprovalsAPI, type ApproveResponse, AuditAPI, type AuditEvent, type AuditResponse, BadRequestError, type BalanceResponse, type CallRequest, type CallResponse, type Chain, type ClientOptions, type DryRunResponse, type EncryptPolicyRequest, type EncryptPolicyResponse, type ErrorCode, type IntentsDepositRequest, type IntentsDepositResponse, NETWORK_BASE_URLS, type Nep413Auth, type Network, NotFoundError, OutlayerClient, OutlayerError, type PendingApproval, type PendingApprovalsResponse, PolicyAPI, PolicyDeniedError, type PolicyResponse, type PolicyRules, RateLimitedError, type RegisterRequest, type RegisterResponse, type RequestListResponse, type RequestStatus, type RequestStatusResponse, type RequestType, type RetryConfig, type SignMessageRequest, type SignMessageResponse, type SignPolicyResponse, type SwapQuoteResponse, type SwapRequest, type SwapResponse, type TokensResponse, type TransferRequest, type UnauthenticatedOptions, UnauthorizedError, WalletFrozenError, type WithdrawRequest, type WithdrawResponse };
|
|
1941
|
+
export { type AddressResponse, type ApiErrorCode, type ApprovalConfig, ApprovalsAPI, type ApproveResponse, AuditAPI, type AuditEvent, type AuditResponse, BadRequestError, type BalanceResponse, type CallRequest, type CallResponse, type Chain, type ClientOptions, type DepositIntentRequest, type DepositIntentResponse, type DepositStatusResponse, type DryRunResponse, type EncryptPolicyRequest, type EncryptPolicyResponse, type ErrorCode, type IntentsDepositRequest, type IntentsDepositResponse, NETWORK_BASE_URLS, type Nep413Auth, type Network, NotFoundError, OutlayerClient, OutlayerError, type PendingApproval, type PendingApprovalsResponse, PolicyAPI, PolicyDeniedError, type PolicyResponse, type PolicyRules, RateLimitedError, type RegisterRequest, type RegisterResponse, type RequestListResponse, type RequestStatus, type RequestStatusResponse, type RequestType, type RetryConfig, type SignMessageRequest, type SignMessageResponse, type SignPolicyResponse, type SwapQuoteResponse, type SwapRequest, type SwapResponse, type TokensResponse, type TransferRequest, type UnauthenticatedOptions, UnauthorizedError, WalletFrozenError, type WithdrawRequest, type WithdrawResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -261,6 +261,49 @@ interface paths {
|
|
|
261
261
|
patch?: never;
|
|
262
262
|
trace?: never;
|
|
263
263
|
};
|
|
264
|
+
"/wallet/v1/deposit-intent": {
|
|
265
|
+
parameters: {
|
|
266
|
+
query?: never;
|
|
267
|
+
header?: never;
|
|
268
|
+
path?: never;
|
|
269
|
+
cookie?: never;
|
|
270
|
+
};
|
|
271
|
+
get?: never;
|
|
272
|
+
put?: never;
|
|
273
|
+
/**
|
|
274
|
+
* Create a cross-chain deposit intent (1Click)
|
|
275
|
+
* @description Requests a one-time deposit address on a source chain via NEAR Intents
|
|
276
|
+
* 1Click. The caller sends `amount` of `token` to the returned
|
|
277
|
+
* `deposit_address` on `chain`; the solver bridges it and credits the
|
|
278
|
+
* wallet's intents.near balance. Poll `getDepositStatus` until `success`.
|
|
279
|
+
*
|
|
280
|
+
* Amounts are in the token's smallest unit. There's a small bridge fee,
|
|
281
|
+
* so `amount_out` < `amount`.
|
|
282
|
+
*/
|
|
283
|
+
post: operations["createDepositIntent"];
|
|
284
|
+
delete?: never;
|
|
285
|
+
options?: never;
|
|
286
|
+
head?: never;
|
|
287
|
+
patch?: never;
|
|
288
|
+
trace?: never;
|
|
289
|
+
};
|
|
290
|
+
"/wallet/v1/deposit-status": {
|
|
291
|
+
parameters: {
|
|
292
|
+
query?: never;
|
|
293
|
+
header?: never;
|
|
294
|
+
path?: never;
|
|
295
|
+
cookie?: never;
|
|
296
|
+
};
|
|
297
|
+
/** Poll a cross-chain deposit intent's status */
|
|
298
|
+
get: operations["getDepositStatus"];
|
|
299
|
+
put?: never;
|
|
300
|
+
post?: never;
|
|
301
|
+
delete?: never;
|
|
302
|
+
options?: never;
|
|
303
|
+
head?: never;
|
|
304
|
+
patch?: never;
|
|
305
|
+
trace?: never;
|
|
306
|
+
};
|
|
264
307
|
"/wallet/v1/sign-message": {
|
|
265
308
|
parameters: {
|
|
266
309
|
query?: never;
|
|
@@ -677,6 +720,37 @@ interface components {
|
|
|
677
720
|
deadline?: string;
|
|
678
721
|
time_estimate_seconds?: number;
|
|
679
722
|
};
|
|
723
|
+
DepositIntentRequest: {
|
|
724
|
+
/**
|
|
725
|
+
* @description Source chain to bridge from. Common values: `ethereum`, `solana`,
|
|
726
|
+
* `base`, `arbitrum`, `polygon`, `optimism`, `avalanche`.
|
|
727
|
+
*/
|
|
728
|
+
chain: string;
|
|
729
|
+
/** @description Amount in the token's smallest unit (e.g. `5000000` = 5 USDC). */
|
|
730
|
+
amount: string;
|
|
731
|
+
/** @description Token symbol to deposit, e.g. `USDC`. */
|
|
732
|
+
token: string;
|
|
733
|
+
};
|
|
734
|
+
DepositIntentResponse: {
|
|
735
|
+
intent_id: string;
|
|
736
|
+
/** @description One-time address on the source chain — send funds here. */
|
|
737
|
+
deposit_address: string;
|
|
738
|
+
amount: string;
|
|
739
|
+
/** @description Amount credited after the bridge fee. */
|
|
740
|
+
amount_out: string;
|
|
741
|
+
min_amount_out: string;
|
|
742
|
+
/** Format: date-time */
|
|
743
|
+
expires_at: string;
|
|
744
|
+
estimated_time_secs: number;
|
|
745
|
+
};
|
|
746
|
+
DepositStatusResponse: {
|
|
747
|
+
intent_id: string;
|
|
748
|
+
/** @enum {string} */
|
|
749
|
+
status: "pending" | "bridging" | "success" | "failed" | "expired";
|
|
750
|
+
result?: {
|
|
751
|
+
[key: string]: unknown;
|
|
752
|
+
} | null;
|
|
753
|
+
};
|
|
680
754
|
SignMessageRequest: {
|
|
681
755
|
message: string;
|
|
682
756
|
recipient: string;
|
|
@@ -1323,6 +1397,66 @@ interface operations {
|
|
|
1323
1397
|
500: components["responses"]["InternalError"];
|
|
1324
1398
|
};
|
|
1325
1399
|
};
|
|
1400
|
+
createDepositIntent: {
|
|
1401
|
+
parameters: {
|
|
1402
|
+
query?: never;
|
|
1403
|
+
header?: never;
|
|
1404
|
+
path?: never;
|
|
1405
|
+
cookie?: never;
|
|
1406
|
+
};
|
|
1407
|
+
requestBody: {
|
|
1408
|
+
content: {
|
|
1409
|
+
/**
|
|
1410
|
+
* @example {
|
|
1411
|
+
* "chain": "ethereum",
|
|
1412
|
+
* "amount": "5000000",
|
|
1413
|
+
* "token": "USDC"
|
|
1414
|
+
* }
|
|
1415
|
+
*/
|
|
1416
|
+
"application/json": components["schemas"]["DepositIntentRequest"];
|
|
1417
|
+
};
|
|
1418
|
+
};
|
|
1419
|
+
responses: {
|
|
1420
|
+
/** @description Deposit intent created */
|
|
1421
|
+
200: {
|
|
1422
|
+
headers: {
|
|
1423
|
+
[name: string]: unknown;
|
|
1424
|
+
};
|
|
1425
|
+
content: {
|
|
1426
|
+
"application/json": components["schemas"]["DepositIntentResponse"];
|
|
1427
|
+
};
|
|
1428
|
+
};
|
|
1429
|
+
400: components["responses"]["BadRequest"];
|
|
1430
|
+
401: components["responses"]["Unauthorized"];
|
|
1431
|
+
500: components["responses"]["InternalError"];
|
|
1432
|
+
};
|
|
1433
|
+
};
|
|
1434
|
+
getDepositStatus: {
|
|
1435
|
+
parameters: {
|
|
1436
|
+
query: {
|
|
1437
|
+
/** @description The `intent_id` from `createDepositIntent`. */
|
|
1438
|
+
id: string;
|
|
1439
|
+
};
|
|
1440
|
+
header?: never;
|
|
1441
|
+
path?: never;
|
|
1442
|
+
cookie?: never;
|
|
1443
|
+
};
|
|
1444
|
+
requestBody?: never;
|
|
1445
|
+
responses: {
|
|
1446
|
+
/** @description Deposit status */
|
|
1447
|
+
200: {
|
|
1448
|
+
headers: {
|
|
1449
|
+
[name: string]: unknown;
|
|
1450
|
+
};
|
|
1451
|
+
content: {
|
|
1452
|
+
"application/json": components["schemas"]["DepositStatusResponse"];
|
|
1453
|
+
};
|
|
1454
|
+
};
|
|
1455
|
+
401: components["responses"]["Unauthorized"];
|
|
1456
|
+
404: components["responses"]["NotFound"];
|
|
1457
|
+
500: components["responses"]["InternalError"];
|
|
1458
|
+
};
|
|
1459
|
+
};
|
|
1326
1460
|
signMessage: {
|
|
1327
1461
|
parameters: {
|
|
1328
1462
|
query?: never;
|
|
@@ -1670,6 +1804,9 @@ type SwapResponse = Schemas['SwapResponse'];
|
|
|
1670
1804
|
type SwapQuoteResponse = Schemas['SwapQuoteResponse'];
|
|
1671
1805
|
type SignMessageRequest = Schemas['SignMessageRequest'];
|
|
1672
1806
|
type SignMessageResponse = Schemas['SignMessageResponse'];
|
|
1807
|
+
type DepositIntentRequest = Schemas['DepositIntentRequest'];
|
|
1808
|
+
type DepositIntentResponse = Schemas['DepositIntentResponse'];
|
|
1809
|
+
type DepositStatusResponse = Schemas['DepositStatusResponse'];
|
|
1673
1810
|
type RequestStatusResponse = Schemas['RequestStatusResponse'];
|
|
1674
1811
|
type RequestListResponse = Schemas['RequestListResponse'];
|
|
1675
1812
|
type PolicyResponse = Schemas['PolicyResponse'];
|
|
@@ -1753,6 +1890,12 @@ declare class OutlayerClient {
|
|
|
1753
1890
|
swap(opts: SwapRequest & Idempotent): Promise<SwapResponse>;
|
|
1754
1891
|
swapQuote(opts: SwapRequest): Promise<SwapQuoteResponse>;
|
|
1755
1892
|
signMessage(opts: SignMessageRequest): Promise<SignMessageResponse>;
|
|
1893
|
+
/**
|
|
1894
|
+
* Create a one-time deposit address on a source chain. Send funds there,
|
|
1895
|
+
* then poll {@link getDepositStatus} until `success`.
|
|
1896
|
+
*/
|
|
1897
|
+
createDepositIntent(opts: DepositIntentRequest): Promise<DepositIntentResponse>;
|
|
1898
|
+
getDepositStatus(intentId: string): Promise<DepositStatusResponse>;
|
|
1756
1899
|
getRequest(id: string): Promise<RequestStatusResponse>;
|
|
1757
1900
|
listRequests(opts?: {
|
|
1758
1901
|
type?: RequestType;
|
|
@@ -1795,4 +1938,4 @@ declare class BadRequestError extends OutlayerError {
|
|
|
1795
1938
|
constructor(opts: OutlayerErrorOptions);
|
|
1796
1939
|
}
|
|
1797
1940
|
|
|
1798
|
-
export { type AddressResponse, type ApiErrorCode, type ApprovalConfig, ApprovalsAPI, type ApproveResponse, AuditAPI, type AuditEvent, type AuditResponse, BadRequestError, type BalanceResponse, type CallRequest, type CallResponse, type Chain, type ClientOptions, type DryRunResponse, type EncryptPolicyRequest, type EncryptPolicyResponse, type ErrorCode, type IntentsDepositRequest, type IntentsDepositResponse, NETWORK_BASE_URLS, type Nep413Auth, type Network, NotFoundError, OutlayerClient, OutlayerError, type PendingApproval, type PendingApprovalsResponse, PolicyAPI, PolicyDeniedError, type PolicyResponse, type PolicyRules, RateLimitedError, type RegisterRequest, type RegisterResponse, type RequestListResponse, type RequestStatus, type RequestStatusResponse, type RequestType, type RetryConfig, type SignMessageRequest, type SignMessageResponse, type SignPolicyResponse, type SwapQuoteResponse, type SwapRequest, type SwapResponse, type TokensResponse, type TransferRequest, type UnauthenticatedOptions, UnauthorizedError, WalletFrozenError, type WithdrawRequest, type WithdrawResponse };
|
|
1941
|
+
export { type AddressResponse, type ApiErrorCode, type ApprovalConfig, ApprovalsAPI, type ApproveResponse, AuditAPI, type AuditEvent, type AuditResponse, BadRequestError, type BalanceResponse, type CallRequest, type CallResponse, type Chain, type ClientOptions, type DepositIntentRequest, type DepositIntentResponse, type DepositStatusResponse, type DryRunResponse, type EncryptPolicyRequest, type EncryptPolicyResponse, type ErrorCode, type IntentsDepositRequest, type IntentsDepositResponse, NETWORK_BASE_URLS, type Nep413Auth, type Network, NotFoundError, OutlayerClient, OutlayerError, type PendingApproval, type PendingApprovalsResponse, PolicyAPI, PolicyDeniedError, type PolicyResponse, type PolicyRules, RateLimitedError, type RegisterRequest, type RegisterResponse, type RequestListResponse, type RequestStatus, type RequestStatusResponse, type RequestType, type RetryConfig, type SignMessageRequest, type SignMessageResponse, type SignPolicyResponse, type SwapQuoteResponse, type SwapRequest, type SwapResponse, type TokensResponse, type TransferRequest, type UnauthenticatedOptions, UnauthorizedError, WalletFrozenError, type WithdrawRequest, type WithdrawResponse };
|
package/dist/index.js
CHANGED
|
@@ -362,6 +362,23 @@ var OutlayerClient = class {
|
|
|
362
362
|
this.retry
|
|
363
363
|
);
|
|
364
364
|
}
|
|
365
|
+
// ------- Cross-chain deposit (1Click) -------
|
|
366
|
+
/**
|
|
367
|
+
* Create a one-time deposit address on a source chain. Send funds there,
|
|
368
|
+
* then poll {@link getDepositStatus} until `success`.
|
|
369
|
+
*/
|
|
370
|
+
createDepositIntent(opts) {
|
|
371
|
+
return runWithRetry(
|
|
372
|
+
() => this.client.POST("/wallet/v1/deposit-intent", { body: opts }),
|
|
373
|
+
this.retry
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
getDepositStatus(intentId) {
|
|
377
|
+
return runWithRetry(
|
|
378
|
+
() => this.client.GET("/wallet/v1/deposit-status", { params: { query: { id: intentId } } }),
|
|
379
|
+
this.retry
|
|
380
|
+
);
|
|
381
|
+
}
|
|
365
382
|
// ------- Async request tracking -------
|
|
366
383
|
getRequest(id) {
|
|
367
384
|
return runWithRetry(
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/client.ts"],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,GAAA,CAAI,0BAAA,EAA4B,EAAE,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,EAAA,EAAG,IAAK,CAAA;AAAA,MAC9E,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AAAA,EAEA,YAAA,CACE,IAAA,GAAwF,EAAC,EAC3D;AAC9B,IAAA,OAAO,YAAA;AAAA,MACL,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,qBAAA,EAAuB,EAAE,MAAA,EAAQ,EAAE,KAAA,EAAO,IAAA,EAAK,EAAG,CAAA;AAAA,MACxE,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AACF","file":"index.js","sourcesContent":["import type { components } from './types.js';\n\nexport type ApiErrorCode = components['schemas']['ErrorCode'];\nexport type ErrorCode = ApiErrorCode | 'network_error' | 'parse_error';\n\nexport type ErrorBody = {\n error?: ApiErrorCode;\n message?: string;\n details?: unknown;\n};\n\nexport interface OutlayerErrorOptions {\n code: ErrorCode;\n message: string;\n status: number;\n details?: unknown;\n}\n\nexport class OutlayerError extends Error {\n readonly code: ErrorCode;\n readonly status: number;\n readonly details: unknown;\n\n constructor(opts: OutlayerErrorOptions) {\n super(opts.message);\n this.name = 'OutlayerError';\n this.code = opts.code;\n this.status = opts.status;\n this.details = opts.details;\n }\n}\n\nexport class PolicyDeniedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'PolicyDeniedError';\n }\n}\n\nexport class WalletFrozenError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'WalletFrozenError';\n }\n}\n\nexport class UnauthorizedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'UnauthorizedError';\n }\n}\n\nexport class RateLimitedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'RateLimitedError';\n }\n}\n\nexport class NotFoundError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'NotFoundError';\n }\n}\n\nexport class BadRequestError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'BadRequestError';\n }\n}\n\nconst codeToCtor: Partial<Record<ErrorCode, new (opts: OutlayerErrorOptions) => OutlayerError>> = {\n policy_denied: PolicyDeniedError,\n wallet_frozen: WalletFrozenError,\n missing_auth: UnauthorizedError,\n invalid_api_key: UnauthorizedError,\n timestamp_expired: UnauthorizedError,\n rate_limited: RateLimitedError,\n request_not_found: NotFoundError,\n approval_not_found: NotFoundError,\n bad_request: BadRequestError,\n invalid_address: BadRequestError,\n insufficient_balance: BadRequestError,\n unsupported_chain: BadRequestError,\n unsupported_token: BadRequestError,\n};\n\nexport function makeError(body: ErrorBody, status: number): OutlayerError {\n const code: ErrorCode = body.error ?? 'parse_error';\n const message = body.message ?? `HTTP ${status}`;\n const opts: OutlayerErrorOptions = body.details !== undefined\n ? { code, message, status, details: body.details }\n : { code, message, status };\n const Ctor = codeToCtor[code] ?? OutlayerError;\n return new Ctor(opts);\n}\n\nexport async function errorFromResponse(response: Response, parsed?: unknown): Promise<OutlayerError> {\n let body: ErrorBody;\n if (parsed && typeof parsed === 'object') {\n body = parsed as ErrorBody;\n } else {\n try {\n body = (await response.clone().json()) as ErrorBody;\n } catch {\n body = { error: 'internal_error', message: response.statusText };\n }\n }\n return makeError(body, response.status);\n}\n","import createClient, { type Client } from 'openapi-fetch';\nimport type { paths } from './types.js';\nimport { OutlayerError, errorFromResponse } from './errors.js';\n\nexport type Network = 'mainnet' | 'testnet';\n\nexport const NETWORK_BASE_URLS: Record<Network, string> = {\n mainnet: 'https://api.outlayer.fastnear.com',\n testnet: 'https://api.testnet.outlayer.fastnear.com',\n};\n\nexport const DEFAULT_BASE_URL = NETWORK_BASE_URLS.mainnet;\n\nexport type RetryConfig = {\n maxAttempts?: number;\n initialDelayMs?: number;\n maxDelayMs?: number;\n};\n\nexport type ClientOptions = {\n apiKey: string;\n /**\n * NEAR network to target. Defaults to `mainnet`. NEAR Intents (cross-chain\n * swaps + gasless withdrawals) only work on mainnet — use testnet for the\n * register / policy / sign-message flow while developing.\n */\n network?: Network;\n /** Overrides `network` for self-hosted or staging deployments. */\n baseUrl?: string;\n fetch?: typeof fetch;\n retry?: RetryConfig;\n};\n\nexport type UnauthenticatedOptions = {\n network?: Network;\n baseUrl?: string;\n fetch?: typeof fetch;\n};\n\nfunction resolveBaseUrl(opts: { network?: Network; baseUrl?: string }): string {\n if (opts.baseUrl) return opts.baseUrl;\n if (opts.network) return NETWORK_BASE_URLS[opts.network];\n return DEFAULT_BASE_URL;\n}\n\nexport const DEFAULT_RETRY: Required<RetryConfig> = {\n maxAttempts: 3,\n initialDelayMs: 100,\n maxDelayMs: 1600,\n};\n\nexport type FetchClient = Client<paths, `${string}/${string}`>;\n\nexport function makeClient(opts: ClientOptions): { client: FetchClient; retry: Required<RetryConfig> } {\n const init: Parameters<typeof createClient<paths>>[0] = {\n baseUrl: resolveBaseUrl(opts),\n headers: { Authorization: `Bearer ${opts.apiKey}` },\n };\n if (opts.fetch) init.fetch = opts.fetch;\n const client = createClient<paths>(init);\n const retry: Required<RetryConfig> = { ...DEFAULT_RETRY, ...opts.retry };\n return { client, retry };\n}\n\nexport function makeUnauthenticatedClient(opts: UnauthenticatedOptions = {}): FetchClient {\n const init: Parameters<typeof createClient<paths>>[0] = {\n baseUrl: resolveBaseUrl(opts),\n };\n if (opts.fetch) init.fetch = opts.fetch;\n return createClient<paths>(init);\n}\n\nexport type FetchCall<T> = () => Promise<{\n data?: T;\n error?: unknown;\n response: Response;\n}>;\n\nexport async function runWithRetry<T>(\n call: FetchCall<T>,\n retry: Required<RetryConfig>,\n): Promise<T> {\n let lastError: unknown;\n for (let attempt = 1; attempt <= retry.maxAttempts; attempt++) {\n try {\n const { data, error, response } = await call();\n if (response.ok) {\n return data as T;\n }\n const err = await errorFromResponse(response, error);\n if (err.status >= 500 && attempt < retry.maxAttempts) {\n lastError = err;\n await sleep(backoff(attempt, retry));\n continue;\n }\n throw err;\n } catch (e) {\n if (e instanceof OutlayerError) throw e;\n lastError = e;\n if (attempt < retry.maxAttempts && isNetworkError(e)) {\n await sleep(backoff(attempt, retry));\n continue;\n }\n throw new OutlayerError({\n code: 'network_error',\n message: e instanceof Error ? e.message : String(e),\n status: 0,\n });\n }\n }\n throw lastError;\n}\n\nfunction backoff(attempt: number, cfg: Required<RetryConfig>): number {\n return Math.min(cfg.maxDelayMs, cfg.initialDelayMs * 2 ** (attempt - 1));\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nfunction isNetworkError(e: unknown): boolean {\n return e instanceof TypeError;\n}\n\nexport function newIdempotencyKey(): string {\n return crypto.randomUUID();\n}\n","import type { components } from './types.js';\nimport {\n type ClientOptions,\n type FetchClient,\n type RetryConfig,\n type UnauthenticatedOptions,\n DEFAULT_RETRY,\n makeClient,\n makeUnauthenticatedClient,\n newIdempotencyKey,\n runWithRetry,\n} from './http.js';\nimport { errorFromResponse } from './errors.js';\n\ntype Schemas = components['schemas'];\n\n// ---------------------------------------------------------------------------\n// Re-exported user-facing types (so consumers don't import paths/components)\n// ---------------------------------------------------------------------------\n\nexport type Chain = Schemas['Chain'];\nexport type RequestType = Schemas['RequestType'];\nexport type RequestStatus = Schemas['RequestStatus'];\n\nexport type RegisterRequest = Schemas['RegisterRequest'];\nexport type RegisterResponse = Schemas['RegisterResponse'];\nexport type AddressResponse = Schemas['AddressResponse'];\nexport type BalanceResponse = Schemas['BalanceResponse'];\nexport type TokensResponse = Schemas['TokensResponse'];\n\nexport type CallRequest = Schemas['CallRequest'];\nexport type CallResponse = Schemas['CallResponse'];\nexport type TransferRequest = Schemas['TransferRequest'];\nexport type IntentsDepositRequest = Schemas['IntentsDepositRequest'];\nexport type IntentsDepositResponse = Schemas['IntentsDepositResponse'];\n\nexport type WithdrawRequest = Schemas['WithdrawRequest'];\nexport type WithdrawResponse = Schemas['WithdrawResponse'];\nexport type DryRunResponse = Schemas['DryRunResponse'];\n\nexport type SwapRequest = Schemas['SwapRequest'];\nexport type SwapResponse = Schemas['SwapResponse'];\nexport type SwapQuoteResponse = Schemas['SwapQuoteResponse'];\n\nexport type SignMessageRequest = Schemas['SignMessageRequest'];\nexport type SignMessageResponse = Schemas['SignMessageResponse'];\n\nexport type RequestStatusResponse = Schemas['RequestStatusResponse'];\nexport type RequestListResponse = Schemas['RequestListResponse'];\n\nexport type PolicyResponse = Schemas['PolicyResponse'];\nexport type PolicyRules = Schemas['PolicyRules'];\nexport type ApprovalConfig = Schemas['ApprovalConfig'];\nexport type EncryptPolicyRequest = Schemas['EncryptPolicyRequest'];\nexport type EncryptPolicyResponse = Schemas['EncryptPolicyResponse'];\nexport type SignPolicyResponse = Schemas['SignPolicyResponse'];\n\nexport type PendingApproval = Schemas['PendingApproval'];\nexport type PendingApprovalsResponse = Schemas['PendingApprovalsResponse'];\nexport type Nep413Auth = Schemas['Nep413Auth'];\nexport type ApproveResponse = Schemas['ApproveResponse'];\n\nexport type AuditEvent = Schemas['AuditEvent'];\nexport type AuditResponse = Schemas['AuditResponse'];\n\n// ---------------------------------------------------------------------------\n// Shared helpers\n// ---------------------------------------------------------------------------\n\ntype Idempotent = { idempotencyKey?: string };\n\nfunction idempotencyHeader(key: string | undefined): Record<string, string> {\n return { 'Idempotency-Key': key ?? newIdempotencyKey() };\n}\n\n// ---------------------------------------------------------------------------\n// Sub-namespaces\n// ---------------------------------------------------------------------------\n\nexport class PolicyAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n get(): Promise<PolicyResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/policy'), this.retry);\n }\n\n encrypt(body: EncryptPolicyRequest): Promise<EncryptPolicyResponse> {\n return runWithRetry(() => this.client.POST('/wallet/v1/encrypt-policy', { body }), this.retry);\n }\n\n sign(encryptedData: string): Promise<SignPolicyResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/sign-policy', { body: { encrypted_data: encryptedData } }),\n this.retry,\n );\n }\n\n invalidateCache(walletId: string): Promise<void> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/invalidate-cache', { body: { wallet_id: walletId } }),\n this.retry,\n ).then(() => undefined);\n }\n}\n\nexport class ApprovalsAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n listPending(): Promise<PendingApprovalsResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/pending_approvals'), this.retry);\n }\n\n approve(approvalId: string, auth: Nep413Auth): Promise<ApproveResponse> {\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/approve/{id}', {\n params: { path: { id: approvalId } },\n body: auth,\n }),\n this.retry,\n );\n }\n\n reject(approvalId: string, auth: Nep413Auth, reason?: string): Promise<ApproveResponse> {\n const body = reason !== undefined ? { ...auth, reason } : auth;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/reject/{id}', {\n params: { path: { id: approvalId } },\n body,\n }),\n this.retry,\n );\n }\n}\n\nexport class AuditAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n list(opts: { limit?: number; offset?: number } = {}): Promise<AuditResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/audit', { params: { query: opts } }),\n this.retry,\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Main client\n// ---------------------------------------------------------------------------\n\nexport class OutlayerClient {\n private readonly client: FetchClient;\n private readonly retry: Required<RetryConfig>;\n\n readonly policy: PolicyAPI;\n readonly approvals: ApprovalsAPI;\n readonly audit: AuditAPI;\n\n constructor(opts: ClientOptions) {\n const { client, retry } = makeClient(opts);\n this.client = client;\n this.retry = retry;\n this.policy = new PolicyAPI(client, retry);\n this.approvals = new ApprovalsAPI(client, retry);\n this.audit = new AuditAPI(client, retry);\n }\n\n // ------- Static factory: register a new wallet (no auth) -------\n\n /**\n * Register a new wallet and obtain an API key.\n *\n * - Empty call: anonymous wallet on OutLayer's shared master. Convenient, no setup.\n * - With `vaultId`: bind to a deployed customer vault so keys derive through\n * the per-vault master. Vault binding is permanent.\n * - With `body`: full control — pass any `RegisterRequest` field (e.g., NEP-413\n * account-binding fields). `vaultId` is merged into `body.vault_id` if not\n * already set.\n *\n * Vault deployment is NOT done here — use the dashboard\n * (https://outlayer.fastnear.com/vault) or `outlayer vault init` CLI.\n * See docs/vaults.md for the full flow.\n */\n static async register(\n opts: {\n vaultId?: string;\n body?: RegisterRequest;\n } & UnauthenticatedOptions = {},\n ): Promise<RegisterResponse> {\n const client = makeUnauthenticatedClient(opts);\n const body: RegisterRequest = { ...(opts.body ?? {}) };\n if (opts.vaultId !== undefined && body.vault_id === undefined) {\n body.vault_id = opts.vaultId;\n }\n const { data, error, response } = await client.POST('/register', { body });\n if (!response.ok) throw await errorFromResponse(response, error);\n return data as RegisterResponse;\n }\n\n // ------- Wallet read -------\n\n getAddress(chain: Chain): Promise<AddressResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/address', { params: { query: { chain } } }),\n this.retry,\n );\n }\n\n getBalance(\n opts: { chain?: Chain; token?: string; source?: 'chain' | 'intents' } = {},\n ): Promise<BalanceResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/balance', { params: { query: opts } }),\n this.retry,\n );\n }\n\n listTokens(): Promise<TokensResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/tokens'), this.retry);\n }\n\n // ------- Wallet write -------\n\n call(opts: CallRequest & Idempotent): Promise<CallResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/call', {\n body: body as CallRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n transfer(opts: TransferRequest & Idempotent): Promise<CallResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/transfer', {\n body: body as TransferRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n intentsDeposit(opts: IntentsDepositRequest & Idempotent): Promise<IntentsDepositResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/deposit', {\n body: body as IntentsDepositRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n withdraw(opts: WithdrawRequest & Idempotent): Promise<WithdrawResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/withdraw', {\n body: body as WithdrawRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n withdrawDryRun(opts: WithdrawRequest): Promise<DryRunResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/intents/withdraw/dry-run', { body: opts }),\n this.retry,\n );\n }\n\n swap(opts: SwapRequest & Idempotent): Promise<SwapResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/swap', {\n body: body as SwapRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n swapQuote(opts: SwapRequest): Promise<SwapQuoteResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/intents/swap/quote', { body: opts }),\n this.retry,\n );\n }\n\n signMessage(opts: SignMessageRequest): Promise<SignMessageResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/sign-message', { body: opts }),\n this.retry,\n );\n }\n\n // ------- Async request tracking -------\n\n getRequest(id: string): Promise<RequestStatusResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/requests/{id}', { params: { path: { id } } }),\n this.retry,\n );\n }\n\n listRequests(\n opts: { type?: RequestType; status?: RequestStatus; limit?: number; offset?: number } = {},\n ): Promise<RequestListResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/requests', { params: { query: opts } }),\n this.retry,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","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O,YAAA;AAAA,MACL,MAAM,KAAK,MAAA,CAAO,IAAA,CAAK,6BAA6B,EAAE,IAAA,EAAM,MAAM,CAAA;AAAA,MAClE,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AAAA,EAEA,iBAAiB,QAAA,EAAkD;AACjE,IAAA,OAAO,YAAA;AAAA,MACL,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,6BAA6B,EAAE,MAAA,EAAQ,EAAE,KAAA,EAAO,EAAE,EAAA,EAAI,QAAA,EAAS,IAAK,CAAA;AAAA,MAC1F,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AAAA;AAAA,EAIA,WAAW,EAAA,EAA4C;AACrD,IAAA,OAAO,YAAA;AAAA,MACL,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,0BAAA,EAA4B,EAAE,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,EAAA,EAAG,IAAK,CAAA;AAAA,MAC9E,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AAAA,EAEA,YAAA,CACE,IAAA,GAAwF,EAAC,EAC3D;AAC9B,IAAA,OAAO,YAAA;AAAA,MACL,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,qBAAA,EAAuB,EAAE,MAAA,EAAQ,EAAE,KAAA,EAAO,IAAA,EAAK,EAAG,CAAA;AAAA,MACxE,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AACF","file":"index.js","sourcesContent":["import type { components } from './types.js';\n\nexport type ApiErrorCode = components['schemas']['ErrorCode'];\nexport type ErrorCode = ApiErrorCode | 'network_error' | 'parse_error';\n\nexport type ErrorBody = {\n error?: ApiErrorCode;\n message?: string;\n details?: unknown;\n};\n\nexport interface OutlayerErrorOptions {\n code: ErrorCode;\n message: string;\n status: number;\n details?: unknown;\n}\n\nexport class OutlayerError extends Error {\n readonly code: ErrorCode;\n readonly status: number;\n readonly details: unknown;\n\n constructor(opts: OutlayerErrorOptions) {\n super(opts.message);\n this.name = 'OutlayerError';\n this.code = opts.code;\n this.status = opts.status;\n this.details = opts.details;\n }\n}\n\nexport class PolicyDeniedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'PolicyDeniedError';\n }\n}\n\nexport class WalletFrozenError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'WalletFrozenError';\n }\n}\n\nexport class UnauthorizedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'UnauthorizedError';\n }\n}\n\nexport class RateLimitedError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'RateLimitedError';\n }\n}\n\nexport class NotFoundError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'NotFoundError';\n }\n}\n\nexport class BadRequestError extends OutlayerError {\n constructor(opts: OutlayerErrorOptions) {\n super(opts);\n this.name = 'BadRequestError';\n }\n}\n\nconst codeToCtor: Partial<Record<ErrorCode, new (opts: OutlayerErrorOptions) => OutlayerError>> = {\n policy_denied: PolicyDeniedError,\n wallet_frozen: WalletFrozenError,\n missing_auth: UnauthorizedError,\n invalid_api_key: UnauthorizedError,\n timestamp_expired: UnauthorizedError,\n rate_limited: RateLimitedError,\n request_not_found: NotFoundError,\n approval_not_found: NotFoundError,\n bad_request: BadRequestError,\n invalid_address: BadRequestError,\n insufficient_balance: BadRequestError,\n unsupported_chain: BadRequestError,\n unsupported_token: BadRequestError,\n};\n\nexport function makeError(body: ErrorBody, status: number): OutlayerError {\n const code: ErrorCode = body.error ?? 'parse_error';\n const message = body.message ?? `HTTP ${status}`;\n const opts: OutlayerErrorOptions = body.details !== undefined\n ? { code, message, status, details: body.details }\n : { code, message, status };\n const Ctor = codeToCtor[code] ?? OutlayerError;\n return new Ctor(opts);\n}\n\nexport async function errorFromResponse(response: Response, parsed?: unknown): Promise<OutlayerError> {\n let body: ErrorBody;\n if (parsed && typeof parsed === 'object') {\n body = parsed as ErrorBody;\n } else {\n try {\n body = (await response.clone().json()) as ErrorBody;\n } catch {\n body = { error: 'internal_error', message: response.statusText };\n }\n }\n return makeError(body, response.status);\n}\n","import createClient, { type Client } from 'openapi-fetch';\nimport type { paths } from './types.js';\nimport { OutlayerError, errorFromResponse } from './errors.js';\n\nexport type Network = 'mainnet' | 'testnet';\n\nexport const NETWORK_BASE_URLS: Record<Network, string> = {\n mainnet: 'https://api.outlayer.fastnear.com',\n testnet: 'https://api.testnet.outlayer.fastnear.com',\n};\n\nexport const DEFAULT_BASE_URL = NETWORK_BASE_URLS.mainnet;\n\nexport type RetryConfig = {\n maxAttempts?: number;\n initialDelayMs?: number;\n maxDelayMs?: number;\n};\n\nexport type ClientOptions = {\n apiKey: string;\n /**\n * NEAR network to target. Defaults to `mainnet`. NEAR Intents (cross-chain\n * swaps + gasless withdrawals) only work on mainnet — use testnet for the\n * register / policy / sign-message flow while developing.\n */\n network?: Network;\n /** Overrides `network` for self-hosted or staging deployments. */\n baseUrl?: string;\n fetch?: typeof fetch;\n retry?: RetryConfig;\n};\n\nexport type UnauthenticatedOptions = {\n network?: Network;\n baseUrl?: string;\n fetch?: typeof fetch;\n};\n\nfunction resolveBaseUrl(opts: { network?: Network; baseUrl?: string }): string {\n if (opts.baseUrl) return opts.baseUrl;\n if (opts.network) return NETWORK_BASE_URLS[opts.network];\n return DEFAULT_BASE_URL;\n}\n\nexport const DEFAULT_RETRY: Required<RetryConfig> = {\n maxAttempts: 3,\n initialDelayMs: 100,\n maxDelayMs: 1600,\n};\n\nexport type FetchClient = Client<paths, `${string}/${string}`>;\n\nexport function makeClient(opts: ClientOptions): { client: FetchClient; retry: Required<RetryConfig> } {\n const init: Parameters<typeof createClient<paths>>[0] = {\n baseUrl: resolveBaseUrl(opts),\n headers: { Authorization: `Bearer ${opts.apiKey}` },\n };\n if (opts.fetch) init.fetch = opts.fetch;\n const client = createClient<paths>(init);\n const retry: Required<RetryConfig> = { ...DEFAULT_RETRY, ...opts.retry };\n return { client, retry };\n}\n\nexport function makeUnauthenticatedClient(opts: UnauthenticatedOptions = {}): FetchClient {\n const init: Parameters<typeof createClient<paths>>[0] = {\n baseUrl: resolveBaseUrl(opts),\n };\n if (opts.fetch) init.fetch = opts.fetch;\n return createClient<paths>(init);\n}\n\nexport type FetchCall<T> = () => Promise<{\n data?: T;\n error?: unknown;\n response: Response;\n}>;\n\nexport async function runWithRetry<T>(\n call: FetchCall<T>,\n retry: Required<RetryConfig>,\n): Promise<T> {\n let lastError: unknown;\n for (let attempt = 1; attempt <= retry.maxAttempts; attempt++) {\n try {\n const { data, error, response } = await call();\n if (response.ok) {\n return data as T;\n }\n const err = await errorFromResponse(response, error);\n if (err.status >= 500 && attempt < retry.maxAttempts) {\n lastError = err;\n await sleep(backoff(attempt, retry));\n continue;\n }\n throw err;\n } catch (e) {\n if (e instanceof OutlayerError) throw e;\n lastError = e;\n if (attempt < retry.maxAttempts && isNetworkError(e)) {\n await sleep(backoff(attempt, retry));\n continue;\n }\n throw new OutlayerError({\n code: 'network_error',\n message: e instanceof Error ? e.message : String(e),\n status: 0,\n });\n }\n }\n throw lastError;\n}\n\nfunction backoff(attempt: number, cfg: Required<RetryConfig>): number {\n return Math.min(cfg.maxDelayMs, cfg.initialDelayMs * 2 ** (attempt - 1));\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nfunction isNetworkError(e: unknown): boolean {\n return e instanceof TypeError;\n}\n\nexport function newIdempotencyKey(): string {\n return crypto.randomUUID();\n}\n","import type { components } from './types.js';\nimport {\n type ClientOptions,\n type FetchClient,\n type RetryConfig,\n type UnauthenticatedOptions,\n DEFAULT_RETRY,\n makeClient,\n makeUnauthenticatedClient,\n newIdempotencyKey,\n runWithRetry,\n} from './http.js';\nimport { errorFromResponse } from './errors.js';\n\ntype Schemas = components['schemas'];\n\n// ---------------------------------------------------------------------------\n// Re-exported user-facing types (so consumers don't import paths/components)\n// ---------------------------------------------------------------------------\n\nexport type Chain = Schemas['Chain'];\nexport type RequestType = Schemas['RequestType'];\nexport type RequestStatus = Schemas['RequestStatus'];\n\nexport type RegisterRequest = Schemas['RegisterRequest'];\nexport type RegisterResponse = Schemas['RegisterResponse'];\nexport type AddressResponse = Schemas['AddressResponse'];\nexport type BalanceResponse = Schemas['BalanceResponse'];\nexport type TokensResponse = Schemas['TokensResponse'];\n\nexport type CallRequest = Schemas['CallRequest'];\nexport type CallResponse = Schemas['CallResponse'];\nexport type TransferRequest = Schemas['TransferRequest'];\nexport type IntentsDepositRequest = Schemas['IntentsDepositRequest'];\nexport type IntentsDepositResponse = Schemas['IntentsDepositResponse'];\n\nexport type WithdrawRequest = Schemas['WithdrawRequest'];\nexport type WithdrawResponse = Schemas['WithdrawResponse'];\nexport type DryRunResponse = Schemas['DryRunResponse'];\n\nexport type SwapRequest = Schemas['SwapRequest'];\nexport type SwapResponse = Schemas['SwapResponse'];\nexport type SwapQuoteResponse = Schemas['SwapQuoteResponse'];\n\nexport type SignMessageRequest = Schemas['SignMessageRequest'];\nexport type SignMessageResponse = Schemas['SignMessageResponse'];\n\nexport type DepositIntentRequest = Schemas['DepositIntentRequest'];\nexport type DepositIntentResponse = Schemas['DepositIntentResponse'];\nexport type DepositStatusResponse = Schemas['DepositStatusResponse'];\n\nexport type RequestStatusResponse = Schemas['RequestStatusResponse'];\nexport type RequestListResponse = Schemas['RequestListResponse'];\n\nexport type PolicyResponse = Schemas['PolicyResponse'];\nexport type PolicyRules = Schemas['PolicyRules'];\nexport type ApprovalConfig = Schemas['ApprovalConfig'];\nexport type EncryptPolicyRequest = Schemas['EncryptPolicyRequest'];\nexport type EncryptPolicyResponse = Schemas['EncryptPolicyResponse'];\nexport type SignPolicyResponse = Schemas['SignPolicyResponse'];\n\nexport type PendingApproval = Schemas['PendingApproval'];\nexport type PendingApprovalsResponse = Schemas['PendingApprovalsResponse'];\nexport type Nep413Auth = Schemas['Nep413Auth'];\nexport type ApproveResponse = Schemas['ApproveResponse'];\n\nexport type AuditEvent = Schemas['AuditEvent'];\nexport type AuditResponse = Schemas['AuditResponse'];\n\n// ---------------------------------------------------------------------------\n// Shared helpers\n// ---------------------------------------------------------------------------\n\ntype Idempotent = { idempotencyKey?: string };\n\nfunction idempotencyHeader(key: string | undefined): Record<string, string> {\n return { 'Idempotency-Key': key ?? newIdempotencyKey() };\n}\n\n// ---------------------------------------------------------------------------\n// Sub-namespaces\n// ---------------------------------------------------------------------------\n\nexport class PolicyAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n get(): Promise<PolicyResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/policy'), this.retry);\n }\n\n encrypt(body: EncryptPolicyRequest): Promise<EncryptPolicyResponse> {\n return runWithRetry(() => this.client.POST('/wallet/v1/encrypt-policy', { body }), this.retry);\n }\n\n sign(encryptedData: string): Promise<SignPolicyResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/sign-policy', { body: { encrypted_data: encryptedData } }),\n this.retry,\n );\n }\n\n invalidateCache(walletId: string): Promise<void> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/invalidate-cache', { body: { wallet_id: walletId } }),\n this.retry,\n ).then(() => undefined);\n }\n}\n\nexport class ApprovalsAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n listPending(): Promise<PendingApprovalsResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/pending_approvals'), this.retry);\n }\n\n approve(approvalId: string, auth: Nep413Auth): Promise<ApproveResponse> {\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/approve/{id}', {\n params: { path: { id: approvalId } },\n body: auth,\n }),\n this.retry,\n );\n }\n\n reject(approvalId: string, auth: Nep413Auth, reason?: string): Promise<ApproveResponse> {\n const body = reason !== undefined ? { ...auth, reason } : auth;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/reject/{id}', {\n params: { path: { id: approvalId } },\n body,\n }),\n this.retry,\n );\n }\n}\n\nexport class AuditAPI {\n constructor(\n private readonly client: FetchClient,\n private readonly retry: Required<RetryConfig>,\n ) {}\n\n list(opts: { limit?: number; offset?: number } = {}): Promise<AuditResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/audit', { params: { query: opts } }),\n this.retry,\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Main client\n// ---------------------------------------------------------------------------\n\nexport class OutlayerClient {\n private readonly client: FetchClient;\n private readonly retry: Required<RetryConfig>;\n\n readonly policy: PolicyAPI;\n readonly approvals: ApprovalsAPI;\n readonly audit: AuditAPI;\n\n constructor(opts: ClientOptions) {\n const { client, retry } = makeClient(opts);\n this.client = client;\n this.retry = retry;\n this.policy = new PolicyAPI(client, retry);\n this.approvals = new ApprovalsAPI(client, retry);\n this.audit = new AuditAPI(client, retry);\n }\n\n // ------- Static factory: register a new wallet (no auth) -------\n\n /**\n * Register a new wallet and obtain an API key.\n *\n * - Empty call: anonymous wallet on OutLayer's shared master. Convenient, no setup.\n * - With `vaultId`: bind to a deployed customer vault so keys derive through\n * the per-vault master. Vault binding is permanent.\n * - With `body`: full control — pass any `RegisterRequest` field (e.g., NEP-413\n * account-binding fields). `vaultId` is merged into `body.vault_id` if not\n * already set.\n *\n * Vault deployment is NOT done here — use the dashboard\n * (https://outlayer.fastnear.com/vault) or `outlayer vault init` CLI.\n * See docs/vaults.md for the full flow.\n */\n static async register(\n opts: {\n vaultId?: string;\n body?: RegisterRequest;\n } & UnauthenticatedOptions = {},\n ): Promise<RegisterResponse> {\n const client = makeUnauthenticatedClient(opts);\n const body: RegisterRequest = { ...(opts.body ?? {}) };\n if (opts.vaultId !== undefined && body.vault_id === undefined) {\n body.vault_id = opts.vaultId;\n }\n const { data, error, response } = await client.POST('/register', { body });\n if (!response.ok) throw await errorFromResponse(response, error);\n return data as RegisterResponse;\n }\n\n // ------- Wallet read -------\n\n getAddress(chain: Chain): Promise<AddressResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/address', { params: { query: { chain } } }),\n this.retry,\n );\n }\n\n getBalance(\n opts: { chain?: Chain; token?: string; source?: 'chain' | 'intents' } = {},\n ): Promise<BalanceResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/balance', { params: { query: opts } }),\n this.retry,\n );\n }\n\n listTokens(): Promise<TokensResponse> {\n return runWithRetry(() => this.client.GET('/wallet/v1/tokens'), this.retry);\n }\n\n // ------- Wallet write -------\n\n call(opts: CallRequest & Idempotent): Promise<CallResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/call', {\n body: body as CallRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n transfer(opts: TransferRequest & Idempotent): Promise<CallResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/transfer', {\n body: body as TransferRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n intentsDeposit(opts: IntentsDepositRequest & Idempotent): Promise<IntentsDepositResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/deposit', {\n body: body as IntentsDepositRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n withdraw(opts: WithdrawRequest & Idempotent): Promise<WithdrawResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/withdraw', {\n body: body as WithdrawRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n withdrawDryRun(opts: WithdrawRequest): Promise<DryRunResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/intents/withdraw/dry-run', { body: opts }),\n this.retry,\n );\n }\n\n swap(opts: SwapRequest & Idempotent): Promise<SwapResponse> {\n const { idempotencyKey, ...body } = opts;\n return runWithRetry(\n () =>\n this.client.POST('/wallet/v1/intents/swap', {\n body: body as SwapRequest,\n headers: idempotencyHeader(idempotencyKey),\n }),\n this.retry,\n );\n }\n\n swapQuote(opts: SwapRequest): Promise<SwapQuoteResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/intents/swap/quote', { body: opts }),\n this.retry,\n );\n }\n\n signMessage(opts: SignMessageRequest): Promise<SignMessageResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/sign-message', { body: opts }),\n this.retry,\n );\n }\n\n // ------- Cross-chain deposit (1Click) -------\n\n /**\n * Create a one-time deposit address on a source chain. Send funds there,\n * then poll {@link getDepositStatus} until `success`.\n */\n createDepositIntent(opts: DepositIntentRequest): Promise<DepositIntentResponse> {\n return runWithRetry(\n () => this.client.POST('/wallet/v1/deposit-intent', { body: opts }),\n this.retry,\n );\n }\n\n getDepositStatus(intentId: string): Promise<DepositStatusResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/deposit-status', { params: { query: { id: intentId } } }),\n this.retry,\n );\n }\n\n // ------- Async request tracking -------\n\n getRequest(id: string): Promise<RequestStatusResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/requests/{id}', { params: { path: { id } } }),\n this.retry,\n );\n }\n\n listRequests(\n opts: { type?: RequestType; status?: RequestStatus; limit?: number; offset?: number } = {},\n ): Promise<RequestListResponse> {\n return runWithRetry(\n () => this.client.GET('/wallet/v1/requests', { params: { query: opts } }),\n this.retry,\n );\n }\n}\n"]}
|
package/package.json
CHANGED
package/spec/openapi.yaml
CHANGED
|
@@ -477,6 +477,69 @@ paths:
|
|
|
477
477
|
'500':
|
|
478
478
|
$ref: '#/components/responses/InternalError'
|
|
479
479
|
|
|
480
|
+
/wallet/v1/deposit-intent:
|
|
481
|
+
post:
|
|
482
|
+
tags: [Wallet]
|
|
483
|
+
operationId: createDepositIntent
|
|
484
|
+
summary: Create a cross-chain deposit intent (1Click)
|
|
485
|
+
description: |
|
|
486
|
+
Requests a one-time deposit address on a source chain via NEAR Intents
|
|
487
|
+
1Click. The caller sends `amount` of `token` to the returned
|
|
488
|
+
`deposit_address` on `chain`; the solver bridges it and credits the
|
|
489
|
+
wallet's intents.near balance. Poll `getDepositStatus` until `success`.
|
|
490
|
+
|
|
491
|
+
Amounts are in the token's smallest unit. There's a small bridge fee,
|
|
492
|
+
so `amount_out` < `amount`.
|
|
493
|
+
requestBody:
|
|
494
|
+
required: true
|
|
495
|
+
content:
|
|
496
|
+
application/json:
|
|
497
|
+
schema:
|
|
498
|
+
$ref: '#/components/schemas/DepositIntentRequest'
|
|
499
|
+
example:
|
|
500
|
+
chain: ethereum
|
|
501
|
+
amount: '5000000'
|
|
502
|
+
token: USDC
|
|
503
|
+
responses:
|
|
504
|
+
'200':
|
|
505
|
+
description: Deposit intent created
|
|
506
|
+
content:
|
|
507
|
+
application/json:
|
|
508
|
+
schema:
|
|
509
|
+
$ref: '#/components/schemas/DepositIntentResponse'
|
|
510
|
+
'400':
|
|
511
|
+
$ref: '#/components/responses/BadRequest'
|
|
512
|
+
'401':
|
|
513
|
+
$ref: '#/components/responses/Unauthorized'
|
|
514
|
+
'500':
|
|
515
|
+
$ref: '#/components/responses/InternalError'
|
|
516
|
+
|
|
517
|
+
/wallet/v1/deposit-status:
|
|
518
|
+
get:
|
|
519
|
+
tags: [Wallet]
|
|
520
|
+
operationId: getDepositStatus
|
|
521
|
+
summary: Poll a cross-chain deposit intent's status
|
|
522
|
+
parameters:
|
|
523
|
+
- name: id
|
|
524
|
+
in: query
|
|
525
|
+
required: true
|
|
526
|
+
schema:
|
|
527
|
+
type: string
|
|
528
|
+
description: The `intent_id` from `createDepositIntent`.
|
|
529
|
+
responses:
|
|
530
|
+
'200':
|
|
531
|
+
description: Deposit status
|
|
532
|
+
content:
|
|
533
|
+
application/json:
|
|
534
|
+
schema:
|
|
535
|
+
$ref: '#/components/schemas/DepositStatusResponse'
|
|
536
|
+
'401':
|
|
537
|
+
$ref: '#/components/responses/Unauthorized'
|
|
538
|
+
'404':
|
|
539
|
+
$ref: '#/components/responses/NotFound'
|
|
540
|
+
'500':
|
|
541
|
+
$ref: '#/components/responses/InternalError'
|
|
542
|
+
|
|
480
543
|
/wallet/v1/sign-message:
|
|
481
544
|
post:
|
|
482
545
|
tags: [Wallet]
|
|
@@ -1285,6 +1348,64 @@ components:
|
|
|
1285
1348
|
time_estimate_seconds:
|
|
1286
1349
|
type: integer
|
|
1287
1350
|
|
|
1351
|
+
DepositIntentRequest:
|
|
1352
|
+
type: object
|
|
1353
|
+
required: [chain, amount, token]
|
|
1354
|
+
properties:
|
|
1355
|
+
chain:
|
|
1356
|
+
type: string
|
|
1357
|
+
description: |
|
|
1358
|
+
Source chain to bridge from. Common values: `ethereum`, `solana`,
|
|
1359
|
+
`base`, `arbitrum`, `polygon`, `optimism`, `avalanche`.
|
|
1360
|
+
amount:
|
|
1361
|
+
type: string
|
|
1362
|
+
description: Amount in the token's smallest unit (e.g. `5000000` = 5 USDC).
|
|
1363
|
+
token:
|
|
1364
|
+
type: string
|
|
1365
|
+
description: Token symbol to deposit, e.g. `USDC`.
|
|
1366
|
+
|
|
1367
|
+
DepositIntentResponse:
|
|
1368
|
+
type: object
|
|
1369
|
+
required:
|
|
1370
|
+
- intent_id
|
|
1371
|
+
- deposit_address
|
|
1372
|
+
- amount
|
|
1373
|
+
- amount_out
|
|
1374
|
+
- min_amount_out
|
|
1375
|
+
- expires_at
|
|
1376
|
+
- estimated_time_secs
|
|
1377
|
+
properties:
|
|
1378
|
+
intent_id:
|
|
1379
|
+
type: string
|
|
1380
|
+
deposit_address:
|
|
1381
|
+
type: string
|
|
1382
|
+
description: One-time address on the source chain — send funds here.
|
|
1383
|
+
amount:
|
|
1384
|
+
type: string
|
|
1385
|
+
amount_out:
|
|
1386
|
+
type: string
|
|
1387
|
+
description: Amount credited after the bridge fee.
|
|
1388
|
+
min_amount_out:
|
|
1389
|
+
type: string
|
|
1390
|
+
expires_at:
|
|
1391
|
+
type: string
|
|
1392
|
+
format: date-time
|
|
1393
|
+
estimated_time_secs:
|
|
1394
|
+
type: integer
|
|
1395
|
+
|
|
1396
|
+
DepositStatusResponse:
|
|
1397
|
+
type: object
|
|
1398
|
+
required: [intent_id, status]
|
|
1399
|
+
properties:
|
|
1400
|
+
intent_id:
|
|
1401
|
+
type: string
|
|
1402
|
+
status:
|
|
1403
|
+
type: string
|
|
1404
|
+
enum: [pending, bridging, success, failed, expired]
|
|
1405
|
+
result:
|
|
1406
|
+
type: [object, 'null']
|
|
1407
|
+
additionalProperties: {}
|
|
1408
|
+
|
|
1288
1409
|
SignMessageRequest:
|
|
1289
1410
|
type: object
|
|
1290
1411
|
required: [message, recipient]
|