@atproto/tap 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,89 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import {
3
- assureAdminAuth,
4
- formatAdminAuthHeader,
5
- parseAdminAuthHeader,
6
- } from '../src/index.js'
7
-
8
- describe('util', () => {
9
- describe('formatAdminAuthHeader', () => {
10
- it('formats password as Basic auth header', () => {
11
- const header = formatAdminAuthHeader('secret')
12
- expect(header).toBe('Basic YWRtaW46c2VjcmV0')
13
- })
14
-
15
- it('uses admin as username', () => {
16
- const header = formatAdminAuthHeader('secret')
17
- const decoded = Buffer.from(
18
- header.replace('Basic ', ''),
19
- 'base64',
20
- ).toString()
21
- expect(decoded).toBe('admin:secret')
22
- })
23
- })
24
-
25
- describe('parseAdminAuthHeader', () => {
26
- it('parses Basic auth header and returns password', () => {
27
- const header = 'Basic YWRtaW46c2VjcmV0' // admin:secret
28
- const password = parseAdminAuthHeader(header)
29
- expect(password).toBe('secret')
30
- })
31
-
32
- it('handles header without Basic prefix', () => {
33
- const header = 'YWRtaW46c2VjcmV0' // admin:secret (no prefix)
34
- const password = parseAdminAuthHeader(header)
35
- expect(password).toBe('secret')
36
- })
37
-
38
- it('throws if username is not admin', () => {
39
- const header = 'Basic ' + Buffer.from('user:secret').toString('base64')
40
- expect(() => parseAdminAuthHeader(header)).toThrow(
41
- "Unexpected username in admin headers. Expected 'admin'",
42
- )
43
- })
44
- })
45
-
46
- describe('assureAdminAuth', () => {
47
- it('does not throw when password matches', () => {
48
- const header = formatAdminAuthHeader('secret')
49
- expect(() => assureAdminAuth('secret', header)).not.toThrow()
50
- })
51
-
52
- it('throws when password does not match', () => {
53
- const header = formatAdminAuthHeader('wrong')
54
- expect(() => assureAdminAuth('secret', header)).toThrow(
55
- 'Invalid admin password',
56
- )
57
- })
58
-
59
- it('throws when header has invalid username', () => {
60
- const header =
61
- 'Basic ' + Buffer.from('notadmin:secret').toString('base64')
62
- expect(() => assureAdminAuth('secret', header)).toThrow()
63
- })
64
-
65
- it('is timing-safe (does not leak password length)', () => {
66
- // This is a basic sanity check - true timing attack tests require statistical analysis
67
- const header = formatAdminAuthHeader('a')
68
- const start1 = performance.now()
69
- try {
70
- assureAdminAuth('b', header)
71
- } catch {
72
- // do nothing
73
- }
74
- const time1 = performance.now() - start1
75
-
76
- const longHeader = formatAdminAuthHeader('a'.repeat(1000))
77
- const start2 = performance.now()
78
- try {
79
- assureAdminAuth('b'.repeat(1000), longHeader)
80
- } catch {
81
- // do nothing
82
- }
83
- const time2 = performance.now() - start2
84
-
85
- // Times should be in the same order of magnitude (not a rigorous test)
86
- expect(Math.abs(time1 - time2)).toBeLessThan(50)
87
- })
88
- })
89
- })
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig/node.json",
3
- "compilerOptions": {
4
- "noImplicitAny": true,
5
- "rootDir": "./src",
6
- "outDir": "./dist",
7
- },
8
- "include": ["./src"],
9
- }
@@ -1 +0,0 @@
1
- {"version":"7.0.0-dev.20260614.1","root":["./src/channel.ts","./src/client.ts","./src/index.ts","./src/lex-indexer.ts","./src/simple-indexer.ts","./src/types.ts","./src/util.ts"]}
package/tsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "include": [],
3
- "references": [
4
- { "path": "./tsconfig.build.json" },
5
- { "path": "./tsconfig.tests.json" },
6
- ],
7
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig/vitest.json",
3
- "include": ["./tests", "./src/**/*.test.ts"],
4
- "compilerOptions": {
5
- "noImplicitAny": true,
6
- "rootDir": "./",
7
- },
8
- }
package/vitest.config.ts DELETED
@@ -1,5 +0,0 @@
1
- import { defineProject } from 'vitest/config'
2
-
3
- export default defineProject({
4
- test: {},
5
- })