@renown/sdk 6.2.2-dev.22 → 6.2.2-dev.23
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/README.md +58 -26
- package/dist/crypto.d.ts +2 -2
- package/dist/{index-25fTa4yI.d.ts → index-CLJb-Nle.d.ts} +2 -2
- package/dist/{index-25fTa4yI.d.ts.map → index-CLJb-Nle.d.ts.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/meta-BIIw0yao.d.ts +16 -0
- package/dist/meta-BIIw0yao.d.ts.map +1 -0
- package/dist/meta-ClnkfLQZ.js +27 -0
- package/dist/meta-ClnkfLQZ.js.map +1 -0
- package/dist/meta-DEiGzvRl.d.ts +14 -0
- package/dist/meta-DEiGzvRl.d.ts.map +1 -0
- package/dist/meta-DoUiCChW.d.ts +19 -0
- package/dist/meta-DoUiCChW.d.ts.map +1 -0
- package/dist/meta-v66wx9x-.js +31 -0
- package/dist/meta-v66wx9x-.js.map +1 -0
- package/dist/node.d.ts +3 -46
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +17 -8
- package/dist/node.js.map +1 -1
- package/dist/{renown-builder-BqWoYtBR.js → renown-builder-1WTEoRc6.js} +24 -1
- package/dist/{renown-builder-BqWoYtBR.js.map → renown-builder-1WTEoRc6.js.map} +1 -1
- package/dist/types-DiIZNA8t.js +20 -0
- package/dist/types-DiIZNA8t.js.map +1 -0
- package/dist/{types-Z6jyeonm.d.ts → types-DteAE_lL.d.ts} +23 -18
- package/dist/types-DteAE_lL.d.ts.map +1 -0
- package/dist/{types-DsF91dDF.d.ts → types-efrA0fu2.d.ts} +6 -4
- package/dist/{types-DsF91dDF.d.ts.map → types-efrA0fu2.d.ts.map} +1 -1
- package/dist/{utils-OOrVXHof.d.ts → utils-BuICPHTW.d.ts} +51 -3
- package/dist/utils-BuICPHTW.d.ts.map +1 -0
- package/dist/wallet/index.d.ts +4 -26
- package/dist/wallet/index.d.ts.map +1 -1
- package/dist/wallet/index.js +20 -64
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/mock/factory.d.ts +9 -0
- package/dist/wallet/mock/factory.d.ts.map +1 -0
- package/dist/wallet/mock/factory.js +35 -0
- package/dist/wallet/mock/factory.js.map +1 -0
- package/dist/wallet/mock/index.d.ts +5 -14
- package/dist/wallet/mock/index.d.ts.map +1 -1
- package/dist/wallet/mock/index.js +9 -31
- package/dist/wallet/mock/index.js.map +1 -1
- package/dist/wallet/privy/factory.d.ts +58 -0
- package/dist/wallet/privy/factory.d.ts.map +1 -0
- package/dist/wallet/privy/factory.js +218 -0
- package/dist/wallet/privy/factory.js.map +1 -0
- package/dist/wallet/privy/index.d.ts +5 -59
- package/dist/wallet/privy/index.d.ts.map +1 -1
- package/dist/wallet/privy/index.js +9 -223
- package/dist/wallet/privy/index.js.map +1 -1
- package/dist/wallet/rainbow/factory.d.ts +7 -0
- package/dist/wallet/rainbow/factory.d.ts.map +1 -0
- package/dist/wallet/rainbow/factory.js +216 -0
- package/dist/wallet/rainbow/factory.js.map +1 -0
- package/dist/wallet/rainbow/index.d.ts +6 -11
- package/dist/wallet/rainbow/index.d.ts.map +1 -1
- package/dist/wallet/rainbow/index.js +13 -210
- package/dist/wallet/rainbow/index.js.map +1 -1
- package/package.json +21 -2
- package/dist/types-DG816Qa8.js +0 -27
- package/dist/types-DG816Qa8.js.map +0 -1
- package/dist/types-Z6jyeonm.d.ts.map +0 -1
- package/dist/utils-OOrVXHof.d.ts.map +0 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { n as normalizeWalletTheme, t as LoginMethod } from "../../types-DiIZNA8t.js";
|
|
3
|
+
import { r as resolvePrivyMethods } from "../../meta-ClnkfLQZ.js";
|
|
4
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { PrivyProvider, getEmbeddedConnectedWallet, useLogin, useLoginWithOAuth, useLogout, usePrivy, useSignTypedData, useWallets } from "@privy-io/react-auth";
|
|
7
|
+
//#region src/wallet/privy/adapter.ts
|
|
8
|
+
const PRIVY_METHOD_MAP = {
|
|
9
|
+
[LoginMethod.WALLET]: "wallet",
|
|
10
|
+
[LoginMethod.GOOGLE]: "google",
|
|
11
|
+
[LoginMethod.APPLE]: "apple",
|
|
12
|
+
[LoginMethod.EMAIL]: "email"
|
|
13
|
+
};
|
|
14
|
+
const PRIVY_OAUTH_PROVIDERS = {
|
|
15
|
+
[LoginMethod.GOOGLE]: "google",
|
|
16
|
+
[LoginMethod.APPLE]: "apple"
|
|
17
|
+
};
|
|
18
|
+
var PrivyCore = class {
|
|
19
|
+
supportedMethods;
|
|
20
|
+
bindings = null;
|
|
21
|
+
pending = null;
|
|
22
|
+
session = void 0;
|
|
23
|
+
listeners = /* @__PURE__ */ new Set();
|
|
24
|
+
constructor(supportedMethods) {
|
|
25
|
+
this.supportedMethods = supportedMethods;
|
|
26
|
+
}
|
|
27
|
+
bind(bindings) {
|
|
28
|
+
this.bindings = bindings;
|
|
29
|
+
return () => {
|
|
30
|
+
if (this.bindings === bindings) this.bindings = null;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
getSession() {
|
|
34
|
+
return this.session;
|
|
35
|
+
}
|
|
36
|
+
subscribe(listener) {
|
|
37
|
+
this.listeners.add(listener);
|
|
38
|
+
if (this.session) listener(this.session);
|
|
39
|
+
return () => {
|
|
40
|
+
this.listeners.delete(listener);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
emit(session) {
|
|
44
|
+
for (const listener of this.listeners) listener(session);
|
|
45
|
+
}
|
|
46
|
+
syncFromEmbeddedWallet(wallet) {
|
|
47
|
+
const address = wallet.address;
|
|
48
|
+
const chainId = parseCaip2ChainId(wallet.chainId);
|
|
49
|
+
const signTypedData = async (args) => {
|
|
50
|
+
if (!this.bindings) throw new Error("PrivyAdapter not bound (bridge not mounted)");
|
|
51
|
+
return this.bindings.signTypedData(args, address);
|
|
52
|
+
};
|
|
53
|
+
const session = {
|
|
54
|
+
address,
|
|
55
|
+
chainId,
|
|
56
|
+
signTypedData,
|
|
57
|
+
canSignSilently: true
|
|
58
|
+
};
|
|
59
|
+
this.session = session;
|
|
60
|
+
if (this.pending) {
|
|
61
|
+
this.pending.resolve(session);
|
|
62
|
+
this.pending = null;
|
|
63
|
+
} else this.emit(session);
|
|
64
|
+
}
|
|
65
|
+
clearSession() {
|
|
66
|
+
this.session = void 0;
|
|
67
|
+
this.emit(void 0);
|
|
68
|
+
}
|
|
69
|
+
handleLoginError(error) {
|
|
70
|
+
if (!this.pending) return;
|
|
71
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
72
|
+
this.pending.reject(err);
|
|
73
|
+
this.pending = null;
|
|
74
|
+
}
|
|
75
|
+
async connect(method) {
|
|
76
|
+
if (this.session) return this.session;
|
|
77
|
+
if (!this.bindings) throw new Error("PrivyAdapter not bound. Ensure the adapter Provider wraps the app.");
|
|
78
|
+
const chosen = method ?? this.supportedMethods.at(0);
|
|
79
|
+
if (!chosen) throw new Error("PrivyAdapter has no supported login methods configured");
|
|
80
|
+
if (!this.supportedMethods.includes(chosen)) throw new Error(`PrivyAdapter does not support login method "${chosen}"`);
|
|
81
|
+
const privyMethod = PRIVY_METHOD_MAP[chosen];
|
|
82
|
+
const bindings = this.bindings;
|
|
83
|
+
const oauthProvider = PRIVY_OAUTH_PROVIDERS[chosen];
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
this.pending = {
|
|
86
|
+
resolve,
|
|
87
|
+
reject
|
|
88
|
+
};
|
|
89
|
+
const fail = (error) => {
|
|
90
|
+
this.pending = null;
|
|
91
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
if (oauthProvider) bindings.initOAuth({ provider: oauthProvider }).catch(fail);
|
|
95
|
+
else bindings.openLoginModal({ loginMethods: [privyMethod] });
|
|
96
|
+
} catch (error) {
|
|
97
|
+
fail(error);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async disconnect() {
|
|
102
|
+
this.clearSession();
|
|
103
|
+
if (!this.bindings) return;
|
|
104
|
+
await this.bindings.logout();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
function parseCaip2ChainId(caip2) {
|
|
108
|
+
const last = caip2.split(":").at(-1);
|
|
109
|
+
const n = Number(last);
|
|
110
|
+
if (!Number.isFinite(n)) throw new Error(`PrivyAdapter: could not parse chainId from CAIP-2 "${caip2}"`);
|
|
111
|
+
return n;
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/wallet/privy/bridge.tsx
|
|
115
|
+
function PrivyAdapterBridge({ core }) {
|
|
116
|
+
const { ready, authenticated } = usePrivy();
|
|
117
|
+
const { wallets } = useWallets();
|
|
118
|
+
const { signTypedData } = useSignTypedData();
|
|
119
|
+
const { logout } = useLogout();
|
|
120
|
+
const { login: openLoginModal } = useLogin({ onError: (error) => core.handleLoginError(error) });
|
|
121
|
+
const { initOAuth } = useLoginWithOAuth({ onError: (error) => core.handleLoginError(error) });
|
|
122
|
+
const fnsRef = useRef({
|
|
123
|
+
openLoginModal,
|
|
124
|
+
initOAuth,
|
|
125
|
+
logout,
|
|
126
|
+
signTypedData
|
|
127
|
+
});
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
fnsRef.current = {
|
|
130
|
+
openLoginModal,
|
|
131
|
+
initOAuth,
|
|
132
|
+
logout,
|
|
133
|
+
signTypedData
|
|
134
|
+
};
|
|
135
|
+
}, [
|
|
136
|
+
openLoginModal,
|
|
137
|
+
initOAuth,
|
|
138
|
+
logout,
|
|
139
|
+
signTypedData
|
|
140
|
+
]);
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
return core.bind({
|
|
143
|
+
openLoginModal: (opts) => fnsRef.current.openLoginModal(opts),
|
|
144
|
+
initOAuth: (opts) => fnsRef.current.initOAuth(opts),
|
|
145
|
+
logout: () => fnsRef.current.logout(),
|
|
146
|
+
signTypedData: async (args, address) => {
|
|
147
|
+
return (await fnsRef.current.signTypedData(args, {
|
|
148
|
+
address,
|
|
149
|
+
uiOptions: { showWalletUIs: false }
|
|
150
|
+
})).signature;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}, [core]);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!ready) return;
|
|
156
|
+
if (!authenticated) {
|
|
157
|
+
core.clearSession();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const embedded = getEmbeddedConnectedWallet(wallets);
|
|
161
|
+
if (embedded) core.syncFromEmbeddedWallet(embedded);
|
|
162
|
+
}, [
|
|
163
|
+
core,
|
|
164
|
+
ready,
|
|
165
|
+
authenticated,
|
|
166
|
+
wallets
|
|
167
|
+
]);
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/wallet/privy/provider.tsx
|
|
172
|
+
function createPrivyProvider(core, config) {
|
|
173
|
+
return function PrivyAuthProvider({ children, theme }) {
|
|
174
|
+
const { mode } = normalizeWalletTheme(theme);
|
|
175
|
+
const privyConfig = useMemo(() => ({
|
|
176
|
+
appearance: { theme: mode },
|
|
177
|
+
embeddedWallets: {
|
|
178
|
+
ethereum: { createOnLogin: "users-without-wallets" },
|
|
179
|
+
showWalletUIs: false
|
|
180
|
+
},
|
|
181
|
+
externalWallets: {
|
|
182
|
+
disableAllExternalWallets: true,
|
|
183
|
+
walletConnect: { enabled: false }
|
|
184
|
+
}
|
|
185
|
+
}), [mode]);
|
|
186
|
+
return /* @__PURE__ */ jsxs(PrivyProvider, {
|
|
187
|
+
appId: config.appId,
|
|
188
|
+
clientId: config.clientId,
|
|
189
|
+
config: privyConfig,
|
|
190
|
+
children: [/* @__PURE__ */ jsx(PrivyAdapterBridge, { core }), children]
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/wallet/privy/factory.ts
|
|
196
|
+
function createPrivyAdapter(config) {
|
|
197
|
+
const core = new PrivyCore(resolvePrivyMethods(config.methods));
|
|
198
|
+
const Provider = createPrivyProvider(core, {
|
|
199
|
+
appId: config.appId,
|
|
200
|
+
clientId: config.clientId
|
|
201
|
+
});
|
|
202
|
+
function useController() {
|
|
203
|
+
return {
|
|
204
|
+
connect: (method) => core.connect(method),
|
|
205
|
+
disconnect: () => core.disconnect(),
|
|
206
|
+
getSession: () => core.getSession(),
|
|
207
|
+
subscribe: (listener) => core.subscribe(listener)
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
Provider,
|
|
212
|
+
useController
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
//#endregion
|
|
216
|
+
export { PrivyAdapterBridge, PrivyCore, createPrivyAdapter, createPrivyProvider };
|
|
217
|
+
|
|
218
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","names":[],"sources":["../../../src/wallet/privy/adapter.ts","../../../src/wallet/privy/bridge.tsx","../../../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 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\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 { 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({ openLoginModal, initOAuth, logout, signTypedData });\n useEffect(() => {\n fnsRef.current = { openLoginModal, initOAuth, logout, signTypedData };\n }, [openLoginModal, initOAuth, logout, signTypedData]);\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 return;\n }\n const embedded = getEmbeddedConnectedWallet(wallets);\n if (embedded) core.syncFromEmbeddedWallet(embedded);\n }, [core, ready, authenticated, wallets]);\n\n return null;\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\";\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 } = normalizeWalletTheme(theme);\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 appearance: { theme: mode },\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],\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;;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,OAAO;GACzC,kBAAkB,KAAK,YAAY;GACnC,kBAAkB,KAAK,YAAY;GACnC,YAAY,aAAa,KAAK,UAAU,SAAS;GAClD;;AAGH,QAAO;EAAE;EAAU;EAAe"}
|
|
@@ -1,63 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ComponentType, ReactNode } from "react";
|
|
4
|
-
import { ConnectedWallet, LoginModalOptions } from "@privy-io/react-auth";
|
|
1
|
+
import { r as WalletAdapterDescriptor } from "../../types-DteAE_lL.js";
|
|
2
|
+
import { a as resolvePrivyMethods, i as privyAdapterMeta, n as PHRenownPrivyAdapterConfig, r as PrivyLoginMethod, t as DEFAULT_PRIVY_METHODS } from "../../meta-BIIw0yao.js";
|
|
5
3
|
|
|
6
|
-
//#region src/wallet/privy/adapter.d.ts
|
|
7
|
-
type Hex = `0x${string}`;
|
|
8
|
-
type PrivyOAuthProviderId = "google" | "apple";
|
|
9
|
-
declare function resolvePrivyMethods(methods?: string[]): LoginMethod[];
|
|
10
|
-
interface PrivyBindings {
|
|
11
|
-
openLoginModal: (options?: LoginModalOptions) => void;
|
|
12
|
-
initOAuth: (options: {
|
|
13
|
-
provider: PrivyOAuthProviderId;
|
|
14
|
-
}) => Promise<void>;
|
|
15
|
-
logout: () => Promise<void>;
|
|
16
|
-
signTypedData: (args: Parameters<SignCredentialTypedData>[0], address: Hex) => Promise<Hex>;
|
|
17
|
-
}
|
|
18
|
-
declare class PrivyCore {
|
|
19
|
-
readonly supportedMethods: LoginMethod[];
|
|
20
|
-
private bindings;
|
|
21
|
-
private pending;
|
|
22
|
-
private session;
|
|
23
|
-
private listeners;
|
|
24
|
-
constructor(supportedMethods: LoginMethod[]);
|
|
25
|
-
bind(bindings: PrivyBindings): () => void;
|
|
26
|
-
getSession(): WalletSession | undefined;
|
|
27
|
-
subscribe(listener: (session: WalletSession | undefined) => void): () => void;
|
|
28
|
-
private emit;
|
|
29
|
-
syncFromEmbeddedWallet(wallet: ConnectedWallet): void;
|
|
30
|
-
clearSession(): void;
|
|
31
|
-
handleLoginError(error: unknown): void;
|
|
32
|
-
connect(method?: LoginMethod): Promise<WalletSession>;
|
|
33
|
-
disconnect(): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/wallet/privy/bridge.d.ts
|
|
37
|
-
interface PrivyAdapterBridgeProps {
|
|
38
|
-
core: PrivyCore;
|
|
39
|
-
}
|
|
40
|
-
declare function PrivyAdapterBridge({
|
|
41
|
-
core
|
|
42
|
-
}: PrivyAdapterBridgeProps): null;
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/wallet/privy/provider.d.ts
|
|
45
|
-
interface PrivyProviderConfig {
|
|
46
|
-
appId: string;
|
|
47
|
-
clientId?: string;
|
|
48
|
-
}
|
|
49
|
-
declare function createPrivyProvider(core: PrivyCore, config: PrivyProviderConfig): ComponentType<{
|
|
50
|
-
children: ReactNode;
|
|
51
|
-
theme?: WalletTheme;
|
|
52
|
-
}>;
|
|
53
|
-
//#endregion
|
|
54
4
|
//#region src/wallet/privy/index.d.ts
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
clientId?: string;
|
|
58
|
-
methods?: string[];
|
|
59
|
-
}
|
|
60
|
-
declare function createPrivyAdapter(config: PHRenownPrivyAdapterConfig): WalletAdapter;
|
|
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
|
+
declare function privyAdapter(config: PHRenownPrivyAdapterConfig): WalletAdapterDescriptor;
|
|
61
7
|
//#endregion
|
|
62
|
-
export {
|
|
8
|
+
export { DEFAULT_PRIVY_METHODS, type PHRenownPrivyAdapterConfig, type PrivyLoginMethod, privyAdapter, privyAdapterMeta, resolvePrivyMethods };
|
|
63
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/wallet/privy/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/wallet/privy/index.ts"],"mappings":";;;;;iBAQgB,YAAA,CACd,MAAA,EAAQ,0BAAA,GACP,uBAAA"}
|
|
@@ -1,230 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect, useMemo, useRef } from "react";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { PrivyProvider, getEmbeddedConnectedWallet, useLogin, useLoginWithOAuth, useLogout, usePrivy, useSignTypedData, useWallets } from "@privy-io/react-auth";
|
|
5
|
-
//#region src/wallet/privy/adapter.ts
|
|
6
|
-
const PRIVY_METHOD_MAP = {
|
|
7
|
-
[LoginMethod.WALLET]: "wallet",
|
|
8
|
-
[LoginMethod.GOOGLE]: "google",
|
|
9
|
-
[LoginMethod.APPLE]: "apple",
|
|
10
|
-
[LoginMethod.EMAIL]: "email"
|
|
11
|
-
};
|
|
12
|
-
const PRIVY_OAUTH_PROVIDERS = {
|
|
13
|
-
[LoginMethod.GOOGLE]: "google",
|
|
14
|
-
[LoginMethod.APPLE]: "apple"
|
|
15
|
-
};
|
|
16
|
-
function resolvePrivyMethods(methods) {
|
|
17
|
-
if (!methods || methods.length === 0) return [...DEFAULT_PRIVY_METHODS];
|
|
18
|
-
const resolved = [];
|
|
19
|
-
for (const method of methods) {
|
|
20
|
-
const value = method;
|
|
21
|
-
if (!(value in PRIVY_METHOD_MAP)) throw new Error(`PrivyAdapter cannot support login method "${method}"`);
|
|
22
|
-
resolved.push(value);
|
|
23
|
-
}
|
|
24
|
-
return resolved;
|
|
25
|
-
}
|
|
26
|
-
var PrivyCore = class {
|
|
27
|
-
supportedMethods;
|
|
28
|
-
bindings = null;
|
|
29
|
-
pending = null;
|
|
30
|
-
session = void 0;
|
|
31
|
-
listeners = /* @__PURE__ */ new Set();
|
|
32
|
-
constructor(supportedMethods) {
|
|
33
|
-
this.supportedMethods = supportedMethods;
|
|
34
|
-
}
|
|
35
|
-
bind(bindings) {
|
|
36
|
-
this.bindings = bindings;
|
|
37
|
-
return () => {
|
|
38
|
-
if (this.bindings === bindings) this.bindings = null;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
getSession() {
|
|
42
|
-
return this.session;
|
|
43
|
-
}
|
|
44
|
-
subscribe(listener) {
|
|
45
|
-
this.listeners.add(listener);
|
|
46
|
-
if (this.session) listener(this.session);
|
|
47
|
-
return () => {
|
|
48
|
-
this.listeners.delete(listener);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
emit(session) {
|
|
52
|
-
for (const listener of this.listeners) listener(session);
|
|
53
|
-
}
|
|
54
|
-
syncFromEmbeddedWallet(wallet) {
|
|
55
|
-
const address = wallet.address;
|
|
56
|
-
const chainId = parseCaip2ChainId(wallet.chainId);
|
|
57
|
-
const signTypedData = async (args) => {
|
|
58
|
-
if (!this.bindings) throw new Error("PrivyAdapter not bound (bridge not mounted)");
|
|
59
|
-
return this.bindings.signTypedData(args, address);
|
|
60
|
-
};
|
|
61
|
-
const session = {
|
|
62
|
-
address,
|
|
63
|
-
chainId,
|
|
64
|
-
signTypedData,
|
|
65
|
-
canSignSilently: true
|
|
66
|
-
};
|
|
67
|
-
this.session = session;
|
|
68
|
-
if (this.pending) {
|
|
69
|
-
this.pending.resolve(session);
|
|
70
|
-
this.pending = null;
|
|
71
|
-
} else this.emit(session);
|
|
72
|
-
}
|
|
73
|
-
clearSession() {
|
|
74
|
-
this.session = void 0;
|
|
75
|
-
this.emit(void 0);
|
|
76
|
-
}
|
|
77
|
-
handleLoginError(error) {
|
|
78
|
-
if (!this.pending) return;
|
|
79
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
80
|
-
this.pending.reject(err);
|
|
81
|
-
this.pending = null;
|
|
82
|
-
}
|
|
83
|
-
async connect(method) {
|
|
84
|
-
if (this.session) return this.session;
|
|
85
|
-
if (!this.bindings) throw new Error("PrivyAdapter not bound. Ensure the adapter Provider wraps the app.");
|
|
86
|
-
const chosen = method ?? this.supportedMethods.at(0);
|
|
87
|
-
if (!chosen) throw new Error("PrivyAdapter has no supported login methods configured");
|
|
88
|
-
const privyMethod = PRIVY_METHOD_MAP[chosen];
|
|
89
|
-
if (!privyMethod || !this.supportedMethods.includes(chosen)) throw new Error(`PrivyAdapter does not support login method "${chosen}"`);
|
|
90
|
-
const bindings = this.bindings;
|
|
91
|
-
const oauthProvider = PRIVY_OAUTH_PROVIDERS[chosen];
|
|
92
|
-
return new Promise((resolve, reject) => {
|
|
93
|
-
this.pending = {
|
|
94
|
-
resolve,
|
|
95
|
-
reject
|
|
96
|
-
};
|
|
97
|
-
const fail = (error) => {
|
|
98
|
-
this.pending = null;
|
|
99
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
100
|
-
};
|
|
101
|
-
try {
|
|
102
|
-
if (oauthProvider) bindings.initOAuth({ provider: oauthProvider }).catch(fail);
|
|
103
|
-
else bindings.openLoginModal({ loginMethods: [privyMethod] });
|
|
104
|
-
} catch (error) {
|
|
105
|
-
fail(error);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
async disconnect() {
|
|
110
|
-
this.clearSession();
|
|
111
|
-
if (!this.bindings) return;
|
|
112
|
-
await this.bindings.logout();
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
function parseCaip2ChainId(caip2) {
|
|
116
|
-
const last = caip2.split(":").at(-1);
|
|
117
|
-
const n = Number(last);
|
|
118
|
-
if (!Number.isFinite(n)) throw new Error(`PrivyAdapter: could not parse chainId from CAIP-2 "${caip2}"`);
|
|
119
|
-
return n;
|
|
120
|
-
}
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/wallet/privy/bridge.tsx
|
|
123
|
-
function PrivyAdapterBridge({ core }) {
|
|
124
|
-
const { ready, authenticated } = usePrivy();
|
|
125
|
-
const { wallets } = useWallets();
|
|
126
|
-
const { signTypedData } = useSignTypedData();
|
|
127
|
-
const { logout } = useLogout();
|
|
128
|
-
const { login: openLoginModal } = useLogin({ onError: (error) => core.handleLoginError(error) });
|
|
129
|
-
const { initOAuth } = useLoginWithOAuth({ onError: (error) => core.handleLoginError(error) });
|
|
130
|
-
const fnsRef = useRef({
|
|
131
|
-
openLoginModal,
|
|
132
|
-
initOAuth,
|
|
133
|
-
logout,
|
|
134
|
-
signTypedData
|
|
135
|
-
});
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
fnsRef.current = {
|
|
138
|
-
openLoginModal,
|
|
139
|
-
initOAuth,
|
|
140
|
-
logout,
|
|
141
|
-
signTypedData
|
|
142
|
-
};
|
|
143
|
-
}, [
|
|
144
|
-
openLoginModal,
|
|
145
|
-
initOAuth,
|
|
146
|
-
logout,
|
|
147
|
-
signTypedData
|
|
148
|
-
]);
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
return core.bind({
|
|
151
|
-
openLoginModal: (opts) => fnsRef.current.openLoginModal(opts),
|
|
152
|
-
initOAuth: (opts) => fnsRef.current.initOAuth(opts),
|
|
153
|
-
logout: () => fnsRef.current.logout(),
|
|
154
|
-
signTypedData: async (args, address) => {
|
|
155
|
-
return (await fnsRef.current.signTypedData(args, {
|
|
156
|
-
address,
|
|
157
|
-
uiOptions: { showWalletUIs: false }
|
|
158
|
-
})).signature;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}, [core]);
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
if (!ready) return;
|
|
164
|
-
if (!authenticated) {
|
|
165
|
-
core.clearSession();
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const embedded = getEmbeddedConnectedWallet(wallets);
|
|
169
|
-
if (embedded) core.syncFromEmbeddedWallet(embedded);
|
|
170
|
-
}, [
|
|
171
|
-
core,
|
|
172
|
-
ready,
|
|
173
|
-
authenticated,
|
|
174
|
-
wallets
|
|
175
|
-
]);
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/wallet/privy/provider.tsx
|
|
180
|
-
function createPrivyProvider(core, config) {
|
|
181
|
-
return function PrivyAuthProvider({ children, theme }) {
|
|
182
|
-
const { mode } = normalizeWalletTheme(theme);
|
|
183
|
-
const privyConfig = useMemo(() => ({
|
|
184
|
-
appearance: { theme: mode },
|
|
185
|
-
embeddedWallets: {
|
|
186
|
-
ethereum: { createOnLogin: "users-without-wallets" },
|
|
187
|
-
showWalletUIs: false
|
|
188
|
-
},
|
|
189
|
-
externalWallets: {
|
|
190
|
-
disableAllExternalWallets: true,
|
|
191
|
-
walletConnect: { enabled: false }
|
|
192
|
-
}
|
|
193
|
-
}), [mode]);
|
|
194
|
-
return /* @__PURE__ */ jsxs(PrivyProvider, {
|
|
195
|
-
appId: config.appId,
|
|
196
|
-
clientId: config.clientId,
|
|
197
|
-
config: privyConfig,
|
|
198
|
-
children: [/* @__PURE__ */ jsx(PrivyAdapterBridge, { core }), children]
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
//#endregion
|
|
1
|
+
import { n as privyAdapterMeta, r as resolvePrivyMethods, t as DEFAULT_PRIVY_METHODS } from "../../meta-ClnkfLQZ.js";
|
|
203
2
|
//#region src/wallet/privy/index.ts
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const core = new PrivyCore(supportedMethods);
|
|
207
|
-
const Provider = createPrivyProvider(core, {
|
|
208
|
-
appId: config.appId,
|
|
209
|
-
clientId: config.clientId
|
|
210
|
-
});
|
|
211
|
-
function useController() {
|
|
212
|
-
return {
|
|
213
|
-
connect: (method) => core.connect(method),
|
|
214
|
-
disconnect: () => core.disconnect(),
|
|
215
|
-
getSession: () => core.getSession(),
|
|
216
|
-
subscribe: (listener) => core.subscribe(listener),
|
|
217
|
-
supportedMethods
|
|
218
|
-
};
|
|
219
|
-
}
|
|
3
|
+
/** 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. */
|
|
4
|
+
function privyAdapter(config) {
|
|
220
5
|
return {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
6
|
+
meta: {
|
|
7
|
+
...privyAdapterMeta,
|
|
8
|
+
supportedMethods: resolvePrivyMethods(config.methods)
|
|
9
|
+
},
|
|
10
|
+
load: () => import("./factory.js").then((m) => m.createPrivyAdapter(config))
|
|
225
11
|
};
|
|
226
12
|
}
|
|
227
13
|
//#endregion
|
|
228
|
-
export {
|
|
14
|
+
export { DEFAULT_PRIVY_METHODS, privyAdapter, privyAdapterMeta, resolvePrivyMethods };
|
|
229
15
|
|
|
230
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/wallet/privy/adapter.ts","../../../src/wallet/privy/bridge.tsx","../../../src/wallet/privy/provider.tsx","../../../src/wallet/privy/index.ts"],"sourcesContent":["import type {\n ConnectedWallet,\n LoginModalOptions,\n SignTypedDataParams,\n} from \"@privy-io/react-auth\";\nimport type { SignCredentialTypedData } from \"../../credential.js\";\nimport {\n DEFAULT_PRIVY_METHODS,\n LoginMethod,\n type WalletSession,\n} from \"../types.js\";\n\ntype Hex = `0x${string}`;\ntype PrivyLoginMethodId = NonNullable<\n LoginModalOptions[\"loginMethods\"]\n>[number];\n\n// Login methods the Privy adapter can drive. Config `methods` is validated\n// against these; the default is [GOOGLE, EMAIL].\nconst PRIVY_METHOD_MAP: Partial<Record<LoginMethod, 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// Resolve config `methods` (LoginMethod string values) to the supported set,\n// falling back to the default when none are provided.\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 LoginMethod;\n if (!(value in PRIVY_METHOD_MAP)) {\n throw new Error(`PrivyAdapter cannot support login method \"${method}\"`);\n }\n resolved.push(value);\n }\n return resolved;\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 const privyMethod = PRIVY_METHOD_MAP[chosen];\n if (!privyMethod || !this.supportedMethods.includes(chosen)) {\n throw new Error(`PrivyAdapter does not support login method \"${chosen}\"`);\n }\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 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\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 { 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({ openLoginModal, initOAuth, logout, signTypedData });\n useEffect(() => {\n fnsRef.current = { openLoginModal, initOAuth, logout, signTypedData };\n }, [openLoginModal, initOAuth, logout, signTypedData]);\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 return;\n }\n const embedded = getEmbeddedConnectedWallet(wallets);\n if (embedded) core.syncFromEmbeddedWallet(embedded);\n }, [core, ready, authenticated, wallets]);\n\n return null;\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\";\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 } = normalizeWalletTheme(theme);\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 appearance: { theme: mode },\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],\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","import type { LoginMethod, WalletAdapter, WalletController } from \"../types.js\";\nimport { PrivyCore, resolvePrivyMethods } from \"./adapter.js\";\nimport { createPrivyProvider } from \"./provider.js\";\n\n// Config slice for the Privy adapter (mirrors connect.renown.adapters.privy).\n// `methods` defaults to [GOOGLE, EMAIL] when omitted.\nexport interface PHRenownPrivyAdapterConfig {\n appId: string;\n clientId?: string;\n methods?: string[];\n}\n\n// Build the Privy WalletAdapter. Provider mounts PrivyProvider + a bridge;\n// useController exposes imperative connect/disconnect over the shared core.\nexport function createPrivyAdapter(\n config: PHRenownPrivyAdapterConfig,\n): WalletAdapter {\n const supportedMethods: LoginMethod[] = resolvePrivyMethods(config.methods);\n const core = new PrivyCore(supportedMethods);\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 supportedMethods,\n };\n }\n\n return {\n id: \"privy\",\n supportedMethods,\n Provider,\n useController,\n };\n}\n\nexport { PrivyCore, resolvePrivyMethods } from \"./adapter.js\";\nexport type { PrivyBindings } from \"./adapter.js\";\nexport { PrivyAdapterBridge } from \"./bridge.js\";\nexport { createPrivyProvider } from \"./provider.js\";\n"],"mappings":";;;;;AAmBA,MAAM,mBAAqE;EACxE,YAAY,SAAS;EACrB,YAAY,SAAS;EACrB,YAAY,QAAQ;EACpB,YAAY,QAAQ;CACtB;AAMD,MAAM,wBAEF;EACD,YAAY,SAAS;EACrB,YAAY,QAAQ;CACtB;AAID,SAAgB,oBAAoB,SAAmC;AACrE,KAAI,CAAC,WAAW,QAAQ,WAAW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kC;IAC7D,eAAe;IAChB;GAGD,iBAAiB;IACf,2BAA2B;IAC3B,eAAe,EAAE,SAAS,OAAO;IAClC;GACF,GACD,CAAC,KAAK,CACP;AAED,SACE,qBAAC,eAAD;GACE,OAAO,OAAO;GACd,UAAU,OAAO;GACjB,QAAQ;aAHV,CAKE,oBAAC,oBAAD,EAA0B,MAAQ,CAAA,EACjC,SACa;;;;;;ACtCtB,SAAgB,mBACd,QACe;CACf,MAAM,mBAAkC,oBAAoB,OAAO,QAAQ;CAC3E,MAAM,OAAO,IAAI,UAAU,iBAAiB;CAC5C,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;GACjD;GACD;;AAGH,QAAO;EACL,IAAI;EACJ;EACA;EACA;EACD"}
|
|
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 { PHRenownPrivyAdapterConfig, PrivyLoginMethod } from \"./meta.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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { a as WalletAdapterImpl } from "../../types-DteAE_lL.js";
|
|
2
|
+
import { t as PHRenownRainbowAdapterConfig } from "../../meta-DEiGzvRl.js";
|
|
3
|
+
//#region src/wallet/rainbow/factory.d.ts
|
|
4
|
+
declare function createRainbowAdapter(config: PHRenownRainbowAdapterConfig): WalletAdapterImpl;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { createRainbowAdapter };
|
|
7
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","names":[],"sources":["../../../src/wallet/rainbow/factory.ts"],"mappings":";;;iBA2DgB,oBAAA,CACd,MAAA,EAAQ,4BAAA,GACP,iBAAA"}
|