oidc-client-rx
Version:
ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications
28 lines (27 loc) • 1.22 kB
JavaScript
import { Injectable, inject } from "injection-js";
import { DOCUMENT } from "../../dom/index.js";
function _ts_decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
class CurrentUrlService {
getStateParamFromCurrentUrl(url) {
const currentUrl = url || this.getCurrentUrl();
if (!currentUrl) return null;
const parsedUrl = new URL(currentUrl);
const urlParams = new URLSearchParams(parsedUrl.search);
return urlParams.get("state");
}
getCurrentUrl() {
return this.document?.defaultView?.location.toString() ?? null;
}
constructor(){
this.document = inject(DOCUMENT);
}
}
CurrentUrlService = _ts_decorate([
Injectable()
], CurrentUrlService);
export { CurrentUrlService };