@atproto/oauth-types 0.7.3 → 0.7.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.
- package/CHANGELOG.md +24 -0
- package/dist/atproto-loopback-client-id.d.ts +3 -3
- package/dist/atproto-loopback-client-id.d.ts.map +1 -1
- package/dist/atproto-loopback-client-id.js.map +1 -1
- package/dist/atproto-loopback-client-metadata.d.ts +5 -5
- package/dist/atproto-loopback-client-metadata.d.ts.map +1 -1
- package/dist/atproto-loopback-client-metadata.js.map +1 -1
- package/dist/atproto-oauth-scope.d.ts +2 -2
- package/dist/atproto-oauth-scope.d.ts.map +1 -1
- package/dist/atproto-oauth-scope.js.map +1 -1
- package/dist/atproto-oauth-token-response.d.ts +1 -1
- package/dist/atproto-oauth-token-response.d.ts.map +1 -1
- package/dist/atproto-oauth-token-response.js.map +1 -1
- package/dist/oauth-client-id-discoverable.d.ts +1 -1
- package/dist/oauth-client-id-discoverable.d.ts.map +1 -1
- package/dist/oauth-client-id-discoverable.js.map +1 -1
- package/dist/oauth-client-id-loopback.d.ts +2 -2
- package/dist/oauth-client-id-loopback.d.ts.map +1 -1
- package/dist/oauth-client-id-loopback.js.map +1 -1
- package/dist/oauth-introspection-response.d.ts +2 -2
- package/dist/oauth-introspection-response.d.ts.map +1 -1
- package/dist/oauth-introspection-response.js.map +1 -1
- package/dist/oauth-redirect-uri.d.ts +1 -1
- package/dist/oauth-redirect-uri.d.ts.map +1 -1
- package/dist/oauth-redirect-uri.js.map +1 -1
- package/dist/uri.d.ts +1 -1
- package/dist/uri.d.ts.map +1 -1
- package/dist/uri.js.map +1 -1
- package/dist/util.d.ts +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js.map +1 -1
- package/package.json +11 -7
- package/src/atproto-loopback-client-id.ts +0 -78
- package/src/atproto-loopback-client-metadata.ts +0 -47
- package/src/atproto-loopback-client-redirect-uris.ts +0 -4
- package/src/atproto-oauth-scope.ts +0 -34
- package/src/atproto-oauth-token-response.ts +0 -16
- package/src/constants.ts +0 -2
- package/src/index.ts +0 -50
- package/src/oauth-access-token.ts +0 -4
- package/src/oauth-authorization-code-grant-token-request.ts +0 -19
- package/src/oauth-authorization-details.ts +0 -48
- package/src/oauth-authorization-request-jar.ts +0 -16
- package/src/oauth-authorization-request-par.ts +0 -12
- package/src/oauth-authorization-request-parameters.ts +0 -100
- package/src/oauth-authorization-request-query.ts +0 -21
- package/src/oauth-authorization-request-uri.ts +0 -10
- package/src/oauth-authorization-response-error.ts +0 -25
- package/src/oauth-authorization-server-metadata.ts +0 -120
- package/src/oauth-client-credentials-grant-token-request.ts +0 -9
- package/src/oauth-client-credentials.ts +0 -53
- package/src/oauth-client-id-discoverable.ts +0 -130
- package/src/oauth-client-id-loopback.ts +0 -164
- package/src/oauth-client-id.ts +0 -4
- package/src/oauth-client-metadata.ts +0 -80
- package/src/oauth-code-challenge-method.ts +0 -3
- package/src/oauth-endpoint-auth-method.ts +0 -13
- package/src/oauth-endpoint-name.ts +0 -8
- package/src/oauth-grant-type.ts +0 -13
- package/src/oauth-introspection-response.ts +0 -23
- package/src/oauth-issuer-identifier.ts +0 -47
- package/src/oauth-par-response.ts +0 -8
- package/src/oauth-password-grant-token-request.ts +0 -11
- package/src/oauth-prompt-mode.ts +0 -18
- package/src/oauth-protected-resource-metadata.ts +0 -94
- package/src/oauth-redirect-uri.ts +0 -73
- package/src/oauth-refresh-token-grant-token-request.ts +0 -11
- package/src/oauth-refresh-token.ts +0 -4
- package/src/oauth-request-uri.ts +0 -5
- package/src/oauth-response-mode.ts +0 -9
- package/src/oauth-response-type.ts +0 -17
- package/src/oauth-scope.ts +0 -21
- package/src/oauth-token-identification.ts +0 -12
- package/src/oauth-token-request.ts +0 -14
- package/src/oauth-token-response.ts +0 -29
- package/src/oauth-token-type.ts +0 -15
- package/src/oidc-authorization-error-response.ts +0 -29
- package/src/oidc-claims-parameter.ts +0 -40
- package/src/oidc-claims-properties.ts +0 -11
- package/src/oidc-entity-type.ts +0 -5
- package/src/oidc-userinfo.ts +0 -15
- package/src/uri.ts +0 -221
- package/src/util.ts +0 -170
- package/tsconfig.build.json +0 -8
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -4
package/src/util.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
export const canParseUrl =
|
|
2
|
-
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
3
|
-
URL.canParse?.bind(URL) ??
|
|
4
|
-
// URL.canParse is not available in Node.js < 18.7.0
|
|
5
|
-
((urlStr: string): boolean => {
|
|
6
|
-
try {
|
|
7
|
-
new URL(urlStr)
|
|
8
|
-
return true
|
|
9
|
-
} catch {
|
|
10
|
-
return false
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
export function isHostnameIP(hostname: string) {
|
|
15
|
-
// IPv4
|
|
16
|
-
if (hostname.match(/^\d+\.\d+\.\d+\.\d+$/)) return true
|
|
17
|
-
|
|
18
|
-
// IPv6
|
|
19
|
-
if (hostname.startsWith('[') && hostname.endsWith(']')) return true
|
|
20
|
-
|
|
21
|
-
return false
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type LoopbackHost = 'localhost' | '127.0.0.1' | '[::1]'
|
|
25
|
-
|
|
26
|
-
export function isLoopbackHost(host: unknown): host is LoopbackHost {
|
|
27
|
-
return host === 'localhost' || host === '127.0.0.1' || host === '[::1]'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function isLocalHostname(hostname: string): boolean {
|
|
31
|
-
const parts = hostname.split('.')
|
|
32
|
-
if (parts.length < 2) return true
|
|
33
|
-
|
|
34
|
-
const tld = parts.at(-1)!.toLowerCase()
|
|
35
|
-
return (
|
|
36
|
-
tld === 'test' ||
|
|
37
|
-
tld === 'local' ||
|
|
38
|
-
tld === 'localhost' ||
|
|
39
|
-
tld === 'invalid' ||
|
|
40
|
-
tld === 'example'
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function safeUrl(input: URL | string): URL | null {
|
|
45
|
-
try {
|
|
46
|
-
return new URL(input)
|
|
47
|
-
} catch {
|
|
48
|
-
return null
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function extractUrlPath(url) {
|
|
53
|
-
// Extracts the path from a URL, without relying on the URL constructor
|
|
54
|
-
// (because it normalizes the URL)
|
|
55
|
-
const endOfProtocol = url.startsWith('https://')
|
|
56
|
-
? 8
|
|
57
|
-
: url.startsWith('http://')
|
|
58
|
-
? 7
|
|
59
|
-
: -1
|
|
60
|
-
if (endOfProtocol === -1) {
|
|
61
|
-
throw new TypeError('URL must use the "https:" or "http:" protocol')
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const hashIdx = url.indexOf('#', endOfProtocol)
|
|
65
|
-
const questionIdx = url.indexOf('?', endOfProtocol)
|
|
66
|
-
|
|
67
|
-
const queryStrIdx =
|
|
68
|
-
questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx)
|
|
69
|
-
? questionIdx
|
|
70
|
-
: -1
|
|
71
|
-
|
|
72
|
-
const pathEnd =
|
|
73
|
-
hashIdx === -1
|
|
74
|
-
? queryStrIdx === -1
|
|
75
|
-
? url.length
|
|
76
|
-
: queryStrIdx
|
|
77
|
-
: queryStrIdx === -1
|
|
78
|
-
? hashIdx
|
|
79
|
-
: Math.min(hashIdx, queryStrIdx)
|
|
80
|
-
|
|
81
|
-
const slashIdx = url.indexOf('/', endOfProtocol)
|
|
82
|
-
|
|
83
|
-
const pathStart = slashIdx === -1 || slashIdx > pathEnd ? pathEnd : slashIdx
|
|
84
|
-
|
|
85
|
-
if (endOfProtocol === pathStart) {
|
|
86
|
-
throw new TypeError('URL must contain a host')
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return url.substring(pathStart, pathEnd)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export const jsonObjectPreprocess = (val: unknown) => {
|
|
93
|
-
if (typeof val === 'string' && val.startsWith('{') && val.endsWith('}')) {
|
|
94
|
-
try {
|
|
95
|
-
return JSON.parse(val)
|
|
96
|
-
} catch {
|
|
97
|
-
return val
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return val
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export const numberPreprocess = (val: unknown): unknown => {
|
|
105
|
-
if (typeof val === 'string') {
|
|
106
|
-
const number = Number(val)
|
|
107
|
-
if (!Number.isNaN(number)) return number
|
|
108
|
-
}
|
|
109
|
-
return val
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Returns true if the two arrays contain the same elements, regardless of order
|
|
114
|
-
* or duplicates.
|
|
115
|
-
*/
|
|
116
|
-
export function arrayEquivalent<T>(a: readonly T[], b: readonly T[]) {
|
|
117
|
-
if (a === b) return true
|
|
118
|
-
return a.every(includedIn, b) && b.every(includedIn, a)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function includedIn<T>(this: readonly T[], item: T) {
|
|
122
|
-
return this.includes(item)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function asArray<T>(
|
|
126
|
-
value: Iterable<T> | undefined,
|
|
127
|
-
): undefined | readonly T[] {
|
|
128
|
-
if (value == null) return undefined
|
|
129
|
-
if (Array.isArray(value)) return value // already a (possibly readonly) array
|
|
130
|
-
return Array.from(value)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export type SpaceSeparatedValue<Value extends string> =
|
|
134
|
-
`${'' | `${string} `}${Value}${'' | ` ${string}`}`
|
|
135
|
-
|
|
136
|
-
export const isSpaceSeparatedValue = <Value extends string>(
|
|
137
|
-
value: Value,
|
|
138
|
-
input: string,
|
|
139
|
-
): input is SpaceSeparatedValue<Value> => {
|
|
140
|
-
if (value.length === 0) throw new TypeError('Value cannot be empty')
|
|
141
|
-
if (value.includes(' ')) throw new TypeError('Value cannot contain spaces')
|
|
142
|
-
|
|
143
|
-
// Optimized version of:
|
|
144
|
-
// return input.split(' ').includes(value)
|
|
145
|
-
|
|
146
|
-
const inputLength = input.length
|
|
147
|
-
const valueLength = value.length
|
|
148
|
-
|
|
149
|
-
if (inputLength < valueLength) return false
|
|
150
|
-
|
|
151
|
-
let idx = input.indexOf(value)
|
|
152
|
-
let idxEnd: number
|
|
153
|
-
|
|
154
|
-
while (idx !== -1) {
|
|
155
|
-
idxEnd = idx + valueLength
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
// at beginning or preceded by space
|
|
159
|
-
(idx === 0 || input.charCodeAt(idx - 1) === 32) &&
|
|
160
|
-
// at end or followed by space
|
|
161
|
-
(idxEnd === inputLength || input.charCodeAt(idxEnd) === 32)
|
|
162
|
-
) {
|
|
163
|
-
return true
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
idx = input.indexOf(value, idxEnd + 1)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return false
|
|
170
|
-
}
|
package/tsconfig.build.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"7.0.0-dev.20260614.1","root":["./src/atproto-loopback-client-id.ts","./src/atproto-loopback-client-metadata.ts","./src/atproto-loopback-client-redirect-uris.ts","./src/atproto-oauth-scope.ts","./src/atproto-oauth-token-response.ts","./src/constants.ts","./src/index.ts","./src/oauth-access-token.ts","./src/oauth-authorization-code-grant-token-request.ts","./src/oauth-authorization-details.ts","./src/oauth-authorization-request-jar.ts","./src/oauth-authorization-request-par.ts","./src/oauth-authorization-request-parameters.ts","./src/oauth-authorization-request-query.ts","./src/oauth-authorization-request-uri.ts","./src/oauth-authorization-response-error.ts","./src/oauth-authorization-server-metadata.ts","./src/oauth-client-credentials-grant-token-request.ts","./src/oauth-client-credentials.ts","./src/oauth-client-id-discoverable.ts","./src/oauth-client-id-loopback.ts","./src/oauth-client-id.ts","./src/oauth-client-metadata.ts","./src/oauth-code-challenge-method.ts","./src/oauth-endpoint-auth-method.ts","./src/oauth-endpoint-name.ts","./src/oauth-grant-type.ts","./src/oauth-introspection-response.ts","./src/oauth-issuer-identifier.ts","./src/oauth-par-response.ts","./src/oauth-password-grant-token-request.ts","./src/oauth-prompt-mode.ts","./src/oauth-protected-resource-metadata.ts","./src/oauth-redirect-uri.ts","./src/oauth-refresh-token-grant-token-request.ts","./src/oauth-refresh-token.ts","./src/oauth-request-uri.ts","./src/oauth-response-mode.ts","./src/oauth-response-type.ts","./src/oauth-scope.ts","./src/oauth-token-identification.ts","./src/oauth-token-request.ts","./src/oauth-token-response.ts","./src/oauth-token-type.ts","./src/oidc-authorization-error-response.ts","./src/oidc-claims-parameter.ts","./src/oidc-claims-properties.ts","./src/oidc-entity-type.ts","./src/oidc-userinfo.ts","./src/uri.ts","./src/util.ts"]}
|
package/tsconfig.json
DELETED