@renown/sdk 6.2.2-dev.13 → 6.2.2-dev.15

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as VERIFIABLE_CREDENTIAL_EIP712_TYPE, _ as DEFAULT_RENOWN_NETWORK_ID, a as BaseStorage, b as ISSUER_TYPE, c as recoverCredentialSigner, d as SwitchboardClient, f as resolveSwitchboardEndpoint, g as DEFAULT_RENOWN_CHAIN_ID, h as CREDENTIAL_TYPES, i as RenownMemoryStorage, l as verifyAuthCredential, m as CREDENTIAL_SUBJECT_TYPE, n as fetchRenownProfile, o as buildAndSignCredential, p as CREDENTIAL_SCHEMA_EIP712_TYPE, r as Renown, s as fetchDelegationCredential, t as BaseRenownBuilder, u as verifyCredentialSignature, v as DEFAULT_RENOWN_URL, x as RENOWN_SESSION_COOKIE, y as DOMAIN_TYPE } from "./renown-builder-Cm5JNOul.js";
1
+ import { S as VERIFIABLE_CREDENTIAL_EIP712_TYPE, _ as DEFAULT_RENOWN_NETWORK_ID, a as BaseStorage, b as ISSUER_TYPE, c as recoverCredentialSigner, d as SwitchboardClient, f as resolveSwitchboardEndpoint, g as DEFAULT_RENOWN_CHAIN_ID, h as CREDENTIAL_TYPES, i as RenownMemoryStorage, l as verifyAuthCredential, m as CREDENTIAL_SUBJECT_TYPE, n as fetchRenownProfile, o as buildAndSignCredential, p as CREDENTIAL_SCHEMA_EIP712_TYPE, r as Renown, s as fetchDelegationCredential, t as BaseRenownBuilder, u as verifyCredentialSignature, v as DEFAULT_RENOWN_URL, x as RENOWN_SESSION_COOKIE, y as DOMAIN_TYPE } from "./renown-builder-BqWoYtBR.js";
2
2
  import { a as signatureHasResultingHash, c as ConnectCrypto, d as createAuthBearerToken, f as getResolver, i as parseSignatureHashField, l as RenownCrypto, m as verifyAuthBearerToken, n as createSignatureVerifier, o as MemoryKeyStorage, p as parsePkhDid, r as extractResultingHashFromSignature, s as RenownCryptoBuilder, t as RenownCryptoSigner, u as assertIsAuthCredential } from "./signer-CgYhXTV7.js";
3
3
  import { t as BrowserKeyStorage } from "./browser-key-storage-v4O-fjz0.js";
4
4
  //#region src/event/event.browser.ts
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as VERIFIABLE_CREDENTIAL_EIP712_TYPE, _ as DEFAULT_RENOWN_NETWORK_ID, a as BaseStorage, b as ISSUER_TYPE, c as recoverCredentialSigner, d as SwitchboardClient, f as resolveSwitchboardEndpoint, g as DEFAULT_RENOWN_CHAIN_ID, h as CREDENTIAL_TYPES, i as RenownMemoryStorage, l as verifyAuthCredential, m as CREDENTIAL_SUBJECT_TYPE, n as fetchRenownProfile, o as buildAndSignCredential, p as CREDENTIAL_SCHEMA_EIP712_TYPE, r as Renown, s as fetchDelegationCredential, t as BaseRenownBuilder, u as verifyCredentialSignature, v as DEFAULT_RENOWN_URL, x as RENOWN_SESSION_COOKIE, y as DOMAIN_TYPE } from "./renown-builder-Cm5JNOul.js";
1
+ import { S as VERIFIABLE_CREDENTIAL_EIP712_TYPE, _ as DEFAULT_RENOWN_NETWORK_ID, a as BaseStorage, b as ISSUER_TYPE, c as recoverCredentialSigner, d as SwitchboardClient, f as resolveSwitchboardEndpoint, g as DEFAULT_RENOWN_CHAIN_ID, h as CREDENTIAL_TYPES, i as RenownMemoryStorage, l as verifyAuthCredential, m as CREDENTIAL_SUBJECT_TYPE, n as fetchRenownProfile, o as buildAndSignCredential, p as CREDENTIAL_SCHEMA_EIP712_TYPE, r as Renown, s as fetchDelegationCredential, t as BaseRenownBuilder, u as verifyCredentialSignature, v as DEFAULT_RENOWN_URL, x as RENOWN_SESSION_COOKIE, y as DOMAIN_TYPE } from "./renown-builder-BqWoYtBR.js";
2
2
  import { a as signatureHasResultingHash, c as ConnectCrypto, d as createAuthBearerToken, f as getResolver, i as parseSignatureHashField, l as RenownCrypto, m as verifyAuthBearerToken, n as createSignatureVerifier, o as MemoryKeyStorage, p as parsePkhDid, r as extractResultingHashFromSignature, s as RenownCryptoBuilder, t as RenownCryptoSigner, u as assertIsAuthCredential } from "./signer-CgYhXTV7.js";
3
3
  import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
4
4
  import { dirname, join } from "node:path";
