popsicle-cookie-jar
Advanced tools
Comparing version
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cookies = exports.CookieJar = void 0; | ||
const tough_cookie_1 = require("tough-cookie"); | ||
exports.CookieJar = tough_cookie_1.CookieJar; | ||
Object.defineProperty(exports, "CookieJar", { enumerable: true, get: function () { return tough_cookie_1.CookieJar; } }); | ||
/** | ||
@@ -6,0 +7,0 @@ * Read and write cookies with a cookie jar. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const vitest_1 = require("vitest"); | ||
const node_1 = require("servie/dist/node"); | ||
const index_1 = require("./index"); | ||
const node_1 = require("servie/dist/node"); | ||
describe("popsicle cookie jar", () => { | ||
(0, vitest_1.describe)("popsicle cookie jar", () => { | ||
const req = new node_1.Request("http://example.com/"); | ||
@@ -12,31 +13,31 @@ const ok = new node_1.Response(null, { status: 200 }); | ||
Location: "/test", | ||
"Set-Cookie": "hello=world; expires=Wed, 01 Jan 3000 00:00:00 GMT; path=/" | ||
} | ||
"Set-Cookie": "hello=world; expires=Wed, 01 Jan 3000 00:00:00 GMT; path=/", | ||
}, | ||
}); | ||
it("should use cookie store for requests", async () => { | ||
const middleware = index_1.cookies(); | ||
(0, vitest_1.it)("should use cookie store for requests", async () => { | ||
const middleware = (0, index_1.cookies)(); | ||
const res1 = await middleware(req.clone(), async () => redirect.clone()); | ||
expect(res1.headers.get("set-cookie")).not.toBeNull(); | ||
(0, vitest_1.expect)(res1.headers.get("set-cookie")).not.toBeNull(); | ||
const req2 = req.clone(); | ||
const res2 = await middleware(req2, async () => { | ||
expect(req2.headers.get("cookie")).toEqual("hello=world"); | ||
(0, vitest_1.expect)(req2.headers.get("cookie")).toEqual("hello=world"); | ||
return ok.clone(); | ||
}); | ||
expect(res2.headers.get("set-cookie")).toBeNull(); | ||
expect.assertions(3); | ||
(0, vitest_1.expect)(res2.headers.get("set-cookie")).toBeNull(); | ||
vitest_1.expect.assertions(3); | ||
}); | ||
it("should allow custom cookie jars", async () => { | ||
(0, vitest_1.it)("should allow custom cookie jars", async () => { | ||
const jar = new index_1.CookieJar(); | ||
const middleware = index_1.cookies(jar); | ||
const middleware = (0, index_1.cookies)(jar); | ||
jar.setCookieSync("test=true", req.url); | ||
const req1 = req.clone(); | ||
const res2 = await middleware(req1, async () => { | ||
expect(req1.headers.get("cookie")).toEqual("test=true"); | ||
(0, vitest_1.expect)(req1.headers.get("cookie")).toEqual("test=true"); | ||
return ok.clone(); | ||
}); | ||
expect(res2.headers.get("set-cookie")).toBeNull(); | ||
(0, vitest_1.expect)(res2.headers.get("set-cookie")).toBeNull(); | ||
}); | ||
it("should merge cookies with existing cookies", async () => { | ||
(0, vitest_1.it)("should merge cookies with existing cookies", async () => { | ||
const jar = new index_1.CookieJar(); | ||
const middleware = index_1.cookies(jar); | ||
const middleware = (0, index_1.cookies)(jar); | ||
jar.setCookieSync("test=true", req.url); | ||
@@ -46,8 +47,8 @@ const req1 = req.clone(); | ||
const res2 = await middleware(req1, async () => { | ||
expect(req1.headers.get("cookie")).toEqual("manual=true; test=true"); | ||
(0, vitest_1.expect)(req1.headers.get("cookie")).toEqual("manual=true; test=true"); | ||
return ok.clone(); | ||
}); | ||
expect(res2.headers.get("set-cookie")).toBeNull(); | ||
(0, vitest_1.expect)(res2.headers.get("set-cookie")).toBeNull(); | ||
}); | ||
}); | ||
//# sourceMappingURL=index.spec.js.map |
117
package.json
{ | ||
"name": "popsicle-cookie-jar", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Popsicle middleware for supporting cookies in node.js", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist/" | ||
], | ||
"scripts": { | ||
"prettier": "prettier --write", | ||
"lint": "tslint \"src/**/*.ts\" --project tsconfig.json", | ||
"format": "npm run prettier -- README.md \"*.yml\" \"src/**/*.{js,ts}\"", | ||
"build": "rimraf dist && tsc", | ||
"specs": "jest --coverage", | ||
"test": "npm run lint && npm run build && npm run specs", | ||
"prepare": "npm run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/serviejs/popsicle-cookie-jar.git" | ||
}, | ||
"keywords": [ | ||
@@ -30,2 +12,11 @@ "popsicle", | ||
], | ||
"homepage": "https://github.com/serviejs/popsicle-cookie-jar", | ||
"bugs": { | ||
"url": "https://github.com/serviejs/popsicle-cookie-jar/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/serviejs/popsicle-cookie-jar.git" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
@@ -36,24 +27,15 @@ "name": "Blake Embrey", | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/serviejs/popsicle-cookie-jar/issues" | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist/" | ||
], | ||
"scripts": { | ||
"build": "ts-scripts build", | ||
"format": "ts-scripts format", | ||
"prepare": "ts-scripts install", | ||
"prepublishOnly": "npm run build", | ||
"specs": "ts-scripts specs", | ||
"test": "ts-scripts test" | ||
}, | ||
"homepage": "https://github.com/serviejs/popsicle-cookie-jar", | ||
"jest": { | ||
"roots": [ | ||
"<rootDir>/src/" | ||
], | ||
"transform": { | ||
"\\.tsx?$": "ts-jest" | ||
}, | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json", | ||
"node" | ||
] | ||
}, | ||
"husky": { | ||
@@ -70,30 +52,45 @@ "hooks": { | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json", | ||
"node" | ||
], | ||
"roots": [ | ||
"<rootDir>/src/" | ||
], | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$", | ||
"transform": { | ||
"\\.tsx?$": "ts-jest" | ||
} | ||
}, | ||
"peerDependencies": { | ||
"servie": "^4.0.0" | ||
"dependencies": { | ||
"@types/tough-cookie": "^4.0.2", | ||
"tough-cookie": "^4.1.3" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^24.0.13", | ||
"@types/node": "^12.0.7", | ||
"@borderless/ts-scripts": "^0.15.0", | ||
"@types/node": "^20.9.3", | ||
"@types/pump": "^1.1.0", | ||
"@vitest/coverage-v8": "^0.34.6", | ||
"express": "^4.17.1", | ||
"husky": "^2.4.0", | ||
"jest": "^24.8.0", | ||
"lint-staged": "^8.2.0", | ||
"prettier": "^1.18.2", | ||
"jest": "^29.7.0", | ||
"servie": "^4.0.10", | ||
"standard": "^10.0.2", | ||
"throwback": "^4.1.0", | ||
"ts-jest": "^24.0.2", | ||
"tslint": "^5.17.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-config-standard": "^8.0.1", | ||
"typescript": "^3.5.1" | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^5.3.2", | ||
"vitest": "^0.34.6" | ||
}, | ||
"dependencies": { | ||
"@types/tough-cookie": "^2.3.5", | ||
"tough-cookie": "^3.0.1" | ||
"peerDependencies": { | ||
"servie": "^4.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15600
1.75%11
-31.25%93
2.2%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated
Updated