Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hampuskraft committed Sep 1, 2022
0 parents commit dc4ca13
Show file tree
Hide file tree
Showing 23 changed files with 1,584 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
dist
node_modules
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
node_modules
pnpm-lock.yaml
8 changes: 8 additions & 0 deletions .prettierrc.yaml
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
22 changes: 22 additions & 0 deletions LICENSE
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
32 changes: 32 additions & 0 deletions README.md
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
```
42 changes: 42 additions & 0 deletions package.json
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"
}
}
Loading

0 comments on commit dc4ca13

Please sign in to comment.