@leancodepl/kratos 7.1.6 → 7.2.1
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/index.cjs.js +14 -16
- package/index.esm.js +15 -17
- package/package.json +1 -1
- package/src/lib/sessionManager/baseSessionManager.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -7,7 +7,6 @@ var axios = require('axios');
|
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var _ = require('lodash');
|
|
9
9
|
var rxjs = require('rxjs');
|
|
10
|
-
var ajax = require('rxjs/ajax');
|
|
11
10
|
var react = require('react');
|
|
12
11
|
var reactHookForm = require('react-hook-form');
|
|
13
12
|
var reactRouter = require('react-router');
|
|
@@ -120,7 +119,7 @@ var BaseSessionManager = /*#__PURE__*/ function() {
|
|
|
120
119
|
function BaseSessionManager(authUrl, signInRoute) {
|
|
121
120
|
var _this = this;
|
|
122
121
|
_class_call_check(this, BaseSessionManager);
|
|
123
|
-
_define_property$3(this, "
|
|
122
|
+
_define_property$3(this, "authUrl", void 0);
|
|
124
123
|
_define_property$3(this, "signInRoute", void 0);
|
|
125
124
|
_define_property$3(this, "session$", new rxjs.ReplaySubject(1));
|
|
126
125
|
_define_property$3(this, "isSignedIn$", this.session$.pipe(rxjs.map(function(session) {
|
|
@@ -138,13 +137,12 @@ var BaseSessionManager = /*#__PURE__*/ function() {
|
|
|
138
137
|
_define_property$3(this, "checkIfSignedIn", function() {
|
|
139
138
|
var fetchSubject = new rxjs.Subject();
|
|
140
139
|
fetchSubject.pipe(rxjs.switchMap(function() {
|
|
141
|
-
return
|
|
142
|
-
url: "".concat(_this.apiUrl, "/sessions/whoami"),
|
|
140
|
+
return rxjs.from(fetch("".concat(_this.authUrl, "/sessions/whoami"), {
|
|
143
141
|
method: "GET",
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
credentials: "include"
|
|
143
|
+
})).pipe(rxjs.switchMap(function(response) {
|
|
144
|
+
return rxjs.from(response.json());
|
|
145
|
+
}), rxjs.map(function(response) {
|
|
148
146
|
var returnTo = new URLSearchParams(window.location.search).get(returnToParameterName);
|
|
149
147
|
if (returnTo) {
|
|
150
148
|
window.location.href = returnTo;
|
|
@@ -180,14 +178,14 @@ var BaseSessionManager = /*#__PURE__*/ function() {
|
|
|
180
178
|
var fetchSubject = new rxjs.Subject();
|
|
181
179
|
var signOutSubject = new rxjs.Subject();
|
|
182
180
|
fetchSubject.pipe(rxjs.exhaustMap(function() {
|
|
183
|
-
return
|
|
184
|
-
url: "".concat(_this.apiUrl, "/sessions/logout"),
|
|
181
|
+
return rxjs.from(fetch("".concat(_this.authUrl, "/sessions/logout"), {
|
|
185
182
|
method: "GET",
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
183
|
+
credentials: "include"
|
|
184
|
+
})).pipe(rxjs.switchMap(function() {
|
|
185
|
+
return rxjs.of(undefined);
|
|
186
|
+
}), rxjs.catchError(function() {
|
|
187
|
+
return rxjs.of(undefined);
|
|
188
|
+
}));
|
|
191
189
|
})).subscribe({
|
|
192
190
|
next: function() {
|
|
193
191
|
_this.session$.next(undefined);
|
|
@@ -199,7 +197,7 @@ var BaseSessionManager = /*#__PURE__*/ function() {
|
|
|
199
197
|
return rxjs.firstValueFrom(signOutSubject);
|
|
200
198
|
};
|
|
201
199
|
}());
|
|
202
|
-
this.
|
|
200
|
+
this.authUrl = authUrl;
|
|
203
201
|
this.signInRoute = signInRoute;
|
|
204
202
|
this.checkIfSignedIn();
|
|
205
203
|
}
|
package/index.esm.js
CHANGED
|
@@ -2,8 +2,7 @@ import { FrontendApi, Configuration } from '@ory/kratos-client';
|
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import _, { set, omit } from 'lodash';
|
|
5
|
-
import { ReplaySubject, map, shareReplay, Subject, switchMap, catchError, of, exhaustMap, firstValueFrom } from 'rxjs';
|
|
6
|
-
import { ajax } from 'rxjs/ajax';
|
|
5
|
+
import { ReplaySubject, map, shareReplay, Subject, switchMap, from, catchError, of, exhaustMap, firstValueFrom } from 'rxjs';
|
|
7
6
|
import { useMemo, useEffect, useState, useCallback } from 'react';
|
|
8
7
|
import { useFormContext, useForm, FormProvider } from 'react-hook-form';
|
|
9
8
|
import { useLocation, useNavigate } from 'react-router';
|
|
@@ -110,7 +109,7 @@ var BaseSessionManager = /*#__PURE__*/ function() {
|
|
|
110
109
|
function BaseSessionManager(authUrl, signInRoute) {
|
|
111
110
|
var _this = this;
|
|
112
111
|
_class_call_check(this, BaseSessionManager);
|
|
113
|
-
_define_property$3(this, "
|
|
112
|
+
_define_property$3(this, "authUrl", void 0);
|
|
114
113
|
_define_property$3(this, "signInRoute", void 0);
|
|
115
114
|
_define_property$3(this, "session$", new ReplaySubject(1));
|
|
116
115
|
_define_property$3(this, "isSignedIn$", this.session$.pipe(map(function(session) {
|
|
@@ -128,13 +127,12 @@ var BaseSessionManager = /*#__PURE__*/ function() {
|
|
|
128
127
|
_define_property$3(this, "checkIfSignedIn", function() {
|
|
129
128
|
var fetchSubject = new Subject();
|
|
130
129
|
fetchSubject.pipe(switchMap(function() {
|
|
131
|
-
return
|
|
132
|
-
url: "".concat(_this.apiUrl, "/sessions/whoami"),
|
|
130
|
+
return from(fetch("".concat(_this.authUrl, "/sessions/whoami"), {
|
|
133
131
|
method: "GET",
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
credentials: "include"
|
|
133
|
+
})).pipe(switchMap(function(response) {
|
|
134
|
+
return from(response.json());
|
|
135
|
+
}), map(function(response) {
|
|
138
136
|
var returnTo = new URLSearchParams(window.location.search).get(returnToParameterName);
|
|
139
137
|
if (returnTo) {
|
|
140
138
|
window.location.href = returnTo;
|
|
@@ -170,14 +168,14 @@ var BaseSessionManager = /*#__PURE__*/ function() {
|
|
|
170
168
|
var fetchSubject = new Subject();
|
|
171
169
|
var signOutSubject = new Subject();
|
|
172
170
|
fetchSubject.pipe(exhaustMap(function() {
|
|
173
|
-
return
|
|
174
|
-
url: "".concat(_this.apiUrl, "/sessions/logout"),
|
|
171
|
+
return from(fetch("".concat(_this.authUrl, "/sessions/logout"), {
|
|
175
172
|
method: "GET",
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
credentials: "include"
|
|
174
|
+
})).pipe(switchMap(function() {
|
|
175
|
+
return of(undefined);
|
|
176
|
+
}), catchError(function() {
|
|
177
|
+
return of(undefined);
|
|
178
|
+
}));
|
|
181
179
|
})).subscribe({
|
|
182
180
|
next: function() {
|
|
183
181
|
_this.session$.next(undefined);
|
|
@@ -189,7 +187,7 @@ var BaseSessionManager = /*#__PURE__*/ function() {
|
|
|
189
187
|
return firstValueFrom(signOutSubject);
|
|
190
188
|
};
|
|
191
189
|
}());
|
|
192
|
-
this.
|
|
190
|
+
this.authUrl = authUrl;
|
|
193
191
|
this.signInRoute = signInRoute;
|
|
194
192
|
this.checkIfSignedIn();
|
|
195
193
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Session } from "@ory/kratos-client";
|
|
2
2
|
import { Subject } from "rxjs";
|
|
3
3
|
export declare class BaseSessionManager {
|
|
4
|
-
|
|
4
|
+
authUrl: string;
|
|
5
5
|
signInRoute: string;
|
|
6
6
|
session$: Subject<Session | undefined>;
|
|
7
7
|
isSignedIn$: import("rxjs").Observable<boolean>;
|