@outfoxx/sunday 2.0.0-beta.2 → 2.0.0-beta.21

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 (141) hide show
  1. package/README.md +346 -4
  2. package/build/authentication-adapter.d.ts +21 -0
  3. package/build/authentication-adapter.js +74 -0
  4. package/build/authentication-adapter.js.map +1 -0
  5. package/build/bearer-token-rejection-adapter.d.ts +6 -0
  6. package/build/bearer-token-rejection-adapter.js +25 -0
  7. package/build/bearer-token-rejection-adapter.js.map +1 -0
  8. package/build/client-settings.d.ts +22 -0
  9. package/build/client-settings.js +180 -0
  10. package/build/client-settings.js.map +1 -0
  11. package/build/credentials.d.ts +58 -0
  12. package/build/credentials.js +51 -0
  13. package/build/credentials.js.map +1 -0
  14. package/build/event-parser.d.ts +23 -8
  15. package/build/event-parser.js +93 -121
  16. package/build/event-parser.js.map +1 -1
  17. package/build/fetch-copy.d.ts +15 -0
  18. package/build/fetch-copy.js +71 -0
  19. package/build/fetch-copy.js.map +1 -0
  20. package/build/fetch-event-source.d.ts +18 -8
  21. package/build/fetch-event-source.js +241 -144
  22. package/build/fetch-event-source.js.map +1 -1
  23. package/build/fetch-oauth-token-provider.d.ts +28 -0
  24. package/build/fetch-oauth-token-provider.js +213 -0
  25. package/build/fetch-oauth-token-provider.js.map +1 -0
  26. package/build/fetch-transport.d.ts +15 -1
  27. package/build/fetch-transport.js +142 -132
  28. package/build/fetch-transport.js.map +1 -1
  29. package/build/fetch.js +24 -10
  30. package/build/fetch.js.map +1 -1
  31. package/build/header-token-adapters.d.ts +28 -0
  32. package/build/header-token-adapters.js +121 -0
  33. package/build/header-token-adapters.js.map +1 -0
  34. package/build/index.d.ts +23 -1
  35. package/build/index.js +22 -1
  36. package/build/index.js.map +1 -1
  37. package/build/media-type-codecs/binary-decoder.d.ts +1 -0
  38. package/build/media-type-codecs/binary-decoder.js +4 -11
  39. package/build/media-type-codecs/binary-decoder.js.map +1 -1
  40. package/build/media-type-codecs/cbor-encoder.d.ts +2 -2
  41. package/build/media-type-codecs/cbor-encoder.js +2 -2
  42. package/build/media-type-codecs/cbor-encoder.js.map +1 -1
  43. package/build/media-type-codecs/json-encoder.d.ts +3 -3
  44. package/build/media-type-codecs/json-encoder.js +4 -4
  45. package/build/media-type-codecs/json-encoder.js.map +1 -1
  46. package/build/media-type-codecs/media-type-encoder.d.ts +3 -3
  47. package/build/media-type-codecs/media-type-encoder.js.map +1 -1
  48. package/build/media-type-codecs/www-form-url-encoder.d.ts +2 -2
  49. package/build/media-type-codecs/www-form-url-encoder.js +2 -2
  50. package/build/media-type-codecs/www-form-url-encoder.js.map +1 -1
  51. package/build/model-construction.d.ts +5 -0
  52. package/build/model-construction.js +40 -0
  53. package/build/model-construction.js.map +1 -0
  54. package/build/model-schema.d.ts +9 -0
  55. package/build/model-schema.js +131 -0
  56. package/build/model-schema.js.map +1 -0
  57. package/build/oauth-wire.d.ts +33 -0
  58. package/build/oauth-wire.js +143 -0
  59. package/build/oauth-wire.js.map +1 -0
  60. package/build/operation.d.ts +3 -1
  61. package/build/problem.d.ts +39 -16
  62. package/build/problem.js +88 -32
  63. package/build/problem.js.map +1 -1
  64. package/build/request-adapter.d.ts +8 -0
  65. package/build/request-adapter.js +15 -0
  66. package/build/request-adapter.js.map +1 -0
  67. package/build/request-adapters-compat.d.ts +6 -0
  68. package/build/request-adapters-compat.js +19 -0
  69. package/build/request-adapters-compat.js.map +1 -0
  70. package/build/request-adapters.d.ts +13 -23
  71. package/build/request-adapters.js +40 -31
  72. package/build/request-adapters.js.map +1 -1
  73. package/build/request-body.d.ts +24 -0
  74. package/build/request-body.js +104 -0
  75. package/build/request-body.js.map +1 -0
  76. package/build/request-cancellation-error.d.ts +13 -0
  77. package/build/request-cancellation-error.js +43 -0
  78. package/build/request-cancellation-error.js.map +1 -0
  79. package/build/request-context.d.ts +4 -0
  80. package/build/request-context.js +29 -0
  81. package/build/request-context.js.map +1 -0
  82. package/build/request-execution.d.ts +13 -0
  83. package/build/request-execution.js +80 -0
  84. package/build/request-execution.js.map +1 -0
  85. package/build/request-security-bindings.d.ts +5 -0
  86. package/build/request-security-bindings.js +30 -0
  87. package/build/request-security-bindings.js.map +1 -0
  88. package/build/request-security.d.ts +20 -0
  89. package/build/request-security.js +223 -0
  90. package/build/request-security.js.map +1 -0
  91. package/build/request-validation-error.d.ts +4 -0
  92. package/build/request-validation-error.js +21 -0
  93. package/build/request-validation-error.js.map +1 -0
  94. package/build/response-adapter.d.ts +10 -0
  95. package/build/response-adapter.js +15 -0
  96. package/build/response-adapter.js.map +1 -0
  97. package/build/response-adapters.d.ts +13 -0
  98. package/build/response-adapters.js +75 -0
  99. package/build/response-adapters.js.map +1 -0
  100. package/build/schema-builtins.js +11 -21
  101. package/build/schema-builtins.js.map +1 -1
  102. package/build/schema-runtime.d.ts +8 -1
  103. package/build/schema-runtime.js +12 -3
  104. package/build/schema-runtime.js.map +1 -1
  105. package/build/security-binding.d.ts +22 -0
  106. package/build/security-binding.js +15 -0
  107. package/build/security-binding.js.map +1 -0
  108. package/build/standard-authentication-adapter.d.ts +18 -0
  109. package/build/standard-authentication-adapter.js +58 -0
  110. package/build/standard-authentication-adapter.js.map +1 -0
  111. package/build/token-manager.d.ts +42 -0
  112. package/build/token-manager.js +276 -0
  113. package/build/token-manager.js.map +1 -0
  114. package/build/token-provider.d.ts +52 -0
  115. package/build/token-provider.js +102 -0
  116. package/build/token-provider.js.map +1 -0
  117. package/build/transport.d.ts +10 -3
  118. package/build/unknown-variant.d.ts +12 -0
  119. package/build/unknown-variant.js +45 -0
  120. package/build/unknown-variant.js.map +1 -0
  121. package/build/url-template.d.ts +3 -0
  122. package/build/url-template.js +30 -2
  123. package/build/url-template.js.map +1 -1
  124. package/build/util/abort.d.ts +3 -0
  125. package/build/util/abort.js +42 -0
  126. package/build/util/abort.js.map +1 -0
  127. package/build/util/base64.d.ts +4 -0
  128. package/build/util/base64.js +46 -0
  129. package/build/util/base64.js.map +1 -0
  130. package/build/util/native-fetch.d.ts +2 -0
  131. package/build/util/native-fetch.js +39 -0
  132. package/build/util/native-fetch.js.map +1 -0
  133. package/build/util/nullify.js +12 -5
  134. package/build/util/nullify.js.map +1 -1
  135. package/build/util/owned-body.d.ts +12 -0
  136. package/build/util/owned-body.js +243 -0
  137. package/build/util/owned-body.js.map +1 -0
  138. package/build/util/status-title.d.ts +2 -0
  139. package/build/util/status-title.js +83 -0
  140. package/build/util/status-title.js.map +1 -0
  141. package/package.json +18 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unknown-variant.js","sourceRoot":"","sources":["../src/unknown-variant.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAkB,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAQ7F,4FAA4F;AAC5F,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;WAC7C,iBAAiB,IAAI,KAAK,IAAI,KAAK,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;AACvE,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,gBAAgB,CAC9B,KAAQ,EACR,OAAU;IAEV,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAA6B,EAAE;QACjE,MAAM,CAAC,KAAK,EAAE,OAAO;YACnB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC3F,OAAO,CAAC,CAAC,KAAK,CAAC;YACjB,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QACD,MAAM,CAAC,KAAK,EAAE,OAAO;YACnB,MAAM,MAAM,GAAc,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;YACpE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC3F,OAAO,CAAC,CAAC,KAAK,CAAC;YACjB,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +1,9 @@
