(value: string)
| 1336 | } |
| 1337 | |
| 1338 | function serializeToken(value: string): string { |
| 1339 | if (value.length === 0) { |
| 1340 | throw new TypeError("Token cannot be empty"); |
| 1341 | } |
| 1342 | |
| 1343 | const first = value[0]!; |
| 1344 | if (!isAlpha(first) && first !== "*") { |
| 1345 | throw new TypeError("Token must start with ALPHA or '*'"); |
| 1346 | } |
| 1347 | |
| 1348 | for (let i = 1; i < value.length; i++) { |
| 1349 | const c = value[i]!; |
| 1350 | if (!isTchar(c) && c !== ":" && c !== "/") { |
| 1351 | throw new TypeError(`Invalid character in token at position ${i}`); |
| 1352 | } |
| 1353 | } |
| 1354 | |
| 1355 | return value; |
| 1356 | } |
| 1357 | |
| 1358 | function serializeBinary(value: Uint8Array): string { |
| 1359 | return `:${encodeBase64(value)}:`; |
no test coverage detected