@atproto/oauth-client 0.5.5 → 0.5.7

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/constants.js.map +1 -1
  3. package/dist/errors/auth-method-unsatisfiable-error.js.map +1 -1
  4. package/dist/errors/token-invalid-error.js.map +1 -1
  5. package/dist/errors/token-refresh-error.js.map +1 -1
  6. package/dist/errors/token-revoked-error.js.map +1 -1
  7. package/dist/fetch-dpop.js.map +1 -1
  8. package/dist/identity-resolver.js.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/lock.js.map +1 -1
  14. package/dist/oauth-authorization-server-metadata-resolver.js.map +1 -1
  15. package/dist/oauth-callback-error.js.map +1 -1
  16. package/dist/oauth-client-auth.d.ts.map +1 -1
  17. package/dist/oauth-client-auth.js +3 -4
  18. package/dist/oauth-client-auth.js.map +1 -1
  19. package/dist/oauth-client.d.ts +167 -139
  20. package/dist/oauth-client.d.ts.map +1 -1
  21. package/dist/oauth-client.js +1 -4
  22. package/dist/oauth-client.js.map +1 -1
  23. package/dist/oauth-protected-resource-metadata-resolver.js.map +1 -1
  24. package/dist/oauth-resolver-error.js.map +1 -1
  25. package/dist/oauth-resolver.js.map +1 -1
  26. package/dist/oauth-response-error.js.map +1 -1
  27. package/dist/oauth-server-agent.d.ts +4 -4
  28. package/dist/oauth-server-agent.d.ts.map +1 -1
  29. package/dist/oauth-server-agent.js +12 -77
  30. package/dist/oauth-server-agent.js.map +1 -1
  31. package/dist/oauth-server-factory.js.map +1 -1
  32. package/dist/oauth-session.d.ts +3 -3
  33. package/dist/oauth-session.d.ts.map +1 -1
  34. package/dist/oauth-session.js.map +1 -1
  35. package/dist/runtime-implementation.js.map +1 -1
  36. package/dist/runtime.js.map +1 -1
  37. package/dist/session-getter.d.ts +1 -1
  38. package/dist/session-getter.d.ts.map +1 -1
  39. package/dist/session-getter.js +2 -2
  40. package/dist/session-getter.js.map +1 -1
  41. package/dist/state-store.js.map +1 -1
  42. package/dist/types.d.ts +164 -1102
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/types.js.map +1 -1
  45. package/dist/util.d.ts +0 -8
  46. package/dist/util.d.ts.map +1 -1
  47. package/dist/util.js +22 -71
  48. package/dist/util.js.map +1 -1
  49. package/dist/validate-client-metadata.d.ts.map +1 -1
  50. package/dist/validate-client-metadata.js +14 -7
  51. package/dist/validate-client-metadata.js.map +1 -1
  52. package/package.json +9 -8
  53. package/src/index.ts +2 -0
  54. package/src/oauth-client-auth.ts +3 -5
  55. package/src/oauth-client.ts +1 -4
  56. package/src/oauth-server-agent.ts +9 -12
  57. package/src/oauth-session.ts +6 -3
  58. package/src/session-getter.ts +3 -3
  59. package/src/util.ts +22 -107
  60. package/src/validate-client-metadata.ts +26 -9
  61. package/tsconfig.build.tsbuildinfo +1 -1
  62. package/dist/atproto-token-response.d.ts +0 -110
  63. package/dist/atproto-token-response.d.ts.map +0 -1
  64. package/dist/atproto-token-response.js +0 -20
  65. package/dist/atproto-token-response.js.map +0 -1
  66. package/src/atproto-token-response.ts +0 -21
package/src/util.ts CHANGED
@@ -1,54 +1,8 @@
1
1
  export type Awaitable<T> = T | PromiseLike<T>
2
2
  export type Simplify<T> = { [K in keyof T]: T[K] } & NonNullable<unknown>
3
3
 
4
- // @ts-expect-error
5
- Symbol.dispose ??= Symbol('@@dispose')
6
-
7
4
  export const ifString = <V>(v: V) => (typeof v === 'string' ? v : undefined)
8
5
 
