-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dc4ca13
Showing
23 changed files
with
1,584 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist | ||
node_modules | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
arrowParens: avoid | ||
bracketSpacing: false | ||
printWidth: 120 | ||
proseWrap: always | ||
quoteProps: consistent | ||
semi: false | ||
singleQuote: true | ||
trailingComma: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) Hampus Kraft | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
Footer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# itsdangerous.js | ||
|
||
... so better sign this. | ||
|
||
Various helpers to pass data to untrusted environments and to get it back safe and sound. Data is cryptographically | ||
signed to ensure that a token has not been tampered with. | ||
|
||
It's possible to customize how data is serialized. Data is compressed as needed. A timestamp can be added and verified | ||
automatically while loading a token. | ||
|
||
> Note: This is an unofficial Node.js port of the Python library | ||
> [itsdangerous](https://github.com/pallets/itsdangerous). | ||
## Installing | ||
|
||
```sh | ||
npm install itsdangerous.js | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import {URLSafeSerializer} from 'itsdangerous.js' | ||
|
||
const authSerializer = new URLSafeSerializer({secretKey: 'secret key', salt: 'auth'}) | ||
const token = authSerializer.stringify({id: 5, name: 'itsdangerous'}) | ||
|
||
console.log(token.toString()) // eyJpZCI6NSwibmFtZSI6Iml0c2Rhbmdlcm91cyJ9.6YP6T0BaO67XP--9UzTrmurXSmg | ||
|
||
const data = authSerializer.parse(token) | ||
console.log(data.name) // itsdangerous | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "itsdangerous.js", | ||
"version": "1.0.0", | ||
"description": "Safely pass trusted data to untrusted environments and back.", | ||
"keywords": [ | ||
"hmac", | ||
"itsdangerous", | ||
"pallets", | ||
"python", | ||
"security", | ||
"serialization" | ||
], | ||
"repository": "hampuskraft/itsdangerous.js", | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"type": "module", | ||
"exports": "./dist/index.js", | ||
"types": "./dist", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "rm -rf dist && tsc", | ||
"format": "prettier --write .", | ||
"prepublishOnly": "npm run -s build", | ||
"test": "vitest run" | ||
}, | ||
"dependencies": { | ||
"ts-mixer": "^6.0.1" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/node18-strictest-esm": "^1.0.1", | ||
"@types/node": "^18.7.14", | ||
"prettier": "^2.7.1", | ||
"typescript": "^4.8.2", | ||
"vite": "^3.0.9", | ||
"vitest": "^0.22.1" | ||
}, | ||
"engines": { | ||
"node": ">=16.17" | ||
} | ||
} |
Oops, something went wrong.