@proveanything/smartlinks-auth-ui 0.5.7 → 0.5.9
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/components/AccountManagement.d.ts.map +1 -1
- package/dist/context/AuthContext.d.ts.map +1 -1
- package/dist/index.esm.js +67 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +67 -4
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +19 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountManagement.d.ts","sourceRoot":"","sources":["../../src/components/AccountManagement.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAOhE,OAAO,KAAK,EAAE,sBAAsB,EAAe,MAAM,UAAU,CAAC;AACpE,OAAO,qBAAqB,CAAC;AAK7B,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"AccountManagement.d.ts","sourceRoot":"","sources":["../../src/components/AccountManagement.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAOhE,OAAO,KAAK,EAAE,sBAAsB,EAAe,MAAM,UAAU,CAAC;AACpE,OAAO,qBAAqB,CAAC;AAK7B,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAgzB9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAOnG,OAAO,KAAK,EAAqC,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGvG,eAAO,MAAM,WAAW,6CAAyD,CAAC;AAGlF,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAOnG,OAAO,KAAK,EAAqC,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGvG,eAAO,MAAM,WAAW,6CAAyD,CAAC;AAGlF,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAw4BpD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,gBAM1B,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -12696,6 +12696,44 @@ collectionId, enableContactSync, enableInteractionTracking, interactionAppId, in
|
|
|
12696
12696
|
}
|
|
12697
12697
|
}
|
|
12698
12698
|
}, [token, user, isVerified, accountData, accountInfo, contact, contactId, notifyAuthStateChange, isNetworkError, logout]);
|
|
12699
|
+
// Apply a session refresh from SDK calls that rotate the bearer token
|
|
12700
|
+
// (e.g. authKit.updateProfile returns { token, ...profile }). Without this
|
|
12701
|
+
// the persisted token still decodes to the OLD claims, so a page refresh
|
|
12702
|
+
// would resurrect stale displayName / email / phone values.
|
|
12703
|
+
const applySessionRefresh = useCallback(async (payload) => {
|
|
12704
|
+
const nextToken = payload.token;
|
|
12705
|
+
const nextUser = user
|
|
12706
|
+
? { ...user, ...(payload.user || {}) }
|
|
12707
|
+
: (payload.user && payload.user.uid ? payload.user : null);
|
|
12708
|
+
const nextAccountData = payload.accountData ?? accountData;
|
|
12709
|
+
if (nextToken && !proxyMode) {
|
|
12710
|
+
// Match the 7-day lifetime used by login()/refreshToken() — backend mints fresh JWTs with the same TTL.
|
|
12711
|
+
await tokenStorage.saveToken(nextToken, Date.now() + 7 * 24 * 60 * 60 * 1000);
|
|
12712
|
+
if (nextUser)
|
|
12713
|
+
await tokenStorage.saveUser(nextUser);
|
|
12714
|
+
if (payload.accountData)
|
|
12715
|
+
await tokenStorage.saveAccountData(payload.accountData);
|
|
12716
|
+
}
|
|
12717
|
+
if (nextToken)
|
|
12718
|
+
setToken(nextToken);
|
|
12719
|
+
if (nextUser)
|
|
12720
|
+
setUser(nextUser);
|
|
12721
|
+
if (payload.accountData)
|
|
12722
|
+
setAccountData(nextAccountData);
|
|
12723
|
+
// Refresh contact too — the backend's account/contact unification means
|
|
12724
|
+
// the contact record may now reflect the new displayName/email/phone.
|
|
12725
|
+
if (collectionId && shouldSyncContacts) {
|
|
12726
|
+
try {
|
|
12727
|
+
const fresh = await smartlinks.contact.publicGetMine(collectionId);
|
|
12728
|
+
if (fresh?.contact)
|
|
12729
|
+
setContact(fresh.contact);
|
|
12730
|
+
}
|
|
12731
|
+
catch {
|
|
12732
|
+
// Non-fatal
|
|
12733
|
+
}
|
|
12734
|
+
}
|
|
12735
|
+
notifyAuthStateChange('TOKEN_REFRESH', nextUser, nextToken ?? token, nextAccountData, accountInfo, isVerified, contact, contactId);
|
|
12736
|
+
}, [proxyMode, user, accountData, accountInfo, isVerified, contact, contactId, collectionId, shouldSyncContacts, token, notifyAuthStateChange]);
|
|
12699
12737
|
// Online/offline event listener for auto-retry verification
|
|
12700
12738
|
useEffect(() => {
|
|
12701
12739
|
if (proxyMode)
|
|
@@ -12773,6 +12811,7 @@ collectionId, enableContactSync, enableInteractionTracking, interactionAppId, in
|
|
|
12773
12811
|
clearAccountCache,
|
|
12774
12812
|
onAuthStateChange,
|
|
12775
12813
|
retryVerification,
|
|
12814
|
+
applySessionRefresh,
|
|
12776
12815
|
};
|
|
12777
12816
|
return jsx(AuthContext.Provider, { value: value, children: children });
|
|
12778
12817
|
};
|
|
@@ -14807,11 +14846,26 @@ const AccountManagement = ({ apiEndpoint, clientId, collectionId, onError, class
|
|
|
14807
14846
|
setError(undefined);
|
|
14808
14847
|
setSuccess(undefined);
|
|
14809
14848
|
try {
|
|
14810
|
-
|
|
14849
|
+
// SDK 1.13.17+: updateProfile returns a fresh bearer token with refreshed
|
|
14850
|
+
// claims (displayName/photoURL). We MUST persist the new token, otherwise
|
|
14851
|
+
// a page refresh would decode the old token and resurrect stale values.
|
|
14852
|
+
// Cast: older @proveanything/smartlinks type defs typed this as UserProfile
|
|
14853
|
+
// (no `token`). The runtime always returns the rotated token in 1.13.17+.
|
|
14854
|
+
const updated = await smartlinks.authKit.updateProfile(resolvedClientId, { displayName });
|
|
14855
|
+
await auth.applySessionRefresh({
|
|
14856
|
+
token: updated.token,
|
|
14857
|
+
user: {
|
|
14858
|
+
displayName: updated.displayName ?? displayName,
|
|
14859
|
+
email: updated.email,
|
|
14860
|
+
phoneNumber: updated.phoneNumber ?? undefined,
|
|
14861
|
+
photoURL: updated.photoURL ?? undefined,
|
|
14862
|
+
},
|
|
14863
|
+
accountData: updated.accountData,
|
|
14864
|
+
});
|
|
14811
14865
|
setSuccess('Profile updated successfully!');
|
|
14812
14866
|
setEditingSection(null);
|
|
14813
14867
|
if (profile) {
|
|
14814
|
-
setProfile({ ...profile, displayName });
|
|
14868
|
+
setProfile({ ...profile, displayName: updated.displayName ?? displayName });
|
|
14815
14869
|
}
|
|
14816
14870
|
}
|
|
14817
14871
|
catch (err) {
|
|
@@ -14855,7 +14909,11 @@ const AccountManagement = ({ apiEndpoint, clientId, collectionId, onError, class
|
|
|
14855
14909
|
setSuccess(undefined);
|
|
14856
14910
|
try {
|
|
14857
14911
|
const redirectUrl = window.location.href;
|
|
14858
|
-
await smartlinks.authKit.changeEmail(resolvedClientId, newEmail, emailPassword, redirectUrl);
|
|
14912
|
+
const res = await smartlinks.authKit.changeEmail(resolvedClientId, newEmail, emailPassword, redirectUrl);
|
|
14913
|
+
// SDK may rotate bearer token on email change — persist if present.
|
|
14914
|
+
if (res?.token) {
|
|
14915
|
+
await auth.applySessionRefresh({ token: res.token });
|
|
14916
|
+
}
|
|
14859
14917
|
setSuccess('Email change requested. Please check your new email for verification.');
|
|
14860
14918
|
setEditingSection(null);
|
|
14861
14919
|
setNewEmail('');
|
|
@@ -14932,7 +14990,12 @@ const AccountManagement = ({ apiEndpoint, clientId, collectionId, onError, class
|
|
|
14932
14990
|
setError(undefined);
|
|
14933
14991
|
setSuccess(undefined);
|
|
14934
14992
|
try {
|
|
14935
|
-
await smartlinks.authKit.updatePhone(resolvedClientId, newPhone, phoneCode);
|
|
14993
|
+
const res = await smartlinks.authKit.updatePhone(resolvedClientId, newPhone, phoneCode);
|
|
14994
|
+
// Phone change rotates the bearer token (phoneNumber is a JWT claim).
|
|
14995
|
+
await auth.applySessionRefresh({
|
|
14996
|
+
token: res?.token,
|
|
14997
|
+
user: { phoneNumber: newPhone },
|
|
14998
|
+
});
|
|
14936
14999
|
setSuccess('Phone number updated successfully!');
|
|
14937
15000
|
setEditingSection(null);
|
|
14938
15001
|
setNewPhone('');
|