9
- /**
10
- * @todo (?) move to common package
11
- */
12
- export const timeoutSignal = (
13
- timeout: number,
14
- options?: { signal?: AbortSignal },
15
- ): AbortSignal & Disposable => {
16
- if (!Number.isInteger(timeout) || timeout < 0) {
17
- throw new TypeError('Expected a positive integer')
18
- }
19
-
20
- options?.signal?.throwIfAborted()
21
-
22
- const controller = new AbortController()
23
- const { signal } = controller
24
-
25
- options?.signal?.addEventListener(
26
- 'abort',
27
- (reason) => controller.abort(reason),
28
- { once: true, signal },
29
- )
30
-
31
- const timeoutId = setTimeout(
32
- (err) => controller.abort(err),
33
- timeout,
34
- // create Error here to keep original stack trace
35
- new Error('Timeout'),
36
- )
37
-
38
- timeoutId?.unref?.() // NodeJS only
39
-
40
- signal.addEventListener('abort', () => clearTimeout(timeoutId), {
41
- once: true,
42
- signal,
43
- })
44
-
45
- Object.defineProperty(signal, Symbol.dispose, {
46
- value: () => controller.abort(),
47
- })
48
-
49
- return signal as AbortSignal & Disposable
50
- }
51
-
52
6
  export function contentMime(headers: Headers): string | undefined {
53
7
  return headers.get('content-type')?.split(';')[0]!.trim()
54
8
  }
@@ -120,50 +74,10 @@ export class CustomEventTarget<EventDetailMap extends Record<string, unknown>> {
120
74
  }
121
75
  }
122
76
 
