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