@voltro/plugin-auth-social 0.89.2 → 0.90.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 +1822 -0
- package/README.md +4 -0
- package/dist/accountMerge.js +149 -0
- package/dist/guestUpgrade.js +26 -26
- package/dist/identityStore.js +27 -18
- package/dist/index.d.ts +164 -5
- package/dist/index.js +17 -15
- package/dist/platformServices.js +80 -0
- package/dist/plugin.js +542 -273
- package/dist/providers.js +2 -2
- 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 +5 -5
package/dist/index.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { PlatformTicketError as e, SocialAccountLinkError as t, SocialAuthError as n, SocialConfigError as r, SocialExchangeError as i, SocialIdTokenError as a, SocialStateMismatchError as o } from "./errors.js";
|
|
2
|
-
import { SOCIAL_PROVIDERS as s, SOCIAL_PROVIDER_IDS as c, isSocialProviderId as l,
|
|
3
|
-
import { socialBeginLogin as
|
|
4
|
-
import { APPLE_CLIENT_SECRET_DEFAULT_TTL_S as
|
|
5
|
-
import { fetchGithubIdentity as
|
|
6
|
-
import { fetchDiscordIdentity as
|
|
7
|
-
import { fetchEpicIdentity as
|
|
8
|
-
import { socialCompleteLogin as
|
|
9
|
-
import { decideSocialLink as
|
|
10
|
-
import { completeSocialSignIn as
|
|
11
|
-
import { SOCIAL_IDENTITY_TABLE as
|
|
12
|
-
import { completeGuestSocialUpgrade as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
2
|
+
import { SOCIAL_PROVIDERS as s, SOCIAL_PROVIDER_IDS as c, isSocialProviderId as l, isSocialWebProviderId as u, socialProvider as d } from "./providers.js";
|
|
3
|
+
import { socialBeginLogin as f } from "./login.js";
|
|
4
|
+
import { APPLE_CLIENT_SECRET_DEFAULT_TTL_S as p, APPLE_CLIENT_SECRET_MAX_TTL_S as m, _resetAppleSecretCache as h, appleClientSecret as g, isApplePrivateRelayEmail as _, parseAppleUserPayload as v } from "./apple.js";
|
|
5
|
+
import { fetchGithubIdentity as y } from "./github.js";
|
|
6
|
+
import { fetchDiscordIdentity as b } from "./discord.js";
|
|
7
|
+
import { fetchEpicIdentity as x } from "./epic.js";
|
|
8
|
+
import { socialCompleteLogin as S } from "./callback.js";
|
|
9
|
+
import { decideSocialLink as C } from "./linking.js";
|
|
10
|
+
import { completeSocialSignIn as w } from "./signIn.js";
|
|
11
|
+
import { ACCOUNT_MERGE_TABLE as T, SOCIAL_IDENTITY_TABLE as E, SocialIdentityConflict as D, accountMergesTable as O, dataStoreSocialIdentityStore as k, linkSocialIdentity as A, memorySocialIdentityStore as j, socialAuthTables as M, socialIdentitiesTable as N } from "./identityStore.js";
|
|
12
|
+
import { completeGuestSocialUpgrade as P } from "./guestUpgrade.js";
|
|
13
|
+
import { completeGuestSocialMerge as F, guestMergeTarget as I } from "./accountMerge.js";
|
|
14
|
+
import { steamBeginOpenId as L, steamCompleteOpenId as R, verifySteamWebApiTicket as z } from "./steam.js";
|
|
15
|
+
import { definePlatformLogin as B, eosPlatformLogin as V, steamPlatformLogin as H, verifyPlatformTicket as U } from "./platform.js";
|
|
16
|
+
import { socialAuthPlugin as W } from "./plugin.js";
|
|
17
|
+
import { PlatformServicesError as G, PlatformServicesPort as K, devPlatformServices as q, steamPlatformServices as J } from "./platformServices.js";
|
|
18
|
+
export { T as ACCOUNT_MERGE_TABLE, p as APPLE_CLIENT_SECRET_DEFAULT_TTL_S, m as APPLE_CLIENT_SECRET_MAX_TTL_S, G as PlatformServicesError, K as PlatformServicesPort, e as PlatformTicketError, E as SOCIAL_IDENTITY_TABLE, s as SOCIAL_PROVIDERS, c as SOCIAL_PROVIDER_IDS, t as SocialAccountLinkError, n as SocialAuthError, r as SocialConfigError, i as SocialExchangeError, a as SocialIdTokenError, D as SocialIdentityConflict, o as SocialStateMismatchError, h as _resetAppleSecretCache, O as accountMergesTable, g as appleClientSecret, F as completeGuestSocialMerge, P as completeGuestSocialUpgrade, w as completeSocialSignIn, k as dataStoreSocialIdentityStore, C as decideSocialLink, B as definePlatformLogin, q as devPlatformServices, V as eosPlatformLogin, b as fetchDiscordIdentity, x as fetchEpicIdentity, y as fetchGithubIdentity, I as guestMergeTarget, _ as isApplePrivateRelayEmail, l as isSocialProviderId, u as isSocialWebProviderId, A as linkSocialIdentity, j as memorySocialIdentityStore, v as parseAppleUserPayload, W as socialAuthPlugin, M as socialAuthTables, f as socialBeginLogin, S as socialCompleteLogin, N as socialIdentitiesTable, d as socialProvider, L as steamBeginOpenId, R as steamCompleteOpenId, H as steamPlatformLogin, J as steamPlatformServices, U as verifyPlatformTicket, z as verifySteamWebApiTicket };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Context as e, Effect as t, Schema as n } from "effect";
|
|
2
|
+
// src/platformServices.ts
|
|
3
|
+
var r = class extends n.TaggedError()("PlatformServicesError", { code: n.Literals([
|
|
4
|
+
"invalid_input",
|
|
5
|
+
"unsupported",
|
|
6
|
+
"unavailable",
|
|
7
|
+
"rejected"
|
|
8
|
+
]) }) {}, i = (e) => new r({ code: e }), a = class extends e.Service()("@voltro/PlatformServicesPort") {}, o = (e, t) => {
|
|
9
|
+
if (typeof e != "string" || !e || e.length > t || e.includes("\0")) throw i("invalid_input");
|
|
10
|
+
return e;
|
|
11
|
+
}, s = (e) => ({
|
|
12
|
+
platform: o(e?.platform, 64),
|
|
13
|
+
platformAccountId: o(e?.platformAccountId, 64)
|
|
14
|
+
}), c = (e) => {
|
|
15
|
+
let t = e.details ?? {};
|
|
16
|
+
if (typeof t != "object" || Array.isArray(t) || Object.keys(t).length > 20) throw i("invalid_input");
|
|
17
|
+
return {
|
|
18
|
+
...s(e),
|
|
19
|
+
status: o(e.status, 256),
|
|
20
|
+
details: Object.freeze(Object.fromEntries(Object.entries(t).map(([e, t]) => [o(e, 64), o(t, 256)])))
|
|
21
|
+
};
|
|
22
|
+
}, l = (e) => t.try({
|
|
23
|
+
try: e,
|
|
24
|
+
catch: (e) => e instanceof r ? e : i("invalid_input")
|
|
25
|
+
}), u = (e = {}) => {
|
|
26
|
+
let n = e.max ?? 1e3, r = [];
|
|
27
|
+
if (!Number.isSafeInteger(n) || n < 1 || n > 1e5) throw i("invalid_input");
|
|
28
|
+
let a = (e) => {
|
|
29
|
+
r.push(Object.freeze(e)), r.length > n && r.shift();
|
|
30
|
+
};
|
|
31
|
+
return Object.freeze({
|
|
32
|
+
unlockAchievement: (e) => t.flatMap(l(() => ({
|
|
33
|
+
...s(e),
|
|
34
|
+
achievementId: o(e.achievementId, 128)
|
|
35
|
+
})), (e) => t.sync(() => a({
|
|
36
|
+
kind: "achievement",
|
|
37
|
+
...e
|
|
38
|
+
}))),
|
|
39
|
+
setPresence: (e) => t.flatMap(l(() => c(e)), (e) => t.sync(() => a({
|
|
40
|
+
kind: "presence",
|
|
41
|
+
...e
|
|
42
|
+
}))),
|
|
43
|
+
calls: () => Object.freeze([...r])
|
|
44
|
+
});
|
|
45
|
+
}, d = "https://partner.steam-api.com/ISteamUserStats/SetUserStatsForGame/v1/", f = (e) => {
|
|
46
|
+
let n = o(e?.appId, 32), a = o(e.publisherKey, 256), u = e.timeoutMs ?? 5e3;
|
|
47
|
+
if (!/^[0-9]+$/.test(n) || !Number.isSafeInteger(u) || u < 100 || u > 6e4) throw i("invalid_input");
|
|
48
|
+
let f = e.fetchImpl ?? fetch, p = e.endpoint ?? d, m = e.achievementName ?? ((e) => e);
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
unlockAchievement: (e) => t.flatMap(l(() => {
|
|
51
|
+
let t = s(e);
|
|
52
|
+
if (t.platform !== "steam" || !/^[0-9]{17,20}$/.test(t.platformAccountId)) throw i("invalid_input");
|
|
53
|
+
return {
|
|
54
|
+
steamId: t.platformAccountId,
|
|
55
|
+
name: o(m(o(e.achievementId, 128)), 128)
|
|
56
|
+
};
|
|
57
|
+
}), ({ steamId: e, name: o }) => t.tryPromise({
|
|
58
|
+
try: async () => {
|
|
59
|
+
let t = new URLSearchParams({
|
|
60
|
+
key: a,
|
|
61
|
+
appid: n,
|
|
62
|
+
steamid: e,
|
|
63
|
+
count: "1",
|
|
64
|
+
"name[0]": o,
|
|
65
|
+
"value[0]": "1"
|
|
66
|
+
}), r = await f(p, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: t,
|
|
69
|
+
signal: AbortSignal.timeout(u),
|
|
70
|
+
headers: { "content-type": "application/x-www-form-urlencoded" }
|
|
71
|
+
});
|
|
72
|
+
if (await r.body?.cancel().catch(() => void 0), r.status === 401 || r.status === 403) throw i("rejected");
|
|
73
|
+
if (!r.ok) throw i("unavailable");
|
|
74
|
+
},
|
|
75
|
+
catch: (e) => e instanceof r ? e : i("unavailable")
|
|
76
|
+
})),
|
|
77
|
+
setPresence: (e) => t.flatMap(l(() => c(e)), () => t.fail(i("unsupported")))
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
export { r as PlatformServicesError, a as PlatformServicesPort, u as devPlatformServices, f as steamPlatformServices };
|