Skip to content
Open
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: 0 additions & 10 deletions .eslintrc.js

This file was deleted.

3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
/.ember-cli
/.env*
/.eslintcache
/.eslintignore
/.eslintrc.js
/.git/
/.github/
/.gitignore
Expand All @@ -21,6 +19,7 @@
/.watchmanconfig
/CONTRIBUTING.md
/ember-cli-build.js
/eslint.config.mjs
/testem.js
/tests/
/tsconfig.declarations.json
Expand Down
10 changes: 9 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
"use strict";

module.exports = {
plugins: ["prettier-plugin-ember-template-tag"],
overrides: [
{
files: "*.{js,ts}",
files: "*.{js,gjs,ts,gts,mjs,mts,cjs,cts}",
options: {
singleQuote: false,
},
},
{
files: "*.{gjs,gts}",
options: {
singleQuote: false,
templateSingleQuote: false,
},
},
],
};
40 changes: 22 additions & 18 deletions addon/authenticators/oidc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { later } from "@ember/runloop";
import { inject as service } from "@ember/service";
import {
isServerErrorResponse,
isAbortError,
isBadRequestResponse,
} from "ember-fetch/errors";
import { waitForPromise } from "@ember/test-waiters";
import BaseAuthenticator from "ember-simple-auth/authenticators/base";
import fetch from "fetch";
import { resolve } from "rsvp";
import { TrackedObject } from "tracked-built-ins";

import config from "ember-simple-auth-oidc/config";
import getAbsoluteUrl from "ember-simple-auth-oidc/utils/absolute-url";

function isServerErrorResponse(response) {
return response.status >= 500 && response.status < 600;
}

function isAbortError(error) {
return error.name === "AbortError";
}

function isBadRequestResponse(response) {
return response.status === 400;
}

