@voltro/plugin-auth-social 0.89.2 → 0.91.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/CHANGELOG.md +1943 -0
- package/README.md +4 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/accountMerge.js +149 -0
- package/dist/guestHandoff.js +12 -12
- package/dist/guestUpgrade.js +26 -26
- package/dist/identityStore.js +27 -18
- package/dist/index.d.ts +164 -5
- package/dist/index.js +18 -16
- package/dist/platformServices.js +80 -0
- package/dist/plugin.js +661 -392
- package/dist/providers.js +2 -2
- package/dist/signIn.js +16 -16
- package/dist/steam.js +49 -49
- package/dist/web/guestUpgradeClient.js +63 -38
- package/dist/web/linksClient.js +74 -0
- package/dist/web.d.ts +64 -4
- package/dist/web.js +3 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -25,6 +25,10 @@ Opt-in same-ID guest promotion, signed browser confirmation and the durable
|
|
|
25
25
|
transaction/installed-port contract, confirmed device proof and recovery limits.
|
|
26
26
|
Existing-account conflicts require a separately confirmed merge.
|
|
27
27
|
|
|
28
|
+
Sign in with Steam in the browser (`steam` option, OpenID with hot-store replay protection) and
|
|
29
|
+
`PlatformServicesPort` for platform achievements and rich presence (`devPlatformServices`,
|
|
30
|
+
`steamPlatformServices`) are built.
|
|
31
|
+
|
|
28
32
|
## License
|
|
29
33
|
|
|
30
34
|
Proprietary. © 2026 Voltro UG. Your use is governed by the
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { ACCOUNT_MERGE_TABLE as e, dataStoreSocialIdentityStore as t } from "./identityStore.js";
|
|
2
|
+
import { transactionSessionStore as n } from "./guestUpgrade.js";
|
|
3
|
+
import { Effect as r, Result as i } from "effect";
|
|
4
|
+
import { and as a, classifyConstraintViolation as o, eq as s, extractDbCause as c, generateId as l } from "@voltro/database";
|
|
5
|
+
import { GuestAuthError as u, dataStoreGuestAuth as d, issueUserSession as f } from "@voltro/plugin-auth";
|
|
6
|
+
// src/accountMerge.ts
|
|
7
|
+
var p = /^[A-Za-z0-9_-]{1,128}$/, m = (e, t) => ({
|
|
8
|
+
table: e,
|
|
9
|
+
predicate: t,
|
|
10
|
+
order: [],
|
|
11
|
+
take: void 0,
|
|
12
|
+
skip: void 0,
|
|
13
|
+
projection: void 0
|
|
14
|
+
}), h = (e, t, n) => ({
|
|
15
|
+
kind: "refused",
|
|
16
|
+
status: e,
|
|
17
|
+
code: t,
|
|
18
|
+
message: n
|
|
19
|
+
}), g = class extends Error {
|
|
20
|
+
result;
|
|
21
|
+
constructor(e) {
|
|
22
|
+
super(e.code), this.result = e;
|
|
23
|
+
}
|
|
24
|
+
}, _ = (e) => ({
|
|
25
|
+
id: String(e.id),
|
|
26
|
+
tenantId: String(e.tenantId),
|
|
27
|
+
email: typeof e.email == "string" ? e.email : null,
|
|
28
|
+
passwordHash: typeof e.passwordHash == "string" ? e.passwordHash : null,
|
|
29
|
+
createdAt: e.createdAt instanceof Date ? e.createdAt : new Date(String(e.createdAt)),
|
|
30
|
+
mfaSecret: typeof e.mfaSecret == "string" ? e.mfaSecret : null,
|
|
31
|
+
mfaEnrolledAt: e.mfaEnrolledAt instanceof Date ? e.mfaEnrolledAt : null,
|
|
32
|
+
emailVerifiedAt: e.emailVerifiedAt instanceof Date ? e.emailVerifiedAt : null
|
|
33
|
+
}), v = (e, n) => r.gen(function* () {
|
|
34
|
+
let i = yield* t(e).findByProviderAccount(n.provider, n.providerAccountId);
|
|
35
|
+
if (i !== null) return {
|
|
36
|
+
kind: "provider",
|
|
37
|
+
targetId: i.userId
|
|
38
|
+
};
|
|
39
|
+
let a = n.email === null || n.email.length === 0 ? null : n.email;
|
|
40
|
+
return a !== null && (yield* r.promise(() => e.query(m("users", s("email", a))))).length !== 0 ? { kind: "email" } : { kind: "none" };
|
|
41
|
+
}), y = (v) => r.gen(function* () {
|
|
42
|
+
let y = v.guest.tenantId;
|
|
43
|
+
if (v.config.defaultTenantId !== y) return h(500, "config", "Account merge requires a matching tenant.");
|
|
44
|
+
if (!p.test(v.requestId)) return h(400, "invalid_input", "A merge needs a request ID.");
|
|
45
|
+
if (v.registry === void 0) return h(409, "account_merge_unavailable", "This app cannot merge accounts.");
|
|
46
|
+
let b = v.profile, x = yield* t(v.store).findByProviderAccount(b.provider, b.providerAccountId);
|
|
47
|
+
if (x === null) return h(409, "account_merge_unavailable", "Sign in to that account first; its address alone cannot confirm it.");
|
|
48
|
+
let S = x.userId, C = (e, t) => r.runPromise(f(_(t), n(e, v.users, y), v.config, {
|
|
49
|
+
clearLoginFailures: !1,
|
|
50
|
+
ipAddress: v.ipAddress ?? null,
|
|
51
|
+
userAgent: v.userAgent ?? null
|
|
52
|
+
})), w = (e, t, n, r) => ({
|
|
53
|
+
kind: "ok",
|
|
54
|
+
userId: S,
|
|
55
|
+
subject: e.subject,
|
|
56
|
+
setCookie: e.setCookie,
|
|
57
|
+
session: {
|
|
58
|
+
value: e.value,
|
|
59
|
+
expiresAt: e.expiresAt
|
|
60
|
+
},
|
|
61
|
+
created: !1,
|
|
62
|
+
linked: !0,
|
|
63
|
+
oneTimeName: null,
|
|
64
|
+
merged: {
|
|
65
|
+
requestId: v.requestId,
|
|
66
|
+
sourceId: t,
|
|
67
|
+
targetId: S,
|
|
68
|
+
participants: n,
|
|
69
|
+
replayed: r,
|
|
70
|
+
residueErased: !1
|
|
71
|
+
}
|
|
72
|
+
}), T = async (t) => {
|
|
73
|
+
if (t.kind !== "ok") return t;
|
|
74
|
+
let n = a(s("tenantId", y), s("requestId", v.requestId)), o = (await v.store.query(m(e, n)))[0];
|
|
75
|
+
if (o?.residueErasedAt !== null && o?.residueErasedAt !== void 0) return {
|
|
76
|
+
...t,
|
|
77
|
+
merged: {
|
|
78
|
+
...t.merged,
|
|
79
|
+
residueErased: !0
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
if (v.privacy === void 0) return t;
|
|
83
|
+
let c = await r.runPromise(r.result(v.privacy.eraseSubject({
|
|
84
|
+
requestId: "merge-" + v.requestId,
|
|
85
|
+
target: {
|
|
86
|
+
tenantId: y,
|
|
87
|
+
subjectId: t.merged.sourceId,
|
|
88
|
+
kind: "guest"
|
|
89
|
+
}
|
|
90
|
+
})));
|
|
91
|
+
return i.isFailure(c) || o === void 0 ? t : (await v.store.update(e, String(o.id), { residueErasedAt: /* @__PURE__ */ new Date() }), {
|
|
92
|
+
...t,
|
|
93
|
+
merged: {
|
|
94
|
+
...t.merged,
|
|
95
|
+
residueErased: !0
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}, E;
|
|
99
|
+
return yield* r.tryPromise({
|
|
100
|
+
try: async () => {
|
|
101
|
+
let t = (await v.store.query(m(e, a(s("tenantId", y), s("requestId", v.requestId)))))[0];
|
|
102
|
+
if (t !== void 0) {
|
|
103
|
+
if (t.sourceId !== v.guestId || t.targetId !== S || t.tenantId !== y) throw new g(h(409, "merge_request_reused", "This request ID belongs to another merge."));
|
|
104
|
+
return await v.store.transactional(async (e) => {
|
|
105
|
+
let n = (await e.query(m("users", a(s("id", S), s("tenantId", y)))))[0];
|
|
106
|
+
if (!n || n.deactivatedAt !== null && n.deactivatedAt !== void 0) throw new g(h(403, "credential_rejected", "The account is not available."));
|
|
107
|
+
return w(await C(e, n), v.guestId, JSON.parse(String(t.participants)), !0);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
let n = v.registry.coverage("guest");
|
|
111
|
+
if (n.missing.length > 0) throw new g(h(409, "merge_coverage_missing", "Not every part of this app can merge accounts yet: " + n.missing.join(", ")));
|
|
112
|
+
let f = v.service ?? d(v.store, v.guest);
|
|
113
|
+
return await r.runPromise(f.mergeInto(v.credential, S, async (t) => {
|
|
114
|
+
if (t.subjectId !== v.guestId || t.tenantId !== y) throw new u({ code: "credential_rejected" });
|
|
115
|
+
let n = t.store, d = await r.runPromise(r.result(v.registry.mergeInTransaction({
|
|
116
|
+
requestId: v.requestId,
|
|
117
|
+
tenantId: y,
|
|
118
|
+
sourceId: t.subjectId,
|
|
119
|
+
sourceKind: "guest",
|
|
120
|
+
targetId: S,
|
|
121
|
+
store: n
|
|
122
|
+
})));
|
|
123
|
+
if (i.isFailure(d)) throw E = d.failure, new u({ code: "store_unavailable" });
|
|
124
|
+
let f = d.success;
|
|
125
|
+
try {
|
|
126
|
+
await n.insert(e, {
|
|
127
|
+
id: l({
|
|
128
|
+
kind: "typeid",
|
|
129
|
+
prefix: "amerge"
|
|
130
|
+
}, "amerge"),
|
|
131
|
+
tenantId: y,
|
|
132
|
+
requestId: v.requestId,
|
|
133
|
+
sourceId: t.subjectId,
|
|
134
|
+
targetId: S,
|
|
135
|
+
participants: JSON.stringify(f),
|
|
136
|
+
mergedAt: /* @__PURE__ */ new Date()
|
|
137
|
+
});
|
|
138
|
+
} catch (e) {
|
|
139
|
+
throw o(c(e), "insert")?.kind === "unique" ? new u({ code: "upgrade_conflict" }) : e;
|
|
140
|
+
}
|
|
141
|
+
let p = (await n.query(m("users", a(s("id", S), s("tenantId", y)))))[0];
|
|
142
|
+
if (!p) throw new u({ code: "credential_rejected" });
|
|
143
|
+
return w(await C(n, p), t.subjectId, f, !1);
|
|
144
|
+
}));
|
|
145
|
+
},
|
|
146
|
+
catch: (e) => e
|
|
147
|
+
}).pipe(r.flatMap((e) => r.promise(() => T(e).catch(() => e))), r.catch((e) => r.succeed(E === void 0 ? e instanceof g ? e.result : e instanceof u ? e.code === "credential_rejected" ? h(403, "credential_rejected", "The guest account could not be confirmed.") : e.code === "upgrade_conflict" ? h(409, "merge_conflict", "The merge collided with another change; try again.") : h(503, "store_unavailable", "Account storage is unavailable.") : h(503, "store_unavailable", "Account storage is unavailable.") : h(409, "merge_failed", "A part of this app could not merge the accounts; nothing changed."))));
|
|
148
|
+
});
|
|
149
|
+
export { y as completeGuestSocialMerge, v as guestMergeTarget };
|
package/dist/guestHandoff.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isSocialProviderId as e } from "./providers.js";
|
|
2
|
+
import { SocialConfigError as t } from "./errors.js";
|
|
3
3
|
import { signAuthClaims as n, verifyAuthClaims as r } from "@voltro/plugin-auth";
|
|
4
4
|
// src/guestHandoff.ts
|
|
5
|
-
var i = (
|
|
6
|
-
let i =
|
|
7
|
-
exp:
|
|
8
|
-
audience:
|
|
9
|
-
guest:
|
|
5
|
+
var i = (e, r) => {
|
|
6
|
+
let i = e.profile, a = n({
|
|
7
|
+
exp: e.exp,
|
|
8
|
+
audience: e.audience,
|
|
9
|
+
guest: e.guest,
|
|
10
10
|
profile: {
|
|
11
11
|
provider: i.provider,
|
|
12
12
|
providerAccountId: i.providerAccountId,
|
|
@@ -18,7 +18,7 @@ var i = (t, r) => {
|
|
|
18
18
|
nameIsFirstAuthorizationOnly: i.nameIsFirstAuthorizationOnly
|
|
19
19
|
}
|
|
20
20
|
}, r.current.secret, "social-upgrade");
|
|
21
|
-
if (a.length > 3400) throw new
|
|
21
|
+
if (a.length > 3400) throw new t("Guest upgrade handoff exceeds its cookie budget");
|
|
22
22
|
return a;
|
|
23
23
|
}, a = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : null, o = (e) => {
|
|
24
24
|
let t = a(e), n = a(t?.metadata);
|
|
@@ -33,12 +33,12 @@ var i = (t, r) => {
|
|
|
33
33
|
guestDeviceGeneration: n.guestDeviceGeneration
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
}, s = (
|
|
37
|
-
if (!
|
|
38
|
-
let s = [n.current, n.previous].filter((e) => e !== void 0).map((
|
|
36
|
+
}, s = (t, n, i) => {
|
|
37
|
+
if (!t || t.length > 3400) return null;
|
|
38
|
+
let s = [n.current, n.previous].filter((e) => e !== void 0).map((e) => r(t, e.secret, "social-upgrade")).find((e) => e !== null);
|
|
39
39
|
if (!s || s.audience !== i || typeof s.exp != "number") return null;
|
|
40
40
|
let c = o(s.guest), l = a(s.profile), u = (e) => e === null || typeof e == "string";
|
|
41
|
-
return !c || !l || typeof l.provider != "string" || !
|
|
41
|
+
return !c || !l || typeof l.provider != "string" || !e(l.provider) || typeof l.providerAccountId != "string" || !l.providerAccountId || !u(l.email) || !u(l.firstName) || !u(l.lastName) || typeof l.emailVerified != "boolean" || typeof l.emailIsPrivateRelay != "boolean" || typeof l.nameIsFirstAuthorizationOnly != "boolean" ? null : {
|
|
42
42
|
guest: c,
|
|
43
43
|
exp: s.exp,
|
|
44
44
|
audience: i,
|
package/dist/guestUpgrade.js
CHANGED
|
@@ -10,15 +10,32 @@ var u = (e, t, n) => ({
|
|
|
10
10
|
take: void 0,
|
|
11
11
|
skip: void 0,
|
|
12
12
|
projection: void 0
|
|
13
|
-
}), d = (
|
|
14
|
-
|
|
13
|
+
}), d = (e, t, o) => ({
|
|
14
|
+
...t,
|
|
15
|
+
...s(e),
|
|
16
|
+
listMemberships: (t) => n.promise(async () => (await e.query({
|
|
17
|
+
...u("memberships", "userId", t),
|
|
18
|
+
predicate: r(i("userId", t), i("tenantId", o))
|
|
19
|
+
})).map((e) => {
|
|
20
|
+
if (e.userId !== t || e.tenantId !== o || typeof e.role != "string") throw new a({ code: "store_unavailable" });
|
|
21
|
+
let n = e.joinedAt instanceof Date ? e.joinedAt : new Date(String(e.joinedAt));
|
|
22
|
+
if (!Number.isFinite(n.getTime())) throw new a({ code: "store_unavailable" });
|
|
23
|
+
return {
|
|
24
|
+
userId: t,
|
|
25
|
+
tenantId: o,
|
|
26
|
+
role: e.role,
|
|
27
|
+
joinedAt: n
|
|
28
|
+
};
|
|
29
|
+
}))
|
|
30
|
+
}), f = (s) => {
|
|
31
|
+
if (s.config.defaultTenantId !== s.guest.tenantId || s.config.ensureActor !== void 0 && s.configForTransaction === void 0) return n.succeed({
|
|
15
32
|
kind: "refused",
|
|
16
33
|
status: 500,
|
|
17
34
|
code: "config",
|
|
18
35
|
message: "Guest upgrade requires a matching tenant and transaction-bound actor hooks."
|
|
19
36
|
});
|
|
20
|
-
let f =
|
|
21
|
-
return (
|
|
37
|
+
let f = s.profile, p = f.email === null || f.email.length === 0 ? null : f.email;
|
|
38
|
+
return (s.service ?? o(s.store, s.guest)).upgrade(s.credential, async (o) => {
|
|
22
39
|
let m = o.store, h = t(m);
|
|
23
40
|
if (await n.runPromise(h.findByProviderAccount(f.provider, f.providerAccountId)) !== null || p !== null && (await m.query(u("users", "email", p))).length !== 0) throw new a({ code: "upgrade_conflict" });
|
|
24
41
|
let g = {
|
|
@@ -30,7 +47,7 @@ var u = (e, t, n) => ({
|
|
|
30
47
|
mfaSecret: null,
|
|
31
48
|
mfaEnrolledAt: null,
|
|
32
49
|
emailVerifiedAt: p !== null && f.emailVerified ? /* @__PURE__ */ new Date() : null
|
|
33
|
-
}, _ =
|
|
50
|
+
}, _ = s.configForTransaction?.(m) ?? s.config;
|
|
34
51
|
if (_.defaultTenantId !== o.tenantId || !(await n.runPromise(l(_.subjectGuards ?? [], g))).ok) throw new a({ code: "credential_rejected" });
|
|
35
52
|
if (await m.insert("users", {
|
|
36
53
|
...g,
|
|
@@ -42,27 +59,10 @@ var u = (e, t, n) => ({
|
|
|
42
59
|
email: p,
|
|
43
60
|
emailVerified: p !== null && f.emailVerified
|
|
44
61
|
}).pipe(n.as(!0), n.catchTag("SocialIdentityConflict", () => n.succeed(!1))))) throw new a({ code: "upgrade_conflict" });
|
|
45
|
-
let v = {
|
|
46
|
-
...d.users,
|
|
47
|
-
...s(m),
|
|
48
|
-
listMemberships: (e) => n.promise(async () => (await m.query({
|
|
49
|
-
...u("memberships", "userId", e),
|
|
50
|
-
predicate: r(i("userId", e), i("tenantId", o.tenantId))
|
|
51
|
-
})).map((t) => {
|
|
52
|
-
if (t.userId !== e || t.tenantId !== o.tenantId || typeof t.role != "string") throw new a({ code: "store_unavailable" });
|
|
53
|
-
let n = t.joinedAt instanceof Date ? t.joinedAt : new Date(String(t.joinedAt));
|
|
54
|
-
if (!Number.isFinite(n.getTime())) throw new a({ code: "store_unavailable" });
|
|
55
|
-
return {
|
|
56
|
-
userId: e,
|
|
57
|
-
tenantId: o.tenantId,
|
|
58
|
-
role: t.role,
|
|
59
|
-
joinedAt: n
|
|
60
|
-
};
|
|
61
|
-
}))
|
|
62
|
-
}, y = await n.runPromise(c(g, v, _, {
|
|
62
|
+
let v = d(m, s.users, o.tenantId), y = await n.runPromise(c(g, v, _, {
|
|
63
63
|
clearLoginFailures: !1,
|
|
64
|
-
ipAddress:
|
|
65
|
-
userAgent:
|
|
64
|
+
ipAddress: s.ipAddress ?? null,
|
|
65
|
+
userAgent: s.userAgent ?? null
|
|
66
66
|
})), b = y.subject.type === "user" ? y.subject.metadata?.sessionId : null;
|
|
67
67
|
if (typeof b != "string" || (await m.query(u("sessions", "id", b))).length !== 1) throw new a({ code: "store_unavailable" });
|
|
68
68
|
let x = (await m.query({
|
|
@@ -93,4 +93,4 @@ var u = (e, t, n) => ({
|
|
|
93
93
|
message: e.code === "upgrade_conflict" ? "The provider or email belongs to an existing account. Confirm both accounts before merging." : e.code === "credential_rejected" ? "Guest upgrade was refused." : "Guest upgrade storage is unavailable."
|
|
94
94
|
})));
|
|
95
95
|
};
|
|
96
|
-
export {
|
|
96
|
+
export { f as completeGuestSocialUpgrade, d as transactionSessionStore };
|
package/dist/identityStore.js
CHANGED
|
@@ -10,18 +10,27 @@ var f = "_voltro_oauth_identities", p = l(f, {
|
|
|
10
10
|
emailVerified: r().default(!1),
|
|
11
11
|
createdAt: d().default("now"),
|
|
12
12
|
lastLoginAt: d().nullable()
|
|
13
|
-
}).unique("byOauthProviderAccount", ["provider", "providerAccountId"]).index(["userId"]), m =
|
|
13
|
+
}).unique("byOauthProviderAccount", ["provider", "providerAccountId"]).index(["userId"]), m = "_voltro_account_merges", h = l(m, {
|
|
14
|
+
id: c({ prefix: "amerge" }),
|
|
15
|
+
tenantId: u(),
|
|
16
|
+
requestId: u(),
|
|
17
|
+
sourceId: u(),
|
|
18
|
+
targetId: u(),
|
|
19
|
+
participants: u(),
|
|
20
|
+
mergedAt: d().default("now"),
|
|
21
|
+
residueErasedAt: d().nullable()
|
|
22
|
+
}).unique("byAccountMergeRequest", ["tenantId", "requestId"]).index(["targetId"]), g = [p, h], _ = class extends e.TaggedError("SocialIdentityConflict") {}, v = (e) => typeof e == "object" && !!e && e._tag === "ConstraintViolation" && e.kind === "unique" || i(o(e), "insert")?.kind === "unique", y = () => s({
|
|
14
23
|
kind: "typeid",
|
|
15
24
|
prefix: "oauthid"
|
|
16
|
-
}, "oauthid"),
|
|
25
|
+
}, "oauthid"), b = (e = []) => {
|
|
17
26
|
let n = [...e];
|
|
18
27
|
return {
|
|
19
28
|
findByProviderAccount: (e, r) => t.sync(() => n.find((t) => t.provider === e && t.providerAccountId === r) ?? null),
|
|
20
29
|
listForUser: (e) => t.sync(() => n.filter((t) => t.userId === e)),
|
|
21
|
-
insert: (e) => n.some((t) => t.provider === e.provider && t.providerAccountId === e.providerAccountId) ? t.fail(new
|
|
30
|
+
insert: (e) => n.some((t) => t.provider === e.provider && t.providerAccountId === e.providerAccountId) ? t.fail(new _({ provider: e.provider })) : t.sync(() => {
|
|
22
31
|
let t = {
|
|
23
32
|
...e,
|
|
24
|
-
id:
|
|
33
|
+
id: y(),
|
|
25
34
|
createdAt: /* @__PURE__ */ new Date(),
|
|
26
35
|
lastLoginAt: null
|
|
27
36
|
};
|
|
@@ -39,23 +48,23 @@ var f = "_voltro_oauth_identities", p = l(f, {
|
|
|
39
48
|
return t < 0 ? !1 : (n.splice(t, 1), !0);
|
|
40
49
|
})
|
|
41
50
|
};
|
|
42
|
-
},
|
|
51
|
+
}, x = (e) => {
|
|
43
52
|
if (e instanceof Date) return e;
|
|
44
53
|
if (typeof e == "string" || typeof e == "number") {
|
|
45
54
|
let t = new Date(e);
|
|
46
55
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
47
56
|
}
|
|
48
57
|
return null;
|
|
49
|
-
},
|
|
58
|
+
}, S = (e) => ({
|
|
50
59
|
id: String(e.id ?? ""),
|
|
51
60
|
userId: String(e.userId ?? ""),
|
|
52
61
|
provider: String(e.provider ?? ""),
|
|
53
62
|
providerAccountId: String(e.providerAccountId ?? ""),
|
|
54
63
|
email: typeof e.email == "string" && e.email.length > 0 ? e.email : null,
|
|
55
64
|
emailVerified: e.emailVerified === !0 || e.emailVerified === 1,
|
|
56
|
-
createdAt:
|
|
57
|
-
lastLoginAt:
|
|
58
|
-
}),
|
|
65
|
+
createdAt: x(e.createdAt) ?? /* @__PURE__ */ new Date(0),
|
|
66
|
+
lastLoginAt: x(e.lastLoginAt)
|
|
67
|
+
}), C = (e) => ({
|
|
59
68
|
findByProviderAccount: (r, i) => t.promise(async () => {
|
|
60
69
|
let t = (await e.query({
|
|
61
70
|
table: f,
|
|
@@ -66,7 +75,7 @@ var f = "_voltro_oauth_identities", p = l(f, {
|
|
|
66
75
|
projection: void 0,
|
|
67
76
|
order: []
|
|
68
77
|
}))[0];
|
|
69
|
-
return t ?
|
|
78
|
+
return t ? S(t) : null;
|
|
70
79
|
}),
|
|
71
80
|
listForUser: (n) => t.promise(async () => (await e.query({
|
|
72
81
|
table: f,
|
|
@@ -78,11 +87,11 @@ var f = "_voltro_oauth_identities", p = l(f, {
|
|
|
78
87
|
take: void 0,
|
|
79
88
|
skip: void 0,
|
|
80
89
|
projection: void 0
|
|
81
|
-
})).map(
|
|
90
|
+
})).map(S)),
|
|
82
91
|
insert: (n) => t.tryPromise({
|
|
83
92
|
try: async () => {
|
|
84
93
|
let t = {
|
|
85
|
-
id:
|
|
94
|
+
id: y(),
|
|
86
95
|
userId: n.userId,
|
|
87
96
|
provider: n.provider,
|
|
88
97
|
providerAccountId: n.providerAccountId,
|
|
@@ -91,13 +100,13 @@ var f = "_voltro_oauth_identities", p = l(f, {
|
|
|
91
100
|
createdAt: /* @__PURE__ */ new Date(),
|
|
92
101
|
lastLoginAt: null
|
|
93
102
|
};
|
|
94
|
-
if (!("insertIgnoreWithOutcome" in e) || e.insertIgnoreWithOutcome === void 0) return
|
|
103
|
+
if (!("insertIgnoreWithOutcome" in e) || e.insertIgnoreWithOutcome === void 0) return S(await e.insert(f, t));
|
|
95
104
|
let r = await e.insertIgnoreWithOutcome(f, t, { conflictColumns: ["provider", "providerAccountId"] });
|
|
96
|
-
if (r.outcome === "ignored") throw new
|
|
97
|
-
return
|
|
105
|
+
if (r.outcome === "ignored") throw new _({ provider: n.provider });
|
|
106
|
+
return S(r.row);
|
|
98
107
|
},
|
|
99
108
|
catch: (e) => e
|
|
100
|
-
}).pipe(t.catch((e) => e instanceof
|
|
109
|
+
}).pipe(t.catch((e) => e instanceof _ || v(e) ? t.fail(new _({ provider: n.provider })) : t.die(e))),
|
|
101
110
|
touch: (n, r) => t.promise(async () => {
|
|
102
111
|
await e.update(f, n, { lastLoginAt: r });
|
|
103
112
|
}),
|
|
@@ -113,11 +122,11 @@ var f = "_voltro_oauth_identities", p = l(f, {
|
|
|
113
122
|
}))[0];
|
|
114
123
|
return t ? e.delete(f, String(t.id ?? "")) : !1;
|
|
115
124
|
})
|
|
116
|
-
}),
|
|
125
|
+
}), w = (e, n, r) => t.gen(function* () {
|
|
117
126
|
let i = yield* e.findByProviderAccount(r.provider, r.providerAccountId);
|
|
118
127
|
return i ? i.userId === n ? i : yield* t.fail(/* @__PURE__ */ Error(`linkSocialIdentity: this ${r.provider} account is already linked to another user`)) : yield* e.insert({
|
|
119
128
|
...r,
|
|
120
129
|
userId: n
|
|
121
130
|
});
|
|
122
131
|
});
|
|
123
|
-
export { f as SOCIAL_IDENTITY_TABLE,
|
|
132
|
+
export { m as ACCOUNT_MERGE_TABLE, f as SOCIAL_IDENTITY_TABLE, _ as SocialIdentityConflict, h as accountMergesTable, C as dataStoreSocialIdentityStore, w as linkSocialIdentity, b as memorySocialIdentityStore, g as socialAuthTables, p as socialIdentitiesTable };
|