@pollar/core 0.3.9 → 0.4.1
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 +201 -114
- package/dist/index.d.ts +201 -114
- package/dist/index.js +157 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +158 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -650,20 +650,20 @@ function createApiClient(baseUrl) {
|
|
|
650
650
|
return createClient({ baseUrl });
|
|
651
651
|
}
|
|
652
652
|
|
|
653
|
-
// src/
|
|
654
|
-
var
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
653
|
+
// src/constants.ts
|
|
654
|
+
var StateStatus = {
|
|
655
|
+
NONE: "NONE",
|
|
656
|
+
LOADING: "LOADING",
|
|
657
|
+
SUCCESS: "SUCCESS",
|
|
658
|
+
ERROR: "ERROR"
|
|
660
659
|
};
|
|
661
660
|
var PollarStateVar = {
|
|
662
|
-
|
|
663
|
-
|
|
661
|
+
NETWORK: "network",
|
|
662
|
+
AUTHENTICATION: "authentication",
|
|
663
|
+
TRANSACTION: "transaction"
|
|
664
664
|
};
|
|
665
665
|
var STATE_VAR_CODES = {
|
|
666
|
-
|
|
666
|
+
authentication: {
|
|
667
667
|
NONE: "NONE",
|
|
668
668
|
LOGOUT: "LOGOUT",
|
|
669
669
|
CREATE_SESSION_START: "CREATE_SESSION_START",
|
|
@@ -688,20 +688,44 @@ var STATE_VAR_CODES = {
|
|
|
688
688
|
FETCH_SESSION_START: "FETCH_SESSION_START",
|
|
689
689
|
FETCH_SESSION_SUCCESS: "FETCH_SESSION_SUCCESS",
|
|
690
690
|
FETCH_SESSION_ERROR: "FETCH_SESSION_ERROR",
|
|
691
|
+
RESTORED_SESSION_SUCCESS: "RESTORED_SESSION_SUCCESS",
|
|
692
|
+
RESTORED_SESSION_ERROR: "RESTORED_SESSION_ERROR",
|
|
693
|
+
SESSION_STORED: "SESSION_STORED",
|
|
691
694
|
ERROR_ABORTED: "ABORTED",
|
|
692
695
|
ERROR_UNKNOWN: "ERROR_UNKNOWN"
|
|
693
696
|
},
|
|
694
|
-
|
|
697
|
+
walletAddress: {
|
|
695
698
|
NONE: "NONE",
|
|
696
699
|
REMOVED_ADDRESS: "REMOVED_ADDRESS",
|
|
697
700
|
UPDATED_ADDRESS: "UPDATED_ADDRESS"
|
|
701
|
+
},
|
|
702
|
+
transaction: {
|
|
703
|
+
NONE: "NONE",
|
|
704
|
+
BUILD_TRANSACTION_ERROR_NO_WALLET: "BUILD_TRANSACTION_ERROR_NO_WALLET",
|
|
705
|
+
BUILD_TRANSACTION_START: "BUILD_TRANSACTION_START",
|
|
706
|
+
BUILD_TRANSACTION_SUCCESS: "BUILD_TRANSACTION_SUCCESS",
|
|
707
|
+
BUILD_TRANSACTION_ERROR: "BUILD_TRANSACTION_ERROR",
|
|
708
|
+
SIGN_SEND_TRANSACTION_START: "SIGN_SEND_TRANSACTION_START",
|
|
709
|
+
SIGN_SEND_TRANSACTION_SUCCESS: "SIGN_SEND_TRANSACTION_SUCCESS",
|
|
710
|
+
SIGN_SEND_TRANSACTION_ERROR: "SIGN_SEND_TRANSACTION_ERROR"
|
|
711
|
+
},
|
|
712
|
+
network: {
|
|
713
|
+
NONE: "NONE",
|
|
714
|
+
NETWORK_UPDATED: "NETWORK_UPDATED"
|
|
698
715
|
}
|
|
699
716
|
};
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
717
|
+
|
|
718
|
+
// src/client/helpers.ts
|
|
719
|
+
var emitResponse = (state, response, success, errorCode, emitLog) => {
|
|
720
|
+
const isSuccess = !response.error && !!response.data && !!response.data?.success;
|
|
721
|
+
emitLog(
|
|
722
|
+
state,
|
|
723
|
+
isSuccess ? success.code : errorCode,
|
|
724
|
+
isSuccess ? "info" : "error",
|
|
725
|
+
isSuccess ? success.status || StateStatus.LOADING : StateStatus.ERROR,
|
|
726
|
+
isSuccess ? response.data : response.error
|
|
727
|
+
);
|
|
728
|
+
return isSuccess;
|
|
705
729
|
};
|
|
706
730
|
|
|
707
731
|
// src/wallets/FreighterAdapter.ts
|
|
@@ -1095,25 +1119,15 @@ function withSignal(promise, signal) {
|
|
|
1095
1119
|
})
|
|
1096
1120
|
]);
|
|
1097
1121
|
}
|
|
1098
|
-
var emitResponse = (response, successCode, errorCode, emitLog) => {
|
|
1099
|
-
const isSuccess = !!response.data && !response.error;
|
|
1100
|
-
emitLog(
|
|
1101
|
-
PollarStateVar.LOGIN,
|
|
1102
|
-
isSuccess ? successCode : errorCode,
|
|
1103
|
-
isSuccess ? "info" : "error",
|
|
1104
|
-
isSuccess ? StateStatus.LOADING : StateStatus.ERROR,
|
|
1105
|
-
isSuccess ? response.data : response.error
|
|
1106
|
-
);
|
|
1107
|
-
return isSuccess;
|
|
1108
|
-
};
|
|
1109
1122
|
async function login(options, deps) {
|
|
1110
1123
|
const { api, basePath, apiKey, signal, emitState, storeSession, clearSession } = deps;
|
|
1111
|
-
emitState(
|
|
1124
|
+
emitState("authentication", STATE_VAR_CODES.authentication.CREATE_SESSION_START, "info", StateStatus.LOADING);
|
|
1112
1125
|
const createSessionResponse = await api.POST("/auth/session", { signal });
|
|
1113
1126
|
if (!emitResponse(
|
|
1127
|
+
PollarStateVar.AUTHENTICATION,
|
|
1114
1128
|
createSessionResponse,
|
|
1115
|
-
STATE_VAR_CODES
|
|
1116
|
-
STATE_VAR_CODES
|
|
1129
|
+
{ code: STATE_VAR_CODES.authentication.CREATE_SESSION_SUCCESS },
|
|
1130
|
+
STATE_VAR_CODES.authentication.CREATE_SESSION_ERROR,
|
|
1117
1131
|
emitState
|
|
1118
1132
|
)) {
|
|
1119
1133
|
return;
|
|
@@ -1121,7 +1135,7 @@ async function login(options, deps) {
|
|
|
1121
1135
|
const clientSessionId = createSessionResponse.data.content.clientSessionId;
|
|
1122
1136
|
switch (options.provider) {
|
|
1123
1137
|
case "email": {
|
|
1124
|
-
emitState(
|
|
1138
|
+
emitState("authentication", STATE_VAR_CODES.authentication.EMAIL_AUTH_START, "info", StateStatus.LOADING, {
|
|
1125
1139
|
email: options.email
|
|
1126
1140
|
});
|
|
1127
1141
|
const emailRes = await api.POST(`/auth/email`, {
|
|
@@ -1129,9 +1143,10 @@ async function login(options, deps) {
|
|
|
1129
1143
|
signal
|
|
1130
1144
|
});
|
|
1131
1145
|
if (!emitResponse(
|
|
1146
|
+
PollarStateVar.AUTHENTICATION,
|
|
1132
1147
|
emailRes,
|
|
1133
|
-
STATE_VAR_CODES
|
|
1134
|
-
STATE_VAR_CODES
|
|
1148
|
+
{ code: STATE_VAR_CODES.authentication.EMAIL_AUTH_START_SUCCESS },
|
|
1149
|
+
STATE_VAR_CODES.authentication.EMAIL_AUTH_START_ERROR,
|
|
1135
1150
|
emitState
|
|
1136
1151
|
)) {
|
|
1137
1152
|
return;
|
|
@@ -1149,15 +1164,15 @@ async function login(options, deps) {
|
|
|
1149
1164
|
}
|
|
1150
1165
|
case "wallet": {
|
|
1151
1166
|
try {
|
|
1152
|
-
emitState(
|
|
1167
|
+
emitState("authentication", STATE_VAR_CODES.authentication.WALLET_AUTH_START, "info", StateStatus.LOADING, {
|
|
1153
1168
|
adapter: options.type
|
|
1154
1169
|
});
|
|
1155
1170
|
const adapter = options.type === "freighter" /* FREIGHTER */ ? new FreighterAdapter() : new AlbedoAdapter();
|
|
1156
1171
|
const available = await withSignal(adapter.isAvailable(), signal);
|
|
1157
1172
|
if (!available) {
|
|
1158
1173
|
emitState(
|
|
1159
|
-
|
|
1160
|
-
options.type === "freighter" /* FREIGHTER */ ? STATE_VAR_CODES
|
|
1174
|
+
"authentication",
|
|
1175
|
+
options.type === "freighter" /* FREIGHTER */ ? STATE_VAR_CODES.authentication.WALLET_AUTH_FREIGHTER_NOT_INSTALLED : STATE_VAR_CODES.authentication.WALLET_AUTH_ALBEDO_NOT_INSTALLED,
|
|
1161
1176
|
"info",
|
|
1162
1177
|
StateStatus.LOADING,
|
|
1163
1178
|
{
|
|
@@ -1166,47 +1181,36 @@ async function login(options, deps) {
|
|
|
1166
1181
|
);
|
|
1167
1182
|
}
|
|
1168
1183
|
const { publicKey } = await withSignal(adapter.connect(), signal);
|
|
1169
|
-
emitState(
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
}
|
|
1178
|
-
);
|
|
1179
|
-
emitState(
|
|
1180
|
-
PollarStateVar.LOGIN,
|
|
1181
|
-
STATE_VAR_CODES[PollarStateVar.LOGIN].WALLET_AUTH_LOGIN_START,
|
|
1182
|
-
"info",
|
|
1183
|
-
StateStatus.LOADING,
|
|
1184
|
-
{
|
|
1185
|
-
adapter: options.type,
|
|
1186
|
-
publicKey
|
|
1187
|
-
}
|
|
1188
|
-
);
|
|
1184
|
+
emitState("authentication", STATE_VAR_CODES.authentication.WALLET_AUTH_CONNECTED, "info", StateStatus.LOADING, {
|
|
1185
|
+
adapter: options.type,
|
|
1186
|
+
publicKey
|
|
1187
|
+
});
|
|
1188
|
+
emitState("authentication", STATE_VAR_CODES.authentication.WALLET_AUTH_LOGIN_START, "info", StateStatus.LOADING, {
|
|
1189
|
+
adapter: options.type,
|
|
1190
|
+
publicKey
|
|
1191
|
+
});
|
|
1189
1192
|
const emailRes = await api.POST(`/auth/wallet`, {
|
|
1190
1193
|
body: { clientSessionId, walletAddress: publicKey },
|
|
1191
1194
|
signal
|
|
1192
1195
|
});
|
|
1193
1196
|
if (!emitResponse(
|
|
1197
|
+
PollarStateVar.AUTHENTICATION,
|
|
1194
1198
|
emailRes,
|
|
1195
|
-
STATE_VAR_CODES
|
|
1196
|
-
STATE_VAR_CODES
|
|
1199
|
+
{ code: STATE_VAR_CODES.authentication.WALLET_AUTH_LOGIN_START_SUCCESS },
|
|
1200
|
+
STATE_VAR_CODES.authentication.WALLET_AUTH_LOGIN_START_ERROR,
|
|
1197
1201
|
emitState
|
|
1198
1202
|
)) {
|
|
1199
1203
|
return;
|
|
1200
1204
|
}
|
|
1201
1205
|
} catch (error2) {
|
|
1202
|
-
emitState(
|
|
1206
|
+
emitState("authentication", STATE_VAR_CODES.authentication.WALLET_AUTH_ERROR, "error", StateStatus.ERROR, {
|
|
1203
1207
|
clientSessionId
|
|
1204
1208
|
});
|
|
1205
1209
|
}
|
|
1206
1210
|
break;
|
|
1207
1211
|
}
|
|
1208
1212
|
}
|
|
1209
|
-
emitState(
|
|
1213
|
+
emitState("authentication", STATE_VAR_CODES.authentication.STREAM_POLL_START, "info", StateStatus.LOADING, {
|
|
1210
1214
|
clientSessionId
|
|
1211
1215
|
});
|
|
1212
1216
|
await streamUntilFound(
|
|
@@ -1215,12 +1219,12 @@ async function login(options, deps) {
|
|
|
1215
1219
|
(data2) => {
|
|
1216
1220
|
const status = data2?.status;
|
|
1217
1221
|
if (status === "READY") {
|
|
1218
|
-
emitState(
|
|
1222
|
+
emitState("authentication", STATE_VAR_CODES.authentication.STREAM_POLL_READY, "info", StateStatus.LOADING);
|
|
1219
1223
|
return true;
|
|
1220
1224
|
}
|
|
1221
1225
|
emitState(
|
|
1222
|
-
|
|
1223
|
-
STATE_VAR_CODES
|
|
1226
|
+
"authentication",
|
|
1227
|
+
STATE_VAR_CODES.authentication.STREAM_POLL_EVENT + (status ? `/${status}` : ""),
|
|
1224
1228
|
"info",
|
|
1225
1229
|
StateStatus.LOADING,
|
|
1226
1230
|
data2
|
|
@@ -1230,16 +1234,16 @@ async function login(options, deps) {
|
|
|
1230
1234
|
200,
|
|
1231
1235
|
signal
|
|
1232
1236
|
);
|
|
1233
|
-
emitState(
|
|
1237
|
+
emitState("authentication", STATE_VAR_CODES.authentication.FETCH_SESSION_START, "info", StateStatus.LOADING);
|
|
1234
1238
|
const { data, error } = await api.POST(`/auth/login`, {
|
|
1235
1239
|
body: { clientSessionId },
|
|
1236
1240
|
signal
|
|
1237
1241
|
});
|
|
1238
1242
|
if (data?.code === "SDK_LOGIN_SUCCESS" && isValidSession(data?.content)) {
|
|
1239
|
-
emitState(
|
|
1243
|
+
emitState("authentication", STATE_VAR_CODES.authentication.FETCH_SESSION_SUCCESS, "info", StateStatus.SUCCESS);
|
|
1240
1244
|
storeSession(data.content);
|
|
1241
1245
|
} else {
|
|
1242
|
-
emitState(
|
|
1246
|
+
emitState("authentication", STATE_VAR_CODES.authentication.FETCH_SESSION_ERROR, "error", StateStatus.ERROR, {
|
|
1243
1247
|
error,
|
|
1244
1248
|
data
|
|
1245
1249
|
});
|
|
@@ -1259,8 +1263,9 @@ var PollarClient = class {
|
|
|
1259
1263
|
this._session = null;
|
|
1260
1264
|
this._stateListeners = /* @__PURE__ */ new Set();
|
|
1261
1265
|
this._state = {
|
|
1262
|
-
|
|
1263
|
-
|
|
1266
|
+
network: [],
|
|
1267
|
+
authentication: [],
|
|
1268
|
+
transaction: []
|
|
1264
1269
|
};
|
|
1265
1270
|
this.apiKey = config.apiKey;
|
|
1266
1271
|
this.id = crypto.randomUUID();
|
|
@@ -1286,6 +1291,9 @@ var PollarClient = class {
|
|
|
1286
1291
|
this._readStore();
|
|
1287
1292
|
}
|
|
1288
1293
|
});
|
|
1294
|
+
this._emitState("network", STATE_VAR_CODES.network.NETWORK_UPDATED, "info", StateStatus.SUCCESS, {
|
|
1295
|
+
network: "testnet"
|
|
1296
|
+
});
|
|
1289
1297
|
}
|
|
1290
1298
|
isAuthenticated() {
|
|
1291
1299
|
return !!this._session?.wallet?.publicKey;
|
|
@@ -1317,11 +1325,11 @@ var PollarClient = class {
|
|
|
1317
1325
|
}).catch((error) => {
|
|
1318
1326
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1319
1327
|
console.info("[PollarClient] Login aborted by user");
|
|
1320
|
-
this._emitState(
|
|
1328
|
+
this._emitState("authentication", STATE_VAR_CODES.authentication.ERROR_ABORTED, "error", StateStatus.ERROR);
|
|
1321
1329
|
return;
|
|
1322
1330
|
}
|
|
1323
1331
|
console.error("[PollarClient] Login failed with unexpected error", error);
|
|
1324
|
-
this._emitState(
|
|
1332
|
+
this._emitState("authentication", STATE_VAR_CODES.authentication.ERROR_UNKNOWN, "error", StateStatus.ERROR, {
|
|
1325
1333
|
error
|
|
1326
1334
|
});
|
|
1327
1335
|
});
|
|
@@ -1346,37 +1354,85 @@ var PollarClient = class {
|
|
|
1346
1354
|
body: { clientSessionId, code }
|
|
1347
1355
|
});
|
|
1348
1356
|
if (error || !data || data?.code !== "SDK_EMAIL_CODE_VERIFIED") {
|
|
1349
|
-
this._emitState(
|
|
1350
|
-
PollarStateVar.LOGIN,
|
|
1351
|
-
STATE_VAR_CODES[PollarStateVar.LOGIN].EMAIL_AUTH_CODE_ERROR,
|
|
1352
|
-
"error",
|
|
1353
|
-
StateStatus.ERROR,
|
|
1354
|
-
{
|
|
1355
|
-
data,
|
|
1356
|
-
error
|
|
1357
|
-
}
|
|
1358
|
-
);
|
|
1359
|
-
return;
|
|
1360
|
-
}
|
|
1361
|
-
this._emitState(
|
|
1362
|
-
PollarStateVar.LOGIN,
|
|
1363
|
-
STATE_VAR_CODES[PollarStateVar.LOGIN].EMAIL_AUTH_CODE_SUCCESS,
|
|
1364
|
-
"info",
|
|
1365
|
-
StateStatus.SUCCESS,
|
|
1366
|
-
{
|
|
1357
|
+
this._emitState("authentication", STATE_VAR_CODES.authentication.EMAIL_AUTH_CODE_ERROR, "error", StateStatus.ERROR, {
|
|
1367
1358
|
data,
|
|
1368
1359
|
error
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1360
|
+
});
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
this._emitState("authentication", STATE_VAR_CODES.authentication.EMAIL_AUTH_CODE_SUCCESS, "info", StateStatus.SUCCESS, {
|
|
1364
|
+
data,
|
|
1365
|
+
error
|
|
1366
|
+
});
|
|
1371
1367
|
} catch (error) {
|
|
1372
1368
|
this._emitState(
|
|
1373
|
-
|
|
1374
|
-
STATE_VAR_CODES
|
|
1369
|
+
"authentication",
|
|
1370
|
+
STATE_VAR_CODES.authentication.WALLET_AUTH_ALBEDO_NOT_INSTALLED,
|
|
1375
1371
|
"error",
|
|
1376
1372
|
StateStatus.ERROR
|
|
1377
1373
|
);
|
|
1378
1374
|
}
|
|
1379
1375
|
}
|
|
1376
|
+
getNetwork() {
|
|
1377
|
+
return this._state.network.at(-1)?.data?.network === "public" ? "public" : "testnet";
|
|
1378
|
+
}
|
|
1379
|
+
async buildTx(operation, params, options) {
|
|
1380
|
+
if (!this._session?.wallet?.publicKey) {
|
|
1381
|
+
this._emitState("transaction", STATE_VAR_CODES.transaction.BUILD_TRANSACTION_ERROR_NO_WALLET, "error", StateStatus.ERROR);
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
const body = {
|
|
1385
|
+
network: this.getNetwork(),
|
|
1386
|
+
publicKey: this._session?.wallet?.publicKey,
|
|
1387
|
+
operation,
|
|
1388
|
+
params,
|
|
1389
|
+
options: options || {}
|
|
1390
|
+
};
|
|
1391
|
+
try {
|
|
1392
|
+
this._emitState("transaction", STATE_VAR_CODES.transaction.BUILD_TRANSACTION_START, "info", StateStatus.LOADING);
|
|
1393
|
+
const response = await this._api.POST("/tx/build", { body });
|
|
1394
|
+
if (!emitResponse(
|
|
1395
|
+
PollarStateVar.TRANSACTION,
|
|
1396
|
+
response,
|
|
1397
|
+
{ code: STATE_VAR_CODES.transaction.BUILD_TRANSACTION_SUCCESS, status: StateStatus.SUCCESS },
|
|
1398
|
+
STATE_VAR_CODES.transaction.BUILD_TRANSACTION_ERROR,
|
|
1399
|
+
this._emitState.bind(this)
|
|
1400
|
+
)) {
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
} catch (error) {
|
|
1404
|
+
this._emitState("transaction", STATE_VAR_CODES.transaction.BUILD_TRANSACTION_ERROR, "error", StateStatus.ERROR, {
|
|
1405
|
+
body,
|
|
1406
|
+
error
|
|
1407
|
+
});
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
async submitTx(signedXdr) {
|
|
1412
|
+
const body = {
|
|
1413
|
+
network: this.getNetwork(),
|
|
1414
|
+
signedXdr
|
|
1415
|
+
};
|
|
1416
|
+
try {
|
|
1417
|
+
this._emitState("transaction", STATE_VAR_CODES.transaction.SIGN_SEND_TRANSACTION_START, "info", StateStatus.LOADING);
|
|
1418
|
+
const response = await this._api.POST("/tx/sign-and-send", { body });
|
|
1419
|
+
if (!emitResponse(
|
|
1420
|
+
PollarStateVar.TRANSACTION,
|
|
1421
|
+
response,
|
|
1422
|
+
{ code: STATE_VAR_CODES.transaction.SIGN_SEND_TRANSACTION_SUCCESS, status: StateStatus.SUCCESS },
|
|
1423
|
+
STATE_VAR_CODES.transaction.SIGN_SEND_TRANSACTION_ERROR,
|
|
1424
|
+
this._emitState.bind(this)
|
|
1425
|
+
)) {
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
} catch (error) {
|
|
1429
|
+
this._emitState("transaction", STATE_VAR_CODES.transaction.SIGN_SEND_TRANSACTION_ERROR, "error", StateStatus.ERROR, {
|
|
1430
|
+
body,
|
|
1431
|
+
error
|
|
1432
|
+
});
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1380
1436
|
logout() {
|
|
1381
1437
|
if (!isBrowser) {
|
|
1382
1438
|
warnServerSide("logout");
|
|
@@ -1389,20 +1445,15 @@ var PollarClient = class {
|
|
|
1389
1445
|
this._session = readStorage();
|
|
1390
1446
|
if (this._session) {
|
|
1391
1447
|
this._emitState(
|
|
1392
|
-
|
|
1393
|
-
STATE_VAR_CODES
|
|
1448
|
+
"authentication",
|
|
1449
|
+
STATE_VAR_CODES.authentication.RESTORED_SESSION_SUCCESS,
|
|
1394
1450
|
"info",
|
|
1395
1451
|
StateStatus.SUCCESS,
|
|
1396
1452
|
this._session
|
|
1397
1453
|
);
|
|
1398
1454
|
console.info("[PollarClient] Session restored from storage");
|
|
1399
1455
|
} else {
|
|
1400
|
-
this._emitState(
|
|
1401
|
-
PollarStateVar.WALLET_ADDRESS,
|
|
1402
|
-
STATE_VAR_CODES[PollarStateVar.WALLET_ADDRESS].REMOVED_ADDRESS,
|
|
1403
|
-
"info",
|
|
1404
|
-
StateStatus.SUCCESS
|
|
1405
|
-
);
|
|
1456
|
+
this._emitState("authentication", STATE_VAR_CODES.authentication.RESTORED_SESSION_SUCCESS, "warn", StateStatus.ERROR);
|
|
1406
1457
|
console.info("[PollarClient] Session NO restored from storage");
|
|
1407
1458
|
}
|
|
1408
1459
|
}
|
|
@@ -1411,8 +1462,8 @@ var PollarClient = class {
|
|
|
1411
1462
|
this._session = session;
|
|
1412
1463
|
writeStorage(session);
|
|
1413
1464
|
this._emitState(
|
|
1414
|
-
|
|
1415
|
-
STATE_VAR_CODES
|
|
1465
|
+
"authentication",
|
|
1466
|
+
STATE_VAR_CODES.authentication.SESSION_STORED,
|
|
1416
1467
|
"info",
|
|
1417
1468
|
StateStatus.SUCCESS,
|
|
1418
1469
|
this._session
|
|
@@ -1423,16 +1474,11 @@ var PollarClient = class {
|
|
|
1423
1474
|
this._session = null;
|
|
1424
1475
|
removeStorage();
|
|
1425
1476
|
this._state = {
|
|
1426
|
-
|
|
1427
|
-
|
|
1477
|
+
network: [],
|
|
1478
|
+
authentication: [],
|
|
1479
|
+
transaction: []
|
|
1428
1480
|
};
|
|
1429
|
-
this._emitState(
|
|
1430
|
-
this._emitState(
|
|
1431
|
-
PollarStateVar.WALLET_ADDRESS,
|
|
1432
|
-
STATE_VAR_CODES[PollarStateVar.WALLET_ADDRESS].REMOVED_ADDRESS,
|
|
1433
|
-
"info",
|
|
1434
|
-
StateStatus.NONE
|
|
1435
|
-
);
|
|
1481
|
+
this._emitState("authentication", STATE_VAR_CODES.authentication.LOGOUT, "info", StateStatus.NONE);
|
|
1436
1482
|
}
|
|
1437
1483
|
_emitState(fn, code, level, status, data) {
|
|
1438
1484
|
const stateEntry = { var: fn, code, level, data, status, ts: Date.now() };
|
|
@@ -1480,6 +1526,6 @@ var StellarClient = class {
|
|
|
1480
1526
|
}
|
|
1481
1527
|
};
|
|
1482
1528
|
|
|
1483
|
-
export { AlbedoAdapter, FreighterAdapter, PollarClient,
|
|
1529
|
+
export { AlbedoAdapter, FreighterAdapter, PollarClient, PollarStateVar, STATE_VAR_CODES, StateStatus, StellarClient, WalletType, isValidSession };
|
|
1484
1530
|
//# sourceMappingURL=index.mjs.map
|
|
1485
1531
|
//# sourceMappingURL=index.mjs.map
|