export default class OidcAuthenticator extends BaseAuthenticator {
@service router;
@service session;
Expand Down Expand Up @@ -57,16 +64,15 @@ export default class OidcAuthenticator extends BaseAuthenticator {
.map((k) => `${k}=${encodeURIComponent(bodyObject[k])}`)
.join("&");

const response = await fetch(
getAbsoluteUrl(this.config.tokenEndpoint, this.config.host),
{
const response = await waitForPromise(
fetch(getAbsoluteUrl(this.config.tokenEndpoint, this.config.host), {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
body,
},
}),
);

const isServerError = isServerErrorResponse(response);
Expand Down Expand Up @@ -176,16 +182,15 @@ export default class OidcAuthenticator extends BaseAuthenticator {
.map((k) => `${k}=${encodeURIComponent(bodyObject[k])}`)
.join("&");

const response = await fetch(
getAbsoluteUrl(this.config.tokenEndpoint, this.config.host),
{
const response = await waitForPromise(
fetch(getAbsoluteUrl(this.config.tokenEndpoint, this.config.host), {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
body,
},
}),
);
isServerError = isServerErrorResponse(response);
if (isServerError) throw new Error(response.message);
Expand Down Expand Up @@ -227,14 +232,13 @@ export default class OidcAuthenticator extends BaseAuthenticator {
* @returns {Object} Object containing the user information
*/
async _getUserinfo(accessToken) {
const response = await fetch(
getAbsoluteUrl(this.config.userinfoEndpoint, this.config.host),
{
const response = await waitForPromise(
fetch(getAbsoluteUrl(this.config.userinfoEndpoint, this.config.host), {
headers: {
Authorization: `${this.config.authPrefix} ${accessToken}`,
Accept: "application/json",
},
},
}),
);

const userinfo = await response.json();
Expand Down
3 changes: 0 additions & 3 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ const EmberAddon = require("ember-cli/lib/broccoli/ember-addon");
module.exports = function (defaults) {
const app = new EmberAddon(defaults, {
// Add options here
"ember-fetch": {
nativePromise: true,
},
});

/*
Expand Down
30 changes: 4 additions & 26 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
import path from "node:path";
import { fileURLToPath } from "node:url";

import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
import adfinisEmberAddonConfig from "@adfinis/eslint-config/ember-addon";
import ember from "eslint-plugin-ember";

export default [
...adfinisEmberAddonConfig,
{
ignores: [
"blueprints/*/files/",
"declarations/",
"dist/",
"coverage/",
"!**/.*",
"**/.*/",
".node_modules.ember-try/",
],
},
...compat.extends("@adfinis/eslint-config/ember-addon"),
{
plugins: { ember },
settings: {
"import/internal-regex": "^ember-simple-auth-oidc/",
},

rules: {
"ember/no-runloop": "warn",
},
Expand Down
46 changes: 25 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
"repository": "https://github.com/adfinis/ember-simple-auth-oidc",
"scripts": {
"build": "ember build --environment=production",
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"",
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
"lint:css": "stylelint \"**/*.css\"",
"lint:css:fix": "concurrently \"pnpm:lint:css -- --fix\"",
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\"",
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto",
"lint:hbs": "ember-template-lint .",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"start": "ember serve",
"test": "concurrently \"pnpm:lint\" \"pnpm:test:*\" --names \"lint,test:\"",
"test": "concurrently \"pnpm:lint\" \"pnpm:test:*\" --names \"lint,test:\" --prefixColors auto",
"test:ember": "ember test",
"test:ember-compatibility": "ember try:each",
"prepare": "husky"
Expand All @@ -36,28 +36,29 @@
"ember-auto-import": "^2.10.0",
"ember-cli-babel": "^8.2.0",
"ember-concurrency": "^4.0.2",
"ember-fetch": "^8.1.2",
"ember-simple-auth": "^6.0.0",
"ember-template-imports": "^4.2.0",
"js-sha256": "^0.11.0",
"tracked-built-ins": "^3.3.0",
"uuid": "^11.0.3"
},
"devDependencies": {
"@adfinis/eslint-config": "2.1.1",
"@adfinis/eslint-config": "3.0.1",
"@adfinis/semantic-release-config": "5.0.0",
"@babel/eslint-parser": "7.25.9",
"@babel/plugin-proposal-decorators": "7.25.9",
"@commitlint/cli": "19.6.0",
"@commitlint/cli": "19.6.1",
"@commitlint/config-conventional": "19.6.0",
"@ember/optional-features": "2.2.0",
"@ember/string": "4.0.0",
"@ember/test-helpers": "4.0.4",
"@embroider/test-setup": "4.0.0",
"@eslint/js": "9.17.0",
"@glimmer/tracking": "1.1.2",
"broccoli-asset-rev": "3.0.0",
"concurrently": "9.1.0",
"concurrently": "9.1.2",
"ember-apollo-client": "4.1.1",
"ember-cli": "6.0.1",
"ember-cli": "6.1.0",
"ember-cli-clean-css": "3.0.0",
"ember-cli-dependency-checker": "3.3.3",
"ember-cli-htmlbars": "6.3.0",
Expand All @@ -66,41 +67,44 @@
"ember-cli-sri": "2.1.1",
"ember-cli-terser": "4.0.2",
"ember-data": "5.3.9",
"ember-fetch": "8.1.2",
"ember-load-initializers": "3.0.1",
"ember-qunit": "8.1.1",
"ember-qunit": "9.0.1",
"ember-resolver": "13.1.0",
"ember-source": "6.0.1",
"ember-source": "6.1.0",
"ember-source-channel-url": "3.0.0",
"ember-template-lint": "6.0.0",
"ember-try": "3.0.0",
"eslint": "9.15.0",
"eslint": "9.17.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-ember": "12.3.3",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-n": "17.14.0",
"eslint-plugin-n": "17.15.1",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-qunit": "8.1.2",
"graphql": "16.9.0",
"globals": "15.14.0",
"graphql": "16.10.0",
"graphql-tag": "2.12.6",
"husky": "9.1.7",
"lint-staged": "15.2.10",
"lint-staged": "15.3.0",
"loader.js": "4.7.0",
"miragejs": "0.1.48",
"prettier": "3.3.3",
"qunit": "2.22.0",
"qunit-dom": "3.3.0",
"semantic-release": "24.2.0",
"stylelint": "16.10.0",
"prettier": "3.4.2",
"prettier-plugin-ember-template-tag": "2.0.4",
"qunit": "2.23.1",
"qunit-dom": "3.4.0",
"semantic-release": "24.2.1",
"stylelint": "16.12.0",
"stylelint-config-standard": "36.0.1",
"stylelint-prettier": "5.0.2",
"webpack": "5.96.1"
"webpack": "5.97.1"
},
"peerDependencies": {
"@ember-data/adapter": "~4.12.0 || >= 5.0.0",
"ember-data": "~4.12.0 || >= 5.0.0",
"ember-source": ">= 4.0.0"
},
"packageManager": "pnpm@9.14.2",
"packageManager": "pnpm@9.15.3",
"engines": {
"node": ">= 18"
},
Expand Down
Loading
Loading