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.cjs
CHANGED
|
@@ -4041,6 +4041,16 @@ async function createDecaneConnect(config) {
|
|
|
4041
4041
|
const candidates = (await storage.listShares()).map(usablePasskeyShare).filter(Boolean);
|
|
4042
4042
|
return candidates.length === 1 ? candidates[0] : null;
|
|
4043
4043
|
}
|
|
4044
|
+
async function rememberProfile(userId, profile) {
|
|
4045
|
+
const incoming = Object.fromEntries(Object.entries(profile).filter(([, v]) => v));
|
|
4046
|
+
if (!Object.keys(incoming).length) return;
|
|
4047
|
+
try {
|
|
4048
|
+
const stored = await storage.getShare(userId);
|
|
4049
|
+
if (!stored) return;
|
|
4050
|
+
await storage.putShare({ ...stored, profile: { ...stored.profile, ...incoming } });
|
|
4051
|
+
} catch {
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4044
4054
|
function usablePasskeyShare(stored) {
|
|
4045
4055
|
if (!stored || stored.unlockMethod !== "passkey") return null;
|
|
4046
4056
|
if (!stored.credentialId || !stored.prfSalt) return null;
|
|
@@ -4078,7 +4088,11 @@ async function createDecaneConnect(config) {
|
|
|
4078
4088
|
savePersisted(PERSIST_KEY, persisted);
|
|
4079
4089
|
events.emit("connected");
|
|
4080
4090
|
persistLiveSession();
|
|
4081
|
-
return {
|
|
4091
|
+
return {
|
|
4092
|
+
addresses,
|
|
4093
|
+
isNewUser: false,
|
|
4094
|
+
...stored.profile ? { profile: stored.profile } : {}
|
|
4095
|
+
};
|
|
4082
4096
|
}
|
|
4083
4097
|
async function handleAuthResult(result) {
|
|
4084
4098
|
let addresses;
|
|
@@ -4094,6 +4108,7 @@ async function createDecaneConnect(config) {
|
|
|
4094
4108
|
savePersisted(PERSIST_KEY, persisted);
|
|
4095
4109
|
events.emit("connected");
|
|
4096
4110
|
persistLiveSession();
|
|
4111
|
+
if (result.profile) await rememberProfile(result.userId, result.profile);
|
|
4097
4112
|
return {
|
|
4098
4113
|
addresses,
|
|
4099
4114
|
isNewUser: result.isNewUser,
|
|
@@ -7300,6 +7315,11 @@ function useSocialAuth() {
|
|
|
7300
7315
|
sessionExpiresAt: socialAuth.sessionExpiresAt,
|
|
7301
7316
|
// True when this device can skip the full sign-in and resume with a passkey.
|
|
7302
7317
|
canUsePasskey: socialAuth.canUsePasskey,
|
|
7318
|
+
// Who the provider said the user is — { name?, email?, picture? }, or null.
|
|
7319
|
+
// A passkey sign-in returns the profile recorded on this device when the
|
|
7320
|
+
// user first signed in, so it carries the same name and email a Google
|
|
7321
|
+
// sign-in does rather than coming back anonymous.
|
|
7322
|
+
profile: socialAuth.profile,
|
|
7303
7323
|
// Long-running work in progress, for driving your own status UI.
|
|
7304
7324
|
phase: socialAuth.phase,
|
|
7305
7325
|
isCreatingWallet: socialAuth.phase === "creating",
|