Skip to content

Commit 6055c7f

Browse files
committed
chore: remove ember-fetch from dependencies
1 parent fa23b37 commit 6055c7f

6 files changed

Lines changed: 1674 additions & 309 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
/npm-debug.log*
1414
/testem.log
1515
/yarn-error.log
16+
/.nvmrc
17+
/.tool-versions
1618

1719
# ember-try
1820
/.node_modules.ember-try/

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ shows an example of a custom fetch service with proper authentication handling:
116116
```js
117117
import Service, { inject as service } from "@ember/service";
118118
import { handleUnauthorized } from "ember-simple-auth-oidc";
119-
import fetch from "fetch";
120119

121120
export default class FetchService extends Service {
122121
@service session;

addon/authenticators/oidc.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { later } from "@ember/runloop";
22
import { inject as service } from "@ember/service";
3-
import {
4-
isServerErrorResponse,
5-
isAbortError,
6-
isBadRequestResponse,
7-
} from "ember-fetch/errors";
83
import BaseAuthenticator from "ember-simple-auth/authenticators/base";
9-
import fetch from "fetch";
104
import { resolve } from "rsvp";
115
import { TrackedObject } from "tracked-built-ins";
126

137
import config from "ember-simple-auth-oidc/config";
148
import getAbsoluteUrl from "ember-simple-auth-oidc/utils/absolute-url";
9+
import {
10+
isServerErrorResponse,
11+
isAbortError,
12+
isBadRequestResponse,
13+
} from "ember-simple-auth-oidc/utils/errors";
1514

1615
export default class OidcAuthenticator extends BaseAuthenticator {
1716
@service router;

addon/utils/errors.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copied from ember-fetch addon/utils/errors.ts (converted to JavaScript)
2+
// This file contains utility functions to check the type of HTTP response errors.
3+
4+
/**
5+
* Checks if the given response represents an unauthorized request error
6+
*/
7+
export function isUnauthorizedResponse(response) {
8+
return response.status === 401;
9+
}
10+
11+
/**
12+
* Checks if the given response represents a forbidden request error
13+
*/
14+
export function isForbiddenResponse(response) {
15+
return response.status === 403;
16+
}
17+
18+
/**
19+
* Checks if the given response represents an invalid request error
20+
*/
21+
export function isInvalidResponse(response) {
22+
return response.status === 422;
23+
}
24+
25+
/**
26+
* Checks if the given response represents a bad request error
27+
*/
28+
export function isBadRequestResponse(response) {
29+
return response.status === 400;
30+
}
31+
32+
/**
33+
* Checks if the given response represents a "not found" error
34+
*/
35+
export function isNotFoundResponse(response) {
36+
return response.status === 404;
37+
}
38+
39+
/**
40+
* Checks if the given response represents a "gone" error
41+
*/
42+
export function isGoneResponse(response) {
43+
return response.status === 410;
44+
}
45+
46+
/**
47+
* Checks if the given error is an "abort" error
48+
*/
49+
export function isAbortError(error) {
50+
return error.name === "AbortError";
51+
}
52+
53+
/**
54+
* Checks if the given response represents a conflict error
55+
*/
56+
export function isConflictResponse(response) {
57+
return response.status === 409;
58+
}
59+
60+
/**
61+
* Checks if the given response represents a server error
62+
*/
63+
export function isServerErrorResponse(response) {
64+
return response.status >= 500 && response.status < 600;
65+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"ember-auto-import": "^2.7.0",
3636
"ember-cli-babel": "^8.2.0",
3737
"ember-concurrency": "^3.1.1",
38-
"ember-fetch": "^8.1.2",
3938
"ember-simple-auth": "^6.0.0",
4039
"js-sha256": "^0.10.1",
4140
"tracked-built-ins": "^3.3.0",
@@ -63,6 +62,7 @@
6362
"ember-cli-sri": "2.1.1",
6463
"ember-cli-terser": "4.0.2",
6564
"ember-data": "5.3.0",
65+
"ember-fetch": "^8.1.2",
6666
"ember-load-initializers": "2.1.2",
6767
"ember-qunit": "8.0.2",
6868
"ember-resolver": "11.0.1",

0 commit comments

Comments
 (0)