Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: delegations model tries to handle if row.bytes is Array not Buff…
…er (e.g. cloudflare) (#478) ## Rationale This is the error I get from staging atm (on `access/claim`) ``` claimResult { name: 'HandlerExecutionError', cause: { row: { cid: 'bafyreihqswtsrxvsp2pqf5a2jjiyb6zks3hynbfkhga7odwbat4ptxrf5e', bytes: [Array], issuer: 'did:mailto:dag.house:bengo', audience: 'did:key:z6MkkUymFxGqXWRqFNiaU4jCa2efexfDCNADqD7sQK3RbU2j', expiration: null, updated_at: '2023-03-03T16:41:54.999Z', inserted_at: '2023-03-03T16:41:54.999Z' }, name: 'UnexpectedDelegation', stack: 'UnexpectedDelegation: failed to create delegation from row\n' + ``` Notably `bytes` is `Array` here. Locally and in node.js, I think miniflare gives back a `Buffer` and (in nodejs) [this catches it](https://github.com/web3-storage/w3protocol/blob/660f773c5d52eaaba9b7177932edb0e92942dde7/packages/access-api/src/utils/d1.js#L77). But on cloudflare. This PR would cast the bytes column on delegations model to Uint8Array if the db/kysely hand it back as an Array. --------- Co-authored-by: Irakli Gozalishvili <contact@gozala.io>
- Loading branch information