@pollar/core 0.4.4 → 0.4.5
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 +80 -89
- package/dist/index.d.ts +80 -89
- package/dist/index.js +566 -495
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +566 -496
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1325,48 +1325,10 @@ declare const StateStatus: {
|
|
|
1325
1325
|
type StateStatus = (typeof StateStatus)[keyof typeof StateStatus];
|
|
1326
1326
|
declare const PollarStateVar: {
|
|
1327
1327
|
readonly NETWORK: "network";
|
|
1328
|
-
readonly AUTHENTICATION: "authentication";
|
|
1329
1328
|
readonly TRANSACTION: "transaction";
|
|
1330
1329
|
};
|
|
1331
1330
|
type PollarStateVar = (typeof PollarStateVar)[keyof typeof PollarStateVar];
|
|
1332
1331
|
declare const STATE_VAR_CODES: {
|
|
1333
|
-
readonly authentication: {
|
|
1334
|
-
readonly NONE: "NONE";
|
|
1335
|
-
readonly LOGOUT: "LOGOUT";
|
|
1336
|
-
readonly CREATE_SESSION_START: "CREATE_SESSION_START";
|
|
1337
|
-
readonly CREATE_SESSION_ERROR: "CREATE_SESSION_ERROR";
|
|
1338
|
-
readonly CREATE_SESSION_SUCCESS: "CREATE_SESSION_SUCCESS";
|
|
1339
|
-
readonly EMAIL_AUTH_START: "EMAIL_AUTH_START";
|
|
1340
|
-
readonly EMAIL_AUTH_START_ERROR: "EMAIL_AUTH_START_ERROR";
|
|
1341
|
-
readonly EMAIL_AUTH_START_SUCCESS: "EMAIL_AUTH_START_SUCCESS";
|
|
1342
|
-
readonly EMAIL_AUTH_CODE_ERROR: "EMAIL_AUTH_CODE_ERROR";
|
|
1343
|
-
readonly EMAIL_AUTH_CODE_SUCCESS: "EMAIL_AUTH_CODE_SUCCESS";
|
|
1344
|
-
readonly WALLET_AUTH_START: "WALLET_AUTH_START";
|
|
1345
|
-
readonly WALLET_AUTH_FREIGHTER_NOT_INSTALLED: "WALLET_AUTH_FREIGHTER_NOT_INSTALLED";
|
|
1346
|
-
readonly WALLET_AUTH_ALBEDO_NOT_INSTALLED: "WALLET_AUTH_ALBEDO_NOT_INSTALLED";
|
|
1347
|
-
readonly WALLET_AUTH_CONNECTED: "WALLET_AUTH_CONNECTED";
|
|
1348
|
-
readonly WALLET_AUTH_LOGIN_START: "WALLET_AUTH_LOGIN_START";
|
|
1349
|
-
readonly WALLET_AUTH_LOGIN_START_SUCCESS: "WALLET_AUTH_LOGIN_START_SUCCESS";
|
|
1350
|
-
readonly WALLET_AUTH_LOGIN_START_ERROR: "WALLET_AUTH_LOGIN_START_ERROR";
|
|
1351
|
-
readonly WALLET_AUTH_ERROR: "WALLET_AUTH_ERROR";
|
|
1352
|
-
readonly STREAM_POLL_START: "STREAM_POLL_START";
|
|
1353
|
-
readonly STREAM_POLL_EVENT: "STREAM_POLL_EVENT";
|
|
1354
|
-
readonly STREAM_POLL_READY: "STREAM_POLL_READY";
|
|
1355
|
-
readonly FETCH_SESSION_START: "FETCH_SESSION_START";
|
|
1356
|
-
readonly FETCH_SESSION_SUCCESS: "FETCH_SESSION_SUCCESS";
|
|
1357
|
-
readonly FETCH_SESSION_ERROR: "FETCH_SESSION_ERROR";
|
|
1358
|
-
readonly NO_RESTORED_SESSION: "NO_RESTORED_SESSION";
|
|
1359
|
-
readonly RESTORED_SESSION_SUCCESS: "RESTORED_SESSION_SUCCESS";
|
|
1360
|
-
readonly RESTORED_SESSION_ERROR: "RESTORED_SESSION_ERROR";
|
|
1361
|
-
readonly SESSION_STORED: "SESSION_STORED";
|
|
1362
|
-
readonly ERROR_ABORTED: "ABORTED";
|
|
1363
|
-
readonly ERROR_UNKNOWN: "ERROR_UNKNOWN";
|
|
1364
|
-
};
|
|
1365
|
-
readonly walletAddress: {
|
|
1366
|
-
readonly NONE: "NONE";
|
|
1367
|
-
readonly REMOVED_ADDRESS: "REMOVED_ADDRESS";
|
|
1368
|
-
readonly UPDATED_ADDRESS: "UPDATED_ADDRESS";
|
|
1369
|
-
};
|
|
1370
1332
|
readonly transaction: {
|
|
1371
1333
|
readonly NONE: "NONE";
|
|
1372
1334
|
readonly BUILD_TRANSACTION_ERROR_NO_WALLET: "BUILD_TRANSACTION_ERROR_NO_WALLET";
|
|
@@ -1461,11 +1423,9 @@ type PollarLoginOptions = {
|
|
|
1461
1423
|
};
|
|
1462
1424
|
type NetworkCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK];
|
|
1463
1425
|
type StateNetworkCodes = NetworkCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK]];
|
|
1464
|
-
type AuthenticationCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION];
|
|
1465
|
-
type StateAuthenticationCodes = AuthenticationCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION]];
|
|
1466
1426
|
type TransactionCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION];
|
|
1467
1427
|
type StateTransactionCodes = TransactionCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION]];
|
|
1468
|
-
type StateVarCodes = StateNetworkCodes |
|
|
1428
|
+
type StateVarCodes = StateNetworkCodes | StateTransactionCodes;
|
|
1469
1429
|
interface PollarStateEntry {
|
|
1470
1430
|
var: PollarStateVar;
|
|
1471
1431
|
code: StateVarCodes;
|
|
@@ -1477,6 +1437,64 @@ interface PollarStateEntry {
|
|
|
1477
1437
|
type PollarState = {
|
|
1478
1438
|
[key in PollarStateVar]: PollarStateEntry[];
|
|
1479
1439
|
};
|
|
1440
|
+
declare const AUTH_ERROR_CODES: {
|
|
1441
|
+
readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
|
|
1442
|
+
readonly EMAIL_SEND_FAILED: "EMAIL_SEND_FAILED";
|
|
1443
|
+
readonly EMAIL_VERIFY_FAILED: "EMAIL_VERIFY_FAILED";
|
|
1444
|
+
readonly EMAIL_CODE_EXPIRED: "EMAIL_CODE_EXPIRED";
|
|
1445
|
+
readonly EMAIL_CODE_INVALID: "EMAIL_CODE_INVALID";
|
|
1446
|
+
readonly AUTH_FAILED: "AUTH_FAILED";
|
|
1447
|
+
readonly WALLET_CONNECT_FAILED: "WALLET_CONNECT_FAILED";
|
|
1448
|
+
readonly WALLET_AUTH_FAILED: "WALLET_AUTH_FAILED";
|
|
1449
|
+
readonly UNEXPECTED_ERROR: "UNEXPECTED_ERROR";
|
|
1450
|
+
};
|
|
1451
|
+
type AuthErrorCode = (typeof AUTH_ERROR_CODES)[keyof typeof AUTH_ERROR_CODES];
|
|
1452
|
+
type AuthState = {
|
|
1453
|
+
step: 'idle';
|
|
1454
|
+
} | {
|
|
1455
|
+
step: 'creating_session';
|
|
1456
|
+
} | {
|
|
1457
|
+
step: 'entering_email';
|
|
1458
|
+
clientSessionId: string;
|
|
1459
|
+
} | {
|
|
1460
|
+
step: 'sending_email';
|
|
1461
|
+
email: string;
|
|
1462
|
+
} | {
|
|
1463
|
+
step: 'entering_code';
|
|
1464
|
+
clientSessionId: string;
|
|
1465
|
+
email: string;
|
|
1466
|
+
} | {
|
|
1467
|
+
step: 'verifying_email_code';
|
|
1468
|
+
clientSessionId: string;
|
|
1469
|
+
email: string;
|
|
1470
|
+
} | {
|
|
1471
|
+
step: 'opening_oauth';
|
|
1472
|
+
provider: 'google' | 'github';
|
|
1473
|
+
} | {
|
|
1474
|
+
step: 'connecting_wallet';
|
|
1475
|
+
walletType: WalletType;
|
|
1476
|
+
} | {
|
|
1477
|
+
step: 'wallet_not_installed';
|
|
1478
|
+
walletType: WalletType;
|
|
1479
|
+
} | {
|
|
1480
|
+
step: 'authenticating_wallet';
|
|
1481
|
+
} | {
|
|
1482
|
+
step: 'authenticating';
|
|
1483
|
+
} | {
|
|
1484
|
+
step: 'authenticated';
|
|
1485
|
+
session: PollarApplicationConfigContent;
|
|
1486
|
+
} | {
|
|
1487
|
+
step: 'error';
|
|
1488
|
+
previousStep: string;
|
|
1489
|
+
message: string;
|
|
1490
|
+
errorCode: AuthErrorCode;
|
|
1491
|
+
clientSessionId?: string;
|
|
1492
|
+
email?: string;
|
|
1493
|
+
};
|
|
1494
|
+
declare class PollarFlowError extends Error {
|
|
1495
|
+
readonly code: "INVALID_FLOW";
|
|
1496
|
+
constructor(message: string);
|
|
1497
|
+
}
|
|
1480
1498
|
|
|
1481
1499
|
declare class PollarClient {
|
|
1482
1500
|
readonly apiKey: string;
|
|
@@ -1486,62 +1504,35 @@ declare class PollarClient {
|
|
|
1486
1504
|
private _session;
|
|
1487
1505
|
private _stateListeners;
|
|
1488
1506
|
private _state;
|
|
1507
|
+
private _authState;
|
|
1508
|
+
private _authStateListeners;
|
|
1509
|
+
private _loginController;
|
|
1489
1510
|
constructor(config: PollarClientConfig);
|
|
1490
1511
|
isAuthenticated(): boolean;
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
user: {
|
|
1502
|
-
id?: string;
|
|
1503
|
-
ready: boolean;
|
|
1504
|
-
};
|
|
1505
|
-
wallet: {
|
|
1506
|
-
publicKey: string | null;
|
|
1507
|
-
existsOnStellar?: boolean;
|
|
1508
|
-
createdAt?: number;
|
|
1509
|
-
};
|
|
1510
|
-
data: {
|
|
1511
|
-
mail: string;
|
|
1512
|
-
first_name: string;
|
|
1513
|
-
last_name: string;
|
|
1514
|
-
avatar: string;
|
|
1515
|
-
providers: {
|
|
1516
|
-
email: {
|
|
1517
|
-
address: string;
|
|
1518
|
-
} | null;
|
|
1519
|
-
google: {
|
|
1520
|
-
id: string;
|
|
1521
|
-
} | null;
|
|
1522
|
-
github: {
|
|
1523
|
-
id: string;
|
|
1524
|
-
} | null;
|
|
1525
|
-
wallet: {
|
|
1526
|
-
address: string;
|
|
1527
|
-
} | null;
|
|
1528
|
-
};
|
|
1529
|
-
};
|
|
1530
|
-
} | null;
|
|
1531
|
-
};
|
|
1512
|
+
getAuthState(): AuthState;
|
|
1513
|
+
onAuthStateChange(cb: (state: AuthState) => void): () => void;
|
|
1514
|
+
login(options: PollarLoginOptions): void;
|
|
1515
|
+
beginEmailLogin(): void;
|
|
1516
|
+
sendEmailCode(email: string): void;
|
|
1517
|
+
verifyEmailCode(code: string): void;
|
|
1518
|
+
loginOAuth(provider: 'google' | 'github'): void;
|
|
1519
|
+
loginWallet(type: WalletType): void;
|
|
1520
|
+
cancelLogin(): void;
|
|
1521
|
+
logout(): void;
|
|
1532
1522
|
getApi(): PollarApiClient;
|
|
1533
|
-
login(options: PollarLoginOptions): {
|
|
1534
|
-
cancelLogin: () => void;
|
|
1535
|
-
};
|
|
1536
|
-
onStateChange(cb: (state: PollarStateEntry) => void): () => void;
|
|
1537
|
-
verifyEmailCode(clientSessionId: string, code: string): Promise<void>;
|
|
1538
1523
|
getNetwork(): "testnet" | "public";
|
|
1524
|
+
onStateChange(cb: (state: PollarStateEntry) => void): () => void;
|
|
1539
1525
|
buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<void>;
|
|
1540
1526
|
submitTx(signedXdr: string): Promise<void>;
|
|
1541
|
-
|
|
1527
|
+
/** Creates a new AbortController, cancelling any existing flow first. */
|
|
1528
|
+
private _newController;
|
|
1529
|
+
/** Builds the deps object passed to flow functions via bind pattern. */
|
|
1530
|
+
private _flowDeps;
|
|
1531
|
+
private _handleFlowError;
|
|
1542
1532
|
private _readStore;
|
|
1543
1533
|
private _storeSession;
|
|
1544
1534
|
private _clearSession;
|
|
1535
|
+
private _setAuthState;
|
|
1545
1536
|
private _emitState;
|
|
1546
1537
|
}
|
|
1547
1538
|
|
|
@@ -1570,4 +1561,4 @@ declare class StellarClient {
|
|
|
1570
1561
|
getBalances(publicKey: string): Promise<GetBalancesResult>;
|
|
1571
1562
|
}
|
|
1572
1563
|
|
|
1573
|
-
export { AlbedoAdapter, type ConnectWalletResponse, FreighterAdapter, type GetBalancesResult, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, type PollarLoginOptions, type PollarState, type PollarStateEntry, PollarStateVar, STATE_VAR_CODES, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type
|
|
1564
|
+
export { AUTH_ERROR_CODES, AlbedoAdapter, type AuthErrorCode, type AuthState, type ConnectWalletResponse, FreighterAdapter, type GetBalancesResult, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type PollarState, type PollarStateEntry, PollarStateVar, STATE_VAR_CODES, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StateNetworkCodes, StateStatus, type StateTransactionCodes, type StateVarCodes, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TxBuildBody, type TxBuildResponse, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, WalletType, isValidSession, type paths as pollarPaths };
|
package/dist/index.d.ts
CHANGED
|
@@ -1325,48 +1325,10 @@ declare const StateStatus: {
|
|
|
1325
1325
|
type StateStatus = (typeof StateStatus)[keyof typeof StateStatus];
|
|
1326
1326
|
declare const PollarStateVar: {
|
|
1327
1327
|
readonly NETWORK: "network";
|
|
1328
|
-
readonly AUTHENTICATION: "authentication";
|
|
1329
1328
|
readonly TRANSACTION: "transaction";
|
|
1330
1329
|
};
|
|
1331
1330
|
type PollarStateVar = (typeof PollarStateVar)[keyof typeof PollarStateVar];
|
|
1332
1331
|
declare const STATE_VAR_CODES: {
|
|
1333
|
-
readonly authentication: {
|
|
1334
|
-
readonly NONE: "NONE";
|
|
1335
|
-
readonly LOGOUT: "LOGOUT";
|
|
1336
|
-
readonly CREATE_SESSION_START: "CREATE_SESSION_START";
|
|
1337
|
-
readonly CREATE_SESSION_ERROR: "CREATE_SESSION_ERROR";
|
|
1338
|
-
readonly CREATE_SESSION_SUCCESS: "CREATE_SESSION_SUCCESS";
|
|
1339
|
-
readonly EMAIL_AUTH_START: "EMAIL_AUTH_START";
|
|
1340
|
-
readonly EMAIL_AUTH_START_ERROR: "EMAIL_AUTH_START_ERROR";
|
|
1341
|
-
readonly EMAIL_AUTH_START_SUCCESS: "EMAIL_AUTH_START_SUCCESS";
|
|
1342
|
-
readonly EMAIL_AUTH_CODE_ERROR: "EMAIL_AUTH_CODE_ERROR";
|
|
1343
|
-
readonly EMAIL_AUTH_CODE_SUCCESS: "EMAIL_AUTH_CODE_SUCCESS";
|
|
1344
|
-
readonly WALLET_AUTH_START: "WALLET_AUTH_START";
|
|
1345
|
-
readonly WALLET_AUTH_FREIGHTER_NOT_INSTALLED: "WALLET_AUTH_FREIGHTER_NOT_INSTALLED";
|
|
1346
|
-
readonly WALLET_AUTH_ALBEDO_NOT_INSTALLED: "WALLET_AUTH_ALBEDO_NOT_INSTALLED";
|
|
1347
|
-
readonly WALLET_AUTH_CONNECTED: "WALLET_AUTH_CONNECTED";
|
|
1348
|
-
readonly WALLET_AUTH_LOGIN_START: "WALLET_AUTH_LOGIN_START";
|
|
1349
|
-
readonly WALLET_AUTH_LOGIN_START_SUCCESS: "WALLET_AUTH_LOGIN_START_SUCCESS";
|
|
1350
|
-
readonly WALLET_AUTH_LOGIN_START_ERROR: "WALLET_AUTH_LOGIN_START_ERROR";
|
|
1351
|
-
readonly WALLET_AUTH_ERROR: "WALLET_AUTH_ERROR";
|
|
1352
|
-
readonly STREAM_POLL_START: "STREAM_POLL_START";
|
|
1353
|
-
readonly STREAM_POLL_EVENT: "STREAM_POLL_EVENT";
|
|
1354
|
-
readonly STREAM_POLL_READY: "STREAM_POLL_READY";
|
|
1355
|
-
readonly FETCH_SESSION_START: "FETCH_SESSION_START";
|
|
1356
|
-
readonly FETCH_SESSION_SUCCESS: "FETCH_SESSION_SUCCESS";
|
|
1357
|
-
readonly FETCH_SESSION_ERROR: "FETCH_SESSION_ERROR";
|
|
1358
|
-
readonly NO_RESTORED_SESSION: "NO_RESTORED_SESSION";
|
|
1359
|
-
readonly RESTORED_SESSION_SUCCESS: "RESTORED_SESSION_SUCCESS";
|
|
1360
|
-
readonly RESTORED_SESSION_ERROR: "RESTORED_SESSION_ERROR";
|
|
1361
|
-
readonly SESSION_STORED: "SESSION_STORED";
|
|
1362
|
-
readonly ERROR_ABORTED: "ABORTED";
|
|
1363
|
-
readonly ERROR_UNKNOWN: "ERROR_UNKNOWN";
|
|
1364
|
-
};
|
|
1365
|
-
readonly walletAddress: {
|
|
1366
|
-
readonly NONE: "NONE";
|
|
1367
|
-
readonly REMOVED_ADDRESS: "REMOVED_ADDRESS";
|
|
1368
|
-
readonly UPDATED_ADDRESS: "UPDATED_ADDRESS";
|
|
1369
|
-
};
|
|
1370
1332
|
readonly transaction: {
|
|
1371
1333
|
readonly NONE: "NONE";
|
|
1372
1334
|
readonly BUILD_TRANSACTION_ERROR_NO_WALLET: "BUILD_TRANSACTION_ERROR_NO_WALLET";
|
|
@@ -1461,11 +1423,9 @@ type PollarLoginOptions = {
|
|
|
1461
1423
|
};
|
|
1462
1424
|
type NetworkCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK];
|
|
1463
1425
|
type StateNetworkCodes = NetworkCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK]];
|
|
1464
|
-
type AuthenticationCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION];
|
|
1465
|
-
type StateAuthenticationCodes = AuthenticationCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION]];
|
|
1466
1426
|
type TransactionCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION];
|
|
1467
1427
|
type StateTransactionCodes = TransactionCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION]];
|
|
1468
|
-
type StateVarCodes = StateNetworkCodes |
|
|
1428
|
+
type StateVarCodes = StateNetworkCodes | StateTransactionCodes;
|
|
1469
1429
|
interface PollarStateEntry {
|
|
1470
1430
|
var: PollarStateVar;
|
|
1471
1431
|
code: StateVarCodes;
|
|
@@ -1477,6 +1437,64 @@ interface PollarStateEntry {
|
|
|
1477
1437
|
type PollarState = {
|
|
1478
1438
|
[key in PollarStateVar]: PollarStateEntry[];
|
|
1479
1439
|
};
|
|
1440
|
+
declare const AUTH_ERROR_CODES: {
|
|
1441
|
+
readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
|
|
1442
|
+
readonly EMAIL_SEND_FAILED: "EMAIL_SEND_FAILED";
|
|
1443
|
+
readonly EMAIL_VERIFY_FAILED: "EMAIL_VERIFY_FAILED";
|
|
1444
|
+
readonly EMAIL_CODE_EXPIRED: "EMAIL_CODE_EXPIRED";
|
|
1445
|
+
readonly EMAIL_CODE_INVALID: "EMAIL_CODE_INVALID";
|
|
1446
|
+
readonly AUTH_FAILED: "AUTH_FAILED";
|
|
1447
|
+
readonly WALLET_CONNECT_FAILED: "WALLET_CONNECT_FAILED";
|
|
1448
|
+
readonly WALLET_AUTH_FAILED: "WALLET_AUTH_FAILED";
|
|
1449
|
+
readonly UNEXPECTED_ERROR: "UNEXPECTED_ERROR";
|
|
1450
|
+
};
|
|
1451
|
+
type AuthErrorCode = (typeof AUTH_ERROR_CODES)[keyof typeof AUTH_ERROR_CODES];
|
|
1452
|
+
type AuthState = {
|
|
1453
|
+
step: 'idle';
|
|
1454
|
+
} | {
|
|
1455
|
+
step: 'creating_session';
|
|
1456
|
+
} | {
|
|
1457
|
+
step: 'entering_email';
|
|
1458
|
+
clientSessionId: string;
|
|
1459
|
+
} | {
|
|
1460
|
+
step: 'sending_email';
|
|
1461
|
+
email: string;
|
|
1462
|
+
} | {
|
|
1463
|
+
step: 'entering_code';
|
|
1464
|
+
clientSessionId: string;
|
|
1465
|
+
email: string;
|
|
1466
|
+
} | {
|
|
1467
|
+
step: 'verifying_email_code';
|
|
1468
|
+
clientSessionId: string;
|
|
1469
|
+
email: string;
|
|
1470
|
+
} | {
|
|
1471
|
+
step: 'opening_oauth';
|
|
1472
|
+
provider: 'google' | 'github';
|
|
1473
|
+
} | {
|
|
1474
|
+
step: 'connecting_wallet';
|
|
1475
|
+
walletType: WalletType;
|
|
1476
|
+
} | {
|
|
1477
|
+
step: 'wallet_not_installed';
|
|
1478
|
+
walletType: WalletType;
|
|
1479
|
+
} | {
|
|
1480
|
+
step: 'authenticating_wallet';
|
|
1481
|
+
} | {
|
|
1482
|
+
step: 'authenticating';
|
|
1483
|
+
} | {
|
|
1484
|
+
step: 'authenticated';
|
|
1485
|
+
session: PollarApplicationConfigContent;
|
|
1486
|
+
} | {
|
|
1487
|
+
step: 'error';
|
|
1488
|
+
previousStep: string;
|
|
1489
|
+
message: string;
|
|
1490
|
+
errorCode: AuthErrorCode;
|
|
1491
|
+
clientSessionId?: string;
|
|
1492
|
+
email?: string;
|
|
1493
|
+
};
|
|
1494
|
+
declare class PollarFlowError extends Error {
|
|
1495
|
+
readonly code: "INVALID_FLOW";
|
|
1496
|
+
constructor(message: string);
|
|
1497
|
+
}
|
|
1480
1498
|
|
|
1481
1499
|
declare class PollarClient {
|
|
1482
1500
|
readonly apiKey: string;
|
|
@@ -1486,62 +1504,35 @@ declare class PollarClient {
|
|
|
1486
1504
|
private _session;
|
|
1487
1505
|
private _stateListeners;
|
|
1488
1506
|
private _state;
|
|
1507
|
+
private _authState;
|
|
1508
|
+
private _authStateListeners;
|
|
1509
|
+
private _loginController;
|
|
1489
1510
|
constructor(config: PollarClientConfig);
|
|
1490
1511
|
isAuthenticated(): boolean;
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
user: {
|
|
1502
|
-
id?: string;
|
|
1503
|
-
ready: boolean;
|
|
1504
|
-
};
|
|
1505
|
-
wallet: {
|
|
1506
|
-
publicKey: string | null;
|
|
1507
|
-
existsOnStellar?: boolean;
|
|
1508
|
-
createdAt?: number;
|
|
1509
|
-
};
|
|
1510
|
-
data: {
|
|
1511
|
-
mail: string;
|
|
1512
|
-
first_name: string;
|
|
1513
|
-
last_name: string;
|
|
1514
|
-
avatar: string;
|
|
1515
|
-
providers: {
|
|
1516
|
-
email: {
|
|
1517
|
-
address: string;
|
|
1518
|
-
} | null;
|
|
1519
|
-
google: {
|
|
1520
|
-
id: string;
|
|
1521
|
-
} | null;
|
|
1522
|
-
github: {
|
|
1523
|
-
id: string;
|
|
1524
|
-
} | null;
|
|
1525
|
-
wallet: {
|
|
1526
|
-
address: string;
|
|
1527
|
-
} | null;
|
|
1528
|
-
};
|
|
1529
|
-
};
|
|
1530
|
-
} | null;
|
|
1531
|
-
};
|
|
1512
|
+
getAuthState(): AuthState;
|
|
1513
|
+
onAuthStateChange(cb: (state: AuthState) => void): () => void;
|
|
1514
|
+
login(options: PollarLoginOptions): void;
|
|
1515
|
+
beginEmailLogin(): void;
|
|
1516
|
+
sendEmailCode(email: string): void;
|
|
1517
|
+
verifyEmailCode(code: string): void;
|
|
1518
|
+
loginOAuth(provider: 'google' | 'github'): void;
|
|
1519
|
+
loginWallet(type: WalletType): void;
|
|
1520
|
+
cancelLogin(): void;
|
|
1521
|
+
logout(): void;
|
|
1532
1522
|
getApi(): PollarApiClient;
|
|
1533
|
-
login(options: PollarLoginOptions): {
|
|
1534
|
-
cancelLogin: () => void;
|
|
1535
|
-
};
|
|
1536
|
-
onStateChange(cb: (state: PollarStateEntry) => void): () => void;
|
|
1537
|
-
verifyEmailCode(clientSessionId: string, code: string): Promise<void>;
|
|
1538
1523
|
getNetwork(): "testnet" | "public";
|
|
1524
|
+
onStateChange(cb: (state: PollarStateEntry) => void): () => void;
|
|
1539
1525
|
buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<void>;
|
|
1540
1526
|
submitTx(signedXdr: string): Promise<void>;
|
|
1541
|
-
|
|
1527
|
+
/** Creates a new AbortController, cancelling any existing flow first. */
|
|
1528
|
+
private _newController;
|
|
1529
|
+
/** Builds the deps object passed to flow functions via bind pattern. */
|
|
1530
|
+
private _flowDeps;
|
|
1531
|
+
private _handleFlowError;
|
|
1542
1532
|
private _readStore;
|
|
1543
1533
|
private _storeSession;
|
|
1544
1534
|
private _clearSession;
|
|
1535
|
+
private _setAuthState;
|
|
1545
1536
|
private _emitState;
|
|
1546
1537
|
}
|
|
1547
1538
|
|
|
@@ -1570,4 +1561,4 @@ declare class StellarClient {
|
|
|
1570
1561
|
getBalances(publicKey: string): Promise<GetBalancesResult>;
|
|
1571
1562
|
}
|
|
1572
1563
|
|
|
1573
|
-
export { AlbedoAdapter, type ConnectWalletResponse, FreighterAdapter, type GetBalancesResult, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, type PollarLoginOptions, type PollarState, type PollarStateEntry, PollarStateVar, STATE_VAR_CODES, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type
|
|
1564
|
+
export { AUTH_ERROR_CODES, AlbedoAdapter, type AuthErrorCode, type AuthState, type ConnectWalletResponse, FreighterAdapter, type GetBalancesResult, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type PollarState, type PollarStateEntry, PollarStateVar, STATE_VAR_CODES, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StateNetworkCodes, StateStatus, type StateTransactionCodes, type StateVarCodes, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TxBuildBody, type TxBuildResponse, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, WalletType, isValidSession, type paths as pollarPaths };
|