Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isolated modules and almost isolated declarations #486

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions api/docs/tough-cookie.prefixsecurityenum.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ The following values can be used to configure how a [CookieJar](./tough-cookie.c
**Signature:**

```typescript
PrefixSecurityEnum: Readonly<{
SILENT: "silent";
STRICT: "strict";
DISABLED: "unsafe-disabled";
}>
PrefixSecurityEnum: {
readonly SILENT: "silent";
readonly STRICT: "strict";
readonly DISABLED: "unsafe-disabled";
}
```
10 changes: 5 additions & 5 deletions api/tough-cookie.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ export function permuteDomain(domain: string, allowSpecialUseDomain?: boolean):
export function permutePath(path: string): string[];

// @public
export const PrefixSecurityEnum: Readonly<{
SILENT: "silent";
STRICT: "strict";
DISABLED: "unsafe-disabled";
}>;
export const PrefixSecurityEnum: {
readonly SILENT: "silent";
readonly STRICT: "strict";
readonly DISABLED: "unsafe-disabled";
};

// @public
export type SerializedCookie = {
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/data/dates/bsd-examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@ export default [
test: 'IAintNoDateFool',
expected: null,
},
]
] as const
2 changes: 1 addition & 1 deletion lib/__tests__/data/dates/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ export default [
test: 'Thu, 10 Dec 2009 13:57:2 GMT',
expected: 'Thu, 10 Dec 2009 13:57:02 GMT',
},
]
] as const
2 changes: 1 addition & 1 deletion lib/__tests__/data/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1330,4 +1330,4 @@ export default [
received: ['\tfoo\t=\tbar\t \t;\tttt'],
sent: [{ name: 'foo', value: 'bar' }],
},
]
] as const
7 changes: 4 additions & 3 deletions lib/__tests__/ietf.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ describe('IETF http state tests', () => {
const jar = new CookieJar()
const expected = testCase.sent
const sentFrom = `http://home.example.org/cookie-parser?${testCase.test}`
const sentTo = testCase['sent-to']
? url.resolve('http://home.example.org', testCase['sent-to'])
: `http://home.example.org/cookie-parser-result?${testCase.test}`
const sentTo =
'sent-to' in testCase
? url.resolve('http://home.example.org', testCase['sent-to'])
: `http://home.example.org/cookie-parser-result?${testCase.test}`

testCase['received'].forEach((cookieStr) => {
jar.setCookieSync(cookieStr, sentFrom, { ignoreError: true })
Expand Down
7 changes: 4 additions & 3 deletions lib/cookie/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
* - `unsafe-disabled` - Disables cookie prefix checking.
* @public
*/
export const PrefixSecurityEnum = Object.freeze({
export const PrefixSecurityEnum = {
SILENT: 'silent',
STRICT: 'strict',
DISABLED: 'unsafe-disabled',
})
} as const
Object.freeze(PrefixSecurityEnum)

const IP_V6_REGEX = `
\\[?(?:
Expand All @@ -32,7 +33,7 @@ const IP_V6_REGEX = `
.replace(/\s*\/\/.*$/gm, '')
.replace(/\n/g, '')
.trim()
export const IP_V6_REGEX_OBJECT = new RegExp(`^${IP_V6_REGEX}$`)
export const IP_V6_REGEX_OBJECT: RegExp = new RegExp(`^${IP_V6_REGEX}$`)

/**
* A JSON representation of a {@link CookieJar}.
Expand Down
25 changes: 16 additions & 9 deletions lib/cookie/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
export { MemoryCookieStore, MemoryCookieStoreIndex } from '../memstore'
export { MemoryCookieStore, type MemoryCookieStoreIndex } from '../memstore'
export { pathMatch } from '../pathMatch'
export { permuteDomain } from '../permuteDomain'
export { getPublicSuffix, GetPublicSuffixOptions } from '../getPublicSuffix'
export {
getPublicSuffix,
type GetPublicSuffixOptions,
} from '../getPublicSuffix'
export { Store } from '../store'
export { ParameterError } from '../validators'
export { version } from '../version'
export { Callback, ErrorCallback, Nullable } from '../utils'
export { type Callback, type ErrorCallback, type Nullable } from '../utils'
export { canonicalDomain } from './canonicalDomain'
export {
PrefixSecurityEnum,
SerializedCookie,
SerializedCookieJar,
type SerializedCookie,
type SerializedCookieJar,
} from './constants'
export { Cookie, CreateCookieOptions, ParseCookieOptions } from './cookie'
export {
Cookie,
type CreateCookieOptions,
type ParseCookieOptions,
} from './cookie'
export { cookieCompare } from './cookieCompare'
export {
CookieJar,
CreateCookieJarOptions,
GetCookiesOptions,
SetCookieOptions,
type CreateCookieJarOptions,
type GetCookiesOptions,
type SetCookieOptions,
} from './cookieJar'
export { defaultPath } from './defaultPath'
export { domainMatch } from './domainMatch'
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"allowUnusedLabels": false,
"allowUnreachableCode": false,
/* Compatibility */
"ignoreDeprecations": "5.0"
"ignoreDeprecations": "5.0",
"isolatedModules": true
},
"include": ["lib"],
"exclude": ["jest.config.ts"]
Expand Down