diff --git a/src/controllers/api/oauth.ts b/src/controllers/api/oauth.ts index b4a7a405..fb23c1c8 100644 --- a/src/controllers/api/oauth.ts +++ b/src/controllers/api/oauth.ts @@ -1,4 +1,4 @@ -import { lodash, nip19, nip21, z } from '@/deps.ts'; +import { lodash, nip19, z } from '@/deps.ts'; import { AppController } from '@/app.ts'; import { parseBody } from '@/utils.ts'; @@ -96,7 +96,7 @@ function maybeDecodeUri(uri: string): string { const oauthAuthorizeSchema = z.object({ pubkey: z.string().regex(/^[0-9a-f]{64}$/).optional().catch(undefined), - nip19: z.string().regex(new RegExp(`^${nip21.BECH32_REGEX.source}$`)).optional().catch(undefined), + nip19: z.string().regex(new RegExp(`^${nip19.BECH32_REGEX.source}$`)).optional().catch(undefined), redirect_uri: z.string().url(), }).superRefine((data, ctx) => { if (!data.pubkey && !data.nip19) { diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index 24ad1c6e..c6dcf64b 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -1,5 +1,5 @@ import { AppController } from '@/app.ts'; -import { nip21 } from '@/deps.ts'; +import { nip19 } from '@/deps.ts'; import { signStreams } from '@/sign.ts'; const streamingController: AppController = (c) => { @@ -17,7 +17,7 @@ const streamingController: AppController = (c) => { return c.json({ error: 'Missing access token' }, 401); } - if (!nip21.BECH32_REGEX.test(token)) { + if (!nip19.BECH32_REGEX.test(token)) { return c.json({ error: 'Invalid access token' }, 401); } diff --git a/src/deps.ts b/src/deps.ts index c9fc1362..e9fa5c6b 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -20,7 +20,7 @@ export { nip19, nip21, signEvent as getSignature, -} from 'npm:nostr-tools@^1.10.1'; +} from 'npm:nostr-tools@^1.11.1'; export { findReplyTag } from 'https://gitlab.com/soapbox-pub/mostr/-/raw/c67064aee5ade5e01597c6d23e22e53c628ef0e2/src/nostr/tags.ts'; export { parseFormData } from 'npm:formdata-helper@^0.3.0'; // @deno-types="npm:@types/lodash@4.14.194" diff --git a/src/transmute.ts b/src/transmute.ts index 397fc6e9..898f6543 100644 --- a/src/transmute.ts +++ b/src/transmute.ts @@ -1,4 +1,4 @@ -import { findReplyTag, lodash, nip19, nip21, TTLCache, unfurl, z } from '@/deps.ts'; +import { findReplyTag, lodash, nip19, TTLCache, unfurl, z } from '@/deps.ts'; import { type Event } from '@/event.ts'; import { emojiTagSchema, filteredArray, type MetaContent, parseMetaContent } from '@/schema.ts'; @@ -151,7 +151,7 @@ function buildInlineRecipients(mentions: Mention[]): string { if (!mentions.length) return ''; const elements = mentions.reduce((acc, { url, username }) => { - const name = nip21.BECH32_REGEX.test(username) ? username.substring(0, 8) : username; + const name = nip19.BECH32_REGEX.test(username) ? username.substring(0, 8) : username; acc.push(`@${name}`); return acc; }, []); diff --git a/src/utils.ts b/src/utils.ts index 4f821702..b78f0fea 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,5 @@ import { getAuthor } from '@/client.ts'; -import { Context, getPublicKey, nip19, nip21, parseFormData } from '@/deps.ts'; +import { Context, getPublicKey, nip19, parseFormData } from '@/deps.ts'; import { type Event } from '@/event.ts'; import { lookupNip05Cached } from '@/nip05.ts'; @@ -25,7 +25,7 @@ function getKeys(c: Context) { /** Return true if the value is a bech32 string, eg for use with NIP-19. */ function isBech32(value: unknown): value is string { - return typeof value === 'string' && nip21.BECH32_REGEX.test(value); + return typeof value === 'string' && nip19.BECH32_REGEX.test(value); } /** Return true if the value is a Nostr pubkey, private key, or event ID. */