@pollar/core 0.9.0-rc.2 → 0.9.0-rc.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.d.mts +169 -7
- package/dist/index.d.ts +169 -7
- package/dist/index.js +70 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -7
- package/dist/index.mjs.map +1 -1
- package/dist/index.rn.d.mts +1 -1
- package/dist/index.rn.d.ts +1 -1
- package/dist/index.rn.js +70 -7
- package/dist/index.rn.js.map +1 -1
- package/dist/index.rn.mjs +70 -7
- package/dist/index.rn.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -344,12 +344,17 @@ interface PollarClientConfig {
|
|
|
344
344
|
* Runs the device WebAuthn ceremony for a server-issued challenge and returns
|
|
345
345
|
* the result to forward to the backend: a registration response for a new user
|
|
346
346
|
* (`create()`) or an authentication assertion for a returning one (`get()`).
|
|
347
|
-
*
|
|
348
|
-
* `create()`)
|
|
349
|
-
*
|
|
347
|
+
* `mode` tells the ceremony which to run: `'login'` runs `get()` only (returning
|
|
348
|
+
* user) and `'register'` runs `create()` only (new wallet) — the caller picks via
|
|
349
|
+
* the "Log in" / "Create wallet" buttons, so there's no ambiguous autodetect that
|
|
350
|
+
* could create a wallet when the user merely cancelled a login prompt. `response`
|
|
351
|
+
* is the browser's PublicKeyCredential serialized to JSON — forwarded verbatim to
|
|
352
|
+
* `/auth/passkey/{register,login}`.
|
|
350
353
|
*/
|
|
354
|
+
type PasskeyMode = 'login' | 'register';
|
|
351
355
|
type PasskeyCeremony = (ctx: {
|
|
352
356
|
challenge: string;
|
|
357
|
+
mode: PasskeyMode;
|
|
353
358
|
}) => Promise<{
|
|
354
359
|
kind: 'login';
|
|
355
360
|
response: unknown;
|
|
@@ -558,6 +563,22 @@ type SubmitOutcome = {
|
|
|
558
563
|
resultCode?: string;
|
|
559
564
|
buildData?: TxBuildContent;
|
|
560
565
|
};
|
|
566
|
+
/**
|
|
567
|
+
* Result of {@link PollarClient.setTrustline}. Like {@link SubmitOutcome} but the
|
|
568
|
+
* `hash` is optional: the sponsored, server-orchestrated path completes without
|
|
569
|
+
* surfacing a transaction hash to the client, whereas the self-paid path returns
|
|
570
|
+
* the underlying submit outcome (hash included).
|
|
571
|
+
*/
|
|
572
|
+
type TrustlineOutcome = {
|
|
573
|
+
status: 'success';
|
|
574
|
+
hash?: string;
|
|
575
|
+
} | {
|
|
576
|
+
status: 'pending';
|
|
577
|
+
hash?: string;
|
|
578
|
+
} | {
|
|
579
|
+
status: 'error';
|
|
580
|
+
details?: string;
|
|
581
|
+
};
|
|
561
582
|
declare const AUTH_ERROR_CODES: {
|
|
562
583
|
readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
|
|
563
584
|
readonly SESSION_EXPIRED: "SESSION_EXPIRED";
|
|
@@ -871,11 +892,19 @@ declare class PollarClient {
|
|
|
871
892
|
verifyEmailCode(code: string): void;
|
|
872
893
|
loginWallet(type: WalletId): void;
|
|
873
894
|
/**
|
|
874
|
-
* "Smart Wallet" login: runs the passkey (WebAuthn) ceremony
|
|
875
|
-
* user
|
|
876
|
-
* ceremony to be configured (e.g. via
|
|
895
|
+
* "Smart Wallet" login: runs the passkey (WebAuthn) `get()` ceremony for a
|
|
896
|
+
* returning user and signs them in. Use {@link createSmartWallet} for a new
|
|
897
|
+
* user. Requires the `passkey` ceremony to be configured (e.g. via
|
|
898
|
+
* `@pollar/react`).
|
|
877
899
|
*/
|
|
878
900
|
loginSmartWallet(): void;
|
|
901
|
+
/**
|
|
902
|
+
* "Smart Wallet" registration: runs the passkey (WebAuthn) `create()` ceremony
|
|
903
|
+
* for a new user and deploys a sponsored smart-account C-address. Use
|
|
904
|
+
* {@link loginSmartWallet} for a returning user. Requires the `passkey`
|
|
905
|
+
* ceremony to be configured (e.g. via `@pollar/react`).
|
|
906
|
+
*/
|
|
907
|
+
createSmartWallet(): void;
|
|
879
908
|
cancelLogin(): void;
|
|
880
909
|
/**
|
|
881
910
|
* Revoke the current session server-side, then clear local storage.
|
|
@@ -952,6 +981,27 @@ declare class PollarClient {
|
|
|
952
981
|
* session. Drives `enabledAssetsState`; mirrors {@link refreshBalance}.
|
|
953
982
|
*/
|
|
954
983
|
refreshAssets(): Promise<void>;
|
|
984
|
+
/**
|
|
985
|
+
* Establishes (omit `limit`) or removes (`limit: '0'`) a trustline for an asset.
|
|
986
|
+
*
|
|
987
|
+
* Routing mirrors how the platform pays for the reserve:
|
|
988
|
+
* - **Sponsored custodial** (`opts.sponsored` true, internal wallet) → the
|
|
989
|
+
* server orchestrates a sponsored `changeTrust`: the app's wallets cover the
|
|
990
|
+
* 0.5 XLM reserve and the fee, so the user pays nothing. Pass the asset's
|
|
991
|
+
* `sponsored` flag (from {@link refreshAssets}) straight through.
|
|
992
|
+
* - **Self-paid** (external/adapter wallet, sponsorship disabled, or a custom
|
|
993
|
+
* asset not configured in the app) → a plain `change_trust` transaction the
|
|
994
|
+
* user's own wallet signs and pays for, via {@link runTx}.
|
|
995
|
+
*
|
|
996
|
+
* Does not refresh on its own — callers should `refreshAssets()` afterwards.
|
|
997
|
+
*/
|
|
998
|
+
setTrustline(asset: {
|
|
999
|
+
code: string;
|
|
1000
|
+
issuer: string;
|
|
1001
|
+
}, opts?: {
|
|
1002
|
+
limit?: string;
|
|
1003
|
+
sponsored?: boolean;
|
|
1004
|
+
}): Promise<TrustlineOutcome>;
|
|
955
1005
|
/**
|
|
956
1006
|
* Builds an unsigned XDR. Drives `_setTransactionState` for modal-style UIs
|
|
957
1007
|
* AND returns a {@link BuildOutcome} so headless callers can `await` and
|
|
@@ -1957,6 +2007,26 @@ interface paths {
|
|
|
1957
2007
|
patch?: never;
|
|
1958
2008
|
trace?: never;
|
|
1959
2009
|
};
|
|
2010
|
+
"/wallet/assets/trustline": {
|
|
2011
|
+
parameters: {
|
|
2012
|
+
query?: never;
|
|
2013
|
+
header?: never;
|
|
2014
|
+
path?: never;
|
|
2015
|
+
cookie?: never;
|
|
2016
|
+
};
|
|
2017
|
+
get?: never;
|
|
2018
|
+
put?: never;
|
|
2019
|
+
/**
|
|
2020
|
+
* Enable or remove a trustline for an enabled asset
|
|
2021
|
+
* @description Establishes (no limit) or removes (limit '0') a trustline on the authenticated user's custodial wallet for an asset configured in the application, sponsored by the app. Returns the refreshed enabled-asset list. Only valid for the sponsored custodial path; custom assets, adapter-managed wallets, and apps with trustline sponsoring disabled must sign a change_trust transaction client-side instead.
|
|
2022
|
+
*/
|
|
2023
|
+
post: operations["postWalletAssetsTrustline"];
|
|
2024
|
+
delete?: never;
|
|
2025
|
+
options?: never;
|
|
2026
|
+
head?: never;
|
|
2027
|
+
patch?: never;
|
|
2028
|
+
trace?: never;
|
|
2029
|
+
};
|
|
1960
2030
|
"/wallet/{publicKey}/balance": {
|
|
1961
2031
|
parameters: {
|
|
1962
2032
|
query?: never;
|
|
@@ -3653,6 +3723,7 @@ interface operations {
|
|
|
3653
3723
|
logoUrl?: string;
|
|
3654
3724
|
emailEnabled?: boolean;
|
|
3655
3725
|
embeddedWallets?: boolean;
|
|
3726
|
+
smartWallet?: boolean;
|
|
3656
3727
|
providers?: {
|
|
3657
3728
|
google?: boolean;
|
|
3658
3729
|
discord?: boolean;
|
|
@@ -5014,6 +5085,8 @@ interface operations {
|
|
|
5014
5085
|
name?: string;
|
|
5015
5086
|
trustlineEstablished: boolean;
|
|
5016
5087
|
limit?: string;
|
|
5088
|
+
enabledInApp: boolean;
|
|
5089
|
+
sponsored?: boolean;
|
|
5017
5090
|
}[];
|
|
5018
5091
|
};
|
|
5019
5092
|
};
|
|
@@ -5047,6 +5120,95 @@ interface operations {
|
|
|
5047
5120
|
};
|
|
5048
5121
|
};
|
|
5049
5122
|
};
|
|
5123
|
+
postWalletAssetsTrustline: {
|
|
5124
|
+
parameters: {
|
|
5125
|
+
query?: never;
|
|
5126
|
+
header?: never;
|
|
5127
|
+
path?: never;
|
|
5128
|
+
cookie?: never;
|
|
5129
|
+
};
|
|
5130
|
+
requestBody: {
|
|
5131
|
+
content: {
|
|
5132
|
+
"application/json": {
|
|
5133
|
+
code: string;
|
|
5134
|
+
issuer: string;
|
|
5135
|
+
limit?: string;
|
|
5136
|
+
};
|
|
5137
|
+
};
|
|
5138
|
+
};
|
|
5139
|
+
responses: {
|
|
5140
|
+
/** @description Trustline updated; refreshed enabled assets */
|
|
5141
|
+
200: {
|
|
5142
|
+
headers: {
|
|
5143
|
+
[name: string]: unknown;
|
|
5144
|
+
};
|
|
5145
|
+
content: {
|
|
5146
|
+
"application/json": {
|
|
5147
|
+
/** @constant */
|
|
5148
|
+
code: "SDK_WALLET_TRUSTLINE";
|
|
5149
|
+
/** @constant */
|
|
5150
|
+
success: true;
|
|
5151
|
+
content: {
|
|
5152
|
+
publicKey: string;
|
|
5153
|
+
/** @enum {string} */
|
|
5154
|
+
network: "testnet" | "mainnet";
|
|
5155
|
+
exists: boolean;
|
|
5156
|
+
assets: {
|
|
5157
|
+
/** @enum {string} */
|
|
5158
|
+
type: "native" | "credit_alphanum4" | "credit_alphanum12";
|
|
5159
|
+
code: string;
|
|
5160
|
+
issuer?: string;
|
|
5161
|
+
name?: string;
|
|
5162
|
+
trustlineEstablished: boolean;
|
|
5163
|
+
limit?: string;
|
|
5164
|
+
enabledInApp: boolean;
|
|
5165
|
+
sponsored?: boolean;
|
|
5166
|
+
}[];
|
|
5167
|
+
};
|
|
5168
|
+
};
|
|
5169
|
+
};
|
|
5170
|
+
};
|
|
5171
|
+
/** @description Validation error */
|
|
5172
|
+
400: {
|
|
5173
|
+
headers: {
|
|
5174
|
+
[name: string]: unknown;
|
|
5175
|
+
};
|
|
5176
|
+
content: {
|
|
5177
|
+
"application/json": {
|
|
5178
|
+
/** @constant */
|
|
5179
|
+
success: false;
|
|
5180
|
+
code: string;
|
|
5181
|
+
};
|
|
5182
|
+
};
|
|
5183
|
+
};
|
|
5184
|
+
/** @description Unauthorized */
|
|
5185
|
+
401: {
|
|
5186
|
+
headers: {
|
|
5187
|
+
[name: string]: unknown;
|
|
5188
|
+
};
|
|
5189
|
+
content: {
|
|
5190
|
+
"application/json": {
|
|
5191
|
+
/** @constant */
|
|
5192
|
+
success: false;
|
|
5193
|
+
code: string;
|
|
5194
|
+
};
|
|
5195
|
+
};
|
|
5196
|
+
};
|
|
5197
|
+
/** @description Not found */
|
|
5198
|
+
404: {
|
|
5199
|
+
headers: {
|
|
5200
|
+
[name: string]: unknown;
|
|
5201
|
+
};
|
|
5202
|
+
content: {
|
|
5203
|
+
"application/json": {
|
|
5204
|
+
/** @constant */
|
|
5205
|
+
success: false;
|
|
5206
|
+
code: string;
|
|
5207
|
+
};
|
|
5208
|
+
};
|
|
5209
|
+
};
|
|
5210
|
+
};
|
|
5211
|
+
};
|
|
5050
5212
|
getWalletByPublicKeyBalance: {
|
|
5051
5213
|
parameters: {
|
|
5052
5214
|
query: {
|
|
@@ -5897,4 +6059,4 @@ declare function listDistributionRules(api: PollarApiClient): Promise<Distributi
|
|
|
5897
6059
|
*/
|
|
5898
6060
|
declare function claimDistributionRule(api: PollarApiClient, body: DistributionClaimBody): Promise<DistributionClaimContent>;
|
|
5899
6061
|
|
|
5900
|
-
export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthOpenContext, type AuthState, type AuthUrlOpener, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, type EnabledAssetRecord, type EnabledAssetsState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type LogLevel, type NetworkState, OnStorageDegrade, POLLAR_CORE_VERSION, type PasskeyCeremony, type PasskeySigner, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLogger, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SessionsState, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletAssetsContent, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
|
|
6062
|
+
export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthOpenContext, type AuthState, type AuthUrlOpener, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, type EnabledAssetRecord, type EnabledAssetsState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type LogLevel, type NetworkState, OnStorageDegrade, POLLAR_CORE_VERSION, type PasskeyCeremony, type PasskeyMode, type PasskeySigner, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLogger, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SessionsState, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TrustlineOutcome, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletAssetsContent, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
|
package/dist/index.d.ts
CHANGED
|
@@ -344,12 +344,17 @@ interface PollarClientConfig {
|
|
|
344
344
|
* Runs the device WebAuthn ceremony for a server-issued challenge and returns
|
|
345
345
|
* the result to forward to the backend: a registration response for a new user
|
|
346
346
|
* (`create()`) or an authentication assertion for a returning one (`get()`).
|
|
347
|
-
*
|
|
348
|
-
* `create()`)
|
|
349
|
-
*
|
|
347
|
+
* `mode` tells the ceremony which to run: `'login'` runs `get()` only (returning
|
|
348
|
+
* user) and `'register'` runs `create()` only (new wallet) — the caller picks via
|
|
349
|
+
* the "Log in" / "Create wallet" buttons, so there's no ambiguous autodetect that
|
|
350
|
+
* could create a wallet when the user merely cancelled a login prompt. `response`
|
|
351
|
+
* is the browser's PublicKeyCredential serialized to JSON — forwarded verbatim to
|
|
352
|
+
* `/auth/passkey/{register,login}`.
|
|
350
353
|
*/
|
|
354
|
+
type PasskeyMode = 'login' | 'register';
|
|
351
355
|
type PasskeyCeremony = (ctx: {
|
|
352
356
|
challenge: string;
|
|
357
|
+
mode: PasskeyMode;
|
|
353
358
|
}) => Promise<{
|
|
354
359
|
kind: 'login';
|
|
355
360
|
response: unknown;
|
|
@@ -558,6 +563,22 @@ type SubmitOutcome = {
|
|
|
558
563
|
resultCode?: string;
|
|
559
564
|
buildData?: TxBuildContent;
|
|
560
565
|
};
|
|
566
|
+
/**
|
|
567
|
+
* Result of {@link PollarClient.setTrustline}. Like {@link SubmitOutcome} but the
|
|
568
|
+
* `hash` is optional: the sponsored, server-orchestrated path completes without
|
|
569
|
+
* surfacing a transaction hash to the client, whereas the self-paid path returns
|
|
570
|
+
* the underlying submit outcome (hash included).
|
|
571
|
+
*/
|
|
572
|
+
type TrustlineOutcome = {
|
|
573
|
+
status: 'success';
|
|
574
|
+
hash?: string;
|
|
575
|
+
} | {
|
|
576
|
+
status: 'pending';
|
|
577
|
+
hash?: string;
|
|
578
|
+
} | {
|
|
579
|
+
status: 'error';
|
|
580
|
+
details?: string;
|
|
581
|
+
};
|
|
561
582
|
declare const AUTH_ERROR_CODES: {
|
|
562
583
|
readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
|
|
563
584
|
readonly SESSION_EXPIRED: "SESSION_EXPIRED";
|
|
@@ -871,11 +892,19 @@ declare class PollarClient {
|
|
|
871
892
|
verifyEmailCode(code: string): void;
|
|
872
893
|
loginWallet(type: WalletId): void;
|
|
873
894
|
/**
|
|
874
|
-
* "Smart Wallet" login: runs the passkey (WebAuthn) ceremony
|
|
875
|
-
* user
|
|
876
|
-
* ceremony to be configured (e.g. via
|
|
895
|
+
* "Smart Wallet" login: runs the passkey (WebAuthn) `get()` ceremony for a
|
|
896
|
+
* returning user and signs them in. Use {@link createSmartWallet} for a new
|
|
897
|
+
* user. Requires the `passkey` ceremony to be configured (e.g. via
|
|
898
|
+
* `@pollar/react`).
|
|
877
899
|
*/
|
|
878
900
|
loginSmartWallet(): void;
|
|
901
|
+
/**
|
|
902
|
+
* "Smart Wallet" registration: runs the passkey (WebAuthn) `create()` ceremony
|
|
903
|
+
* for a new user and deploys a sponsored smart-account C-address. Use
|
|
904
|
+
* {@link loginSmartWallet} for a returning user. Requires the `passkey`
|
|
905
|
+
* ceremony to be configured (e.g. via `@pollar/react`).
|
|
906
|
+
*/
|
|
907
|
+
createSmartWallet(): void;
|
|
879
908
|
cancelLogin(): void;
|
|
880
909
|
/**
|
|
881
910
|
* Revoke the current session server-side, then clear local storage.
|
|
@@ -952,6 +981,27 @@ declare class PollarClient {
|
|
|
952
981
|
* session. Drives `enabledAssetsState`; mirrors {@link refreshBalance}.
|
|
953
982
|
*/
|
|
954
983
|
refreshAssets(): Promise<void>;
|
|
984
|
+
/**
|
|
985
|
+
* Establishes (omit `limit`) or removes (`limit: '0'`) a trustline for an asset.
|
|
986
|
+
*
|
|
987
|
+
* Routing mirrors how the platform pays for the reserve:
|
|
988
|
+
* - **Sponsored custodial** (`opts.sponsored` true, internal wallet) → the
|
|
989
|
+
* server orchestrates a sponsored `changeTrust`: the app's wallets cover the
|
|
990
|
+
* 0.5 XLM reserve and the fee, so the user pays nothing. Pass the asset's
|
|
991
|
+
* `sponsored` flag (from {@link refreshAssets}) straight through.
|
|
992
|
+
* - **Self-paid** (external/adapter wallet, sponsorship disabled, or a custom
|
|
993
|
+
* asset not configured in the app) → a plain `change_trust` transaction the
|
|
994
|
+
* user's own wallet signs and pays for, via {@link runTx}.
|
|
995
|
+
*
|
|
996
|
+
* Does not refresh on its own — callers should `refreshAssets()` afterwards.
|
|
997
|
+
*/
|
|
998
|
+
setTrustline(asset: {
|
|
999
|
+
code: string;
|
|
1000
|
+
issuer: string;
|
|
1001
|
+
}, opts?: {
|
|
1002
|
+
limit?: string;
|
|
1003
|
+
sponsored?: boolean;
|
|
1004
|
+
}): Promise<TrustlineOutcome>;
|
|
955
1005
|
/**
|
|
956
1006
|
* Builds an unsigned XDR. Drives `_setTransactionState` for modal-style UIs
|
|
957
1007
|
* AND returns a {@link BuildOutcome} so headless callers can `await` and
|
|
@@ -1957,6 +2007,26 @@ interface paths {
|
|
|
1957
2007
|
patch?: never;
|
|
1958
2008
|
trace?: never;
|
|
1959
2009
|
};
|
|
2010
|
+
"/wallet/assets/trustline": {
|
|
2011
|
+
parameters: {
|
|
2012
|
+
query?: never;
|
|
2013
|
+
header?: never;
|
|
2014
|
+
path?: never;
|
|
2015
|
+
cookie?: never;
|
|
2016
|
+
};
|
|
2017
|
+
get?: never;
|
|
2018
|
+
put?: never;
|
|
2019
|
+
/**
|
|
2020
|
+
* Enable or remove a trustline for an enabled asset
|
|
2021
|
+
* @description Establishes (no limit) or removes (limit '0') a trustline on the authenticated user's custodial wallet for an asset configured in the application, sponsored by the app. Returns the refreshed enabled-asset list. Only valid for the sponsored custodial path; custom assets, adapter-managed wallets, and apps with trustline sponsoring disabled must sign a change_trust transaction client-side instead.
|
|
2022
|
+
*/
|
|
2023
|
+
post: operations["postWalletAssetsTrustline"];
|
|
2024
|
+
delete?: never;
|
|
2025
|
+
options?: never;
|
|
2026
|
+
head?: never;
|
|
2027
|
+
patch?: never;
|
|
2028
|
+
trace?: never;
|
|
2029
|
+
};
|
|
1960
2030
|
"/wallet/{publicKey}/balance": {
|
|
1961
2031
|
parameters: {
|
|
1962
2032
|
query?: never;
|
|
@@ -3653,6 +3723,7 @@ interface operations {
|
|
|
3653
3723
|
logoUrl?: string;
|
|
3654
3724
|
emailEnabled?: boolean;
|
|
3655
3725
|
embeddedWallets?: boolean;
|
|
3726
|
+
smartWallet?: boolean;
|
|
3656
3727
|
providers?: {
|
|
3657
3728
|
google?: boolean;
|
|
3658
3729
|
discord?: boolean;
|
|
@@ -5014,6 +5085,8 @@ interface operations {
|
|
|
5014
5085
|
name?: string;
|
|
5015
5086
|
trustlineEstablished: boolean;
|
|
5016
5087
|
limit?: string;
|
|
5088
|
+
enabledInApp: boolean;
|
|
5089
|
+
sponsored?: boolean;
|
|
5017
5090
|
}[];
|
|
5018
5091
|
};
|
|
5019
5092
|
};
|
|
@@ -5047,6 +5120,95 @@ interface operations {
|
|
|
5047
5120
|
};
|
|
5048
5121
|
};
|
|
5049
5122
|
};
|
|
5123
|
+
postWalletAssetsTrustline: {
|
|
5124
|
+
parameters: {
|
|
5125
|
+
query?: never;
|
|
5126
|
+
header?: never;
|
|
5127
|
+
path?: never;
|
|
5128
|
+
cookie?: never;
|
|
5129
|
+
};
|
|
5130
|
+
requestBody: {
|
|
5131
|
+
content: {
|
|
5132
|
+
"application/json": {
|
|
5133
|
+
code: string;
|
|
5134
|
+
issuer: string;
|
|
5135
|
+
limit?: string;
|
|
5136
|
+
};
|
|
5137
|
+
};
|
|
5138
|
+
};
|
|
5139
|
+
responses: {
|
|
5140
|
+
/** @description Trustline updated; refreshed enabled assets */
|
|
5141
|
+
200: {
|
|
5142
|
+
headers: {
|
|
5143
|
+
[name: string]: unknown;
|
|
5144
|
+
};
|
|
5145
|
+
content: {
|
|
5146
|
+
"application/json": {
|
|
5147
|
+
/** @constant */
|
|
5148
|
+
code: "SDK_WALLET_TRUSTLINE";
|
|
5149
|
+
/** @constant */
|
|
5150
|
+
success: true;
|
|
5151
|
+
content: {
|
|
5152
|
+
publicKey: string;
|
|
5153
|
+
/** @enum {string} */
|
|
5154
|
+
network: "testnet" | "mainnet";
|
|
5155
|
+
exists: boolean;
|
|
5156
|
+
assets: {
|
|
5157
|
+
/** @enum {string} */
|
|
5158
|
+
type: "native" | "credit_alphanum4" | "credit_alphanum12";
|
|
5159
|
+
code: string;
|
|
5160
|
+
issuer?: string;
|
|
5161
|
+
name?: string;
|
|
5162
|
+
trustlineEstablished: boolean;
|
|
5163
|
+
limit?: string;
|
|
5164
|
+
enabledInApp: boolean;
|
|
5165
|
+
sponsored?: boolean;
|
|
5166
|
+
}[];
|
|
5167
|
+
};
|
|
5168
|
+
};
|
|
5169
|
+
};
|
|
5170
|
+
};
|
|
5171
|
+
/** @description Validation error */
|
|
5172
|
+
400: {
|
|
5173
|
+
headers: {
|
|
5174
|
+
[name: string]: unknown;
|
|
5175
|
+
};
|
|
5176
|
+
content: {
|
|
5177
|
+
"application/json": {
|
|
5178
|
+
/** @constant */
|
|
5179
|
+
success: false;
|
|
5180
|
+
code: string;
|
|
5181
|
+
};
|
|
5182
|
+
};
|
|
5183
|
+
};
|
|
5184
|
+
/** @description Unauthorized */
|
|
5185
|
+
401: {
|
|
5186
|
+
headers: {
|
|
5187
|
+
[name: string]: unknown;
|
|
5188
|
+
};
|
|
5189
|
+
content: {
|
|
5190
|
+
"application/json": {
|
|
5191
|
+
/** @constant */
|
|
5192
|
+
success: false;
|
|
5193
|
+
code: string;
|
|
5194
|
+
};
|
|
5195
|
+
};
|
|
5196
|
+
};
|
|
5197
|
+
/** @description Not found */
|
|
5198
|
+
404: {
|
|
5199
|
+
headers: {
|
|
5200
|
+
[name: string]: unknown;
|
|
5201
|
+
};
|
|
5202
|
+
content: {
|
|
5203
|
+
"application/json": {
|
|
5204
|
+
/** @constant */
|
|
5205
|
+
success: false;
|
|
5206
|
+
code: string;
|
|
5207
|
+
};
|
|
5208
|
+
};
|
|
5209
|
+
};
|
|
5210
|
+
};
|
|
5211
|
+
};
|
|
5050
5212
|
getWalletByPublicKeyBalance: {
|
|
5051
5213
|
parameters: {
|
|
5052
5214
|
query: {
|
|
@@ -5897,4 +6059,4 @@ declare function listDistributionRules(api: PollarApiClient): Promise<Distributi
|
|
|
5897
6059
|
*/
|
|
5898
6060
|
declare function claimDistributionRule(api: PollarApiClient, body: DistributionClaimBody): Promise<DistributionClaimContent>;
|
|
5899
6061
|
|
|
5900
|
-
export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthOpenContext, type AuthState, type AuthUrlOpener, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, type EnabledAssetRecord, type EnabledAssetsState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type LogLevel, type NetworkState, OnStorageDegrade, POLLAR_CORE_VERSION, type PasskeyCeremony, type PasskeySigner, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLogger, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SessionsState, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletAssetsContent, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
|
|
6062
|
+
export { AUTH_ERROR_CODES, type AdapterFn, AlbedoAdapter, type AuthErrorCode, type AuthOpenContext, type AuthState, type AuthUrlOpener, type BuildOutcome, type BuildProofArgs, type ConnectWalletResponse, type DistributionClaimBody, type DistributionClaimContent, type DistributionRule, type DistributionRulesState, type EnabledAssetRecord, type EnabledAssetsState, FreighterAdapter, type KeyManager, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type LocalStorageAdapterOptions, type LogLevel, type NetworkState, OnStorageDegrade, POLLAR_CORE_VERSION, type PasskeyCeremony, type PasskeyMode, type PasskeySigner, type PaymentInstructions, type PollarAdapter, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLogger, type PollarLoginOptions, type PollarPersistedSession, type PollarUserProfile, type PublicEcJwk, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type RulePeriod, type SessionInfo, type SessionsState, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignOutcome, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, Storage, type SubmitOutcome, type TransactionState, type TrustlineOutcome, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxBuildSignSubmitBody, type TxBuildSignSubmitContent, type TxBuildSignSubmitResponse, type TxErrorPhase, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignBody, type TxSignContent, type TxSignResponse, type TxSignSendResponse, type TxSubmitSignedBody, type WalletAdapter, type WalletAdapterResolver, type WalletAssetsContent, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, type WalletId, WalletType, WebCryptoKeyManager, buildProof, canonicalEcJwk, claimDistributionRule, computeJwkThumbprint, createLocalStorageAdapter, createLogger, createMemoryAdapter, createOffRamp, createOnRamp, defaultKeyManager, defaultStorage, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, listDistributionRules, normalizeHtu, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
|
package/dist/index.js
CHANGED
|
@@ -1173,7 +1173,7 @@ function defaultStorage(options = {}) {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
|
|
1175
1175
|
// src/version.ts
|
|
1176
|
-
var POLLAR_CORE_VERSION = "0.9.0-rc.
|
|
1176
|
+
var POLLAR_CORE_VERSION = "0.9.0-rc.3" ;
|
|
1177
1177
|
|
|
1178
1178
|
// src/visibility/noop.ts
|
|
1179
1179
|
function createNoopVisibilityProvider() {
|
|
@@ -1894,7 +1894,7 @@ async function loginOAuth(provider, deps) {
|
|
|
1894
1894
|
}
|
|
1895
1895
|
|
|
1896
1896
|
// src/client/auth/passkeyFlow.ts
|
|
1897
|
-
async function
|
|
1897
|
+
async function smartWalletFlow(deps, mode) {
|
|
1898
1898
|
const { api, signal, setAuthState, passkey } = deps;
|
|
1899
1899
|
if (!passkey) {
|
|
1900
1900
|
setAuthState({
|
|
@@ -1917,7 +1917,7 @@ async function loginSmartWallet(deps) {
|
|
|
1917
1917
|
return failPasskey(setAuthState, "Failed to start passkey");
|
|
1918
1918
|
}
|
|
1919
1919
|
setAuthState({ step: "creating_passkey" });
|
|
1920
|
-
const ceremony = await passkey({ challenge });
|
|
1920
|
+
const ceremony = await passkey({ challenge, mode });
|
|
1921
1921
|
const response = ceremony.response;
|
|
1922
1922
|
if (ceremony.kind === "register") {
|
|
1923
1923
|
setAuthState({ step: "deploying_smart_account" });
|
|
@@ -2510,9 +2510,10 @@ var PollarClient = class {
|
|
|
2510
2510
|
loginWallet(type, this._flowDeps(controller.signal)).catch((err) => this._handleFlowError(err));
|
|
2511
2511
|
}
|
|
2512
2512
|
/**
|
|
2513
|
-
* "Smart Wallet" login: runs the passkey (WebAuthn) ceremony
|
|
2514
|
-
* user
|
|
2515
|
-
* ceremony to be configured (e.g. via
|
|
2513
|
+
* "Smart Wallet" login: runs the passkey (WebAuthn) `get()` ceremony for a
|
|
2514
|
+
* returning user and signs them in. Use {@link createSmartWallet} for a new
|
|
2515
|
+
* user. Requires the `passkey` ceremony to be configured (e.g. via
|
|
2516
|
+
* `@pollar/react`).
|
|
2516
2517
|
*/
|
|
2517
2518
|
loginSmartWallet() {
|
|
2518
2519
|
if (!isClientRuntime) {
|
|
@@ -2520,7 +2521,21 @@ var PollarClient = class {
|
|
|
2520
2521
|
return;
|
|
2521
2522
|
}
|
|
2522
2523
|
const controller = this._newController();
|
|
2523
|
-
|
|
2524
|
+
smartWalletFlow(this._flowDeps(controller.signal), "login").catch((err) => this._handleFlowError(err));
|
|
2525
|
+
}
|
|
2526
|
+
/**
|
|
2527
|
+
* "Smart Wallet" registration: runs the passkey (WebAuthn) `create()` ceremony
|
|
2528
|
+
* for a new user and deploys a sponsored smart-account C-address. Use
|
|
2529
|
+
* {@link loginSmartWallet} for a returning user. Requires the `passkey`
|
|
2530
|
+
* ceremony to be configured (e.g. via `@pollar/react`).
|
|
2531
|
+
*/
|
|
2532
|
+
createSmartWallet() {
|
|
2533
|
+
if (!isClientRuntime) {
|
|
2534
|
+
warnServerSide("createSmartWallet");
|
|
2535
|
+
return;
|
|
2536
|
+
}
|
|
2537
|
+
const controller = this._newController();
|
|
2538
|
+
smartWalletFlow(this._flowDeps(controller.signal), "register").catch((err) => this._handleFlowError(err));
|
|
2524
2539
|
}
|
|
2525
2540
|
// ─── Cancel ───────────────────────────────────────────────────────────────
|
|
2526
2541
|
cancelLogin() {
|
|
@@ -2760,6 +2775,54 @@ var PollarClient = class {
|
|
|
2760
2775
|
this._setEnabledAssetsState({ step: "error", message: "Failed to load assets" });
|
|
2761
2776
|
}
|
|
2762
2777
|
}
|
|
2778
|
+
/**
|
|
2779
|
+
* Establishes (omit `limit`) or removes (`limit: '0'`) a trustline for an asset.
|
|
2780
|
+
*
|
|
2781
|
+
* Routing mirrors how the platform pays for the reserve:
|
|
2782
|
+
* - **Sponsored custodial** (`opts.sponsored` true, internal wallet) → the
|
|
2783
|
+
* server orchestrates a sponsored `changeTrust`: the app's wallets cover the
|
|
2784
|
+
* 0.5 XLM reserve and the fee, so the user pays nothing. Pass the asset's
|
|
2785
|
+
* `sponsored` flag (from {@link refreshAssets}) straight through.
|
|
2786
|
+
* - **Self-paid** (external/adapter wallet, sponsorship disabled, or a custom
|
|
2787
|
+
* asset not configured in the app) → a plain `change_trust` transaction the
|
|
2788
|
+
* user's own wallet signs and pays for, via {@link runTx}.
|
|
2789
|
+
*
|
|
2790
|
+
* Does not refresh on its own — callers should `refreshAssets()` afterwards.
|
|
2791
|
+
*/
|
|
2792
|
+
async setTrustline(asset, opts) {
|
|
2793
|
+
const limit = opts?.limit;
|
|
2794
|
+
const walletType = this._session?.wallet?.type;
|
|
2795
|
+
if (!this._session?.wallet?.address) {
|
|
2796
|
+
return { status: "error", details: "No wallet connected" };
|
|
2797
|
+
}
|
|
2798
|
+
if (walletType === "smart") {
|
|
2799
|
+
return { status: "error", details: "Trustlines do not apply to smart wallets" };
|
|
2800
|
+
}
|
|
2801
|
+
if (opts?.sponsored && !this._walletAdapter && walletType === "internal") {
|
|
2802
|
+
try {
|
|
2803
|
+
const { data, error } = await this._api.POST("/wallet/assets/trustline", {
|
|
2804
|
+
body: { code: asset.code, issuer: asset.issuer, ...limit !== void 0 && { limit } }
|
|
2805
|
+
});
|
|
2806
|
+
if (!error && data?.success) {
|
|
2807
|
+
if (data.content) this._setEnabledAssetsState({ step: "loaded", data: data.content });
|
|
2808
|
+
return { status: "success" };
|
|
2809
|
+
}
|
|
2810
|
+
const details = error?.details ?? error?.code;
|
|
2811
|
+
return { status: "error", ...details && { details } };
|
|
2812
|
+
} catch (err) {
|
|
2813
|
+
const details = err instanceof Error ? err.message : void 0;
|
|
2814
|
+
return { status: "error", ...details && { details } };
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
return this.runTx("change_trust", {
|
|
2818
|
+
asset: {
|
|
2819
|
+
type: asset.code.length <= 4 ? "credit_alphanum4" : "credit_alphanum12",
|
|
2820
|
+
code: asset.code,
|
|
2821
|
+
issuer: asset.issuer
|
|
2822
|
+
},
|
|
2823
|
+
...limit !== void 0 && { limit }
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2763
2826
|
// ─── Transactions ─────────────────────────────────────────────────────────
|
|
2764
2827
|
/**
|
|
2765
2828
|
* Builds an unsigned XDR. Drives `_setTransactionState` for modal-style UIs
|