@renown/sdk 6.2.3-dev.23 → 6.2.3-dev.24
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/{browser-key-storage-e3RQsnLS.js → browser-key-storage-CeyLjla8.js} +1 -1
- package/dist/{browser-key-storage-e3RQsnLS.js.map → browser-key-storage-CeyLjla8.js.map} +1 -1
- package/dist/crypto.d.ts +2 -2
- package/dist/crypto.js +2 -2
- package/dist/{index-BLIpkdF7.d.ts → index-Bcs-BY-C.d.ts} +10 -19
- package/dist/{index-BLIpkdF7.d.ts.map → index-Bcs-BY-C.d.ts.map} +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/local-credential-verifier-2aC00ymX.js +429 -0
- package/dist/local-credential-verifier-2aC00ymX.js.map +1 -0
- package/dist/{meta-bV7L-1yb.d.ts → meta-B8HbJHy8.d.ts} +2 -2
- package/dist/{meta-bV7L-1yb.d.ts.map → meta-B8HbJHy8.d.ts.map} +1 -1
- package/dist/{meta-CHgd9Qd0.js → meta-BOjLjJ1Y.js} +2 -2
- package/dist/{meta-CHgd9Qd0.js.map → meta-BOjLjJ1Y.js.map} +1 -1
- package/dist/{meta-BesJP74N.d.ts → meta-CRXEMUUQ.d.ts} +2 -2
- package/dist/{meta-BesJP74N.d.ts.map → meta-CRXEMUUQ.d.ts.map} +1 -1
- package/dist/{meta-D-5kvwx8.js → meta-adhFGw0o.js} +2 -2
- package/dist/{meta-D-5kvwx8.js.map → meta-adhFGw0o.js.map} +1 -1
- package/dist/node.d.ts +19 -4
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +18 -3
- package/dist/node.js.map +1 -1
- package/dist/{signer-DrjINLqt.js → signer-DIbtSfsu.js} +30 -102
- package/dist/signer-DIbtSfsu.js.map +1 -0
- package/dist/{local-credential-verifier-CU8hmFlR.js → signer-trust-D7vg4xbS.js} +120 -421
- package/dist/signer-trust-D7vg4xbS.js.map +1 -0
- package/dist/signer-trust-Dg7Wggsc.d.ts +53 -0
- package/dist/signer-trust-Dg7Wggsc.d.ts.map +1 -0
- package/dist/trust.d.ts +2 -0
- package/dist/trust.js +2 -0
- package/dist/{types-DInveFLz.d.ts → types-CQDAkCVn.d.ts} +2 -2
- package/dist/{types-DInveFLz.d.ts.map → types-CQDAkCVn.d.ts.map} +1 -1
- package/dist/{types-BGQKPoUr.d.ts → types-CXBWG4JY.d.ts} +10 -2
- package/dist/types-CXBWG4JY.d.ts.map +1 -0
- package/dist/{types-C-hJrsQg.d.ts → types-ChjGDXVS.d.ts} +2 -2
- package/dist/{types-C-hJrsQg.d.ts.map → types-ChjGDXVS.d.ts.map} +1 -1
- package/dist/{types-C_qc_62W.js → types-ome2Ysme.js} +1 -1
- package/dist/{types-C_qc_62W.js.map → types-ome2Ysme.js.map} +1 -1
- package/dist/{utils-DtWREYeO.d.ts → utils-BuSw6Mud.d.ts} +3 -11
- package/dist/utils-BuSw6Mud.d.ts.map +1 -0
- package/dist/utils-Dtdm4vFs.js +74 -0
- package/dist/utils-Dtdm4vFs.js.map +1 -0
- package/dist/wallet/index.d.ts +1 -1
- package/dist/wallet/index.js +1 -1
- package/dist/wallet/mock/factory.d.ts +2 -2
- package/dist/wallet/mock/factory.js +1 -1
- package/dist/wallet/mock/index.d.ts +2 -2
- package/dist/wallet/mock/index.js +1 -1
- package/dist/wallet/privy/factory.d.ts +3 -3
- package/dist/wallet/privy/factory.js +2 -2
- package/dist/wallet/privy/index.d.ts +2 -2
- package/dist/wallet/privy/index.js +1 -1
- package/dist/wallet/rainbow/factory.d.ts +2 -2
- package/dist/wallet/rainbow/factory.js +1 -1
- package/dist/wallet/rainbow/index.d.ts +2 -2
- package/dist/wallet/rainbow/index.js +1 -1
- package/package.json +9 -3
- package/dist/local-credential-verifier-CU8hmFlR.js.map +0 -1
- package/dist/signer-DrjINLqt.js.map +0 -1
- package/dist/types-BGQKPoUr.d.ts.map +0 -1
- package/dist/utils-DtWREYeO.d.ts.map +0 -1
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { a as DEFAULT_RENOWN_NETWORK_ID, o as DEFAULT_RENOWN_URL, r as CREDENTIAL_TYPES } from "./constants-BexAR53F.js";
|
|
2
|
+
import { c as MissingSwitchboardError, l as SwitchboardClient, n as buildAndSignCredential, o as verifyCredentialSignature, r as fetchDelegationCredential, u as resolveSwitchboardEndpoint } from "./signer-trust-D7vg4xbS.js";
|
|
3
|
+
import { a as verifyAuthBearerToken, i as parsePkhDid } from "./utils-Dtdm4vFs.js";
|
|
4
|
+
import { s as RenownCryptoBuilder, t as RenownCryptoSigner } from "./signer-DIbtSfsu.js";
|
|
5
|
+
//#region src/storage/common.ts
|
|
6
|
+
var BaseStorage = class {};
|
|
7
|
+
var MemoryStorage = class extends BaseStorage {
|
|
8
|
+
data = /* @__PURE__ */ new Map();
|
|
9
|
+
get(key) {
|
|
10
|
+
return this.data.get(key);
|
|
11
|
+
}
|
|
12
|
+
set(key, value) {
|
|
13
|
+
if (value === void 0) this.data.delete(key);
|
|
14
|
+
else this.data.set(key, value);
|
|
15
|
+
}
|
|
16
|
+
delete(key) {
|
|
17
|
+
this.data.delete(key);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/common.ts
|
|
22
|
+
var RenownMemoryStorage = class extends MemoryStorage {};
|
|
23
|
+
/**
|
|
24
|
+
* The acting identity an action's signature carries.
|
|
25
|
+
*
|
|
26
|
+
* `User` here is the whole session record — it also holds the DID, the
|
|
27
|
+
* credential, the fetched profile and ENS info — while `UserActionSigner` is
|
|
28
|
+
* what travels on a signed action, and it is deliberately just an address on a
|
|
29
|
+
* chain. The reactor's `ReactorSignerUserInput` declares exactly these three
|
|
30
|
+
* fields, and a GraphQL input object refuses a field it does not declare by
|
|
31
|
+
* rejecting the WHOLE request, so handing the session record to the signer
|
|
32
|
+
* makes every signed push fail before it reaches the reactor.
|
|
33
|
+
*
|
|
34
|
+
* Narrowed here rather than at the transport, because the session record has no
|
|
35
|
+
* business being on an operation in the first place: it is stored on every
|
|
36
|
+
* operation a local reactor writes, not only on the ones that go over a wire.
|
|
37
|
+
*
|
|
38
|
+
* The compiler cannot catch the difference — excess-property checks apply to
|
|
39
|
+
* fresh object literals, never to a variable of a wider type — which is why
|
|
40
|
+
* this is a function rather than a type annotation.
|
|
41
|
+
*/
|
|
42
|
+
function toActionSigner(user) {
|
|
43
|
+
if (!user) return void 0;
|
|
44
|
+
return {
|
|
45
|
+
address: user.address,
|
|
46
|
+
networkId: user.networkId,
|
|
47
|
+
chainId: user.chainId
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
var Renown = class {
|
|
51
|
+
#baseUrl;
|
|
52
|
+
#store;
|
|
53
|
+
#eventEmitter;
|
|
54
|
+
#appName;
|
|
55
|
+
#crypto;
|
|
56
|
+
#signer;
|
|
57
|
+
#profileFetcher;
|
|
58
|
+
#switchboard;
|
|
59
|
+
#chainId;
|
|
60
|
+
#status = "initial";
|
|
61
|
+
constructor(store, eventEmitter, crypto, appName, baseUrl = DEFAULT_RENOWN_URL, profileFetcher, switchboard, chainId = 1) {
|
|
62
|
+
this.#store = store;
|
|
63
|
+
this.#eventEmitter = eventEmitter;
|
|
64
|
+
this.#baseUrl = baseUrl;
|
|
65
|
+
this.#crypto = crypto;
|
|
66
|
+
this.#appName = appName;
|
|
67
|
+
this.#profileFetcher = profileFetcher;
|
|
68
|
+
this.#switchboard = switchboard;
|
|
69
|
+
this.#chainId = chainId;
|
|
70
|
+
const restoredUser = this.user;
|
|
71
|
+
this.#signer = new RenownCryptoSigner(crypto, this.#appName, toActionSigner(restoredUser));
|
|
72
|
+
if (restoredUser) this.#status = "authorized";
|
|
73
|
+
this.on("user", (user) => {
|
|
74
|
+
this.#signer.user = toActionSigner(user);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
get baseUrl() {
|
|
78
|
+
return this.#baseUrl;
|
|
79
|
+
}
|
|
80
|
+
/** Chain id this app issues credentials on; a session from another chain is rejected by {@link signIn}. */
|
|
81
|
+
get chainId() {
|
|
82
|
+
return this.#chainId;
|
|
83
|
+
}
|
|
84
|
+
get user() {
|
|
85
|
+
return this.#store.get("user");
|
|
86
|
+
}
|
|
87
|
+
get status() {
|
|
88
|
+
return this.#status;
|
|
89
|
+
}
|
|
90
|
+
get signer() {
|
|
91
|
+
return this.#signer;
|
|
92
|
+
}
|
|
93
|
+
get crypto() {
|
|
94
|
+
return this.#crypto;
|
|
95
|
+
}
|
|
96
|
+
get did() {
|
|
97
|
+
return this.#crypto.did;
|
|
98
|
+
}
|
|
99
|
+
get profileFetcher() {
|
|
100
|
+
return this.#profileFetcher;
|
|
101
|
+
}
|
|
102
|
+
#updateStatus(status) {
|
|
103
|
+
this.#status = status;
|
|
104
|
+
this.#eventEmitter.emit("status", status);
|
|
105
|
+
}
|
|
106
|
+
#updateUser(user) {
|
|
107
|
+
if (user) this.#store.set("user", user);
|
|
108
|
+
else this.#store.delete("user");
|
|
109
|
+
this.#eventEmitter.emit("user", user);
|
|
110
|
+
}
|
|
111
|
+
async login(userDid) {
|
|
112
|
+
this.#updateStatus("checking");
|
|
113
|
+
try {
|
|
114
|
+
const result = parsePkhDid(userDid);
|
|
115
|
+
const credential = await this.#getCredential(result.address, result.chainId, this.#crypto.did);
|
|
116
|
+
if (!credential) {
|
|
117
|
+
this.#updateUser(void 0);
|
|
118
|
+
throw new Error("Credential not found");
|
|
119
|
+
}
|
|
120
|
+
return await this.#completeLogin(userDid, result, credential);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
this.#updateUser(void 0);
|
|
123
|
+
this.#updateStatus("not-authorized");
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async signIn(params) {
|
|
128
|
+
if (!this.#switchboard) throw new MissingSwitchboardError();
|
|
129
|
+
const { address, chainId, signTypedData, username, userImage, expiresInDays } = params;
|
|
130
|
+
if (chainId !== this.#chainId) throw new Error(`Renown signIn: wallet is on chain ${chainId}, but this app issues credentials on chain ${this.#chainId}. Switch networks and retry — signing here would create a separate identity for the same address.`);
|
|
131
|
+
this.#updateStatus("checking");
|
|
132
|
+
try {
|
|
133
|
+
const credential = await buildAndSignCredential({
|
|
134
|
+
signTypedData,
|
|
135
|
+
address,
|
|
136
|
+
chainId,
|
|
137
|
+
app: this.#appName,
|
|
138
|
+
appId: this.did,
|
|
139
|
+
expiresInDays
|
|
140
|
+
});
|
|
141
|
+
await this.#switchboard.issueCredential(credential);
|
|
142
|
+
await this.#switchboard.findOrCreateUser(address, {
|
|
143
|
+
username,
|
|
144
|
+
userImage
|
|
145
|
+
});
|
|
146
|
+
const userDid = `did:pkh:${DEFAULT_RENOWN_NETWORK_ID}:${chainId}:${address.toLowerCase()}`;
|
|
147
|
+
return await this.#completeLogin(userDid, parsePkhDid(userDid), credential);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
this.#updateUser(void 0);
|
|
150
|
+
this.#updateStatus("not-authorized");
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async #completeLogin(userDid, result, credential) {
|
|
155
|
+
if (!(credential.issuer.id === userDid && credential.credentialSubject.id === this.did)) throw new Error("Invalid credential");
|
|
156
|
+
const verifiableCredential = credential.proof.eip712?.domain ? credential : {
|
|
157
|
+
...credential,
|
|
158
|
+
proof: {
|
|
159
|
+
...credential.proof,
|
|
160
|
+
eip712: {
|
|
161
|
+
domain: {
|
|
162
|
+
version: "1",
|
|
163
|
+
chainId: result.chainId
|
|
164
|
+
},
|
|
165
|
+
types: CREDENTIAL_TYPES,
|
|
166
|
+
primaryType: "VerifiableCredential"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
if (credential.issuer.ethereumAddress.toLowerCase() !== result.address.toLowerCase() || verifiableCredential.proof.eip712.domain.chainId !== result.chainId || !await verifyCredentialSignature(verifiableCredential)) throw new Error("Invalid credential signature");
|
|
171
|
+
const user = {
|
|
172
|
+
...result,
|
|
173
|
+
address: credential.issuer.ethereumAddress,
|
|
174
|
+
did: userDid,
|
|
175
|
+
credential: verifiableCredential
|
|
176
|
+
};
|
|
177
|
+
this.#updateUser(user);
|
|
178
|
+
this.#updateStatus("authorized");
|
|
179
|
+
if (this.#profileFetcher) this.#profileFetcher(user, this.#baseUrl).then((profile) => {
|
|
180
|
+
if (profile && this.user?.address === user.address && this.user.chainId === user.chainId) this.#updateUser({
|
|
181
|
+
...this.user,
|
|
182
|
+
profile,
|
|
183
|
+
ens: {
|
|
184
|
+
name: profile.username ?? void 0,
|
|
185
|
+
avatarUrl: profile.userImage ?? void 0
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}).catch(console.error);
|
|
189
|
+
return user;
|
|
190
|
+
}
|
|
191
|
+
logout() {
|
|
192
|
+
this.#updateUser(void 0);
|
|
193
|
+
this.#updateStatus("initial");
|
|
194
|
+
return Promise.resolve();
|
|
195
|
+
}
|
|
196
|
+
async revalidate() {
|
|
197
|
+
const user = this.user;
|
|
198
|
+
if (!user) return false;
|
|
199
|
+
try {
|
|
200
|
+
if (!await this.#getCredential(user.address, user.chainId, this.#crypto.did)) {
|
|
201
|
+
await this.logout();
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
await this.refreshProfile();
|
|
205
|
+
return true;
|
|
206
|
+
} catch {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async refreshProfile() {
|
|
211
|
+
const user = this.user;
|
|
212
|
+
if (!user || !this.#profileFetcher) return false;
|
|
213
|
+
try {
|
|
214
|
+
const profile = await this.#profileFetcher(user, this.#baseUrl);
|
|
215
|
+
if (!profile) return false;
|
|
216
|
+
const current = this.user;
|
|
217
|
+
if (!current || current.address !== user.address || current.chainId !== user.chainId) return false;
|
|
218
|
+
if (current.profile !== void 0 && current.profile.documentId === profile.documentId && current.profile.username === profile.username && current.profile.userImage === profile.userImage) return false;
|
|
219
|
+
this.#updateUser({
|
|
220
|
+
...current,
|
|
221
|
+
profile,
|
|
222
|
+
ens: {
|
|
223
|
+
name: profile.username ?? void 0,
|
|
224
|
+
avatarUrl: profile.userImage ?? void 0
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
return true;
|
|
228
|
+
} catch {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
on(event, listener) {
|
|
233
|
+
return this.#eventEmitter.on(event, listener);
|
|
234
|
+
}
|
|
235
|
+
async #getCredential(address, chainId, appDid) {
|
|
236
|
+
if (this.#switchboard) return this.#switchboard.getCredential({
|
|
237
|
+
address,
|
|
238
|
+
chainId,
|
|
239
|
+
appDid
|
|
240
|
+
});
|
|
241
|
+
if (!this.#baseUrl) throw new Error("RENOWN_URL is not set");
|
|
242
|
+
const url = new URL(`/api/auth/credential?address=${encodeURIComponent(address)}&chainId=${encodeURIComponent(chainId)}&connectId=${encodeURIComponent(appDid)}&appId=${encodeURIComponent(appDid)}`, this.#baseUrl);
|
|
243
|
+
const response = await fetch(url, { method: "GET" });
|
|
244
|
+
if (response.ok) return (await response.json()).credential;
|
|
245
|
+
else throw new Error(`Failed to get credential: ${response.status}`);
|
|
246
|
+
}
|
|
247
|
+
async verifyBearerToken(token) {
|
|
248
|
+
return verifyAuthBearerToken(token);
|
|
249
|
+
}
|
|
250
|
+
async getBearerToken(options) {
|
|
251
|
+
if (!this.user) throw new Error("User not found");
|
|
252
|
+
return this.#crypto.getBearerToken(this.user.address, options);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/event/memory.ts
|
|
257
|
+
var MemoryEventEmitter = class {
|
|
258
|
+
#listeners = /* @__PURE__ */ new Map();
|
|
259
|
+
on(event, listener) {
|
|
260
|
+
if (!this.#listeners.has(event)) this.#listeners.set(event, /* @__PURE__ */ new Set());
|
|
261
|
+
this.#listeners.get(event).add(listener);
|
|
262
|
+
return () => {
|
|
263
|
+
this.#listeners.get(event)?.delete(listener);
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
emit(event, data) {
|
|
267
|
+
this.#listeners.get(event)?.forEach((listener) => listener(data));
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region src/profile.ts
|
|
272
|
+
const fetchRenownProfile = async (user, baseUrl) => {
|
|
273
|
+
try {
|
|
274
|
+
const response = await fetch(`${baseUrl.replace(/\/+$/, "")}/api/profile`, {
|
|
275
|
+
method: "POST",
|
|
276
|
+
headers: { "Content-Type": "application/json" },
|
|
277
|
+
body: JSON.stringify({ ethAddress: user.address })
|
|
278
|
+
});
|
|
279
|
+
if (!response.ok) return;
|
|
280
|
+
return (await response.json()).profile ?? void 0;
|
|
281
|
+
} catch {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/renown-builder.ts
|
|
287
|
+
/**
|
|
288
|
+
* Base builder for creating Renown instances.
|
|
289
|
+
* Use platform-specific builders (RenownBuilder from init.browser.js or init.node.js)
|
|
290
|
+
* for pre-configured defaults.
|
|
291
|
+
*/
|
|
292
|
+
var BaseRenownBuilder = class BaseRenownBuilder {
|
|
293
|
+
#appName;
|
|
294
|
+
#storage;
|
|
295
|
+
#eventEmitter;
|
|
296
|
+
#crypto;
|
|
297
|
+
#keyPairStorage;
|
|
298
|
+
#baseUrl;
|
|
299
|
+
#switchboardUrl;
|
|
300
|
+
#profileFetcher;
|
|
301
|
+
#chainId;
|
|
302
|
+
/**
|
|
303
|
+
* @param appName - Application name used for signing context
|
|
304
|
+
*/
|
|
305
|
+
constructor(appName) {
|
|
306
|
+
this.#appName = appName;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Set custom storage for user data persistence.
|
|
310
|
+
* Defaults to in-memory storage if not set.
|
|
311
|
+
*/
|
|
312
|
+
withStorage(storage) {
|
|
313
|
+
this.#storage = storage;
|
|
314
|
+
return this;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Set custom event emitter for user state changes.
|
|
318
|
+
* Defaults to in-memory event emitter if not set.
|
|
319
|
+
*/
|
|
320
|
+
withEventEmitter(eventEmitter) {
|
|
321
|
+
this.#eventEmitter = eventEmitter;
|
|
322
|
+
return this;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Set a pre-built crypto instance.
|
|
326
|
+
* Either crypto or keyPairStorage must be provided.
|
|
327
|
+
*/
|
|
328
|
+
withCrypto(crypto) {
|
|
329
|
+
this.#crypto = crypto;
|
|
330
|
+
return this;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Set key pair storage for cryptographic keys.
|
|
334
|
+
* A crypto instance will be built from this storage.
|
|
335
|
+
* Either crypto or keyPairStorage must be provided.
|
|
336
|
+
*/
|
|
337
|
+
withKeyPairStorage(keyPairStorage) {
|
|
338
|
+
this.#keyPairStorage = keyPairStorage;
|
|
339
|
+
return this;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Set the Renown server URL for credential verification.
|
|
343
|
+
* Defaults to https://www.renown.id
|
|
344
|
+
*/
|
|
345
|
+
withBaseUrl(baseUrl) {
|
|
346
|
+
this.#baseUrl = baseUrl;
|
|
347
|
+
return this;
|
|
348
|
+
}
|
|
349
|
+
withSwitchboardUrl(switchboardUrl) {
|
|
350
|
+
this.#switchboardUrl = switchboardUrl;
|
|
351
|
+
return this;
|
|
352
|
+
}
|
|
353
|
+
withChainId(chainId) {
|
|
354
|
+
this.#chainId = chainId;
|
|
355
|
+
return this;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Set a profile fetcher strategy for enriching user data after login.
|
|
359
|
+
* The fetcher receives the authenticated user and the base URL,
|
|
360
|
+
* and returns a RenownProfile. Called in the background after each login.
|
|
361
|
+
* Defaults to fetchRenownProfile which calls the Renown API.
|
|
362
|
+
*/
|
|
363
|
+
withProfileFetcher(profileFetcher) {
|
|
364
|
+
this.#profileFetcher = profileFetcher;
|
|
365
|
+
return this;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Build and initialize the Renown instance.
|
|
369
|
+
* If a user is stored, attempts to re-authenticate them.
|
|
370
|
+
* @throws Error if neither crypto nor keyPairStorage is provided
|
|
371
|
+
*/
|
|
372
|
+
async build() {
|
|
373
|
+
if (!this.#crypto && !this.#keyPairStorage) throw new Error("Either crypto or keyPairStorage is required. Use withCrypto() or withKeyPairStorage() to set one.");
|
|
374
|
+
const chainId = this.#chainId ?? 1;
|
|
375
|
+
const crypto = this.#crypto ?? await new RenownCryptoBuilder().withKeyPairStorage(this.#keyPairStorage).withChainId(chainId).build();
|
|
376
|
+
if (crypto.chainId !== void 0 && crypto.chainId !== chainId) console.warn(`Renown: the supplied crypto signs bearer tokens for chain ${crypto.chainId}, but credentials are issued on chain ${chainId}.`);
|
|
377
|
+
const storage = this.#storage ?? new RenownMemoryStorage();
|
|
378
|
+
const eventEmitter = this.#eventEmitter ?? new MemoryEventEmitter();
|
|
379
|
+
const baseUrl = this.#baseUrl ?? "https://www.renown.id";
|
|
380
|
+
const switchboardEndpoint = await resolveSwitchboardEndpoint({
|
|
381
|
+
switchboardUrl: this.#switchboardUrl,
|
|
382
|
+
baseUrl
|
|
383
|
+
});
|
|
384
|
+
const switchboard = switchboardEndpoint ? new SwitchboardClient(switchboardEndpoint) : void 0;
|
|
385
|
+
const profileFetcher = this.#profileFetcher ?? (switchboard ? switchboard.profileFetcher : fetchRenownProfile);
|
|
386
|
+
return new Renown(storage, eventEmitter, crypto, this.#appName, baseUrl, profileFetcher, switchboard, chainId);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Create a BaseRenownBuilder from options object for a more concise API
|
|
390
|
+
*/
|
|
391
|
+
static from(options) {
|
|
392
|
+
const builder = new BaseRenownBuilder(options.appName);
|
|
393
|
+
if (options.storage) builder.withStorage(options.storage);
|
|
394
|
+
if (options.eventEmitter) builder.withEventEmitter(options.eventEmitter);
|
|
395
|
+
if (options.crypto) builder.withCrypto(options.crypto);
|
|
396
|
+
if (options.keyPairStorage) builder.withKeyPairStorage(options.keyPairStorage);
|
|
397
|
+
if (options.baseUrl) builder.withBaseUrl(options.baseUrl);
|
|
398
|
+
if (options.switchboardUrl) builder.withSwitchboardUrl(options.switchboardUrl);
|
|
399
|
+
if (options.profileFetcher) builder.withProfileFetcher(options.profileFetcher);
|
|
400
|
+
if (options.chainId !== void 0) builder.withChainId(options.chainId);
|
|
401
|
+
return builder;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/local-credential-verifier.ts
|
|
406
|
+
/** A credential check that reads a Switchboard's own renown read model through
|
|
407
|
+
* `execute`, rather than any Renown or Switchboard over HTTP. */
|
|
408
|
+
function createLocalCredentialVerifier(execute, options = {}) {
|
|
409
|
+
const request = async (query, variables) => {
|
|
410
|
+
try {
|
|
411
|
+
return await execute(query, variables);
|
|
412
|
+
} catch (error) {
|
|
413
|
+
options.onError?.(error);
|
|
414
|
+
throw error;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
return async ({ address, chainId, appId }) => {
|
|
418
|
+
return await fetchDelegationCredential({
|
|
419
|
+
address,
|
|
420
|
+
chainId,
|
|
421
|
+
appDid: appId,
|
|
422
|
+
switchboardRequest: request
|
|
423
|
+
}) !== void 0;
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
//#endregion
|
|
427
|
+
export { RenownMemoryStorage as a, Renown as i, BaseRenownBuilder as n, BaseStorage as o, fetchRenownProfile as r, createLocalCredentialVerifier as t };
|
|
428
|
+
|
|
429
|
+
//# sourceMappingURL=local-credential-verifier-2aC00ymX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-credential-verifier-2aC00ymX.js","names":["#store","#eventEmitter","#baseUrl","#crypto","#appName","#profileFetcher","#switchboard","#chainId","#signer","#status","#updateStatus","#getCredential","#updateUser","#completeLogin","#listeners","#appName","#storage","#eventEmitter","#crypto","#keyPairStorage","#baseUrl","#switchboardUrl","#chainId","#profileFetcher"],"sources":["../src/storage/common.ts","../src/common.ts","../src/event/memory.ts","../src/profile.ts","../src/renown-builder.ts","../src/local-credential-verifier.ts"],"sourcesContent":["export interface IStorage<\n T extends Record<string, unknown> = Record<string, unknown>,\n Key extends keyof T = keyof T,\n> {\n get(key: Key): T[Key] | undefined;\n set(key: Key, value?: T[Key]): void;\n delete(key: Key): void;\n}\n\nexport abstract class BaseStorage<\n T extends Record<string, unknown> = Record<string, unknown>,\n Key extends keyof T = keyof T,\n> implements IStorage<T> {\n abstract get(key: Key): T[Key] | undefined;\n abstract set(key: Key, value?: T[Key]): void;\n abstract delete(key: Key): void;\n}\n\nexport class MemoryStorage<\n T extends Record<string, unknown> = Record<string, unknown>,\n Key extends keyof T = keyof T,\n> extends BaseStorage<T> {\n private readonly data = new Map<Key, T[Key]>();\n\n get(key: Key) {\n return this.data.get(key);\n }\n\n set(key: Key, value?: T[Key]): void {\n if (value === undefined) {\n this.data.delete(key);\n } else {\n this.data.set(key, value);\n }\n }\n\n delete(key: Key): void {\n this.data.delete(key);\n }\n}\n","import {\n CREDENTIAL_TYPES,\n DEFAULT_RENOWN_CHAIN_ID,\n DEFAULT_RENOWN_NETWORK_ID,\n DEFAULT_RENOWN_URL,\n} from \"./constants.js\";\nimport {\n buildAndSignCredential,\n verifyCredentialSignature,\n} from \"./credential.js\";\nimport { RenownCryptoSigner, type IRenownCrypto } from \"./crypto/index.js\";\nimport { MemoryStorage } from \"./storage/common.js\";\nimport {\n MissingSwitchboardError,\n type SwitchboardClient,\n} from \"./switchboard.js\";\nimport type {\n CreateBearerTokenOptions,\n IProof,\n IRenown,\n ISigner,\n LoginStatus,\n PKHDid,\n PowerhouseVerifiableCredential,\n ProfileFetcher,\n RenownEventEmitter,\n RenownEvents,\n RenownStorage,\n RenownStorageMap,\n SignInParams,\n User,\n UserActionSigner,\n} from \"./types.js\";\nimport { parsePkhDid, verifyAuthBearerToken } from \"./utils.js\";\nexport * from \"./constants.js\";\n\nexport class RenownMemoryStorage extends MemoryStorage<RenownStorageMap> {}\n\n/**\n * The acting identity an action's signature carries.\n *\n * `User` here is the whole session record — it also holds the DID, the\n * credential, the fetched profile and ENS info — while `UserActionSigner` is\n * what travels on a signed action, and it is deliberately just an address on a\n * chain. The reactor's `ReactorSignerUserInput` declares exactly these three\n * fields, and a GraphQL input object refuses a field it does not declare by\n * rejecting the WHOLE request, so handing the session record to the signer\n * makes every signed push fail before it reaches the reactor.\n *\n * Narrowed here rather than at the transport, because the session record has no\n * business being on an operation in the first place: it is stored on every\n * operation a local reactor writes, not only on the ones that go over a wire.\n *\n * The compiler cannot catch the difference — excess-property checks apply to\n * fresh object literals, never to a variable of a wider type — which is why\n * this is a function rather than a type annotation.\n */\nfunction toActionSigner(user: User | undefined): UserActionSigner | undefined {\n if (!user) return undefined;\n return {\n address: user.address,\n networkId: user.networkId,\n chainId: user.chainId,\n };\n}\n\nexport class Renown implements IRenown {\n #baseUrl: string;\n #store: RenownStorage;\n #eventEmitter: RenownEventEmitter;\n #appName: string;\n #crypto: IRenownCrypto;\n #signer: ISigner;\n #profileFetcher?: ProfileFetcher;\n #switchboard?: SwitchboardClient;\n #chainId: number;\n #status: LoginStatus = \"initial\";\n\n constructor(\n store: RenownStorage,\n eventEmitter: RenownEventEmitter,\n crypto: IRenownCrypto,\n appName: string,\n baseUrl = DEFAULT_RENOWN_URL,\n profileFetcher?: ProfileFetcher,\n switchboard?: SwitchboardClient,\n chainId = Number(DEFAULT_RENOWN_CHAIN_ID),\n ) {\n this.#store = store;\n this.#eventEmitter = eventEmitter;\n this.#baseUrl = baseUrl;\n this.#crypto = crypto;\n this.#appName = appName;\n this.#profileFetcher = profileFetcher;\n this.#switchboard = switchboard;\n this.#chainId = chainId;\n const restoredUser = this.user;\n this.#signer = new RenownCryptoSigner(\n crypto,\n this.#appName,\n toActionSigner(restoredUser),\n );\n\n // A restored, previously-verified user is an authorized session; otherwise\n // status stays \"initial\" after a reload while the user is present.\n if (restoredUser) {\n this.#status = \"authorized\";\n }\n\n this.on(\"user\", (user) => {\n this.#signer.user = toActionSigner(user);\n });\n }\n\n get baseUrl() {\n return this.#baseUrl;\n }\n\n /** Chain id this app issues credentials on; a session from another chain is rejected by {@link signIn}. */\n get chainId() {\n return this.#chainId;\n }\n\n get user() {\n return this.#store.get(\"user\");\n }\n\n get status() {\n return this.#status;\n }\n\n get signer() {\n return this.#signer;\n }\n\n get crypto() {\n return this.#crypto;\n }\n\n get did() {\n return this.#crypto.did;\n }\n\n get profileFetcher() {\n return this.#profileFetcher;\n }\n\n #updateStatus(status: LoginStatus) {\n this.#status = status;\n this.#eventEmitter.emit(\"status\", status);\n }\n\n #updateUser(user: User | undefined) {\n if (user) {\n this.#store.set(\"user\", user);\n } else {\n this.#store.delete(\"user\");\n }\n this.#eventEmitter.emit(\"user\", user);\n }\n\n async login(userDid: string): Promise<User> {\n this.#updateStatus(\"checking\");\n try {\n const result = parsePkhDid(userDid);\n const credential = await this.#getCredential(\n result.address,\n result.chainId,\n this.#crypto.did,\n );\n\n if (!credential) {\n this.#updateUser(undefined);\n throw new Error(\"Credential not found\");\n }\n\n return await this.#completeLogin(userDid, result, credential);\n } catch (error) {\n this.#updateUser(undefined);\n this.#updateStatus(\"not-authorized\");\n throw error;\n }\n }\n\n // Sign in without the Renown redirect: build + sign a delegation credential\n // with the caller's wallet signer, write it to the switchboard, then log in.\n async signIn(params: SignInParams): Promise<User> {\n if (!this.#switchboard) throw new MissingSwitchboardError();\n const {\n address,\n chainId,\n signTypedData,\n username,\n userImage,\n expiresInDays,\n } = params;\n\n // The chain id goes into the issuer DID and the EIP-712 domain, so signing on\n // another chain would mint a second identity for the same wallet.\n if (chainId !== this.#chainId) {\n throw new Error(\n `Renown signIn: wallet is on chain ${chainId}, but this app issues credentials on chain ${this.#chainId}. Switch networks and retry — signing here would create a separate identity for the same address.`,\n );\n }\n\n this.#updateStatus(\"checking\");\n try {\n const credential = await buildAndSignCredential({\n signTypedData,\n address,\n chainId,\n app: this.#appName,\n appId: this.did,\n expiresInDays,\n });\n\n await this.#switchboard.issueCredential(credential);\n await this.#switchboard.findOrCreateUser(address, {\n username,\n userImage,\n });\n\n const userDid = `did:pkh:${DEFAULT_RENOWN_NETWORK_ID}:${chainId}:${address.toLowerCase()}`;\n // Authenticate from the freshly signed credential — no read-back, which\n // avoids racing the read-model processor that indexes the write.\n return await this.#completeLogin(\n userDid,\n parsePkhDid(userDid),\n credential,\n );\n } catch (error) {\n this.#updateUser(undefined);\n this.#updateStatus(\"not-authorized\");\n throw error;\n }\n }\n\n // Verify a credential binds to userDid + this app key, set the user, and\n // start the background profile fetch. Throws if the credential is invalid.\n async #completeLogin(\n userDid: string,\n result: PKHDid,\n credential: PowerhouseVerifiableCredential,\n ): Promise<User> {\n if (\n !(\n credential.issuer.id === userDid &&\n credential.credentialSubject.id === this.did\n )\n ) {\n throw new Error(\"Invalid credential\");\n }\n\n // The API may return proof.eip712 without domain/types; the domain is\n // canonical (version \"1\", the chainId), so reconstruct it before verifying.\n const eip712 = credential.proof.eip712 as\n | Partial<IProof[\"eip712\"]>\n | undefined;\n const verifiableCredential: PowerhouseVerifiableCredential = eip712?.domain\n ? credential\n : {\n ...credential,\n proof: {\n ...credential.proof,\n eip712: {\n domain: { version: \"1\", chainId: result.chainId },\n types: CREDENTIAL_TYPES,\n primaryType: \"VerifiableCredential\",\n },\n },\n };\n\n // Verify the EIP-712 proof was signed by the DID's address on its chain.\n if (\n credential.issuer.ethereumAddress.toLowerCase() !==\n result.address.toLowerCase() ||\n verifiableCredential.proof.eip712.domain.chainId !== result.chainId ||\n !(await verifyCredentialSignature(verifiableCredential))\n ) {\n throw new Error(\"Invalid credential signature\");\n }\n\n const user: User = {\n ...result,\n address: credential.issuer.ethereumAddress,\n did: userDid,\n credential: verifiableCredential,\n };\n\n this.#updateUser(user);\n this.#updateStatus(\"authorized\");\n\n // Fetch profile data in the background if a fetcher is configured\n if (this.#profileFetcher) {\n this.#profileFetcher(user, this.#baseUrl)\n .then((profile) => {\n if (\n profile &&\n this.user?.address === user.address &&\n this.user.chainId === user.chainId\n ) {\n this.#updateUser({\n ...this.user,\n profile,\n ens: {\n name: profile.username ?? undefined,\n avatarUrl: profile.userImage ?? undefined,\n },\n });\n }\n })\n .catch(console.error);\n }\n\n return user;\n }\n\n logout() {\n this.#updateUser(undefined);\n this.#updateStatus(\"initial\");\n return Promise.resolve();\n }\n\n // Re-check the current user's credential at the source; logs out if it was\n // revoked or expired. Network errors keep the session (fail open).\n async revalidate(): Promise<boolean> {\n const user = this.user;\n if (!user) return false;\n try {\n const credential = await this.#getCredential(\n user.address,\n user.chainId,\n this.#crypto.did,\n );\n if (!credential) {\n await this.logout();\n return false;\n }\n await this.refreshProfile();\n return true;\n } catch {\n return true;\n }\n }\n\n // Re-read profile attributes at the source so a renamed user or changed avatar\n // shows up on the next load. Carries no logout risk, unlike revalidate().\n async refreshProfile(): Promise<boolean> {\n const user = this.user;\n if (!user || !this.#profileFetcher) return false;\n try {\n const profile = await this.#profileFetcher(user, this.#baseUrl);\n if (!profile) return false;\n // Asserted because narrowing from the pre-await read would otherwise hide\n // that a logout during the fetch can clear this.\n const current = this.user as User | undefined;\n if (\n !current ||\n current.address !== user.address ||\n current.chainId !== user.chainId\n ) {\n return false;\n }\n // Narrow `profile` first: the fetched payload is unvalidated JSON, so a\n // missing documentId must not make the undefined case compare equal.\n const unchanged =\n current.profile !== undefined &&\n current.profile.documentId === profile.documentId &&\n current.profile.username === profile.username &&\n current.profile.userImage === profile.userImage;\n if (unchanged) return false;\n this.#updateUser({\n ...current,\n profile,\n ens: {\n name: profile.username ?? undefined,\n avatarUrl: profile.userImage ?? undefined,\n },\n });\n return true;\n } catch {\n return false;\n }\n }\n\n on<K extends keyof RenownEvents>(\n event: K,\n listener: (data: RenownEvents[K]) => void,\n ): () => void {\n return this.#eventEmitter.on(event, listener);\n }\n\n async #getCredential(\n address: string,\n chainId: number,\n appDid: string,\n ): Promise<PowerhouseVerifiableCredential | undefined> {\n // Direct-switchboard flow: read the credential from the reactor subgraph.\n if (this.#switchboard) {\n return this.#switchboard.getCredential({ address, chainId, appDid });\n }\n if (!this.#baseUrl) {\n throw new Error(\"RENOWN_URL is not set\");\n }\n const url = new URL(\n `/api/auth/credential?address=${encodeURIComponent(address)}&chainId=${encodeURIComponent(chainId)}&connectId=${encodeURIComponent(appDid)}&appId=${encodeURIComponent(appDid)}`,\n this.#baseUrl,\n );\n const response = await fetch(url, {\n method: \"GET\",\n });\n if (response.ok) {\n const result = (await response.json()) as {\n credential: PowerhouseVerifiableCredential;\n };\n return result.credential;\n } else {\n throw new Error(`Failed to get credential: ${response.status}`);\n }\n }\n\n async verifyBearerToken(token: string) {\n return verifyAuthBearerToken(token);\n }\n\n async getBearerToken(options: CreateBearerTokenOptions) {\n if (!this.user) {\n throw new Error(\"User not found\");\n }\n return this.#crypto.getBearerToken(this.user.address, options);\n }\n}\n","import type { RenownEvents } from \"../types.js\";\nimport type { IEventEmitter } from \"./types.js\";\n\nexport class MemoryEventEmitter implements IEventEmitter<RenownEvents> {\n #listeners = new Map<keyof RenownEvents, Set<(data: unknown) => void>>();\n\n on<K extends keyof RenownEvents>(\n event: K,\n listener: (data: RenownEvents[K]) => void,\n ): () => void {\n if (!this.#listeners.has(event)) {\n this.#listeners.set(event, new Set());\n }\n this.#listeners.get(event)!.add(listener as (data: unknown) => void);\n return () => {\n this.#listeners.get(event)?.delete(listener as (data: unknown) => void);\n };\n }\n\n emit<K extends keyof RenownEvents>(event: K, data: RenownEvents[K]): void {\n this.#listeners.get(event)?.forEach((listener) => listener(data));\n }\n}\n","import type { ProfileFetcher, RenownProfile } from \"./types.js\";\n\nexport const fetchRenownProfile: ProfileFetcher = async (user, baseUrl) => {\n try {\n const response = await fetch(`${baseUrl.replace(/\\/+$/, \"\")}/api/profile`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n ethAddress: user.address,\n }),\n });\n\n if (!response.ok) {\n return undefined;\n }\n\n const result = (await response.json()) as {\n profile?: RenownProfile;\n };\n\n return result.profile ?? undefined;\n } catch {\n return undefined;\n }\n};\n","import { Renown, RenownMemoryStorage } from \"./common.js\";\nimport { DEFAULT_RENOWN_CHAIN_ID, DEFAULT_RENOWN_URL } from \"./constants.js\";\nimport { RenownCryptoBuilder } from \"./crypto/renown-crypto-builder.js\";\nimport type { IRenownCrypto, JsonWebKeyPairStorage } from \"./crypto/types.js\";\nimport { resolveSwitchboardEndpoint } from \"./discovery.js\";\nimport { MemoryEventEmitter } from \"./event/memory.js\";\nimport { fetchRenownProfile } from \"./profile.js\";\nimport { SwitchboardClient } from \"./switchboard.js\";\nimport type {\n ProfileFetcher,\n RenownEventEmitter,\n RenownStorage,\n} from \"./types.js\";\n\nexport interface RenownBuilderOptions {\n appName: string;\n storage?: RenownStorage;\n eventEmitter?: RenownEventEmitter;\n crypto?: IRenownCrypto;\n keyPairStorage?: JsonWebKeyPairStorage;\n baseUrl?: string;\n switchboardUrl?: string;\n profileFetcher?: ProfileFetcher;\n /** Chain id credentials are issued on (default 1). The issuer DID embeds it, so `signIn` rejects a wallet session from another chain. */\n chainId?: number;\n}\n\n/**\n * Base builder for creating Renown instances.\n * Use platform-specific builders (RenownBuilder from init.browser.js or init.node.js)\n * for pre-configured defaults.\n */\nexport class BaseRenownBuilder {\n #appName: string;\n #storage?: RenownStorage;\n #eventEmitter?: RenownEventEmitter;\n #crypto?: IRenownCrypto;\n #keyPairStorage?: JsonWebKeyPairStorage;\n #baseUrl?: string;\n #switchboardUrl?: string;\n #profileFetcher?: ProfileFetcher;\n #chainId?: number;\n\n /**\n * @param appName - Application name used for signing context\n */\n constructor(appName: string) {\n this.#appName = appName;\n }\n\n /**\n * Set custom storage for user data persistence.\n * Defaults to in-memory storage if not set.\n */\n withStorage(storage: RenownStorage): this {\n this.#storage = storage;\n return this;\n }\n\n /**\n * Set custom event emitter for user state changes.\n * Defaults to in-memory event emitter if not set.\n */\n withEventEmitter(eventEmitter: RenownEventEmitter): this {\n this.#eventEmitter = eventEmitter;\n return this;\n }\n\n /**\n * Set a pre-built crypto instance.\n * Either crypto or keyPairStorage must be provided.\n */\n withCrypto(crypto: IRenownCrypto): this {\n this.#crypto = crypto;\n return this;\n }\n\n /**\n * Set key pair storage for cryptographic keys.\n * A crypto instance will be built from this storage.\n * Either crypto or keyPairStorage must be provided.\n */\n withKeyPairStorage(keyPairStorage: JsonWebKeyPairStorage): this {\n this.#keyPairStorage = keyPairStorage;\n return this;\n }\n\n /**\n * Set the Renown server URL for credential verification.\n * Defaults to https://www.renown.id\n */\n withBaseUrl(baseUrl: string): this {\n this.#baseUrl = baseUrl;\n return this;\n }\n\n // Set the Switchboard GraphQL endpoint to read from the reactor directly.\n // When unset, the SDK discovers it from the base URL, else uses the REST flow.\n withSwitchboardUrl(switchboardUrl: string): this {\n this.#switchboardUrl = switchboardUrl;\n return this;\n }\n\n // Set the chain id credentials are issued on (default 1). It is part of the\n // issuer DID, so signIn rejects a wallet session from a different chain.\n withChainId(chainId: number): this {\n this.#chainId = chainId;\n return this;\n }\n\n /**\n * Set a profile fetcher strategy for enriching user data after login.\n * The fetcher receives the authenticated user and the base URL,\n * and returns a RenownProfile. Called in the background after each login.\n * Defaults to fetchRenownProfile which calls the Renown API.\n */\n withProfileFetcher(profileFetcher: ProfileFetcher): this {\n this.#profileFetcher = profileFetcher;\n return this;\n }\n\n /**\n * Build and initialize the Renown instance.\n * If a user is stored, attempts to re-authenticate them.\n * @throws Error if neither crypto nor keyPairStorage is provided\n */\n async build(): Promise<Renown> {\n if (!this.#crypto && !this.#keyPairStorage) {\n throw new Error(\n \"Either crypto or keyPairStorage is required. Use withCrypto() or withKeyPairStorage() to set one.\",\n );\n }\n\n const chainId = this.#chainId ?? Number(DEFAULT_RENOWN_CHAIN_ID);\n const crypto =\n this.#crypto ??\n (await new RenownCryptoBuilder()\n .withKeyPairStorage(this.#keyPairStorage!)\n .withChainId(chainId)\n .build());\n\n // A crypto supplied via withCrypto() carries its own chain; the bearer token\n // it mints would then disagree with the credentials issued here.\n if (crypto.chainId !== undefined && crypto.chainId !== chainId) {\n console.warn(\n `Renown: the supplied crypto signs bearer tokens for chain ${crypto.chainId}, but credentials are issued on chain ${chainId}.`,\n );\n }\n\n const storage = this.#storage ?? new RenownMemoryStorage();\n const eventEmitter = this.#eventEmitter ?? new MemoryEventEmitter();\n const baseUrl = this.#baseUrl ?? DEFAULT_RENOWN_URL;\n\n // Pick the transport once: direct-switchboard when an endpoint resolves,\n // else the REST flow. A custom profile fetcher always takes precedence.\n const switchboardEndpoint = await resolveSwitchboardEndpoint({\n switchboardUrl: this.#switchboardUrl,\n baseUrl,\n });\n const switchboard = switchboardEndpoint\n ? new SwitchboardClient(switchboardEndpoint)\n : undefined;\n const profileFetcher =\n this.#profileFetcher ??\n (switchboard ? switchboard.profileFetcher : fetchRenownProfile);\n\n const renown = new Renown(\n storage,\n eventEmitter,\n crypto,\n this.#appName,\n baseUrl,\n profileFetcher,\n switchboard,\n chainId,\n );\n\n // A stored user is loaded as-is for an instant, offline-safe start; callers\n // revalidate against the source separately via renown.revalidate().\n return renown;\n }\n\n /**\n * Create a BaseRenownBuilder from options object for a more concise API\n */\n static from(options: RenownBuilderOptions): BaseRenownBuilder {\n const builder = new BaseRenownBuilder(options.appName);\n\n if (options.storage) {\n builder.withStorage(options.storage);\n }\n if (options.eventEmitter) {\n builder.withEventEmitter(options.eventEmitter);\n }\n if (options.crypto) {\n builder.withCrypto(options.crypto);\n }\n if (options.keyPairStorage) {\n builder.withKeyPairStorage(options.keyPairStorage);\n }\n if (options.baseUrl) {\n builder.withBaseUrl(options.baseUrl);\n }\n if (options.switchboardUrl) {\n builder.withSwitchboardUrl(options.switchboardUrl);\n }\n if (options.profileFetcher) {\n builder.withProfileFetcher(options.profileFetcher);\n }\n if (options.chainId !== undefined) {\n builder.withChainId(options.chainId);\n }\n\n return builder;\n }\n}\n","import { fetchDelegationCredential } from \"./credential.js\";\nimport type { SwitchboardRequestFn } from \"./switchboard.js\";\n\n/** Confirms an authenticated signer's delegation credential is still live. */\nexport type CredentialCheck = (params: {\n address: string;\n chainId: number;\n appId: string;\n}) => Promise<boolean>;\n\nexport interface LocalCredentialVerifierOptions {\n /** Notified when the read itself fails; the check then fails closed. */\n onError?: (error: unknown) => void;\n}\n\n/** A credential check that reads a Switchboard's own renown read model through\n * `execute`, rather than any Renown or Switchboard over HTTP. */\nexport function createLocalCredentialVerifier(\n execute: SwitchboardRequestFn,\n options: LocalCredentialVerifierOptions = {},\n): CredentialCheck {\n // fetchDelegationCredential turns a read failure into \"no credential\" — the\n // right verdict, but silent; surface it before it is swallowed.\n const request: SwitchboardRequestFn = async (query, variables) => {\n try {\n return await execute(query, variables);\n } catch (error) {\n options.onError?.(error);\n throw error;\n }\n };\n\n return async ({ address, chainId, appId }) => {\n const credential = await fetchDelegationCredential({\n address,\n chainId,\n appDid: appId,\n switchboardRequest: request,\n });\n return credential !== undefined;\n };\n}\n"],"mappings":";;;;;AASA,IAAsB,cAAtB,MAGyB;AAMzB,IAAa,gBAAb,cAGU,YAAe;CACvB,uBAAwB,IAAI,KAAkB;CAE9C,IAAI,KAAU;AACZ,SAAO,KAAK,KAAK,IAAI,IAAI;;CAG3B,IAAI,KAAU,OAAsB;AAClC,MAAI,UAAU,KAAA,EACZ,MAAK,KAAK,OAAO,IAAI;MAErB,MAAK,KAAK,IAAI,KAAK,MAAM;;CAI7B,OAAO,KAAgB;AACrB,OAAK,KAAK,OAAO,IAAI;;;;;ACDzB,IAAa,sBAAb,cAAyC,cAAgC;;;;;;;;;;;;;;;;;;;;AAqBzE,SAAS,eAAe,MAAsD;AAC5E,KAAI,CAAC,KAAM,QAAO,KAAA;AAClB,QAAO;EACL,SAAS,KAAK;EACd,WAAW,KAAK;EAChB,SAAS,KAAK;EACf;;AAGH,IAAa,S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ChE,MAAI;AACF,UAAO,MAAM,QAAQ,OAAO,UAAU;WAC/B,OAAO;AACd,WAAQ,UAAU,MAAM;AACxB,SAAM;;;AAIV,QAAO,OAAO,EAAE,SAAS,SAAS,YAAY;AAO5C,SANmB,MAAM,0BAA0B;GACjD;GACA;GACA,QAAQ;GACR,oBAAoB;GACrB,CAAC,KACoB,KAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as WalletAdapterMeta, t as LoginMethod } from "./types-
|
|
1
|
+
import { o as WalletAdapterMeta, t as LoginMethod } from "./types-ChjGDXVS.js";
|
|
2
2
|
|
|
3
3
|
//#region src/wallet/rainbow/meta.d.ts
|
|
4
4
|
interface PHRenownChain {
|
|
@@ -16,4 +16,4 @@ declare const RAINBOW_METHODS: LoginMethod[];
|
|
|
16
16
|
declare const rainbowAdapterMeta: WalletAdapterMeta;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { rainbowAdapterMeta as i, PHRenownRainbowAdapterConfig as n, RAINBOW_METHODS as r, PHRenownChain as t };
|
|
19
|
-
//# sourceMappingURL=meta-
|
|
19
|
+
//# sourceMappingURL=meta-B8HbJHy8.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-
|
|
1
|
+
{"version":3,"file":"meta-B8HbJHy8.d.ts","names":[],"sources":["../src/wallet/rainbow/meta.ts"],"mappings":";;;UAIiB,aAAA;EACf,EAAA;EACA,IAAA;AAAA;AAAA,UAKe,4BAAA;EAGf,sBAAA;EACA,eAAA;EACA,OAAA;EAGA,MAAA,aAAmB,aAAA,KAAkB,aAAA;EAGrC,GAAA;AAAA;AAAA,cAGW,eAAA,EAAiB,WAAA;AAAA,cAIjB,kBAAA,EAAoB,iBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as LoginMethod } from "./types-
|
|
1
|
+
import { t as LoginMethod } from "./types-ome2Ysme.js";
|
|
2
2
|
//#region src/wallet/mock/meta.ts
|
|
3
3
|
const MOCK_SUPPORTED_METHODS = [
|
|
4
4
|
LoginMethod.WALLET,
|
|
@@ -28,4 +28,4 @@ const mockAdapterMeta = {
|
|
|
28
28
|
//#endregion
|
|
29
29
|
export { mockAdapterMeta as n, resolveMockMethods as r, DEFAULT_MOCK_METHODS as t };
|
|
30
30
|
|
|
31
|
-
//# sourceMappingURL=meta-
|
|
31
|
+
//# sourceMappingURL=meta-BOjLjJ1Y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-
|
|
1
|
+
{"version":3,"file":"meta-BOjLjJ1Y.js","names":[],"sources":["../src/wallet/mock/meta.ts"],"sourcesContent":["import { LoginMethod, type WalletAdapterMeta } from \"../types.js\";\n\nexport type MockLoginMethod = \"wallet\" | \"google\" | \"apple\" | \"email\";\n\nconst MOCK_SUPPORTED_METHODS: MockLoginMethod[] = [\n LoginMethod.WALLET,\n LoginMethod.GOOGLE,\n LoginMethod.APPLE,\n LoginMethod.EMAIL,\n];\n\n// Methods offered when config omits `methods`.\nexport const DEFAULT_MOCK_METHODS: LoginMethod[] = [\n LoginMethod.WALLET,\n LoginMethod.GOOGLE,\n LoginMethod.EMAIL,\n];\n\n/** Config for the mock wallet adapter. TEST/DEV ONLY — signs with a local key; never enable in production. */\nexport interface PHRenownMockAdapterConfig {\n /** Signing key; defaults to the well-known Anvil test account #0. */\n privateKey?: `0x${string}`;\n /** Chain id reported in the session (default 1). */\n chainId?: number;\n /** Methods this adapter answers for; defaults to wallet + google + email. */\n methods?: MockLoginMethod[];\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 resolveMockMethods(methods?: string[]): LoginMethod[] {\n if (!methods || methods.length === 0) return [...DEFAULT_MOCK_METHODS];\n const resolved: LoginMethod[] = [];\n for (const method of methods) {\n const value = method as MockLoginMethod;\n if (!MOCK_SUPPORTED_METHODS.includes(value)) {\n throw new Error(`MockAdapter cannot support login method \"${method}\"`);\n }\n resolved.push(value);\n }\n return resolved;\n}\n\n// Dependency-free identity (see privy/meta.ts). The mock signer has no\n// full-page OAuth redirect.\nexport const mockAdapterMeta: Omit<WalletAdapterMeta, \"supportedMethods\"> = {\n id: \"mock\",\n redirectReturnParams: [],\n};\n"],"mappings":";;AAIA,MAAM,yBAA4C;CAChD,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACb;AAGD,MAAa,uBAAsC;CACjD,YAAY;CACZ,YAAY;CACZ,YAAY;CACb;AAcD,SAAgB,mBAAmB,SAAmC;AACpE,KAAI,CAAC,WAAW,QAAQ,WAAW,EAAG,QAAO,CAAC,GAAG,qBAAqB;CACtE,MAAM,WAA0B,EAAE;AAClC,MAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,QAAQ;AACd,MAAI,CAAC,uBAAuB,SAAS,MAAM,CACzC,OAAM,IAAI,MAAM,4CAA4C,OAAO,GAAG;AAExE,WAAS,KAAK,MAAM;;AAEtB,QAAO;;AAKT,MAAa,kBAA+D;CAC1E,IAAI;CACJ,sBAAsB,EAAE;CACzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as WalletAdapterMeta, t as LoginMethod } from "./types-
|
|
1
|
+
import { o as WalletAdapterMeta, t as LoginMethod } from "./types-ChjGDXVS.js";
|
|
2
2
|
|
|
3
3
|
//#region src/wallet/mock/meta.d.ts
|
|
4
4
|
type MockLoginMethod = "wallet" | "google" | "apple" | "email";
|
|
@@ -16,4 +16,4 @@ declare function resolveMockMethods(methods?: string[]): LoginMethod[];
|
|
|
16
16
|
declare const mockAdapterMeta: Omit<WalletAdapterMeta, "supportedMethods">;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { resolveMockMethods as a, mockAdapterMeta as i, MockLoginMethod as n, PHRenownMockAdapterConfig as r, DEFAULT_MOCK_METHODS as t };
|
|
19
|
-
//# sourceMappingURL=meta-
|
|
19
|
+
//# sourceMappingURL=meta-CRXEMUUQ.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-
|
|
1
|
+
{"version":3,"file":"meta-CRXEMUUQ.d.ts","names":[],"sources":["../src/wallet/mock/meta.ts"],"mappings":";;;KAEY,eAAA;AAAA,cAUC,oBAAA,EAAsB,WAAA;AAVnC;AAAA,UAiBiB,yBAAA;;EAEf,UAAA;EAnByB;EAqBzB,OAAA;EAPD;EASC,OAAA,GAAU,eAAA;AAAA;AAAA,iBAKI,kBAAA,CAAmB,OAAA,cAAqB,WAAA;AAAA,cAe3C,eAAA,EAAiB,IAAA,CAAK,iBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as LoginMethod } from "./types-
|
|
1
|
+
import { t as LoginMethod } from "./types-ome2Ysme.js";
|
|
2
2
|
//#region src/wallet/privy/meta.ts
|
|
3
3
|
const PRIVY_SUPPORTED_METHODS = [
|
|
4
4
|
LoginMethod.WALLET,
|
|
@@ -24,4 +24,4 @@ const privyAdapterMeta = {
|
|
|
24
24
|
//#endregion
|
|
25
25
|
export { privyAdapterMeta as n, resolvePrivyMethods as r, DEFAULT_PRIVY_METHODS as t };
|
|
26
26
|
|
|
27
|
-
//# sourceMappingURL=meta-
|
|
27
|
+
//# sourceMappingURL=meta-adhFGw0o.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-
|
|
1
|
+
{"version":3,"file":"meta-adhFGw0o.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"}
|