@@ -537,7 +537,9 @@ var Renown = class {
537
537
  this.#appName = appName;
538
538
  this.#profileFetcher = profileFetcher;
539
539
  this.#switchboard = switchboard;
540
- this.#signer = new RenownCryptoSigner(crypto, this.#appName, this.user);
540
+ const restoredUser = this.user;
541
+ this.#signer = new RenownCryptoSigner(crypto, this.#appName, restoredUser);
542
+ if (restoredUser) this.#status = "authorized";
541
543
  this.on("user", (user) => {
542
544
  this.#signer.user = user;
543
545
  });
@@ -836,4 +838,4 @@ var BaseRenownBuilder = class BaseRenownBuilder {
836
838
  //#endregion
837
839
  export { VERIFIABLE_CREDENTIAL_EIP712_TYPE as S, DEFAULT_RENOWN_NETWORK_ID as _, BaseStorage as a, ISSUER_TYPE as b, recoverCredentialSigner as c, SwitchboardClient as d, resolveSwitchboardEndpoint as f, DEFAULT_RENOWN_CHAIN_ID as g, CREDENTIAL_TYPES as h, RenownMemoryStorage as i, verifyAuthCredential as l, CREDENTIAL_SUBJECT_TYPE as m, fetchRenownProfile as n, buildAndSignCredential as o, CREDENTIAL_SCHEMA_EIP712_TYPE as p, Renown as r, fetchDelegationCredential as s, BaseRenownBuilder as t, verifyCredentialSignature as u, DEFAULT_RENOWN_URL as v, RENOWN_SESSION_COOKIE as x, DOMAIN_TYPE as y };
838
840
 
839
- //# sourceMappingURL=renown-builder-Cm5JNOul.js.map
841
+ //# sourceMappingURL=renown-builder-BqWoYtBR.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renown-builder-Cm5JNOul.js","names":["#endpoint","#request","#store","#eventEmitter","#baseUrl","#crypto","#appName","#profileFetcher","#switchboard","#signer","#status","#updateStatus","#getCredential","#updateUser","#completeLogin","#listeners","#appName","#storage","#eventEmitter","#crypto","#keyPairStorage","#baseUrl","#switchboardUrl","#profileFetcher"],"sources":["../src/constants.ts","../src/discovery.ts","../src/switchboard.ts","../src/credential.ts","../src/storage/common.ts","../src/common.ts","../src/event/memory.ts","../src/profile.ts","../src/renown-builder.ts"],"sourcesContent":["export const DEFAULT_RENOWN_URL = \"https://www.renown.id\";\nexport const DEFAULT_RENOWN_NETWORK_ID = \"eip155\";\nexport const DEFAULT_RENOWN_CHAIN_ID = \"1\";\n\n/** Default cookie name for a server-readable Renown session (bearer token). */\nexport const RENOWN_SESSION_COOKIE = \"renown_session\";\n\nexport const DOMAIN_TYPE = [\n { name: \"version\", type: \"string\" },\n { name: \"chainId\", type: \"uint256\" },\n] as const;\n\nexport const VERIFIABLE_CREDENTIAL_EIP712_TYPE = [\n { name: \"@context\", type: \"string[]\" },\n { name: \"type\", type: \"string[]\" },\n { name: \"id\", type: \"string\" },\n { name: \"issuer\", type: \"Issuer\" },\n { name: \"credentialSubject\", type: \"CredentialSubject\" },\n { name: \"credentialSchema\", type: \"CredentialSchema\" },\n { name: \"issuanceDate\", type: \"string\" },\n { name: \"expirationDate\", type: \"string\" },\n] as const;\n\nexport const CREDENTIAL_SCHEMA_EIP712_TYPE = [\n { name: \"id\", type: \"string\" },\n { name: \"type\", type: \"string\" },\n] as const;\n\nexport const CREDENTIAL_SUBJECT_TYPE = [\n { name: \"app\", type: \"string\" },\n { name: \"id\", type: \"string\" },\n] as const;\n\nexport const ISSUER_TYPE = [\n { name: \"id\", type: \"string\" },\n { name: \"ethereumAddress\", type: \"string\" },\n] as const;\n\nexport const CREDENTIAL_TYPES = {\n EIP712Domain: DOMAIN_TYPE,\n VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,\n CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,\n CredentialSubject: CREDENTIAL_SUBJECT_TYPE,\n Issuer: ISSUER_TYPE,\n} as const;\n","export interface ResolveSwitchboardEndpointOptions {\n // Explicit Switchboard GraphQL endpoint. When set, used directly.\n switchboardUrl?: string;\n // Renown base URL to ask for a switchboard endpoint when none is explicit.\n baseUrl?: string;\n // Max time (ms) to wait for the discovery probe before falling back to REST.\n timeoutMs?: number;\n}\n\n// Legacy Renown instances accept the connection but never respond to the\n// discovery request; without a bound, `fetch` hangs and blocks startup.\nconst DEFAULT_DISCOVERY_TIMEOUT_MS = 3000;\n\n// Shape returned by the Renown app's `/api/switchboard` discovery endpoint.\ninterface DiscoveryResponse {\n endpoint?: string;\n}\n\n// Resolve the Switchboard GraphQL endpoint: explicit `switchboardUrl` wins,\n// else discover via `{baseUrl}/api/switchboard`; undefined means use REST.\nexport async function resolveSwitchboardEndpoint(\n options: ResolveSwitchboardEndpointOptions,\n): Promise<string | undefined> {\n const { switchboardUrl, baseUrl, timeoutMs } = options;\n\n if (switchboardUrl) {\n return switchboardUrl;\n }\n\n if (!baseUrl) {\n return undefined;\n }\n\n const controller = new AbortController();\n const timeout = setTimeout(\n () => controller.abort(),\n timeoutMs ?? DEFAULT_DISCOVERY_TIMEOUT_MS,\n );\n\n try {\n const url = new URL(\"/api/switchboard\", baseUrl);\n const response = await fetch(url, {\n method: \"GET\",\n signal: controller.signal,\n });\n if (!response.ok) {\n return undefined;\n }\n const body = (await response.json()) as DiscoveryResponse;\n return body.endpoint || undefined;\n } catch {\n // Old Renown instances never answer (or lack the endpoint); the abort\n // timeout rejects here so we fall back to the REST flow instead of hanging.\n return undefined;\n } finally {\n clearTimeout(timeout);\n }\n}\n","import {\n createAction,\n type Action,\n} from \"@powerhousedao/shared/document-model\";\nimport { CREDENTIAL_TYPES } from \"./constants.js\";\nimport type {\n PowerhouseVerifiableCredential,\n ProfileFetcher,\n RenownProfile,\n} from \"./types.js\";\n\n// Per-user drive convention shared with the Renown app: `renown-<address>`.\n// The read-model ignores driveId, but we pass it for parity.\nfunction userDriveId(address: string): string {\n return `renown-${address.toLowerCase()}`;\n}\n\n// Flat row returned by the `renownCredentials` read-model query.\ninterface ReadRenownCredential {\n documentId: string;\n credentialId: string;\n context: string[];\n type: string[];\n issuerId: string;\n issuerEthereumAddress: string;\n issuanceDate: string;\n expirationDate: string | null;\n credentialSubjectId: string | null;\n credentialSubjectApp: string;\n credentialStatusId: string | null;\n credentialStatusType: string | null;\n credentialSchemaId: string;\n credentialSchemaType: string;\n proofVerificationMethod: string;\n proofEthereumAddress: string;\n proofCreated: string;\n proofPurpose: string;\n proofType: string;\n proofValue: string;\n proofEip712Domain: string;\n proofEip712PrimaryType: string;\n revoked: boolean;\n}\n\n// Flat row returned by the `renownUsers` read-model query.\ninterface ReadRenownUser {\n documentId: string;\n username: string | null;\n ethAddress: string | null;\n userImage: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nconst CREDENTIALS_QUERY = /* GraphQL */ `\n query RenownCredentials($input: RenownCredentialsInput!) {\n renownCredentials(input: $input) {\n documentId\n credentialId\n context\n type\n issuerId\n issuerEthereumAddress\n issuanceDate\n expirationDate\n credentialSubjectId\n credentialSubjectApp\n credentialStatusId\n credentialStatusType\n credentialSchemaId\n credentialSchemaType\n proofVerificationMethod\n proofEthereumAddress\n proofCreated\n proofPurpose\n proofType\n proofValue\n proofEip712Domain\n proofEip712PrimaryType\n revoked\n }\n }\n`;\n\nconst USERS_QUERY = /* GraphQL */ `\n query RenownUsers($input: RenownUsersInput!) {\n renownUsers(input: $input) {\n documentId\n username\n ethAddress\n userImage\n createdAt\n updatedAt\n }\n }\n`;\n\nconst CREATE_EMPTY_DOCUMENT_MUTATION = /* GraphQL */ `\n mutation CreateEmptyDocument(\n $documentType: String!\n $parentIdentifier: String\n ) {\n createEmptyDocument(\n documentType: $documentType\n parentIdentifier: $parentIdentifier\n ) {\n id\n }\n }\n`;\n\nconst MUTATE_DOCUMENT_MUTATION = /* GraphQL */ `\n mutation MutateDocument(\n $documentIdentifier: String!\n $actions: [JSONObject!]!\n ) {\n mutateDocument(documentIdentifier: $documentIdentifier, actions: $actions) {\n id\n }\n }\n`;\n\nconst RENOWN_CREDENTIAL_DOC_TYPE = \"powerhouse/renown-credential\";\nconst RENOWN_USER_DOC_TYPE = \"powerhouse/renown-user\";\n\n// Rebuild the nested EIP-712 verifiable credential from a flat read-model row.\nfunction reshapeCredential(\n row: ReadRenownCredential,\n): PowerhouseVerifiableCredential {\n // `proofEip712Domain` is stored as a JSON string ({ version, chainId }).\n const domain = JSON.parse(row.proofEip712Domain) as {\n version: string;\n chainId: number;\n };\n\n return {\n \"@context\": row.context,\n type: row.type,\n id: row.credentialId,\n issuer: {\n id: row.issuerId,\n ethereumAddress: row.issuerEthereumAddress as `0x${string}`,\n },\n credentialSubject: {\n id: row.credentialSubjectId ?? \"\",\n app: row.credentialSubjectApp,\n },\n credentialSchema: {\n id: row.credentialSchemaId,\n type: row.credentialSchemaType,\n },\n ...(row.credentialStatusId\n ? {\n credentialStatus: {\n id: row.credentialStatusId,\n type: row.credentialStatusType ?? \"\",\n },\n }\n : {}),\n issuanceDate: row.issuanceDate,\n expirationDate: row.expirationDate ?? \"\",\n proof: {\n type: row.proofType,\n created: row.proofCreated,\n verificationMethod: row.proofVerificationMethod,\n proofPurpose: row.proofPurpose,\n proofValue: row.proofValue,\n ethereumAddress: row.proofEthereumAddress as `0x${string}`,\n eip712: {\n domain,\n types: CREDENTIAL_TYPES,\n primaryType: \"VerifiableCredential\",\n },\n },\n };\n}\n\n// The chain id in a `did:pkh:<net>:<chainId>:<address>` issuer id.\nfunction issuerChainId(issuerId: string): string | undefined {\n return issuerId.split(\":\")[3];\n}\n\n// Reads a Switchboard reactor's `renown-read-model` subgraph directly over\n// GraphQL, replacing the Renown Next.js REST proxy. Read-only; plain `fetch`.\nexport class SwitchboardClient {\n #endpoint: string;\n\n constructor(endpoint: string) {\n this.#endpoint = endpoint;\n }\n\n get endpoint() {\n return this.#endpoint;\n }\n\n async #request<T>(\n query: string,\n variables: Record<string, unknown>,\n ): Promise<T> {\n const response = await fetch(this.#endpoint, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ query, variables }),\n });\n if (!response.ok) {\n throw new Error(`Switchboard request failed: ${response.status}`);\n }\n const body = (await response.json()) as {\n data?: T;\n errors?: { message: string }[];\n };\n if (body.errors?.length) {\n throw new Error(body.errors.map((e) => e.message).join(\"; \"));\n }\n if (!body.data) {\n throw new Error(\"Switchboard returned no data\");\n }\n return body.data;\n }\n\n // Fetch the active delegation credential for (address, chainId) that delegates\n // to `appDid`: filter by chainId, drop expired, return most recent.\n async getCredential(params: {\n address: string;\n chainId: number;\n appDid: string;\n }): Promise<PowerhouseVerifiableCredential | undefined> {\n const { address, chainId, appDid } = params;\n const { renownCredentials } = await this.#request<{\n renownCredentials: ReadRenownCredential[];\n }>(CREDENTIALS_QUERY, {\n input: {\n driveId: userDriveId(address),\n ethAddress: address.toLowerCase(),\n did: appDid,\n includeRevoked: false,\n },\n });\n\n const now = Date.now();\n const candidates = renownCredentials\n .filter((row) => issuerChainId(row.issuerId) === String(chainId))\n .filter((row) => {\n if (!row.expirationDate) return true;\n const expiresAt = Date.parse(row.expirationDate);\n return !Number.isNaN(expiresAt) && expiresAt > now;\n })\n .sort((a, b) => Date.parse(b.issuanceDate) - Date.parse(a.issuanceDate));\n\n const mostRecent = candidates.at(0);\n return mostRecent ? reshapeCredential(mostRecent) : undefined;\n }\n\n // Look up a Renown profile by ethereum address via the `renownUsers` query.\n async getProfileByAddress(\n address: string,\n ): Promise<RenownProfile | undefined> {\n const { renownUsers } = await this.#request<{\n renownUsers: ReadRenownUser[];\n }>(USERS_QUERY, {\n input: {\n driveId: userDriveId(address),\n ethAddresses: [address.toLowerCase()],\n },\n });\n\n const user = renownUsers.at(0);\n if (!user) return undefined;\n return {\n documentId: user.documentId,\n username: user.username,\n ethAddress: user.ethAddress,\n userImage: user.userImage,\n createdAt: user.createdAt,\n updatedAt: user.updatedAt,\n };\n }\n\n // Create an empty document of the given type; returns its document id.\n async createEmptyDocument(\n documentType: string,\n parentIdentifier?: string,\n ): Promise<string> {\n const { createEmptyDocument } = await this.#request<{\n createEmptyDocument: { id: string };\n }>(CREATE_EMPTY_DOCUMENT_MUTATION, { documentType, parentIdentifier });\n return createEmptyDocument.id;\n }\n\n // Apply reactor action envelopes to a document; returns its document id.\n async mutateDocument(\n documentIdentifier: string,\n actions: Action[],\n ): Promise<string> {\n const { mutateDocument } = await this.#request<{\n mutateDocument: { id: string };\n }>(MUTATE_DOCUMENT_MUTATION, { documentIdentifier, actions });\n return mutateDocument.id;\n }\n\n // Issue a signed credential: create a renown-credential doc and INIT it.\n async issueCredential(\n credential: PowerhouseVerifiableCredential,\n ): Promise<string> {\n const documentId = await this.createEmptyDocument(\n RENOWN_CREDENTIAL_DOC_TYPE,\n );\n const input: Record<string, unknown> = {\n id: credential.id,\n context: credential[\"@context\"],\n type: credential.type,\n issuer: {\n id: credential.issuer.id,\n ethereumAddress: credential.issuer.ethereumAddress,\n },\n credentialSubject: {\n id: credential.credentialSubject.id,\n app: credential.credentialSubject.app,\n },\n credentialSchema: {\n id: credential.credentialSchema.id,\n type: credential.credentialSchema.type,\n },\n issuanceDate: credential.issuanceDate,\n expirationDate: credential.expirationDate || undefined,\n proof: {\n type: credential.proof.type,\n created: credential.proof.created,\n verificationMethod: credential.proof.verificationMethod,\n proofPurpose: credential.proof.proofPurpose,\n proofValue: credential.proof.proofValue,\n ethereumAddress: credential.proof.ethereumAddress,\n eip712: {\n domain: {\n version: credential.proof.eip712.domain.version,\n chainId: credential.proof.eip712.domain.chainId,\n },\n primaryType: credential.proof.eip712.primaryType,\n },\n },\n };\n await this.mutateDocument(documentId, [createAction(\"INIT\", input)]);\n return documentId;\n }\n\n // Find the RenownUser for an address or create one; returns its document id.\n async findOrCreateUser(\n address: string,\n profile: { username?: string; userImage?: string } = {},\n ): Promise<string> {\n const updates: Action[] = [];\n if (profile.username !== undefined) {\n updates.push(\n createAction(\"SET_USERNAME\", { username: profile.username }),\n );\n }\n if (profile.userImage !== undefined) {\n updates.push(\n createAction(\"SET_USER_IMAGE\", { userImage: profile.userImage }),\n );\n }\n\n const existing = await this.getProfileByAddress(address);\n if (existing) {\n if (updates.length)\n await this.mutateDocument(existing.documentId, updates);\n return existing.documentId;\n }\n\n const documentId = await this.createEmptyDocument(RENOWN_USER_DOC_TYPE);\n await this.mutateDocument(documentId, [\n createAction(\"SET_ETH_ADDRESS\", { ethAddress: address }),\n ...updates,\n ]);\n return documentId;\n }\n\n // Revoke a credential by its document id.\n async revokeCredential(documentId: string, reason?: string): Promise<void> {\n await this.mutateDocument(documentId, [\n createAction(\"REVOKE\", {\n revokedAt: new Date().toISOString(),\n reason: reason ?? null,\n }),\n ]);\n }\n\n // A ProfileFetcher backed by this client; used as the default when the\n // direct-switchboard flow is active. The `baseUrl` argument is ignored.\n profileFetcher: ProfileFetcher = (user) =>\n this.getProfileByAddress(user.address).catch(() => undefined);\n}\n","import { recoverTypedDataAddress } from \"viem\";\nimport {\n CREDENTIAL_TYPES,\n DEFAULT_RENOWN_NETWORK_ID,\n DEFAULT_RENOWN_URL,\n} from \"./constants.js\";\nimport { resolveSwitchboardEndpoint } from \"./discovery.js\";\nimport { SwitchboardClient } from \"./switchboard.js\";\nimport type { IProof, PowerhouseVerifiableCredential } from \"./types.js\";\nimport { verifyAuthBearerToken } from \"./utils.js\";\n\n/* Local structural aliases (EIP-712 standard shapes) so renown's public .d.ts\n * never names viem — a viem type in the surface drags viem's whole closure in. */\ntype Hex = `0x${string}`;\ntype TypedDataDomain = {\n name?: string;\n version?: string;\n chainId?: number;\n verifyingContract?: Hex;\n salt?: Hex;\n};\ntype TypedDataParameter = { name: string; type: string };\n\n/** EIP-712 domain as signed by the credential issuer. */\nexport type CredentialDomain = {\n version: string;\n chainId: number;\n};\n\n/** The credential body that is EIP-712 signed (everything except `proof`). */\nexport type CredentialMessage = {\n \"@context\": string[];\n type: string[];\n id: string;\n issuer: { id: string; ethereumAddress: Hex };\n credentialSubject: { id: string; app: string };\n credentialSchema: { id: string; type: string };\n issuanceDate: string;\n expirationDate: string;\n};\n\n/** Typed-data signer; matches the loose shape used by wallet adapters. */\nexport type SignCredentialTypedData = (args: {\n domain: TypedDataDomain;\n types: Record<string, readonly TypedDataParameter[]>;\n primaryType: string;\n message: Record<string, unknown>;\n}) => Promise<Hex>;\n\nexport interface BuildCredentialParams {\n signTypedData: SignCredentialTypedData;\n address: Hex;\n chainId: number;\n app: string;\n /** Credential subject id: the app/client DID the credential delegates to. */\n appId: string;\n expiresInDays?: number;\n}\n\n/** Assemble a Renown delegation VC and sign it with the provided signer. */\nexport async function buildAndSignCredential(\n params: BuildCredentialParams,\n): Promise<PowerhouseVerifiableCredential> {\n const {\n signTypedData,\n address,\n chainId,\n app,\n appId,\n expiresInDays = 7,\n } = params;\n\n const issuerId = `did:pkh:${DEFAULT_RENOWN_NETWORK_ID}:${chainId}:${address.toLowerCase()}`;\n const credentialId = `urn:uuid:${globalThis.crypto.randomUUID()}`;\n const now = new Date();\n const expirationDate = new Date(\n now.getTime() + expiresInDays * 24 * 60 * 60 * 1000,\n );\n\n const message: CredentialMessage = {\n \"@context\": [\"https://www.w3.org/2018/credentials/v1\"],\n type: [\"VerifiableCredential\", \"RenownCredential\"],\n id: credentialId,\n issuer: { id: issuerId, ethereumAddress: address },\n credentialSubject: { id: appId, app },\n credentialSchema: {\n id: \"https://renown.id/schemas/renown-credential/v1\",\n type: \"JsonSchemaValidator2018\",\n },\n issuanceDate: now.toISOString(),\n expirationDate: expirationDate.toISOString(),\n };\n\n const domain: CredentialDomain = { version: \"1\", chainId };\n\n // viem and most wallet adapters reserve EIP712Domain and derive it from\n // `domain` — passing it explicitly makes them throw.\n const { EIP712Domain, ...signTypes } = CREDENTIAL_TYPES;\n void EIP712Domain;\n const signature = await signTypedData({\n domain,\n types: signTypes,\n primaryType: \"VerifiableCredential\",\n message,\n });\n\n return {\n ...message,\n proof: {\n type: \"EthereumEip712Signature2021\",\n created: message.issuanceDate,\n verificationMethod: issuerId,\n proofPurpose: \"assertionMethod\",\n proofValue: signature,\n ethereumAddress: address,\n eip712: {\n domain,\n types: CREDENTIAL_TYPES,\n primaryType: \"VerifiableCredential\",\n },\n },\n };\n}\n\n/** Recover the address that signed a credential's EIP-712 proof. */\nexport async function recoverCredentialSigner(\n credential: PowerhouseVerifiableCredential,\n): Promise<Hex> {\n const { proof, ...message } = credential;\n // Drop EIP712Domain so viem derives it from `domain`; viem ignores\n // message keys not present in the types, so the proof is excluded too.\n const { EIP712Domain, ...types } = CREDENTIAL_TYPES;\n void EIP712Domain;\n return recoverTypedDataAddress({\n domain: proof.eip712.domain,\n types,\n primaryType: \"VerifiableCredential\",\n message,\n signature: proof.proofValue as Hex,\n } as Parameters<typeof recoverTypedDataAddress>[0]);\n}\n\n/** True when the proof was signed by the credential's declared issuer address. */\nexport async function verifyCredentialSignature(\n credential: PowerhouseVerifiableCredential,\n): Promise<boolean> {\n try {\n const recovered = await recoverCredentialSigner(credential);\n return (\n recovered.toLowerCase() ===\n credential.issuer.ethereumAddress.toLowerCase()\n );\n } catch {\n // Malformed proof (bad hex, missing fields) is an invalid signature.\n return false;\n }\n}\n\n// The deployed Renown API may omit proof.eip712.domain; it's canonical\n// (version \"1\", the credential's chainId), so reconstruct it before verifying.\nfunction withEip712Domain(\n credential: PowerhouseVerifiableCredential,\n chainId: number,\n): PowerhouseVerifiableCredential {\n const eip712 = credential.proof.eip712 as\n | Partial<IProof[\"eip712\"]>\n | undefined;\n if (eip712?.domain) return credential;\n return {\n ...credential,\n proof: {\n ...credential.proof,\n eip712: {\n domain: { version: \"1\", chainId },\n types: CREDENTIAL_TYPES,\n primaryType: \"VerifiableCredential\",\n },\n },\n };\n}\n\nexport interface FetchDelegationCredentialOptions {\n /** Ethereum address that must have issued the credential. */\n address: string;\n /** Chain id the credential must be scoped to. */\n chainId: number;\n /** App/client DID the credential must delegate to (credentialSubject.id). */\n appDid: string;\n /** Renown service base URL. Defaults to DEFAULT_RENOWN_URL. */\n baseUrl?: string;\n /** Switchboard GraphQL endpoint; when reachable, read the reactor directly. */\n switchboardUrl?: string;\n /** Probe {baseUrl}/api/switchboard for an endpoint (default true). */\n discover?: boolean;\n /** Re-verify the EIP-712 proof signature (default true). */\n verifySignature?: boolean;\n}\n\n// Fetch + binding/expiry-validate the credential over the Renown REST API.\nasync function fetchDelegationCredentialRest(params: {\n address: string;\n chainId: number;\n appDid: string;\n baseUrl: string;\n}): Promise<PowerhouseVerifiableCredential | undefined> {\n const { address, chainId, appDid, baseUrl } = params;\n const url = new URL(\n `/api/auth/credential?address=${encodeURIComponent(address)}&chainId=${encodeURIComponent(chainId)}&connectId=${encodeURIComponent(appDid)}&appId=${encodeURIComponent(appDid)}`,\n baseUrl,\n );\n const response = await fetch(url, { method: \"GET\" });\n if (!response.ok) return undefined;\n const { credential } = (await response.json()) as {\n credential?: PowerhouseVerifiableCredential;\n };\n if (!credential) return undefined;\n\n // Binding: delegates to this app DID, issued by this address on this chain\n // (issuer.id = did:pkh:<networkId>:<chainId>:<address>).\n const [, , , issuerChainId, issuerAddress] = credential.issuer.id.split(\":\");\n if (\n credential.credentialSubject.id !== appDid ||\n issuerChainId !== String(chainId) ||\n issuerAddress.toLowerCase() !== address.toLowerCase() ||\n credential.issuer.ethereumAddress.toLowerCase() !== address.toLowerCase()\n ) {\n return undefined;\n }\n\n // Reject an expired credential (revocation drops it from the endpoint\n // instead); a malformed date (NaN) counts as invalid, not non-expiring.\n if (credential.expirationDate) {\n const expiresAt = Date.parse(credential.expirationDate);\n if (Number.isNaN(expiresAt) || expiresAt <= Date.now()) {\n return undefined;\n }\n }\n\n return credential;\n}\n\n// Optionally re-verify the EIP-712 proof; returns the credential or undefined.\nasync function finalizeCredential(\n credential: PowerhouseVerifiableCredential,\n chainId: number,\n verifySignature: boolean,\n): Promise<PowerhouseVerifiableCredential | undefined> {\n if (!verifySignature) return credential;\n const withDomain = withEip712Domain(credential, chainId);\n if (\n withDomain.proof.eip712.domain.chainId !== chainId ||\n !(await verifyCredentialSignature(withDomain))\n ) {\n return undefined;\n }\n return withDomain;\n}\n\n// Fetch the Renown delegation credential for (address, chainId) and validate it\n// delegates to `appDid`; returns it, or undefined if absent/invalid. No throw.\nexport async function fetchDelegationCredential(\n options: FetchDelegationCredentialOptions,\n): Promise<PowerhouseVerifiableCredential | undefined> {\n const {\n address,\n chainId,\n appDid,\n switchboardUrl,\n discover = true,\n verifySignature = true,\n } = options;\n const explicitBaseUrl = options.baseUrl;\n const baseUrl = explicitBaseUrl ?? DEFAULT_RENOWN_URL;\n try {\n // An explicit switchboardUrl is used directly; otherwise discover from the\n // base URL unless disabled (callers that already resolved the endpoint).\n const endpoint = switchboardUrl\n ? switchboardUrl\n : discover && explicitBaseUrl\n ? await resolveSwitchboardEndpoint({ baseUrl })\n : undefined;\n\n const credential = endpoint\n ? await new SwitchboardClient(endpoint).getCredential({\n address,\n chainId,\n appDid,\n })\n : await fetchDelegationCredentialRest({\n address,\n chainId,\n appDid,\n baseUrl,\n });\n\n if (!credential) return undefined;\n return await finalizeCredential(credential, chainId, verifySignature);\n } catch {\n return undefined;\n }\n}\n\nexport interface VerifiedAuthCredential {\n address: string;\n chainId: number;\n networkId: string;\n /** Owner identity: the pkh DID (did:pkh:<net>:<chainId>:<address>). */\n did: string;\n /** App/client DID the bearer token was issued by. */\n appDid: string;\n credential: PowerhouseVerifiableCredential;\n}\n\nexport interface VerifyAuthCredentialOptions {\n /** Expected `aud` claim on the bearer token. */\n audience?: string;\n /** Renown service base URL. */\n renownUrl?: string;\n /** Switchboard GraphQL endpoint; when reachable, read the reactor directly. */\n switchboardUrl?: string;\n /** Re-verify the credential's EIP-712 proof (default true). */\n verifySignature?: boolean;\n}\n\n// Verify a renown bearer token end to end: check the JWT, then fetch+verify the\n// matching credential. Resolves the owner identity, or undefined. No throw.\nexport async function verifyAuthCredential(\n jwt: string,\n options: VerifyAuthCredentialOptions = {},\n): Promise<VerifiedAuthCredential | undefined> {\n const verified = await verifyAuthBearerToken(jwt, {\n audience: options.audience,\n });\n if (!verified) return undefined;\n\n const { address, chainId, networkId } =\n verified.verifiableCredential.credentialSubject;\n const appDid = verified.issuer;\n const credential = await fetchDelegationCredential({\n address,\n chainId,\n appDid,\n baseUrl: options.renownUrl,\n switchboardUrl: options.switchboardUrl,\n verifySignature: options.verifySignature,\n });\n if (!credential) return undefined;\n\n return {\n address,\n chainId,\n networkId,\n did: credential.issuer.id,\n appDid,\n credential,\n };\n}\n","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_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 type { SwitchboardClient } 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} from \"./types.js\";\nimport { parsePkhDid, verifyAuthBearerToken } from \"./utils.js\";\nexport * from \"./constants.js\";\n\nexport class RenownMemoryStorage extends MemoryStorage<RenownStorageMap> {}\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 #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 ) {\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.#signer = new RenownCryptoSigner(crypto, this.#appName, this.user);\n\n this.on(\"user\", (user) => {\n this.#signer.user = user;\n });\n }\n\n get baseUrl() {\n return this.#baseUrl;\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) {\n throw new Error(\n \"signIn requires a switchboard endpoint. Set switchboardUrl or a discoverable baseUrl.\",\n );\n }\n const {\n address,\n chainId,\n signTypedData,\n username,\n userImage,\n expiresInDays,\n } = params;\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 return true;\n } catch {\n return true;\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_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}\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\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 /**\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 crypto =\n this.#crypto ??\n (await new RenownCryptoBuilder()\n .withKeyPairStorage(this.#keyPairStorage!)\n .build());\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 );\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\n return builder;\n }\n}\n"],"mappings":";;;;AAAA,MAAa,qBAAqB;AAClC,MAAa,4BAA4B;AACzC,MAAa,0BAA0B;;AAGvC,MAAa,wBAAwB;AAErC,MAAa,cAAc,CACzB;CAAE,MAAM;CAAW,MAAM;CAAU,EACnC;CAAE,MAAM;CAAW,MAAM;CAAW,CACrC;AAED,MAAa,oCAAoC;CAC/C;EAAE,MAAM;EAAY,MAAM;EAAY;CACtC;EAAE,MAAM;EAAQ,MAAM;EAAY;CAClC;EAAE,MAAM;EAAM,MAAM;EAAU;CAC9B;EAAE,MAAM;EAAU,MAAM;EAAU;CAClC;EAAE,MAAM;EAAqB,MAAM;EAAqB;CACxD;EAAE,MAAM;EAAoB,MAAM;EAAoB;CACtD;EAAE,MAAM;EAAgB,MAAM;EAAU;CACxC;EAAE,MAAM;EAAkB,MAAM;EAAU;CAC3C;AAED,MAAa,gCAAgC,CAC3C;CAAE,MAAM;CAAM,MAAM;CAAU,EAC9B;CAAE,MAAM;CAAQ,MAAM;CAAU,CACjC;AAED,MAAa,0BAA0B,CACrC;CAAE,MAAM;CAAO,MAAM;CAAU,EAC/B;CAAE,MAAM;CAAM,MAAM;CAAU,CAC/B;AAED,MAAa,cAAc,CACzB;CAAE,MAAM;CAAM,MAAM;CAAU,EAC9B;CAAE,MAAM;CAAmB,MAAM;CAAU,CAC5C;AAED,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Q,mBAAmB,QAAQ,eAAe;AAEpD,MAAI,QAAQ,eACV,SAAQ,mBAAmB,QAAQ,eAAe;AAGpD,SAAO"}
1
+ {"version":3,"file":"renown-builder-BqWoYtBR.js","names":["#endpoint","#request","#store","#eventEmitter","#baseUrl","#crypto","#appName","#profileFetcher","#switchboard","#signer","#status","#updateStatus","#getCredential","#updateUser","#completeLogin","#listeners","#appName","#storage","#eventEmitter","#crypto","#keyPairStorage","#baseUrl","#switchboardUrl","#profileFetcher"],"sources":["../src/constants.ts","../src/discovery.ts","../src/switchboard.ts","../src/credential.ts","../src/storage/common.ts","../src/common.ts","../src/event/memory.ts","../src/profile.ts","../src/renown-builder.ts"],"sourcesContent":["export const DEFAULT_RENOWN_URL = \"https://www.renown.id\";\nexport const DEFAULT_RENOWN_NETWORK_ID = \"eip155\";\nexport const DEFAULT_RENOWN_CHAIN_ID = \"1\";\n\n/** Default cookie name for a server-readable Renown session (bearer token). */\nexport const RENOWN_SESSION_COOKIE = \"renown_session\";\n\nexport const DOMAIN_TYPE = [\n { name: \"version\", type: \"string\" },\n { name: \"chainId\", type: \"uint256\" },\n] as const;\n\nexport const VERIFIABLE_CREDENTIAL_EIP712_TYPE = [\n { name: \"@context\", type: \"string[]\" },\n { name: \"type\", type: \"string[]\" },\n { name: \"id\", type: \"string\" },\n { name: \"issuer\", type: \"Issuer\" },\n { name: \"credentialSubject\", type: \"CredentialSubject\" },\n { name: \"credentialSchema\", type: \"CredentialSchema\" },\n { name: \"issuanceDate\", type: \"string\" },\n { name: \"expirationDate\", type: \"string\" },\n] as const;\n\nexport const CREDENTIAL_SCHEMA_EIP712_TYPE = [\n { name: \"id\", type: \"string\" },\n { name: \"type\", type: \"string\" },\n] as const;\n\nexport const CREDENTIAL_SUBJECT_TYPE = [\n { name: \"app\", type: \"string\" },\n { name: \"id\", type: \"string\" },\n] as const;\n\nexport const ISSUER_TYPE = [\n { name: \"id\", type: \"string\" },\n { name: \"ethereumAddress\", type: \"string\" },\n] as const;\n\nexport const CREDENTIAL_TYPES = {\n EIP712Domain: DOMAIN_TYPE,\n VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,\n CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,\n CredentialSubject: CREDENTIAL_SUBJECT_TYPE,\n Issuer: ISSUER_TYPE,\n} as const;\n","export interface ResolveSwitchboardEndpointOptions {\n // Explicit Switchboard GraphQL endpoint. When set, used directly.\n switchboardUrl?: string;\n // Renown base URL to ask for a switchboard endpoint when none is explicit.\n baseUrl?: string;\n // Max time (ms) to wait for the discovery probe before falling back to REST.\n timeoutMs?: number;\n}\n\n// Legacy Renown instances accept the connection but never respond to the\n// discovery request; without a bound, `fetch` hangs and blocks startup.\nconst DEFAULT_DISCOVERY_TIMEOUT_MS = 3000;\n\n// Shape returned by the Renown app's `/api/switchboard` discovery endpoint.\ninterface DiscoveryResponse {\n endpoint?: string;\n}\n\n// Resolve the Switchboard GraphQL endpoint: explicit `switchboardUrl` wins,\n// else discover via `{baseUrl}/api/switchboard`; undefined means use REST.\nexport async function resolveSwitchboardEndpoint(\n options: ResolveSwitchboardEndpointOptions,\n): Promise<string | undefined> {\n const { switchboardUrl, baseUrl, timeoutMs } = options;\n\n if (switchboardUrl) {\n return switchboardUrl;\n }\n\n if (!baseUrl) {\n return undefined;\n }\n\n const controller = new AbortController();\n const timeout = setTimeout(\n () => controller.abort(),\n timeoutMs ?? DEFAULT_DISCOVERY_TIMEOUT_MS,\n );\n\n try {\n const url = new URL(\"/api/switchboard\", baseUrl);\n const response = await fetch(url, {\n method: \"GET\",\n signal: controller.signal,\n });\n if (!response.ok) {\n return undefined;\n }\n const body = (await response.json()) as DiscoveryResponse;\n return body.endpoint || undefined;\n } catch {\n // Old Renown instances never answer (or lack the endpoint); the abort\n // timeout rejects here so we fall back to the REST flow instead of hanging.\n return undefined;\n } finally {\n clearTimeout(timeout);\n }\n}\n","import {\n createAction,\n type Action,\n} from \"@powerhousedao/shared/document-model\";\nimport { CREDENTIAL_TYPES } from \"./constants.js\";\nimport type {\n PowerhouseVerifiableCredential,\n ProfileFetcher,\n RenownProfile,\n} from \"./types.js\";\n\n// Per-user drive convention shared with the Renown app: `renown-<address>`.\n// The read-model ignores driveId, but we pass it for parity.\nfunction userDriveId(address: string): string {\n return `renown-${address.toLowerCase()}`;\n}\n\n// Flat row returned by the `renownCredentials` read-model query.\ninterface ReadRenownCredential {\n documentId: string;\n credentialId: string;\n context: string[];\n type: string[];\n issuerId: string;\n issuerEthereumAddress: string;\n issuanceDate: string;\n expirationDate: string | null;\n credentialSubjectId: string | null;\n credentialSubjectApp: string;\n credentialStatusId: string | null;\n credentialStatusType: string | null;\n credentialSchemaId: string;\n credentialSchemaType: string;\n proofVerificationMethod: string;\n proofEthereumAddress: string;\n proofCreated: string;\n proofPurpose: string;\n proofType: string;\n proofValue: string;\n proofEip712Domain: string;\n proofEip712PrimaryType: string;\n revoked: boolean;\n}\n\n// Flat row returned by the `renownUsers` read-model query.\ninterface ReadRenownUser {\n documentId: string;\n username: string | null;\n ethAddress: string | null;\n userImage: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nconst CREDENTIALS_QUERY = /* GraphQL */ `\n query RenownCredentials($input: RenownCredentialsInput!) {\n renownCredentials(input: $input) {\n documentId\n credentialId\n context\n type\n issuerId\n issuerEthereumAddress\n issuanceDate\n expirationDate\n credentialSubjectId\n credentialSubjectApp\n credentialStatusId\n credentialStatusType\n credentialSchemaId\n credentialSchemaType\n proofVerificationMethod\n proofEthereumAddress\n proofCreated\n proofPurpose\n proofType\n proofValue\n proofEip712Domain\n proofEip712PrimaryType\n revoked\n }\n }\n`;\n\nconst USERS_QUERY = /* GraphQL */ `\n query RenownUsers($input: RenownUsersInput!) {\n renownUsers(input: $input) {\n documentId\n username\n ethAddress\n userImage\n createdAt\n updatedAt\n }\n }\n`;\n\nconst CREATE_EMPTY_DOCUMENT_MUTATION = /* GraphQL */ `\n mutation CreateEmptyDocument(\n $documentType: String!\n $parentIdentifier: String\n ) {\n createEmptyDocument(\n documentType: $documentType\n parentIdentifier: $parentIdentifier\n ) {\n id\n }\n }\n`;\n\nconst MUTATE_DOCUMENT_MUTATION = /* GraphQL */ `\n mutation MutateDocument(\n $documentIdentifier: String!\n $actions: [JSONObject!]!\n ) {\n mutateDocument(documentIdentifier: $documentIdentifier, actions: $actions) {\n id\n }\n }\n`;\n\nconst RENOWN_CREDENTIAL_DOC_TYPE = \"powerhouse/renown-credential\";\nconst RENOWN_USER_DOC_TYPE = \"powerhouse/renown-user\";\n\n// Rebuild the nested EIP-712 verifiable credential from a flat read-model row.\nfunction reshapeCredential(\n row: ReadRenownCredential,\n): PowerhouseVerifiableCredential {\n // `proofEip712Domain` is stored as a JSON string ({ version, chainId }).\n const domain = JSON.parse(row.proofEip712Domain) as {\n version: string;\n chainId: number;\n };\n\n return {\n \"@context\": row.context,\n type: row.type,\n id: row.credentialId,\n issuer: {\n id: row.issuerId,\n ethereumAddress: row.issuerEthereumAddress as `0x${string}`,\n },\n credentialSubject: {\n id: row.credentialSubjectId ?? \"\",\n app: row.credentialSubjectApp,\n },\n credentialSchema: {\n id: row.credentialSchemaId,\n type: row.credentialSchemaType,\n },\n ...(row.credentialStatusId\n ? {\n credentialStatus: {\n id: row.credentialStatusId,\n type: row.credentialStatusType ?? \"\",\n },\n }\n : {}),\n issuanceDate: row.issuanceDate,\n expirationDate: row.expirationDate ?? \"\",\n proof: {\n type: row.proofType,\n created: row.proofCreated,\n verificationMethod: row.proofVerificationMethod,\n proofPurpose: row.proofPurpose,\n proofValue: row.proofValue,\n ethereumAddress: row.proofEthereumAddress as `0x${string}`,\n eip712: {\n domain,\n types: CREDENTIAL_TYPES,\n primaryType: \"VerifiableCredential\",\n },\n },\n };\n}\n\n// The chain id in a `did:pkh:<net>:<chainId>:<address>` issuer id.\nfunction issuerChainId(issuerId: string): string | undefined {\n return issuerId.split(\":\")[3];\n}\n\n// Reads a Switchboard reactor's `renown-read-model` subgraph directly over\n// GraphQL, replacing the Renown Next.js REST proxy. Read-only; plain `fetch`.\nexport class SwitchboardClient {\n #endpoint: string;\n\n constructor(endpoint: string) {\n this.#endpoint = endpoint;\n }\n\n get endpoint() {\n return this.#endpoint;\n }\n\n async #request<T>(\n query: string,\n variables: Record<string, unknown>,\n ): Promise<T> {\n const response = await fetch(this.#endpoint, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ query, variables }),\n });\n if (!response.ok) {\n throw new Error(`Switchboard request failed: ${response.status}`);\n }\n const body = (await response.json()) as {\n data?: T;\n errors?: { message: string }[];\n };\n if (body.errors?.length) {\n throw new Error(body.errors.map((e) => e.message).join(\"; \"));\n }\n if (!body.data) {\n throw new Error(\"Switchboard returned no data\");\n }\n return body.data;\n }\n\n // Fetch the active delegation credential for (address, chainId) that delegates\n // to `appDid`: filter by chainId, drop expired, return most recent.\n async getCredential(params: {\n address: string;\n chainId: number;\n appDid: string;\n }): Promise<PowerhouseVerifiableCredential | undefined> {\n const { address, chainId, appDid } = params;\n const { renownCredentials } = await this.#request<{\n renownCredentials: ReadRenownCredential[];\n }>(CREDENTIALS_QUERY, {\n input: {\n driveId: userDriveId(address),\n ethAddress: address.toLowerCase(),\n did: appDid,\n includeRevoked: false,\n },\n });\n\n const now = Date.now();\n const candidates = renownCredentials\n .filter((row) => issuerChainId(row.issuerId) === String(chainId))\n .filter((row) => {\n if (!row.expirationDate) return true;\n const expiresAt = Date.parse(row.expirationDate);\n return !Number.isNaN(expiresAt) && expiresAt > now;\n })\n .sort((a, b) => Date.parse(b.issuanceDate) - Date.parse(a.issuanceDate));\n\n const mostRecent = candidates.at(0);\n return mostRecent ? reshapeCredential(mostRecent) : undefined;\n }\n\n // Look up a Renown profile by ethereum address via the `renownUsers` query.\n async getProfileByAddress(\n address: string,\n ): Promise<RenownProfile | undefined> {\n const { renownUsers } = await this.#request<{\n renownUsers: ReadRenownUser[];\n }>(USERS_QUERY, {\n input: {\n driveId: userDriveId(address),\n ethAddresses: [address.toLowerCase()],\n },\n });\n\n const user = renownUsers.at(0);\n if (!user) return undefined;\n return {\n documentId: user.documentId,\n username: user.username,\n ethAddress: user.ethAddress,\n userImage: user.userImage,\n createdAt: user.createdAt,\n updatedAt: user.updatedAt,\n };\n }\n\n // Create an empty document of the given type; returns its document id.\n async createEmptyDocument(\n documentType: string,\n parentIdentifier?: string,\n ): Promise<string> {\n const { createEmptyDocument } = await this.#request<{\n createEmptyDocument: { id: string };\n }>(CREATE_EMPTY_DOCUMENT_MUTATION, { documentType, parentIdentifier });\n return createEmptyDocument.id;\n }\n\n // Apply reactor action envelopes to a document; returns its document id.\n async mutateDocument(\n documentIdentifier: string,\n actions: Action[],\n ): Promise<string> {\n const { mutateDocument } = await this.#request<{\n mutateDocument: { id: string };\n }>(MUTATE_DOCUMENT_MUTATION, { documentIdentifier, actions });\n return mutateDocument.id;\n }\n\n // Issue a signed credential: create a renown-credential doc and INIT it.\n async issueCredential(\n credential: PowerhouseVerifiableCredential,\n ): Promise<string> {\n const documentId = await this.createEmptyDocument(\n RENOWN_CREDENTIAL_DOC_TYPE,\n );\n const input: Record<string, unknown> = {\n id: credential.id,\n context: credential[\"@context\"],\n type: credential.type,\n issuer: {\n id: credential.issuer.id,\n ethereumAddress: credential.issuer.ethereumAddress,\n },\n credentialSubject: {\n id: credential.credentialSubject.id,\n app: credential.credentialSubject.app,\n },\n credentialSchema: {\n id: credential.credentialSchema.id,\n type: credential.credentialSchema.type,\n },\n issuanceDate: credential.issuanceDate,\n expirationDate: credential.expirationDate || undefined,\n proof: {\n type: credential.proof.type,\n created: credential.proof.created,\n verificationMethod: credential.proof.verificationMethod,\n proofPurpose: credential.proof.proofPurpose,\n proofValue: credential.proof.proofValue,\n ethereumAddress: credential.proof.ethereumAddress,\n eip712: {\n domain: {\n version: credential.proof.eip712.domain.version,\n chainId: credential.proof.eip712.domain.chainId,\n },\n primaryType: credential.proof.eip712.primaryType,\n },\n },\n };\n await this.mutateDocument(documentId, [createAction(\"INIT\", input)]);\n return documentId;\n }\n\n // Find the RenownUser for an address or create one; returns its document id.\n async findOrCreateUser(\n address: string,\n profile: { username?: string; userImage?: string } = {},\n ): Promise<string> {\n const updates: Action[] = [];\n if (profile.username !== undefined) {\n updates.push(\n createAction(\"SET_USERNAME\", { username: profile.username }),\n );\n }\n if (profile.userImage !== undefined) {\n updates.push(\n createAction(\"SET_USER_IMAGE\", { userImage: profile.userImage }),\n );\n }\n\n const existing = await this.getProfileByAddress(address);\n if (existing) {\n if (updates.length)\n await this.mutateDocument(existing.documentId, updates);\n return existing.documentId;\n }\n\n const documentId = await this.createEmptyDocument(RENOWN_USER_DOC_TYPE);\n await this.mutateDocument(documentId, [\n createAction(\"SET_ETH_ADDRESS\", { ethAddress: address }),\n ...updates,\n ]);\n return documentId;\n }\n\n // Revoke a credential by its document id.\n async revokeCredential(documentId: string, reason?: string): Promise<void> {\n await this.mutateDocument(documentId, [\n createAction(\"REVOKE\", {\n revokedAt: new Date().toISOString(),\n reason: reason ?? null,\n }),\n ]);\n }\n\n // A ProfileFetcher backed by this client; used as the default when the\n // direct-switchboard flow is active. The `baseUrl` argument is ignored.\n profileFetcher: ProfileFetcher = (user) =>\n this.getProfileByAddress(user.address).catch(() => undefined);\n}\n","import { recoverTypedDataAddress } from \"viem\";\nimport {\n CREDENTIAL_TYPES,\n DEFAULT_RENOWN_NETWORK_ID,\n DEFAULT_RENOWN_URL,\n} from \"./constants.js\";\nimport { resolveSwitchboardEndpoint } from \"./discovery.js\";\nimport { SwitchboardClient } from \"./switchboard.js\";\nimport type { IProof, PowerhouseVerifiableCredential } from \"./types.js\";\nimport { verifyAuthBearerToken } from \"./utils.js\";\n\n/* Local structural aliases (EIP-712 standard shapes) so renown's public .d.ts\n * never names viem — a viem type in the surface drags viem's whole closure in. */\ntype Hex = `0x${string}`;\ntype TypedDataDomain = {\n name?: string;\n version?: string;\n chainId?: number;\n verifyingContract?: Hex;\n salt?: Hex;\n};\ntype TypedDataParameter = { name: string; type: string };\n\n/** EIP-712 domain as signed by the credential issuer. */\nexport type CredentialDomain = {\n version: string;\n chainId: number;\n};\n\n/** The credential body that is EIP-712 signed (everything except `proof`). */\nexport type CredentialMessage = {\n \"@context\": string[];\n type: string[];\n id: string;\n issuer: { id: string; ethereumAddress: Hex };\n credentialSubject: { id: string; app: string };\n credentialSchema: { id: string; type: string };\n issuanceDate: string;\n expirationDate: string;\n};\n\n/** Typed-data signer; matches the loose shape used by wallet adapters. */\nexport type SignCredentialTypedData = (args: {\n domain: TypedDataDomain;\n types: Record<string, readonly TypedDataParameter[]>;\n primaryType: string;\n message: Record<string, unknown>;\n}) => Promise<Hex>;\n\nexport interface BuildCredentialParams {\n signTypedData: SignCredentialTypedData;\n address: Hex;\n chainId: number;\n app: string;\n /** Credential subject id: the app/client DID the credential delegates to. */\n appId: string;\n expiresInDays?: number;\n}\n\n/** Assemble a Renown delegation VC and sign it with the provided signer. */\nexport async function buildAndSignCredential(\n params: BuildCredentialParams,\n): Promise<PowerhouseVerifiableCredential> {\n const {\n signTypedData,\n address,\n chainId,\n app,\n appId,\n expiresInDays = 7,\n } = params;\n\n const issuerId = `did:pkh:${DEFAULT_RENOWN_NETWORK_ID}:${chainId}:${address.toLowerCase()}`;\n const credentialId = `urn:uuid:${globalThis.crypto.randomUUID()}`;\n const now = new Date();\n const expirationDate = new Date(\n now.getTime() + expiresInDays * 24 * 60 * 60 * 1000,\n );\n\n const message: CredentialMessage = {\n \"@context\": [\"https://www.w3.org/2018/credentials/v1\"],\n type: [\"VerifiableCredential\", \"RenownCredential\"],\n id: credentialId,\n issuer: { id: issuerId, ethereumAddress: address },\n credentialSubject: { id: appId, app },\n credentialSchema: {\n id: \"https://renown.id/schemas/renown-credential/v1\",\n type: \"JsonSchemaValidator2018\",\n },\n issuanceDate: now.toISOString(),\n expirationDate: expirationDate.toISOString(),\n };\n\n const domain: CredentialDomain = { version: \"1\", chainId };\n\n // viem and most wallet adapters reserve EIP712Domain and derive it from\n // `domain` — passing it explicitly makes them throw.\n const { EIP712Domain, ...signTypes } = CREDENTIAL_TYPES;\n void EIP712Domain;\n const signature = await signTypedData({\n domain,\n types: signTypes,\n primaryType: \"VerifiableCredential\",\n message,\n });\n\n return {\n ...message,\n proof: {\n type: \"EthereumEip712Signature2021\",\n created: message.issuanceDate,\n verificationMethod: issuerId,\n proofPurpose: \"assertionMethod\",\n proofValue: signature,\n ethereumAddress: address,\n eip712: {\n domain,\n types: CREDENTIAL_TYPES,\n primaryType: \"VerifiableCredential\",\n },\n },\n };\n}\n\n/** Recover the address that signed a credential's EIP-712 proof. */\nexport async function recoverCredentialSigner(\n credential: PowerhouseVerifiableCredential,\n): Promise<Hex> {\n const { proof, ...message } = credential;\n // Drop EIP712Domain so viem derives it from `domain`; viem ignores\n // message keys not present in the types, so the proof is excluded too.\n const { EIP712Domain, ...types } = CREDENTIAL_TYPES;\n void EIP712Domain;\n return recoverTypedDataAddress({\n domain: proof.eip712.domain,\n types,\n primaryType: \"VerifiableCredential\",\n message,\n signature: proof.proofValue as Hex,\n } as Parameters<typeof recoverTypedDataAddress>[0]);\n}\n\n/** True when the proof was signed by the credential's declared issuer address. */\nexport async function verifyCredentialSignature(\n credential: PowerhouseVerifiableCredential,\n): Promise<boolean> {\n try {\n const recovered = await recoverCredentialSigner(credential);\n return (\n recovered.toLowerCase() ===\n credential.issuer.ethereumAddress.toLowerCase()\n );\n } catch {\n // Malformed proof (bad hex, missing fields) is an invalid signature.\n return false;\n }\n}\n\n// The deployed Renown API may omit proof.eip712.domain; it's canonical\n// (version \"1\", the credential's chainId), so reconstruct it before verifying.\nfunction withEip712Domain(\n credential: PowerhouseVerifiableCredential,\n chainId: number,\n): PowerhouseVerifiableCredential {\n const eip712 = credential.proof.eip712 as\n | Partial<IProof[\"eip712\"]>\n | undefined;\n if (eip712?.domain) return credential;\n return {\n ...credential,\n proof: {\n ...credential.proof,\n eip712: {\n domain: { version: \"1\", chainId },\n types: CREDENTIAL_TYPES,\n primaryType: \"VerifiableCredential\",\n },\n },\n };\n}\n\nexport interface FetchDelegationCredentialOptions {\n /** Ethereum address that must have issued the credential. */\n address: string;\n /** Chain id the credential must be scoped to. */\n chainId: number;\n /** App/client DID the credential must delegate to (credentialSubject.id). */\n appDid: string;\n /** Renown service base URL. Defaults to DEFAULT_RENOWN_URL. */\n baseUrl?: string;\n /** Switchboard GraphQL endpoint; when reachable, read the reactor directly. */\n switchboardUrl?: string;\n /** Probe {baseUrl}/api/switchboard for an endpoint (default true). */\n discover?: boolean;\n /** Re-verify the EIP-712 proof signature (default true). */\n verifySignature?: boolean;\n}\n\n// Fetch + binding/expiry-validate the credential over the Renown REST API.\nasync function fetchDelegationCredentialRest(params: {\n address: string;\n chainId: number;\n appDid: string;\n baseUrl: string;\n}): Promise<PowerhouseVerifiableCredential | undefined> {\n const { address, chainId, appDid, baseUrl } = params;\n const url = new URL(\n `/api/auth/credential?address=${encodeURIComponent(address)}&chainId=${encodeURIComponent(chainId)}&connectId=${encodeURIComponent(appDid)}&appId=${encodeURIComponent(appDid)}`,\n baseUrl,\n );\n const response = await fetch(url, { method: \"GET\" });\n if (!response.ok) return undefined;\n const { credential } = (await response.json()) as {\n credential?: PowerhouseVerifiableCredential;\n };\n if (!credential) return undefined;\n\n // Binding: delegates to this app DID, issued by this address on this chain\n // (issuer.id = did:pkh:<networkId>:<chainId>:<address>).\n const [, , , issuerChainId, issuerAddress] = credential.issuer.id.split(\":\");\n if (\n credential.credentialSubject.id !== appDid ||\n issuerChainId !== String(chainId) ||\n issuerAddress.toLowerCase() !== address.toLowerCase() ||\n credential.issuer.ethereumAddress.toLowerCase() !== address.toLowerCase()\n ) {\n return undefined;\n }\n\n // Reject an expired credential (revocation drops it from the endpoint\n // instead); a malformed date (NaN) counts as invalid, not non-expiring.\n if (credential.expirationDate) {\n const expiresAt = Date.parse(credential.expirationDate);\n if (Number.isNaN(expiresAt) || expiresAt <= Date.now()) {\n return undefined;\n }\n }\n\n return credential;\n}\n\n// Optionally re-verify the EIP-712 proof; returns the credential or undefined.\nasync function finalizeCredential(\n credential: PowerhouseVerifiableCredential,\n chainId: number,\n verifySignature: boolean,\n): Promise<PowerhouseVerifiableCredential | undefined> {\n if (!verifySignature) return credential;\n const withDomain = withEip712Domain(credential, chainId);\n if (\n withDomain.proof.eip712.domain.chainId !== chainId ||\n !(await verifyCredentialSignature(withDomain))\n ) {\n return undefined;\n }\n return withDomain;\n}\n\n// Fetch the Renown delegation credential for (address, chainId) and validate it\n// delegates to `appDid`; returns it, or undefined if absent/invalid. No throw.\nexport async function fetchDelegationCredential(\n options: FetchDelegationCredentialOptions,\n): Promise<PowerhouseVerifiableCredential | undefined> {\n const {\n address,\n chainId,\n appDid,\n switchboardUrl,\n discover = true,\n verifySignature = true,\n } = options;\n const explicitBaseUrl = options.baseUrl;\n const baseUrl = explicitBaseUrl ?? DEFAULT_RENOWN_URL;\n try {\n // An explicit switchboardUrl is used directly; otherwise discover from the\n // base URL unless disabled (callers that already resolved the endpoint).\n const endpoint = switchboardUrl\n ? switchboardUrl\n : discover && explicitBaseUrl\n ? await resolveSwitchboardEndpoint({ baseUrl })\n : undefined;\n\n const credential = endpoint\n ? await new SwitchboardClient(endpoint).getCredential({\n address,\n chainId,\n appDid,\n })\n : await fetchDelegationCredentialRest({\n address,\n chainId,\n appDid,\n baseUrl,\n });\n\n if (!credential) return undefined;\n return await finalizeCredential(credential, chainId, verifySignature);\n } catch {\n return undefined;\n }\n}\n\nexport interface VerifiedAuthCredential {\n address: string;\n chainId: number;\n networkId: string;\n /** Owner identity: the pkh DID (did:pkh:<net>:<chainId>:<address>). */\n did: string;\n /** App/client DID the bearer token was issued by. */\n appDid: string;\n credential: PowerhouseVerifiableCredential;\n}\n\nexport interface VerifyAuthCredentialOptions {\n /** Expected `aud` claim on the bearer token. */\n audience?: string;\n /** Renown service base URL. */\n renownUrl?: string;\n /** Switchboard GraphQL endpoint; when reachable, read the reactor directly. */\n switchboardUrl?: string;\n /** Re-verify the credential's EIP-712 proof (default true). */\n verifySignature?: boolean;\n}\n\n// Verify a renown bearer token end to end: check the JWT, then fetch+verify the\n// matching credential. Resolves the owner identity, or undefined. No throw.\nexport async function verifyAuthCredential(\n jwt: string,\n options: VerifyAuthCredentialOptions = {},\n): Promise<VerifiedAuthCredential | undefined> {\n const verified = await verifyAuthBearerToken(jwt, {\n audience: options.audience,\n });\n if (!verified) return undefined;\n\n const { address, chainId, networkId } =\n verified.verifiableCredential.credentialSubject;\n const appDid = verified.issuer;\n const credential = await fetchDelegationCredential({\n address,\n chainId,\n appDid,\n baseUrl: options.renownUrl,\n switchboardUrl: options.switchboardUrl,\n verifySignature: options.verifySignature,\n });\n if (!credential) return undefined;\n\n return {\n address,\n chainId,\n networkId,\n did: credential.issuer.id,\n appDid,\n credential,\n };\n}\n","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_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 type { SwitchboardClient } 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} from \"./types.js\";\nimport { parsePkhDid, verifyAuthBearerToken } from \"./utils.js\";\nexport * from \"./constants.js\";\n\nexport class RenownMemoryStorage extends MemoryStorage<RenownStorageMap> {}\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 #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 ) {\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 const restoredUser = this.user;\n this.#signer = new RenownCryptoSigner(crypto, this.#appName, restoredUser);\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 = user;\n });\n }\n\n get baseUrl() {\n return this.#baseUrl;\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) {\n throw new Error(\n \"signIn requires a switchboard endpoint. Set switchboardUrl or a discoverable baseUrl.\",\n );\n }\n const {\n address,\n chainId,\n signTypedData,\n username,\n userImage,\n expiresInDays,\n } = params;\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 return true;\n } catch {\n return true;\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_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}\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\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 /**\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 crypto =\n this.#crypto ??\n (await new RenownCryptoBuilder()\n .withKeyPairStorage(this.#keyPairStorage!)\n .build());\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 );\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\n return builder;\n }\n}\n"],"mappings":";;;;AAAA,MAAa,qBAAqB;AAClC,MAAa,4BAA4B;AACzC,MAAa,0BAA0B;;AAGvC,MAAa,wBAAwB;AAErC,MAAa,cAAc,CACzB;CAAE,MAAM;CAAW,MAAM;CAAU,EACnC;CAAE,MAAM;CAAW,MAAM;CAAW,CACrC;AAED,MAAa,oCAAoC;CAC/C;EAAE,MAAM;EAAY,MAAM;EAAY;CACtC;EAAE,MAAM;EAAQ,MAAM;EAAY;CAClC;EAAE,MAAM;EAAM,MAAM;EAAU;CAC9B;EAAE,MAAM;EAAU,MAAM;EAAU;CAClC;EAAE,MAAM;EAAqB,MAAM;EAAqB;CACxD;EAAE,MAAM;EAAoB,MAAM;EAAoB;CACtD;EAAE,MA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OACjB,SACA,cACA,QACA,MAAA,SACA,SACA,gBACA,YACD;;;;;CAUH,OAAO,KAAK,SAAkD;EAC5D,MAAM,UAAU,IAAI,kBAAkB,QAAQ,QAAQ;AAEtD,MAAI,QAAQ,QACV,SAAQ,YAAY,QAAQ,QAAQ;AAEtC,MAAI,QAAQ,aACV,SAAQ,iBAAiB,QAAQ,aAAa;AAEhD,MAAI,QAAQ,OACV,SAAQ,WAAW,QAAQ,OAAO;AAEpC,MAAI,QAAQ,eACV,SAAQ,mBAAmB,QAAQ,eAAe;AAEpD,MAAI,QAAQ,QACV,SAAQ,YAAY,QAAQ,QAAQ;AAEtC,MAAI,QAAQ,eACV,SAAQ,mBAAmB,QAAQ,eAAe;AAEpD,MAAI,QAAQ,eACV,SAAQ,mBAAmB,QAAQ,eAAe;AAGpD,SAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils-OOrVXHof.d.ts","names":[],"sources":["../src/switchboard.ts","../src/common.ts","../src/discovery.ts","../src/renown-builder.ts","../src/profile.ts","../src/utils.ts"],"mappings":";;;;;cAwLa,iBAAA;EAAA;cAGC,QAAA;EAAA,IAIR,QAAA,CAAA;EA+BE,aAAA,CAAc,MAAA;IAClB,OAAA;IACA,OAAA;IACA,MAAA;EAAA,IACE,OAAA,CAAQ,8BAAA;EA4BN,mBAAA,CACJ,OAAA,WACC,OAAA,CAAQ,aAAA;EAuBL,mBAAA,CACJ,YAAA,UACA,gBAAA,YACC,OAAA;EAQG,cAAA,CACJ,kBAAA,UACA,OAAA,EAAS,MAAA,KACR,OAAA;EAQG,eAAA,CACJ,UAAA,EAAY,8BAAA,GACX,OAAA;EA2CG,gBAAA,CACJ,OAAA,UACA,OAAA;IAAW,QAAA;IAAmB,SAAA;EAAA,IAC7B,OAAA;EA6BG,gBAAA,CAAiB,UAAA,UAAoB,MAAA,YAAkB,OAAA;EAW7D,cAAA,EAAgB,cAAA;AAAA;;;cCtWL,mBAAA,SAA4B,aAAA,CAAc,gBAAA;AAAA,c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AAiB,YAAA,EAAc,kBAAA;EHmM7B;;;;EG1LF,UAAA,CAAW,MAAA,EAAQ,aAAA;EHoNjB;;;;;EG1MF,kBAAA,CAAmB,cAAA,EAAgB,qBAAA;EHsNhC;;;;EG7MH,WAAA,CAAY,OAAA;EAOZ,kBAAA,CAAmB,cAAA;EH4PjB;;;;;;EGjPF,kBAAA,CAAmB,cAAA,EAAgB,cAAA;EHgRQ;;;;;EGtQrC,KAAA,CAAA,GAAS,OAAA,CAAQ,MAAA;;;;SAgDhB,IAAA,CAAK,OAAA,EAAS,oBAAA,GAAuB,iBAAA;AAAA;;;cClKjC,kBAAA,EAAoB,cAAA;;;KCWrB,OAAA;EACV,KAAA;EAEA,OAAA,GAAU,OAAA,aAAoB,YAAA;EAC9B,KAAA,GAAQ,OAAA,aAAoB,YAAA;EAC5B,IAAA,GAAO,OAAA,aAAoB,YAAA;EAC3B,IAAA,GAAO,OAAA,aAAoB,YAAA;EAC3B,KAAA,GAAQ,OAAA,aAAoB,YAAA;AAAA;;;;;;;iBASd,WAAA,CAAY,GAAA,WAAc,MAAA;AAAA,UAuBzB,4BAAA;ELsU8C;;;;EKjU7D,QAAA;AAAA;AAAA,iBAGoB,qBAAA,CACpB,GAAA,UACA,OAAA,GAAU,4BAAA,GACT,OAAA,SAAgB,sBAAA;AAAA,iBA2BH,sBAAA,CACd,UAAA,EAAY,kBAAA,WACH,UAAA,IAAc,sBAAA;AAAA,iBAoBH,qBAAA,CACpB,OAAA,UACA,SAAA,UACA,OAAA,UACA,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,wBAAA,GAAwB,OAAA;AAAA,cAsBvB,WAAA,QAAW,QAAA"}
1
+ {"version":3,"file":"utils-OOrVXHof.d.ts","names":[],"sources":["../src/switchboard.ts","../src/common.ts","../src/discovery.ts","../src/renown-builder.ts","../src/profile.ts","../src/utils.ts"],"mappings":";;;;;cAwLa,iBAAA;EAAA;cAGC,QAAA;EAAA,IAIR,QAAA,CAAA;EA+BE,aAAA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;AAAA,iBAGoB,qBAAA,CACpB,GAAA,UACA,OAAA,GAAU,4BAAA,GACT,OAAA,SAAgB,sBAAA;AAAA,iBA2BH,sBAAA,CACd,UAAA,EAAY,kBAAA,WACH,UAAA,IAAc,sBAAA;AAAA,iBAoBH,qBAAA,CACpB,OAAA,UACA,SAAA,UACA,OAAA,UACA,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,wBAAA,GAAwB,OAAA;AAAA,cAsBvB,WAAA,QAAW,QAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@renown/sdk",
3
- "version": "6.2.2-dev.13",
3
+ "version": "6.2.2-dev.15",
4
4
  "description": "Renown SDK — wallet-based authentication and user identity management for Powerhouse React applications.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "private": false,
@@ -86,7 +86,7 @@
86
86
  "key-did-resolver": "^4.0.0",
87
87
  "uint8arrays": "^5.1.0",
88
88
  "viem": "~2.50.4",
89
- "@powerhousedao/shared": "6.2.2-dev.13"
89
+ "@powerhousedao/shared": "6.2.2-dev.15"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "@privy-io/react-auth": "^3.25.0",