decane-connect-kit 2.10.0 → 2.11.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/index.cjs +21 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1126,9 +1126,14 @@ interface SocialAuthState {
|
|
|
1126
1126
|
* Who the provider said the user is — `{ name?, email?, picture? }`.
|
|
1127
1127
|
*
|
|
1128
1128
|
* `null` until a sign-in returns one, and stays null for email sign-in and
|
|
1129
|
-
* for providers the user withheld a profile from.
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1129
|
+
* for providers the user withheld a profile from.
|
|
1130
|
+
*
|
|
1131
|
+
* The backend stores no profile, so this cannot be re-fetched — but whatever
|
|
1132
|
+
* a sign-in does reveal is kept beside this device's share, and a passkey
|
|
1133
|
+
* login hands it back. A passkey sign-in therefore carries the same name and
|
|
1134
|
+
* email the original Google sign-in did. A session merely restored from a
|
|
1135
|
+
* reload still has an address and no name, so copy it somewhere durable if
|
|
1136
|
+
* you need it in that state.
|
|
1132
1137
|
*/
|
|
1133
1138
|
profile: AuthProfile | null;
|
|
1134
1139
|
isUnlocked: boolean;
|
|
@@ -1222,6 +1227,7 @@ declare function useSocialAuth(): {
|
|
|
1222
1227
|
} | null;
|
|
1223
1228
|
sessionExpiresAt: number | null;
|
|
1224
1229
|
canUsePasskey: boolean;
|
|
1230
|
+
profile: AuthProfile | null;
|
|
1225
1231
|
phase: "creating" | "unlocking" | null;
|
|
1226
1232
|
isCreatingWallet: boolean;
|
|
1227
1233
|
needsReconnect: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1126,9 +1126,14 @@ interface SocialAuthState {
|
|
|
1126
1126
|
* Who the provider said the user is — `{ name?, email?, picture? }`.
|
|
1127
1127
|
*
|
|
1128
1128
|
* `null` until a sign-in returns one, and stays null for email sign-in and
|
|
1129
|
-
* for providers the user withheld a profile from.
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1129
|
+
* for providers the user withheld a profile from.
|
|
1130
|
+
*
|
|
1131
|
+
* The backend stores no profile, so this cannot be re-fetched — but whatever
|
|
1132
|
+
* a sign-in does reveal is kept beside this device's share, and a passkey
|
|
1133
|
+
* login hands it back. A passkey sign-in therefore carries the same name and
|
|
1134
|
+
* email the original Google sign-in did. A session merely restored from a
|
|
1135
|
+
* reload still has an address and no name, so copy it somewhere durable if
|
|
1136
|
+
* you need it in that state.
|
|
1132
1137
|
*/
|
|
1133
1138
|
profile: AuthProfile | null;
|
|
1134
1139
|
isUnlocked: boolean;
|
|
@@ -1222,6 +1227,7 @@ declare function useSocialAuth(): {
|
|
|
1222
1227
|
} | null;
|
|
1223
1228
|
sessionExpiresAt: number | null;
|
|
1224
1229
|
canUsePasskey: boolean;
|
|
1230
|
+
profile: AuthProfile | null;
|
|
1225
1231
|
phase: "creating" | "unlocking" | null;
|
|
1226
1232
|
isCreatingWallet: boolean;
|
|
1227
1233
|
needsReconnect: boolean;
|
package/dist/index.js
CHANGED
|
@@ -3965,6 +3965,16 @@ async function createDecaneConnect(config) {
|
|
|
3965
3965
|
const candidates = (await storage.listShares()).map(usablePasskeyShare).filter(Boolean);
|
|
3966
3966
|
return candidates.length === 1 ? candidates[0] : null;
|
|
3967
3967
|
}
|
|
3968
|
+
async function rememberProfile(userId, profile) {
|
|
3969
|
+
const incoming = Object.fromEntries(Object.entries(profile).filter(([, v]) => v));
|
|
3970
|
+
if (!Object.keys(incoming).length) return;
|
|
3971
|
+
try {
|
|
3972
|
+
const stored = await storage.getShare(userId);
|
|
3973
|
+
if (!stored) return;
|
|
3974
|
+
await storage.putShare({ ...stored, profile: { ...stored.profile, ...incoming } });
|
|
3975
|
+
} catch {
|
|
3976
|
+
}
|
|
3977
|
+
}
|
|
3968
3978
|
function usablePasskeyShare(stored) {
|
|
3969
3979
|
if (!stored || stored.unlockMethod !== "passkey") return null;
|
|
3970
3980
|
if (!stored.credentialId || !stored.prfSalt) return null;
|
|
@@ -4002,7 +4012,11 @@ async function createDecaneConnect(config) {
|
|
|
4002
4012
|
savePersisted(PERSIST_KEY, persisted);
|
|
4003
4013
|
events.emit("connected");
|
|
4004
4014
|
persistLiveSession();
|
|
4005
|
-
return {
|
|
4015
|
+
return {
|
|
4016
|
+
addresses,
|
|
4017
|
+
isNewUser: false,
|
|
4018
|
+
...stored.profile ? { profile: stored.profile } : {}
|
|
4019
|
+
};
|
|
4006
4020
|
}
|
|
4007
4021
|
async function handleAuthResult(result) {
|
|
4008
4022
|
let addresses;
|
|
@@ -4018,6 +4032,7 @@ async function createDecaneConnect(config) {
|
|
|
4018
4032
|
savePersisted(PERSIST_KEY, persisted);
|
|
4019
4033
|
events.emit("connected");
|
|
4020
4034
|
persistLiveSession();
|
|
4035
|
+
if (result.profile) await rememberProfile(result.userId, result.profile);
|
|
4021
4036
|
return {
|
|
4022
4037
|
addresses,
|
|
4023
4038
|
isNewUser: result.isNewUser,
|
|
@@ -7231,6 +7246,11 @@ function useSocialAuth() {
|
|
|
7231
7246
|
sessionExpiresAt: socialAuth.sessionExpiresAt,
|
|
7232
7247
|
// True when this device can skip the full sign-in and resume with a passkey.
|
|
7233
7248
|
canUsePasskey: socialAuth.canUsePasskey,
|
|
7249
|
+
// Who the provider said the user is — { name?, email?, picture? }, or null.
|
|
7250
|
+
// A passkey sign-in returns the profile recorded on this device when the
|
|
7251
|
+
// user first signed in, so it carries the same name and email a Google
|
|
7252
|
+
// sign-in does rather than coming back anonymous.
|
|
7253
|
+
profile: socialAuth.profile,
|
|
7234
7254
|
// Long-running work in progress, for driving your own status UI.
|
|
7235
7255
|
phase: socialAuth.phase,
|
|
7236
7256
|
isCreatingWallet: socialAuth.phase === "creating",
|