handy online tools for AT Protocol boat.kelinci.net
atproto bluesky atcute typescript solidjs
20
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: wah

Mary 71535b79 6e09467b

+30 -36
+29 -12
src/api/types/plc.ts
··· 70 70 type: v.string(), 71 71 endpoint: urlString, 72 72 }), 73 - v.forward( 74 - v.check((input) => { 75 - switch (input.type) { 76 - case 'AtprotoPersonalDataServer': 77 - case 'AtprotoLabeler': 78 - case 'BskyFeedGenerator': 79 - case 'BskyNotificationService': 80 - return v.is(serviceUrlString, input.endpoint); 73 + v.rawTransform(({ dataset, addIssue, NEVER }) => { 74 + const input = dataset.value; 75 + 76 + switch (input.type) { 77 + case 'AtprotoPersonalDataServer': 78 + case 'AtprotoLabeler': 79 + case 'BskyFeedGenerator': 80 + case 'BskyNotificationService': { 81 + if (!v.is(serviceUrlString, input.endpoint)) { 82 + addIssue({ 83 + message: `must be a valid atproto service endpoint`, 84 + path: [ 85 + { 86 + type: 'object', 87 + origin: 'value', 88 + input: input, 89 + key: 'endpoint', 90 + value: input.endpoint, 91 + }, 92 + ], 93 + }); 94 + 95 + return NEVER; 96 + } 97 + 98 + return { ...input, endpoint: input.endpoint.replace(/\/$/, '') }; 81 99 } 100 + } 82 101 83 - return true; 84 - }, 'must be a valid atproto service endpoint'), 85 - ['endpoint'], 86 - ), 102 + return input; 103 + }), 87 104 ), 88 105 ), 89 106 });
+1 -1
src/api/utils/strings.ts
··· 1 1 import type { At, Records } from '@atcute/client/lexicons'; 2 2 3 - import { assert } from '../../lib/utils/invariant'; 3 + import { assert } from '~/lib/utils/invariant'; 4 4 5 5 export const ATURI_RE = 6 6 /^at:\/\/(did:[a-zA-Z0-9._:%\-]+|[a-zA-Z0-9-.]+)\/([a-zA-Z0-9-.]+)\/([a-zA-Z0-9._~:@!$&%')(*+,;=\-]+)(?:#(\/[a-zA-Z0-9._~:@!$&%')(*+,;=\-[\]/\\]*))?$/;
-23
tests/plc.test.ts
··· 1 - import { describe, it, expect } from 'bun:test'; 2 - 3 - import * as v from 'valibot'; 4 - 5 - import { updatePayload, PlcUpdatePayload } from '../src/api/types/plc.ts'; 6 - 7 - describe('update payload', () => { 8 - it('does not allow atproto service endpoints containing paths', () => { 9 - const payload: PlcUpdatePayload = { 10 - alsoKnownAs: [], 11 - rotationKeys: ['did:key:zQ3shhCGUqDKjStzuDxPkTxN6ujddP4RkEKJJouJGRRkaLGbg'], 12 - verificationMethods: {}, 13 - services: { 14 - atproto_pds: { 15 - type: 'AtprotoPersonalDataServer', 16 - endpoint: 'https://pds.test/hello', 17 - }, 18 - }, 19 - }; 20 - 21 - expect(() => v.assert(updatePayload, payload)).toThrow(/must be a valid atproto service endpoint/); 22 - }); 23 - });