@glyphteck/veyl 0.66.2 → 0.67.0
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/account.js +114 -32
- package/dist/accountprofiles.js +80 -16
- package/dist/auth.js +2 -2
- package/dist/cli.js +204 -117
- package/dist/index.js +204 -117
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7922,7 +7922,7 @@ function closeSessionResources({ wallet, chatPK, chatPrivateKey, chatSigningSecr
|
|
|
7922
7922
|
close(vaultAccess);
|
|
7923
7923
|
close(vaultSigner);
|
|
7924
7924
|
close(localCache);
|
|
7925
|
-
|
|
7925
|
+
lockWallet(wallet);
|
|
7926
7926
|
lockChat(chatPrivateKey, chatPK);
|
|
7927
7927
|
cleanBytes(chatSigningSecret, notificationPrivateKey, notificationPublicKey);
|
|
7928
7928
|
return Promise.allSettled(pending).then(() => {
|
|
@@ -8551,12 +8551,16 @@ function settingsState(settings = defaultSettings) {
|
|
|
8551
8551
|
}
|
|
8552
8552
|
};
|
|
8553
8553
|
}
|
|
8554
|
+
function isAccountAuthenticationError(error) {
|
|
8555
|
+
const code = typeof error?.code === "string" ? error.code.toLowerCase() : "";
|
|
8556
|
+
return code === "permission-denied" || code.endsWith("/permission-denied") || code === "unauthenticated" || code.endsWith("/unauthenticated");
|
|
8557
|
+
}
|
|
8554
8558
|
function createUser({ cloud, network, avatarCache = null, diag = null, onSessionRevoked = null }) {
|
|
8555
8559
|
if (!cloud) {
|
|
8556
8560
|
throw new Error("createUser requires { cloud }");
|
|
8557
8561
|
}
|
|
8558
|
-
if (avatarCache && [avatarCache.read, avatarCache.write, avatarCache.remove
|
|
8559
|
-
throw new Error("avatarCache requires read, write,
|
|
8562
|
+
if (avatarCache && [avatarCache.read, avatarCache.write, avatarCache.remove].some((method) => typeof method !== "function")) {
|
|
8563
|
+
throw new Error("avatarCache requires read, write, and remove");
|
|
8560
8564
|
}
|
|
8561
8565
|
let activeNetwork = network;
|
|
8562
8566
|
let state = defaultUser;
|
|
@@ -8694,9 +8698,6 @@ function createUser({ cloud, network, avatarCache = null, diag = null, onSession
|
|
|
8694
8698
|
return;
|
|
8695
8699
|
runCacheTask("user.avatar.cache.remove", () => avatarCache.remove(uid));
|
|
8696
8700
|
}
|
|
8697
|
-
function clearCachedAvatars() {
|
|
8698
|
-
runCacheTask("user.avatar.cache.clear", () => avatarCache.removeAll());
|
|
8699
|
-
}
|
|
8700
8701
|
async function fetchAvatar(uid, { version = null, force = false, clear = false, persist = true } = {}) {
|
|
8701
8702
|
if (!uid)
|
|
8702
8703
|
return;
|
|
@@ -8779,6 +8780,54 @@ function createUser({ cloud, network, avatarCache = null, diag = null, onSession
|
|
|
8779
8780
|
function isCurrentUser(uid, session) {
|
|
8780
8781
|
return started && authSession === session && userUid === uid;
|
|
8781
8782
|
}
|
|
8783
|
+
function revokeAuthentication(authUser, {
|
|
8784
|
+
code = "",
|
|
8785
|
+
local = false,
|
|
8786
|
+
reason = "session-inactive"
|
|
8787
|
+
} = {}) {
|
|
8788
|
+
if (revokingSession)
|
|
8789
|
+
return;
|
|
8790
|
+
revokingSession = true;
|
|
8791
|
+
let callback;
|
|
8792
|
+
try {
|
|
8793
|
+
callback = onSessionRevoked?.({
|
|
8794
|
+
uid: authUser.uid,
|
|
8795
|
+
code,
|
|
8796
|
+
reason
|
|
8797
|
+
});
|
|
8798
|
+
} catch (error) {
|
|
8799
|
+
callback = Promise.reject(error);
|
|
8800
|
+
}
|
|
8801
|
+
markDiag(diag, "user.auth.revoked", {
|
|
8802
|
+
code,
|
|
8803
|
+
local,
|
|
8804
|
+
reason
|
|
8805
|
+
});
|
|
8806
|
+
setState((user) => ({
|
|
8807
|
+
...user,
|
|
8808
|
+
authSessionReady: true,
|
|
8809
|
+
authSessionActive: false,
|
|
8810
|
+
authCredential: null
|
|
8811
|
+
}));
|
|
8812
|
+
let operation = Promise.resolve(callback).catch((error) => markError(diag, "user.session.revoke.local", Date.now(), error));
|
|
8813
|
+
if (!local) {
|
|
8814
|
+
operation = operation.then(() => cloud.auth.logout()).catch((error) => markError(diag, "user.session.revoke.auth", Date.now(), error));
|
|
8815
|
+
}
|
|
8816
|
+
operation.finally(() => {
|
|
8817
|
+
if (userUid === authUser.uid) {
|
|
8818
|
+
revokingSession = false;
|
|
8819
|
+
}
|
|
8820
|
+
});
|
|
8821
|
+
}
|
|
8822
|
+
function revokeAuthenticationError(authUser, error, reason) {
|
|
8823
|
+
if (!isAccountAuthenticationError(error))
|
|
8824
|
+
return false;
|
|
8825
|
+
revokeAuthentication(authUser, {
|
|
8826
|
+
code: error?.code || "",
|
|
8827
|
+
reason
|
|
8828
|
+
});
|
|
8829
|
+
return true;
|
|
8830
|
+
}
|
|
8782
8831
|
function watchUser(authUser) {
|
|
8783
8832
|
if (!started)
|
|
8784
8833
|
return;
|
|
@@ -8788,7 +8837,6 @@ function createUser({ cloud, network, avatarCache = null, diag = null, onSession
|
|
|
8788
8837
|
closeUserWatches();
|
|
8789
8838
|
markDiag(diag, "user.auth.state", { signedIn: !!authUser });
|
|
8790
8839
|
if (!authUser) {
|
|
8791
|
-
const signedOutUid = userUid;
|
|
8792
8840
|
revokingSession = false;
|
|
8793
8841
|
userUid = null;
|
|
8794
8842
|
clearSettingsKey(settingsKey);
|
|
@@ -8797,17 +8845,11 @@ function createUser({ cloud, network, avatarCache = null, diag = null, onSession
|
|
|
8797
8845
|
agreementStored = null;
|
|
8798
8846
|
agreementOverride = null;
|
|
8799
8847
|
agreementAcceptance = null;
|
|
8800
|
-
if (signedOutUid) {
|
|
8801
|
-
clearCachedAvatars();
|
|
8802
|
-
}
|
|
8803
8848
|
avatarFetch = { uid: null, key: null, promise: null };
|
|
8804
8849
|
setState({ ...defaultUser, authReady: true });
|
|
8805
8850
|
return;
|
|
8806
8851
|
}
|
|
8807
8852
|
const authUidChanged = userUid !== authUser.uid;
|
|
8808
|
-
if (userUid && authUidChanged) {
|
|
8809
|
-
clearCachedAvatars();
|
|
8810
|
-
}
|
|
8811
8853
|
userUid = authUser.uid;
|
|
8812
8854
|
if (authUidChanged) {
|
|
8813
8855
|
clearSettingsKey(settingsKey);
|
|
@@ -8837,32 +8879,28 @@ function createUser({ cloud, network, avatarCache = null, diag = null, onSession
|
|
|
8837
8879
|
userWatches.push(cloud.auth.session.watch(authUser.uid, current((authSessionState) => {
|
|
8838
8880
|
if (authSessionState?.active) {
|
|
8839
8881
|
const authCredential = authSessionState.authCredential;
|
|
8840
|
-
setState((user) => user.authCredential?.kind === authCredential?.kind && user.authCredential?.id === authCredential?.id ? user : {
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
revokingSession = true;
|
|
8846
|
-
if (cloud.auth.session.isLocalTermination?.(authUser.uid, authSessionState?.generation)) {
|
|
8847
|
-
Promise.resolve(onSessionRevoked?.({ uid: authUser.uid })).catch((error) => markError(diag, "user.session.revoke.local", Date.now(), error)).finally(() => {
|
|
8848
|
-
if (userUid === authUser.uid) {
|
|
8849
|
-
revokingSession = false;
|
|
8850
|
-
}
|
|
8882
|
+
setState((user) => user.authSessionReady && user.authSessionActive && user.authCredential?.kind === authCredential?.kind && user.authCredential?.id === authCredential?.id ? user : {
|
|
8883
|
+
...user,
|
|
8884
|
+
authSessionReady: true,
|
|
8885
|
+
authSessionActive: true,
|
|
8886
|
+
authCredential
|
|
8851
8887
|
});
|
|
8852
8888
|
return;
|
|
8853
8889
|
}
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
}
|
|
8890
|
+
revokeAuthentication(authUser, {
|
|
8891
|
+
local: cloud.auth.session.isLocalTermination?.(authUser.uid, authSessionState?.generation) === true,
|
|
8892
|
+
reason: "session-inactive"
|
|
8858
8893
|
});
|
|
8859
8894
|
}), current((error) => {
|
|
8860
8895
|
markError(diag, "user.session.listen", authStartedAt, error);
|
|
8896
|
+
revokeAuthenticationError(authUser, error, "session-listener");
|
|
8861
8897
|
})));
|
|
8862
8898
|
userWatches.push(cloud.user.admin.watch(authUser.uid, current((allowed) => {
|
|
8863
8899
|
setState((user) => ({ ...user, isAdmin: allowed, adminReady: true }));
|
|
8864
8900
|
}), current((error) => {
|
|
8865
8901
|
markError(diag, "user.admin.listen", authStartedAt, error);
|
|
8902
|
+
if (revokeAuthenticationError(authUser, error, "admin-listener"))
|
|
8903
|
+
return;
|
|
8866
8904
|
setState((user) => ({ ...user, isAdmin: false, adminReady: true }));
|
|
8867
8905
|
})));
|
|
8868
8906
|
userWatches.push(cloud.user.private.watch(authUser.uid, current((privateData, info = {}) => {
|
|
@@ -8886,6 +8924,8 @@ function createUser({ cloud, network, avatarCache = null, diag = null, onSession
|
|
|
8886
8924
|
}));
|
|
8887
8925
|
}), current((error) => {
|
|
8888
8926
|
markError(diag, "user.settings.snapshot", authStartedAt, error);
|
|
8927
|
+
if (revokeAuthenticationError(authUser, error, "settings-listener"))
|
|
8928
|
+
return;
|
|
8889
8929
|
settingsStored = null;
|
|
8890
8930
|
agreementStored = null;
|
|
8891
8931
|
setState((user) => ({
|
|
@@ -8898,6 +8938,8 @@ function createUser({ cloud, network, avatarCache = null, diag = null, onSession
|
|
|
8898
8938
|
setState((user) => ({ ...user, banned: banned ?? null }));
|
|
8899
8939
|
}), current((error) => {
|
|
8900
8940
|
markError(diag, "user.moderation.listen", authStartedAt, error);
|
|
8941
|
+
if (revokeAuthenticationError(authUser, error, "moderation-listener"))
|
|
8942
|
+
return;
|
|
8901
8943
|
setState((user) => ({ ...user, banned: null }));
|
|
8902
8944
|
})));
|
|
8903
8945
|
userWatches.push(cloud.user.blocked.watch(authUser.uid, current((blocked, info = {}) => {
|
|
@@ -8910,6 +8952,8 @@ function createUser({ cloud, network, avatarCache = null, diag = null, onSession
|
|
|
8910
8952
|
});
|
|
8911
8953
|
}), current((error) => {
|
|
8912
8954
|
markError(diag, "user.blocked.listen", authStartedAt, error);
|
|
8955
|
+
if (revokeAuthenticationError(authUser, error, "blocked-listener"))
|
|
8956
|
+
return;
|
|
8913
8957
|
setState((user) => ({ ...user, blockedReady: false }));
|
|
8914
8958
|
})));
|
|
8915
8959
|
userWatches.push(cloud.user.profile.watch(authUser.uid, current((profileData, info = {}) => {
|
|
@@ -8956,6 +9000,8 @@ function createUser({ cloud, network, avatarCache = null, diag = null, onSession
|
|
|
8956
9000
|
}
|
|
8957
9001
|
}), current((error) => {
|
|
8958
9002
|
markError(diag, "user.profile.snapshot", authStartedAt, error);
|
|
9003
|
+
if (revokeAuthenticationError(authUser, error, "profile-listener"))
|
|
9004
|
+
return;
|
|
8959
9005
|
avatarFetch = { uid: null, key: null, promise: null };
|
|
8960
9006
|
setState((user) => ({
|
|
8961
9007
|
...user,
|
|
@@ -9186,6 +9232,8 @@ var init_user = __esm(() => {
|
|
|
9186
9232
|
defaultUser = {
|
|
9187
9233
|
uid: null,
|
|
9188
9234
|
authReady: false,
|
|
9235
|
+
authSessionReady: false,
|
|
9236
|
+
authSessionActive: false,
|
|
9189
9237
|
authCredential: null,
|
|
9190
9238
|
profileReady: false,
|
|
9191
9239
|
username: null,
|
|
@@ -45674,20 +45722,36 @@ function openAccount(options = {}) {
|
|
|
45674
45722
|
let closePromise = null;
|
|
45675
45723
|
let state;
|
|
45676
45724
|
let chatSession = null;
|
|
45725
|
+
let revokedUid = null;
|
|
45726
|
+
let revocationPromise = null;
|
|
45677
45727
|
let nextAgreement = agreementContract(options.agreement || CURRENT_AGREEMENT);
|
|
45678
45728
|
const listeners = new Set;
|
|
45679
45729
|
let activeWriteTail = Promise.resolve();
|
|
45680
45730
|
const sessionCloseWork = new Set;
|
|
45681
45731
|
const operationBarrier = createAccountOperationCloseBarrier();
|
|
45732
|
+
function revokeSession(details = {}) {
|
|
45733
|
+
const { uid = null } = details;
|
|
45734
|
+
const accountUid = uid || state?.uid || null;
|
|
45735
|
+
if (accountUid && revokedUid === accountUid) {
|
|
45736
|
+
return revocationPromise || Promise.resolve();
|
|
45737
|
+
}
|
|
45738
|
+
revokedUid = accountUid;
|
|
45739
|
+
let callback;
|
|
45740
|
+
try {
|
|
45741
|
+
callback = options.onSessionRevoked?.({ ...details, uid: accountUid });
|
|
45742
|
+
} catch (error) {
|
|
45743
|
+
callback = Promise.reject(error);
|
|
45744
|
+
}
|
|
45745
|
+
lock();
|
|
45746
|
+
revocationPromise = Promise.resolve(callback);
|
|
45747
|
+
return revocationPromise;
|
|
45748
|
+
}
|
|
45682
45749
|
const user = options.user || createUser({
|
|
45683
45750
|
cloud,
|
|
45684
45751
|
network: options.network || defaultNetwork,
|
|
45685
45752
|
avatarCache,
|
|
45686
45753
|
diag,
|
|
45687
|
-
onSessionRevoked:
|
|
45688
|
-
lock();
|
|
45689
|
-
options.onSessionRevoked?.({ uid: uid || state?.uid || null });
|
|
45690
|
-
}
|
|
45754
|
+
onSessionRevoked: revokeSession
|
|
45691
45755
|
});
|
|
45692
45756
|
state = emptyState(user.getSnapshot(), options.network || defaultNetwork);
|
|
45693
45757
|
const chat = createChatSession({
|
|
@@ -45936,6 +46000,24 @@ function openAccount(options = {}) {
|
|
|
45936
46000
|
code: error?.code || "",
|
|
45937
46001
|
message: error?.message || String(error)
|
|
45938
46002
|
});
|
|
46003
|
+
if (isAccountAuthenticationError(error)) {
|
|
46004
|
+
revokeSession({
|
|
46005
|
+
uid,
|
|
46006
|
+
code: error?.code || "",
|
|
46007
|
+
reason: "vault-listener"
|
|
46008
|
+
}).catch((revocationError) => {
|
|
46009
|
+
diag?.("account.session.revoke.error", {
|
|
46010
|
+
code: revocationError?.code || "",
|
|
46011
|
+
message: revocationError?.message || String(revocationError)
|
|
46012
|
+
});
|
|
46013
|
+
}).then(() => cloud.auth.logout()).catch((logoutError) => {
|
|
46014
|
+
diag?.("account.session.revoke.auth.error", {
|
|
46015
|
+
code: logoutError?.code || "",
|
|
46016
|
+
message: logoutError?.message || String(logoutError)
|
|
46017
|
+
});
|
|
46018
|
+
});
|
|
46019
|
+
return;
|
|
46020
|
+
}
|
|
45939
46021
|
lock();
|
|
45940
46022
|
emit2({ vault: null, vaultReady: true, vaultError: error });
|
|
45941
46023
|
});
|
|
@@ -46400,8 +46482,8 @@ function normalizePasskeyLoginError(error, options = {}) {
|
|
|
46400
46482
|
return error;
|
|
46401
46483
|
}
|
|
46402
46484
|
function normalizePasskeyRegisterError(error, options = {}) {
|
|
46403
|
-
if (error?.name === "InvalidStateError" || error?.code === "functions/already-exists") {
|
|
46404
|
-
return passkeyError(PASSKEY_PROVIDER_ALREADY_LINKED, "
|
|
46485
|
+
if (error?.name === "CredentialAlreadyExistsException" || error?.name === "InvalidStateError" || error?.code === "functions/already-exists") {
|
|
46486
|
+
return passkeyError(PASSKEY_PROVIDER_ALREADY_LINKED, "you already have a passkey for this account", error);
|
|
46405
46487
|
}
|
|
46406
46488
|
if (error?.code === "functions/failed-precondition") {
|
|
46407
46489
|
return passkeyError(PASSKEY_RP_MISMATCH, "This passkey belongs to a different Glyphteck passkey setup.", error);
|
|
@@ -56424,7 +56506,7 @@ var package_default;
|
|
|
56424
56506
|
var init_package2 = __esm(() => {
|
|
56425
56507
|
package_default = {
|
|
56426
56508
|
name: "veyl",
|
|
56427
|
-
version: "0.
|
|
56509
|
+
version: "0.67.0",
|
|
56428
56510
|
packageManager: "bun@1.4.0",
|
|
56429
56511
|
private: true,
|
|
56430
56512
|
license: "UNLICENSED",
|
|
@@ -57536,7 +57618,7 @@ var init_client = __esm(() => {
|
|
|
57536
57618
|
]);
|
|
57537
57619
|
});
|
|
57538
57620
|
|
|
57539
|
-
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+
|
|
57621
|
+
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+8e98cae01074b602/node_modules/@buildonspark/spark-sdk/dist/chunk-BCcL9Bmk.js
|
|
57540
57622
|
var init_chunk_BCcL9Bmk = () => {};
|
|
57541
57623
|
|
|
57542
57624
|
// ../../node_modules/.bun/@bufbuild+protobuf@2.14.0/node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js
|
|
@@ -58308,7 +58390,7 @@ var init_wire2 = __esm(() => {
|
|
|
58308
58390
|
init_size_delimited();
|
|
58309
58391
|
});
|
|
58310
58392
|
|
|
58311
|
-
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+
|
|
58393
|
+
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+8e98cae01074b602/node_modules/@buildonspark/spark-sdk/dist/empty-mxtQJySK.js
|
|
58312
58394
|
function createBaseTimestamp() {
|
|
58313
58395
|
return {
|
|
58314
58396
|
seconds: 0,
|
|
@@ -58653,7 +58735,7 @@ var init_empty_mxtQJySK = __esm(() => {
|
|
|
58653
58735
|
};
|
|
58654
58736
|
});
|
|
58655
58737
|
|
|
58656
|
-
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+
|
|
58738
|
+
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+8e98cae01074b602/node_modules/@buildonspark/spark-sdk/dist/proto/spark.js
|
|
58657
58739
|
function networkFromJSON(object) {
|
|
58658
58740
|
switch (object) {
|
|
58659
58741
|
case 0:
|
|
@@ -95034,7 +95116,7 @@ var init_dist3 = __esm(() => {
|
|
|
95034
95116
|
};
|
|
95035
95117
|
});
|
|
95036
95118
|
|
|
95037
|
-
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+
|
|
95119
|
+
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+8e98cae01074b602/node_modules/@buildonspark/spark-sdk/dist/sdk-types-CKSuGSGE.js
|
|
95038
95120
|
function getAllProperties2(object) {
|
|
95039
95121
|
const properties = /* @__PURE__ */ new Set;
|
|
95040
95122
|
let current = object;
|
|
@@ -95878,7 +95960,7 @@ var init_sdk_types_CKSuGSGE = __esm(() => {
|
|
|
95878
95960
|
}({});
|
|
95879
95961
|
});
|
|
95880
95962
|
|
|
95881
|
-
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+
|
|
95963
|
+
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+8e98cae01074b602/node_modules/@buildonspark/spark-sdk/dist/multisig-BPUmc7A3.js
|
|
95882
95964
|
function createBaseMultisigConfig() {
|
|
95883
95965
|
return {
|
|
95884
95966
|
version: 0,
|
|
@@ -96107,7 +96189,7 @@ var init_multisig_BPUmc7A3 = __esm(() => {
|
|
|
96107
96189
|
};
|
|
96108
96190
|
});
|
|
96109
96191
|
|
|
96110
|
-
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+
|
|
96192
|
+
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+8e98cae01074b602/node_modules/@buildonspark/spark-sdk/dist/proto/spark_token.js
|
|
96111
96193
|
function tokenOutputStatusFromJSON(object) {
|
|
96112
96194
|
switch (object) {
|
|
96113
96195
|
case 0:
|
|
@@ -109410,7 +109492,7 @@ var require_bolt11 = __commonJS(function(exports, module) {
|
|
|
109410
109492
|
};
|
|
109411
109493
|
});
|
|
109412
109494
|
|
|
109413
|
-
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+
|
|
109495
|
+
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+8e98cae01074b602/node_modules/@buildonspark/spark-sdk/dist/spark-wallet-CwB3Fuv1.js
|
|
109414
109496
|
function parseSignature(signature) {
|
|
109415
109497
|
if (signature.length !== 64)
|
|
109416
109498
|
throw new Error(`Invalid signature length: expected 64, got ${signature.length}`);
|
|
@@ -153313,7 +153395,7 @@ var require_lib5 = __commonJS(function(exports) {
|
|
|
153313
153395
|
exports.retryMiddleware = retryMiddleware;
|
|
153314
153396
|
});
|
|
153315
153397
|
|
|
153316
|
-
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+
|
|
153398
|
+
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+8e98cae01074b602/node_modules/@buildonspark/spark-sdk/dist/spark-wallet.node-bD67u0Y4.js
|
|
153317
153399
|
import { createHash } from "crypto";
|
|
153318
153400
|
import { createWriteStream, mkdirSync } from "node:fs";
|
|
153319
153401
|
import { dirname } from "node:path";
|
|
@@ -155912,7 +155994,7 @@ var init_spark_wallet_node_bD67u0Y4 = __esm(() => {
|
|
|
155912
155994
|
};
|
|
155913
155995
|
});
|
|
155914
155996
|
|
|
155915
|
-
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+
|
|
155997
|
+
// ../../node_modules/.bun/@buildonspark+spark-sdk@0.9.0+8e98cae01074b602/node_modules/@buildonspark/spark-sdk/dist/index.node.js
|
|
155916
155998
|
import nodeCrypto from "crypto";
|
|
155917
155999
|
var cryptoImpl2;
|
|
155918
156000
|
var init_index_node = __esm(() => {
|
|
@@ -158469,7 +158551,7 @@ var init_index_esm3 = __esm(() => {
|
|
|
158469
158551
|
registerCoreComponents("");
|
|
158470
158552
|
});
|
|
158471
158553
|
|
|
158472
|
-
// ../../node_modules/.bun/firebase@12.18.0+
|
|
158554
|
+
// ../../node_modules/.bun/firebase@12.18.0+40ac9e013e4b1dea/node_modules/firebase/app/dist/index.mjs
|
|
158473
158555
|
var name3 = "firebase", version2 = "12.18.0";
|
|
158474
158556
|
var init_dist4 = __esm(() => {
|
|
158475
158557
|
init_index_esm3();
|
|
@@ -158477,7 +158559,7 @@ var init_dist4 = __esm(() => {
|
|
|
158477
158559
|
registerVersion(name3, version2, "app");
|
|
158478
158560
|
});
|
|
158479
158561
|
|
|
158480
|
-
// ../../node_modules/.bun/@firebase+auth@1.13.5+
|
|
158562
|
+
// ../../node_modules/.bun/@firebase+auth@1.13.5+a89daa0b3e4af1f5/node_modules/@firebase/auth/dist/node-esm/totp-C24pd8aS.js
|
|
158481
158563
|
function _debugErrorMap() {
|
|
158482
158564
|
return {
|
|
158483
158565
|
["admin-restricted-operation"]: "This operation is restricted to administrators only.",
|
|
@@ -162451,7 +162533,7 @@ var init_totp_C24pd8aS = __esm(() => {
|
|
|
162451
162533
|
};
|
|
162452
162534
|
});
|
|
162453
162535
|
|
|
162454
|
-
// ../../node_modules/.bun/@firebase+auth@1.13.5+
|
|
162536
|
+
// ../../node_modules/.bun/@firebase+auth@1.13.5+a89daa0b3e4af1f5/node_modules/@firebase/auth/dist/node-esm/index.js
|
|
162455
162537
|
var init_node_esm = __esm(() => {
|
|
162456
162538
|
init_totp_C24pd8aS();
|
|
162457
162539
|
init_index_esm3();
|
|
@@ -162460,7 +162542,7 @@ var init_node_esm = __esm(() => {
|
|
|
162460
162542
|
init_index_esm2();
|
|
162461
162543
|
});
|
|
162462
162544
|
|
|
162463
|
-
// ../../node_modules/.bun/firebase@12.18.0+
|
|
162545
|
+
// ../../node_modules/.bun/firebase@12.18.0+40ac9e013e4b1dea/node_modules/firebase/auth/dist/index.mjs
|
|
162464
162546
|
var exports_dist = {};
|
|
162465
162547
|
__export(exports_dist, {
|
|
162466
162548
|
ActionCodeOperation: () => ActionCodeOperation,
|
|
@@ -197105,7 +197187,7 @@ var init_index_node2 = __esm(() => {
|
|
|
197105
197187
|
registerFirestore("node");
|
|
197106
197188
|
});
|
|
197107
197189
|
|
|
197108
|
-
// ../../node_modules/.bun/firebase@12.18.0+
|
|
197190
|
+
// ../../node_modules/.bun/firebase@12.18.0+40ac9e013e4b1dea/node_modules/firebase/firestore/dist/index.mjs
|
|
197109
197191
|
var exports_dist2 = {};
|
|
197110
197192
|
__export(exports_dist2, {
|
|
197111
197193
|
AbstractUserDataWriter: () => AbstractUserDataWriter,
|
|
@@ -197808,7 +197890,7 @@ var init_index_esm4 = __esm(() => {
|
|
|
197808
197890
|
registerFunctions();
|
|
197809
197891
|
});
|
|
197810
197892
|
|
|
197811
|
-
// ../../node_modules/.bun/firebase@12.18.0+
|
|
197893
|
+
// ../../node_modules/.bun/firebase@12.18.0+40ac9e013e4b1dea/node_modules/firebase/functions/dist/index.mjs
|
|
197812
197894
|
var exports_dist3 = {};
|
|
197813
197895
|
__export(exports_dist3, {
|
|
197814
197896
|
FunctionsError: () => FunctionsError,
|
|
@@ -201665,18 +201747,25 @@ class Fleet {
|
|
|
201665
201747
|
const client2 = this.client(profile);
|
|
201666
201748
|
return operation(client2, publicAccount(record));
|
|
201667
201749
|
}
|
|
201750
|
+
failRecord(record, error) {
|
|
201751
|
+
const message = error?.message || String(error);
|
|
201752
|
+
record.error ||= message;
|
|
201753
|
+
record.status = "error";
|
|
201754
|
+
record.controller.abort(error);
|
|
201755
|
+
if (record.failureEmitted)
|
|
201756
|
+
return;
|
|
201757
|
+
record.failureEmitted = true;
|
|
201758
|
+
this.emit("account-error", {
|
|
201759
|
+
account: publicAccount(record),
|
|
201760
|
+
error: record.error
|
|
201761
|
+
});
|
|
201762
|
+
}
|
|
201668
201763
|
queuePolicies(record, event2) {
|
|
201669
201764
|
record.pendingEvents += 1;
|
|
201670
201765
|
if (record.pendingEvents > this.maxPendingEvents) {
|
|
201671
201766
|
record.pendingEvents -= 1;
|
|
201672
201767
|
const error = new Error(`fleet event backlog exceeded for ${record.profile.profile}`);
|
|
201673
|
-
record
|
|
201674
|
-
record.status = "error";
|
|
201675
|
-
record.controller.abort(error);
|
|
201676
|
-
this.emit("account-error", {
|
|
201677
|
-
account: publicAccount(record),
|
|
201678
|
-
error: error.message
|
|
201679
|
-
});
|
|
201768
|
+
this.failRecord(record, error);
|
|
201680
201769
|
return;
|
|
201681
201770
|
}
|
|
201682
201771
|
if (this.policyReloading) {
|
|
@@ -201725,69 +201814,64 @@ class Fleet {
|
|
|
201725
201814
|
unsubscribeRevoked: () => {},
|
|
201726
201815
|
startedPolicies: [],
|
|
201727
201816
|
reloadEvents: [],
|
|
201728
|
-
closed: false
|
|
201817
|
+
closed: false,
|
|
201818
|
+
failureEmitted: false
|
|
201729
201819
|
};
|
|
201730
201820
|
this.records.set(profile.profile, record);
|
|
201731
201821
|
this.emit("account-starting", { account: publicAccount(record) });
|
|
201732
|
-
|
|
201733
|
-
|
|
201734
|
-
|
|
201735
|
-
|
|
201736
|
-
|
|
201737
|
-
|
|
201738
|
-
|
|
201739
|
-
|
|
201740
|
-
|
|
201741
|
-
|
|
201742
|
-
|
|
201743
|
-
|
|
201744
|
-
|
|
201745
|
-
|
|
201746
|
-
}
|
|
201747
|
-
let readyResolve;
|
|
201748
|
-
let readyReject;
|
|
201749
|
-
const ready2 = new Promise((resolve2, reject) => {
|
|
201750
|
-
readyResolve = resolve2;
|
|
201751
|
-
readyReject = reject;
|
|
201752
|
-
});
|
|
201753
|
-
record.unsubscribeRevoked = record.client.subscribeSessionRevoked?.(() => {
|
|
201754
|
-
const error = new Error("account session revoked");
|
|
201755
|
-
record.error = error.message;
|
|
201756
|
-
record.status = "error";
|
|
201757
|
-
controller.abort(error);
|
|
201758
|
-
readyReject(error);
|
|
201759
|
-
this.emit("account-error", {
|
|
201760
|
-
account: publicAccount(record),
|
|
201761
|
-
error: error.message
|
|
201762
|
-
});
|
|
201763
|
-
}) || (() => {});
|
|
201764
|
-
const accountEventOptions = typeof this.eventOptions === "function" ? await this.eventOptions(profile) : this.eventOptions;
|
|
201765
|
-
record.listenTask = record.client.listen({
|
|
201766
|
-
...accountEventOptions || {},
|
|
201767
|
-
signal: controller.signal,
|
|
201768
|
-
onEvent: (event2) => {
|
|
201769
|
-
if (event2?.type === "ready")
|
|
201770
|
-
readyResolve();
|
|
201771
|
-
this.emit("account-event", {
|
|
201772
|
-
account: publicAccount(record),
|
|
201773
|
-
event: event2
|
|
201822
|
+
try {
|
|
201823
|
+
const baseOptions = typeof this.clientOptions === "function" ? await this.clientOptions(profile) : this.clientOptions;
|
|
201824
|
+
record.client = await this.openClient({
|
|
201825
|
+
...baseOptions || {},
|
|
201826
|
+
profile: profile.profile,
|
|
201827
|
+
...profile.network ? { network: profile.network } : {}
|
|
201828
|
+
}, profile);
|
|
201829
|
+
await record.client.ensureUnlocked();
|
|
201830
|
+
for (const policy of this.policies) {
|
|
201831
|
+
record.startedPolicies.push(policy);
|
|
201832
|
+
await policy.start?.({
|
|
201833
|
+
account: profile,
|
|
201834
|
+
client: record.client,
|
|
201835
|
+
fleet: this
|
|
201774
201836
|
});
|
|
201775
|
-
this.queuePolicies(record, event2);
|
|
201776
201837
|
}
|
|
201777
|
-
|
|
201778
|
-
|
|
201779
|
-
|
|
201780
|
-
|
|
201781
|
-
|
|
201782
|
-
|
|
201783
|
-
|
|
201784
|
-
account
|
|
201785
|
-
|
|
201838
|
+
let readyResolve;
|
|
201839
|
+
let readyReject;
|
|
201840
|
+
const ready2 = new Promise((resolve2, reject) => {
|
|
201841
|
+
readyResolve = resolve2;
|
|
201842
|
+
readyReject = reject;
|
|
201843
|
+
});
|
|
201844
|
+
record.unsubscribeRevoked = record.client.subscribeSessionRevoked?.(() => {
|
|
201845
|
+
const error = new Error("account session revoked");
|
|
201846
|
+
this.failRecord(record, error);
|
|
201847
|
+
readyReject(error);
|
|
201848
|
+
}) || (() => {});
|
|
201849
|
+
const accountEventOptions = typeof this.eventOptions === "function" ? await this.eventOptions(profile) : this.eventOptions;
|
|
201850
|
+
record.listenTask = record.client.listen({
|
|
201851
|
+
...accountEventOptions || {},
|
|
201852
|
+
signal: controller.signal,
|
|
201853
|
+
onEvent: (event2) => {
|
|
201854
|
+
if (event2?.type === "ready")
|
|
201855
|
+
readyResolve();
|
|
201856
|
+
this.emit("account-event", {
|
|
201857
|
+
account: publicAccount(record),
|
|
201858
|
+
event: event2
|
|
201859
|
+
});
|
|
201860
|
+
this.queuePolicies(record, event2);
|
|
201861
|
+
}
|
|
201862
|
+
}).catch((error) => {
|
|
201863
|
+
if (controller.signal.aborted)
|
|
201864
|
+
return;
|
|
201865
|
+
this.failRecord(record, error);
|
|
201866
|
+
readyReject(error);
|
|
201786
201867
|
});
|
|
201787
|
-
|
|
201788
|
-
|
|
201789
|
-
|
|
201790
|
-
|
|
201868
|
+
await waitFor3(ready2, this.startTimeoutMs, `fleet profile start timed out: ${profile.profile}`);
|
|
201869
|
+
record.status = "ready";
|
|
201870
|
+
this.emit("account-ready", { account: publicAccount(record) });
|
|
201871
|
+
} catch (error) {
|
|
201872
|
+
this.failRecord(record, error);
|
|
201873
|
+
throw error;
|
|
201874
|
+
}
|
|
201791
201875
|
}
|
|
201792
201876
|
async stopRecordPolicies(record) {
|
|
201793
201877
|
const errors = [];
|
|
@@ -201999,10 +202083,13 @@ class Fleet {
|
|
|
201999
202083
|
}
|
|
202000
202084
|
};
|
|
202001
202085
|
record.controller.abort();
|
|
202002
|
-
await attempt(() => record.listenTask);
|
|
202003
|
-
errors.push(...await this.stopRecordPolicies(record));
|
|
202004
202086
|
await attempt(() => record.unsubscribeRevoked());
|
|
202005
|
-
await
|
|
202087
|
+
errors.push(...await this.stopRecordPolicies(record));
|
|
202088
|
+
const closeTask = Promise.resolve().then(() => record.client?.close());
|
|
202089
|
+
await Promise.all([
|
|
202090
|
+
attempt(() => record.listenTask),
|
|
202091
|
+
attempt(() => closeTask)
|
|
202092
|
+
]);
|
|
202006
202093
|
record.closed = true;
|
|
202007
202094
|
record.status = errors.length || record.error ? "error" : "stopped";
|
|
202008
202095
|
if (errors.length) {
|