Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
ff6a84a8e1 | |||
c7c152a554 | |||
7977c42c20 | |||
05b9eea638 | |||
e14b456d9a | |||
f85595224f | |||
1247a9b5f0 |
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -26,6 +26,3 @@ jobs:
|
|||||||
|
|
||||||
- name: 'Test'
|
- name: 'Test'
|
||||||
run: 'npm run test'
|
run: 'npm run test'
|
||||||
|
|
||||||
- name: 'Upload Coverage'
|
|
||||||
uses: 'codecov/codecov-action@v3.0.0'
|
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
"*": ["editorconfig-checker"],
|
"*": ["editorconfig-checker"],
|
||||||
"*.{js,jsx,ts,tsx}": ["prettier --write", "eslint --fix"],
|
"*.{js,jsx,ts,tsx}": ["prettier --write", "eslint --fix"],
|
||||||
"*.{json,jsonc,yml,yaml}": ["prettier --write"],
|
"*.{json,jsonc,yml,yaml}": ["prettier --write"],
|
||||||
"*.{md}": ["prettier --write", "markdownlint --dot --fix"]
|
"*.{md,mdx}": ["prettier --write", "markdownlint-cli2 --fix"]
|
||||||
}
|
}
|
||||||
|
10
.markdownlint-cli2.jsonc
Normal file
10
.markdownlint-cli2.jsonc
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"default": true,
|
||||||
|
"MD013": false,
|
||||||
|
"MD033": false,
|
||||||
|
"MD041": false
|
||||||
|
},
|
||||||
|
"globs": ["**/*.{md,mdx}"],
|
||||||
|
"ignores": ["**/node_modules"]
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"default": true,
|
|
||||||
"MD013": false,
|
|
||||||
"MD024": false,
|
|
||||||
"MD033": false,
|
|
||||||
"MD041": false
|
|
||||||
}
|
|
14
.swcrc
14
.swcrc
@ -2,21 +2,11 @@
|
|||||||
"jsc": {
|
"jsc": {
|
||||||
"parser": {
|
"parser": {
|
||||||
"syntax": "typescript",
|
"syntax": "typescript",
|
||||||
"decorators": true,
|
|
||||||
"dynamicImport": true
|
"dynamicImport": true
|
||||||
},
|
},
|
||||||
"transform": {
|
"target": "es2022"
|
||||||
"legacyDecorator": true,
|
|
||||||
"decoratorMetadata": true
|
|
||||||
},
|
|
||||||
"target": "es2022",
|
|
||||||
"loose": true
|
|
||||||
},
|
},
|
||||||
"module": {
|
"module": {
|
||||||
"type": "es6",
|
"type": "es6"
|
||||||
"strict": false,
|
|
||||||
"strictMode": true,
|
|
||||||
"lazy": false,
|
|
||||||
"noInterop": false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -6,5 +6,6 @@
|
|||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll": true
|
"source.fixAll": true
|
||||||
}
|
},
|
||||||
|
"eslint.options": { "ignorePath": ".gitignore" }
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
<a href="https://github.com/Thream/socketio-jwt/actions/workflows/build.yml"><img src="https://github.com/Thream/socketio-jwt/actions/workflows/build.yml/badge.svg?branch=develop" /></a>
|
<a href="https://github.com/Thream/socketio-jwt/actions/workflows/build.yml"><img src="https://github.com/Thream/socketio-jwt/actions/workflows/build.yml/badge.svg?branch=develop" /></a>
|
||||||
<a href="https://github.com/Thream/socketio-jwt/actions/workflows/lint.yml"><img src="https://github.com/Thream/socketio-jwt/actions/workflows/lint.yml/badge.svg?branch=develop" /></a>
|
<a href="https://github.com/Thream/socketio-jwt/actions/workflows/lint.yml"><img src="https://github.com/Thream/socketio-jwt/actions/workflows/lint.yml/badge.svg?branch=develop" /></a>
|
||||||
<a href="https://github.com/Thream/socketio-jwt/actions/workflows/test.yml"><img src="https://github.com/Thream/socketio-jwt/actions/workflows/test.yml/badge.svg?branch=develop" /></a>
|
<a href="https://github.com/Thream/socketio-jwt/actions/workflows/test.yml"><img src="https://github.com/Thream/socketio-jwt/actions/workflows/test.yml/badge.svg?branch=develop" /></a>
|
||||||
<a href="https://codecov.io/gh/Thream/socketio-jwt"><img src="https://codecov.io/gh/Thream/socketio-jwt/branch/develop/graph/badge.svg" alt="codecov" /></a>
|
|
||||||
<br />
|
<br />
|
||||||
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits" /></a>
|
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits" /></a>
|
||||||
<a href="https://github.com/semantic-release/semantic-release"><img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-release" /></a>
|
<a href="https://github.com/semantic-release/semantic-release"><img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-release" /></a>
|
||||||
@ -133,7 +132,7 @@ io.on('connection', async (socket) => {
|
|||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { io } from 'socket.io-client'
|
import { io } from 'socket.io-client'
|
||||||
import { isUnauthorizedError } from '@thream/socketio-jwt'
|
import { isUnauthorizedError } from '@thream/socketio-jwt/UnauthorizedError.js'
|
||||||
|
|
||||||
// Require Bearer Token
|
// Require Bearer Token
|
||||||
const socket = io('http://localhost:9000', {
|
const socket = io('http://localhost:9000', {
|
||||||
|
7214
package-lock.json
generated
7214
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
52
package.json
52
package.json
@ -35,7 +35,7 @@
|
|||||||
"build:dev": "swc ./src --out-dir ./build --watch",
|
"build:dev": "swc ./src --out-dir ./build --watch",
|
||||||
"lint:commit": "commitlint",
|
"lint:commit": "commitlint",
|
||||||
"lint:editorconfig": "editorconfig-checker",
|
"lint:editorconfig": "editorconfig-checker",
|
||||||
"lint:markdown": "markdownlint \"**/*.md\" --dot --ignore-path \".gitignore\"",
|
"lint:markdown": "markdownlint-cli2",
|
||||||
"lint:typescript": "eslint \"**/*.{js,jsx,ts,tsx}\" --ignore-path \".gitignore\"",
|
"lint:typescript": "eslint \"**/*.{js,jsx,ts,tsx}\" --ignore-path \".gitignore\"",
|
||||||
"lint:prettier": "prettier \".\" --check --ignore-path \".gitignore\"",
|
"lint:prettier": "prettier \".\" --check --ignore-path \".gitignore\"",
|
||||||
"lint:staged": "lint-staged",
|
"lint:staged": "lint-staged",
|
||||||
@ -52,36 +52,36 @@
|
|||||||
"jsonwebtoken": "8.5.1"
|
"jsonwebtoken": "8.5.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "16.2.3",
|
"@commitlint/cli": "17.1.2",
|
||||||
"@commitlint/config-conventional": "16.2.1",
|
"@commitlint/config-conventional": "17.1.0",
|
||||||
"@swc/cli": "0.1.57",
|
"@swc/cli": "0.1.57",
|
||||||
"@swc/core": "1.2.164",
|
"@swc/core": "1.2.249",
|
||||||
"@types/jsonwebtoken": "8.5.8",
|
"@types/jsonwebtoken": "8.5.9",
|
||||||
"@types/node": "17.0.23",
|
"@types/node": "18.7.16",
|
||||||
"@types/tap": "15.0.6",
|
"@types/tap": "15.0.7",
|
||||||
"@typescript-eslint/eslint-plugin": "5.18.0",
|
"@typescript-eslint/eslint-plugin": "5.36.2",
|
||||||
"@typescript-eslint/parser": "5.18.0",
|
"@typescript-eslint/parser": "5.36.2",
|
||||||
"axios": "0.26.1",
|
"axios": "0.27.2",
|
||||||
"c8": "7.11.0",
|
"c8": "7.12.0",
|
||||||
"editorconfig-checker": "4.0.2",
|
"editorconfig-checker": "4.0.2",
|
||||||
"eslint": "8.12.0",
|
"eslint": "8.23.0",
|
||||||
"eslint-config-conventions": "2.0.0",
|
"eslint-config-conventions": "4.0.0",
|
||||||
"eslint-config-prettier": "8.5.0",
|
"eslint-config-prettier": "8.5.0",
|
||||||
"eslint-plugin-import": "2.26.0",
|
"eslint-plugin-import": "2.26.0",
|
||||||
"eslint-plugin-prettier": "4.0.0",
|
"eslint-plugin-prettier": "4.2.1",
|
||||||
"eslint-plugin-promise": "6.0.0",
|
"eslint-plugin-promise": "6.0.1",
|
||||||
"eslint-plugin-unicorn": "42.0.0",
|
"eslint-plugin-unicorn": "43.0.2",
|
||||||
"fastify": "3.28.0",
|
"fastify": "4.5.3",
|
||||||
"husky": "7.0.4",
|
"husky": "8.0.1",
|
||||||
"lint-staged": "12.3.7",
|
"lint-staged": "13.0.3",
|
||||||
"markdownlint-cli": "0.31.1",
|
"markdownlint-cli2": "0.5.1",
|
||||||
"pinst": "3.0.0",
|
"pinst": "3.0.0",
|
||||||
"prettier": "2.6.2",
|
"prettier": "2.7.1",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"semantic-release": "19.0.2",
|
"semantic-release": "19.0.5",
|
||||||
"socket.io": "4.4.1",
|
"socket.io": "4.5.2",
|
||||||
"socket.io-client": "4.4.1",
|
"socket.io-client": "4.5.2",
|
||||||
"tap": "16.0.1",
|
"tap": "16.3.0",
|
||||||
"typescript": "4.6.3"
|
"typescript": "4.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
import tap from 'tap'
|
import tap from 'tap'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { io, Socket } from 'socket.io-client'
|
import type { Socket } from 'socket.io-client'
|
||||||
|
import { io } from 'socket.io-client'
|
||||||
|
|
||||||
import { isUnauthorizedError } from '../UnauthorizedError.js'
|
import { isUnauthorizedError } from '../UnauthorizedError.js'
|
||||||
|
import type { Profile } from './fixture/index.js'
|
||||||
import {
|
import {
|
||||||
API_URL,
|
API_URL,
|
||||||
fixtureStart,
|
fixtureStart,
|
||||||
fixtureStop,
|
fixtureStop,
|
||||||
getSocket,
|
getSocket,
|
||||||
basicProfile,
|
basicProfile
|
||||||
Profile
|
|
||||||
} from './fixture/index.js'
|
} from './fixture/index.js'
|
||||||
|
|
||||||
export const api = axios.create({
|
export const api = axios.create({
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import jwt from 'jsonwebtoken'
|
import jwt from 'jsonwebtoken'
|
||||||
import { Server as SocketIoServer } from 'socket.io'
|
import { Server as SocketIoServer } from 'socket.io'
|
||||||
import fastify, { FastifyInstance } from 'fastify'
|
import type { FastifyInstance } from 'fastify'
|
||||||
|
import fastify from 'fastify'
|
||||||
|
|
||||||
import { authorize, AuthorizeOptions } from '../../index.js'
|
import type { AuthorizeOptions } from '../../index.js'
|
||||||
|
import { authorize } from '../../index.js'
|
||||||
|
|
||||||
interface FastifyIo {
|
interface FastifyIo {
|
||||||
instance: SocketIoServer
|
instance: SocketIoServer
|
||||||
@ -67,7 +69,9 @@ export const fixtureStart = async (
|
|||||||
application.addHook('onClose', (fastify) => {
|
application.addHook('onClose', (fastify) => {
|
||||||
fastify.io.instance.close()
|
fastify.io.instance.close()
|
||||||
})
|
})
|
||||||
await application.listen(PORT)
|
await application.listen({
|
||||||
|
port: PORT
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fixtureStop = async (): Promise<void> => {
|
export const fixtureStop = async (): Promise<void> => {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import jwt, { Algorithm } from 'jsonwebtoken'
|
import type { Algorithm } from 'jsonwebtoken'
|
||||||
import { Socket } from 'socket.io'
|
import jwt from 'jsonwebtoken'
|
||||||
|
import type { Socket } from 'socket.io'
|
||||||
|
|
||||||
import { UnauthorizedError } from './UnauthorizedError.js'
|
import { UnauthorizedError } from './UnauthorizedError.js'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user