Suite of AT Protocol TypeScript libraries built on web standards
21
fork

Configure Feed

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

at main 65 lines 1.6 kB view raw
1/** 2 * # AT Protocol Syntax Validation 3 * 4 * Validation utilities for AT Protocol strings: 5 * - DIDs 6 * - Handles 7 * - NSIDs 8 * - AT URIs 9 * - TIDs 10 * - Record Keys 11 * - Datetimes 12 * 13 * @example Handles 14 * ```typescript 15 * import { isValidHandle, ensureValidHandle, isValidDid } from '@atp/syntax' 16 * 17 * isValidHandle('alice.test') // returns true 18 * ensureValidHandle('alice.test') // returns void 19 * 20 * isValidHandle('al!ce.test') // returns false 21 * ensureValidHandle('al!ce.test') // throws an error 22 * ``` 23 * 24 * @example NSIDs 25 * ```typescript 26 * import { NSID } from '@atp/syntax' 27 * 28 * const id1 = NSID.parse('com.example.foo') 29 * id1.authority // => 'example.com' 30 * id1.name // => 'foo' 31 * id1.toString() // => 'com.example.foo' 32 * 33 * const id2 = NSID.create('example.com', 'foo') 34 * id2.authority // => 'example.com' 35 * id2.name // => 'foo' 36 * id2.toString() // => 'com.example.foo' 37 * 38 * NSID.isValid('com.example.foo') // => true 39 * NSID.isValid('com.example.someThing') // => true 40 * NSID.isValid('example.com/foo') // => false 41 * NSID.isValid('foo') // => false 42 * ``` 43 * 44 * @example AT URIs 45 * ```typescript 46 * import { AtUri } from '@atp/syntax' 47 * 48 * const uri = new AtUri('at://bob.com/com.example.post/1234') 49 * uri.protocol // => 'at:' 50 * uri.origin // => 'at://bob.com' 51 * uri.hostname // => 'bob.com' 52 * uri.collection // => 'com.example.post' 53 * uri.rkey // => '1234' 54 * ``` 55 * 56 * @module 57 */ 58 59export * from "./handle.ts"; 60export * from "./did.ts"; 61export * from "./nsid.ts"; 62export * from "./aturi.ts"; 63export * from "./tid.ts"; 64export * from "./recordkey.ts"; 65export * from "./datetime.ts";