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
alanshaw committed Dec 8, 2022
1 parent b6d7e75 commit cdccbd3
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 cdccbd3

Please sign in to comment.