123
- export type SpaceSeparatedValue<Value extends string> =
124
- | `${Value}`
125
- | `${Value} ${string}`
126
- | `${string} ${Value}`
127
- | `${string} ${Value} ${string}`
128
-
129
- export const includesSpaceSeparatedValue = <Value extends string>(
130
- input: string,
131
- value: Value,
132
- ): input is SpaceSeparatedValue<Value> => {
133
- if (value.length === 0) throw new TypeError('Value cannot be empty')
134
- if (value.includes(' ')) throw new TypeError('Value cannot contain spaces')
135
-
136
- // Optimized version of:
137
- // return input.split(' ').includes(value)
138
-
139
- const inputLength = input.length
140
- const valueLength = value.length
141
-
142
- if (inputLength < valueLength) return false
143
-
144
- let idx = input.indexOf(value)
145
- let idxEnd: number
146
-
147
- while (idx !== -1) {
148
- idxEnd = idx + valueLength
149
-
150
- if (
151
- // at beginning or preceded by space
152
- (idx === 0 || input[idx - 1] === ' ') &&
153
- // at end or followed by space
154
- (idxEnd === inputLength || input[idxEnd] === ' ')
155
- ) {
156
- return true
157
- }
158
-
159
- idx = input.indexOf(value, idxEnd + 1)
160
- }
161
-
162
- return false
163
- }
164
-
165
- export function combineSignals(signals: readonly (AbortSignal | undefined)[]) {
166
- const controller = new AbortController()
77
+ export function combineSignals(
78
+ signals: readonly (AbortSignal | undefined)[],
79
+ ): AbortController & Disposable {
80
+ const controller = new DisposableAbortController()
167
81
 
168
82
  const onAbort = function (this: AbortSignal, _event: Event) {
169
83
  const reason = new Error('This operation was aborted', {
@@ -173,26 +87,27 @@ export function combineSignals(signals: readonly (AbortSignal | undefined)[]) {
173
87
  controller.abort(reason)
174
88
  }
175
89
 
176
- for (const sig of signals) {
177
- if (!sig) continue
178
-
179
- if (sig.aborted) {
180
- // Remove "abort" listener that was added to sig in previous iterations
181
- controller.abort()
182
-
183
- throw new Error('One of the signals is already aborted', {
184
- cause: sig.reason,
185
- })
90
+ try {
91
+ for (const sig of signals) {
92
+ if (sig) {
93
+ sig.throwIfAborted()
94
+ sig.addEventListener('abort', onAbort, { signal: controller.signal })
95
+ }
186
96
  }
187
97
 
188
- sig.addEventListener('abort', onAbort, { signal: controller.signal })
98
+ return controller
99
+ } catch (err) {
100
+ controller.abort(err)
101
+ throw err
189
102
  }
103
+ }
190
104
 
191
- controller[Symbol.dispose] = () => {
192
- const reason = new Error('AbortController was disposed')
193
-
194
- controller.abort(reason)
105
+ /**
106
+ * Allows using {@link AbortController} with the `using` keyword, in order to
107
+ * automatically abort them once the execution block ends.
108
+ */
109
+ class DisposableAbortController extends AbortController implements Disposable {
110
+ [Symbol.dispose]() {
111
+ this.abort(new Error('AbortController was disposed'))
195
112
  }
196
-
197
- return controller as AbortController & Disposable
198
113
  }
@@ -56,15 +56,28 @@ export function validateClientMetadata(
56
56
  )
57
57
  }
58
58
 
59
- const signingKeys = keyset
60
- ? Array.from(keyset.list({ use: 'sig' })).filter(
61
- (key) => key.isPrivate && key.kid,
62
- )
63
- : null
59
+ if (!keyset) {
60
+ throw new TypeError(
61
+ `Client authentication method "${method}" requires a keyset`,
62
+ )
63
+ }
64
+
65
+ // @NOTE This reproduces the logic from `negotiateClientAuthMethod` at
66
+ // initialization time to ensure that every key that might end-up being
67
+ // used is indeed valid & advertised in the metadata.
68
+ const signingKeys = Array.from(keyset.list({ usage: 'sign' })).filter(
69
+ (key) => key.kid,
70
+ )
71
+
72
+ if (!signingKeys.length) {
73
+ throw new TypeError(
74
+ `Client authentication method "${method}" requires at least one active signing key with a "kid" property`,
75
+ )
76
+ }
64
77
 
65
- if (!signingKeys?.some((key) => key.algorithms.includes(FALLBACK_ALG))) {
78
+ if (!signingKeys.some((key) => key.algorithms.includes(FALLBACK_ALG))) {
66
79
  throw new TypeError(
67
- `Client authentication method "${method}" requires at least one "${FALLBACK_ALG}" signing key with a "kid" property`,
80
+ `Client authentication method "${method}" requires at least one active "${FALLBACK_ALG}" signing key`,
68
81
  )
69
82
  }
70
83
 
@@ -72,8 +85,12 @@ export function validateClientMetadata(
72
85
  // Ensure that all the signing keys that could end-up being used are
73
86
  // advertised in the JWKS.
74
87
  for (const key of signingKeys) {
75
- if (!metadata.jwks.keys.some((k) => k.kid === key.kid)) {
76
- throw new TypeError(`Key with kid "${key.kid}" not found in jwks`)
88
+ if (
89
+ !metadata.jwks.keys.some((k) => k.kid === key.kid && !k.revoked)
90
+ ) {
91
+ throw new TypeError(
92
+ `Missing or inactive key "${key.kid}" in jwks. Make sure that every signing key of the Keyset is declared as an active key in the Metadata's JWKS.`,
93
+ )
77
94
  }
78
95
  }
79
96
  } else if (metadata.jwks_uri) {
@@ -1 +1 @@
1
- {"root":["./src/atproto-token-response.ts","./src/constants.ts","./src/fetch-dpop.ts","./src/identity-resolver.ts","./src/index.ts","./src/lock.ts","./src/oauth-authorization-server-metadata-resolver.ts","./src/oauth-callback-error.ts","./src/oauth-client-auth.ts","./src/oauth-client.ts","./src/oauth-protected-resource-metadata-resolver.ts","./src/oauth-resolver-error.ts","./src/oauth-resolver.ts","./src/oauth-response-error.ts","./src/oauth-server-agent.ts","./src/oauth-server-factory.ts","./src/oauth-session.ts","./src/runtime-implementation.ts","./src/runtime.ts","./src/session-getter.ts","./src/state-store.ts","./src/types.ts","./src/util.ts","./src/validate-client-metadata.ts","./src/errors/auth-method-unsatisfiable-error.ts","./src/errors/token-invalid-error.ts","./src/errors/token-refresh-error.ts","./src/errors/token-revoked-error.ts"],"version":"5.8.2"}
1
+ {"root":["./src/constants.ts","./src/fetch-dpop.ts","./src/identity-resolver.ts","./src/index.ts","./src/lock.ts","./src/oauth-authorization-server-metadata-resolver.ts","./src/oauth-callback-error.ts","./src/oauth-client-auth.ts","./src/oauth-client.ts","./src/oauth-protected-resource-metadata-resolver.ts","./src/oauth-resolver-error.ts","./src/oauth-resolver.ts","./src/oauth-response-error.ts","./src/oauth-server-agent.ts","./src/oauth-server-factory.ts","./src/oauth-session.ts","./src/runtime-implementation.ts","./src/runtime.ts","./src/session-getter.ts","./src/state-store.ts","./src/types.ts","./src/util.ts","./src/validate-client-metadata.ts","./src/errors/auth-method-unsatisfiable-error.ts","./src/errors/token-invalid-error.ts","./src/errors/token-refresh-error.ts","./src/errors/token-revoked-error.ts"],"version":"5.8.2"}
@@ -1,110 +0,0 @@
1
- import { TypeOf, z } from 'zod';
2
- import { SpaceSeparatedValue } from './util';
3
- export type AtprotoScope = SpaceSeparatedValue<'atproto'>;
4
- export declare const isAtprotoScope: (input: string) => input is AtprotoScope;
5
- export declare const atprotoScopeSchema: z.ZodEffects<z.ZodString, AtprotoScope, string>;
6
- export declare const atprotoTokenResponseSchema: z.ZodObject<z.objectUtil.extendShape<{
7
- access_token: z.ZodString;
8
- token_type: z.ZodUnion<[z.ZodEffects<z.ZodString, "DPoP", string>, z.ZodEffects<z.ZodString, "Bearer", string>]>;
9
- scope: z.ZodOptional<z.ZodString>;
10
- refresh_token: z.ZodOptional<z.ZodString>;
11
- expires_in: z.ZodOptional<z.ZodNumber>;
12
- id_token: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}.${string}`, string>>;
13
- authorization_details: z.ZodOptional<z.ZodArray<z.ZodObject<{
14
- type: z.ZodString;
15
- locations: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, `${string}:${string}`, string>, "many">>;
16
- actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
17
- datatypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
18
- identifier: z.ZodOptional<z.ZodString>;
19
- privileges: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
20
- }, "strip", z.ZodTypeAny, {
21
- type: string;
22
- locations?: `${string}:${string}`[] | undefined;
23
- actions?: string[] | undefined;
24
- datatypes?: string[] | undefined;
25
- identifier?: string | undefined;
26
- privileges?: string[] | undefined;
27
- }, {
28
- type: string;
29
- locations?: string[] | undefined;
30
- actions?: string[] | undefined;
31
- datatypes?: string[] | undefined;
32
- identifier?: string | undefined;
33
- privileges?: string[] | undefined;
34
- }>, "many">>;
35
- }, {
36
- token_type: z.ZodLiteral<"DPoP">;
37
- sub: z.ZodEffects<z.ZodString, `did:plc:${string}` | `did:web:${string}`, string>;
38
- scope: z.ZodEffects<z.ZodString, AtprotoScope, string>;
39
- id_token: z.ZodOptional<z.ZodNever>;
40
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
41
- access_token: z.ZodString;
42
- token_type: z.ZodUnion<[z.ZodEffects<z.ZodString, "DPoP", string>, z.ZodEffects<z.ZodString, "Bearer", string>]>;
43
- scope: z.ZodOptional<z.ZodString>;
44
- refresh_token: z.ZodOptional<z.ZodString>;
45
- expires_in: z.ZodOptional<z.ZodNumber>;
46
- id_token: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}.${string}`, string>>;
47
- authorization_details: z.ZodOptional<z.ZodArray<z.ZodObject<{
48
- type: z.ZodString;
49
- locations: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, `${string}:${string}`, string>, "many">>;
50
- actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
51
- datatypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
52
- identifier: z.ZodOptional<z.ZodString>;
53
- privileges: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
54
- }, "strip", z.ZodTypeAny, {
55
- type: string;
56
- locations?: `${string}:${string}`[] | undefined;
57
- actions?: string[] | undefined;
58
- datatypes?: string[] | undefined;
59
- identifier?: string | undefined;
60
- privileges?: string[] | undefined;
61
- }, {
62
- type: string;
63
- locations?: string[] | undefined;
64
- actions?: string[] | undefined;
65
- datatypes?: string[] | undefined;
66
- identifier?: string | undefined;
67
- privileges?: string[] | undefined;
68
- }>, "many">>;
69
- }, {
70
- token_type: z.ZodLiteral<"DPoP">;
71
- sub: z.ZodEffects<z.ZodString, `did:plc:${string}` | `did:web:${string}`, string>;
72
- scope: z.ZodEffects<z.ZodString, AtprotoScope, string>;
73
- id_token: z.ZodOptional<z.ZodNever>;
74
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
75
- access_token: z.ZodString;
76
- token_type: z.ZodUnion<[z.ZodEffects<z.ZodString, "DPoP", string>, z.ZodEffects<z.ZodString, "Bearer", string>]>;
77
- scope: z.ZodOptional<z.ZodString>;
78
- refresh_token: z.ZodOptional<z.ZodString>;
79
- expires_in: z.ZodOptional<z.ZodNumber>;
80
- id_token: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}.${string}`, string>>;
81
- authorization_details: z.ZodOptional<z.ZodArray<z.ZodObject<{
82
- type: z.ZodString;
83
- locations: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, `${string}:${string}`, string>, "many">>;
84
- actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
85
- datatypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
86
- identifier: z.ZodOptional<z.ZodString>;
87
- privileges: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
88
- }, "strip", z.ZodTypeAny, {
89
- type: string;
90
- locations?: `${string}:${string}`[] | undefined;
91
- actions?: string[] | undefined;
92
- datatypes?: string[] | undefined;
93
- identifier?: string | undefined;
94
- privileges?: string[] | undefined;
95
- }, {
96
- type: string;
97
- locations?: string[] | undefined;
98
- actions?: string[] | undefined;
99
- datatypes?: string[] | undefined;
100
- identifier?: string | undefined;
101
- privileges?: string[] | undefined;
102
- }>, "many">>;
103
- }, {
104
- token_type: z.ZodLiteral<"DPoP">;
105
- sub: z.ZodEffects<z.ZodString, `did:plc:${string}` | `did:web:${string}`, string>;
106
- scope: z.ZodEffects<z.ZodString, AtprotoScope, string>;
107
- id_token: z.ZodOptional<z.ZodNever>;
108
- }>, z.ZodTypeAny, "passthrough">>;
109
- export type AtprotoTokenResponse = TypeOf<typeof atprotoTokenResponseSchema>;
110
- //# sourceMappingURL=atproto-token-response.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atproto-token-response.d.ts","sourceRoot":"","sources":["../src/atproto-token-response.ts"],"names":[],"mappings":"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"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.atprotoTokenResponseSchema = exports.atprotoScopeSchema = exports.isAtprotoScope = void 0;
4
- const zod_1 = require("zod");
5
- const did_1 = require("@atproto/did");
6
- const oauth_types_1 = require("@atproto/oauth-types");
7
- const util_1 = require("./util");
8
- const isAtprotoScope = (input) => (0, util_1.includesSpaceSeparatedValue)(input, 'atproto');
9
- exports.isAtprotoScope = isAtprotoScope;
10
- exports.atprotoScopeSchema = zod_1.z
11
- .string()
12
- .refine(exports.isAtprotoScope, 'The "atproto" scope is required');
13
- exports.atprotoTokenResponseSchema = oauth_types_1.oauthTokenResponseSchema.extend({
14
- token_type: zod_1.z.literal('DPoP'),
15
- sub: did_1.atprotoDidSchema,
16
- scope: exports.atprotoScopeSchema,
17
- // OpenID is not compatible with atproto identities
18
- id_token: zod_1.z.never().optional(),
19
- });
20
- //# sourceMappingURL=atproto-token-response.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atproto-token-response.js","sourceRoot":"","sources":["../src/atproto-token-response.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAC/B,sCAA+C;AAC/C,sDAA+D;AAC/D,iCAAyE;AAGlE,MAAM,cAAc,GAAG,CAAC,KAAa,EAAyB,EAAE,CACrE,IAAA,kCAA2B,EAAC,KAAK,EAAE,SAAS,CAAC,CAAA;AADlC,QAAA,cAAc,kBACoB;AAClC,QAAA,kBAAkB,GAAG,OAAC;KAChC,MAAM,EAAE;KACR,MAAM,CAAC,sBAAc,EAAE,iCAAiC,CAAC,CAAA;AAE/C,QAAA,0BAA0B,GAAG,sCAAwB,CAAC,MAAM,CAAC;IACxE,UAAU,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,GAAG,EAAE,sBAAgB;IACrB,KAAK,EAAE,0BAAkB;IACzB,mDAAmD;IACnD,QAAQ,EAAE,OAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAA"}
@@ -1,21 +0,0 @@
1
- import { TypeOf, z } from 'zod'
2
- import { atprotoDidSchema } from '@atproto/did'
3
- import { oauthTokenResponseSchema } from '@atproto/oauth-types'
4
- import { SpaceSeparatedValue, includesSpaceSeparatedValue } from './util'
5
-
6
- export type AtprotoScope = SpaceSeparatedValue<'atproto'>
7
- export const isAtprotoScope = (input: string): input is AtprotoScope =>
8
- includesSpaceSeparatedValue(input, 'atproto')
9
- export const atprotoScopeSchema = z
10
- .string()
11
- .refine(isAtprotoScope, 'The "atproto" scope is required')
12
-
13
- export const atprotoTokenResponseSchema = oauthTokenResponseSchema.extend({
14
- token_type: z.literal('DPoP'),
15
- sub: atprotoDidSchema,
16
- scope: atprotoScopeSchema,
17
- // OpenID is not compatible with atproto identities
18
- id_token: z.never().optional(),
19
- })
20
-
21
- export type AtprotoTokenResponse = TypeOf<typeof atprotoTokenResponseSchema>