1
+ /** An RFC 6570 URL template with reusable parameter defaults. */
1
2
  export declare class URLTemplate {
2
3
  template: string;
3
4
  parameters: Record<string, unknown>;
5
+ /** Creates a template whose stored parameters can be overridden for each expansion. */
4
6
  constructor(template: string, parameters?: Record<string, unknown>);
7
+ /** Expands base and relative templates, preserving empty values and omitting null or missing values. */
5
8
  complete(relativeTemplate: string, parameters: Record<string, unknown>): URL;
6
9
  }
@@ -11,14 +11,17 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { parse } from 'uri-template';
14
+ import { expandExpression, parse } from 'uri-template';
15
+ /** An RFC 6570 URL template with reusable parameter defaults. */
15
16
  export class URLTemplate {
16
17
  template;
17
18
  parameters;
19
+ /** Creates a template whose stored parameters can be overridden for each expansion. */
18
20
  constructor(template, parameters = {}) {
19
21
  this.template = template;
20
22
  this.parameters = parameters;
21
23
  }
24
+ /** Expands base and relative templates, preserving empty values and omitting null or missing values. */
22
25
  complete(relativeTemplate, parameters) {
23
26
  const allParameters = { ...this.parameters, ...parameters };
24
27
  const baseTempl = this.template.endsWith('/')
@@ -27,7 +30,32 @@ export class URLTemplate {
27
30
  const relTempl = relativeTemplate.startsWith('/') || !relativeTemplate.length
28
31
  ? relativeTemplate
29
32
  : `/${relativeTemplate}`;
30
- return new URL(parse(baseTempl + relTempl).expand(allParameters));
33
+ const template = parse(baseTempl + relTempl);
34
+ const expanded = template.ast.parts
35
+ .map((part) => {
36
+ if (part.type === 'literal')
37
+ return part.value;
38
+ const value = expandExpression(part, allParameters);
39
+ // uri-template 2 drops the path prefix when defined variables expand to an empty string.
40
+ if (part.operator === '/' &&
41
+ value === '' &&
42
+ part.variables.some((variable) => isDefined(allParameters[variable.name]))) {
43
+ return '/';
44
+ }
45
+ return value;
46
+ })
47
+ .join('');
48
+ return new URL(expanded);
31
49
  }
32
50
  }
51
+ // RFC 6570 treats empty collections as undefined, but an empty string is defined.
52
+ function isDefined(value) {
53
+ if (value == null)
54
+ return false;
55
+ if (typeof value !== 'object')
56
+ return true;
57
+ if (Array.isArray(value))
58
+ return value.length > 0;
59
+ return Object.values(value).some((entry) => entry != null);
60
+ }
33
61
  //# sourceMappingURL=url-template.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"url-template.js","sourceRoot":"","sources":["../src/url-template.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,MAAM,OAAO,WAAW;IAEb;IACA;IAFT,YACS,QAAgB,EAChB,aAAsC,EAAE;QADxC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,eAAU,GAAV,UAAU,CAA8B;IAC9C,CAAC;IAEJ,QAAQ,CAAC,gBAAwB,EAAE,UAAmC;QACpE,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC3C,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5B,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAClB,MAAM,QAAQ,GACZ,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM;YAC1D,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,IAAI,gBAAgB,EAAE,CAAC;QAC7B,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IACpE,CAAC;CACF"}
1
+ {"version":3,"file":"url-template.js","sourceRoot":"","sources":["../src/url-template.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;A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CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC/B,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACxC,EACD,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;CACF;AAED,kFAAkF;AAClF,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { discardBody } from './owned-body.js';
2
+ /** Waits cooperatively without leaving abort listeners or late resource results behind. */
3
+ export declare function withAbort<T>(action: () => T | PromiseLike<T>, signal: AbortSignal, discard?: (value: T, reason: unknown) => void): Promise<T>;
@@ -0,0 +1,42 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ export { discardBody } from './owned-body.js';
15
+ /** Waits cooperatively without leaving abort listeners or late resource results behind. */
16
+ export function withAbort(action, signal, discard) {
17
+ signal.throwIfAborted();
18
+ return new Promise((resolve, reject) => {
19
+ let aborted = false;
20
+ const onAbort = () => {
21
+ aborted = true;
22
+ reject(signal.reason);
23
+ };
24
+ signal.addEventListener('abort', onAbort, { once: true });
25
+ Promise.resolve()
26
+ .then(() => {
27
+ signal.throwIfAborted();
28
+ return action();
29
+ })
30
+ .then((value) => {
31
+ signal.removeEventListener('abort', onAbort);
32
+ if (aborted)
33
+ discard?.(value, signal.reason);
34
+ else
35
+ resolve(value);
36
+ }, (error) => {
37
+ signal.removeEventListener('abort', onAbort);
38
+ reject(error);
39
+ });
40
+ });
41
+ }
42
+ //# sourceMappingURL=abort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.js","sourceRoot":"","sources":["../../src/util/abort.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,2FAA2F;AAC3F,MAAM,UAAU,SAAS,CACvB,MAAgC,EAChC,MAAmB,EACnB,OAA6C;IAE7C,MAAM,CAAC,cAAc,EAAE,CAAC;IACxB,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,OAAO,EAAE;aACd,IAAI,CAAC,GAAG,EAAE;YACT,MAAM,CAAC,cAAc,EAAE,CAAC;YACxB,OAAO,MAAM,EAAE,CAAC;QAClB,CAAC,CAAC;aACD,IAAI,CACH,CAAC,KAAK,EAAE,EAAE;YACR,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,IAAI,OAAO;gBAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;;gBACxC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACR,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CACF,CAAC;IACN,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Decodes standard or URL-safe base64 with optional padding and loose final chunks. */
2
+ export declare function decodeBase64(value: string, alphabet?: 'base64' | 'base64url'): ArrayBuffer;
3
+ /** Encodes a byte view as unpadded standard or URL-safe base64. */
4
+ export declare function encodeBase64(value: Uint8Array, alphabet?: 'base64' | 'base64url'): string;
@@ -0,0 +1,46 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /** Decodes standard or URL-safe base64 with optional padding and loose final chunks. */
15
+ export function decodeBase64(value, alphabet = 'base64') {
16
+ if (alphabet === 'base64url') {
17
+ if (/[+/]/.test(value)) {
18
+ throw new SyntaxError('Invalid base64url input');
19
+ }
20
+ value = value.replaceAll('-', '+').replaceAll('_', '/');
21
+ }
22
+ let binary;
23
+ try {
24
+ binary = atob(value);
25
+ }
26
+ catch (error) {
27
+ throw new SyntaxError('Invalid base64 input', { cause: error });
28
+ }
29
+ const bytes = new Uint8Array(binary.length);
30
+ for (let index = 0; index < binary.length; index++) {
31
+ bytes[index] = binary.charCodeAt(index);
32
+ }
33
+ return bytes.buffer;
34
+ }
35
+ /** Encodes a byte view as unpadded standard or URL-safe base64. */
36
+ export function encodeBase64(value, alphabet = 'base64') {
37
+ const chunks = [];
38
+ // Bound temporary binary strings and spread arguments; align chunks so padding only occurs at the end.
39
+ const chunkSize = 0x6000;
40
+ for (let offset = 0; offset < value.length; offset += chunkSize) {
41
+ const encoded = btoa(String.fromCharCode(...value.subarray(offset, offset + chunkSize))).replace(/=+$/, '');
42
+ chunks.push(alphabet === 'base64url' ? encoded.replaceAll('+', '-').replaceAll('/', '_') : encoded);
43
+ }
44
+ return chunks.join('');
45
+ }
46
+ //# sourceMappingURL=base64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/util/base64.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,wFAAwF;AACxF,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,WAAmC,QAAQ;IACrF,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,WAAW,CAAC,yBAAyB,CAAC,CAAC;QACnD,CAAC;QACD,KAAK,GAAG,KAAK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C,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACtG,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** @internal Repairs native Fetch failures only; source ownership takes precedence over native causes. */
2
+ export declare function nativeFetch(request: Request, signal: AbortSignal): Promise<Response>;
@@ -0,0 +1,39 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { isRequestStopped } from '../request-cancellation-error.js';
15
+ import { nativeBodyOperation } from './owned-body.js';
16
+ /** @internal Repairs native Fetch failures only; source ownership takes precedence over native causes. */
17
+ export function nativeFetch(request, signal) {
18
+ return nativeBodyOperation(request.body, async () => {
19
+ try {
20
+ return await fetch(request, { signal });
21
+ }
22
+ catch (error) {
23
+ if (signal.aborted)
24
+ throw signal.reason;
25
+ // Node may carry an unmanaged upload's stop error in Fetch's cause chain. This walk must
26
+ // never surround adapters, credential providers, decoders, or custom Fetch callbacks.
27
+ const seen = new Set();
28
+ let cause = error;
29
+ while (typeof cause === 'object' && cause !== null && !seen.has(cause)) {
30
+ if (isRequestStopped(cause))
31
+ throw cause;
32
+ seen.add(cause);
33
+ cause = 'cause' in cause ? cause.cause : undefined;
34
+ }
35
+ throw error;
36
+ }
37
+ });
38
+ }
39
+ //# sourceMappingURL=native-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-fetch.js","sourceRoot":"","sources":["../../src/util/native-fetch.ts"],"names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either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
+ import { z } from 'zod';
14
15
  import { Problem } from '../problem.js';
15
16
  export async function nullifyNotFound(promise) {
16
17
  return await nullifyProblem(promise, [404], []);
@@ -20,18 +21,24 @@ export async function nullifyProblem(promise, statuses, problemTypes) {
20
21
  return await promise;
21
22
  }
22
23
  catch (error) {
23
- if (error instanceof Problem && matchesProblem(error, statuses, problemTypes)) {
24
+ if (error instanceof Problem &&
25
+ matchesProblem(error, statuses, problemTypes)) {
24
26
  return null;
25
27
  }
26
28
  throw error;
27
29
  }
28
30
  }
29
31
  function matchesProblem(error, statuses, problemTypes) {
30
- if (statuses.includes(error.status)) {
32
+ if (error.status !== undefined && statuses.includes(error.status)) {
31
33
  return true;
32
34
  }
33
- return problemTypes.some((matcher) => typeof matcher === 'function'
34
- ? matcher(error)
35
- : matcher.safeParse(error).success);
35
+ return problemTypes.some((matcher) => {
36
+ if (typeof matcher === 'function')
37
+ return matcher(error);
38
+ // A thrown Problem is already decoded; codecs validate it in their output direction.
39
+ return matcher instanceof z.ZodCodec
40
+ ? matcher.safeEncode(error).success
41
+ : matcher.safeParse(error).success;
42
+ });
36
43
  }
37
44
  //# sourceMappingURL=nullify.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nullify.js","sourceRoot":"","sources":["../../src/util/nullify.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAI,OAAmB;IAC1D,OAAO,MAAM,cAAc,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC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,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAmB,EACnB,QAAkB,EAClB,YAA8B;IAE9B,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IACE,KAAK,YAAY,OAAO;YACxB,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,EAC7C,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CACrB,KAAc,EACd,QAAkB,EAClB,YAA8B;IAE9B,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QACnC,IAAI,OAAO,OAAO,KAAK,UAAU;YAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;QACzD,qFAAqF;QACrF,OAAO,OAAO,YAAY,CAAC,CAAC,QAAQ;YAClC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO;YACnC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ /** @internal Owns only application streams, preserving byte-stream capability and backpressure. */
2
+ export declare function ownBody(source: ReadableStream<Uint8Array>, signal?: AbortSignal): ReadableStream<Uint8Array>;
3
+ /** @internal Transfers body metadata and retires unused native branches without consuming the active body. */
4
+ export declare function inheritBody(source: ReadableStream<Uint8Array> | null | undefined, target: Request | Response, previousBody?: ReadableStream<Uint8Array> | null): void;
5
+ /** @internal Recognizes constructor-transferred bodies even when a runtime creates a new stream handle. */
6
+ export declare function sameBody(left: ReadableStream<Uint8Array> | null, right: ReadableStream<Uint8Array> | null): boolean;
7
+ /** @internal Restores errors only at a native read/fetch boundary, never around application callbacks. */
8
+ export declare function nativeBodyOperation<T>(body: ReadableStream<Uint8Array> | null | undefined, action: () => Promise<T>): Promise<T>;
9
+ /** @internal Gives native bulk reads exact source errors and request reads cooperative cancellation. */
10
+ export declare function bodyReads(value: Request | Response): void;
11
+ /** @internal Disposes transferred bodies without waiting for user cleanup or replacing the original error. */
12
+ export declare function discardBody(value: Request | Response, reason?: unknown): void;
@@ -0,0 +1,243 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { withAbort } from './abort.js';
15
+ const bodies = new WeakMap();
16
+ /** @internal Owns only application streams, preserving byte-stream capability and backpressure. */
17
+ export function ownBody(source, signal) {
18
+ const existing = bodies.get(source)?.owner;
19
+ if (existing) {
20
+ existing.observe(signal);
21
+ return source;
22
+ }
23
+ const owner = new BodyOwner(source);
24
+ bodies.set(owner.stream, { source: owner.stream, owner });
25
+ owner.observe(signal);
26
+ return owner.stream;
27
+ }
28
+ /** @internal Transfers body metadata and retires unused native branches without consuming the active body. */
29
+ export function inheritBody(source, target, previousBody) {
30
+ if (source && target.body) {
31
+ const reference = bodies.get(source) ?? { source };
32
+ // Bun leaves a new tee branch on the input. Ownership has transferred, so retire that
33
+ // unused branch immediately to prevent buffering and to let later cancellation reach the source.
34
+ if (previousBody && previousBody !== source && previousBody !== target.body)
35
+ void cancelStream(previousBody);
36
+ bodies.set(target.body, reference);
37
+ if (target instanceof Request)
38
+ reference.owner?.observe(target.signal);
39
+ }
40
+ bodyReads(target);
41
+ }
42
+ /** @internal Recognizes constructor-transferred bodies even when a runtime creates a new stream handle. */
43
+ export function sameBody(left, right) {
44
+ return (left === right ||
45
+ !!(left &&
46
+ right &&
47
+ (bodies.get(left)?.source ?? left) ===
48
+ (bodies.get(right)?.source ?? right)));
49
+ }
50
+ /** @internal Restores errors only at a native read/fetch boundary, never around application callbacks. */
51
+ export async function nativeBodyOperation(body, action) {
52
+ const owner = body && bodies.get(body)?.owner;
53
+ try {
54
+ // Start the native operation immediately to retain synchronous bodyUsed/locking behavior.
55
+ const operation = action();
56
+ // A stop can win before withAbort invokes its callback; observe the native result regardless.
57
+ void operation.catch(() => undefined);
58
+ // WebKit can leave an in-flight native bulk read pending after its stream errors.
59
+ return await (owner && !owner.failure.signal.aborted
60
+ ? withAbort(() => operation, owner.failure.signal)
61
+ : operation);
62
+ }
63
+ catch (error) {
64
+ throw owner?.failure.signal.aborted
65
+ ? owner.failure.signal.reason.error
66
+ : error;
67
+ }
68
+ }
69
+ /** @internal Gives native bulk reads exact source errors and request reads cooperative cancellation. */
70
+ export function bodyReads(value) {
71
+ if (!value.body)
72
+ return;
73
+ const request = value instanceof Request;
74
+ if (!request && !bodies.get(value.body)?.owner)
75
+ return;
76
+ const prototype = request ? Request.prototype : Response.prototype;
77
+ for (const name of [
78
+ 'arrayBuffer',
79
+ 'blob',
80
+ 'bytes',
81
+ 'formData',
82
+ 'json',
83
+ 'text',
84
+ ]) {
85
+ const native = prototype[name];
86
+ // Preserve custom overrides and avoid decorating an instance twice.
87
+ if (!native || value[name] !== native)
88
+ continue;
89
+ Object.defineProperty(value, name, {
90
+ configurable: true,
91
+ writable: true,
92
+ value: async function () {
93
+ if (this !== value || this.bodyUsed || !this.body || this.body.locked)
94
+ return native.call(this);
95
+ if (this instanceof Request && !bodies.get(this.body)?.owner) {
96
+ // Defer ownership until the adapter actually reads. Unread Blob/string requests keep
97
+ // their native replayable sources, including native redirects and follow-ups.
98
+ const body = ownBody(this.body, this.signal);
99
+ bodies.set(this.body, bodies.get(body));
100
+ const response = new Response(body, { headers: this.headers });
101
+ const read = Response.prototype[name];
102
+ return nativeBodyOperation(body, () => read.call(response));
103
+ }
104
+ return nativeBodyOperation(this.body, () => native.call(this));
105
+ },
106
+ });
107
+ }
108
+ }
109
+ /** @internal Disposes transferred bodies without waiting for user cleanup or replacing the original error. */
110
+ export function discardBody(value, reason) {
111
+ try {
112
+ const body = value.body;
113
+ if (!body)
114
+ return;
115
+ const reference = bodies.get(body);
116
+ if (reference?.owner) {
117
+ reference.owner.stop(reason);
118
+ return;
119
+ }
120
+ void cancelStream(body, reason);
121
+ }
122
+ catch {
123
+ // Custom body accessors must not replace the operation's error either.
124
+ }
125
+ }
126
+ async function cancelStream(stream, reason) {
127
+ try {
128
+ if (!stream.locked)
129
+ await stream.cancel(reason);
130
+ }
131
+ catch {
132
+ // Cleanup failures must not replace the operation's outcome.
133
+ }
134
+ }
135
+ class BodyOwner {
136
+ source;
137
+ stream;
138
+ // Wrap the original value because abort(undefined) would create a different AbortError.
139
+ failure = new AbortController();
140
+ reader;
141
+ controller;
142
+ closed = false;
143
+ listeners = new Map();
144
+ // WebKit can recreate a native Request.body wrapper if only its reader remains reachable.
145
+ // Keep the source handle alive so ownership lookups survive garbage collection during reads.
146
+ constructor(source) {
147
+ this.source = source;
148
+ // Keep the selected reader: some byte producers can only fill a supplied BYOB view.
149
+ let bytes = false;
150
+ try {
151
+ this.reader = this.source.getReader({ mode: 'byob' });
152
+ bytes = true;
153
+ }
154
+ catch (error) {
155
+ if (this.source.locked)
156
+ throw error;
157
+ this.reader = this.source.getReader();
158
+ }
159
+ const underlying = {
160
+ start: (controller) => {
161
+ this.controller = controller;
162
+ },
163
+ pull: () => this.pull(),
164
+ cancel: (reason) => this.cancel(reason),
165
+ };
166
+ // Do not read ahead on behalf of a consumer. Native Response methods still collect whole chunks.
167
+ this.stream = bytes
168
+ ? new ReadableStream({ ...underlying, type: 'bytes', autoAllocateChunkSize: 64 * 1024 }, { highWaterMark: 0 })
169
+ : new ReadableStream(underlying, { highWaterMark: 0 });
170
+ }
171
+ observe(signal) {
172
+ if (!signal || this.closed || this.listeners.has(signal))
173
+ return;
174
+ if (signal.aborted) {
175
+ this.stop(signal.reason);
176
+ return;
177
+ }
178
+ const abort = () => this.stop(signal.reason);
179
+ this.listeners.set(signal, abort);
180
+ signal.addEventListener('abort', abort, { once: true });
181
+ }
182
+ cancel(reason) {
183
+ if (this.closed)
184
+ return;
185
+ // Cleanup cannot delay or replace the original failure, even if user cleanup never settles.
186
+ void this.reader.cancel(reason).catch(() => undefined);
187
+ this.finish();
188
+ }
189
+ stop(reason) {
190
+ if (this.closed)
191
+ return;
192
+ this.failure.abort({ error: reason });
193
+ this.controller.error(reason);
194
+ this.cancel(reason);
195
+ }
196
+ async pull() {
197
+ try {
198
+ const byob = 'byobRequest' in this.controller
199
+ ? this.controller.byobRequest
200
+ : undefined;
201
+ // Auto-allocation supplies a view for default/bulk consumers too. Forward the returned
202
+ // view because the source reader transfers its buffer, detaching the original view.
203
+ const result = byob
204
+ ? await this.reader.read(byob.view)
205
+ : await this.reader.read();
206
+ if (this.closed)
207
+ return;
208
+ if (result.done) {
209
+ this.controller.close();
210
+ if (byob)
211
+ byob.respondWithNewView(result.value);
212
+ this.finish();
213
+ }
214
+ else if (byob) {
215
+ byob.respondWithNewView(result.value);
216
+ }
217
+ else {
218
+ this.controller.enqueue(result.value);
219
+ }
220
+ }
221
+ catch (error) {
222
+ if (this.closed)
223
+ return;
224
+ this.failure.abort({ error });
225
+ this.controller.error(error);
226
+ this.finish();
227
+ }
228
+ }
229
+ finish() {
230
+ this.closed = true;
231
+ for (const [signal, listener] of this.listeners)
232
+ signal.removeEventListener('abort', listener);
233
+ this.listeners.clear();
234
+ try {
235
+ this.reader.releaseLock();
236
+ }
237
+ catch {
238
+ // Bun leaves pending BYOB reads unsettled after cancel(), and refuses lock release.
239
+ // The output is already terminated; native cleanup must not replace that outcome.
240
+ }
241
+ }
242
+ }
243
+ //# sourceMappingURL=owned-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owned-body.js","sourceRoot":"","sources":["../../src/util/owned-body.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOvC,MAAM,MAAM,GAAG,IAAI,OAAO,EAA6C,CAAC;AAExE,mGAAmG;AACnG,MAAM,UAAU,OAAO,CACrB,MAAkC,EAClC,MAAoB;IAEpB,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;IAC3C,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1D,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC,MAAM,CAAC;AACtB,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,WAAW,CACzB,MAAqD,EACrD,MAA0B,EAC1B,YAAgD;IAEhD,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAkB,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAClE,sFAAsF;QACtF,iG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CAAC;IACH,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,SAAS;YAC7C,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,oFAAoF;YACpF,kFAAkF;QACpF,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ /** Returns the standard title for a recognized HTTP status. */
2
+ export declare function statusTitle(status: number): string | undefined;
@@ -0,0 +1,83 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ // Standard HTTP reason phrases for about:blank when the body status differs from the response.
15
+ const titles = {
16
+ 100: 'Continue',
17
+ 101: 'Switching Protocols',
18
+ 102: 'Processing',
19
+ 103: 'Early Hints',
20
+ 200: 'OK',
21
+ 201: 'Created',
22
+ 202: 'Accepted',
23
+ 203: 'Non-Authoritative Information',
24
+ 204: 'No Content',
25
+ 205: 'Reset Content',
26
+ 206: 'Partial Content',
27
+ 207: 'Multi-Status',
28
+ 208: 'Already Reported',
29
+ 226: 'IM Used',
30
+ 300: 'Multiple Choices',
31
+ 301: 'Moved Permanently',
32
+ 302: 'Found',
33
+ 303: 'See Other',
34
+ 304: 'Not Modified',
35
+ 305: 'Use Proxy',
36
+ 307: 'Temporary Redirect',
37
+ 308: 'Permanent Redirect',
38
+ 400: 'Bad Request',
39
+ 401: 'Unauthorized',
40
+ 402: 'Payment Required',
41
+ 403: 'Forbidden',
42
+ 404: 'Not Found',
43
+ 405: 'Method Not Allowed',
44
+ 406: 'Not Acceptable',
45
+ 407: 'Proxy Authentication Required',
46
+ 408: 'Request Timeout',
47
+ 409: 'Conflict',
48
+ 410: 'Gone',
49
+ 411: 'Length Required',
50
+ 412: 'Precondition Failed',
51
+ 413: 'Content Too Large',
52
+ 414: 'URI Too Long',
53
+ 415: 'Unsupported Media Type',
54
+ 416: 'Range Not Satisfiable',
55
+ 417: 'Expectation Failed',
56
+ 418: "I'm a Teapot",
57
+ 421: 'Misdirected Request',
58
+ 422: 'Unprocessable Content',
59
+ 423: 'Locked',
60
+ 424: 'Failed Dependency',
61
+ 425: 'Too Early',
62
+ 426: 'Upgrade Required',
63
+ 428: 'Precondition Required',
64
+ 429: 'Too Many Requests',
65
+ 431: 'Request Header Fields Too Large',
66
+ 451: 'Unavailable For Legal Reasons',
67
+ 500: 'Internal Server Error',
68
+ 501: 'Not Implemented',
69
+ 502: 'Bad Gateway',
70
+ 503: 'Service Unavailable',
71
+ 504: 'Gateway Timeout',
72
+ 505: 'HTTP Version Not Supported',
73
+ 506: 'Variant Also Negotiates',
74
+ 507: 'Insufficient Storage',
75
+ 508: 'Loop Detected',
76
+ 510: 'Not Extended',
77
+ 511: 'Network Authentication Required',
78
+ };
79
+ /** Returns the standard title for a recognized HTTP status. */
80
+ export function statusTitle(status) {
81
+ return titles[status];
82
+ }
83
+ //# sourceMappingURL=status-title.js.map