@renown/sdk 6.2.3-dev.27 → 6.2.3-dev.28
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/crypto.d.ts +2 -2
- package/dist/{index-CGTiUojp.d.ts → index-DbiBjqs6.d.ts} +2 -2
- package/dist/{index-CGTiUojp.d.ts.map → index-DbiBjqs6.d.ts.map} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/{meta-DlON7DmF.d.ts → meta-Dpmn2Ywp.d.ts} +2 -2
- package/dist/{meta-DlON7DmF.d.ts.map → meta-Dpmn2Ywp.d.ts.map} +1 -1
- package/dist/{meta-CpBbgZnu.d.ts → meta-qadFdiX7.d.ts} +2 -2
- package/dist/{meta-CpBbgZnu.d.ts.map → meta-qadFdiX7.d.ts.map} +1 -1
- package/dist/node.d.ts +5 -5
- package/dist/node.js +3 -3
- package/dist/{local-credential-verifier-BC4HS01T.js → signed-message-Cp5oRPLN.js} +46 -7
- package/dist/signed-message-Cp5oRPLN.js.map +1 -0
- package/dist/{signer-trust-DstQutcf.d.ts → signer-trust-FmbMTn39.d.ts} +2 -2
- package/dist/{signer-trust-DstQutcf.d.ts.map → signer-trust-FmbMTn39.d.ts.map} +1 -1
- package/dist/{signer-trust-C6UJAsNJ.js → signer-trust-H1rNzUcd.js} +127 -25
- package/dist/signer-trust-H1rNzUcd.js.map +1 -0
- package/dist/trust.d.ts +1 -1
- package/dist/trust.js +1 -1
- package/dist/{types-CHIgkzKb.d.ts → types-7xgrEnx7.d.ts} +2 -2
- package/dist/{types-CHIgkzKb.d.ts.map → types-7xgrEnx7.d.ts.map} +1 -1
- package/dist/{types-DOTk0z2D.d.ts → types-Ceiz2dkk.d.ts} +22 -8
- package/dist/types-Ceiz2dkk.d.ts.map +1 -0
- package/dist/{types-Bsve10Ny.d.ts → types-DRnq2URw.d.ts} +2 -2
- package/dist/{types-Bsve10Ny.d.ts.map → types-DRnq2URw.d.ts.map} +1 -1
- package/dist/{utils-C_2VV8CS.d.ts → utils-DkVxP7Ug.d.ts} +18 -4
- package/dist/utils-DkVxP7Ug.d.ts.map +1 -0
- package/dist/wallet/index.d.ts +1 -1
- package/dist/wallet/mock/factory.d.ts +2 -2
- package/dist/wallet/mock/index.d.ts +2 -2
- package/dist/wallet/privy/factory.d.ts +3 -3
- package/dist/wallet/privy/index.d.ts +2 -2
- package/dist/wallet/rainbow/factory.d.ts +2 -2
- package/dist/wallet/rainbow/index.d.ts +2 -2
- package/package.json +2 -2
- package/dist/local-credential-verifier-BC4HS01T.js.map +0 -1
- package/dist/signer-trust-C6UJAsNJ.js.map +0 -1
- package/dist/types-DOTk0z2D.d.ts.map +0 -1
- package/dist/utils-C_2VV8CS.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer-trust-H1rNzUcd.js","names":["bindsTo"],"sources":["../src/discovery.ts","../src/switchboard.ts","../src/credential.ts","../src/signer-trust.ts"],"sourcesContent":["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/** Thrown by `signIn` when the instance has no switchboard to write the\n * credential to, so a host can fall back to the Renown redirect flow. */\nexport class MissingSwitchboardError extends Error {\n constructor() {\n super(\n \"signIn requires a switchboard endpoint. Set switchboardUrl or a discoverable baseUrl.\",\n );\n this.name = \"MissingSwitchboardError\";\n }\n\n /** `instanceof` fails across duplicate SDK copies, so match by name too. */\n static is(error: unknown): error is MissingSwitchboardError {\n return (\n error instanceof MissingSwitchboardError ||\n (error instanceof Error && error.name === \"MissingSwitchboardError\")\n );\n }\n}\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: [ActionInput!]!\n ) {\n mutateDocument: execute(\n documentIdentifier: $documentIdentifier\n actions: $actions\n ) {\n id\n }\n }\n`;\n\n/* Switchboards older than 6.2.2-dev.54 have no `execute`; their `mutateDocument`\n takes the same envelopes as untyped JSON. Same selection, so one result shape. */\nconst LEGACY_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\n// graphql-js validation failure for a field the server's schema lacks.\nfunction isUnknownExecuteField(error: unknown): boolean {\n return (\n error instanceof Error &&\n /Cannot query field \"execute\" on type \"Mutation\"/.test(error.message)\n );\n}\n\n// Dedicated renown-package mutations that write through the reactor client,\n// bypassing the authorization policy so unauthenticated sign-in can bootstrap.\nconst ISSUE_CREDENTIAL_MUTATION = /* GraphQL */ `\n mutation RenownIssueCredential(\n $input: RenownCredential_InitInput!\n $username: String\n $userImage: String\n $userDocId: PHID\n ) {\n renown_issueCredential(\n input: $input\n username: $username\n userImage: $userImage\n userDocId: $userDocId\n )\n }\n`;\n\nconst UPSERT_PROFILE_MUTATION = /* GraphQL */ `\n mutation RenownUpsertProfile(\n $address: String!\n $username: String\n $userImage: String\n $signature: String\n $timestamp: String\n ) {\n renown_upsertProfile(\n address: $address\n username: $username\n userImage: $userImage\n signature: $signature\n timestamp: $timestamp\n )\n }\n`;\n\nconst REVOKE_CREDENTIAL_MUTATION = /* GraphQL */ `\n mutation RenownRevokeCredential(\n $credentialId: String!\n $signature: String\n $timestamp: String\n ) {\n renown_revokeCredential(\n credentialId: $credentialId\n signature: $signature\n timestamp: $timestamp\n )\n }\n`;\n\n/** How a caller authorizes a Renown write: a login (bearer) token for the\n * address, or that address's `personal_sign` over the canonical message\n * (`revokeMessage` / `profileMessage`) with the ISO-8601 timestamp it signed. */\nexport type RenownWriteAuth =\n | { token: string }\n | { signature: string; timestamp: string };\n\n// Split a RenownWriteAuth into the bearer token and the signature variables.\nfunction authParts(auth: RenownWriteAuth): {\n token?: string;\n signed: { signature?: string; timestamp?: string };\n} {\n return \"token\" in auth\n ? { token: auth.token, signed: {} }\n : {\n signed: { signature: auth.signature, timestamp: auth.timestamp },\n };\n}\n\nconst RENOWN_CREDENTIAL_DOC_TYPE = \"powerhouse/renown-credential\";\nconst RENOWN_USER_DOC_TYPE = \"powerhouse/renown-user\";\n\n// A `\"name\"` quote as graphql-js writes it; `\\\"` too, for transports that\n// relay the errors JSON-encoded inside their own message.\nfunction quoted(name: string): string {\n return `\\\\\\\\?\"${name}\\\\\\\\?\"`;\n}\n\n// True when `error` says the switchboard's schema lacks `field` itself (or\n// one of `types`) — an older renown-package without the renown-auth subgraph.\n// Anything else, including a NEW server's input-coercion failure such as\n// `Variable \"$input\" got invalid value …; Field \"x\" is not defined by type\n// \"RenownCredential_InitInput\"`, is a rejection and must not fall back.\nfunction isUnknownSchemaError(\n error: unknown,\n field: string,\n ...types: string[]\n): boolean {\n const message = error instanceof Error ? error.message : String(error);\n if (new RegExp(`Cannot query field ${quoted(field)}`).test(message)) {\n return true;\n }\n return (\n !message.includes(\"got invalid value\") &&\n types.some((type) =>\n new RegExp(`Unknown type ${quoted(type)}`).test(message),\n )\n );\n}\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// The address in a `did:pkh:<net>:<chainId>:<address>` issuer id.\nfunction issuerDidAddress(issuerId: string): string | undefined {\n return issuerId.split(\":\")[4];\n}\n\n// Re-check the delegation binding instead of trusting the read-model's\n// `did`/`ethAddress` filters, matching the REST path in `credential.ts`.\nfunction bindsTo(\n row: ReadRenownCredential,\n address: string,\n chainId: number,\n appDid: string,\n): boolean {\n return !row.revoked && issuedTo(row, address, chainId, appDid);\n}\n\nfunction issuedTo(\n row: ReadRenownCredential,\n address: string,\n chainId: number,\n appDid: string,\n): boolean {\n const expected = address.toLowerCase();\n return (\n row.credentialSubjectId === appDid &&\n issuerChainId(row.issuerId) === String(chainId) &&\n issuerDidAddress(row.issuerId)?.toLowerCase() === expected &&\n row.issuerEthereumAddress.toLowerCase() === expected\n );\n}\n\n/** Per-request options: `token` is a Renown bearer token that authenticates\n * the request (sent as `Authorization: Bearer <token>` over HTTP). */\nexport interface SwitchboardRequestOptions {\n token?: string;\n}\n\n/** Runs a GraphQL document against a Switchboard and resolves its `data`;\n * throws on transport or GraphQL errors. */\nexport type SwitchboardRequestFn = (\n query: string,\n variables: Record<string, unknown>,\n options?: SwitchboardRequestOptions,\n) => Promise<unknown>;\n\n/** Where a SwitchboardClient reads from: an HTTP endpoint or a local executor. */\nexport type SwitchboardSource = string | SwitchboardRequestFn;\n\n// Reads and writes a Switchboard reactor's `renown-read-model` subgraph and\n// document mutations over GraphQL, replacing the Renown Next.js REST proxy.\nexport class SwitchboardClient {\n #endpoint: string | undefined;\n #transport: SwitchboardRequestFn;\n // Set once the switchboard has rejected `execute`, so later writes skip the probe.\n #legacyMutate = false;\n\n constructor(source: SwitchboardSource) {\n if (typeof source === \"string\") {\n this.#endpoint = source;\n this.#transport = (query, variables, options) =>\n this.#post(source, query, variables, options?.token);\n } else {\n this.#transport = source;\n }\n }\n\n /** The HTTP endpoint, or undefined when reading through a local executor. */\n get endpoint(): string | undefined {\n return this.#endpoint;\n }\n\n async #post(\n endpoint: string,\n query: string,\n variables: Record<string, unknown>,\n token?: string,\n ): Promise<unknown> {\n const response = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(token ? { Authorization: `Bearer ${token}` } : {}),\n },\n body: JSON.stringify({ query, variables }),\n });\n /* A validation failure comes back as 400 WITH a GraphQL error body, so read\n it before judging the status: the messages say what was wrong, the code\n only that something was. */\n const body = (await response.json().catch(() => undefined)) as\n | { data?: unknown; errors?: { message: string }[] }\n | undefined;\n if (body?.errors?.length) {\n throw new Error(body.errors.map((e) => e.message).join(\"; \"));\n }\n if (!response.ok || !body) {\n throw new Error(`Switchboard request failed: ${response.status}`);\n }\n // `#request` rejects an empty `data` for every transport, HTTP or local.\n return body.data;\n }\n\n async #request<T>(\n query: string,\n variables: Record<string, unknown>,\n token?: string,\n ): Promise<T> {\n const data = await (token\n ? this.#transport(query, variables, { token })\n : this.#transport(query, variables));\n if (!data) {\n throw new Error(\"Switchboard returned no data\");\n }\n return data as T;\n }\n\n // Fetch the active delegation credential for (address, chainId) that delegates\n // to `appDid`: re-check the binding, 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) => bindsTo(row, address, chainId, appDid))\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 // Every credential (address, chainId) issued to `appDid`, revoked and expired\n // included: that the address once delegated to the key does not change.\n async getIssuedCredentials(params: {\n address: string;\n chainId: number;\n appDid: string;\n }): Promise<PowerhouseVerifiableCredential[]> {\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: true,\n },\n });\n\n const credentials: PowerhouseVerifiableCredential[] = [];\n for (const row of renownCredentials) {\n if (!issuedTo(row, address, chainId, appDid)) continue;\n try {\n credentials.push(reshapeCredential(row));\n } catch {\n // A row whose proof domain does not parse cannot verify.\n }\n }\n return credentials;\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 // Pass a bearer token to authenticate the write when auth is enabled.\n async createEmptyDocument(\n documentType: string,\n parentIdentifier?: string,\n token?: string,\n ): Promise<string> {\n const { createEmptyDocument } = await this.#request<{\n createEmptyDocument: { id: string };\n }>(\n CREATE_EMPTY_DOCUMENT_MUTATION,\n { documentType, parentIdentifier },\n token,\n );\n return createEmptyDocument.id;\n }\n\n // Apply reactor action envelopes to a document; returns its document id.\n // Pass a bearer token to authenticate the write when auth is enabled.\n async mutateDocument(\n documentIdentifier: string,\n actions: Action[],\n token?: string,\n ): Promise<string> {\n const variables = { documentIdentifier, actions };\n if (!this.#legacyMutate) {\n try {\n const { mutateDocument } = await this.#request<{\n mutateDocument: { id: string };\n }>(MUTATE_DOCUMENT_MUTATION, variables, token);\n return mutateDocument.id;\n } catch (error) {\n if (!isUnknownExecuteField(error)) throw error;\n this.#legacyMutate = true;\n }\n }\n const { mutateDocument } = await this.#request<{\n mutateDocument: { id: string };\n }>(LEGACY_MUTATE_DOCUMENT_MUTATION, variables, token);\n return mutateDocument.id;\n }\n\n // Issue a signed credential via the renown-package `renown_issueCredential`\n // mutation, which validates the proof and writes without requiring auth.\n async issueCredential(\n credential: PowerhouseVerifiableCredential,\n parentIdentifier?: string,\n ): Promise<string> {\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 try {\n const { renown_issueCredential } = await this.#request<{\n renown_issueCredential: string;\n }>(ISSUE_CREDENTIAL_MUTATION, { input });\n return renown_issueCredential;\n } catch (error) {\n // Fallback for a switchboard on an older renown-package without the\n // issuance subgraph: write via the generic reactor mutations instead.\n if (\n !isUnknownSchemaError(\n error,\n \"renown_issueCredential\",\n \"RenownCredential_InitInput\",\n )\n ) {\n throw error;\n }\n const documentId = await this.createEmptyDocument(\n RENOWN_CREDENTIAL_DOC_TYPE,\n parentIdentifier,\n );\n await this.mutateDocument(documentId, [createAction(\"INIT\", input)]);\n return documentId;\n }\n }\n\n // Create or update the RenownUser profile for an address via the\n // renown-package `renown_upsertProfile` mutation, authorized by a login token\n // for the address or its personal_sign of `profileMessage`. Returns the\n // profile document id.\n async upsertUserProfile(\n address: string,\n profile: { username?: string; userImage?: string },\n auth: RenownWriteAuth,\n ): Promise<string> {\n const { token, signed } = authParts(auth);\n try {\n const { renown_upsertProfile } = await this.#request<{\n renown_upsertProfile: string;\n }>(\n UPSERT_PROFILE_MUTATION,\n {\n address,\n username: profile.username,\n userImage: profile.userImage,\n ...signed,\n },\n token,\n );\n return renown_upsertProfile;\n } catch (error) {\n // Fallback for a switchboard on an older renown-package without the\n // renown-auth subgraph: write via the generic reactor mutations instead.\n if (!isUnknownSchemaError(error, \"renown_upsertProfile\")) throw error;\n return this.#legacyUpsertUserProfile(address, profile, token);\n }\n }\n\n async #legacyUpsertUserProfile(\n address: string,\n profile: { username?: string; userImage?: string },\n token?: string,\n ): Promise<string> {\n const updates: Action[] = [];\n if (profile.username != null) {\n updates.push(\n createAction(\"SET_USERNAME\", { username: profile.username }),\n );\n }\n if (profile.userImage != null) {\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, token);\n return existing.documentId;\n }\n\n const documentId = await this.createEmptyDocument(\n RENOWN_USER_DOC_TYPE,\n undefined,\n token,\n );\n await this.mutateDocument(\n documentId,\n [createAction(\"SET_ETH_ADDRESS\", { ethAddress: address }), ...updates],\n token,\n );\n return documentId;\n }\n\n // Revoke a credential by its VC id (`credential.id`, not its document id) via\n // the renown-package `renown_revokeCredential` mutation, authorized by a\n // login token for the issuer or its personal_sign of `revokeMessage`.\n async revokeCredential(\n credentialId: string,\n auth: RenownWriteAuth,\n ): Promise<void> {\n const { token, signed } = authParts(auth);\n try {\n await this.#request<{ renown_revokeCredential: boolean }>(\n REVOKE_CREDENTIAL_MUTATION,\n { credentialId, ...signed },\n token,\n );\n } catch (error) {\n // Fallback for a switchboard on an older renown-package without the\n // renown-auth subgraph: REVOKE the credential's documents directly.\n if (!isUnknownSchemaError(error, \"renown_revokeCredential\")) throw error;\n await this.#legacyRevokeCredential(credentialId, token);\n }\n }\n\n async #legacyRevokeCredential(\n credentialId: string,\n token?: string,\n ): Promise<void> {\n // The read model has no lookup by VC id, so scan the live credentials.\n const { renownCredentials } = await this.#request<{\n renownCredentials: ReadRenownCredential[];\n }>(CREDENTIALS_QUERY, { input: { includeRevoked: false } }, token);\n const documentIds = renownCredentials\n .filter((row) => row.credentialId === credentialId)\n .map((row) => row.documentId);\n if (!documentIds.length) {\n throw new Error(`Credential not found: ${credentialId}`);\n }\n const revokedAt = new Date().toISOString();\n for (const documentId of documentIds) {\n await this.mutateDocument(\n documentId,\n [createAction(\"REVOKE\", { revokedAt, reason: null })],\n token,\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 {\n SwitchboardClient,\n type SwitchboardRequestFn,\n type SwitchboardSource,\n} 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 /** In-process Switchboard reader; wins over any URL and skips discovery. */\n switchboardRequest?: SwitchboardRequestFn;\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/** True when the credential's EIP-712 proof, on `chainId`, was signed by its\n * issuer address. Binding and expiry are the caller's to check. */\nexport async function verifyDelegationProof(\n credential: PowerhouseVerifiableCredential,\n chainId: number,\n): Promise<boolean> {\n const withDomain = withEip712Domain(credential, chainId);\n return (\n withDomain.proof.eip712.domain.chainId === chainId &&\n (await verifyCredentialSignature(withDomain))\n );\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 if (!(await verifyDelegationProof(credential, chainId))) {\n return undefined;\n }\n return withEip712Domain(credential, chainId);\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 switchboardRequest,\n discover = true,\n verifySignature = true,\n } = options;\n const explicitBaseUrl = options.baseUrl;\n const baseUrl = explicitBaseUrl ?? DEFAULT_RENOWN_URL;\n try {\n // A local reader or explicit switchboardUrl is used directly; otherwise\n // discover from the base URL unless the caller already resolved it.\n const source: SwitchboardSource | undefined =\n switchboardRequest ??\n (switchboardUrl\n ? switchboardUrl\n : discover && explicitBaseUrl\n ? await resolveSwitchboardEndpoint({ baseUrl })\n : undefined);\n\n const credential = source\n ? await new SwitchboardClient(source).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 /** In-process Switchboard reader; wins over any URL and skips discovery. */\n switchboardRequest?: SwitchboardRequestFn;\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 switchboardRequest: options.switchboardRequest,\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","import type { ActionSigner } from \"@powerhousedao/shared/document-model\";\nimport { DEFAULT_RENOWN_URL } from \"./constants.js\";\nimport { verifyDelegationProof } from \"./credential.js\";\nimport { SwitchboardClient, type SwitchboardSource } from \"./switchboard.js\";\nimport type { PowerhouseVerifiableCredential } from \"./types.js\";\n\ntype SignerUser = ActionSigner[\"user\"];\n\n/** A signer whose `app.key` and `user` are read on every ask. */\nexport interface RenownOwnSigner {\n readonly app?: { readonly key: string };\n readonly user?: SignerUser;\n}\n\nexport interface RenownTrustPolicyOptions {\n /** Serves the renown read model; without it, Renown's REST API is read. */\n switchboard?: SwitchboardSource;\n /** Renown base URL for the REST lookup. Defaults to DEFAULT_RENOWN_URL. */\n renownUrl?: string;\n /** This node's signer, read on every ask; its key signing as its current user is accepted without a lookup. Wins over `self`. */\n ownSigner?: RenownOwnSigner;\n /**\n * A snapshot of this node's key and user, for a pooled worker whose signer\n * cannot cross the thread boundary. Only matches the worker's own key.\n */\n self?: { key: string; user: SignerUser };\n /** How many acceptances are remembered. Defaults to 10000. */\n maxAccepted?: number;\n /** How long a refusal is remembered before asking again. Defaults to 60s. */\n refusalTtlMs?: number;\n}\n\n/** Structurally a reactor `SignatureTrustPolicy`. */\nexport interface RenownTrustPolicy {\n authorizeSigner(\n signer: ActionSigner,\n key: string,\n documentId: string,\n ): Promise<boolean>;\n}\n\nconst DEFAULT_MAX_ACCEPTED = 10_000;\nconst DEFAULT_REFUSAL_TTL_MS = 60_000;\n\n/**\n * Accepts a key the user's EIP-712 Renown credential delegates to, ignoring\n * expiry and revocation. Verdicts are cached per (address, key); this node's\n * own key is checked before the cache and never cached.\n */\nexport function createRenownTrustPolicy(\n options: RenownTrustPolicyOptions = {},\n): RenownTrustPolicy {\n const maxAccepted = options.maxAccepted ?? DEFAULT_MAX_ACCEPTED;\n const refusalTtlMs = options.refusalTtlMs ?? DEFAULT_REFUSAL_TTL_MS;\n const client = options.switchboard\n ? new SwitchboardClient(options.switchboard)\n : undefined;\n const renownUrl = options.renownUrl ?? DEFAULT_RENOWN_URL;\n\n const accepted = new Set<string>();\n const refusedUntil = new Map<string, number>();\n const pending = new Map<string, Promise<boolean>>();\n\n const issued = (\n user: SignerUser,\n key: string,\n ): Promise<PowerhouseVerifiableCredential[]> =>\n client\n ? client.getIssuedCredentials({\n address: user.address,\n chainId: user.chainId,\n appDid: key,\n })\n : fetchIssuedCredentialRest(user, key, renownUrl);\n\n async function lookup(user: SignerUser, key: string): Promise<boolean> {\n for (const credential of await issued(user, key)) {\n if (\n bindsTo(credential, user, key) &&\n (await verifyDelegationProof(credential, user.chainId))\n ) {\n return true;\n }\n }\n return false;\n }\n\n function remember(entry: string, verdict: boolean): void {\n if (verdict) {\n if (accepted.size >= maxAccepted) {\n const oldest = accepted.values().next().value;\n if (oldest !== undefined) accepted.delete(oldest);\n }\n accepted.add(entry);\n refusedUntil.delete(entry);\n } else {\n refusedUntil.set(entry, Date.now() + refusalTtlMs);\n }\n }\n\n return {\n authorizeSigner(signer, key) {\n const user = signer.user as SignerUser | undefined;\n const self = ownIdentity(options);\n if (self && isSelf(self, user, key)) {\n return Promise.resolve(true);\n }\n if (!user || !isLookupable(user, key)) {\n return Promise.resolve(false);\n }\n\n const entry = `${user.networkId}|${user.chainId}|${user.address.toLowerCase()}|${key}`;\n if (accepted.has(entry)) {\n return Promise.resolve(true);\n }\n const until = refusedUntil.get(entry);\n if (until !== undefined && until > Date.now()) {\n return Promise.resolve(false);\n }\n const inFlight = pending.get(entry);\n if (inFlight) {\n return inFlight;\n }\n\n const verdict = lookup(user, key).then(\n (result) => {\n pending.delete(entry);\n remember(entry, result);\n return result;\n },\n (error: unknown) => {\n pending.delete(entry);\n throw error;\n },\n );\n pending.set(entry, verdict);\n return verdict;\n },\n };\n}\n\nfunction ownIdentity(\n options: RenownTrustPolicyOptions,\n): RenownTrustPolicyOptions[\"self\"] {\n if (!options.ownSigner) {\n return options.self;\n }\n const { app, user } = options.ownSigner;\n return {\n key: app?.key ?? \"\",\n user: {\n address: user?.address ?? \"\",\n networkId: user?.networkId ?? \"\",\n chainId: user?.chainId ?? 0,\n },\n };\n}\n\nfunction isSelf(\n self: NonNullable<RenownTrustPolicyOptions[\"self\"]>,\n user: SignerUser | undefined,\n key: string,\n): boolean {\n return (\n self.key !== \"\" &&\n key === self.key &&\n (user?.address ?? \"\").toLowerCase() === self.user.address.toLowerCase() &&\n (user?.networkId ?? \"\") === self.user.networkId &&\n (user?.chainId ?? 0) === self.user.chainId\n );\n}\n\nfunction isLookupable(user: SignerUser, key: string): boolean {\n return (\n key.startsWith(\"did:key:\") &&\n /^0x[0-9a-fA-F]{40}$/.test(user.address) &&\n user.networkId !== \"\" &&\n Number.isInteger(user.chainId) &&\n user.chainId > 0\n );\n}\n\nfunction bindsTo(\n credential: PowerhouseVerifiableCredential,\n user: SignerUser,\n key: string,\n): boolean {\n const address = user.address.toLowerCase();\n const issuer = credential.issuer.id.split(\":\");\n if (issuer.length !== 5) return false;\n const [scheme, method, networkId, chainId, issuerAddress] = issuer;\n return (\n credential.credentialSubject.id === key &&\n scheme === \"did\" &&\n method === \"pkh\" &&\n networkId === user.networkId &&\n chainId === String(user.chainId) &&\n issuerAddress.toLowerCase() === address &&\n credential.issuer.ethereumAddress.toLowerCase() === address\n );\n}\n\n// Renown's REST endpoint answers with the active credential only.\nasync function fetchIssuedCredentialRest(\n user: SignerUser,\n key: string,\n renownUrl: string,\n): Promise<PowerhouseVerifiableCredential[]> {\n const url = new URL(\"/api/auth/credential\", renownUrl);\n url.searchParams.set(\"address\", user.address);\n url.searchParams.set(\"chainId\", String(user.chainId));\n url.searchParams.set(\"connectId\", key);\n url.searchParams.set(\"appId\", key);\n const response = await fetch(url, { method: \"GET\" });\n if (response.status === 404) {\n return [];\n }\n if (!response.ok) {\n throw new Error(`Renown credential lookup failed: ${response.status}`);\n }\n const { credential } = (await response.json()) as {\n credential?: PowerhouseVerifiableCredential | null;\n };\n return credential ? [credential] : [];\n}\n"],"mappings":";;;;;AAWA,MAAM,+BAA+B;AASrC,eAAsB,2BACpB,SAC6B;CAC7B,MAAM,EAAE,gBAAgB,SAAS,cAAc;CAE/C,IAAI,gBACF,OAAO;CAGT,IAAI,CAAC,SACH;CAGF,MAAM,aAAa,IAAI,gBAAgB;CACvC,MAAM,UAAU,iBACR,WAAW,MAAM,GACvB,aAAa,4BACf;CAEA,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,oBAAoB,OAAO;EAC/C,MAAM,WAAW,MAAM,MAAM,KAAK;GAChC,QAAQ;GACR,QAAQ,WAAW;EACrB,CAAC;EACD,IAAI,CAAC,SAAS,IACZ;EAGF,QAAO,MADa,SAAS,KAAK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AAW,MAAM,MAAM,KAAK,EAAE,QAAQ,MAAM,CAAC;CACnD,IAAI,SAAS,WAAW,KACtB,OAAO,CAAC;CAEV,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,oCAAoC,SAAS,QAAQ;CAEvE,MAAM,EAAE,eAAgB,MAAM,SAAS,KAAK;CAG5C,OAAO,aAAa,CAAC,UAAU,IAAI,CAAC;AACtC"}
|
package/dist/trust.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as createRenownTrustPolicy, n as RenownTrustPolicy, o as resolveSwitchboardEndpoint, r as RenownTrustPolicyOptions, t as RenownOwnSigner } from "./signer-trust-
|
|
1
|
+
import { i as createRenownTrustPolicy, n as RenownTrustPolicy, o as resolveSwitchboardEndpoint, r as RenownTrustPolicyOptions, t as RenownOwnSigner } from "./signer-trust-FmbMTn39.js";
|
|
2
2
|
export { RenownOwnSigner, RenownTrustPolicy, RenownTrustPolicyOptions, createRenownTrustPolicy, resolveSwitchboardEndpoint };
|
|
3
3
|
export {};
|
package/dist/trust.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createRenownTrustPolicy, u as resolveSwitchboardEndpoint } from "./signer-trust-
|
|
1
|
+
import { t as createRenownTrustPolicy, u as resolveSwitchboardEndpoint } from "./signer-trust-H1rNzUcd.js";
|
|
2
2
|
export { createRenownTrustPolicy, resolveSwitchboardEndpoint };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { at as SignCredentialTypedData } from "./types-
|
|
1
|
+
import { at as SignCredentialTypedData } from "./types-Ceiz2dkk.js";
|
|
2
2
|
import { ComponentType, ReactNode } from "react";
|
|
3
3
|
//#region src/wallet/types.d.ts
|
|
4
4
|
declare const LoginMethod: {
|
|
@@ -56,4 +56,4 @@ type WalletAdapterProvider<Config = unknown> = (config: Config) => WalletAdapter
|
|
|
56
56
|
//#endregion
|
|
57
57
|
export { WalletAdapterImpl as a, WalletController as c, WalletThemeColors as d, normalizeWalletTheme as f, WalletAdapterFactory as i, WalletSession as l, WalletAdapter as n, WalletAdapterMeta as o, WalletAdapterDescriptor as r, WalletAdapterProvider as s, LoginMethod as t, WalletTheme as u };
|
|
58
58
|
export {};
|
|
59
|
-
//# sourceMappingURL=types-
|
|
59
|
+
//# sourceMappingURL=types-7xgrEnx7.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-7xgrEnx7.d.ts","names":[],"sources":["../src/wallet/types.ts"],"mappings":";;;cAKa;WACX;WACA;WACA;WACA;;KAGU,sBAAsB,0BAA0B;UAI3C;EACf;EACA;;KAIU;EAGL;IAA2B;iBAGlB,qBAAqB,OAAO;EAC1C;EACA;EACA;;UAYe;EACf;EACA;EACA,eAAe;EAGf;;UAIe;EACf,QAAQ,SAAS,cAAc,QAAQ;EACvC,cAAc;EACd,cAAc;EAGd,WACE,WAAW,SAAS;;UAMP;EACf;EAGA;EAGA,kBAAkB;;UAIH;EAGf,UAAU;IAAgB,UAAU;IAAW,QAAQ;;EAEvD,qBAAqB;;UAIN,sBAAsB;EACrC,MAAM;;UAKS;EACf,MAAM;EACN,YAAY,QAAQ;;KAGV,qBAAqB,qBAC/B,QAAQ,WACL;KAEO,sBAAsB,qBAChC,QAAQ,WACL"}
|
|
@@ -125,9 +125,23 @@ declare class MissingSwitchboardError extends Error {
|
|
|
125
125
|
/** `instanceof` fails across duplicate SDK copies, so match by name too. */
|
|
126
126
|
static is(error: unknown): error is MissingSwitchboardError;
|
|
127
127
|
}
|
|
128
|
+
/** How a caller authorizes a Renown write: a login (bearer) token for the
|
|
129
|
+
* address, or that address's `personal_sign` over the canonical message
|
|
130
|
+
* (`revokeMessage` / `profileMessage`) with the ISO-8601 timestamp it signed. */
|
|
131
|
+
type RenownWriteAuth = {
|
|
132
|
+
token: string;
|
|
133
|
+
} | {
|
|
134
|
+
signature: string;
|
|
135
|
+
timestamp: string;
|
|
136
|
+
};
|
|
137
|
+
/** Per-request options: `token` is a Renown bearer token that authenticates
|
|
138
|
+
* the request (sent as `Authorization: Bearer <token>` over HTTP). */
|
|
139
|
+
interface SwitchboardRequestOptions {
|
|
140
|
+
token?: string;
|
|
141
|
+
}
|
|
128
142
|
/** Runs a GraphQL document against a Switchboard and resolves its `data`;
|
|
129
143
|
* throws on transport or GraphQL errors. */
|
|
130
|
-
type SwitchboardRequestFn = (query: string, variables: Record<string, unknown
|
|
144
|
+
type SwitchboardRequestFn = (query: string, variables: Record<string, unknown>, options?: SwitchboardRequestOptions) => Promise<unknown>;
|
|
131
145
|
/** Where a SwitchboardClient reads from: an HTTP endpoint or a local executor. */
|
|
132
146
|
type SwitchboardSource = string | SwitchboardRequestFn;
|
|
133
147
|
declare class SwitchboardClient {
|
|
@@ -146,14 +160,14 @@ declare class SwitchboardClient {
|
|
|
146
160
|
appDid: string;
|
|
147
161
|
}): Promise<PowerhouseVerifiableCredential[]>;
|
|
148
162
|
getProfileByAddress(address: string): Promise<RenownProfile | undefined>;
|
|
149
|
-
createEmptyDocument(documentType: string, parentIdentifier?: string): Promise<string>;
|
|
150
|
-
mutateDocument(documentIdentifier: string, actions: Action[]): Promise<string>;
|
|
163
|
+
createEmptyDocument(documentType: string, parentIdentifier?: string, token?: string): Promise<string>;
|
|
164
|
+
mutateDocument(documentIdentifier: string, actions: Action[], token?: string): Promise<string>;
|
|
151
165
|
issueCredential(credential: PowerhouseVerifiableCredential, parentIdentifier?: string): Promise<string>;
|
|
152
|
-
|
|
166
|
+
upsertUserProfile(address: string, profile: {
|
|
153
167
|
username?: string;
|
|
154
168
|
userImage?: string;
|
|
155
|
-
}): Promise<string>;
|
|
156
|
-
revokeCredential(
|
|
169
|
+
}, auth: RenownWriteAuth): Promise<string>;
|
|
170
|
+
revokeCredential(credentialId: string, auth: RenownWriteAuth): Promise<void>;
|
|
157
171
|
profileFetcher: ProfileFetcher;
|
|
158
172
|
}
|
|
159
173
|
//#endregion
|
|
@@ -608,6 +622,6 @@ interface IRenownCrypto {
|
|
|
608
622
|
*/
|
|
609
623
|
interface IConnectCrypto extends IRenownCrypto {}
|
|
610
624
|
//#endregion
|
|
611
|
-
export { MemoryStorage as $, LoginStatus as A, Service as B, InternalUser as C,
|
|
625
|
+
export { MemoryStorage as $, LoginStatus as A, VERIFIABLE_CREDENTIAL_EIP712_TYPE as At, Service as B, InternalUser as C, DEFAULT_RENOWN_CHAIN_ID as Ct, JWTVerifyPolicies as D, ISSUER_TYPE as Dt, JWTVerified as E, DOMAIN_TYPE as Et, RenownEventEmitter as F, User$1 as G, SignInParams as H, RenownEvents as I, VerificationMethod as J, UserActionSigner$1 as K, RenownProfile as L, PowerhouseVerifiableCredential as M, ProfileFetcher as N, JsonWebKey$1 as O, RENOWN_READ_MODEL_SUBGRAPH as Ot, Proof as P, BaseStorage as Q, RenownStorage as R, IVerifiableCredential as S, CREDENTIAL_TYPES as St, JWTPayload as T, DEFAULT_RENOWN_URL as Tt, Signer as U, ServiceEndpoint as V, Unsubscribe as W, VerifiedJWT as X, VerifiedCredential as Y, W3CCredential as Z, IPowerhouseCredentialSubject as _, SwitchboardRequestFn as _t, JwkKeyPair as a, SignCredentialTypedData as at, IRenown as b, CREDENTIAL_SCHEMA_EIP712_TYPE as bt, ConditionWeightedThreshold as c, buildAndSignCredential as ct, DIDDocument as d, verifyAuthCredential as dt, IEventEmitter as et, DIDDocumentMetadata as f, verifyCredentialSignature as ft, IAuthCredentialSubject as g, SwitchboardClient as gt, EcdsaSignature as h, RenownWriteAuth as ht, JsonWebKeyPairStorage as i, FetchDelegationCredentialOptions as it, PKHDid as j, KeyCapabilitySection as k, RENOWN_SESSION_COOKIE as kt, CreateBearerTokenOptions as l, fetchDelegationCredential as lt, DIDResolutionResult as m, MissingSwitchboardError as mt, IConnectCrypto as n, CredentialDomain as nt, AuthVerifiableCredential as o, VerifiedAuthCredential as ot, DIDResolutionMetadata as p, verifyDelegationProof as pt, Verifiable as q, IRenownCrypto as r, CredentialMessage as rt, AuthVerifiedCredential as s, VerifyAuthCredentialOptions as st, DID as t, BuildCredentialParams as tt, CredentialStatus as u, recoverCredentialSigner as ut, IPowerhouseIssuerType as v, SwitchboardRequestOptions as vt, Issuer as w, DEFAULT_RENOWN_NETWORK_ID as wt, ISigner$1 as x, CREDENTIAL_SUBJECT_TYPE as xt, IProof as y, SwitchboardSource as yt, RenownStorageMap as z };
|
|
612
626
|
export {};
|
|
613
|
-
//# sourceMappingURL=types-
|
|
627
|
+
//# sourceMappingURL=types-Ceiz2dkk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-Ceiz2dkk.d.ts","names":[],"sources":["../src/constants.ts","../src/switchboard.ts","../src/credential.ts","../src/event/types.ts","../src/storage/common.ts","../src/types.ts","../src/crypto/types.ts"],"mappings":";;cAAa;cACA;cACA;;cAGA;;;cAIA;cAEA;WACT;WAAiB;;WACjB;WAAiB;;cAGR;WACT;WAAkB;;WAClB;WAAc;;WACd;WAAY;;WACZ;WAAgB;;WAChB;WAA2B;;WAC3B;WAA0B;;WAC1B;WAAsB;;WACtB;WAAwB;;cAGf;WACT;WAAY;;WACZ;WAAc;;cAGL;WACT;WAAa;;WACb;WAAY;;cAGH;WACT;WAAY;;WACZ;WAAyB;;cAGhB;WACX;aA/BQ;aAAiB;;aACjB;aAAiB;;WA+BzB;aA3BQ;aAAkB;;aAClB;aAAc;;aACd;aAAY;;aACZ;aAAgB;;aAChB;aAA2B;;aAC3B;aAA0B;;aAC1B;aAAsB;;aACtB;aAAwB;;WAqBhC;aAjBQ;aAAY;;aACZ;aAAc;;WAiBtB;aAbQ;aAAa;;aACb;aAAY;;WAapB;aATQ;aAAY;;aACZ;aAAyB;;;;;;;cC1BtB,gCAAgC;EAC3C;;SAQO,GAAG,iBAAiB,SAAS;;;;;KAoM1B;EACN;;EACA;EAAmB;;;;UAuIR;EACf;;;;KAKU,wBACV,eACA,WAAW,yBACX,UAAU,8BACP;;KAGO,6BAA6B;cAI5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AAY;;UAGG;EACf,eAAe,QAAQ;EACvB,YAAY,SAAS,aAAa;EAClC,iBAAiB;;KAGP;UAEK;EACf,KAAK;;EAEL;EACA,WAAW;EACX,aAAa;EACb,OAAO,MAAM,eAAe,QAAQ;EACpC,SAAS,MAAM,YAAY,WAAW,eAAe;EACrD,QAAQ;EACR,iBACE,6BACA,UAAU,6BACP;;;;;UAMU,uBAAuB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as WalletController, l as WalletSession, o as WalletAdapterMeta, t as LoginMethod } from "./types-
|
|
1
|
+
import { c as WalletController, l as WalletSession, o as WalletAdapterMeta, t as LoginMethod } from "./types-7xgrEnx7.js";
|
|
2
2
|
//#region src/wallet/privy/meta.d.ts
|
|
3
3
|
/** Structural subset of viem's `Chain`, so any `viem/chains` / `wagmi/chains` export fits regardless of the host's viem version. */
|
|
4
4
|
interface PrivyChain {
|
|
@@ -60,4 +60,4 @@ interface PrivyWalletController extends WalletController {
|
|
|
60
60
|
//#endregion
|
|
61
61
|
export { DEFAULT_PRIVY_METHODS as a, PrivyLoginMethod as c, SendCodeOptions as i, privyAdapterMeta as l, PrivyEmailStatus as n, PHRenownPrivyAdapterConfig as o, PrivyWalletController as r, PrivyChain as s, PrivyAuthState as t, resolvePrivyMethods as u };
|
|
62
62
|
export {};
|
|
63
|
-
//# sourceMappingURL=types-
|
|
63
|
+
//# sourceMappingURL=types-DRnq2URw.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-DRnq2URw.d.ts","names":[],"sources":["../src/wallet/privy/meta.ts","../src/wallet/privy/types.ts"],"mappings":";;;UAGiB;EACf;EACA;EACA;IAAkB;IAAc;IAAgB;;EAChD;IAAW;MAAW;;;;KAKZ;cAUC,uBAAuB;UAMnB;EACf;EACA;;EAEA,UAAU;;EAEV,QAAQ;;EAER;;iBAKc,oBAAoB,qBAAqB;cAe5C,kBAAkB,KAAK;;;;KClDxB;;UASK;;EAEf;;EAEA;;EAEA;EACA,aAAa;EACb,aAAa;;UAGE;;EAEf;;;UAIe,8BAA8B;;EAE7C,SAAS,eAAe,UAAU,kBAAkB;;EAEpD,cAAc,eAAe,QAAQ;EACrC,YAAY;EACZ,eAAe,WAAW,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as MemoryStorage, A as LoginStatus, C as InternalUser, F as RenownEventEmitter, G as User, H as SignInParams, I as RenownEvents, N as ProfileFetcher, R as RenownStorage, Y as VerifiedCredential,
|
|
2
|
-
import "./index-
|
|
1
|
+
import { $ as MemoryStorage, A as LoginStatus, C as InternalUser, F as RenownEventEmitter, G as User, H as SignInParams, I as RenownEvents, N as ProfileFetcher, R as RenownStorage, Y as VerifiedCredential, _t as SwitchboardRequestFn, b as IRenown, gt as SwitchboardClient, i as JsonWebKeyPairStorage, j as PKHDid, l as CreateBearerTokenOptions, r as IRenownCrypto, s as AuthVerifiedCredential, w as Issuer, x as ISigner, z as RenownStorageMap } from "./types-Ceiz2dkk.js";
|
|
2
|
+
import "./index-DbiBjqs6.js";
|
|
3
3
|
import { Resolver } from "did-resolver";
|
|
4
4
|
//#region src/common.d.ts
|
|
5
5
|
declare class RenownMemoryStorage extends MemoryStorage<RenownStorageMap> {}
|
|
@@ -114,6 +114,20 @@ declare function createLocalCredentialVerifier(execute: SwitchboardRequestFn, op
|
|
|
114
114
|
//#region src/profile.d.ts
|
|
115
115
|
declare const fetchRenownProfile: ProfileFetcher;
|
|
116
116
|
//#endregion
|
|
117
|
+
//#region src/signed-message.d.ts
|
|
118
|
+
declare const SIGNATURE_WINDOW_MS = 600000;
|
|
119
|
+
/** Canonical message a caller signs to authorize revoking `credentialId`. */
|
|
120
|
+
declare function revokeMessage(credentialId: string, timestamp: string): string;
|
|
121
|
+
/**
|
|
122
|
+
* Canonical message a caller signs to authorize a profile upsert. The payload
|
|
123
|
+
* is hashed (rather than embedded raw) so the signed message has a fixed
|
|
124
|
+
* shape regardless of field content.
|
|
125
|
+
*/
|
|
126
|
+
declare function profileMessage(address: string, profile: {
|
|
127
|
+
username?: string | null;
|
|
128
|
+
userImage?: string | null;
|
|
129
|
+
}, timestamp: string): Promise<string>;
|
|
130
|
+
//#endregion
|
|
117
131
|
//#region src/session.d.ts
|
|
118
132
|
/** Server-side view of an authenticated Renown session. */
|
|
119
133
|
interface RenownSession {
|
|
@@ -189,6 +203,6 @@ declare function assertIsAuthCredential(credential: VerifiedCredential): asserts
|
|
|
189
203
|
declare function createAuthBearerToken(chainId: number, networkId: string, address: string, issuer: Issuer, options?: CreateBearerTokenOptions): Promise<string>;
|
|
190
204
|
declare const getResolver: () => Resolver;
|
|
191
205
|
//#endregion
|
|
192
|
-
export {
|
|
206
|
+
export { BaseRenownBuilder as C, RenownMemoryStorage as E, createLocalCredentialVerifier as S, Renown as T, profileMessage as _, getResolver as a, CredentialCheck as b, RenownSession as c, RenownSessionProfile as d, VerifyRenownSessionOptions as f, SIGNATURE_WINDOW_MS as g, verifyRenownSession as h, createAuthBearerToken as i, RenownSessionClaims as l, serializeRenownSessionCookie as m, VerifyAuthBearerTokenOptions as n, parsePkhDid as o, readSessionClaims as p, assertIsAuthCredential as r, verifyAuthBearerToken as s, ILogger as t, RenownSessionCookie as u, revokeMessage as v, RenownBuilderOptions as w, LocalCredentialVerifierOptions as x, fetchRenownProfile as y };
|
|
193
207
|
export {};
|
|
194
|
-
//# sourceMappingURL=utils-
|
|
208
|
+
//# sourceMappingURL=utils-DkVxP7Ug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-DkVxP7Ug.d.ts","names":[],"sources":["../src/common.ts","../src/renown-builder.ts","../src/local-credential-verifier.ts","../src/profile.ts","../src/signed-message.ts","../src/session.ts","../src/utils.ts"],"mappings":";;;;cAoCa,4BAA4B,cAAc;cA8B1C,kBAAkB;;EAY7B,YACE,OAAO,eACP,cAAc,oBACd,QAAQ,eACR,iBACA,kBACA,iBAAiB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C3B,OAAO,oBAAoB;EAC3B,QAAQ,oBAAoB;;;;;;;;iBASd,YAAY,cAAc;UAuBzB;;;;;EAKf;;iBAGoB,sBACpB,aACA,UAAU,+BACT,gBAAgB;iBA2BH,uBACd,YAAY,6BACH,cAAc;iBAoBH,sBACpB,iBACA,mBACA,iBACA,QAAQ,QACR,UAAU,2BAAwB;cAsBvB,mBAAW"}
|
package/dist/wallet/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as WalletAdapterImpl, c as WalletController, d as WalletThemeColors, f as normalizeWalletTheme, i as WalletAdapterFactory, l as WalletSession, n as WalletAdapter, o as WalletAdapterMeta, r as WalletAdapterDescriptor, s as WalletAdapterProvider, t as LoginMethod, u as WalletTheme } from "../types-
|
|
1
|
+
import { a as WalletAdapterImpl, c as WalletController, d as WalletThemeColors, f as normalizeWalletTheme, i as WalletAdapterFactory, l as WalletSession, n as WalletAdapter, o as WalletAdapterMeta, r as WalletAdapterDescriptor, s as WalletAdapterProvider, t as LoginMethod, u as WalletTheme } from "../types-7xgrEnx7.js";
|
|
2
2
|
//#region src/wallet/controller.d.ts
|
|
3
3
|
export declare function isWalletRedirectReturn(search: string, metas: WalletAdapterMeta[]): boolean;
|
|
4
4
|
export declare function resolveAdapters(descriptors: WalletAdapterDescriptor[] | undefined): Promise<WalletAdapter[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as WalletAdapterImpl } from "../../types-
|
|
2
|
-
import { r as PHRenownMockAdapterConfig } from "../../meta-
|
|
1
|
+
import { a as WalletAdapterImpl } from "../../types-7xgrEnx7.js";
|
|
2
|
+
import { r as PHRenownMockAdapterConfig } from "../../meta-Dpmn2Ywp.js";
|
|
3
3
|
//#region src/wallet/mock/factory.d.ts
|
|
4
4
|
/** Headless test/dev wallet adapter: `connect()` resolves immediately with a session backed by a viem local account (real EIP-712 signatures, no wallet UI or OAuth). **TEST/DEV ONLY; never enable in production** — it signs with a known key. See the reactor-browser README "Testing" and the Academy Renown auth guide. */
|
|
5
5
|
export declare function createMockAdapter(config: PHRenownMockAdapterConfig): WalletAdapterImpl;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as WalletAdapterDescriptor } from "../../types-
|
|
2
|
-
import { a as resolveMockMethods, i as mockAdapterMeta, n as MockLoginMethod, r as PHRenownMockAdapterConfig, t as DEFAULT_MOCK_METHODS } from "../../meta-
|
|
1
|
+
import { r as WalletAdapterDescriptor } from "../../types-7xgrEnx7.js";
|
|
2
|
+
import { a as resolveMockMethods, i as mockAdapterMeta, n as MockLoginMethod, r as PHRenownMockAdapterConfig, t as DEFAULT_MOCK_METHODS } from "../../meta-Dpmn2Ywp.js";
|
|
3
3
|
//#region src/wallet/mock/index.d.ts
|
|
4
4
|
/** Headless test/dev wallet adapter for `RenownWalletProvider`: signs real EIP-712 credentials with a local viem account, no wallet UI or OAuth, so e2e sign-in is deterministic. **TEST/DEV ONLY; never enable in production** — it signs with a known key. Needs only `viem`, which `@renown/sdk` already depends on. */
|
|
5
5
|
export declare function mockAdapter(config: PHRenownMockAdapterConfig): WalletAdapterDescriptor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { at as SignCredentialTypedData } from "../../types-
|
|
2
|
-
import { a as WalletAdapterImpl, l as WalletSession, t as LoginMethod, u as WalletTheme } from "../../types-
|
|
3
|
-
import { i as SendCodeOptions, n as PrivyEmailStatus, o as PHRenownPrivyAdapterConfig, r as PrivyWalletController, s as PrivyChain, t as PrivyAuthState } from "../../types-
|
|
1
|
+
import { at as SignCredentialTypedData } from "../../types-Ceiz2dkk.js";
|
|
2
|
+
import { a as WalletAdapterImpl, l as WalletSession, t as LoginMethod, u as WalletTheme } from "../../types-7xgrEnx7.js";
|
|
3
|
+
import { i as SendCodeOptions, n as PrivyEmailStatus, o as PHRenownPrivyAdapterConfig, r as PrivyWalletController, s as PrivyChain, t as PrivyAuthState } from "../../types-DRnq2URw.js";
|
|
4
4
|
import { ComponentType, ReactNode } from "react";
|
|
5
5
|
import { ConnectedWallet, LoginModalOptions } from "@privy-io/react-auth";
|
|
6
6
|
//#region src/wallet/privy/adapter.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as WalletAdapterDescriptor } from "../../types-
|
|
2
|
-
import { a as DEFAULT_PRIVY_METHODS, c as PrivyLoginMethod, i as SendCodeOptions, l as privyAdapterMeta, n as PrivyEmailStatus, o as PHRenownPrivyAdapterConfig, r as PrivyWalletController, s as PrivyChain, t as PrivyAuthState, u as resolvePrivyMethods } from "../../types-
|
|
1
|
+
import { r as WalletAdapterDescriptor } from "../../types-7xgrEnx7.js";
|
|
2
|
+
import { a as DEFAULT_PRIVY_METHODS, c as PrivyLoginMethod, i as SendCodeOptions, l as privyAdapterMeta, n as PrivyEmailStatus, o as PHRenownPrivyAdapterConfig, r as PrivyWalletController, s as PrivyChain, t as PrivyAuthState, u as resolvePrivyMethods } from "../../types-DRnq2URw.js";
|
|
3
3
|
//#region src/wallet/privy/index.d.ts
|
|
4
4
|
/** Privy wallet adapter (embedded wallets plus social / email login) for `RenownWalletProvider`. Importing this module loads no wallet library — `@privy-io/react-auth` is fetched by `load()` on the first login click — but it does make that package a build-time requirement, so install it alongside this import. */
|
|
5
5
|
export declare function privyAdapter(config: PHRenownPrivyAdapterConfig): WalletAdapterDescriptor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as WalletAdapterImpl } from "../../types-
|
|
2
|
-
import { n as PHRenownRainbowAdapterConfig } from "../../meta-
|
|
1
|
+
import { a as WalletAdapterImpl } from "../../types-7xgrEnx7.js";
|
|
2
|
+
import { n as PHRenownRainbowAdapterConfig } from "../../meta-qadFdiX7.js";
|
|
3
3
|
import "@rainbow-me/rainbowkit/styles.css";
|
|
4
4
|
//#region src/wallet/rainbow/factory.d.ts
|
|
5
5
|
export declare function createRainbowAdapter(config: PHRenownRainbowAdapterConfig): WalletAdapterImpl;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as WalletAdapterDescriptor } from "../../types-
|
|
2
|
-
import { i as rainbowAdapterMeta, n as PHRenownRainbowAdapterConfig, r as RAINBOW_METHODS, t as PHRenownChain } from "../../meta-
|
|
1
|
+
import { r as WalletAdapterDescriptor } from "../../types-7xgrEnx7.js";
|
|
2
|
+
import { i as rainbowAdapterMeta, n as PHRenownRainbowAdapterConfig, r as RAINBOW_METHODS, t as PHRenownChain } from "../../meta-qadFdiX7.js";
|
|
3
3
|
//#region src/wallet/rainbow/index.d.ts
|
|
4
4
|
/** RainbowKit + wagmi wallet adapter (external / injected wallets) for `RenownWalletProvider`. Importing this module loads no wallet library — `@rainbow-me/rainbowkit`, `wagmi` and `@tanstack/react-query` are fetched by `load()` on the first login click — but it does make them build-time requirements, so install them alongside this import. Pass `ssr: true` on server-rendered hosts. */
|
|
5
5
|
export declare function rainbowAdapter(config: PHRenownRainbowAdapterConfig): WalletAdapterDescriptor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renown/sdk",
|
|
3
|
-
"version": "6.2.3-dev.
|
|
3
|
+
"version": "6.2.3-dev.28",
|
|
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,
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"@didtools/key-webcrypto": "^0.2.0",
|
|
109
|
-
"@powerhousedao/shared": "6.2.3-dev.
|
|
109
|
+
"@powerhousedao/shared": "6.2.3-dev.28",
|
|
110
110
|
"did-jwt-vc": "^4.0.12",
|
|
111
111
|
"did-resolver": "^4.1.0",
|
|
112
112
|
"key-did-resolver": "^4.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-credential-verifier-BC4HS01T.js","names":[],"sources":["../src/storage/common.ts","../src/common.ts","../src/event/memory.ts","../src/profile.ts","../src/renown-builder.ts","../src/local-credential-verifier.ts"],"sourcesContent":["export interface IStorage<\n T extends Record<string, unknown> = Record<string, unknown>,\n Key extends keyof T = keyof T,\n> {\n get(key: Key): T[Key] | undefined;\n set(key: Key, value?: T[Key]): void;\n delete(key: Key): void;\n}\n\nexport abstract class BaseStorage<\n T extends Record<string, unknown> = Record<string, unknown>,\n Key extends keyof T = keyof T,\n> implements IStorage<T> {\n abstract get(key: Key): T[Key] | undefined;\n abstract set(key: Key, value?: T[Key]): void;\n abstract delete(key: Key): void;\n}\n\nexport class MemoryStorage<\n T extends Record<string, unknown> = Record<string, unknown>,\n Key extends keyof T = keyof T,\n> extends BaseStorage<T> {\n private readonly data = new Map<Key, T[Key]>();\n\n get(key: Key) {\n return this.data.get(key);\n }\n\n set(key: Key, value?: T[Key]): void {\n if (value === undefined) {\n this.data.delete(key);\n } else {\n this.data.set(key, value);\n }\n }\n\n delete(key: Key): void {\n this.data.delete(key);\n }\n}\n","import {\n CREDENTIAL_TYPES,\n DEFAULT_RENOWN_CHAIN_ID,\n DEFAULT_RENOWN_NETWORK_ID,\n DEFAULT_RENOWN_URL,\n} from \"./constants.js\";\nimport {\n buildAndSignCredential,\n verifyCredentialSignature,\n} from \"./credential.js\";\nimport { RenownCryptoSigner, type IRenownCrypto } from \"./crypto/index.js\";\nimport { MemoryStorage } from \"./storage/common.js\";\nimport {\n MissingSwitchboardError,\n type SwitchboardClient,\n} from \"./switchboard.js\";\nimport type {\n CreateBearerTokenOptions,\n IProof,\n IRenown,\n ISigner,\n LoginStatus,\n PKHDid,\n PowerhouseVerifiableCredential,\n ProfileFetcher,\n RenownEventEmitter,\n RenownEvents,\n RenownStorage,\n RenownStorageMap,\n SignInParams,\n User,\n UserActionSigner,\n} from \"./types.js\";\nimport { parsePkhDid, verifyAuthBearerToken } from \"./utils.js\";\nexport * from \"./constants.js\";\n\nexport class RenownMemoryStorage extends MemoryStorage<RenownStorageMap> {}\n\n/**\n * The acting identity an action's signature carries.\n *\n * `User` here is the whole session record — it also holds the DID, the\n * credential, the fetched profile and ENS info — while `UserActionSigner` is\n * what travels on a signed action, and it is deliberately just an address on a\n * chain. The reactor's `ReactorSignerUserInput` declares exactly these three\n * fields, and a GraphQL input object refuses a field it does not declare by\n * rejecting the WHOLE request, so handing the session record to the signer\n * makes every signed push fail before it reaches the reactor.\n *\n * Narrowed here rather than at the transport, because the session record has no\n * business being on an operation in the first place: it is stored on every\n * operation a local reactor writes, not only on the ones that go over a wire.\n *\n * The compiler cannot catch the difference — excess-property checks apply to\n * fresh object literals, never to a variable of a wider type — which is why\n * this is a function rather than a type annotation.\n */\nfunction toActionSigner(user: User | undefined): UserActionSigner | undefined {\n if (!user) return undefined;\n return {\n address: user.address,\n networkId: user.networkId,\n chainId: user.chainId,\n };\n}\n\nexport class Renown implements IRenown {\n #baseUrl: string;\n #store: RenownStorage;\n #eventEmitter: RenownEventEmitter;\n #appName: string;\n #crypto: IRenownCrypto;\n #signer: ISigner;\n #profileFetcher?: ProfileFetcher;\n #switchboard?: SwitchboardClient;\n #chainId: number;\n #status: LoginStatus = \"initial\";\n\n constructor(\n store: RenownStorage,\n eventEmitter: RenownEventEmitter,\n crypto: IRenownCrypto,\n appName: string,\n baseUrl = DEFAULT_RENOWN_URL,\n profileFetcher?: ProfileFetcher,\n switchboard?: SwitchboardClient,\n chainId = Number(DEFAULT_RENOWN_CHAIN_ID),\n ) {\n this.#store = store;\n this.#eventEmitter = eventEmitter;\n this.#baseUrl = baseUrl;\n this.#crypto = crypto;\n this.#appName = appName;\n this.#profileFetcher = profileFetcher;\n this.#switchboard = switchboard;\n this.#chainId = chainId;\n const restoredUser = this.user;\n this.#signer = new RenownCryptoSigner(\n crypto,\n this.#appName,\n toActionSigner(restoredUser),\n );\n\n // A restored, previously-verified user is an authorized session; otherwise\n // status stays \"initial\" after a reload while the user is present.\n if (restoredUser) {\n this.#status = \"authorized\";\n }\n\n this.on(\"user\", (user) => {\n this.#signer.user = toActionSigner(user);\n });\n }\n\n get baseUrl() {\n return this.#baseUrl;\n }\n\n /** Chain id this app issues credentials on; a session from another chain is rejected by {@link signIn}. */\n get chainId() {\n return this.#chainId;\n }\n\n get user() {\n return this.#store.get(\"user\");\n }\n\n get status() {\n return this.#status;\n }\n\n get signer() {\n return this.#signer;\n }\n\n get crypto() {\n return this.#crypto;\n }\n\n get did() {\n return this.#crypto.did;\n }\n\n get profileFetcher() {\n return this.#profileFetcher;\n }\n\n #updateStatus(status: LoginStatus) {\n this.#status = status;\n this.#eventEmitter.emit(\"status\", status);\n }\n\n #updateUser(user: User | undefined) {\n if (user) {\n this.#store.set(\"user\", user);\n } else {\n this.#store.delete(\"user\");\n }\n this.#eventEmitter.emit(\"user\", user);\n }\n\n async login(userDid: string): Promise<User> {\n this.#updateStatus(\"checking\");\n try {\n const result = parsePkhDid(userDid);\n const credential = await this.#getCredential(\n result.address,\n result.chainId,\n this.#crypto.did,\n );\n\n if (!credential) {\n this.#updateUser(undefined);\n throw new Error(\"Credential not found\");\n }\n\n return await this.#completeLogin(userDid, result, credential);\n } catch (error) {\n this.#updateUser(undefined);\n this.#updateStatus(\"not-authorized\");\n throw error;\n }\n }\n\n // Sign in without the Renown redirect: build + sign a delegation credential\n // with the caller's wallet signer, write it to the switchboard, then log in.\n async signIn(params: SignInParams): Promise<User> {\n if (!this.#switchboard) throw new MissingSwitchboardError();\n const {\n address,\n chainId,\n signTypedData,\n username,\n userImage,\n expiresInDays,\n } = params;\n\n // The chain id goes into the issuer DID and the EIP-712 domain, so signing on\n // another chain would mint a second identity for the same wallet.\n if (chainId !== this.#chainId) {\n throw new Error(\n `Renown signIn: wallet is on chain ${chainId}, but this app issues credentials on chain ${this.#chainId}. Switch networks and retry — signing here would create a separate identity for the same address.`,\n );\n }\n\n this.#updateStatus(\"checking\");\n try {\n const credential = await buildAndSignCredential({\n signTypedData,\n address,\n chainId,\n app: this.#appName,\n appId: this.did,\n expiresInDays,\n });\n\n await this.#switchboard.issueCredential(credential);\n await this.#switchboard.findOrCreateUser(address, {\n username,\n userImage,\n });\n\n const userDid = `did:pkh:${DEFAULT_RENOWN_NETWORK_ID}:${chainId}:${address.toLowerCase()}`;\n // Authenticate from the freshly signed credential — no read-back, which\n // avoids racing the read-model processor that indexes the write.\n return await this.#completeLogin(\n userDid,\n parsePkhDid(userDid),\n credential,\n );\n } catch (error) {\n this.#updateUser(undefined);\n this.#updateStatus(\"not-authorized\");\n throw error;\n }\n }\n\n // Verify a credential binds to userDid + this app key, set the user, and\n // start the background profile fetch. Throws if the credential is invalid.\n async #completeLogin(\n userDid: string,\n result: PKHDid,\n credential: PowerhouseVerifiableCredential,\n ): Promise<User> {\n if (\n !(\n credential.issuer.id === userDid &&\n credential.credentialSubject.id === this.did\n )\n ) {\n throw new Error(\"Invalid credential\");\n }\n\n // The API may return proof.eip712 without domain/types; the domain is\n // canonical (version \"1\", the chainId), so reconstruct it before verifying.\n const eip712 = credential.proof.eip712 as\n | Partial<IProof[\"eip712\"]>\n | undefined;\n const verifiableCredential: PowerhouseVerifiableCredential = eip712?.domain\n ? credential\n : {\n ...credential,\n proof: {\n ...credential.proof,\n eip712: {\n domain: { version: \"1\", chainId: result.chainId },\n types: CREDENTIAL_TYPES,\n primaryType: \"VerifiableCredential\",\n },\n },\n };\n\n // Verify the EIP-712 proof was signed by the DID's address on its chain.\n if (\n credential.issuer.ethereumAddress.toLowerCase() !==\n result.address.toLowerCase() ||\n verifiableCredential.proof.eip712.domain.chainId !== result.chainId ||\n !(await verifyCredentialSignature(verifiableCredential))\n ) {\n throw new Error(\"Invalid credential signature\");\n }\n\n const user: User = {\n ...result,\n address: credential.issuer.ethereumAddress,\n did: userDid,\n credential: verifiableCredential,\n };\n\n this.#updateUser(user);\n this.#updateStatus(\"authorized\");\n\n // Fetch profile data in the background if a fetcher is configured\n if (this.#profileFetcher) {\n this.#profileFetcher(user, this.#baseUrl)\n .then((profile) => {\n if (\n profile &&\n this.user?.address === user.address &&\n this.user.chainId === user.chainId\n ) {\n this.#updateUser({\n ...this.user,\n profile,\n ens: {\n name: profile.username ?? undefined,\n avatarUrl: profile.userImage ?? undefined,\n },\n });\n }\n })\n .catch(console.error);\n }\n\n return user;\n }\n\n logout() {\n this.#updateUser(undefined);\n this.#updateStatus(\"initial\");\n return Promise.resolve();\n }\n\n // Re-check the current user's credential at the source; logs out if it was\n // revoked or expired. Network errors keep the session (fail open).\n async revalidate(): Promise<boolean> {\n const user = this.user;\n if (!user) return false;\n try {\n const credential = await this.#getCredential(\n user.address,\n user.chainId,\n this.#crypto.did,\n );\n if (!credential) {\n await this.logout();\n return false;\n }\n await this.refreshProfile();\n return true;\n } catch {\n return true;\n }\n }\n\n // Re-read profile attributes at the source so a renamed user or changed avatar\n // shows up on the next load. Carries no logout risk, unlike revalidate().\n async refreshProfile(): Promise<boolean> {\n const user = this.user;\n if (!user || !this.#profileFetcher) return false;\n try {\n const profile = await this.#profileFetcher(user, this.#baseUrl);\n if (!profile) return false;\n // Asserted because narrowing from the pre-await read would otherwise hide\n // that a logout during the fetch can clear this.\n const current = this.user as User | undefined;\n if (\n !current ||\n current.address !== user.address ||\n current.chainId !== user.chainId\n ) {\n return false;\n }\n // Narrow `profile` first: the fetched payload is unvalidated JSON, so a\n // missing documentId must not make the undefined case compare equal.\n const unchanged =\n current.profile !== undefined &&\n current.profile.documentId === profile.documentId &&\n current.profile.username === profile.username &&\n current.profile.userImage === profile.userImage;\n if (unchanged) return false;\n this.#updateUser({\n ...current,\n profile,\n ens: {\n name: profile.username ?? undefined,\n avatarUrl: profile.userImage ?? undefined,\n },\n });\n return true;\n } catch {\n return false;\n }\n }\n\n on<K extends keyof RenownEvents>(\n event: K,\n listener: (data: RenownEvents[K]) => void,\n ): () => void {\n return this.#eventEmitter.on(event, listener);\n }\n\n async #getCredential(\n address: string,\n chainId: number,\n appDid: string,\n ): Promise<PowerhouseVerifiableCredential | undefined> {\n // Direct-switchboard flow: read the credential from the reactor subgraph.\n if (this.#switchboard) {\n return this.#switchboard.getCredential({ address, chainId, appDid });\n }\n if (!this.#baseUrl) {\n throw new Error(\"RENOWN_URL is not set\");\n }\n const url = new URL(\n `/api/auth/credential?address=${encodeURIComponent(address)}&chainId=${encodeURIComponent(chainId)}&connectId=${encodeURIComponent(appDid)}&appId=${encodeURIComponent(appDid)}`,\n this.#baseUrl,\n );\n const response = await fetch(url, {\n method: \"GET\",\n });\n if (response.ok) {\n const result = (await response.json()) as {\n credential: PowerhouseVerifiableCredential;\n };\n return result.credential;\n } else {\n throw new Error(`Failed to get credential: ${response.status}`);\n }\n }\n\n async verifyBearerToken(token: string) {\n return verifyAuthBearerToken(token);\n }\n\n async getBearerToken(options: CreateBearerTokenOptions) {\n if (!this.user) {\n throw new Error(\"User not found\");\n }\n return this.#crypto.getBearerToken(this.user.address, options);\n }\n}\n","import type { RenownEvents } from \"../types.js\";\nimport type { IEventEmitter } from \"./types.js\";\n\nexport class MemoryEventEmitter implements IEventEmitter<RenownEvents> {\n #listeners = new Map<keyof RenownEvents, Set<(data: unknown) => void>>();\n\n on<K extends keyof RenownEvents>(\n event: K,\n listener: (data: RenownEvents[K]) => void,\n ): () => void {\n if (!this.#listeners.has(event)) {\n this.#listeners.set(event, new Set());\n }\n this.#listeners.get(event)!.add(listener as (data: unknown) => void);\n return () => {\n this.#listeners.get(event)?.delete(listener as (data: unknown) => void);\n };\n }\n\n emit<K extends keyof RenownEvents>(event: K, data: RenownEvents[K]): void {\n this.#listeners.get(event)?.forEach((listener) => listener(data));\n }\n}\n","import type { ProfileFetcher, RenownProfile } from \"./types.js\";\n\nexport const fetchRenownProfile: ProfileFetcher = async (user, baseUrl) => {\n try {\n const response = await fetch(`${baseUrl.replace(/\\/+$/, \"\")}/api/profile`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n ethAddress: user.address,\n }),\n });\n\n if (!response.ok) {\n return undefined;\n }\n\n const result = (await response.json()) as {\n profile?: RenownProfile;\n };\n\n return result.profile ?? undefined;\n } catch {\n return undefined;\n }\n};\n","import { Renown, RenownMemoryStorage } from \"./common.js\";\nimport { DEFAULT_RENOWN_CHAIN_ID, DEFAULT_RENOWN_URL } from \"./constants.js\";\nimport { RenownCryptoBuilder } from \"./crypto/renown-crypto-builder.js\";\nimport type { IRenownCrypto, JsonWebKeyPairStorage } from \"./crypto/types.js\";\nimport { resolveSwitchboardEndpoint } from \"./discovery.js\";\nimport { MemoryEventEmitter } from \"./event/memory.js\";\nimport { fetchRenownProfile } from \"./profile.js\";\nimport { SwitchboardClient } from \"./switchboard.js\";\nimport type {\n ProfileFetcher,\n RenownEventEmitter,\n RenownStorage,\n} from \"./types.js\";\n\nexport interface RenownBuilderOptions {\n appName: string;\n storage?: RenownStorage;\n eventEmitter?: RenownEventEmitter;\n crypto?: IRenownCrypto;\n keyPairStorage?: JsonWebKeyPairStorage;\n baseUrl?: string;\n switchboardUrl?: string;\n profileFetcher?: ProfileFetcher;\n /** Chain id credentials are issued on (default 1). The issuer DID embeds it, so `signIn` rejects a wallet session from another chain. */\n chainId?: number;\n}\n\n/**\n * Base builder for creating Renown instances.\n * Use platform-specific builders (RenownBuilder from init.browser.js or init.node.js)\n * for pre-configured defaults.\n */\nexport class BaseRenownBuilder {\n #appName: string;\n #storage?: RenownStorage;\n #eventEmitter?: RenownEventEmitter;\n #crypto?: IRenownCrypto;\n #keyPairStorage?: JsonWebKeyPairStorage;\n #baseUrl?: string;\n #switchboardUrl?: string;\n #profileFetcher?: ProfileFetcher;\n #chainId?: number;\n\n /**\n * @param appName - Application name used for signing context\n */\n constructor(appName: string) {\n this.#appName = appName;\n }\n\n /**\n * Set custom storage for user data persistence.\n * Defaults to in-memory storage if not set.\n */\n withStorage(storage: RenownStorage): this {\n this.#storage = storage;\n return this;\n }\n\n /**\n * Set custom event emitter for user state changes.\n * Defaults to in-memory event emitter if not set.\n */\n withEventEmitter(eventEmitter: RenownEventEmitter): this {\n this.#eventEmitter = eventEmitter;\n return this;\n }\n\n /**\n * Set a pre-built crypto instance.\n * Either crypto or keyPairStorage must be provided.\n */\n withCrypto(crypto: IRenownCrypto): this {\n this.#crypto = crypto;\n return this;\n }\n\n /**\n * Set key pair storage for cryptographic keys.\n * A crypto instance will be built from this storage.\n * Either crypto or keyPairStorage must be provided.\n */\n withKeyPairStorage(keyPairStorage: JsonWebKeyPairStorage): this {\n this.#keyPairStorage = keyPairStorage;\n return this;\n }\n\n /**\n * Set the Renown server URL for credential verification.\n * Defaults to https://www.renown.id\n */\n withBaseUrl(baseUrl: string): this {\n this.#baseUrl = baseUrl;\n return this;\n }\n\n // Set the Switchboard GraphQL endpoint to read from the reactor directly.\n // When unset, the SDK discovers it from the base URL, else uses the REST flow.\n withSwitchboardUrl(switchboardUrl: string): this {\n this.#switchboardUrl = switchboardUrl;\n return this;\n }\n\n // Set the chain id credentials are issued on (default 1). It is part of the\n // issuer DID, so signIn rejects a wallet session from a different chain.\n withChainId(chainId: number): this {\n this.#chainId = chainId;\n return this;\n }\n\n /**\n * Set a profile fetcher strategy for enriching user data after login.\n * The fetcher receives the authenticated user and the base URL,\n * and returns a RenownProfile. Called in the background after each login.\n * Defaults to fetchRenownProfile which calls the Renown API.\n */\n withProfileFetcher(profileFetcher: ProfileFetcher): this {\n this.#profileFetcher = profileFetcher;\n return this;\n }\n\n /**\n * Build and initialize the Renown instance.\n * If a user is stored, attempts to re-authenticate them.\n * @throws Error if neither crypto nor keyPairStorage is provided\n */\n async build(): Promise<Renown> {\n if (!this.#crypto && !this.#keyPairStorage) {\n throw new Error(\n \"Either crypto or keyPairStorage is required. Use withCrypto() or withKeyPairStorage() to set one.\",\n );\n }\n\n const chainId = this.#chainId ?? Number(DEFAULT_RENOWN_CHAIN_ID);\n const crypto =\n this.#crypto ??\n (await new RenownCryptoBuilder()\n .withKeyPairStorage(this.#keyPairStorage!)\n .withChainId(chainId)\n .build());\n\n // A crypto supplied via withCrypto() carries its own chain; the bearer token\n // it mints would then disagree with the credentials issued here.\n if (crypto.chainId !== undefined && crypto.chainId !== chainId) {\n console.warn(\n `Renown: the supplied crypto signs bearer tokens for chain ${crypto.chainId}, but credentials are issued on chain ${chainId}.`,\n );\n }\n\n const storage = this.#storage ?? new RenownMemoryStorage();\n const eventEmitter = this.#eventEmitter ?? new MemoryEventEmitter();\n const baseUrl = this.#baseUrl ?? DEFAULT_RENOWN_URL;\n\n // Pick the transport once: direct-switchboard when an endpoint resolves,\n // else the REST flow. A custom profile fetcher always takes precedence.\n const switchboardEndpoint = await resolveSwitchboardEndpoint({\n switchboardUrl: this.#switchboardUrl,\n baseUrl,\n });\n const switchboard = switchboardEndpoint\n ? new SwitchboardClient(switchboardEndpoint)\n : undefined;\n const profileFetcher =\n this.#profileFetcher ??\n (switchboard ? switchboard.profileFetcher : fetchRenownProfile);\n\n const renown = new Renown(\n storage,\n eventEmitter,\n crypto,\n this.#appName,\n baseUrl,\n profileFetcher,\n switchboard,\n chainId,\n );\n\n // A stored user is loaded as-is for an instant, offline-safe start; callers\n // revalidate against the source separately via renown.revalidate().\n return renown;\n }\n\n /**\n * Create a BaseRenownBuilder from options object for a more concise API\n */\n static from(options: RenownBuilderOptions): BaseRenownBuilder {\n const builder = new BaseRenownBuilder(options.appName);\n\n if (options.storage) {\n builder.withStorage(options.storage);\n }\n if (options.eventEmitter) {\n builder.withEventEmitter(options.eventEmitter);\n }\n if (options.crypto) {\n builder.withCrypto(options.crypto);\n }\n if (options.keyPairStorage) {\n builder.withKeyPairStorage(options.keyPairStorage);\n }\n if (options.baseUrl) {\n builder.withBaseUrl(options.baseUrl);\n }\n if (options.switchboardUrl) {\n builder.withSwitchboardUrl(options.switchboardUrl);\n }\n if (options.profileFetcher) {\n builder.withProfileFetcher(options.profileFetcher);\n }\n if (options.chainId !== undefined) {\n builder.withChainId(options.chainId);\n }\n\n return builder;\n }\n}\n","import { fetchDelegationCredential } from \"./credential.js\";\nimport type { SwitchboardRequestFn } from \"./switchboard.js\";\n\n/** Confirms an authenticated signer's delegation credential is still live. */\nexport type CredentialCheck = (params: {\n address: string;\n chainId: number;\n appId: string;\n}) => Promise<boolean>;\n\nexport interface LocalCredentialVerifierOptions {\n /** Notified when the read itself fails; the check then fails closed. */\n onError?: (error: unknown) => void;\n}\n\n/** A credential check that reads a Switchboard's own renown read model through\n * `execute`, rather than any Renown or Switchboard over HTTP. */\nexport function createLocalCredentialVerifier(\n execute: SwitchboardRequestFn,\n options: LocalCredentialVerifierOptions = {},\n): CredentialCheck {\n // fetchDelegationCredential turns a read failure into \"no credential\" — the\n // right verdict, but silent; surface it before it is swallowed.\n const request: SwitchboardRequestFn = async (query, variables) => {\n try {\n return await execute(query, variables);\n } catch (error) {\n options.onError?.(error);\n throw error;\n }\n };\n\n return async ({ address, chainId, appId }) => {\n const credential = await fetchDelegationCredential({\n address,\n chainId,\n appDid: appId,\n switchboardRequest: request,\n });\n return credential !== undefined;\n };\n}\n"],"mappings":";;;;;AASA,IAAsB,cAAtB,MAGyB,CAIzB;AAEA,IAAa,gBAAb,cAGU,YAAe;CACvB,uBAAwB,IAAI,IAAiB;CAE7C,IAAI,KAAU;EACZ,OAAO,KAAK,KAAK,IAAI,GAAG;CAC1B;CAEA,IAAI,KAAU,OAAsB;EAClC,IAAI,UAAU,KAAA,GACZ,KAAK,KAAK,OAAO,GAAG;OAEpB,KAAK,KAAK,IAAI,KAAK,KAAK;CAE5B;CAEA,OAAO,KAAgB;EACrB,KAAK,KAAK,OAAO,GAAG;CACtB;AACF;;;ACHA,IAAa,sBAAb,cAAyC,cAAgC,CAAC;;;;;;;;;;;;;;;;;;;;AAqB1E,SAAS,eAAe,MAAsD;CAC5E,IAAI,CAAC,MAAM,OAAO,KAAA;CAClB,OAAO;EACL,SAAS,KAAK;EACd,WAAW,KAAK;EAChB,SAAS,KAAK;CAChB;AACF;AAEA,IAAa,SAAb,MAAuC;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,UAAuB;CAEvB,YACE,OACA,cACA,QACA,SACA,UAAU,oBACV,gBACA,aACA,UAAU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