Skip to content

Commit

Permalink
fix: validate agent name (#271)
Browse files Browse the repository at this point in the history
Cannot put `undefined` in UCANs
  • Loading branch information
Alan Shaw authored Dec 8, 2022
1 parent fe9ebd1 commit 5a1fdb2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/access-client/src/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,16 @@ export class Agent {
expiration: Infinity,
})

const meta = { name, isRegistered: false }
/** @type {import('./types').SpaceMeta} */
const meta = { isRegistered: false }
// eslint-disable-next-line eqeqeq
if (name != undefined) {
if (typeof name !== 'string') {
throw new TypeError('invalid name')
}
meta.name = name
}

await this.#data.addSpace(signer.did(), meta, proof)

return {
Expand Down

0 comments on commit 5a1fdb2

Please sign in to comment.