@renown/sdk 6.2.2-dev.61 → 6.2.2-dev.63
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/meta-D-5kvwx8.js.map +1 -1
- package/dist/types-C3PZqMdJ.d.ts +63 -0
- package/dist/types-C3PZqMdJ.d.ts.map +1 -0
- package/dist/wallet/privy/factory.d.ts +23 -2
- package/dist/wallet/privy/factory.d.ts.map +1 -1
- package/dist/wallet/privy/factory.js +155 -31
- package/dist/wallet/privy/factory.js.map +1 -1
- package/dist/wallet/privy/index.d.ts +2 -2
- package/dist/wallet/privy/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/meta-BubXYEe3.d.ts +0 -16
- package/dist/meta-BubXYEe3.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-D-5kvwx8.js","names":[],"sources":["../src/wallet/privy/meta.ts"],"sourcesContent":["import { LoginMethod, type WalletAdapterMeta } from \"../types.js\";\n\n// Login methods the Privy adapter can drive. adapter.ts maps each to a Privy\n// login-method id, so adding one here without mapping it fails to compile.\nexport type PrivyLoginMethod = \"wallet\" | \"google\" | \"apple\" | \"email\";\n\nexport const PRIVY_SUPPORTED_METHODS: PrivyLoginMethod[] = [\n LoginMethod.WALLET,\n LoginMethod.GOOGLE,\n LoginMethod.APPLE,\n LoginMethod.EMAIL,\n];\n\n// Methods offered when config omits `methods`.\nexport const DEFAULT_PRIVY_METHODS: LoginMethod[] = [\n LoginMethod.GOOGLE,\n LoginMethod.EMAIL,\n];\n\n// Config slice for the Privy adapter (mirrors connect.renown.adapters.privy).\nexport interface PHRenownPrivyAdapterConfig {\n appId: string;\n clientId?: string;\n /** Login methods to offer; defaults to [google, email]. */\n methods?: PrivyLoginMethod[];\n}\n\n// Resolve config `methods` to the supported set, falling back to the default.\n// Takes string[] because Connect's config arrives from JSON, unvalidated.\nexport function resolvePrivyMethods(methods?: string[]): LoginMethod[] {\n if (!methods || methods.length === 0) return [...DEFAULT_PRIVY_METHODS];\n const resolved: LoginMethod[] = [];\n for (const method of methods) {\n const value = method as PrivyLoginMethod;\n if (!PRIVY_SUPPORTED_METHODS.includes(value)) {\n throw new Error(`PrivyAdapter cannot support login method \"${method}\"`);\n }\n resolved.push(value);\n }\n return resolved;\n}\n\n// Dependency-free identity, safe to import eagerly (pulls no wallet library);\n// the heavy factory stays behind the dynamic import in ./index.ts.\nexport const privyAdapterMeta: Omit<WalletAdapterMeta, \"supportedMethods\"> = {\n id: \"privy\",\n redirectReturnParams: [\"privy_oauth_code\", \"privy_oauth_state\"],\n};\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"meta-D-5kvwx8.js","names":[],"sources":["../src/wallet/privy/meta.ts"],"sourcesContent":["import { LoginMethod, type WalletAdapterMeta } from \"../types.js\";\n\n/** Structural subset of viem's `Chain`, so any `viem/chains` / `wagmi/chains` export fits regardless of the host's viem version. */\nexport interface PrivyChain {\n id: number;\n name: string;\n nativeCurrency: { name: string; symbol: string; decimals: number };\n rpcUrls: { default: { http: readonly string[] } };\n}\n\n// Login methods the Privy adapter can drive. adapter.ts maps each to a Privy\n// login-method id, so adding one here without mapping it fails to compile.\nexport type PrivyLoginMethod = \"wallet\" | \"google\" | \"apple\" | \"email\";\n\nexport const PRIVY_SUPPORTED_METHODS: PrivyLoginMethod[] = [\n LoginMethod.WALLET,\n LoginMethod.GOOGLE,\n LoginMethod.APPLE,\n LoginMethod.EMAIL,\n];\n\n// Methods offered when config omits `methods`.\nexport const DEFAULT_PRIVY_METHODS: LoginMethod[] = [\n LoginMethod.GOOGLE,\n LoginMethod.EMAIL,\n];\n\n// Config slice for the Privy adapter (mirrors connect.renown.adapters.privy).\nexport interface PHRenownPrivyAdapterConfig {\n appId: string;\n clientId?: string;\n /** Login methods to offer; defaults to [google, email]. */\n methods?: PrivyLoginMethod[];\n /** Chain Renown issues credentials on (e.g. `mainnet` from `viem/chains`). Pins the embedded wallet to it: a wallet on another chain is a different DID and is rejected. */\n chain?: PrivyChain;\n /** Privy `appearance.walletList`. Defaults to `[\"detected_ethereum_wallets\"]`: with external wallets disabled here (they go through the rainbow adapter), anything else makes Privy fetch the WalletConnect explorer listings (~163 KB) on mount. Set it only if you want those listings. */\n walletList?: string[];\n}\n\n// Resolve config `methods` to the supported set, falling back to the default.\n// Takes string[] because Connect's config arrives from JSON, unvalidated.\nexport function resolvePrivyMethods(methods?: string[]): LoginMethod[] {\n if (!methods || methods.length === 0) return [...DEFAULT_PRIVY_METHODS];\n const resolved: LoginMethod[] = [];\n for (const method of methods) {\n const value = method as PrivyLoginMethod;\n if (!PRIVY_SUPPORTED_METHODS.includes(value)) {\n throw new Error(`PrivyAdapter cannot support login method \"${method}\"`);\n }\n resolved.push(value);\n }\n return resolved;\n}\n\n// Dependency-free identity, safe to import eagerly (pulls no wallet library);\n// the heavy factory stays behind the dynamic import in ./index.ts.\nexport const privyAdapterMeta: Omit<WalletAdapterMeta, \"supportedMethods\"> = {\n id: \"privy\",\n redirectReturnParams: [\"privy_oauth_code\", \"privy_oauth_state\"],\n};\n"],"mappings":";;AAcA,MAAa,0BAA8C;CACzD,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACb;AAGD,MAAa,wBAAuC,CAClD,YAAY,QACZ,YAAY,MACb;AAgBD,SAAgB,oBAAoB,SAAmC;AACrE,KAAI,CAAC,WAAW,QAAQ,WAAW,EAAG,QAAO,CAAC,GAAG,sBAAsB;CACvE,MAAM,WAA0B,EAAE;AAClC,MAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,QAAQ;AACd,MAAI,CAAC,wBAAwB,SAAS,MAAM,CAC1C,OAAM,IAAI,MAAM,6CAA6C,OAAO,GAAG;AAEzE,WAAS,KAAK,MAAM;;AAEtB,QAAO;;AAKT,MAAa,mBAAgE;CAC3E,IAAI;CACJ,sBAAsB,CAAC,oBAAoB,oBAAoB;CAChE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { c as WalletController, l as WalletSession, o as WalletAdapterMeta, t as LoginMethod } from "./types-b2fgIxlx.js";
|
|
2
|
+
|
|
3
|
+
//#region src/wallet/privy/meta.d.ts
|
|
4
|
+
/** Structural subset of viem's `Chain`, so any `viem/chains` / `wagmi/chains` export fits regardless of the host's viem version. */
|
|
5
|
+
interface PrivyChain {
|
|
6
|
+
id: number;
|
|
7
|
+
name: string;
|
|
8
|
+
nativeCurrency: {
|
|
9
|
+
name: string;
|
|
10
|
+
symbol: string;
|
|
11
|
+
decimals: number;
|
|
12
|
+
};
|
|
13
|
+
rpcUrls: {
|
|
14
|
+
default: {
|
|
15
|
+
http: readonly string[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
type PrivyLoginMethod = "wallet" | "google" | "apple" | "email";
|
|
20
|
+
declare const DEFAULT_PRIVY_METHODS: LoginMethod[];
|
|
21
|
+
interface PHRenownPrivyAdapterConfig {
|
|
22
|
+
appId: string;
|
|
23
|
+
clientId?: string;
|
|
24
|
+
/** Login methods to offer; defaults to [google, email]. */
|
|
25
|
+
methods?: PrivyLoginMethod[];
|
|
26
|
+
/** Chain Renown issues credentials on (e.g. `mainnet` from `viem/chains`). Pins the embedded wallet to it: a wallet on another chain is a different DID and is rejected. */
|
|
27
|
+
chain?: PrivyChain;
|
|
28
|
+
/** Privy `appearance.walletList`. Defaults to `["detected_ethereum_wallets"]`: with external wallets disabled here (they go through the rainbow adapter), anything else makes Privy fetch the WalletConnect explorer listings (~163 KB) on mount. Set it only if you want those listings. */
|
|
29
|
+
walletList?: string[];
|
|
30
|
+
}
|
|
31
|
+
declare function resolvePrivyMethods(methods?: string[]): LoginMethod[];
|
|
32
|
+
declare const privyAdapterMeta: Omit<WalletAdapterMeta, "supportedMethods">;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/wallet/privy/types.d.ts
|
|
35
|
+
/** Privy's email OTP flow status, as reported by its `useLoginWithEmail`. */
|
|
36
|
+
type PrivyEmailStatus = "initial" | "sending-code" | "awaiting-code-input" | "submitting-code" | "done" | "error";
|
|
37
|
+
/** Privy auth state the bridge mirrors into the core, for hosts drawing their own sign-in screens. */
|
|
38
|
+
interface PrivyAuthState {
|
|
39
|
+
/** Privy has finished restoring any existing session. */
|
|
40
|
+
ready: boolean;
|
|
41
|
+
/** Privy holds a session (before Renown has issued a credential). */
|
|
42
|
+
authenticated: boolean;
|
|
43
|
+
/** The signed-in user's verified email, when logged in by email. */
|
|
44
|
+
email?: string;
|
|
45
|
+
emailStatus: PrivyEmailStatus;
|
|
46
|
+
emailError?: Error;
|
|
47
|
+
}
|
|
48
|
+
interface SendCodeOptions {
|
|
49
|
+
/** Reject addresses with no Privy account instead of creating one. */
|
|
50
|
+
disableSignup?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** The Privy adapter's controller: `WalletController` plus the headless email OTP surface, so a host can draw its own sign-in screens without importing `@privy-io/react-auth`. */
|
|
53
|
+
interface PrivyWalletController extends WalletController {
|
|
54
|
+
/** Send a one-time code to `email`. */
|
|
55
|
+
sendCode(email: string, options?: SendCodeOptions): Promise<void>;
|
|
56
|
+
/** Verify the code; resolves with the embedded-wallet session, ready for `login(session)`. */
|
|
57
|
+
loginWithCode(code: string): Promise<WalletSession>;
|
|
58
|
+
getState(): PrivyAuthState;
|
|
59
|
+
subscribeState(listener: (state: PrivyAuthState) => void): () => void;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { DEFAULT_PRIVY_METHODS as a, PrivyLoginMethod as c, SendCodeOptions as i, privyAdapterMeta as l, PrivyEmailStatus as n, PHRenownPrivyAdapterConfig as o, PrivyWalletController as r, PrivyChain as s, PrivyAuthState as t, resolvePrivyMethods as u };
|
|
63
|
+
//# sourceMappingURL=types-C3PZqMdJ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-C3PZqMdJ.d.ts","names":[],"sources":["../src/wallet/privy/meta.ts","../src/wallet/privy/types.ts"],"mappings":";;;;UAGiB,UAAA;EACf,EAAA;EACA,IAAA;EACA,cAAA;IAAkB,IAAA;IAAc,MAAA;IAAgB,QAAA;EAAA;EAChD,OAAA;IAAW,OAAA;MAAW,IAAA;IAAA;EAAA;AAAA;AAAA,KAKZ,gBAAA;AAAA,cAUC,qBAAA,EAAuB,WAAA;AAAA,UAMnB,0BAAA;EACf,KAAA;EACA,QAAA;EAlB0B;EAoB1B,OAAA,GAAU,gBAAA;EAPX;EASC,KAAA,GAAQ,UAAA;EAZ0B;EAclC,UAAA;AAAA;AAAA,iBAKc,mBAAA,CAAoB,OAAA,cAAqB,WAAA;AAAA,cAe5C,gBAAA,EAAkB,IAAA,CAAK,iBAAA;;;;KClDxB,gBAAA;ADHZ;AAAA,UCYiB,cAAA;;EAEf,KAAA;EDbA;ECeA,aAAA;EDbA;ECeA,KAAA;EACA,WAAA,EAAa,gBAAA;EACb,UAAA,GAAa,KAAA;AAAA;AAAA,UAGE,eAAA;EDnBO;ECqBtB,aAAA;AAAA;ADhBF;AAAA,UCoBiB,qBAAA,SAA8B,gBAAA;;EAE7C,QAAA,CAAS,KAAA,UAAe,OAAA,GAAU,eAAA,GAAkB,OAAA;EDtB1B;ECwB1B,aAAA,CAAc,IAAA,WAAe,OAAA,CAAQ,aAAA;EACrC,QAAA,IAAY,cAAA;EACZ,cAAA,CAAe,QAAA,GAAW,KAAA,EAAO,cAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { it as SignCredentialTypedData } from "../../types-DVcz43Fb.js";
|
|
2
2
|
import { a as WalletAdapterImpl, l as WalletSession, t as LoginMethod, u as WalletTheme } from "../../types-b2fgIxlx.js";
|
|
3
|
-
import { n as PHRenownPrivyAdapterConfig } from "../../
|
|
3
|
+
import { i as SendCodeOptions, n as PrivyEmailStatus, o as PHRenownPrivyAdapterConfig, r as PrivyWalletController, s as PrivyChain, t as PrivyAuthState } from "../../types-C3PZqMdJ.js";
|
|
4
4
|
import { ComponentType, ReactNode } from "react";
|
|
5
5
|
import { ConnectedWallet, LoginModalOptions } from "@privy-io/react-auth";
|
|
6
6
|
|
|
@@ -12,6 +12,13 @@ interface PrivyBindings {
|
|
|
12
12
|
initOAuth: (options: {
|
|
13
13
|
provider: PrivyOAuthProviderId;
|
|
14
14
|
}) => Promise<void>;
|
|
15
|
+
sendCode: (options: {
|
|
16
|
+
email: string;
|
|
17
|
+
disableSignup?: boolean;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
loginWithCode: (options: {
|
|
20
|
+
code: string;
|
|
21
|
+
}) => Promise<void>;
|
|
15
22
|
logout: () => Promise<void>;
|
|
16
23
|
signTypedData: (args: Parameters<SignCredentialTypedData>[0], address: Hex) => Promise<Hex>;
|
|
17
24
|
}
|
|
@@ -21,16 +28,28 @@ declare class PrivyCore {
|
|
|
21
28
|
private pending;
|
|
22
29
|
private session;
|
|
23
30
|
private listeners;
|
|
31
|
+
private state;
|
|
32
|
+
private stateListeners;
|
|
24
33
|
constructor(supportedMethods: LoginMethod[]);
|
|
25
34
|
bind(bindings: PrivyBindings): () => void;
|
|
26
35
|
getSession(): WalletSession | undefined;
|
|
27
36
|
subscribe(listener: (session: WalletSession | undefined) => void): () => void;
|
|
28
37
|
private emit;
|
|
38
|
+
getState(): PrivyAuthState;
|
|
39
|
+
subscribeState(listener: (state: PrivyAuthState) => void): () => void;
|
|
40
|
+
syncState(next: PrivyAuthState): void;
|
|
29
41
|
syncFromEmbeddedWallet(wallet: ConnectedWallet): void;
|
|
30
42
|
clearSession(): void;
|
|
31
43
|
handleLoginError(error: unknown): void;
|
|
44
|
+
private requireBindings;
|
|
45
|
+
private requireMethod;
|
|
46
|
+
private awaitSession;
|
|
32
47
|
connect(method?: LoginMethod): Promise<WalletSession>;
|
|
48
|
+
sendCode(email: string, options?: SendCodeOptions): Promise<void>;
|
|
49
|
+
loginWithCode(code: string): Promise<WalletSession>;
|
|
33
50
|
disconnect(): Promise<void>;
|
|
51
|
+
private currentBindings;
|
|
52
|
+
private whenReady;
|
|
34
53
|
}
|
|
35
54
|
//#endregion
|
|
36
55
|
//#region src/wallet/privy/bridge.d.ts
|
|
@@ -45,6 +64,8 @@ declare function PrivyAdapterBridge({
|
|
|
45
64
|
interface PrivyProviderConfig {
|
|
46
65
|
appId: string;
|
|
47
66
|
clientId?: string;
|
|
67
|
+
chain?: PrivyChain;
|
|
68
|
+
walletList?: string[];
|
|
48
69
|
}
|
|
49
70
|
declare function createPrivyProvider(core: PrivyCore, config: PrivyProviderConfig): ComponentType<{
|
|
50
71
|
children: ReactNode;
|
|
@@ -54,5 +75,5 @@ declare function createPrivyProvider(core: PrivyCore, config: PrivyProviderConfi
|
|
|
54
75
|
//#region src/wallet/privy/factory.d.ts
|
|
55
76
|
declare function createPrivyAdapter(config: PHRenownPrivyAdapterConfig): WalletAdapterImpl;
|
|
56
77
|
//#endregion
|
|
57
|
-
export { PrivyAdapterBridge, type PrivyBindings, PrivyCore, createPrivyAdapter, createPrivyProvider };
|
|
78
|
+
export { PrivyAdapterBridge, type PrivyAuthState, type PrivyBindings, PrivyCore, type PrivyEmailStatus, type PrivyWalletController, type SendCodeOptions, createPrivyAdapter, createPrivyProvider };
|
|
58
79
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","names":[],"sources":["../../../src/wallet/privy/adapter.ts","../../../src/wallet/privy/bridge.tsx","../../../src/wallet/privy/provider.tsx","../../../src/wallet/privy/factory.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","names":[],"sources":["../../../src/wallet/privy/adapter.ts","../../../src/wallet/privy/bridge.tsx","../../../src/wallet/privy/provider.tsx","../../../src/wallet/privy/factory.ts"],"mappings":";;;;;;;KAUK,GAAA;AAAA,KAcA,oBAAA;AAAA,UAaY,aAAA;EACf,cAAA,GAAiB,OAAA,GAAU,iBAAA;EAC3B,SAAA,GAAY,OAAA;IAAW,QAAA,EAAU,oBAAA;EAA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A,GAAQ,UAAA;EACR,UAAA;AAAA;AAAA,iBAKc,mBAAA,CACd,IAAA,EAAM,SAAA,EACN,MAAA,EAAQ,mBAAA,GACP,aAAA;EAAgB,QAAA,EAAU,SAAA;EAAW,KAAA,GAAQ,WAAA;AAAA;;;iBCLhC,kBAAA,CACd,MAAA,EAAQ,0BAAA,GACP,iBAAA"}
|
|
@@ -3,7 +3,7 @@ import { n as normalizeWalletTheme, t as LoginMethod } from "../../types-C_qc_62
|
|
|
3
3
|
import { r as resolvePrivyMethods } from "../../meta-D-5kvwx8.js";
|
|
4
4
|
import { useEffect, useMemo, useRef } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { PrivyProvider, getEmbeddedConnectedWallet, useCreateWallet, useLogin, useLoginWithOAuth, useLogout, usePrivy, useSignTypedData, useWallets } from "@privy-io/react-auth";
|
|
6
|
+
import { PrivyProvider, getEmbeddedConnectedWallet, useCreateWallet, useLogin, useLoginWithEmail, useLoginWithOAuth, useLogout, usePrivy, useSignTypedData, useWallets } from "@privy-io/react-auth";
|
|
7
7
|
//#region src/wallet/privy/adapter.ts
|
|
8
8
|
const PRIVY_METHOD_MAP = {
|
|
9
9
|
[LoginMethod.WALLET]: "wallet",
|
|
@@ -15,12 +15,19 @@ const PRIVY_OAUTH_PROVIDERS = {
|
|
|
15
15
|
[LoginMethod.GOOGLE]: "google",
|
|
16
16
|
[LoginMethod.APPLE]: "apple"
|
|
17
17
|
};
|
|
18
|
+
const INITIAL_STATE = {
|
|
19
|
+
ready: false,
|
|
20
|
+
authenticated: false,
|
|
21
|
+
emailStatus: "initial"
|
|
22
|
+
};
|
|
18
23
|
var PrivyCore = class {
|
|
19
24
|
supportedMethods;
|
|
20
25
|
bindings = null;
|
|
21
26
|
pending = null;
|
|
22
27
|
session = void 0;
|
|
23
28
|
listeners = /* @__PURE__ */ new Set();
|
|
29
|
+
state = INITIAL_STATE;
|
|
30
|
+
stateListeners = /* @__PURE__ */ new Set();
|
|
24
31
|
constructor(supportedMethods) {
|
|
25
32
|
this.supportedMethods = supportedMethods;
|
|
26
33
|
}
|
|
@@ -43,6 +50,21 @@ var PrivyCore = class {
|
|
|
43
50
|
emit(session) {
|
|
44
51
|
for (const listener of this.listeners) listener(session);
|
|
45
52
|
}
|
|
53
|
+
getState() {
|
|
54
|
+
return this.state;
|
|
55
|
+
}
|
|
56
|
+
subscribeState(listener) {
|
|
57
|
+
this.stateListeners.add(listener);
|
|
58
|
+
return () => {
|
|
59
|
+
this.stateListeners.delete(listener);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
syncState(next) {
|
|
63
|
+
const prev = this.state;
|
|
64
|
+
if (prev.ready === next.ready && prev.authenticated === next.authenticated && prev.email === next.email && prev.emailStatus === next.emailStatus && prev.emailError === next.emailError) return;
|
|
65
|
+
this.state = next;
|
|
66
|
+
for (const listener of this.stateListeners) listener(next);
|
|
67
|
+
}
|
|
46
68
|
syncFromEmbeddedWallet(wallet) {
|
|
47
69
|
const address = wallet.address;
|
|
48
70
|
const chainId = parseCaip2ChainId(wallet.chainId);
|
|
@@ -72,15 +94,15 @@ var PrivyCore = class {
|
|
|
72
94
|
this.pending.reject(err);
|
|
73
95
|
this.pending = null;
|
|
74
96
|
}
|
|
75
|
-
|
|
76
|
-
if (this.session) return this.session;
|
|
97
|
+
requireBindings() {
|
|
77
98
|
if (!this.bindings) throw new Error("PrivyAdapter not bound. Ensure the adapter Provider wraps the app.");
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
return this.bindings;
|
|
100
|
+
}
|
|
101
|
+
requireMethod(method) {
|
|
102
|
+
if (!this.supportedMethods.includes(method)) throw new Error(`PrivyAdapter does not support login method "${method}"`);
|
|
103
|
+
}
|
|
104
|
+
awaitSession(start) {
|
|
105
|
+
if (this.pending) return Promise.reject(/* @__PURE__ */ new Error("PrivyAdapter: a login is already in progress"));
|
|
84
106
|
return new Promise((resolve, reject) => {
|
|
85
107
|
this.pending = {
|
|
86
108
|
resolve,
|
|
@@ -91,17 +113,64 @@ var PrivyCore = class {
|
|
|
91
113
|
reject(error instanceof Error ? error : new Error(String(error)));
|
|
92
114
|
};
|
|
93
115
|
try {
|
|
94
|
-
|
|
95
|
-
else bindings.openLoginModal({ loginMethods: [privyMethod] });
|
|
116
|
+
start(fail);
|
|
96
117
|
} catch (error) {
|
|
97
118
|
fail(error);
|
|
98
119
|
}
|
|
99
120
|
});
|
|
100
121
|
}
|
|
122
|
+
async connect(method) {
|
|
123
|
+
if (this.session) return this.session;
|
|
124
|
+
const bindings = this.requireBindings();
|
|
125
|
+
const chosen = method ?? this.supportedMethods.at(0);
|
|
126
|
+
if (!chosen) throw new Error("PrivyAdapter has no supported login methods configured");
|
|
127
|
+
this.requireMethod(chosen);
|
|
128
|
+
const privyMethod = PRIVY_METHOD_MAP[chosen];
|
|
129
|
+
const oauthProvider = PRIVY_OAUTH_PROVIDERS[chosen];
|
|
130
|
+
return this.awaitSession((fail) => {
|
|
131
|
+
if (oauthProvider) bindings.initOAuth({ provider: oauthProvider }).catch(fail);
|
|
132
|
+
else bindings.openLoginModal({ loginMethods: [privyMethod] });
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
async sendCode(email, options) {
|
|
136
|
+
this.requireMethod(LoginMethod.EMAIL);
|
|
137
|
+
await this.requireBindings().sendCode({
|
|
138
|
+
email,
|
|
139
|
+
disableSignup: options?.disableSignup
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async loginWithCode(code) {
|
|
143
|
+
if (this.session) return this.session;
|
|
144
|
+
this.requireMethod(LoginMethod.EMAIL);
|
|
145
|
+
const bindings = this.requireBindings();
|
|
146
|
+
return this.awaitSession((fail) => {
|
|
147
|
+
bindings.loginWithCode({ code }).catch(fail);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
101
150
|
async disconnect() {
|
|
102
151
|
this.clearSession();
|
|
103
152
|
if (!this.bindings) return;
|
|
104
|
-
await this.
|
|
153
|
+
await this.whenReady();
|
|
154
|
+
const bindings = this.currentBindings();
|
|
155
|
+
if (!bindings) return;
|
|
156
|
+
await bindings.logout();
|
|
157
|
+
}
|
|
158
|
+
currentBindings() {
|
|
159
|
+
return this.bindings;
|
|
160
|
+
}
|
|
161
|
+
whenReady(timeoutMs = 1e4) {
|
|
162
|
+
if (this.state.ready) return Promise.resolve();
|
|
163
|
+
return new Promise((resolve) => {
|
|
164
|
+
const done = () => {
|
|
165
|
+
unsubscribe();
|
|
166
|
+
clearTimeout(timer);
|
|
167
|
+
resolve();
|
|
168
|
+
};
|
|
169
|
+
const unsubscribe = this.subscribeState((state) => {
|
|
170
|
+
if (state.ready) done();
|
|
171
|
+
});
|
|
172
|
+
const timer = setTimeout(done, timeoutMs);
|
|
173
|
+
});
|
|
105
174
|
}
|
|
106
175
|
};
|
|
107
176
|
function parseCaip2ChainId(caip2) {
|
|
@@ -118,7 +187,7 @@ function isAlreadyExistsError(error) {
|
|
|
118
187
|
return typeof error === "object" && error !== null && error.privyErrorCode === EMBEDDED_WALLET_ALREADY_EXISTS;
|
|
119
188
|
}
|
|
120
189
|
function PrivyAdapterBridge({ core }) {
|
|
121
|
-
const { ready, authenticated } = usePrivy();
|
|
190
|
+
const { ready, authenticated, user } = usePrivy();
|
|
122
191
|
const { wallets } = useWallets();
|
|
123
192
|
const { signTypedData } = useSignTypedData();
|
|
124
193
|
const { logout } = useLogout();
|
|
@@ -127,9 +196,12 @@ function PrivyAdapterBridge({ core }) {
|
|
|
127
196
|
} });
|
|
128
197
|
const { login: openLoginModal } = useLogin({ onError: (error) => core.handleLoginError(error) });
|
|
129
198
|
const { initOAuth } = useLoginWithOAuth({ onError: (error) => core.handleLoginError(error) });
|
|
199
|
+
const { sendCode, loginWithCode, state: emailState } = useLoginWithEmail({ onError: (error) => core.handleLoginError(error) });
|
|
130
200
|
const fnsRef = useRef({
|
|
131
201
|
openLoginModal,
|
|
132
202
|
initOAuth,
|
|
203
|
+
sendCode,
|
|
204
|
+
loginWithCode,
|
|
133
205
|
logout,
|
|
134
206
|
signTypedData,
|
|
135
207
|
createWallet
|
|
@@ -138,6 +210,8 @@ function PrivyAdapterBridge({ core }) {
|
|
|
138
210
|
fnsRef.current = {
|
|
139
211
|
openLoginModal,
|
|
140
212
|
initOAuth,
|
|
213
|
+
sendCode,
|
|
214
|
+
loginWithCode,
|
|
141
215
|
logout,
|
|
142
216
|
signTypedData,
|
|
143
217
|
createWallet
|
|
@@ -145,15 +219,34 @@ function PrivyAdapterBridge({ core }) {
|
|
|
145
219
|
}, [
|
|
146
220
|
openLoginModal,
|
|
147
221
|
initOAuth,
|
|
222
|
+
sendCode,
|
|
223
|
+
loginWithCode,
|
|
148
224
|
logout,
|
|
149
225
|
signTypedData,
|
|
150
226
|
createWallet
|
|
151
227
|
]);
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
core.syncState({
|
|
230
|
+
ready,
|
|
231
|
+
authenticated,
|
|
232
|
+
email: user?.email?.address,
|
|
233
|
+
emailStatus: emailState.status,
|
|
234
|
+
emailError: emailState.status === "error" ? emailState.error ?? void 0 : void 0
|
|
235
|
+
});
|
|
236
|
+
}, [
|
|
237
|
+
core,
|
|
238
|
+
ready,
|
|
239
|
+
authenticated,
|
|
240
|
+
user,
|
|
241
|
+
emailState
|
|
242
|
+
]);
|
|
152
243
|
const creatingWalletRef = useRef(false);
|
|
153
244
|
useEffect(() => {
|
|
154
245
|
return core.bind({
|
|
155
246
|
openLoginModal: (opts) => fnsRef.current.openLoginModal(opts),
|
|
156
247
|
initOAuth: (opts) => fnsRef.current.initOAuth(opts),
|
|
248
|
+
sendCode: (opts) => fnsRef.current.sendCode(opts),
|
|
249
|
+
loginWithCode: (opts) => fnsRef.current.loginWithCode(opts),
|
|
157
250
|
logout: () => fnsRef.current.logout(),
|
|
158
251
|
signTypedData: async (args, address) => {
|
|
159
252
|
return (await fnsRef.current.signTypedData(args, {
|
|
@@ -187,6 +280,32 @@ function PrivyAdapterBridge({ core }) {
|
|
|
187
280
|
return null;
|
|
188
281
|
}
|
|
189
282
|
//#endregion
|
|
283
|
+
//#region src/wallet/privy/client-config.ts
|
|
284
|
+
const DEFAULT_WALLET_LIST = ["detected_ethereum_wallets"];
|
|
285
|
+
function buildPrivyClientConfig({ methods, mode, accentColor, chain, walletList }) {
|
|
286
|
+
const pinned = chain;
|
|
287
|
+
return {
|
|
288
|
+
loginMethods: methods.map((method) => PRIVY_METHOD_MAP[method]),
|
|
289
|
+
appearance: {
|
|
290
|
+
theme: mode,
|
|
291
|
+
walletList: [...walletList ?? DEFAULT_WALLET_LIST],
|
|
292
|
+
...accentColor ? { accentColor } : {}
|
|
293
|
+
},
|
|
294
|
+
...pinned ? {
|
|
295
|
+
defaultChain: pinned,
|
|
296
|
+
supportedChains: [pinned]
|
|
297
|
+
} : {},
|
|
298
|
+
embeddedWallets: {
|
|
299
|
+
ethereum: { createOnLogin: "users-without-wallets" },
|
|
300
|
+
showWalletUIs: false
|
|
301
|
+
},
|
|
302
|
+
externalWallets: {
|
|
303
|
+
disableAllExternalWallets: true,
|
|
304
|
+
walletConnect: { enabled: false }
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
//#endregion
|
|
190
309
|
//#region src/wallet/privy/theme.ts
|
|
191
310
|
const HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
192
311
|
const RGB = /^rgba?\(\s*(-?[\d.]+)[\s,]+(-?[\d.]+)[\s,]+(-?[\d.]+)/i;
|
|
@@ -209,20 +328,19 @@ function createPrivyProvider(core, config) {
|
|
|
209
328
|
return function PrivyAuthProvider({ children, theme }) {
|
|
210
329
|
const { mode, accentColor } = normalizeWalletTheme(theme);
|
|
211
330
|
const accent = toPrivyAccentColor(accentColor);
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}), [mode, accent]);
|
|
331
|
+
const { chain, walletList } = config;
|
|
332
|
+
const privyConfig = useMemo(() => buildPrivyClientConfig({
|
|
333
|
+
methods: core.supportedMethods,
|
|
334
|
+
mode,
|
|
335
|
+
accentColor: accent,
|
|
336
|
+
chain,
|
|
337
|
+
walletList
|
|
338
|
+
}), [
|
|
339
|
+
mode,
|
|
340
|
+
accent,
|
|
341
|
+
chain,
|
|
342
|
+
walletList
|
|
343
|
+
]);
|
|
226
344
|
return /* @__PURE__ */ jsxs(PrivyProvider, {
|
|
227
345
|
appId: config.appId,
|
|
228
346
|
clientId: config.clientId,
|
|
@@ -237,15 +355,21 @@ function createPrivyAdapter(config) {
|
|
|
237
355
|
const core = new PrivyCore(resolvePrivyMethods(config.methods));
|
|
238
356
|
const Provider = createPrivyProvider(core, {
|
|
239
357
|
appId: config.appId,
|
|
240
|
-
clientId: config.clientId
|
|
358
|
+
clientId: config.clientId,
|
|
359
|
+
chain: config.chain,
|
|
360
|
+
walletList: config.walletList
|
|
241
361
|
});
|
|
242
362
|
function useController() {
|
|
243
|
-
return {
|
|
363
|
+
return useMemo(() => ({
|
|
244
364
|
connect: (method) => core.connect(method),
|
|
245
365
|
disconnect: () => core.disconnect(),
|
|
246
366
|
getSession: () => core.getSession(),
|
|
247
|
-
subscribe: (listener) => core.subscribe(listener)
|
|
248
|
-
|
|
367
|
+
subscribe: (listener) => core.subscribe(listener),
|
|
368
|
+
sendCode: (email, options) => core.sendCode(email, options),
|
|
369
|
+
loginWithCode: (code) => core.loginWithCode(code),
|
|
370
|
+
getState: () => core.getState(),
|
|
371
|
+
subscribeState: (listener) => core.subscribeState(listener)
|
|
372
|
+
}), []);
|
|
249
373
|
}
|
|
250
374
|
return {
|
|
251
375
|
Provider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","names":[],"sources":["../../../src/wallet/privy/adapter.ts","../../../src/wallet/privy/bridge.tsx","../../../src/wallet/privy/theme.ts","../../../src/wallet/privy/provider.tsx","../../../src/wallet/privy/factory.ts"],"sourcesContent":["import type {\n ConnectedWallet,\n LoginModalOptions,\n SignTypedDataParams,\n} from \"@privy-io/react-auth\";\nimport type { SignCredentialTypedData } from \"../../credential.js\";\nimport { LoginMethod, type WalletSession } from \"../types.js\";\nimport type { PrivyLoginMethod } from \"./meta.js\";\n\ntype Hex = `0x${string}`;\ntype PrivyLoginMethodId = NonNullable<\n LoginModalOptions[\"loginMethods\"]\n>[number];\n\n// Exhaustive over PrivyLoginMethod, so widening that union without adding the\n// Privy id here is a compile error.\nconst PRIVY_METHOD_MAP: Record<PrivyLoginMethod, PrivyLoginMethodId> = {\n [LoginMethod.WALLET]: \"wallet\",\n [LoginMethod.GOOGLE]: \"google\",\n [LoginMethod.APPLE]: \"apple\",\n [LoginMethod.EMAIL]: \"email\",\n};\n\ntype PrivyOAuthProviderId = \"google\" | \"apple\";\n\n// Methods Privy can start headlessly with initOAuth. Opening the modal for these\n// would only render a single button for a provider the caller already picked.\nconst PRIVY_OAUTH_PROVIDERS: Partial<\n Record<LoginMethod, PrivyOAuthProviderId>\n> = {\n [LoginMethod.GOOGLE]: \"google\",\n [LoginMethod.APPLE]: \"apple\",\n};\n\n// Privy React functions captured by <PrivyAdapterBridge> via bind(). Until bind\n// runs, connect/disconnect calls throw.\nexport interface PrivyBindings {\n openLoginModal: (options?: LoginModalOptions) => void;\n initOAuth: (options: { provider: PrivyOAuthProviderId }) => Promise<void>;\n logout: () => Promise<void>;\n signTypedData: (\n args: Parameters<SignCredentialTypedData>[0],\n address: Hex,\n ) => Promise<Hex>;\n}\n\ninterface PendingLogin {\n resolve(session: WalletSession): void;\n reject(error: Error): void;\n}\n\n// Framework-agnostic core the bridge drives. Holds the session and pending\n// login promise so the class can operate Privy without owning React state.\nexport class PrivyCore {\n readonly supportedMethods: LoginMethod[];\n\n private bindings: PrivyBindings | null = null;\n private pending: PendingLogin | null = null;\n private session: WalletSession | undefined = undefined;\n private listeners = new Set<(session: WalletSession | undefined) => void>();\n\n constructor(supportedMethods: LoginMethod[]) {\n this.supportedMethods = supportedMethods;\n }\n\n bind(bindings: PrivyBindings): () => void {\n this.bindings = bindings;\n return () => {\n if (this.bindings === bindings) this.bindings = null;\n };\n }\n\n getSession(): WalletSession | undefined {\n return this.session;\n }\n\n // Push session changes to subscribers, replaying the current one on subscribe.\n // Lets the host complete sign-in when a session arrives with no pending connect().\n subscribe(\n listener: (session: WalletSession | undefined) => void,\n ): () => void {\n this.listeners.add(listener);\n if (this.session) listener(this.session);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n private emit(session: WalletSession | undefined): void {\n for (const listener of this.listeners) listener(session);\n }\n\n // Called by the bridge when the embedded wallet is available. Builds the\n // session and resolves any pending login promise.\n syncFromEmbeddedWallet(wallet: ConnectedWallet): void {\n const address = wallet.address as Hex;\n const chainId = parseCaip2ChainId(wallet.chainId);\n\n const signTypedData: SignCredentialTypedData = async (args) => {\n if (!this.bindings) {\n throw new Error(\"PrivyAdapter not bound (bridge not mounted)\");\n }\n return this.bindings.signTypedData(args, address);\n };\n\n // Privy's embedded wallet signs without a prompt, so a host may auto-complete\n // sign-in with this session after a full-page OAuth redirect return.\n const session: WalletSession = {\n address,\n chainId,\n signTypedData,\n canSignSilently: true,\n };\n this.session = session;\n // A live connect() (in-page popup flow) consumes the session via its promise;\n // otherwise the promise died with the pre-redirect page, so emit to subscribers.\n if (this.pending) {\n this.pending.resolve(session);\n this.pending = null;\n } else {\n this.emit(session);\n }\n }\n\n clearSession(): void {\n this.session = undefined;\n this.emit(undefined);\n }\n\n // Called by the bridge on Privy's onError. String codes like `exited_auth_flow`\n // mean the user dismissed the modal.\n handleLoginError(error: unknown): void {\n if (!this.pending) return;\n const err = error instanceof Error ? error : new Error(String(error));\n this.pending.reject(err);\n this.pending = null;\n }\n\n async connect(method?: LoginMethod): Promise<WalletSession> {\n if (this.session) return this.session;\n if (!this.bindings) {\n throw new Error(\n \"PrivyAdapter not bound. Ensure the adapter Provider wraps the app.\",\n );\n }\n\n const chosen = method ?? this.supportedMethods.at(0);\n if (!chosen) {\n throw new Error(\"PrivyAdapter has no supported login methods configured\");\n }\n // PRIVY_METHOD_MAP is total over the methods Privy can drive, so only the\n // configured subset needs checking here.\n if (!this.supportedMethods.includes(chosen)) {\n throw new Error(`PrivyAdapter does not support login method \"${chosen}\"`);\n }\n const privyMethod = PRIVY_METHOD_MAP[chosen];\n\n const bindings = this.bindings;\n const oauthProvider = PRIVY_OAUTH_PROVIDERS[chosen];\n return new Promise<WalletSession>((resolve, reject) => {\n this.pending = { resolve, reject };\n const fail = (error: unknown) => {\n this.pending = null;\n reject(error instanceof Error ? error : new Error(String(error)));\n };\n try {\n // initOAuth navigates away, so this promise stays pending until the page\n // unloads; syncFromEmbeddedWallet emits the session on the redirect back.\n if (oauthProvider) {\n bindings.initOAuth({ provider: oauthProvider }).catch(fail);\n } else {\n bindings.openLoginModal({ loginMethods: [privyMethod] });\n }\n } catch (error) {\n fail(error);\n }\n });\n }\n\n async disconnect(): Promise<void> {\n this.clearSession();\n if (!this.bindings) return;\n await this.bindings.logout();\n }\n}\n\nfunction parseCaip2ChainId(caip2: string): number {\n const last = caip2.split(\":\").at(-1);\n const n = Number(last);\n if (!Number.isFinite(n)) {\n throw new Error(\n `PrivyAdapter: could not parse chainId from CAIP-2 \"${caip2}\"`,\n );\n }\n return n;\n}\n\nexport type { SignTypedDataParams };\n","import { useEffect, useRef } from \"react\";\nimport {\n getEmbeddedConnectedWallet,\n useCreateWallet,\n useLogin,\n useLoginWithOAuth,\n useLogout,\n usePrivy,\n useSignTypedData,\n useWallets,\n} from \"@privy-io/react-auth\";\nimport type { PrivyCore, SignTypedDataParams } from \"./adapter.js\";\n\ntype Hex = `0x${string}`;\n\n// PrivyErrorCode is declared in the types but not exported at runtime, so match\n// the code by value.\nconst EMBEDDED_WALLET_ALREADY_EXISTS = \"embedded_wallet_already_exists\";\n\n// onError is typed as the bare code, but Privy's error class carries it on\n// `privyErrorCode`, so accept either rather than trusting toString().\nfunction isAlreadyExistsError(error: unknown): boolean {\n if (error === EMBEDDED_WALLET_ALREADY_EXISTS) return true;\n return (\n typeof error === \"object\" &&\n error !== null &&\n (error as { privyErrorCode?: unknown }).privyErrorCode ===\n EMBEDDED_WALLET_ALREADY_EXISTS\n );\n}\n\ninterface PrivyAdapterBridgeProps {\n core: PrivyCore;\n}\n\n// Captures the React-only Privy hooks and wires them into PrivyCore so the\n// class can drive Privy without owning React state. Mounted inside PrivyProvider.\nexport function PrivyAdapterBridge({ core }: PrivyAdapterBridgeProps) {\n const { ready, authenticated } = usePrivy();\n const { wallets } = useWallets();\n const { signTypedData } = useSignTypedData();\n const { logout } = useLogout();\n const { createWallet } = useCreateWallet({\n // A wallet that already exists still arrives through useWallets(), so that\n // code is not a login failure.\n onError: (error) => {\n if (!isAlreadyExistsError(error)) core.handleLoginError(error);\n },\n });\n const { login: openLoginModal } = useLogin({\n onError: (error) => core.handleLoginError(error),\n });\n // Also mounts this hook on the page Privy redirects back to, which is what\n // lets it finish the OAuth flow there.\n const { initOAuth } = useLoginWithOAuth({\n onError: (error) => core.handleLoginError(error),\n });\n\n // Privy returns fresh function references each render. A ref keeps the bind\n // stable so we bind once per core instead of re-binding every render.\n const fnsRef = useRef({\n openLoginModal,\n initOAuth,\n logout,\n signTypedData,\n createWallet,\n });\n useEffect(() => {\n fnsRef.current = {\n openLoginModal,\n initOAuth,\n logout,\n signTypedData,\n createWallet,\n };\n }, [openLoginModal, initOAuth, logout, signTypedData, createWallet]);\n\n // One attempt per authenticated session, reset on logout.\n const creatingWalletRef = useRef(false);\n\n useEffect(() => {\n return core.bind({\n openLoginModal: (opts) => fnsRef.current.openLoginModal(opts),\n initOAuth: (opts) => fnsRef.current.initOAuth(opts),\n logout: () => fnsRef.current.logout(),\n // Privy owns the embedded wallet keys, so showWalletUIs:false signs the\n // credential typed-data silently as part of login.\n signTypedData: async (args, address) => {\n const result = await fnsRef.current.signTypedData(\n args as unknown as SignTypedDataParams,\n { address, uiOptions: { showWalletUIs: false } },\n );\n return result.signature as Hex;\n },\n });\n }, [core]);\n\n useEffect(() => {\n if (!ready) return;\n if (!authenticated) {\n core.clearSession();\n creatingWalletRef.current = false;\n return;\n }\n const embedded = getEmbeddedConnectedWallet(wallets);\n if (embedded) {\n core.syncFromEmbeddedWallet(embedded);\n return;\n }\n // `createOnLogin` only fires for Privy's own modal, so initOAuth logins\n // reach here with no wallet. Privy's docs prescribe creating it manually.\n if (creatingWalletRef.current) return;\n creatingWalletRef.current = true;\n // Failures are reported through useCreateWallet's onError; this only keeps\n // the rejection from surfacing as an unhandled one.\n void fnsRef.current.createWallet().catch(() => undefined);\n }, [core, ready, authenticated, wallets]);\n\n return null;\n}\n","const HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst RGB = /^rgba?\\(\\s*(-?[\\d.]+)[\\s,]+(-?[\\d.]+)[\\s,]+(-?[\\d.]+)/i;\n\nfunction channel(value: string): string {\n const byte = Math.round(Number(value));\n return Math.min(255, Math.max(0, byte)).toString(16).padStart(2, \"0\");\n}\n\n/** Convert a host theme accent color to the hex Privy's `appearance` requires, or `undefined` if it is not expressible. Hosts resolve CSS tokens through `getComputedStyle`, which yields `rgb(...)`, so plain pass-through would be rejected. Alpha is dropped: Privy derives its own variants. */\nexport function toPrivyAccentColor(\n color: string | undefined,\n): `#${string}` | undefined {\n if (!color) return undefined;\n const value = color.trim();\n if (HEX.test(value)) return value as `#${string}`;\n const rgb = RGB.exec(value);\n if (!rgb) return undefined;\n return `#${channel(rgb[1])}${channel(rgb[2])}${channel(rgb[3])}`;\n}\n","import { useMemo, type ComponentType, type ReactNode } from \"react\";\nimport { PrivyProvider, type PrivyClientConfig } from \"@privy-io/react-auth\";\nimport { normalizeWalletTheme, type WalletTheme } from \"../types.js\";\nimport type { PrivyCore } from \"./adapter.js\";\nimport { PrivyAdapterBridge } from \"./bridge.js\";\nimport { toPrivyAccentColor } from \"./theme.js\";\n\ninterface PrivyProviderConfig {\n appId: string;\n clientId?: string;\n}\n\n// Build the adapter Provider bound to a specific core + config. Mounts\n// PrivyProvider with embedded wallets + showWalletUIs:false for silent signing.\nexport function createPrivyProvider(\n core: PrivyCore,\n config: PrivyProviderConfig,\n): ComponentType<{ children: ReactNode; theme?: WalletTheme }> {\n return function PrivyAuthProvider({\n children,\n theme,\n }: {\n children: ReactNode;\n theme?: WalletTheme;\n }) {\n const { mode, accentColor } = normalizeWalletTheme(theme);\n const accent = toPrivyAccentColor(accentColor);\n // Memoize so a new config object per render doesn't rebuild PrivyProvider's\n // context and cascade re-renders into descendants.\n const privyConfig = useMemo<PrivyClientConfig>(\n () => ({\n // Privy generates its own light/dark variants from the accent.\n appearance: { theme: mode, ...(accent ? { accentColor: accent } : {}) },\n embeddedWallets: {\n ethereum: { createOnLogin: \"users-without-wallets\" as const },\n showWalletUIs: false,\n },\n // Social/email adapter only (external wallets go through the rainbow\n // adapter), so don't init WalletConnect / fetch its registry on mount.\n externalWallets: {\n disableAllExternalWallets: true,\n walletConnect: { enabled: false },\n },\n }),\n [mode, accent],\n );\n\n return (\n <PrivyProvider\n appId={config.appId}\n clientId={config.clientId}\n config={privyConfig}\n >\n <PrivyAdapterBridge core={core} />\n {children}\n </PrivyProvider>\n );\n };\n}\n","// Renders React (PrivyProvider + hooks), so RSC hosts must treat this as a\n// client module even though the descriptor entry reaches it lazily.\n\"use client\";\n\nimport type { WalletAdapterImpl, WalletController } from \"../types.js\";\nimport { PrivyCore } from \"./adapter.js\";\nimport {\n resolvePrivyMethods,\n type PHRenownPrivyAdapterConfig,\n} from \"./meta.js\";\nimport { createPrivyProvider } from \"./provider.js\";\n\n// Build the Privy adapter. Provider mounts PrivyProvider + a bridge;\n// useController exposes imperative connect/disconnect over the shared core.\nexport function createPrivyAdapter(\n config: PHRenownPrivyAdapterConfig,\n): WalletAdapterImpl {\n const core = new PrivyCore(resolvePrivyMethods(config.methods));\n const Provider = createPrivyProvider(core, {\n appId: config.appId,\n clientId: config.clientId,\n });\n\n function useController(): WalletController {\n return {\n connect: (method) => core.connect(method),\n disconnect: () => core.disconnect(),\n getSession: () => core.getSession(),\n subscribe: (listener) => core.subscribe(listener),\n };\n }\n\n return { Provider, useController };\n}\n\nexport { PrivyCore } from \"./adapter.js\";\nexport type { PrivyBindings } from \"./adapter.js\";\nexport { PrivyAdapterBridge } from \"./bridge.js\";\nexport { createPrivyProvider } from \"./provider.js\";\n"],"mappings":";;;;;;;AAgBA,MAAM,mBAAiE;EACpE,YAAY,SAAS;EACrB,YAAY,SAAS;EACrB,YAAY,QAAQ;EACpB,YAAY,QAAQ;CACtB;AAMD,MAAM,wBAEF;EACD,YAAY,SAAS;EACrB,YAAY,QAAQ;CACtB;AAqBD,IAAa,YAAb,MAAuB;CACrB;CAEA,WAAyC;CACzC,UAAuC;CACvC,UAA6C,KAAA;CAC7C,4BAAoB,IAAI,KAAmD;CAE3E,YAAY,kBAAiC;AAC3C,OAAK,mBAAmB;;CAG1B,KAAK,UAAqC;AACxC,OAAK,WAAW;AAChB,eAAa;AACX,OAAI,KAAK,aAAa,SAAU,MAAK,WAAW;;;CAIpD,aAAwC;AACtC,SAAO,KAAK;;CAKd,UACE,UACY;AACZ,OAAK,UAAU,IAAI,SAAS;AAC5B,MAAI,KAAK,QAAS,UAAS,KAAK,QAAQ;AACxC,eAAa;AACX,QAAK,UAAU,OAAO,SAAS;;;CAInC,KAAa,SAA0C;AACrD,OAAK,MAAM,YAAY,KAAK,UAAW,UAAS,QAAQ;;CAK1D,uBAAuB,QAA+B;EACpD,MAAM,UAAU,OAAO;EACvB,MAAM,UAAU,kBAAkB,OAAO,QAAQ;EAEjD,MAAM,gBAAyC,OAAO,SAAS;AAC7D,OAAI,CAAC,KAAK,SACR,OAAM,IAAI,MAAM,8CAA8C;AAEhE,UAAO,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AAM,cAAc,eACX;GAEL,YAAY;IAAE,OAAO;IAAM,GAAI,SAAS,EAAE,aAAa,QAAQ,GAAG,EAAE;IAAG;GACvE,iBAAiB;IACf,UAAU,EAAE,eAAe,yBAAkC;IAC7D,eAAe;IAChB;GAGD,iBAAiB;IACf,2BAA2B;IAC3B,eAAe,EAAE,SAAS,OAAO;IAClC;GACF,GACD,CAAC,MAAM,OAAO,CACf;AAED,SACE,qBAAC,eAAD;GACE,OAAO,OAAO;GACd,UAAU,OAAO;GACjB,QAAQ;aAHV,CAKE,oBAAC,oBAAD,EAA0B,MAAQ,CAAA,EACjC,SACa;;;;;;ACzCtB,SAAgB,mBACd,QACmB;CACnB,MAAM,OAAO,IAAI,UAAU,oBAAoB,OAAO,QAAQ,CAAC;CAC/D,MAAM,WAAW,oBAAoB,MAAM;EACzC,OAAO,OAAO;EACd,UAAU,OAAO;EAClB,CAAC;CAEF,SAAS,gBAAkC;AACzC,SAAO;GACL,UAAU,WAAW,KAAK,QAAQ,OAAO;GACzC,kBAAkB,KAAK,YAAY;GACnC,kBAAkB,KAAK,YAAY;GACnC,YAAY,aAAa,KAAK,UAAU,SAAS;GAClD;;AAGH,QAAO;EAAE;EAAU;EAAe"}
|
|
1
|
+
{"version":3,"file":"factory.js","names":[],"sources":["../../../src/wallet/privy/adapter.ts","../../../src/wallet/privy/bridge.tsx","../../../src/wallet/privy/client-config.ts","../../../src/wallet/privy/theme.ts","../../../src/wallet/privy/provider.tsx","../../../src/wallet/privy/factory.ts"],"sourcesContent":["import type {\n ConnectedWallet,\n LoginModalOptions,\n SignTypedDataParams,\n} from \"@privy-io/react-auth\";\nimport type { SignCredentialTypedData } from \"../../credential.js\";\nimport { LoginMethod, type WalletSession } from \"../types.js\";\nimport type { PrivyLoginMethod } from \"./meta.js\";\nimport type { PrivyAuthState, SendCodeOptions } from \"./types.js\";\n\ntype Hex = `0x${string}`;\ntype PrivyLoginMethodId = NonNullable<\n LoginModalOptions[\"loginMethods\"]\n>[number];\n\n// Exhaustive over PrivyLoginMethod, so widening that union without adding the\n// Privy id here is a compile error.\nexport const PRIVY_METHOD_MAP: Record<PrivyLoginMethod, PrivyLoginMethodId> = {\n [LoginMethod.WALLET]: \"wallet\",\n [LoginMethod.GOOGLE]: \"google\",\n [LoginMethod.APPLE]: \"apple\",\n [LoginMethod.EMAIL]: \"email\",\n};\n\ntype PrivyOAuthProviderId = \"google\" | \"apple\";\n\n// Methods Privy can start headlessly with initOAuth. Opening the modal for these\n// would only render a single button for a provider the caller already picked.\nconst PRIVY_OAUTH_PROVIDERS: Partial<\n Record<LoginMethod, PrivyOAuthProviderId>\n> = {\n [LoginMethod.GOOGLE]: \"google\",\n [LoginMethod.APPLE]: \"apple\",\n};\n\n// Privy React functions captured by <PrivyAdapterBridge> via bind(). Until bind\n// runs, connect/disconnect calls throw.\nexport interface PrivyBindings {\n openLoginModal: (options?: LoginModalOptions) => void;\n initOAuth: (options: { provider: PrivyOAuthProviderId }) => Promise<void>;\n sendCode: (options: {\n email: string;\n disableSignup?: boolean;\n }) => Promise<void>;\n loginWithCode: (options: { code: string }) => Promise<void>;\n logout: () => Promise<void>;\n signTypedData: (\n args: Parameters<SignCredentialTypedData>[0],\n address: Hex,\n ) => Promise<Hex>;\n}\n\nconst INITIAL_STATE: PrivyAuthState = {\n ready: false,\n authenticated: false,\n emailStatus: \"initial\",\n};\n\ninterface PendingLogin {\n resolve(session: WalletSession): void;\n reject(error: Error): void;\n}\n\n// Framework-agnostic core the bridge drives. Holds the session and pending\n// login promise so the class can operate Privy without owning React state.\nexport class PrivyCore {\n readonly supportedMethods: LoginMethod[];\n\n private bindings: PrivyBindings | null = null;\n private pending: PendingLogin | null = null;\n private session: WalletSession | undefined = undefined;\n private listeners = new Set<(session: WalletSession | undefined) => void>();\n private state: PrivyAuthState = INITIAL_STATE;\n private stateListeners = new Set<(state: PrivyAuthState) => void>();\n\n constructor(supportedMethods: LoginMethod[]) {\n this.supportedMethods = supportedMethods;\n }\n\n bind(bindings: PrivyBindings): () => void {\n this.bindings = bindings;\n return () => {\n if (this.bindings === bindings) this.bindings = null;\n };\n }\n\n getSession(): WalletSession | undefined {\n return this.session;\n }\n\n // Push session changes to subscribers, replaying the current one on subscribe.\n // Lets the host complete sign-in when a session arrives with no pending connect().\n subscribe(\n listener: (session: WalletSession | undefined) => void,\n ): () => void {\n this.listeners.add(listener);\n if (this.session) listener(this.session);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n private emit(session: WalletSession | undefined): void {\n for (const listener of this.listeners) listener(session);\n }\n\n getState(): PrivyAuthState {\n return this.state;\n }\n\n subscribeState(listener: (state: PrivyAuthState) => void): () => void {\n this.stateListeners.add(listener);\n return () => {\n this.stateListeners.delete(listener);\n };\n }\n\n // Called by the bridge whenever Privy's auth/OTP state changes. Identity-stable\n // while unchanged so useSyncExternalStore consumers don't re-render.\n syncState(next: PrivyAuthState): void {\n const prev = this.state;\n if (\n prev.ready === next.ready &&\n prev.authenticated === next.authenticated &&\n prev.email === next.email &&\n prev.emailStatus === next.emailStatus &&\n prev.emailError === next.emailError\n ) {\n return;\n }\n this.state = next;\n for (const listener of this.stateListeners) listener(next);\n }\n\n // Called by the bridge when the embedded wallet is available. Builds the\n // session and resolves any pending login promise.\n syncFromEmbeddedWallet(wallet: ConnectedWallet): void {\n const address = wallet.address as Hex;\n const chainId = parseCaip2ChainId(wallet.chainId);\n\n const signTypedData: SignCredentialTypedData = async (args) => {\n if (!this.bindings) {\n throw new Error(\"PrivyAdapter not bound (bridge not mounted)\");\n }\n return this.bindings.signTypedData(args, address);\n };\n\n // Privy's embedded wallet signs without a prompt, so a host may auto-complete\n // sign-in with this session after a full-page OAuth redirect return.\n const session: WalletSession = {\n address,\n chainId,\n signTypedData,\n canSignSilently: true,\n };\n this.session = session;\n // A live connect() (in-page popup flow) consumes the session via its promise;\n // otherwise the promise died with the pre-redirect page, so emit to subscribers.\n if (this.pending) {\n this.pending.resolve(session);\n this.pending = null;\n } else {\n this.emit(session);\n }\n }\n\n clearSession(): void {\n this.session = undefined;\n this.emit(undefined);\n }\n\n // Called by the bridge on Privy's onError. String codes like `exited_auth_flow`\n // mean the user dismissed the modal.\n handleLoginError(error: unknown): void {\n if (!this.pending) return;\n const err = error instanceof Error ? error : new Error(String(error));\n this.pending.reject(err);\n this.pending = null;\n }\n\n private requireBindings(): PrivyBindings {\n if (!this.bindings) {\n throw new Error(\n \"PrivyAdapter not bound. Ensure the adapter Provider wraps the app.\",\n );\n }\n return this.bindings;\n }\n\n private requireMethod(method: LoginMethod): void {\n if (!this.supportedMethods.includes(method)) {\n throw new Error(`PrivyAdapter does not support login method \"${method}\"`);\n }\n }\n\n // Resolves via syncFromEmbeddedWallet once the embedded wallet arrives, or\n // rejects through handleLoginError / the start() failure.\n private awaitSession(\n start: (fail: (error: unknown) => void) => void,\n ): Promise<WalletSession> {\n // One login at a time: replacing `pending` would orphan the earlier promise.\n if (this.pending) {\n return Promise.reject(\n new Error(\"PrivyAdapter: a login is already in progress\"),\n );\n }\n return new Promise<WalletSession>((resolve, reject) => {\n this.pending = { resolve, reject };\n const fail = (error: unknown) => {\n this.pending = null;\n reject(error instanceof Error ? error : new Error(String(error)));\n };\n try {\n start(fail);\n } catch (error) {\n fail(error);\n }\n });\n }\n\n async connect(method?: LoginMethod): Promise<WalletSession> {\n if (this.session) return this.session;\n const bindings = this.requireBindings();\n\n const chosen = method ?? this.supportedMethods.at(0);\n if (!chosen) {\n throw new Error(\"PrivyAdapter has no supported login methods configured\");\n }\n // PRIVY_METHOD_MAP is total over the methods Privy can drive, so only the\n // configured subset needs checking here.\n this.requireMethod(chosen);\n const privyMethod = PRIVY_METHOD_MAP[chosen];\n const oauthProvider = PRIVY_OAUTH_PROVIDERS[chosen];\n\n return this.awaitSession((fail) => {\n // initOAuth navigates away, so this promise stays pending until the page\n // unloads; syncFromEmbeddedWallet emits the session on the redirect back.\n if (oauthProvider) {\n bindings.initOAuth({ provider: oauthProvider }).catch(fail);\n } else {\n bindings.openLoginModal({ loginMethods: [privyMethod] });\n }\n });\n }\n\n async sendCode(email: string, options?: SendCodeOptions): Promise<void> {\n this.requireMethod(LoginMethod.EMAIL);\n await this.requireBindings().sendCode({\n email,\n disableSignup: options?.disableSignup,\n });\n }\n\n async loginWithCode(code: string): Promise<WalletSession> {\n if (this.session) return this.session;\n this.requireMethod(LoginMethod.EMAIL);\n const bindings = this.requireBindings();\n // loginWithCode resolves on authentication; the wallet follows through the\n // bridge (useWallets, or createWallet for a first login).\n return this.awaitSession((fail) => {\n bindings.loginWithCode({ code }).catch(fail);\n });\n }\n\n async disconnect(): Promise<void> {\n this.clearSession();\n if (!this.bindings) return;\n // When mounted on demand for this logout, Privy may still be restoring its\n // session; its logout needs that to finish.\n await this.whenReady();\n // Re-read: the bridge may have unmounted during the wait.\n const bindings = this.currentBindings();\n if (!bindings) return;\n await bindings.logout();\n }\n\n private currentBindings(): PrivyBindings | null {\n return this.bindings;\n }\n\n private whenReady(timeoutMs = 10_000): Promise<void> {\n if (this.state.ready) return Promise.resolve();\n return new Promise((resolve) => {\n const done = () => {\n unsubscribe();\n clearTimeout(timer);\n resolve();\n };\n const unsubscribe = this.subscribeState((state) => {\n if (state.ready) done();\n });\n const timer = setTimeout(done, timeoutMs);\n });\n }\n}\n\nfunction parseCaip2ChainId(caip2: string): number {\n const last = caip2.split(\":\").at(-1);\n const n = Number(last);\n if (!Number.isFinite(n)) {\n throw new Error(\n `PrivyAdapter: could not parse chainId from CAIP-2 \"${caip2}\"`,\n );\n }\n return n;\n}\n\nexport type { SignTypedDataParams };\n","import { useEffect, useRef } from \"react\";\nimport {\n getEmbeddedConnectedWallet,\n useCreateWallet,\n useLogin,\n useLoginWithEmail,\n useLoginWithOAuth,\n useLogout,\n usePrivy,\n useSignTypedData,\n useWallets,\n} from \"@privy-io/react-auth\";\nimport type { PrivyCore, SignTypedDataParams } from \"./adapter.js\";\n\ntype Hex = `0x${string}`;\n\n// PrivyErrorCode is declared in the types but not exported at runtime, so match\n// the code by value.\nconst EMBEDDED_WALLET_ALREADY_EXISTS = \"embedded_wallet_already_exists\";\n\n// onError is typed as the bare code, but Privy's error class carries it on\n// `privyErrorCode`, so accept either rather than trusting toString().\nfunction isAlreadyExistsError(error: unknown): boolean {\n if (error === EMBEDDED_WALLET_ALREADY_EXISTS) return true;\n return (\n typeof error === \"object\" &&\n error !== null &&\n (error as { privyErrorCode?: unknown }).privyErrorCode ===\n EMBEDDED_WALLET_ALREADY_EXISTS\n );\n}\n\ninterface PrivyAdapterBridgeProps {\n core: PrivyCore;\n}\n\n// Captures the React-only Privy hooks and wires them into PrivyCore so the\n// class can drive Privy without owning React state. Mounted inside PrivyProvider.\nexport function PrivyAdapterBridge({ core }: PrivyAdapterBridgeProps) {\n const { ready, authenticated, user } = usePrivy();\n const { wallets } = useWallets();\n const { signTypedData } = useSignTypedData();\n const { logout } = useLogout();\n const { createWallet } = useCreateWallet({\n // A wallet that already exists still arrives through useWallets(), so that\n // code is not a login failure.\n onError: (error) => {\n if (!isAlreadyExistsError(error)) core.handleLoginError(error);\n },\n });\n const { login: openLoginModal } = useLogin({\n onError: (error) => core.handleLoginError(error),\n });\n // Also mounts this hook on the page Privy redirects back to, which is what\n // lets it finish the OAuth flow there.\n const { initOAuth } = useLoginWithOAuth({\n onError: (error) => core.handleLoginError(error),\n });\n // Headless email OTP for hosts drawing their own screens (see PrivyWalletController).\n const {\n sendCode,\n loginWithCode,\n state: emailState,\n } = useLoginWithEmail({\n onError: (error) => core.handleLoginError(error),\n });\n\n // Privy returns fresh function references each render. A ref keeps the bind\n // stable so we bind once per core instead of re-binding every render.\n const fnsRef = useRef({\n openLoginModal,\n initOAuth,\n sendCode,\n loginWithCode,\n logout,\n signTypedData,\n createWallet,\n });\n useEffect(() => {\n fnsRef.current = {\n openLoginModal,\n initOAuth,\n sendCode,\n loginWithCode,\n logout,\n signTypedData,\n createWallet,\n };\n }, [\n openLoginModal,\n initOAuth,\n sendCode,\n loginWithCode,\n logout,\n signTypedData,\n createWallet,\n ]);\n\n useEffect(() => {\n core.syncState({\n ready,\n authenticated,\n email: user?.email?.address,\n emailStatus: emailState.status,\n emailError:\n emailState.status === \"error\"\n ? (emailState.error ?? undefined)\n : undefined,\n });\n }, [core, ready, authenticated, user, emailState]);\n\n // One attempt per authenticated session, reset on logout.\n const creatingWalletRef = useRef(false);\n\n useEffect(() => {\n return core.bind({\n openLoginModal: (opts) => fnsRef.current.openLoginModal(opts),\n initOAuth: (opts) => fnsRef.current.initOAuth(opts),\n sendCode: (opts) => fnsRef.current.sendCode(opts),\n loginWithCode: (opts) => fnsRef.current.loginWithCode(opts),\n logout: () => fnsRef.current.logout(),\n // Privy owns the embedded wallet keys, so showWalletUIs:false signs the\n // credential typed-data silently as part of login.\n signTypedData: async (args, address) => {\n const result = await fnsRef.current.signTypedData(\n args as unknown as SignTypedDataParams,\n { address, uiOptions: { showWalletUIs: false } },\n );\n return result.signature as Hex;\n },\n });\n }, [core]);\n\n useEffect(() => {\n if (!ready) return;\n if (!authenticated) {\n core.clearSession();\n creatingWalletRef.current = false;\n return;\n }\n const embedded = getEmbeddedConnectedWallet(wallets);\n if (embedded) {\n core.syncFromEmbeddedWallet(embedded);\n return;\n }\n // `createOnLogin` only fires for Privy's own modal, so initOAuth logins\n // reach here with no wallet. Privy's docs prescribe creating it manually.\n if (creatingWalletRef.current) return;\n creatingWalletRef.current = true;\n // Failures are reported through useCreateWallet's onError; this only keeps\n // the rejection from surfacing as an unhandled one.\n void fnsRef.current.createWallet().catch(() => undefined);\n }, [core, ready, authenticated, wallets]);\n\n return null;\n}\n","import type { PrivyClientConfig, WalletListEntry } from \"@privy-io/react-auth\";\nimport type { Chain } from \"viem\";\nimport type { LoginMethod } from \"../types.js\";\nimport { PRIVY_METHOD_MAP } from \"./adapter.js\";\nimport type { PrivyChain } from \"./meta.js\";\n\n// Privy's provider root fetches the WalletConnect explorer listings on mount\n// unless walletList needs none; externalWallets.* and loginMethods don't gate it.\nexport const DEFAULT_WALLET_LIST: readonly WalletListEntry[] = [\n \"detected_ethereum_wallets\",\n];\n\nexport interface PrivyClientConfigInput {\n methods: LoginMethod[];\n mode: \"light\" | \"dark\";\n accentColor?: `#${string}`;\n chain?: PrivyChain;\n walletList?: string[];\n}\n\n// Pure so the config shape is testable without mounting PrivyProvider.\nexport function buildPrivyClientConfig({\n methods,\n mode,\n accentColor,\n chain,\n walletList,\n}: PrivyClientConfigInput): PrivyClientConfig {\n // PrivyChain is the structural subset every viem Chain satisfies.\n const pinned = chain as Chain | undefined;\n return {\n // Only the configured methods, so Privy skips the connectors (e.g.\n // WalletConnect) that the unlisted ones would initialize.\n loginMethods: methods.map((method) => PRIVY_METHOD_MAP[method]),\n appearance: {\n // Privy generates its own light/dark variants from the accent.\n theme: mode,\n // Config arrives from JSON, so entries are unvalidated here.\n walletList: [...(walletList ?? DEFAULT_WALLET_LIST)] as WalletListEntry[],\n ...(accentColor ? { accentColor } : {}),\n },\n // Renown rejects a wallet on any chain but the one it issues on.\n ...(pinned ? { defaultChain: pinned, supportedChains: [pinned] } : {}),\n embeddedWallets: {\n ethereum: { createOnLogin: \"users-without-wallets\" },\n showWalletUIs: false,\n },\n // Social/email adapter only (external wallets go through the rainbow\n // adapter), so don't init WalletConnect / fetch its registry on mount.\n externalWallets: {\n disableAllExternalWallets: true,\n walletConnect: { enabled: false },\n },\n };\n}\n","const HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst RGB = /^rgba?\\(\\s*(-?[\\d.]+)[\\s,]+(-?[\\d.]+)[\\s,]+(-?[\\d.]+)/i;\n\nfunction channel(value: string): string {\n const byte = Math.round(Number(value));\n return Math.min(255, Math.max(0, byte)).toString(16).padStart(2, \"0\");\n}\n\n/** Convert a host theme accent color to the hex Privy's `appearance` requires, or `undefined` if it is not expressible. Hosts resolve CSS tokens through `getComputedStyle`, which yields `rgb(...)`, so plain pass-through would be rejected. Alpha is dropped: Privy derives its own variants. */\nexport function toPrivyAccentColor(\n color: string | undefined,\n): `#${string}` | undefined {\n if (!color) return undefined;\n const value = color.trim();\n if (HEX.test(value)) return value as `#${string}`;\n const rgb = RGB.exec(value);\n if (!rgb) return undefined;\n return `#${channel(rgb[1])}${channel(rgb[2])}${channel(rgb[3])}`;\n}\n","import { useMemo, type ComponentType, type ReactNode } from \"react\";\nimport { PrivyProvider } from \"@privy-io/react-auth\";\nimport { normalizeWalletTheme, type WalletTheme } from \"../types.js\";\nimport type { PrivyCore } from \"./adapter.js\";\nimport { PrivyAdapterBridge } from \"./bridge.js\";\nimport { buildPrivyClientConfig } from \"./client-config.js\";\nimport type { PrivyChain } from \"./meta.js\";\nimport { toPrivyAccentColor } from \"./theme.js\";\n\ninterface PrivyProviderConfig {\n appId: string;\n clientId?: string;\n chain?: PrivyChain;\n walletList?: string[];\n}\n\n// Build the adapter Provider bound to a specific core + config. Mounts\n// PrivyProvider with embedded wallets + showWalletUIs:false for silent signing.\nexport function createPrivyProvider(\n core: PrivyCore,\n config: PrivyProviderConfig,\n): ComponentType<{ children: ReactNode; theme?: WalletTheme }> {\n return function PrivyAuthProvider({\n children,\n theme,\n }: {\n children: ReactNode;\n theme?: WalletTheme;\n }) {\n const { mode, accentColor } = normalizeWalletTheme(theme);\n const accent = toPrivyAccentColor(accentColor);\n const { chain, walletList } = config;\n // Memoize so a new config object per render doesn't rebuild PrivyProvider's\n // context and cascade re-renders into descendants.\n const privyConfig = useMemo(\n () =>\n buildPrivyClientConfig({\n methods: core.supportedMethods,\n mode,\n accentColor: accent,\n chain,\n walletList,\n }),\n [mode, accent, chain, walletList],\n );\n\n return (\n <PrivyProvider\n appId={config.appId}\n clientId={config.clientId}\n config={privyConfig}\n >\n <PrivyAdapterBridge core={core} />\n {children}\n </PrivyProvider>\n );\n };\n}\n","// Renders React (PrivyProvider + hooks), so RSC hosts must treat this as a\n// client module even though the descriptor entry reaches it lazily.\n\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { WalletAdapterImpl } from \"../types.js\";\nimport { PrivyCore } from \"./adapter.js\";\nimport type { PrivyWalletController } from \"./types.js\";\nimport {\n resolvePrivyMethods,\n type PHRenownPrivyAdapterConfig,\n} from \"./meta.js\";\nimport { createPrivyProvider } from \"./provider.js\";\n\n// Build the Privy adapter. Provider mounts PrivyProvider + a bridge;\n// useController exposes imperative connect/disconnect over the shared core.\nexport function createPrivyAdapter(\n config: PHRenownPrivyAdapterConfig,\n): WalletAdapterImpl {\n const core = new PrivyCore(resolvePrivyMethods(config.methods));\n const Provider = createPrivyProvider(core, {\n appId: config.appId,\n clientId: config.clientId,\n chain: config.chain,\n walletList: config.walletList,\n });\n\n // Stable identity: the host publishes this to a registry on change.\n function useController(): PrivyWalletController {\n return useMemo<PrivyWalletController>(\n () => ({\n connect: (method) => core.connect(method),\n disconnect: () => core.disconnect(),\n getSession: () => core.getSession(),\n subscribe: (listener) => core.subscribe(listener),\n sendCode: (email, options) => core.sendCode(email, options),\n loginWithCode: (code) => core.loginWithCode(code),\n getState: () => core.getState(),\n subscribeState: (listener) => core.subscribeState(listener),\n }),\n [],\n );\n }\n\n return { Provider, useController };\n}\n\nexport { PrivyCore } from \"./adapter.js\";\nexport type { PrivyBindings } from \"./adapter.js\";\nexport type {\n PrivyAuthState,\n PrivyEmailStatus,\n PrivyWalletController,\n SendCodeOptions,\n} from \"./types.js\";\nexport { PrivyAdapterBridge } from \"./bridge.js\";\nexport { createPrivyProvider } from \"./provider.js\";\n"],"mappings":";;;;;;;AAiBA,MAAa,mBAAiE;EAC3E,YAAY,SAAS;EACrB,YAAY,SAAS;EACrB,YAAY,QAAQ;EACpB,YAAY,QAAQ;CACtB;AAMD,MAAM,wBAEF;EACD,YAAY,SAAS;EACrB,YAAY,QAAQ;CACtB;AAmBD,MAAM,gBAAgC;CACpC,OAAO;CACP,eAAe;CACf,aAAa;CACd;AASD,IAAa,YAAb,MAAuB;CACrB;CAEA,WAAyC;CACzC,UAAuC;CACvC,UAA6C,KAAA;CAC7C,4BAAoB,IAAI,K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GACD,EAAE,CACH;;AAGH,QAAO;EAAE;EAAU;EAAe"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as WalletAdapterDescriptor } from "../../types-b2fgIxlx.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as DEFAULT_PRIVY_METHODS, c as PrivyLoginMethod, i as SendCodeOptions, l as privyAdapterMeta, n as PrivyEmailStatus, o as PHRenownPrivyAdapterConfig, r as PrivyWalletController, s as PrivyChain, t as PrivyAuthState, u as resolvePrivyMethods } from "../../types-C3PZqMdJ.js";
|
|
3
3
|
|
|
4
4
|
//#region src/wallet/privy/index.d.ts
|
|
5
5
|
/** Privy wallet adapter (embedded wallets plus social / email login) for `RenownWalletProvider`. Importing this module loads no wallet library — `@privy-io/react-auth` is fetched by `load()` on the first login click — but it does make that package a build-time requirement, so install it alongside this import. */
|
|
6
6
|
declare function privyAdapter(config: PHRenownPrivyAdapterConfig): WalletAdapterDescriptor;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { DEFAULT_PRIVY_METHODS, type PHRenownPrivyAdapterConfig, type PrivyLoginMethod, privyAdapter, privyAdapterMeta, resolvePrivyMethods };
|
|
8
|
+
export { DEFAULT_PRIVY_METHODS, type PHRenownPrivyAdapterConfig, type PrivyAuthState, type PrivyChain, type PrivyEmailStatus, type PrivyLoginMethod, type PrivyWalletController, type SendCodeOptions, privyAdapter, privyAdapterMeta, resolvePrivyMethods };
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/wallet/privy/index.ts"],"sourcesContent":["import type { WalletAdapterDescriptor } from \"../types.js\";\nimport {\n privyAdapterMeta,\n resolvePrivyMethods,\n type PHRenownPrivyAdapterConfig,\n} from \"./meta.js\";\n\n/** Privy wallet adapter (embedded wallets plus social / email login) for `RenownWalletProvider`. Importing this module loads no wallet library — `@privy-io/react-auth` is fetched by `load()` on the first login click — but it does make that package a build-time requirement, so install it alongside this import. */\nexport function privyAdapter(\n config: PHRenownPrivyAdapterConfig,\n): WalletAdapterDescriptor {\n return {\n meta: {\n ...privyAdapterMeta,\n supportedMethods: resolvePrivyMethods(config.methods),\n },\n load: () =>\n import(\"./factory.js\").then((m) => m.createPrivyAdapter(config)),\n };\n}\n\nexport {\n DEFAULT_PRIVY_METHODS,\n privyAdapterMeta,\n resolvePrivyMethods,\n} from \"./meta.js\";\nexport type {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/wallet/privy/index.ts"],"sourcesContent":["import type { WalletAdapterDescriptor } from \"../types.js\";\nimport {\n privyAdapterMeta,\n resolvePrivyMethods,\n type PHRenownPrivyAdapterConfig,\n} from \"./meta.js\";\n\n/** Privy wallet adapter (embedded wallets plus social / email login) for `RenownWalletProvider`. Importing this module loads no wallet library — `@privy-io/react-auth` is fetched by `load()` on the first login click — but it does make that package a build-time requirement, so install it alongside this import. */\nexport function privyAdapter(\n config: PHRenownPrivyAdapterConfig,\n): WalletAdapterDescriptor {\n return {\n meta: {\n ...privyAdapterMeta,\n supportedMethods: resolvePrivyMethods(config.methods),\n },\n load: () =>\n import(\"./factory.js\").then((m) => m.createPrivyAdapter(config)),\n };\n}\n\nexport {\n DEFAULT_PRIVY_METHODS,\n privyAdapterMeta,\n resolvePrivyMethods,\n} from \"./meta.js\";\nexport type {\n PHRenownPrivyAdapterConfig,\n PrivyChain,\n PrivyLoginMethod,\n} from \"./meta.js\";\n// Type-only: lets a host type `useRenownWalletAdapter<PrivyWalletController>(\"privy\")`\n// without pulling the factory (or @privy-io) into its bundle.\nexport type {\n PrivyAuthState,\n PrivyEmailStatus,\n PrivyWalletController,\n SendCodeOptions,\n} from \"./types.js\";\n"],"mappings":";;;AAQA,SAAgB,aACd,QACyB;AACzB,QAAO;EACL,MAAM;GACJ,GAAG;GACH,kBAAkB,oBAAoB,OAAO,QAAQ;GACtD;EACD,YACE,OAAO,gBAAgB,MAAM,MAAM,EAAE,mBAAmB,OAAO,CAAC;EACnE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renown/sdk",
|
|
3
|
-
"version": "6.2.2-dev.
|
|
3
|
+
"version": "6.2.2-dev.63",
|
|
4
4
|
"description": "Renown SDK — wallet-based authentication and user identity management for Powerhouse React applications.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"private": false,
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"@didtools/key-webcrypto": "^0.2.0",
|
|
102
|
-
"@powerhousedao/shared": "6.2.2-dev.
|
|
102
|
+
"@powerhousedao/shared": "6.2.2-dev.63",
|
|
103
103
|
"did-jwt-vc": "^4.0.12",
|
|
104
104
|
"did-resolver": "^4.1.0",
|
|
105
105
|
"key-did-resolver": "^4.0.0",
|
package/dist/meta-BubXYEe3.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { o as WalletAdapterMeta, t as LoginMethod } from "./types-b2fgIxlx.js";
|
|
2
|
-
|
|
3
|
-
//#region src/wallet/privy/meta.d.ts
|
|
4
|
-
type PrivyLoginMethod = "wallet" | "google" | "apple" | "email";
|
|
5
|
-
declare const DEFAULT_PRIVY_METHODS: LoginMethod[];
|
|
6
|
-
interface PHRenownPrivyAdapterConfig {
|
|
7
|
-
appId: string;
|
|
8
|
-
clientId?: string;
|
|
9
|
-
/** Login methods to offer; defaults to [google, email]. */
|
|
10
|
-
methods?: PrivyLoginMethod[];
|
|
11
|
-
}
|
|
12
|
-
declare function resolvePrivyMethods(methods?: string[]): LoginMethod[];
|
|
13
|
-
declare const privyAdapterMeta: Omit<WalletAdapterMeta, "supportedMethods">;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { resolvePrivyMethods as a, privyAdapterMeta as i, PHRenownPrivyAdapterConfig as n, PrivyLoginMethod as r, DEFAULT_PRIVY_METHODS as t };
|
|
16
|
-
//# sourceMappingURL=meta-BubXYEe3.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta-BubXYEe3.d.ts","names":[],"sources":["../src/wallet/privy/meta.ts"],"mappings":";;;KAIY,gBAAA;AAAA,cAUC,qBAAA,EAAuB,WAAA;AAAA,UAMnB,0BAAA;EACf,KAAA;EACA,QAAA;EAlB0B;EAoB1B,OAAA,GAAU,gBAAA;AAAA;AAAA,iBAKI,mBAAA,CAAoB,OAAA,cAAqB,WAAA;AAAA,cAe5C,gBAAA,EAAkB,IAAA,CAAK,iBAAA"}
|