Skip to content

add urn:said pre-processing support - #14

Merged
kentbull merged 1 commit into
kentbull:mainfrom
setayesh78:feat/urn-said
Jul 2, 2026
Merged

add urn:said pre-processing support#14
kentbull merged 1 commit into
kentbull:mainfrom
setayesh78:feat/urn-said

Conversation

@setayesh78

Copy link
Copy Markdown
Contributor

Summary

  • Add pre-processing urn:said: prefix to saidify/verify
  • Preserve serialized field length (53 chars for 256-bit SAIDs)
  • Add saidifyUrn/verifyUrn convenience wrappers

Test plan

  • npm test (29 tests pass)

@kentbull kentbull left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll approve your PR and then make the suggested changes.

Comment thread src/lib/core.ts
const [raw, sad] = deriveSAIDBytes(data, code, kind, label)
const said = qb64(raw, code)
const [raw, sad] = deriveSAIDBytes(data, code, kind, label, prefix)
const said = prefix + qb64(raw, code)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exposing that I took a shortcut for SAIDification by setting a property value rather than doing a string replace of the 44 pound sign # characters with the SAID. The code you wrote would work, yet let's be explicit and separate the SAID out from the finalized label that includes the prefix.

Change this so that the said var is still qb64(raw, code) and a new label var is used where:

  • if prefix is defined
    • label is set to prefix + label
    • otherwise label is said

This should be good enough for now.

Comment thread src/lib/core.ts
label: string = 'd',
code: string = SAIDDex.Blake3_256,
kind: Serials = Serials.JSON,
prefix: string = ``,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the single apostrophe quote here instead of backticks so we use the simplest tool possible.

Comment thread src/lib/core.ts
kind: Serials = Serials.JSON,
prefixed: boolean = false,
versioned: boolean = false,
prefix: string = ``,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the single apostrophe quote here instead of backticks so we use the simplest tool possible.

Comment thread src/lib/core.ts
// code = detectCode(data)
const [raw, derivedSad] = deriveSAIDBytes(sad, code, kind, label)
const [raw, derivedSad] = deriveSAIDBytes(sad, code, kind, label, prefix)
const computed = prefix + qb64(raw, code)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, here, where you have the computed const put the qb64(raw, code) into a said var and then use the same if (prefixed && prefix) check like above to construct the prefixed label.

@kentbull
kentbull merged commit decae78 into kentbull:main Jul 2, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants