@frontegg/nextjs 6.7.8 → 6.7.9-alpha.3757258005
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/CHANGELOG.md +6 -0
- package/FronteggClientProviderNext13-b55f477b.js +127 -0
- package/FronteggClientProviderNext13-b55f477b.js.map +1 -0
- package/FronteggConfig-7ae86562.js +123 -0
- package/FronteggConfig-7ae86562.js.map +1 -0
- package/FronteggProvider.d.ts +3 -12
- package/FronteggProviderNoSSR.d.ts +2 -4
- package/README.md +56 -4
- package/api-70f0e81e.js +58 -0
- package/api-70f0e81e.js.map +1 -0
- package/client/FronteggAppRouter.d.ts +10 -0
- package/client/FronteggClientProviderNext13.d.ts +3 -0
- package/client/index.d.ts +2 -0
- package/client/index.js +63 -0
- package/client/index.js.map +1 -0
- package/{FronteggConfig.d.ts → common/FronteggConfig.d.ts} +1 -1
- package/{api.d.ts → common/api.d.ts} +0 -0
- package/{AppContext.d.ts → common/client/AppContext.d.ts} +0 -0
- package/common/client/ExpireInListener.d.ts +1 -0
- package/common/client/FronteggBaseProvider.d.ts +3 -0
- package/common/client/createOrGetFronteggApp.d.ts +11 -0
- package/common/client/hooks/index.d.ts +1 -0
- package/common/client/hooks/useRequestAuthorizeSSR.d.ts +9 -0
- package/common/client/index.d.ts +4 -0
- package/{consts.d.ts → common/consts.d.ts} +0 -0
- package/common/getMeAndTenants.d.ts +2 -0
- package/{helpers.d.ts → common/helpers.d.ts} +7 -9
- package/common/index.d.ts +6 -0
- package/common/index.js +20 -0
- package/common/index.js.map +1 -0
- package/common/types.d.ts +74 -0
- package/common/utils/createGetSession.d.ts +7 -0
- package/common/utils/getCookieFromRequest.d.ts +2 -0
- package/common/utils/index.d.ts +3 -0
- package/common/utils/parseCookie.d.ts +1 -0
- package/createGetSession-81b1748e.js +50 -0
- package/createGetSession-81b1748e.js.map +1 -0
- package/edge/getSessionOnEdge.d.ts +2 -0
- package/edge/index.d.ts +1 -0
- package/edge/index.js +29 -0
- package/edge/index.js.map +1 -0
- package/getCookieFromRequest-624c37b5.js +28 -0
- package/getCookieFromRequest-624c37b5.js.map +1 -0
- package/helpers-dac4dc7b.js +189 -0
- package/helpers-dac4dc7b.js.map +1 -0
- package/index.d.ts +1 -2
- package/index.js +1168 -0
- package/index.js.map +1 -0
- package/package.json +17 -12
- package/refreshToken.d.ts +3 -0
- package/server/FronteggProviderNext13.d.ts +3 -0
- package/server/getSessionNext13.d.ts +4 -0
- package/server/index.d.ts +2 -0
- package/server/index.js +86 -0
- package/server/index.js.map +1 -0
- package/session.d.ts +4 -8
- package/withFronteggApp.d.ts +10 -8
- package/index.cjs.js +0 -2747
- package/index.esm.js +0 -2691
- package/types.d.ts +0 -53
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { FronteggAppOptions } from '@frontegg/types';
|
|
2
|
+
import { ILoginResponse, ITenantsResponse } from '@frontegg/rest-api';
|
|
3
|
+
import { IncomingMessage } from 'http';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { AppRouterInstance } from 'next/dist/shared/lib/app-router-context';
|
|
6
|
+
import { NextRouter } from 'next/router';
|
|
7
|
+
export declare type RequestType = IncomingMessage | Request;
|
|
8
|
+
export interface AccountEnvironment {
|
|
9
|
+
id: string;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
environment: 'production' | 'development';
|
|
12
|
+
}
|
|
13
|
+
export interface CustomClaims {
|
|
14
|
+
accountEnvironments: AccountEnvironment[];
|
|
15
|
+
}
|
|
16
|
+
export interface FronteggUserTokens {
|
|
17
|
+
accessToken: string;
|
|
18
|
+
refreshToken?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface MeAndTenantsResponse {
|
|
21
|
+
user?: ILoginResponse;
|
|
22
|
+
tenants?: ITenantsResponse[];
|
|
23
|
+
}
|
|
24
|
+
export interface FronteggUserSession {
|
|
25
|
+
sub: string;
|
|
26
|
+
name: string;
|
|
27
|
+
email: string;
|
|
28
|
+
email_verified: boolean;
|
|
29
|
+
metadata: any;
|
|
30
|
+
roles: string[];
|
|
31
|
+
permissions: string[];
|
|
32
|
+
tenantId: string;
|
|
33
|
+
tenantIds: string[];
|
|
34
|
+
profilePictureUrl: string;
|
|
35
|
+
type: string;
|
|
36
|
+
customClaims: CustomClaims;
|
|
37
|
+
iat: number;
|
|
38
|
+
exp: number;
|
|
39
|
+
aud: string;
|
|
40
|
+
iss: string;
|
|
41
|
+
}
|
|
42
|
+
export interface FronteggNextJSSession extends FronteggUserTokens {
|
|
43
|
+
user: FronteggUserSession;
|
|
44
|
+
}
|
|
45
|
+
export interface AppEnvConfig {
|
|
46
|
+
envAppUrl?: string;
|
|
47
|
+
envBaseUrl?: string;
|
|
48
|
+
envClientId?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface FronteggProviderOptions extends Omit<FronteggAppOptions, 'contextOptions'> {
|
|
51
|
+
session?: FronteggNextJSSession;
|
|
52
|
+
envAppUrl: string;
|
|
53
|
+
envBaseUrl: string;
|
|
54
|
+
envClientId: string;
|
|
55
|
+
contextOptions?: Omit<FronteggAppOptions['contextOptions'], 'baseUrl'>;
|
|
56
|
+
}
|
|
57
|
+
export interface FronteggProviderProps extends FronteggProviderOptions, MeAndTenantsResponse {
|
|
58
|
+
children?: ReactNode;
|
|
59
|
+
router: AppRouterInstance | NextRouter;
|
|
60
|
+
appName?: string;
|
|
61
|
+
}
|
|
62
|
+
declare module 'iron-session' {
|
|
63
|
+
interface IronSessionData {
|
|
64
|
+
accessToken: FronteggNextJSSession['accessToken'];
|
|
65
|
+
user: FronteggNextJSSession['user'];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
declare global {
|
|
69
|
+
interface ProcessEnv {
|
|
70
|
+
FRONTEGG_BASE_URL: string;
|
|
71
|
+
PORT?: string;
|
|
72
|
+
PWD: string;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FronteggNextJSSession, FronteggUserTokens } from '../types';
|
|
2
|
+
declare type CreateGetSessionParams = {
|
|
3
|
+
getCookie: () => string | undefined;
|
|
4
|
+
cookieResolver: (cookie: string) => Promise<FronteggUserTokens | undefined>;
|
|
5
|
+
};
|
|
6
|
+
export declare const createGetSession: ({ getCookie, cookieResolver, }: CreateGetSessionParams) => Promise<FronteggNextJSSession | undefined>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseCookie(cookieStr: string): string | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { __awaiter, __generator } from 'tslib';
|
|
2
|
+
import { jwtVerify } from 'jose';
|
|
3
|
+
import { F as FronteggConfig } from './FronteggConfig-7ae86562.js';
|
|
4
|
+
|
|
5
|
+
var createGetSession = function (_a) {
|
|
6
|
+
var getCookie = _a.getCookie, cookieResolver = _a.cookieResolver;
|
|
7
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
8
|
+
var cookie, tokens, accessToken, refreshToken, publicKey, payload, session, e_1;
|
|
9
|
+
return __generator(this, function (_b) {
|
|
10
|
+
switch (_b.label) {
|
|
11
|
+
case 0:
|
|
12
|
+
_b.trys.push([0, 4, , 5]);
|
|
13
|
+
cookie = getCookie();
|
|
14
|
+
if (!cookie) {
|
|
15
|
+
return [2 /*return*/, undefined];
|
|
16
|
+
}
|
|
17
|
+
return [4 /*yield*/, cookieResolver(cookie)];
|
|
18
|
+
case 1:
|
|
19
|
+
tokens = _b.sent();
|
|
20
|
+
if (!(tokens === null || tokens === void 0 ? void 0 : tokens.accessToken)) {
|
|
21
|
+
return [2 /*return*/, undefined];
|
|
22
|
+
}
|
|
23
|
+
accessToken = tokens.accessToken, refreshToken = tokens.refreshToken;
|
|
24
|
+
return [4 /*yield*/, FronteggConfig.getJwtPublicKey()];
|
|
25
|
+
case 2:
|
|
26
|
+
publicKey = _b.sent();
|
|
27
|
+
return [4 /*yield*/, jwtVerify(accessToken, publicKey)];
|
|
28
|
+
case 3:
|
|
29
|
+
payload = (_b.sent()).payload;
|
|
30
|
+
session = {
|
|
31
|
+
accessToken: accessToken,
|
|
32
|
+
user: payload,
|
|
33
|
+
refreshToken: refreshToken,
|
|
34
|
+
};
|
|
35
|
+
if (session.user.exp * 1000 < Date.now()) {
|
|
36
|
+
return [2 /*return*/, undefined];
|
|
37
|
+
}
|
|
38
|
+
return [2 /*return*/, session];
|
|
39
|
+
case 4:
|
|
40
|
+
e_1 = _b.sent();
|
|
41
|
+
console.error(e_1);
|
|
42
|
+
return [2 /*return*/, undefined];
|
|
43
|
+
case 5: return [2 /*return*/];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { createGetSession as c };
|
|
50
|
+
//# sourceMappingURL=createGetSession-81b1748e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGetSession-81b1748e.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/edge/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getSessionOnEdge';
|
package/edge/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { __awaiter, __generator } from 'tslib';
|
|
2
|
+
import { unsealData } from 'iron-session/edge';
|
|
3
|
+
import { F as FronteggConfig } from '../FronteggConfig-7ae86562.js';
|
|
4
|
+
import 'cookie';
|
|
5
|
+
import { c as createGetSession } from '../createGetSession-81b1748e.js';
|
|
6
|
+
import { g as getCookieFromRequest } from '../getCookieFromRequest-624c37b5.js';
|
|
7
|
+
import 'jose';
|
|
8
|
+
|
|
9
|
+
function getTokensFromCookieOnEdge(cookie) {
|
|
10
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11
|
+
var jwt;
|
|
12
|
+
return __generator(this, function (_a) {
|
|
13
|
+
switch (_a.label) {
|
|
14
|
+
case 0: return [4 /*yield*/, unsealData(cookie, {
|
|
15
|
+
password: FronteggConfig.passwordsAsMap,
|
|
16
|
+
})];
|
|
17
|
+
case 1:
|
|
18
|
+
jwt = _a.sent();
|
|
19
|
+
return [2 /*return*/, JSON.parse(jwt)];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
var getSession = function (req) {
|
|
25
|
+
return createGetSession({ getCookie: function () { return getCookieFromRequest(req); }, cookieResolver: getTokensFromCookieOnEdge });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { getSession };
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import cookie from 'cookie';
|
|
2
|
+
import { F as FronteggConfig } from './FronteggConfig-7ae86562.js';
|
|
3
|
+
|
|
4
|
+
function parseCookie(cookieStr) {
|
|
5
|
+
var sealFromCookies = '';
|
|
6
|
+
if (cookie.parse(cookieStr)[FronteggConfig.cookieName]) {
|
|
7
|
+
sealFromCookies = cookie.parse(cookieStr)[FronteggConfig.cookieName];
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
var i = 1;
|
|
11
|
+
while (cookie.parse(cookieStr)[FronteggConfig.cookieName + "-" + i]) {
|
|
12
|
+
sealFromCookies += cookie.parse(cookieStr)[FronteggConfig.cookieName + "-" + i];
|
|
13
|
+
i++;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return sealFromCookies !== '' ? sealFromCookies : undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getCookieFromRequest(req) {
|
|
20
|
+
if (!req) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
var cookieStr = 'credentials' in req ? req.headers.get('cookie') || '' : req.headers.cookie || '';
|
|
24
|
+
return parseCookie(cookieStr);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { getCookieFromRequest as g, parseCookie as p };
|
|
28
|
+
//# sourceMappingURL=getCookieFromRequest-624c37b5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCookieFromRequest-624c37b5.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { __awaiter, __generator, __assign, __spreadArrays } from 'tslib';
|
|
2
|
+
import { g as getUsers, a as getTenants } from './api-70f0e81e.js';
|
|
3
|
+
import cookie from 'cookie';
|
|
4
|
+
import { sealData, unsealData } from 'iron-session';
|
|
5
|
+
import { jwtVerify } from 'jose';
|
|
6
|
+
import { F as FronteggConfig } from './FronteggConfig-7ae86562.js';
|
|
7
|
+
|
|
8
|
+
function getMeAndTenants(reqHeaders, accessToken) {
|
|
9
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
10
|
+
var headers, _a, user, tenants;
|
|
11
|
+
return __generator(this, function (_b) {
|
|
12
|
+
switch (_b.label) {
|
|
13
|
+
case 0:
|
|
14
|
+
if (!reqHeaders || !accessToken) {
|
|
15
|
+
return [2 /*return*/, {}];
|
|
16
|
+
}
|
|
17
|
+
headers = __assign(__assign({}, reqHeaders), { Authorization: "Bearer " + accessToken });
|
|
18
|
+
return [4 /*yield*/, Promise.all([getUsers(headers), getTenants(headers)])];
|
|
19
|
+
case 1:
|
|
20
|
+
_a = _b.sent(), user = _a[0], tenants = _a[1];
|
|
21
|
+
return [2 /*return*/, { user: user, tenants: tenants }];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function rewriteCookieProperty(header, config, property) {
|
|
28
|
+
if (Array.isArray(header)) {
|
|
29
|
+
return header.map(function (headerElement) {
|
|
30
|
+
return rewriteCookieProperty(headerElement, config, property);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return header.replace(new RegExp('(;\\s*' + property + '=)([^;]+)', 'i'), function (match, prefix, previousValue) {
|
|
34
|
+
var newValue;
|
|
35
|
+
if (previousValue in config) {
|
|
36
|
+
newValue = config[previousValue];
|
|
37
|
+
}
|
|
38
|
+
else if ('*' in config) {
|
|
39
|
+
newValue = config['*'];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// no match, return previous value
|
|
43
|
+
return match;
|
|
44
|
+
}
|
|
45
|
+
if (newValue) {
|
|
46
|
+
// replace value
|
|
47
|
+
return prefix + newValue;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// remove value
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
var COOKIE_MAX_LENGTH = 4096;
|
|
56
|
+
function createCookie(_a) {
|
|
57
|
+
var _b = _a.cookieName, cookieName = _b === void 0 ? FronteggConfig.cookieName : _b, session = _a.session, expires = _a.expires, isSecured = _a.isSecured, _c = _a.cookieDomain, cookieDomain = _c === void 0 ? FronteggConfig.cookieDomain : _c, _d = _a.httpOnly, httpOnly = _d === void 0 ? true : _d, _e = _a.path, path = _e === void 0 ? '/' : _e;
|
|
58
|
+
var options = {
|
|
59
|
+
expires: expires,
|
|
60
|
+
httpOnly: httpOnly,
|
|
61
|
+
domain: cookieDomain,
|
|
62
|
+
path: path,
|
|
63
|
+
sameSite: isSecured ? 'none' : undefined,
|
|
64
|
+
secure: isSecured,
|
|
65
|
+
};
|
|
66
|
+
var cookieValue = cookie.serialize(cookieName, session, options);
|
|
67
|
+
if (cookieValue.length < COOKIE_MAX_LENGTH) {
|
|
68
|
+
return [cookieValue];
|
|
69
|
+
}
|
|
70
|
+
return createSplitCookie(cookieName, session, options, cookieValue.length);
|
|
71
|
+
}
|
|
72
|
+
function createSplitCookie(cookieName, session, options, cookieLength) {
|
|
73
|
+
var numberOfCookies = Math.ceil(cookieLength / COOKIE_MAX_LENGTH);
|
|
74
|
+
var splitSession = chunkString(session, numberOfCookies);
|
|
75
|
+
var allCookies = [];
|
|
76
|
+
for (var i = 1; i <= numberOfCookies; i++) {
|
|
77
|
+
allCookies.push(cookie.serialize(cookieName + "-" + i, splitSession[i - 1], options));
|
|
78
|
+
}
|
|
79
|
+
return allCookies;
|
|
80
|
+
}
|
|
81
|
+
function chunkString(str, numChunks) {
|
|
82
|
+
var chunkSize = Math.ceil(str.length / numChunks);
|
|
83
|
+
var chunks = [];
|
|
84
|
+
for (var i = 0; i < numChunks; i + chunkSize) {
|
|
85
|
+
var limit = i + chunkSize;
|
|
86
|
+
chunks.push(str.substring(i, limit < str.length ? limit : str.length));
|
|
87
|
+
}
|
|
88
|
+
return chunks;
|
|
89
|
+
}
|
|
90
|
+
function parseCookieFromArray(cookies) {
|
|
91
|
+
var userCookie = cookies.find(function (c) { return c.name === FronteggConfig.cookieName; });
|
|
92
|
+
if (userCookie) {
|
|
93
|
+
return userCookie.value;
|
|
94
|
+
}
|
|
95
|
+
var cookieChunks = cookies.filter(function (c) { return c.name.includes(FronteggConfig.cookieName); });
|
|
96
|
+
if (!cookieChunks) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
cookieChunks.sort(function (a, b) { return (parseInt(a.name) > parseInt(b.name) ? 1 : -1); });
|
|
100
|
+
return cookieChunks.map(function (c) { return c.value; }).join();
|
|
101
|
+
}
|
|
102
|
+
function addToCookies(newCookies, res) {
|
|
103
|
+
var _a;
|
|
104
|
+
var existingSetCookie = (_a = res.getHeader('set-cookie')) !== null && _a !== void 0 ? _a : [];
|
|
105
|
+
if (typeof existingSetCookie === 'string') {
|
|
106
|
+
existingSetCookie = [existingSetCookie];
|
|
107
|
+
}
|
|
108
|
+
res.setHeader('set-cookie', __spreadArrays(existingSetCookie, newCookies));
|
|
109
|
+
}
|
|
110
|
+
function removeCookies(cookieName, isSecured, cookieDomain, res) {
|
|
111
|
+
var _a;
|
|
112
|
+
var cookieValue = createCookie({ cookieName: cookieName, session: '', expires: new Date(), isSecured: isSecured, cookieDomain: cookieDomain });
|
|
113
|
+
var existingSetCookie = (_a = res.getHeader('set-cookie')) !== null && _a !== void 0 ? _a : [];
|
|
114
|
+
if (typeof existingSetCookie === 'string') {
|
|
115
|
+
existingSetCookie = [existingSetCookie];
|
|
116
|
+
}
|
|
117
|
+
res.setHeader('set-cookie', __spreadArrays(existingSetCookie, cookieValue));
|
|
118
|
+
}
|
|
119
|
+
function createSessionFromAccessToken(output) {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var data, accessToken, refreshToken, publicKey, decodedJwt, stringifySession, session;
|
|
123
|
+
return __generator(this, function (_c) {
|
|
124
|
+
switch (_c.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
_c.trys.push([0, 4, , 5]);
|
|
127
|
+
data = JSON.parse(output);
|
|
128
|
+
accessToken = (_a = data === null || data === void 0 ? void 0 : data.accessToken) !== null && _a !== void 0 ? _a : data.access_token;
|
|
129
|
+
refreshToken = (_b = data === null || data === void 0 ? void 0 : data.refreshToken) !== null && _b !== void 0 ? _b : data.refresh_token;
|
|
130
|
+
return [4 /*yield*/, FronteggConfig.getJwtPublicKey()];
|
|
131
|
+
case 1:
|
|
132
|
+
publicKey = _c.sent();
|
|
133
|
+
return [4 /*yield*/, jwtVerify(accessToken, publicKey)];
|
|
134
|
+
case 2:
|
|
135
|
+
decodedJwt = (_c.sent()).payload;
|
|
136
|
+
decodedJwt.expiresIn = Math.floor((decodedJwt.exp * 1000 - Date.now()) / 1000);
|
|
137
|
+
stringifySession = JSON.stringify({ accessToken: accessToken, refreshToken: refreshToken });
|
|
138
|
+
return [4 /*yield*/, sealData(stringifySession, {
|
|
139
|
+
password: FronteggConfig.passwordsAsMap,
|
|
140
|
+
ttl: decodedJwt.exp,
|
|
141
|
+
})];
|
|
142
|
+
case 3:
|
|
143
|
+
session = _c.sent();
|
|
144
|
+
return [2 /*return*/, [session, decodedJwt, refreshToken]];
|
|
145
|
+
case 4:
|
|
146
|
+
_c.sent();
|
|
147
|
+
return [2 /*return*/, []];
|
|
148
|
+
case 5: return [2 /*return*/];
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
var modifySetCookieIfUnsecure = function (setCookieValue, isSecured) {
|
|
154
|
+
if (!setCookieValue) {
|
|
155
|
+
return setCookieValue;
|
|
156
|
+
}
|
|
157
|
+
if (setCookieValue.length > 0) {
|
|
158
|
+
return setCookieValue.map(function (c) {
|
|
159
|
+
var cookie = c.split('; ');
|
|
160
|
+
if (isSecured) {
|
|
161
|
+
return c;
|
|
162
|
+
}
|
|
163
|
+
return cookie.filter(function (property) { return property !== 'Secure' && property !== 'SameSite=None'; }).join('; ');
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return setCookieValue;
|
|
167
|
+
};
|
|
168
|
+
function getTokensFromCookie(cookie) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
var stringifyJwt;
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
switch (_a.label) {
|
|
173
|
+
case 0:
|
|
174
|
+
if (!cookie) {
|
|
175
|
+
return [2 /*return*/, undefined];
|
|
176
|
+
}
|
|
177
|
+
return [4 /*yield*/, unsealData(cookie, {
|
|
178
|
+
password: FronteggConfig.passwordsAsMap,
|
|
179
|
+
})];
|
|
180
|
+
case 1:
|
|
181
|
+
stringifyJwt = _a.sent();
|
|
182
|
+
return [2 /*return*/, JSON.parse(stringifyJwt)];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { getMeAndTenants as a, addToCookies as b, createCookie as c, removeCookies as d, createSessionFromAccessToken as e, getTokensFromCookie as g, modifySetCookieIfUnsecure as m, parseCookieFromArray as p, rewriteCookieProperty as r };
|
|
189
|
+
//# sourceMappingURL=helpers-dac4dc7b.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-dac4dc7b.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export * from './FronteggProvider';
|
|
2
2
|
export * from './FronteggProviderNoSSR';
|
|
3
3
|
export * from './AuthorizedContent';
|
|
4
|
-
export { default as FronteggConfig } from './FronteggConfig';
|
|
5
4
|
export * from './FronteggRouter';
|
|
6
5
|
export * from './withFronteggApp';
|
|
7
6
|
export * from './session';
|
|
8
7
|
export * from './FronteggMiddleware';
|
|
8
|
+
export * from './common';
|
|
9
9
|
export { AdminPortal } from '@frontegg/js';
|
|
10
10
|
export * from '@frontegg/react-hooks';
|
|
11
11
|
export * from '@frontegg/types';
|
|
12
|
-
export { ContextHolder } from '@frontegg/rest-api';
|