casdoor 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # casdoor-chrome-extension
2
2
 
3
- Casdoor chrome extension can help the user to auto login with the casdoor application or login this extension through casdoor.
3
+ The Casdoor extension can help browser users automatically log into applications protected by [Casdoor](https://casdoor.org). The extension's code is open-sourced at: https://github.com/casdoor/casdoor-chrome-extension
4
4
 
5
- Casdoor chrome extension is very simple to use. We will show you the steps below.
5
+ This extension is very simple to use. We will show you the steps below.
6
6
 
7
7
  ## Usage
8
8
 
Binary file
package/images/icon16.png CHANGED
Binary file
package/images/icon32.png CHANGED
Binary file
package/images/icon48.png CHANGED
Binary file
package/manifest.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "Casdoor",
3
- "description": "Casdoor Chrome Extension",
3
+ "description": "The Casdoor extension can help browser users automatically log into applications protected by Casdoor single-sign-on (SSO) system.",
4
4
  "version": "1.0.0",
5
5
  "manifest_version": 3,
6
6
  "permissions": ["storage", "identity"],
@@ -37,4 +37,4 @@
37
37
  "https://*/*",
38
38
  "http://*/*"
39
39
  ]
40
- }
40
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "casdoor",
3
- "version": "1.0.0",
4
- "description": "Casdoor Chrome Extension",
3
+ "version": "1.0.2",
4
+ "description": "The Casdoor extension can help browser users automatically log into applications protected by Casdoor single-sign-on (SSO) system.",
5
5
  "scripts": {
6
6
  "semantic-release": "semantic-release"
7
7
  },
package/src/oauth.js CHANGED
@@ -40,6 +40,7 @@ function login() {
40
40
  .getUserProfile(accessToken)
41
41
  .then((userProfile) => displayUserProfile(userProfile));
42
42
  });
43
+ setInputDisabledState(true, "endpoint", "applicationName")
43
44
  } else {
44
45
  alert("Login failed!");
45
46
  }
@@ -49,6 +50,7 @@ function login() {
49
50
  // eslint-disable-next-line no-unused-vars
50
51
  function logout() {
51
52
  chrome.storage.sync.set({accessToken: ""}, () => clearUserProfile());
53
+ setInputDisabledState(false, "endpoint", "applicationName")
52
54
  }
53
55
 
54
56
  function displayUserProfile(userProfile) {
@@ -63,3 +65,14 @@ function clearUserProfile() {
63
65
  document.getElementById("user").innerHTML = "";
64
66
  document.getElementById("loginOrLogout").innerText = "Login";
65
67
  }
68
+
69
+ function setInputDisabledState(disabledState, ...elementIds) {
70
+ elementIds.forEach(elementId => {
71
+ const inputElement = document.getElementById(elementId);
72
+ if (inputElement) {
73
+ inputElement.disabled = disabledState;
74
+ } else {
75
+ console.warn(`No element found with ID: ${elementId}`);
76
+ }
77
+ });
78
+ }
package/src/popup.js CHANGED
@@ -40,6 +40,7 @@ document.addEventListener("DOMContentLoaded", function() {
40
40
  const managedAccounts = account.data.managedAccounts;
41
41
  chrome.storage.sync.set({managedAccounts});
42
42
  });
43
+ setInputDisabledState(true, "endpoint", "applicationName")
43
44
  } else {
44
45
  clearUserProfile();
45
46
  }
package/src/sdk.js CHANGED
@@ -38,26 +38,19 @@ class Sdk {
38
38
 
39
39
  getAccessTokenFromRedirectUrl(redirectUrl) {
40
40
  if (redirectUrl) {
41
- const hashTagIndex = redirectUrl.indexOf("#");
42
- const questionMaskIndex = redirectUrl.indexOf("?");
43
- if (
44
- hashTagIndex > 0 &&
45
- questionMaskIndex > 0 &&
46
- hashTagIndex < questionMaskIndex
47
- ) {
48
- // e.g. "https://${extensionId}.chromiumapp.org#token=${accessToken}?state=${state}&token_type=bearer"
49
- return redirectUrl.substring(hashTagIndex + 7, questionMaskIndex);
50
- }
41
+ const accessTokenMatch = redirectUrl.match(/#access_token=([^&]*)/);
42
+ const accessToken = accessTokenMatch ? accessTokenMatch[1] : "";
43
+ return accessToken;
51
44
  }
52
45
  return "";
53
46
  }
54
47
 
55
48
  login(func) {
56
- this.getApplication().then(application => {
49
+ this.getApplication().then((res) => {
57
50
  // refer: https://developer.chrome.com/docs/extensions/reference/identity/#method-launchWebAuthFlow
58
51
  chrome.identity.launchWebAuthFlow(
59
52
  {
60
- url: this.getSignInUrl(application.clientId),
53
+ url: this.getSignInUrl(res.data.clientId),
61
54
  interactive: true,
62
55
  },
63
56
  (redirectUrl) => {