@hipnation-truth/sdk 0.26.1 → 0.26.2
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 +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +9 -0
- package/dist/react.js +25 -0
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1651,12 +1651,21 @@ declare class TruthClient {
|
|
|
1651
1651
|
readonly userSettings: UserSettingsResource;
|
|
1652
1652
|
private readonly convex;
|
|
1653
1653
|
private readonly tracker;
|
|
1654
|
+
private readonly _getAuthToken?;
|
|
1654
1655
|
private _vapidPublicKey;
|
|
1655
1656
|
private _webPushReady;
|
|
1656
1657
|
private readonly _serviceWorkerPath;
|
|
1657
1658
|
constructor(config: TruthClientConfig);
|
|
1658
1659
|
get vapidPublicKey(): string | null;
|
|
1659
1660
|
get webPushReady(): Promise<void> | null;
|
|
1661
|
+
/**
|
|
1662
|
+
* When a Clerk token fetcher is configured (publishable-key clients),
|
|
1663
|
+
* the VAPID endpoint is auth-gated — calling it before the session has
|
|
1664
|
+
* hydrated 401s and strands web-push in the "no key" path. Wait
|
|
1665
|
+
* (briefly, bounded) for a token to become available first. No fetcher
|
|
1666
|
+
* → resolve immediately (secret-key path is unaffected).
|
|
1667
|
+
*/
|
|
1668
|
+
private waitForAuthToken;
|
|
1660
1669
|
private initWebPush;
|
|
1661
1670
|
/**
|
|
1662
1671
|
* The resolved Truth API base URL for this environment.
|
package/dist/index.d.ts
CHANGED
|
@@ -1651,12 +1651,21 @@ declare class TruthClient {
|
|
|
1651
1651
|
readonly userSettings: UserSettingsResource;
|
|
1652
1652
|
private readonly convex;
|
|
1653
1653
|
private readonly tracker;
|
|
1654
|
+
private readonly _getAuthToken?;
|
|
1654
1655
|
private _vapidPublicKey;
|
|
1655
1656
|
private _webPushReady;
|
|
1656
1657
|
private readonly _serviceWorkerPath;
|
|
1657
1658
|
constructor(config: TruthClientConfig);
|
|
1658
1659
|
get vapidPublicKey(): string | null;
|
|
1659
1660
|
get webPushReady(): Promise<void> | null;
|
|
1661
|
+
/**
|
|
1662
|
+
* When a Clerk token fetcher is configured (publishable-key clients),
|
|
1663
|
+
* the VAPID endpoint is auth-gated — calling it before the session has
|
|
1664
|
+
* hydrated 401s and strands web-push in the "no key" path. Wait
|
|
1665
|
+
* (briefly, bounded) for a token to become available first. No fetcher
|
|
1666
|
+
* → resolve immediately (secret-key path is unaffected).
|
|
1667
|
+
*/
|
|
1668
|
+
private waitForAuthToken;
|
|
1660
1669
|
private initWebPush;
|
|
1661
1670
|
/**
|
|
1662
1671
|
* The resolved Truth API base URL for this environment.
|
package/dist/index.js
CHANGED
|
@@ -1982,6 +1982,7 @@ var TruthClient = class {
|
|
|
1982
1982
|
config.getAuthToken
|
|
1983
1983
|
);
|
|
1984
1984
|
this.userSettings = new UserSettingsResource(this.convex);
|
|
1985
|
+
this._getAuthToken = config.getAuthToken;
|
|
1985
1986
|
this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
|
|
1986
1987
|
if (typeof window !== "undefined" && isWebPushSupported() && config.autoInitServiceWorker !== false) {
|
|
1987
1988
|
this._webPushReady = this.initWebPush();
|
|
@@ -1993,9 +1994,33 @@ var TruthClient = class {
|
|
|
1993
1994
|
get webPushReady() {
|
|
1994
1995
|
return this._webPushReady;
|
|
1995
1996
|
}
|
|
1997
|
+
/**
|
|
1998
|
+
* When a Clerk token fetcher is configured (publishable-key clients),
|
|
1999
|
+
* the VAPID endpoint is auth-gated — calling it before the session has
|
|
2000
|
+
* hydrated 401s and strands web-push in the "no key" path. Wait
|
|
2001
|
+
* (briefly, bounded) for a token to become available first. No fetcher
|
|
2002
|
+
* → resolve immediately (secret-key path is unaffected).
|
|
2003
|
+
*/
|
|
2004
|
+
waitForAuthToken() {
|
|
2005
|
+
return __async(this, null, function* () {
|
|
2006
|
+
if (!this._getAuthToken) {
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
2010
|
+
try {
|
|
2011
|
+
if (yield this._getAuthToken()) {
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
} catch (e) {
|
|
2015
|
+
}
|
|
2016
|
+
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
2017
|
+
}
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
1996
2020
|
initWebPush() {
|
|
1997
2021
|
return __async(this, null, function* () {
|
|
1998
2022
|
try {
|
|
2023
|
+
yield this.waitForAuthToken();
|
|
1999
2024
|
const key = yield this.notifications.getVapidKey();
|
|
2000
2025
|
if (!key) {
|
|
2001
2026
|
return;
|