Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
71e0d82655 | |||
03e8d51f9a | |||
bf234bd7b8 |
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -10,10 +10,10 @@ jobs:
|
||||
build:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.5.0'
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v3.1.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: 'npm'
|
||||
@ -23,3 +23,5 @@ jobs:
|
||||
|
||||
- name: 'Build'
|
||||
run: 'npm run build'
|
||||
|
||||
- run: 'npm run build:typescript'
|
||||
|
6
.github/workflows/lint.yml
vendored
6
.github/workflows/lint.yml
vendored
@ -10,10 +10,10 @@ jobs:
|
||||
lint:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.5.0'
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v3.1.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: 'npm'
|
||||
@ -24,5 +24,5 @@ jobs:
|
||||
- run: 'npm run lint:commit -- --to "${{ github.sha }}"'
|
||||
- run: 'npm run lint:editorconfig'
|
||||
- run: 'npm run lint:markdown'
|
||||
- run: 'npm run lint:typescript'
|
||||
- run: 'npm run lint:eslint'
|
||||
- run: 'npm run lint:prettier'
|
||||
|
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -8,10 +8,10 @@ jobs:
|
||||
release:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.5.0'
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v3.1.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: 'npm'
|
||||
@ -22,6 +22,8 @@ jobs:
|
||||
- name: 'Build Package'
|
||||
run: 'npm run build'
|
||||
|
||||
- run: 'npm run build:typescript'
|
||||
|
||||
- name: 'Release'
|
||||
run: 'npm run release'
|
||||
env:
|
||||
|
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -10,10 +10,10 @@ jobs:
|
||||
test:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.5.0'
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v3.1.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: 'npm'
|
||||
|
@ -3,3 +3,4 @@
|
||||
|
||||
npm run lint:staged
|
||||
npm run build
|
||||
npm run build:typescript
|
||||
|
@ -1,10 +1,5 @@
|
||||
{
|
||||
"config": {
|
||||
"default": true,
|
||||
"MD013": false,
|
||||
"MD033": false,
|
||||
"MD041": false
|
||||
},
|
||||
"globs": ["**/*.{md,mdx}"],
|
||||
"ignores": ["**/node_modules"]
|
||||
"ignores": ["**/node_modules"],
|
||||
"customRules": ["markdownlint-rule-relative-links"]
|
||||
}
|
||||
|
7
.markdownlint.json
Normal file
7
.markdownlint.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"default": true,
|
||||
"relative-links": true,
|
||||
"extends": "markdownlint/style/prettier",
|
||||
"MD033": false,
|
||||
"MD041": false
|
||||
}
|
@ -132,7 +132,7 @@ io.on('connection', async (socket) => {
|
||||
|
||||
```ts
|
||||
import { io } from 'socket.io-client'
|
||||
import { isUnauthorizedError } from '@thream/socketio-jwt/UnauthorizedError.js'
|
||||
import { isUnauthorizedError } from '@thream/socketio-jwt/build/UnauthorizedError.js'
|
||||
|
||||
// Require Bearer Token
|
||||
const socket = io('http://localhost:9000', {
|
||||
|
17264
package-lock.json
generated
17264
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
67
package.json
67
package.json
@ -31,12 +31,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/Thream/socketio-jwt#readme",
|
||||
"scripts": {
|
||||
"build": "rimraf ./build && swc ./src --out-dir ./build && tsc",
|
||||
"build": "rimraf ./build && swc ./src --out-dir ./build",
|
||||
"build:dev": "swc ./src --out-dir ./build --watch",
|
||||
"build:typescript": "tsc",
|
||||
"lint:commit": "commitlint",
|
||||
"lint:editorconfig": "editorconfig-checker",
|
||||
"lint:markdown": "markdownlint-cli2",
|
||||
"lint:typescript": "eslint \"**/*.{js,jsx,ts,tsx}\" --ignore-path \".gitignore\"",
|
||||
"lint:eslint": "eslint \"**/*.{js,jsx,ts,tsx}\" --ignore-path \".gitignore\"",
|
||||
"lint:prettier": "prettier \".\" --check --ignore-path \".gitignore\"",
|
||||
"lint:staged": "lint-staged",
|
||||
"test": "c8 tap",
|
||||
@ -49,39 +50,41 @@
|
||||
"socket.io": ">=3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsonwebtoken": "8.5.1"
|
||||
"jsonwebtoken": "9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "17.1.2",
|
||||
"@commitlint/config-conventional": "17.1.0",
|
||||
"@swc/cli": "0.1.57",
|
||||
"@swc/core": "1.2.249",
|
||||
"@types/jsonwebtoken": "8.5.9",
|
||||
"@types/node": "18.7.16",
|
||||
"@types/tap": "15.0.7",
|
||||
"@typescript-eslint/eslint-plugin": "5.36.2",
|
||||
"@typescript-eslint/parser": "5.36.2",
|
||||
"axios": "0.27.2",
|
||||
"c8": "7.12.0",
|
||||
"editorconfig-checker": "4.0.2",
|
||||
"eslint": "8.23.0",
|
||||
"eslint-config-conventions": "4.0.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-import": "2.26.0",
|
||||
"@commitlint/cli": "17.5.1",
|
||||
"@commitlint/config-conventional": "17.4.4",
|
||||
"@swc/cli": "0.1.62",
|
||||
"@swc/core": "1.3.44",
|
||||
"@tsconfig/strictest": "2.0.0",
|
||||
"@types/jsonwebtoken": "9.0.1",
|
||||
"@types/node": "18.15.11",
|
||||
"@types/tap": "15.0.8",
|
||||
"@typescript-eslint/eslint-plugin": "5.57.0",
|
||||
"@typescript-eslint/parser": "5.57.0",
|
||||
"axios": "1.3.4",
|
||||
"c8": "7.13.0",
|
||||
"editorconfig-checker": "5.0.1",
|
||||
"eslint": "8.37.0",
|
||||
"eslint-config-conventions": "8.0.0",
|
||||
"eslint-config-prettier": "8.8.0",
|
||||
"eslint-plugin-import": "2.27.5",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
"eslint-plugin-promise": "6.0.1",
|
||||
"eslint-plugin-unicorn": "43.0.2",
|
||||
"fastify": "4.5.3",
|
||||
"husky": "8.0.1",
|
||||
"lint-staged": "13.0.3",
|
||||
"markdownlint-cli2": "0.5.1",
|
||||
"eslint-plugin-promise": "6.1.1",
|
||||
"eslint-plugin-unicorn": "46.0.0",
|
||||
"fastify": "4.15.0",
|
||||
"husky": "8.0.3",
|
||||
"lint-staged": "13.2.0",
|
||||
"markdownlint-cli2": "0.6.0",
|
||||
"markdownlint-rule-relative-links": "1.1.2",
|
||||
"pinst": "3.0.0",
|
||||
"prettier": "2.7.1",
|
||||
"rimraf": "3.0.2",
|
||||
"semantic-release": "19.0.5",
|
||||
"socket.io": "4.5.2",
|
||||
"socket.io-client": "4.5.2",
|
||||
"tap": "16.3.0",
|
||||
"typescript": "4.8.3"
|
||||
"prettier": "2.8.7",
|
||||
"rimraf": "4.4.1",
|
||||
"semantic-release": "21.0.1",
|
||||
"socket.io": "4.6.1",
|
||||
"socket.io-client": "4.6.1",
|
||||
"tap": "16.3.4",
|
||||
"typescript": "5.0.3"
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,11 @@ export class UnauthorizedError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
export const isUnauthorizedError = (error: any): error is UnauthorizedError => {
|
||||
return error.data.type === 'UnauthorizedError'
|
||||
export const isUnauthorizedError = (
|
||||
error: unknown
|
||||
): error is UnauthorizedError => {
|
||||
return (
|
||||
error instanceof UnauthorizedError &&
|
||||
error.data.type === 'UnauthorizedError'
|
||||
)
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ export const authorize = (options: AuthorizeOptions): SocketIOMiddleware => {
|
||||
}
|
||||
socket.encodedToken = encodedToken
|
||||
let keySecret: string | null = null
|
||||
let decodedToken: any
|
||||
let decodedToken: any = null
|
||||
if (typeof secret === 'string') {
|
||||
keySecret = secret
|
||||
} else {
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"extends": "@tsconfig/strictest/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
@ -7,9 +8,6 @@
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src",
|
||||
"emitDeclarationOnly": true,
|
||||
"declaration": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true
|
||||
"declaration": true
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user