@renown/sdk 6.2.3-dev.1 → 6.2.3-dev.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{browser-key-storage-e3RQsnLS.js → browser-key-storage-wjSwTnhs.js} +3 -2
- package/dist/browser-key-storage-wjSwTnhs.js.map +1 -0
- package/dist/{constants-BexAR53F.js → constants-DVOF17NB.js} +1 -1
- package/dist/{constants-BexAR53F.js.map → constants-DVOF17NB.js.map} +1 -1
- package/dist/crypto.d.ts +4 -3
- package/dist/crypto.js +3 -2
- package/dist/{index-BLIpkdF7.d.ts → index-Bf53Cq6x.d.ts} +11 -20
- package/dist/index-Bf53Cq6x.d.ts.map +1 -0
- package/dist/index.d.ts +12 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/memory-key-storage-CVVAWWS4.js +145 -0
- package/dist/memory-key-storage-CVVAWWS4.js.map +1 -0
- package/dist/{meta-D-5kvwx8.js → meta-4NmijIbE.js} +2 -2
- package/dist/{meta-D-5kvwx8.js.map → meta-4NmijIbE.js.map} +1 -1
- package/dist/{meta-CHgd9Qd0.js → meta-B2fHYlPD.js} +2 -2
- package/dist/{meta-CHgd9Qd0.js.map → meta-B2fHYlPD.js.map} +1 -1
- package/dist/{meta-BesJP74N.d.ts → meta-Co-vmMo-.d.ts} +3 -3
- package/dist/meta-Co-vmMo-.d.ts.map +1 -0
- package/dist/{meta-bV7L-1yb.d.ts → meta-ScD9zeLt.d.ts} +3 -3
- package/dist/meta-ScD9zeLt.d.ts.map +1 -0
- package/dist/node.d.ts +42 -25
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +32 -71
- package/dist/node.js.map +1 -1
- package/dist/signed-message-DuAelefH.js +556 -0
- package/dist/signed-message-DuAelefH.js.map +1 -0
- package/dist/{signer-DrjINLqt.js → signer-9gB5YUMp.js} +40 -177
- package/dist/signer-9gB5YUMp.js.map +1 -0
- package/dist/signer-trust-B4XTKeZ2.d.ts +170 -0
- package/dist/signer-trust-B4XTKeZ2.d.ts.map +1 -0
- package/dist/signer-trust-aVg9lYAn.js +992 -0
- package/dist/signer-trust-aVg9lYAn.js.map +1 -0
- package/dist/trust.d.ts +3 -0
- package/dist/trust.js +2 -0
- package/dist/{types-DInveFLz.d.ts → types-BmdG67IZ.d.ts} +3 -3
- package/dist/types-BmdG67IZ.d.ts.map +1 -0
- package/dist/{types-C-hJrsQg.d.ts → types-CfSRJMyb.d.ts} +3 -3
- package/dist/types-CfSRJMyb.d.ts.map +1 -0
- package/dist/{types-BGQKPoUr.d.ts → types-CplBDMtV.d.ts} +77 -12
- package/dist/types-CplBDMtV.d.ts.map +1 -0
- package/dist/{types-C_qc_62W.js → types-Dwy6khXb.js} +1 -1
- package/dist/{types-C_qc_62W.js.map → types-Dwy6khXb.js.map} +1 -1
- package/dist/{utils-DtWREYeO.d.ts → utils-K2mtcxhD.d.ts} +47 -9
- package/dist/utils-K2mtcxhD.d.ts.map +1 -0
- package/dist/wallet/index.d.ts +5 -5
- package/dist/wallet/index.d.ts.map +1 -1
- package/dist/wallet/index.js +1 -1
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/mock/factory.d.ts +4 -5
- package/dist/wallet/mock/factory.d.ts.map +1 -1
- package/dist/wallet/mock/factory.js +1 -1
- package/dist/wallet/mock/factory.js.map +1 -1
- package/dist/wallet/mock/index.d.ts +5 -5
- package/dist/wallet/mock/index.d.ts.map +1 -1
- package/dist/wallet/mock/index.js +1 -1
- package/dist/wallet/mock/index.js.map +1 -1
- package/dist/wallet/privy/factory.d.ts +9 -11
- package/dist/wallet/privy/factory.d.ts.map +1 -1
- package/dist/wallet/privy/factory.js +2 -2
- package/dist/wallet/privy/factory.js.map +1 -1
- package/dist/wallet/privy/index.d.ts +5 -5
- package/dist/wallet/privy/index.d.ts.map +1 -1
- package/dist/wallet/privy/index.js +1 -1
- package/dist/wallet/privy/index.js.map +1 -1
- package/dist/wallet/rainbow/factory.d.ts +5 -4
- package/dist/wallet/rainbow/factory.d.ts.map +1 -1
- package/dist/wallet/rainbow/factory.js +2 -2
- package/dist/wallet/rainbow/factory.js.map +1 -1
- package/dist/wallet/rainbow/index.d.ts +5 -5
- package/dist/wallet/rainbow/index.d.ts.map +1 -1
- package/dist/wallet/rainbow/index.js +1 -1
- package/dist/wallet/rainbow/index.js.map +1 -1
- package/package.json +12 -5
- package/dist/browser-key-storage-e3RQsnLS.js.map +0 -1
- package/dist/index-BLIpkdF7.d.ts.map +0 -1
- package/dist/local-credential-verifier-CU8hmFlR.js +0 -907
- package/dist/local-credential-verifier-CU8hmFlR.js.map +0 -1
- package/dist/meta-BesJP74N.d.ts.map +0 -1
- package/dist/meta-bV7L-1yb.d.ts.map +0 -1
- package/dist/signer-DrjINLqt.js.map +0 -1
- package/dist/types-BGQKPoUr.d.ts.map +0 -1
- package/dist/types-C-hJrsQg.d.ts.map +0 -1
- package/dist/types-DInveFLz.d.ts.map +0 -1
- package/dist/utils-DtWREYeO.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer-trust-aVg9lYAn.js","names":["bindsTo"],"sources":["../src/discovery.ts","../src/switchboard.ts","../src/credential.ts","../src/delegation.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 (issuer.id = did:pkh:<networkId>:<chainId>:<address>).\n if (!credentialIssuedTo(credential, address, chainId, appDid)) {\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\n/**\n * What Renown says of a credential. `unknown` means it did not answer, and is\n * never read as revoked: an outage must not stop anything.\n */\nexport type DelegationCredentialStatus =\n | \"active\"\n | \"revoked\"\n | \"expired\"\n | \"unknown\";\n\nexport interface CheckDelegationCredentialOptions {\n address: string;\n chainId: number;\n appDid: string;\n /** Renown service base URL. Defaults to DEFAULT_RENOWN_URL. */\n baseUrl?: string;\n /** Switchboard GraphQL endpoint; wins over the REST lookup. */\n switchboardUrl?: string;\n /** In-process Switchboard reader; wins over any URL. */\n switchboardRequest?: SwitchboardRequestFn;\n /**\n * The credential's own expiry, when the caller holds it. The REST endpoint\n * answers with active credentials only, so this tells a credential that\n * expired from one revoked.\n */\n expirationDate?: string;\n /** How long Renown has to answer. Defaults to 5 seconds. */\n timeoutMs?: number;\n}\n\nexport interface DelegationCredentialCheck {\n status: DelegationCredentialStatus;\n /** The active credential, proof verified. */\n credential?: PowerhouseVerifiableCredential;\n}\n\nconst DEFAULT_CHECK_TIMEOUT_MS = 5_000;\n\n// Delegates to this app DID, issued by this address on this chain.\nfunction credentialIssuedTo(\n credential: PowerhouseVerifiableCredential,\n address: string,\n chainId: number,\n appDid: string,\n): boolean {\n const [, , , issuerChainId, issuerAddress] = credential.issuer.id.split(\":\");\n return (\n credential.credentialSubject.id === appDid &&\n issuerChainId === String(chainId) &&\n issuerAddress?.toLowerCase() === address.toLowerCase() &&\n credential.issuer.ethereumAddress.toLowerCase() === address.toLowerCase()\n );\n}\n\n// A credential Renown no longer serves: past its date, or revoked. With no date\n// to go on, a credential that is gone was not expired by anything known here.\nfunction goneStatus(\n expirationDate: string | undefined,\n): DelegationCredentialStatus {\n if (!expirationDate) return \"revoked\";\n const expiresAt = Date.parse(expirationDate);\n return !Number.isNaN(expiresAt) && expiresAt <= Date.now()\n ? \"expired\"\n : \"revoked\";\n}\n\nasync function checkOverRest(\n options: CheckDelegationCredentialOptions,\n baseUrl: string,\n): Promise<DelegationCredentialCheck> {\n const { address, chainId, appDid, expirationDate } = options;\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, {\n method: \"GET\",\n signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS),\n });\n if (!response.ok && response.status !== 404) return { status: \"unknown\" };\n // A JSON body is Renown's own answer; a proxy's 404 page says nothing.\n const body = (await response.json().catch(() => undefined)) as\n | { credential?: PowerhouseVerifiableCredential | null }\n | undefined;\n if (!body) return { status: \"unknown\" };\n if (!body.credential) return { status: goneStatus(expirationDate) };\n return { status: \"active\", credential: body.credential };\n}\n\nasync function checkOverSwitchboard(\n options: CheckDelegationCredentialOptions,\n source: SwitchboardSource,\n): Promise<DelegationCredentialCheck> {\n const { address, chainId, appDid, expirationDate } = options;\n const client = new SwitchboardClient(source);\n const credential = await client.getCredential({ address, chainId, appDid });\n if (credential) return { status: \"active\", credential };\n const issued = await client.getIssuedCredentials({\n address,\n chainId,\n appDid,\n });\n // This read model has never held it: nothing definite to say.\n if (issued.length === 0 && !expirationDate) return { status: \"unknown\" };\n const latest = issued\n .map((row) => row.expirationDate)\n .filter((date): date is string => Boolean(date))\n .sort()\n .at(-1);\n return { status: goneStatus(latest ?? expirationDate) };\n}\n\n/**\n * Asks Renown about a credential, keeping \"no\" apart from \"no answer\". Never\n * throws. Used where a definite answer stops something, unlike\n * {@link fetchDelegationCredential}, which reads both as undefined.\n */\nexport async function checkDelegationCredential(\n options: CheckDelegationCredentialOptions,\n): Promise<DelegationCredentialCheck> {\n const source = options.switchboardRequest ?? options.switchboardUrl;\n try {\n const check = source\n ? await checkOverSwitchboard(options, source)\n : await checkOverRest(options, options.baseUrl ?? DEFAULT_RENOWN_URL);\n if (check.status !== \"active\" || !check.credential) return check;\n const { address, chainId, appDid } = options;\n const verified = credentialIssuedTo(\n check.credential,\n address,\n chainId,\n appDid,\n )\n ? await finalizeCredential(check.credential, chainId, true)\n : undefined;\n return verified\n ? { status: \"active\", credential: verified }\n : { status: \"unknown\" };\n } catch {\n return { status: \"unknown\" };\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 {\n Action,\n ActionSigner,\n ActionSigningTarget,\n Signature,\n UserActionSigner,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n actionSignerIdentity,\n signActionV2,\n} from \"@powerhousedao/shared/document-model\";\nimport { fromString, toString } from \"uint8arrays\";\nimport { verifyDelegationProof } from \"./credential.js\";\nimport { importDidPublicKey } from \"./crypto/signer.js\";\nimport type { IRenownCrypto } from \"./crypto/types.js\";\nimport type { Issuer, PowerhouseVerifiableCredential } from \"./types.js\";\nimport { parsePkhDid } from \"./utils.js\";\n\n/** The tag of the `signatures` entry holding a statement, and of its binding. */\nexport const DELEGATION_TAG = \"dlg1\";\n\n/** Keeps a statement apart from the bearer tokens the same key signs. */\nexport const DELEGATION_JWT_TYPE = \"ph-delegation+jwt\";\n\n/** What a statement may name in this version. Nothing wider is accepted. */\nexport const DELEGABLE_OPERATIONS: readonly string[] = [\"PUBLISH_WORKFLOW\"];\n\nconst DEFAULT_LIFETIME_SECONDS = 30 * 24 * 60 * 60;\n/** How far the browser's clock at issuance may run ahead of the signing tuple. */\nconst ISSUED_AT_TOLERANCE_SECONDS = 300;\nconst BINDING_PREFIX = `${DELEGATION_TAG}-`;\n\nexport type DelegationScope = {\n /** Action types the delegate may sign. */\n ops: string[];\n /** What the statement is for; the host using it checks this. */\n res: string;\n};\n\nexport type DelegationClaims = {\n iss: string;\n aud: string;\n sub: string;\n env: string;\n scp: DelegationScope;\n iat: number;\n exp: number;\n jti: string;\n prf: PowerhouseVerifiableCredential;\n};\n\nexport interface CreateDelegationParams {\n /** The session key named in `credential`. */\n issuer: Issuer;\n /** The Renown credential binding the person to `issuer`. */\n credential: PowerhouseVerifiableCredential;\n /** The delegate's `did:key`. */\n delegate: string;\n /** The `did:key` of the host the delegate writes to. */\n environment: string;\n scope: DelegationScope;\n /** Defaults to 30 days. */\n lifetimeSeconds?: number;\n /** Epoch seconds; defaults to the clock. */\n now?: number;\n}\n\n/**\n * Signs a statement naming `delegate`, with no wallet step: the session key\n * signs it, and the statement carries the credential so it verifies offline.\n */\nexport async function createDelegation(\n params: CreateDelegationParams,\n): Promise<string> {\n const {\n issuer,\n credential,\n delegate,\n environment,\n scope,\n lifetimeSeconds = DEFAULT_LIFETIME_SECONDS,\n now = Math.floor(Date.now() / 1000),\n } = params;\n const claims: DelegationClaims = {\n iss: issuer.did,\n aud: delegate,\n sub: credential.issuer.id,\n env: environment,\n scp: scope,\n iat: now,\n exp: now + lifetimeSeconds,\n jti: globalThis.crypto.randomUUID(),\n prf: credential,\n };\n const signingInput = [\n encodeSegment({ alg: \"ES256\", typ: DELEGATION_JWT_TYPE }),\n encodeSegment(claims),\n ].join(\".\");\n const signature = await issuer.signer(signingInput);\n if (typeof signature !== \"string\") {\n throw new Error(\"A delegation issuer must sign as base64url\");\n }\n return `${signingInput}.${signature}`;\n}\n\n/** The statement's claims, unverified; undefined when it does not parse. */\nexport function decodeDelegation(\n statement: string,\n): DelegationClaims | undefined {\n const [, payload] = statement.split(\".\");\n if (!payload) return undefined;\n try {\n const claims = JSON.parse(\n toString(fromString(payload, \"base64url\")),\n ) as Partial<DelegationClaims> | null;\n return isClaims(claims) ? claims : undefined;\n } catch {\n return undefined;\n }\n}\n\nexport type DelegationVerdict =\n | { ok: true; claims: DelegationClaims }\n | { ok: false; reason: string };\n\nexport interface VerifyDelegationParams {\n /** Who the action claims to act as. */\n user: UserActionSigner;\n /** The key that signed the action. */\n key: string;\n /** The signing tuple's time, in epoch seconds. */\n signedAt: number;\n /** The action's type. */\n actionType: string;\n}\n\n/**\n * Whether `statement` lets `key` sign this action as `user`. Offline and pure:\n * every replica reaches the same verdict at any time, so an old operation\n * verifies forever. The credential's own dates are not read: link one is judged\n * at issuance, and a credential outliving its seven days must not end a delegate.\n */\nexport async function verifyDelegation(\n statement: string,\n params: VerifyDelegationParams,\n): Promise<DelegationVerdict> {\n const { user, key, signedAt, actionType } = params;\n const parts = statement.split(\".\");\n if (parts.length !== 3) return refuse(\"is not a compact JWS\");\n const claims = decodeDelegation(statement);\n if (!claims) return refuse(\"has malformed claims\");\n\n const header = decodeHeader(parts[0]);\n if (header?.alg !== \"ES256\" || header.typ !== DELEGATION_JWT_TYPE) {\n return refuse(\"has the wrong header\");\n }\n if (!(await signedBy(claims.iss, parts))) {\n return refuse(\"is not signed by its issuer\");\n }\n if (!samePerson(claims.sub, user)) {\n return refuse(`does not name ${user.address}`);\n }\n if (claims.aud !== key) {\n return refuse(`names ${claims.aud}, not the signing key ${key}`);\n }\n if (!(await chainsToPerson(claims, user))) {\n return refuse(\"has no credential binding its issuer to the person\");\n }\n const scopeProblem = scopeRefusal(claims.scp, actionType);\n if (scopeProblem) return refuse(scopeProblem);\n if (\n signedAt < claims.iat - ISSUED_AT_TOLERANCE_SECONDS ||\n signedAt >= claims.exp\n ) {\n return refuse(\"does not cover the time the action was signed\");\n }\n return { ok: true, claims };\n}\n\nexport type DelegationCarried = {\n /** Absent: the tuple names a statement the signer does not carry. */\n statement?: string;\n /** The binding in the signing tuple; absent: not bound. */\n binding?: string;\n /** The signing tuple's time. */\n signedAt: number;\n};\n\n/** What `signer` carries of a delegation; undefined when it carries nothing. */\nexport function delegationOf(\n signer: ActionSigner,\n): DelegationCarried | undefined {\n const signatures = signer.signatures as Signature[] | undefined;\n const tuple = signatures?.at(-1);\n if (!signatures || !tuple) return undefined;\n const statements = signatures\n .slice(0, -1)\n .filter((entry) => entry[0] === DELEGATION_TAG)\n .map((entry) => entry[3]);\n const binding = tuple[3]?.startsWith(BINDING_PREFIX) ? tuple[3] : undefined;\n if (statements.length === 0 && binding === undefined) return undefined;\n return {\n ...(statements.length === 1 ? { statement: statements[0] } : {}),\n ...(binding !== undefined ? { binding } : {}),\n signedAt: Number(tuple[0]),\n };\n}\n\n/** Why what `signer` carries does not stand as bound; undefined when it does. */\nexport async function bindingRefusal(\n carried: DelegationCarried,\n): Promise<string | undefined> {\n if (carried.statement === undefined) {\n return \"the signing tuple names a statement the action does not carry\";\n }\n if (carried.binding === undefined) {\n return \"the signing tuple does not cover the statement\";\n }\n if (carried.binding !== (await delegationBinding(carried.statement))) {\n return \"the signing tuple covers a different statement\";\n }\n return undefined;\n}\n\n/** What the signing tuple's element [3] holds, so the signature covers the statement. */\nexport async function delegationBinding(statement: string): Promise<string> {\n const digest = await globalThis.crypto.subtle.digest(\n \"SHA-256\",\n new TextEncoder().encode(statement),\n );\n return BINDING_PREFIX + toString(new Uint8Array(digest), \"base64url\");\n}\n\nexport interface SignDelegatedActionParams {\n action: Action;\n target: ActionSigningTarget;\n /** The delegate's key. */\n crypto: Pick<IRenownCrypto, \"did\" | \"sign\">;\n /** A label for `signer.app.name`; unsigned. */\n appName: string;\n /** The person the delegate signs as. */\n user: UserActionSigner;\n statement: string;\n}\n\n/**\n * Signs `action` as the person, carrying the statement in an earlier entry of\n * `signatures`. The reactor leaves an action already signed under a key as it\n * is, so this goes through any client.\n */\nexport async function signDelegatedAction(\n params: SignDelegatedActionParams,\n): Promise<Action> {\n const { action, target, crypto, appName, user, statement } = params;\n const identity = actionSignerIdentity({\n user,\n app: { name: appName, key: crypto.did },\n });\n const tuple = await signActionV2({\n action,\n target,\n signer: identity,\n sign: (message) => crypto.sign(message),\n previousStateHash: await delegationBinding(statement),\n });\n const issuer = decodeDelegation(statement)?.iss ?? \"\";\n const entry: Signature = [DELEGATION_TAG, issuer, \"\", statement, \"\"];\n return {\n ...action,\n context: {\n ...action.context,\n signer: { ...identity, signatures: [entry, tuple] },\n },\n };\n}\n\nfunction refuse(reason: string): DelegationVerdict {\n return { ok: false, reason: `the statement ${reason}` };\n}\n\nfunction encodeSegment(value: unknown): string {\n return toString(fromString(JSON.stringify(value)), \"base64url\");\n}\n\nfunction decodeHeader(\n segment: string,\n): { alg?: unknown; typ?: unknown } | undefined {\n try {\n return JSON.parse(toString(fromString(segment, \"base64url\"))) as {\n alg?: unknown;\n typ?: unknown;\n };\n } catch {\n return undefined;\n }\n}\n\nfunction isClaims(\n value: Partial<DelegationClaims> | null,\n): value is DelegationClaims {\n return (\n !!value &&\n typeof value.iss === \"string\" &&\n typeof value.aud === \"string\" &&\n typeof value.sub === \"string\" &&\n typeof value.env === \"string\" &&\n typeof value.iat === \"number\" &&\n typeof value.exp === \"number\" &&\n typeof value.jti === \"string\" &&\n typeof value.scp === \"object\" &&\n value.scp !== null &&\n typeof value.prf === \"object\" &&\n value.prf !== null\n );\n}\n\nasync function signedBy(issuer: string, parts: string[]): Promise<boolean> {\n try {\n const key = await importDidPublicKey(issuer);\n return await globalThis.crypto.subtle.verify(\n { name: \"ECDSA\", hash: \"SHA-256\" },\n key,\n new Uint8Array(fromString(parts[2], \"base64url\")),\n new TextEncoder().encode(`${parts[0]}.${parts[1]}`),\n );\n } catch {\n return false;\n }\n}\n\nfunction samePerson(subject: string, user: UserActionSigner): boolean {\n try {\n const person = parsePkhDid(subject);\n return (\n person.address.toLowerCase() === user.address.toLowerCase() &&\n person.networkId === user.networkId &&\n person.chainId === user.chainId\n );\n } catch {\n return false;\n }\n}\n\n/** Link one: the credential in `prf` binds the person to the statement's issuer. */\nasync function chainsToPerson(\n claims: DelegationClaims,\n user: UserActionSigner,\n): Promise<boolean> {\n const credential = claims.prf;\n const address = user.address.toLowerCase();\n try {\n if (\n credential.credentialSubject.id !== claims.iss ||\n credential.issuer.id !== claims.sub ||\n credential.issuer.ethereumAddress.toLowerCase() !== address\n ) {\n return false;\n }\n return await verifyDelegationProof(credential, user.chainId);\n } catch {\n return false;\n }\n}\n\nfunction scopeRefusal(\n scope: DelegationScope,\n actionType: string,\n): string | undefined {\n if (!Array.isArray(scope.ops) || scope.ops.length === 0) {\n return \"names no operations\";\n }\n const wider = scope.ops.find((op) => !DELEGABLE_OPERATIONS.includes(op));\n if (wider !== undefined) {\n return `names ${wider}, which cannot be delegated`;\n }\n if (!scope.ops.includes(actionType)) {\n return `does not cover ${actionType}`;\n }\n return undefined;\n}\n","import type { ActionSigner } from \"@powerhousedao/shared/document-model\";\nimport { DEFAULT_RENOWN_URL } from \"./constants.js\";\nimport { verifyDelegationProof } from \"./credential.js\";\nimport {\n bindingRefusal,\n delegationOf,\n verifyDelegation,\n type DelegationCarried,\n} from \"./delegation.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 * Verify delegated signers only, and accept every other signer: what a host\n * with `authEnforcement` off does. It makes no lookup, so it needs no network.\n */\n delegationOnly?: boolean;\n}\n\n/** What admission knows of the write; the reactor's `SignatureTrustContext`. */\nexport interface RenownTrustContext {\n /** Where this reactor first stores the write. */\n path: \"mutation\" | \"load\";\n actionType: string;\n}\n\n/** Structurally a reactor `SignatureTrustPolicy`. */\nexport interface RenownTrustPolicy {\n authorizeSigner(\n signer: ActionSigner,\n key: string,\n documentId: string,\n context?: RenownTrustContext,\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 *\n * A signer carrying a delegation is verified from what it carries, with no\n * lookup and no cache: the verdict depends on the statement, not on (address,\n * key). `options.delegationOnly` accepts every other signer.\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, _documentId, context) {\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 const carried = delegationOf(signer);\n if (carried) {\n return authorizeDelegated(carried, user, key, self?.key, context);\n }\n if (options.delegationOnly) {\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\n/**\n * The statement alone decides, so every replica agrees and no network is\n * needed. The one exception is `env`, checked only at first write: peers\n * receive these operations legitimately on load.\n */\nasync function authorizeDelegated(\n carried: DelegationCarried,\n user: SignerUser | undefined,\n key: string,\n ownKey: string | undefined,\n context: RenownTrustContext | undefined,\n): Promise<boolean> {\n if (!user || !context || carried.statement === undefined) {\n return false;\n }\n if ((await bindingRefusal(carried)) !== undefined) {\n return false;\n }\n const verdict = await verifyDelegation(carried.statement, {\n user,\n key,\n signedAt: carried.signedAt,\n actionType: context.actionType,\n });\n if (!verdict.ok) {\n return false;\n }\n return context.path === \"load\" || verdict.claims.env === ownKey;\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,EAAA,CACtB,YAAY,KAAA;CAC1B,QAAQ;EAGN;CACF,UAAU;EACR,aAAa,OAAO;CACtB;AACF;;;;;AC5CA,IAAa,0BAAb,MAAa,gCAAgC,MAAM;CACjD,cAAc;EACZ,MACE,uFACF;EACA,KAAK,OAAO;CACd;;CAGA,OAAO,GAAG,OAAkD;EAC1D,OACE,iBAAiB,2BAChB,iBAAiB,SAAS,MAAM,SAAS;CAE9C;AACF;AAIA,SAAS,YAAY,SAAyB;CAC5C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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
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { C as signDelegatedAction, S as delegationOf, _ as VerifyDelegationParams, a as createRenownTrustPolicy, b as decodeDelegation, c as CreateDelegationParams, d as DELEGATION_TAG, f as DelegationCarried, g as SignDelegatedActionParams, h as DelegationVerdict, i as RenownTrustPolicyOptions, l as DELEGABLE_OPERATIONS, m as DelegationScope, n as RenownTrustContext, p as DelegationClaims, r as RenownTrustPolicy, s as resolveSwitchboardEndpoint, t as RenownOwnSigner, u as DELEGATION_JWT_TYPE, v as bindingRefusal, w as verifyDelegation, x as delegationBinding, y as createDelegation } from "./signer-trust-B4XTKeZ2.js";
|
|
2
|
+
export { CreateDelegationParams, DELEGABLE_OPERATIONS, DELEGATION_JWT_TYPE, DELEGATION_TAG, DelegationCarried, DelegationClaims, DelegationScope, DelegationVerdict, RenownOwnSigner, RenownTrustContext, RenownTrustPolicy, RenownTrustPolicyOptions, SignDelegatedActionParams, VerifyDelegationParams, bindingRefusal, createDelegation, createRenownTrustPolicy, decodeDelegation, delegationBinding, delegationOf, resolveSwitchboardEndpoint, signDelegatedAction, verifyDelegation };
|
|
3
|
+
export {};
|
package/dist/trust.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as bindingRefusal, c as delegationBinding, d as verifyDelegation, i as DELEGATION_TAG, l as delegationOf, n as DELEGABLE_OPERATIONS, o as createDelegation, r as DELEGATION_JWT_TYPE, s as decodeDelegation, t as createRenownTrustPolicy, u as signDelegatedAction, x as resolveSwitchboardEndpoint } from "./signer-trust-aVg9lYAn.js";
|
|
2
|
+
export { DELEGABLE_OPERATIONS, DELEGATION_JWT_TYPE, DELEGATION_TAG, bindingRefusal, createDelegation, createRenownTrustPolicy, decodeDelegation, delegationBinding, delegationOf, resolveSwitchboardEndpoint, signDelegatedAction, verifyDelegation };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { c as WalletController, l as WalletSession, o as WalletAdapterMeta, t as LoginMethod } from "./types-
|
|
2
|
-
|
|
1
|
+
import { c as WalletController, l as WalletSession, o as WalletAdapterMeta, t as LoginMethod } from "./types-CfSRJMyb.js";
|
|
3
2
|
//#region src/wallet/privy/meta.d.ts
|
|
4
3
|
/** Structural subset of viem's `Chain`, so any `viem/chains` / `wagmi/chains` export fits regardless of the host's viem version. */
|
|
5
4
|
interface PrivyChain {
|
|
@@ -60,4 +59,5 @@ interface PrivyWalletController extends WalletController {
|
|
|
60
59
|
}
|
|
61
60
|
//#endregion
|
|
62
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 };
|
|
63
|
-
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=types-BmdG67IZ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BmdG67IZ.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,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ct as SignCredentialTypedData } from "./types-CplBDMtV.js";
|
|
2
2
|
import { ComponentType, ReactNode } from "react";
|
|
3
|
-
|
|
4
3
|
//#region src/wallet/types.d.ts
|
|
5
4
|
declare const LoginMethod: {
|
|
6
5
|
readonly WALLET: "wallet";
|
|
@@ -56,4 +55,5 @@ type WalletAdapterFactory<Config = unknown> = (config: Config) => WalletAdapterI
|
|
|
56
55
|
type WalletAdapterProvider<Config = unknown> = (config: Config) => WalletAdapterDescriptor;
|
|
57
56
|
//#endregion
|
|
58
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 };
|
|
59
|
-
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=types-CfSRJMyb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CfSRJMyb.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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Action, ISigner as ISigner$1, User, UserActionSigner as UserActionSigner$1 } from "@powerhousedao/shared/document-model";
|
|
2
|
-
|
|
3
2
|
//#region src/constants.d.ts
|
|
4
3
|
declare const DEFAULT_RENOWN_URL = "https://www.renown.id";
|
|
5
4
|
declare const DEFAULT_RENOWN_NETWORK_ID = "eip155";
|
|
@@ -126,9 +125,23 @@ declare class MissingSwitchboardError extends Error {
|
|
|
126
125
|
/** `instanceof` fails across duplicate SDK copies, so match by name too. */
|
|
127
126
|
static is(error: unknown): error is MissingSwitchboardError;
|
|
128
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
|
+
}
|
|
129
142
|
/** Runs a GraphQL document against a Switchboard and resolves its `data`;
|
|
130
143
|
* throws on transport or GraphQL errors. */
|
|
131
|
-
type SwitchboardRequestFn = (query: string, variables: Record<string, unknown
|
|
144
|
+
type SwitchboardRequestFn = (query: string, variables: Record<string, unknown>, options?: SwitchboardRequestOptions) => Promise<unknown>;
|
|
132
145
|
/** Where a SwitchboardClient reads from: an HTTP endpoint or a local executor. */
|
|
133
146
|
type SwitchboardSource = string | SwitchboardRequestFn;
|
|
134
147
|
declare class SwitchboardClient {
|
|
@@ -141,15 +154,20 @@ declare class SwitchboardClient {
|
|
|
141
154
|
chainId: number;
|
|
142
155
|
appDid: string;
|
|
143
156
|
}): Promise<PowerhouseVerifiableCredential | undefined>;
|
|
157
|
+
getIssuedCredentials(params: {
|
|
158
|
+
address: string;
|
|
159
|
+
chainId: number;
|
|
160
|
+
appDid: string;
|
|
161
|
+
}): Promise<PowerhouseVerifiableCredential[]>;
|
|
144
162
|
getProfileByAddress(address: string): Promise<RenownProfile | undefined>;
|
|
145
|
-
createEmptyDocument(documentType: string, parentIdentifier?: string): Promise<string>;
|
|
146
|
-
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>;
|
|
147
165
|
issueCredential(credential: PowerhouseVerifiableCredential, parentIdentifier?: string): Promise<string>;
|
|
148
|
-
|
|
166
|
+
upsertUserProfile(address: string, profile: {
|
|
149
167
|
username?: string;
|
|
150
168
|
userImage?: string;
|
|
151
|
-
}): Promise<string>;
|
|
152
|
-
revokeCredential(
|
|
169
|
+
}, auth: RenownWriteAuth): Promise<string>;
|
|
170
|
+
revokeCredential(credentialId: string, auth: RenownWriteAuth): Promise<void>;
|
|
153
171
|
profileFetcher: ProfileFetcher;
|
|
154
172
|
}
|
|
155
173
|
//#endregion
|
|
@@ -231,7 +249,45 @@ interface FetchDelegationCredentialOptions {
|
|
|
231
249
|
/** Re-verify the EIP-712 proof signature (default true). */
|
|
232
250
|
verifySignature?: boolean;
|
|
233
251
|
}
|
|
252
|
+
/** True when the credential's EIP-712 proof, on `chainId`, was signed by its
|
|
253
|
+
* issuer address. Binding and expiry are the caller's to check. */
|
|
254
|
+
declare function verifyDelegationProof(credential: PowerhouseVerifiableCredential, chainId: number): Promise<boolean>;
|
|
234
255
|
declare function fetchDelegationCredential(options: FetchDelegationCredentialOptions): Promise<PowerhouseVerifiableCredential | undefined>;
|
|
256
|
+
/**
|
|
257
|
+
* What Renown says of a credential. `unknown` means it did not answer, and is
|
|
258
|
+
* never read as revoked: an outage must not stop anything.
|
|
259
|
+
*/
|
|
260
|
+
type DelegationCredentialStatus = "active" | "revoked" | "expired" | "unknown";
|
|
261
|
+
interface CheckDelegationCredentialOptions {
|
|
262
|
+
address: string;
|
|
263
|
+
chainId: number;
|
|
264
|
+
appDid: string;
|
|
265
|
+
/** Renown service base URL. Defaults to DEFAULT_RENOWN_URL. */
|
|
266
|
+
baseUrl?: string;
|
|
267
|
+
/** Switchboard GraphQL endpoint; wins over the REST lookup. */
|
|
268
|
+
switchboardUrl?: string;
|
|
269
|
+
/** In-process Switchboard reader; wins over any URL. */
|
|
270
|
+
switchboardRequest?: SwitchboardRequestFn;
|
|
271
|
+
/**
|
|
272
|
+
* The credential's own expiry, when the caller holds it. The REST endpoint
|
|
273
|
+
* answers with active credentials only, so this tells a credential that
|
|
274
|
+
* expired from one revoked.
|
|
275
|
+
*/
|
|
276
|
+
expirationDate?: string;
|
|
277
|
+
/** How long Renown has to answer. Defaults to 5 seconds. */
|
|
278
|
+
timeoutMs?: number;
|
|
279
|
+
}
|
|
280
|
+
interface DelegationCredentialCheck {
|
|
281
|
+
status: DelegationCredentialStatus;
|
|
282
|
+
/** The active credential, proof verified. */
|
|
283
|
+
credential?: PowerhouseVerifiableCredential;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Asks Renown about a credential, keeping "no" apart from "no answer". Never
|
|
287
|
+
* throws. Used where a definite answer stops something, unlike
|
|
288
|
+
* {@link fetchDelegationCredential}, which reads both as undefined.
|
|
289
|
+
*/
|
|
290
|
+
declare function checkDelegationCredential(options: CheckDelegationCredentialOptions): Promise<DelegationCredentialCheck>;
|
|
235
291
|
interface VerifiedAuthCredential {
|
|
236
292
|
address: string;
|
|
237
293
|
chainId: number;
|
|
@@ -353,9 +409,10 @@ type DIDDocument = {
|
|
|
353
409
|
alsoKnownAs?: string[];
|
|
354
410
|
controller?: string | string[];
|
|
355
411
|
verificationMethod?: VerificationMethod[];
|
|
356
|
-
service?: Service[];
|
|
412
|
+
service?: Service[];
|
|
413
|
+
/** @deprecated */
|
|
357
414
|
publicKey?: VerificationMethod[];
|
|
358
|
-
} & { [x in KeyCapabilitySection]?: (string | VerificationMethod)[] };
|
|
415
|
+
} & { [x in KeyCapabilitySection]?: (string | VerificationMethod)[]; };
|
|
359
416
|
interface Service {
|
|
360
417
|
id: string;
|
|
361
418
|
type: string;
|
|
@@ -445,7 +502,8 @@ type RenownProfile = {
|
|
|
445
502
|
documentId: string;
|
|
446
503
|
username: string | null;
|
|
447
504
|
ethAddress: string | null;
|
|
448
|
-
userImage: string | null;
|
|
505
|
+
userImage: string | null;
|
|
506
|
+
/** Absent on a profile seeded from the session cookie (see RenownSessionProfile). */
|
|
449
507
|
createdAt?: string;
|
|
450
508
|
updatedAt?: string;
|
|
451
509
|
};
|
|
@@ -453,6 +511,8 @@ type InternalUser = User & {
|
|
|
453
511
|
did: string;
|
|
454
512
|
credential: PowerhouseVerifiableCredential | undefined;
|
|
455
513
|
profile?: RenownProfile;
|
|
514
|
+
/** Signed in with a key on this computer: no Renown holds the credential. */
|
|
515
|
+
local?: boolean;
|
|
456
516
|
};
|
|
457
517
|
type User$1 = InternalUser;
|
|
458
518
|
/**
|
|
@@ -493,6 +553,10 @@ interface IRenown extends Pick<RenownEventEmitter, "on"> {
|
|
|
493
553
|
readonly status: LoginStatus;
|
|
494
554
|
login: (userDid: string) => Promise<User$1>;
|
|
495
555
|
signIn: (params: SignInParams) => Promise<User$1>;
|
|
556
|
+
/** Signs in from a credential in hand, asking nobody. */
|
|
557
|
+
adoptCredential: (credential: PowerhouseVerifiableCredential, options?: {
|
|
558
|
+
local?: boolean;
|
|
559
|
+
}) => Promise<User$1>;
|
|
496
560
|
logout: () => Promise<void>;
|
|
497
561
|
/** Re-check the current credential at the source; logs out if revoked/expired. */
|
|
498
562
|
revalidate: () => Promise<boolean>;
|
|
@@ -599,5 +663,6 @@ interface IRenownCrypto {
|
|
|
599
663
|
*/
|
|
600
664
|
interface IConnectCrypto extends IRenownCrypto {}
|
|
601
665
|
//#endregion
|
|
602
|
-
export { MemoryStorage as $, LoginStatus as A, Service as B, InternalUser as C,
|
|
603
|
-
|
|
666
|
+
export { MemoryStorage as $, LoginStatus as A, DOMAIN_TYPE as At, Service as B, InternalUser as C, SwitchboardSource as Ct, JWTVerifyPolicies as D, DEFAULT_RENOWN_CHAIN_ID as Dt, JWTVerified as E, CREDENTIAL_TYPES 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, RENOWN_READ_MODEL_SUBGRAPH as Mt, ProfileFetcher as N, RENOWN_SESSION_COOKIE as Nt, JsonWebKey$1 as O, DEFAULT_RENOWN_NETWORK_ID as Ot, Proof as P, VERIFIABLE_CREDENTIAL_EIP712_TYPE as Pt, BaseStorage as Q, RenownStorage as R, IVerifiableCredential as S, SwitchboardRequestOptions as St, JWTPayload as T, CREDENTIAL_SUBJECT_TYPE as Tt, Signer as U, ServiceEndpoint as V, Unsubscribe as W, VerifiedJWT as X, VerifiedCredential as Y, W3CCredential as Z, IPowerhouseCredentialSubject as _, verifyDelegationProof as _t, JwkKeyPair as a, DelegationCredentialCheck as at, IRenown as b, SwitchboardClient as bt, ConditionWeightedThreshold as c, SignCredentialTypedData as ct, DIDDocument as d, buildAndSignCredential as dt, IEventEmitter as et, DIDDocumentMetadata as f, checkDelegationCredential as ft, IAuthCredentialSubject as g, verifyCredentialSignature as gt, EcdsaSignature as h, verifyAuthCredential as ht, JsonWebKeyPairStorage as i, CredentialMessage as it, PKHDid as j, ISSUER_TYPE as jt, KeyCapabilitySection as k, DEFAULT_RENOWN_URL as kt, CreateBearerTokenOptions as l, VerifiedAuthCredential as lt, DIDResolutionResult as m, recoverCredentialSigner as mt, IConnectCrypto as n, CheckDelegationCredentialOptions as nt, AuthVerifiableCredential as o, DelegationCredentialStatus as ot, DIDResolutionMetadata as p, fetchDelegationCredential as pt, Verifiable as q, IRenownCrypto as r, CredentialDomain as rt, AuthVerifiedCredential as s, FetchDelegationCredentialOptions as st, DID as t, BuildCredentialParams as tt, CredentialStatus as u, VerifyAuthCredentialOptions as ut, IPowerhouseIssuerType as v, MissingSwitchboardError as vt, Issuer as w, CREDENTIAL_SCHEMA_EIP712_TYPE as wt, ISigner$1 as x, SwitchboardRequestFn as xt, IProof as y, RenownWriteAuth as yt, RenownStorageMap as z };
|
|
667
|
+
export {};
|
|
668
|
+
//# sourceMappingURL=types-CplBDMtV.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CplBDMtV.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;cAI5B;;EAMX,YAAY,QA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;EACf;;KAGU,iCAAiC,sBAC3C,8BACA;UAGe;EACf;EACA;EACA;;KAGU,2BAA2B,sBACrC,wBACA;KAGU,yBAAyB;EACnC,sBAAsB,WAAW;;KAGvB;EACV;EACA;EACA;;UAGe;EACf;EACA;;;;KCrYU;EACV,WAAW;EACX,YAAY;;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-Dwy6khXb.js","names":[],"sources":["../src/wallet/types.ts"],"sourcesContent":["import type { ComponentType, ReactNode } from \"react\";\nimport type { SignCredentialTypedData } from \"../credential.js\";\n\n// Const object rather than an enum so config can be authored with plain string\n// literals (`methods: [\"google\"]`) while `LoginMethod.GOOGLE` still works.\nexport const LoginMethod = {\n WALLET: \"wallet\",\n GOOGLE: \"google\",\n EMAIL: \"email\",\n APPLE: \"apple\",\n} as const;\n\nexport type LoginMethod = (typeof LoginMethod)[keyof typeof LoginMethod];\n\n// Colors the host passes into an adapter Provider so its wallet UI matches.\n// The adapter stays agnostic to how the host derives them (CSS tokens, etc.).\nexport interface WalletThemeColors {\n accentColor?: string;\n accentColorForeground?: string;\n}\n\n// The theme the host passes at runtime: a bare mode, or a mode plus colors.\nexport type WalletTheme =\n | \"light\"\n | \"dark\"\n | ({ mode: \"light\" | \"dark\" } & WalletThemeColors);\n\n// Normalize a WalletTheme (or undefined) to a mode + colors the adapters use.\nexport function normalizeWalletTheme(theme: WalletTheme | undefined): {\n mode: \"light\" | \"dark\";\n accentColor?: string;\n accentColorForeground?: string;\n} {\n if (theme === undefined) return { mode: \"light\" };\n if (typeof theme === \"string\") return { mode: theme };\n return {\n mode: theme.mode,\n accentColor: theme.accentColor,\n accentColorForeground: theme.accentColorForeground,\n };\n}\n\n// The signer surface signIn needs, produced by an adapter after the user connects.\nexport interface WalletSession {\n address: `0x${string}`;\n chainId: number;\n signTypedData: SignCredentialTypedData;\n // Capability, not policy: the session can sign without a user prompt (e.g. a\n // Privy embedded wallet). Whether/when to sign silently is the host's call.\n canSignSilently?: boolean;\n}\n\n// Imperative controls returned by an adapter's React hook (used inside its Provider).\nexport interface WalletController {\n connect(method?: LoginMethod): Promise<WalletSession>;\n disconnect(): Promise<void>;\n getSession(): WalletSession | undefined;\n // Optional push stream of session changes (fires immediately with the current\n // one), so a host can complete sign-in on an OAuth return with no live connect().\n subscribe?(\n listener: (session: WalletSession | undefined) => void,\n ): () => void;\n}\n\n// Identity + capabilities, declared once per adapter in a dependency-free module\n// so a host can list methods and detect a redirect return with no wallet library.\nexport interface WalletAdapterMeta {\n id: string;\n // URL params the adapter leaves when a full-page OAuth login returns; empty for\n // adapters with no redirect flow.\n redirectReturnParams: string[];\n // Must be known before load(): the login UI renders buttons before any wallet\n // library is fetched.\n supportedMethods: LoginMethod[];\n}\n\n// Behaviour only — what an adapter factory returns. Identity lives in the meta.\nexport interface WalletAdapterImpl {\n // React provider that must wrap the app subtree for this adapter to work; the\n // host passes its current theme so the adapter's UI can match.\n Provider: ComponentType<{ children: ReactNode; theme?: WalletTheme }>;\n // Hook returning imperative controls; MUST be called inside <Provider>.\n useController: () => WalletController;\n}\n\n// What the host consumes: resolveAdapters pairs an impl with its meta.\nexport interface WalletAdapter extends WalletAdapterImpl {\n meta: WalletAdapterMeta;\n}\n\n// An adapter's light entry: eager meta plus a lazy loader that pulls the factory\n// and its wallet library only once login is activated.\nexport interface WalletAdapterDescriptor {\n meta: WalletAdapterMeta;\n load: () => Promise<WalletAdapterImpl>;\n}\n\nexport type WalletAdapterFactory<Config = unknown> = (\n config: Config,\n) => WalletAdapterImpl;\n\nexport type WalletAdapterProvider<Config = unknown> = (\n config: Config,\n) => WalletAdapterDescriptor;\n"],"mappings":";AAKA,MAAa,cAAc;CACzB,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,OAAO;AACT;AAkBA,SAAgB,qBAAqB,OAInC;CACA,IAAI,UAAU,KAAA,GAAW,OAAO,EAAE,MAAM,QAAQ;CAChD,IAAI,OAAO,UAAU,UAAU,OAAO,EAAE,MAAM,MAAM;CACpD,OAAO;EACL,MAAM,MAAM;EACZ,aAAa,MAAM;EACnB,uBAAuB,MAAM;CAC/B;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
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, b as IRenown,
|
|
1
|
+
import { $ as MemoryStorage, A as LoginStatus, C as InternalUser, F as RenownEventEmitter, G as User, H as SignInParams, I as RenownEvents, M as PowerhouseVerifiableCredential, N as ProfileFetcher, R as RenownStorage, Y as VerifiedCredential, b as IRenown, bt as SwitchboardClient, i as JsonWebKeyPairStorage, j as PKHDid, l as CreateBearerTokenOptions, r as IRenownCrypto, s as AuthVerifiedCredential, w as Issuer, x as ISigner, xt as SwitchboardRequestFn, z as RenownStorageMap } from "./types-CplBDMtV.js";
|
|
2
|
+
import "./index-Bf53Cq6x.js";
|
|
2
3
|
import { Resolver } from "did-resolver";
|
|
3
|
-
|
|
4
4
|
//#region src/common.d.ts
|
|
5
5
|
declare class RenownMemoryStorage extends MemoryStorage<RenownStorageMap> {}
|
|
6
6
|
declare class Renown implements IRenown {
|
|
@@ -17,6 +17,9 @@ declare class Renown implements IRenown {
|
|
|
17
17
|
get profileFetcher(): ProfileFetcher | undefined;
|
|
18
18
|
login(userDid: string): Promise<User>;
|
|
19
19
|
signIn(params: SignInParams): Promise<User>;
|
|
20
|
+
adoptCredential(credential: PowerhouseVerifiableCredential, options?: {
|
|
21
|
+
local?: boolean;
|
|
22
|
+
}): Promise<User>;
|
|
20
23
|
logout(): Promise<void>;
|
|
21
24
|
revalidate(): Promise<boolean>;
|
|
22
25
|
refreshProfile(): Promise<boolean>;
|
|
@@ -25,13 +28,33 @@ declare class Renown implements IRenown {
|
|
|
25
28
|
getBearerToken(options: CreateBearerTokenOptions): Promise<string>;
|
|
26
29
|
}
|
|
27
30
|
//#endregion
|
|
28
|
-
//#region src/
|
|
29
|
-
interface
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
//#region src/console-login.d.ts
|
|
32
|
+
interface ConsoleLoginOptions {
|
|
33
|
+
/** Renown server URL */
|
|
34
|
+
renownUrl: string;
|
|
35
|
+
/**
|
|
36
|
+
* Opens the sign-in page somewhere the person can use it. The page stays
|
|
37
|
+
* there: this side only polls, so no redirect has to find its way back.
|
|
38
|
+
*/
|
|
39
|
+
open: (url: string) => void | Promise<void>;
|
|
40
|
+
/** Timeout in milliseconds. Defaults to 5 minutes. */
|
|
32
41
|
timeoutMs?: number;
|
|
42
|
+
/** Called with the login URL and session ID before it is opened */
|
|
43
|
+
onLoginUrl?: (url: string, sessionId: string) => void;
|
|
44
|
+
/** Called on each poll tick while waiting for authentication */
|
|
45
|
+
onPollTick?: () => void;
|
|
46
|
+
/** Called when `open` failed; the flow goes on polling */
|
|
47
|
+
onOpenFailed?: (url: string) => void;
|
|
48
|
+
/** AbortSignal to cancel the login flow */
|
|
49
|
+
signal?: AbortSignal;
|
|
33
50
|
}
|
|
34
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Signs `renown`'s own key in through Renown's console session: opens the page
|
|
53
|
+
* for that key, polls until the person has finished, then logs in. It works
|
|
54
|
+
* from anywhere that can open a page and fetch, which is why a CLI and an app
|
|
55
|
+
* window with no popup both use it.
|
|
56
|
+
*/
|
|
57
|
+
declare function consoleLogin(renown: IRenown, options: ConsoleLoginOptions): Promise<User>;
|
|
35
58
|
//#endregion
|
|
36
59
|
//#region src/renown-builder.d.ts
|
|
37
60
|
interface RenownBuilderOptions {
|
|
@@ -122,6 +145,20 @@ declare function createLocalCredentialVerifier(execute: SwitchboardRequestFn, op
|
|
|
122
145
|
//#region src/profile.d.ts
|
|
123
146
|
declare const fetchRenownProfile: ProfileFetcher;
|
|
124
147
|
//#endregion
|
|
148
|
+
//#region src/signed-message.d.ts
|
|
149
|
+
declare const SIGNATURE_WINDOW_MS = 600000;
|
|
150
|
+
/** Canonical message a caller signs to authorize revoking `credentialId`. */
|
|
151
|
+
declare function revokeMessage(credentialId: string, timestamp: string): string;
|
|
152
|
+
/**
|
|
153
|
+
* Canonical message a caller signs to authorize a profile upsert. The payload
|
|
154
|
+
* is hashed (rather than embedded raw) so the signed message has a fixed
|
|
155
|
+
* shape regardless of field content.
|
|
156
|
+
*/
|
|
157
|
+
declare function profileMessage(address: string, profile: {
|
|
158
|
+
username?: string | null;
|
|
159
|
+
userImage?: string | null;
|
|
160
|
+
}, timestamp: string): Promise<string>;
|
|
161
|
+
//#endregion
|
|
125
162
|
//#region src/session.d.ts
|
|
126
163
|
/** Server-side view of an authenticated Renown session. */
|
|
127
164
|
interface RenownSession {
|
|
@@ -197,5 +234,6 @@ declare function assertIsAuthCredential(credential: VerifiedCredential): asserts
|
|
|
197
234
|
declare function createAuthBearerToken(chainId: number, networkId: string, address: string, issuer: Issuer, options?: CreateBearerTokenOptions): Promise<string>;
|
|
198
235
|
declare const getResolver: () => Resolver;
|
|
199
236
|
//#endregion
|
|
200
|
-
export {
|
|
201
|
-
|
|
237
|
+
export { BaseRenownBuilder as C, Renown as D, consoleLogin as E, RenownMemoryStorage as O, createLocalCredentialVerifier as S, ConsoleLoginOptions 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 };
|
|
238
|
+
export {};
|
|
239
|
+
//# sourceMappingURL=utils-K2mtcxhD.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-K2mtcxhD.d.ts","names":[],"sources":["../src/common.ts","../src/console-login.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,gBACjB,cAAc,mBACd;MA4BE;;MAKA;MAIA,QAtCY;MA0CZ,UAAM;MAIN,UAAM;MAIN,UAAM;MAIN;MAIA,kBAAc;EAkBZ,MAAM,kBAAkB,QAAQ;EAyBhC,OAAO,QAAQ,eAAe,QAAQ;EA4DtC,gBACJ,YAAY,gCACZ;IAAW;MACV,QAAQ;EAwHX,UAAM;EAQA,cAAc;EAuBd,kBAAkB;EAsCxB,GAAG,gBAAgB,cACjB,OAAO,GACP,WAAW,MAAM,aAAa;EAkC1B,kBAAkB,gBAAa,gBAlCL;EAsC1B,eAAe,SAAS,2BAAwB;;;;UCzdvC;;EAEf;;;;;EAKA,OAAO,uBAAuB;;EAE9B;;EAEA,cAAc,aAAa;;EAE3B;;EAEA,gBAAgB;;EAEhB,SAAS;;;;;;;;iBAqFW,aACpB,QAAQ,SACR,SAAS,sBACR,QAAQ;;;UChGM;EACf;EACA,UAAU;EACV,eAAe;EACf,SAAS;EACT,iBAAiB;EACjB;EACA;EACA,iBAAiB;;EAEjB;;;;;;;cAQW;;;;;EAcX,YAAY;;;;;EAQZ,YAAY,SAAS;;;;;EASrB,iBAAiB,cAAc;;;;;EAS/B,WAAW,QAAQ;;;;;;EAUnB,mBAAmB,gBAAgB;;;;;EASnC,YAAY;EAOZ,mBAAmB;EAOnB,YAAY;;;;;;;EAWZ,mBAAmB,gBAAgB;;;;;;EAU7B,SAAS,QAAQ;;;;SA2DhB,KAAK,SAAS,uBAAuB;;;;;KCrLlC,mBAAmB;EAC7B;EACA;EACA;MACI;UAEW;;EAEf,WAAW;;;;iBAKG,8BACd,SAAS,sBACT,UAAS,iCACR;;;cClBU,oBAAoB;;;cCMpB;;iBAiBG,cAAc,sBAAsB;;;;;;iBAS9B,eACpB,iBACA;EAAW;EAA0B;GACrC,oBACC;;;;UCjCc;;EAEf,MAAM;;EAEN;;EAEA;;;UAIe;EACf;EACA;;EAEA;EACA;EACA;;;UAIe;EACf;EACA,UAAU;;UAGK;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;EACf;EACA;EACA;;EAEA;;;iBAIc,6BACd,OAAO;iBAwBO,kBACd,gBACC;iBA+BmB,oBACpB,eACA,UAAS,6BACR,QAAQ;;;KCnGC;EACV;EAEA,UAAU,oBAAoB;EAC9B,QAAQ,oBAAoB;EAC5B,OAAO,oBAAoB;EAC3B,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,8 +1,8 @@
|
|
|
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-
|
|
2
|
-
|
|
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-CfSRJMyb.js";
|
|
3
2
|
//#region src/wallet/controller.d.ts
|
|
4
|
-
declare function isWalletRedirectReturn(search: string, metas: WalletAdapterMeta[]): boolean;
|
|
5
|
-
declare function resolveAdapters(descriptors: WalletAdapterDescriptor[] | undefined): Promise<WalletAdapter[]>;
|
|
3
|
+
export declare function isWalletRedirectReturn(search: string, metas: WalletAdapterMeta[]): boolean;
|
|
4
|
+
export declare function resolveAdapters(descriptors: WalletAdapterDescriptor[] | undefined): Promise<WalletAdapter[]>;
|
|
6
5
|
//#endregion
|
|
7
|
-
export { LoginMethod, WalletAdapter, WalletAdapterDescriptor, WalletAdapterFactory, WalletAdapterImpl, WalletAdapterMeta, WalletAdapterProvider, WalletController, WalletSession, WalletTheme, WalletThemeColors,
|
|
6
|
+
export { LoginMethod, WalletAdapter, WalletAdapterDescriptor, WalletAdapterFactory, WalletAdapterImpl, WalletAdapterMeta, WalletAdapterProvider, WalletController, WalletSession, WalletTheme, WalletThemeColors, normalizeWalletTheme };
|
|
7
|
+
export {};
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/wallet/controller.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/wallet/controller.ts"],"mappings":";;wBAQgB,uBACd,gBACA,OAAO;wBAUa,gBACpB,aAAa,wCACZ,QAAQ"}
|
package/dist/wallet/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as normalizeWalletTheme, t as LoginMethod } from "../types-
|
|
1
|
+
import { n as normalizeWalletTheme, t as LoginMethod } from "../types-Dwy6khXb.js";
|
|
2
2
|
//#region src/wallet/controller.ts
|
|
3
3
|
function isWalletRedirectReturn(search, metas) {
|
|
4
4
|
const params = new URLSearchParams(search);
|
package/dist/wallet/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/wallet/controller.ts"],"sourcesContent":["import type {\n WalletAdapter,\n WalletAdapterDescriptor,\n WalletAdapterMeta,\n} from \"./types.js\";\n\n// True when a URL search string looks like a wallet OAuth redirect return, per\n// each adapter's own declared params — no adapter-specific strings live here.\nexport function isWalletRedirectReturn(\n search: string,\n metas: WalletAdapterMeta[],\n): boolean {\n const params = new URLSearchParams(search);\n return metas.some((meta) =>\n meta.redirectReturnParams.some((param) => params.has(param)),\n );\n}\n\n// Load the descriptors the host passed in, pairing each resolved implementation\n// with its already-eager meta so identity is declared in exactly one place.\nexport async function resolveAdapters(\n descriptors: WalletAdapterDescriptor[] | undefined,\n): Promise<WalletAdapter[]> {\n if (!descriptors || descriptors.length === 0) return [];\n // allSettled, not all: one broken loader must not take the others down.\n const settled = await Promise.allSettled(\n descriptors.map((descriptor) => descriptor.load()),\n );\n\n const adapters: WalletAdapter[] = [];\n const failures: string[] = [];\n settled.forEach((result, index) => {\n const { meta } = descriptors[index];\n if (result.status === \"fulfilled\") {\n adapters.push({ ...result.value, meta });\n } else {\n failures.push(`${meta.id}: ${describeError(result.reason)}`);\n }\n });\n\n if (adapters.length === 0) {\n throw new Error(\n `No wallet adapter could be loaded. ${failures.join(\"; \")}`,\n );\n }\n if (failures.length > 0) {\n console.error(\n `[renown] Some wallet adapters failed to load. ${failures.join(\"; \")}`,\n );\n }\n return adapters;\n}\n\nfunction describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;AAQA,SAAgB,uBACd,QACA,OACS;CACT,MAAM,SAAS,IAAI,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/wallet/controller.ts"],"sourcesContent":["import type {\n WalletAdapter,\n WalletAdapterDescriptor,\n WalletAdapterMeta,\n} from \"./types.js\";\n\n// True when a URL search string looks like a wallet OAuth redirect return, per\n// each adapter's own declared params — no adapter-specific strings live here.\nexport function isWalletRedirectReturn(\n search: string,\n metas: WalletAdapterMeta[],\n): boolean {\n const params = new URLSearchParams(search);\n return metas.some((meta) =>\n meta.redirectReturnParams.some((param) => params.has(param)),\n );\n}\n\n// Load the descriptors the host passed in, pairing each resolved implementation\n// with its already-eager meta so identity is declared in exactly one place.\nexport async function resolveAdapters(\n descriptors: WalletAdapterDescriptor[] | undefined,\n): Promise<WalletAdapter[]> {\n if (!descriptors || descriptors.length === 0) return [];\n // allSettled, not all: one broken loader must not take the others down.\n const settled = await Promise.allSettled(\n descriptors.map((descriptor) => descriptor.load()),\n );\n\n const adapters: WalletAdapter[] = [];\n const failures: string[] = [];\n settled.forEach((result, index) => {\n const { meta } = descriptors[index];\n if (result.status === \"fulfilled\") {\n adapters.push({ ...result.value, meta });\n } else {\n failures.push(`${meta.id}: ${describeError(result.reason)}`);\n }\n });\n\n if (adapters.length === 0) {\n throw new Error(\n `No wallet adapter could be loaded. ${failures.join(\"; \")}`,\n );\n }\n if (failures.length > 0) {\n console.error(\n `[renown] Some wallet adapters failed to load. ${failures.join(\"; \")}`,\n );\n }\n return adapters;\n}\n\nfunction describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;AAQA,SAAgB,uBACd,QACA,OACS;CACT,MAAM,SAAS,IAAI,gBAAgB,MAAM;CACzC,OAAO,MAAM,MAAM,SACjB,KAAK,qBAAqB,MAAM,UAAU,OAAO,IAAI,KAAK,CAAC,CAC7D;AACF;AAIA,eAAsB,gBACpB,aAC0B;CAC1B,IAAI,CAAC,eAAe,YAAY,WAAW,GAAG,OAAO,CAAC;CAEtD,MAAM,UAAU,MAAM,QAAQ,WAC5B,YAAY,KAAK,eAAe,WAAW,KAAK,CAAC,CACnD;CAEA,MAAM,WAA4B,CAAC;CACnC,MAAM,WAAqB,CAAC;CAC5B,QAAQ,SAAS,QAAQ,UAAU;EACjC,MAAM,EAAE,SAAS,YAAY;EAC7B,IAAI,OAAO,WAAW,aACpB,SAAS,KAAK;GAAE,GAAG,OAAO;GAAO;EAAK,CAAC;OAEvC,SAAS,KAAK,GAAG,KAAK,GAAG,IAAI,cAAc,OAAO,MAAM,GAAG;CAE/D,CAAC;CAED,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,MACR,sCAAsC,SAAS,KAAK,IAAI,GAC1D;CAEF,IAAI,SAAS,SAAS,GACpB,QAAQ,MACN,iDAAiD,SAAS,KAAK,IAAI,GACrE;CAEF,OAAO;AACT;AAEA,SAAS,cAAc,OAAwB;CAC7C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D"}
|