@ticketmaster/allure-mock
Advanced tools
Comparing version 5.5.34-alpha.0 to 5.5.34-alpha.1
import { NextResponse } from 'next/server'; | ||
import { headers } from 'next/headers'; | ||
import { jwtDecode } from 'jwt-decode'; | ||
@@ -386,2 +385,3 @@ import * as jose from 'jose'; | ||
let token = ""; | ||
function identityMockApi(request) { | ||
@@ -393,3 +393,3 @@ var _a, _b, _c, _d, _e, _f; | ||
const { token: ott, market } = yield request.json(); | ||
const token = yield generateJWT({ ott, market }); | ||
token = (yield generateJWT({ ott, market })) || ""; | ||
return token | ||
@@ -400,3 +400,3 @@ ? new NextResponse("", { | ||
"content-type": "application/json", | ||
"Set-Cookie": `tmtools_token=${JSON.stringify(token)}; path=/; sameSite=Strict;`, | ||
"Set-Cookie": `tmtools_token=${JSON.stringify(token)}; path=/; sameSite=Strict; httpOnly=true;`, | ||
}, | ||
@@ -410,3 +410,2 @@ }) | ||
else if (pathname.startsWith(`/api/v1/token/verify`)) { | ||
const token = headers().get("Authorization") || ""; | ||
let valid = true; | ||
@@ -438,3 +437,2 @@ try { | ||
else if (pathname.startsWith(`/api/v1/token/refresh`)) { | ||
const token = headers().get("Authorization") || ""; | ||
let valid = true; | ||
@@ -445,2 +443,3 @@ let session = undefined; | ||
session = jwtDecode(token); | ||
valid = ((_a = session === null || session === void 0 ? void 0 : session.user) === null || _a === void 0 ? void 0 : _a.username) === "OTT_VALID_WITH_FAILING_REFRESH"; | ||
} | ||
@@ -450,14 +449,11 @@ catch (err) { | ||
} | ||
if (((_a = session === null || session === void 0 ? void 0 : session.user) === null || _a === void 0 ? void 0 : _a.username) === "OTT_VALID_WITH_FAILING_REFRESH") { | ||
valid = false; | ||
} | ||
if (session && valid) { | ||
refreshedToken = yield generateJWT({ | ||
ott: (_b = session === null || session === void 0 ? void 0 : session.user) === null || _b === void 0 ? void 0 : _b.username, | ||
market: (_c = session === null || session === void 0 ? void 0 : session.user) === null || _c === void 0 ? void 0 : _c.market, | ||
systemId: (_e = (_d = session === null || session === void 0 ? void 0 : session.user) === null || _d === void 0 ? void 0 : _d.system) === null || _e === void 0 ? void 0 : _e.id, | ||
ott: (_b = session.user) === null || _b === void 0 ? void 0 : _b.username, | ||
market: (_c = session.user) === null || _c === void 0 ? void 0 : _c.market, | ||
systemId: (_e = (_d = session.user) === null || _d === void 0 ? void 0 : _d.system) === null || _e === void 0 ? void 0 : _e.id, | ||
}); | ||
} | ||
return refreshedToken | ||
? new NextResponse("", { | ||
? new NextResponse(JSON.stringify({ refreshedToken }), { | ||
status: 200, | ||
@@ -475,3 +471,2 @@ headers: { | ||
else if (pathname.startsWith(`/api/v1/sessions/logout`)) { | ||
const token = headers().get("Authorization") || ""; | ||
let session = null; | ||
@@ -488,2 +483,3 @@ let error; | ||
} | ||
token = ""; | ||
return error | ||
@@ -490,0 +486,0 @@ ? new NextResponse(JSON.stringify({ error }), { |
'use strict'; | ||
var server = require('next/server'); | ||
var headers = require('next/headers'); | ||
var jwtDecode = require('jwt-decode'); | ||
@@ -407,2 +406,3 @@ var jose = require('jose'); | ||
let token = ""; | ||
function identityMockApi(request) { | ||
@@ -414,3 +414,3 @@ var _a, _b, _c, _d, _e, _f; | ||
const { token: ott, market } = yield request.json(); | ||
const token = yield generateJWT({ ott, market }); | ||
token = (yield generateJWT({ ott, market })) || ""; | ||
return token | ||
@@ -421,3 +421,3 @@ ? new server.NextResponse("", { | ||
"content-type": "application/json", | ||
"Set-Cookie": `tmtools_token=${JSON.stringify(token)}; path=/; sameSite=Strict;`, | ||
"Set-Cookie": `tmtools_token=${JSON.stringify(token)}; path=/; sameSite=Strict; httpOnly=true;`, | ||
}, | ||
@@ -431,3 +431,2 @@ }) | ||
else if (pathname.startsWith(`/api/v1/token/verify`)) { | ||
const token = headers.headers().get("Authorization") || ""; | ||
let valid = true; | ||
@@ -459,3 +458,2 @@ try { | ||
else if (pathname.startsWith(`/api/v1/token/refresh`)) { | ||
const token = headers.headers().get("Authorization") || ""; | ||
let valid = true; | ||
@@ -466,2 +464,3 @@ let session = undefined; | ||
session = jwtDecode.jwtDecode(token); | ||
valid = ((_a = session === null || session === void 0 ? void 0 : session.user) === null || _a === void 0 ? void 0 : _a.username) === "OTT_VALID_WITH_FAILING_REFRESH"; | ||
} | ||
@@ -471,14 +470,11 @@ catch (err) { | ||
} | ||
if (((_a = session === null || session === void 0 ? void 0 : session.user) === null || _a === void 0 ? void 0 : _a.username) === "OTT_VALID_WITH_FAILING_REFRESH") { | ||
valid = false; | ||
} | ||
if (session && valid) { | ||
refreshedToken = yield generateJWT({ | ||
ott: (_b = session === null || session === void 0 ? void 0 : session.user) === null || _b === void 0 ? void 0 : _b.username, | ||
market: (_c = session === null || session === void 0 ? void 0 : session.user) === null || _c === void 0 ? void 0 : _c.market, | ||
systemId: (_e = (_d = session === null || session === void 0 ? void 0 : session.user) === null || _d === void 0 ? void 0 : _d.system) === null || _e === void 0 ? void 0 : _e.id, | ||
ott: (_b = session.user) === null || _b === void 0 ? void 0 : _b.username, | ||
market: (_c = session.user) === null || _c === void 0 ? void 0 : _c.market, | ||
systemId: (_e = (_d = session.user) === null || _d === void 0 ? void 0 : _d.system) === null || _e === void 0 ? void 0 : _e.id, | ||
}); | ||
} | ||
return refreshedToken | ||
? new server.NextResponse("", { | ||
? new server.NextResponse(JSON.stringify({ refreshedToken }), { | ||
status: 200, | ||
@@ -496,3 +492,2 @@ headers: { | ||
else if (pathname.startsWith(`/api/v1/sessions/logout`)) { | ||
const token = headers.headers().get("Authorization") || ""; | ||
let session = null; | ||
@@ -509,2 +504,3 @@ let error; | ||
} | ||
token = ""; | ||
return error | ||
@@ -511,0 +507,0 @@ ? new server.NextResponse(JSON.stringify({ error }), { |
{ | ||
"name": "@ticketmaster/allure-mock", | ||
"version": "5.5.34-alpha.0", | ||
"version": "5.5.34-alpha.1", | ||
"description": "Allure common mocking solution library", | ||
@@ -25,3 +25,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@ticketmaster/allure-command": "^5.5.34-alpha.0" | ||
"@ticketmaster/allure-command": "^5.5.34-alpha.1" | ||
}, | ||
@@ -28,0 +28,0 @@ "publishConfig": { |
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
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
45132
1162