casdoor-js-sdk
Advanced tools
Comparing version 0.0.1 to 0.0.2
"use strict"; | ||
// Copyright 2021 The casbin Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const sdk_1 = require("./sdk"); | ||
exports.default = sdk_1.default; |
@@ -7,3 +7,3 @@ export interface sdkConfig { | ||
} | ||
export interface accountSession { | ||
export interface account { | ||
organization: string; | ||
@@ -26,7 +26,8 @@ username: string; | ||
constructor(config: sdkConfig); | ||
getSignupUrl(): string; | ||
getSigninUrl(redirectUri?: string): string; | ||
getUserProfileUrl(userName: string, account: accountSession): string; | ||
getMyProfileUrl(account: accountSession): string; | ||
getSignupUrl(enablePassword?: boolean): string; | ||
getSigninUrl(): string; | ||
getUserProfileUrl(userName: string, account: account): string; | ||
getMyProfileUrl(account: account): string; | ||
signin(serverUrl: string): Promise<Response>; | ||
} | ||
export default Sdk; |
"use strict"; | ||
// Copyright 2021 The casbin Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -7,6 +20,12 @@ class Sdk { | ||
} | ||
getSignupUrl() { | ||
return `${this.config.serverUrl.trim()}/signup/${this.config.appName}`; | ||
getSignupUrl(enablePassword = true) { | ||
if (enablePassword) { | ||
return `${this.config.serverUrl.trim()}/signup/${this.config.appName}`; | ||
} | ||
else { | ||
return this.getSigninUrl().replace("/login/oauth/authorize", "/signup/oauth/authorize"); | ||
} | ||
} | ||
getSigninUrl(redirectUri = `${window.location.origin}/callback`) { | ||
getSigninUrl() { | ||
const redirectUri = `${window.location.origin}/callback`; | ||
const scope = "read"; | ||
@@ -30,3 +49,10 @@ const state = this.config.appName; | ||
} | ||
signin(serverUrl) { | ||
const params = new URLSearchParams(window.location.search); | ||
return fetch(`${serverUrl}/api/signin?code=${params.get("code")}&state=${params.get("state")}`, { | ||
method: "POST", | ||
credentials: "include", | ||
}).then(res => res.json()); | ||
} | ||
} | ||
exports.default = Sdk; |
@@ -0,2 +1,15 @@ | ||
// Copyright 2021 The casbin Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
import sdk from './sdk'; | ||
export default sdk; |
@@ -7,3 +7,3 @@ export interface sdkConfig { | ||
} | ||
export interface accountSession { | ||
export interface account { | ||
organization: string; | ||
@@ -26,7 +26,8 @@ username: string; | ||
constructor(config: sdkConfig); | ||
getSignupUrl(): string; | ||
getSigninUrl(redirectUri?: string): string; | ||
getUserProfileUrl(userName: string, account: accountSession): string; | ||
getMyProfileUrl(account: accountSession): string; | ||
getSignupUrl(enablePassword?: boolean): string; | ||
getSigninUrl(): string; | ||
getUserProfileUrl(userName: string, account: account): string; | ||
getMyProfileUrl(account: account): string; | ||
signin(serverUrl: string): Promise<Response>; | ||
} | ||
export default Sdk; |
@@ -0,1 +1,14 @@ | ||
// Copyright 2021 The casbin Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
class Sdk { | ||
@@ -5,6 +18,12 @@ constructor(config) { | ||
} | ||
getSignupUrl() { | ||
return `${this.config.serverUrl.trim()}/signup/${this.config.appName}`; | ||
getSignupUrl(enablePassword = true) { | ||
if (enablePassword) { | ||
return `${this.config.serverUrl.trim()}/signup/${this.config.appName}`; | ||
} | ||
else { | ||
return this.getSigninUrl().replace("/login/oauth/authorize", "/signup/oauth/authorize"); | ||
} | ||
} | ||
getSigninUrl(redirectUri = `${window.location.origin}/callback`) { | ||
getSigninUrl() { | ||
const redirectUri = `${window.location.origin}/callback`; | ||
const scope = "read"; | ||
@@ -28,3 +47,10 @@ const state = this.config.appName; | ||
} | ||
signin(serverUrl) { | ||
const params = new URLSearchParams(window.location.search); | ||
return fetch(`${serverUrl}/api/signin?code=${params.get("code")}&state=${params.get("state")}`, { | ||
method: "POST", | ||
credentials: "include", | ||
}).then(res => res.json()); | ||
} | ||
} | ||
export default Sdk; |
{ | ||
"name": "casdoor-js-sdk", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Javascript client SDK for Casdoor", | ||
"main": "lib/cjs/index.js", | ||
@@ -22,6 +23,24 @@ "typings": "lib/cjs/index.d.ts", | ||
], | ||
"keywords": [ | ||
"auth", | ||
"authn", | ||
"authentication", | ||
"sso", | ||
"oauth", | ||
"oidc", | ||
"casbin", | ||
"casdoor" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/casdoor/casdoor-js-sdk.git" | ||
} | ||
}, | ||
"author": { | ||
"name": "Zxilly", | ||
"email": "zxilly@outlook.com" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/casdoor/casdoor-js-sdk/issues" | ||
}, | ||
"homepage": "https://github.com/casdoor/casdoor-js-sdk" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
20202
208
0
1
2