Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(*): fish fish wrapper #1

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
0f8161b
feat(*): base code and tools
JPBM135 Oct 26, 2022
df35e9d
feat(base): implement fish fish api wrapper
JPBM135 Oct 26, 2022
906a1af
feat(tests): starting on tests
JPBM135 Oct 26, 2022
fc62441
fix(*): apply suggestions from code review (me)
JPBM135 Oct 27, 2022
c824ccb
chore(main): implement static functions
JPBM135 Oct 27, 2022
103fb39
feat(ci): automated testing
JPBM135 Oct 27, 2022
ad33835
chore(rename): `main` => `api` and `FishFish.test` => `API.test`
JPBM135 Oct 27, 2022
c061bbd
fix(eslint): remove leftovers
JPBM135 Oct 27, 2022
efaf363
feat(tests): random data generation
JPBM135 Oct 27, 2022
8c35a15
chore(rename): `main` => `api`
JPBM135 Oct 27, 2022
3aec705
feat(api): docs, permissions checking, static where applicable
JPBM135 Oct 27, 2022
ff62856
refactor(types): improve types
JPBM135 Oct 27, 2022
f184ebc
feat(errors): `SESSION_TOKEN_NO_PERMISSION` error
JPBM135 Oct 27, 2022
7507eb7
feat(tests): more tests
JPBM135 Oct 27, 2022
9ca90a1
fix(prettier): prettier ignore
JPBM135 Oct 28, 2022
484543c
fix(lint): linting
JPBM135 Oct 29, 2022
8ebed05
feat(websocket): WebSocket handler
JPBM135 Oct 29, 2022
e429223
chore(docs): improve jsdocs
JPBM135 Oct 29, 2022
de5ecd9
refactor(*): move to a `structures` folder
JPBM135 Oct 29, 2022
1d1966c
refactor(auth): move auth to it's own class
JPBM135 Oct 29, 2022
45d3560
feat(tests): more tests for all classes
JPBM135 Oct 29, 2022
de0da02
chore(utils): move common functions to it's own file
JPBM135 Oct 29, 2022
eaabd3c
feat(errors): more error messages
JPBM135 Oct 29, 2022
bcca592
chore(api): move to a structures folder
JPBM135 Oct 29, 2022
12a6530
fix(merge): merge conflicts
JPBM135 Oct 29, 2022
c2b7f9b
chore(api): rename to `permissions` for consistency
JPBM135 Oct 29, 2022
9d75575
feat(pkg): exports
JPBM135 Oct 29, 2022
7b5b2dd
feat(readme): preliminary readme
JPBM135 Oct 29, 2022
c4119f9
feat(docs): auth docs
JPBM135 Oct 29, 2022
5ccdb34
chore(deps): update undici
JPBM135 Jan 16, 2023
be35d54
chore(deps): bump
JPBM135 Jan 17, 2023
5a697b3
chore(const): move enums to its own file
JPBM135 Jan 17, 2023
ce80e17
feat(errors): errors
JPBM135 Jan 17, 2023
c5f4768
feat(structures): admin utils class
JPBM135 Jan 17, 2023
95240f7
refactor(ws): use the correct data format
JPBM135 Jan 17, 2023
c9560db
refactor(api): do not ensure perms neither choosing category
JPBM135 Jan 17, 2023
96b39ac
fix(utils): *
JPBM135 Jan 17, 2023
193d9cd
chore(structures): remove unused permissions on root
JPBM135 Jan 17, 2023
2c05c8e
feat(errors): callback error
JPBM135 Jan 17, 2023
32290fb
refactor(tests): adapt to new options
JPBM135 Jan 17, 2023
18f278b
chore(api): allow empty options
JPBM135 Jan 17, 2023
24b9767
feat(errors): specific errors
JPBM135 Jan 17, 2023
bfe67a9
feat(ws): validate options
JPBM135 Jan 17, 2023
4bfee3d
feat(pkg): post install
JPBM135 Jan 17, 2023
e5c3db2
feat(npm): .npmignore
JPBM135 Jan 18, 2023
9d01b72
refactor(pkg): prepare for publish
JPBM135 Jan 18, 2023
416bd8f
refactor(readme): update
JPBM135 Jan 18, 2023
deaa62c
chore(index): do not export consts
JPBM135 Jan 18, 2023
048e69a
chore(api): fixes and improvements
JPBM135 Jan 18, 2023
b91ff4a
fix(auth): prevent race conditions
JPBM135 Jan 18, 2023
5e176d5
chore(assertString): more verbose error
JPBM135 Jan 18, 2023
45a87e0
chore(auth): do not create a token at startup
JPBM135 Jan 18, 2023
2053ce3
feat(ws): allow a hacky way to change ws url for tests
JPBM135 Jan 18, 2023
c9041df
fix(cache): check if cache is disabled
JPBM135 Jan 18, 2023
9cfb60c
feat(ws): getter for webSocket
JPBM135 Jan 18, 2023
3f740d8
chore(tests/utils): rename
JPBM135 Jan 18, 2023
9488354
feat(test): more api tests
JPBM135 Jan 18, 2023
c0754fa
feat(pkg): lint-staged and husky
JPBM135 Jan 18, 2023
a4860f7
refactor(types): revert and improve ws types
JPBM135 Jan 19, 2023
c3348da
fix(ws): clear timeout before running another one
JPBM135 Jan 19, 2023
dcfb91d
feat(types/ws): js docs
JPBM135 Jan 19, 2023
7e1e9b5
chore(deps): husky and bump @types/node
JPBM135 Jan 19, 2023
b92472e
refactor(ws): move to an event emitter based system
JPBM135 Jan 19, 2023
c4bc760
chore(types): remove url if type is domain and vice-versa
JPBM135 Jan 19, 2023
f69a9c9
refactor(types): ws types and raw event
JPBM135 Jan 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"root": true,
"parserOptions": {
"project": "./tsconfig.eslint.json"
},
"ignorePatterns": [
"**/dist/*"
],
"env": {
"jest": true
},
"extends": [
"neon/common",
"neon/node",
"neon/typescript",
"neon/prettier"
],
"rules": {
"@typescript-eslint/consistent-type-definitions": [
"error",
"interface"
]
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
40 changes: 35 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down Expand Up @@ -41,8 +42,8 @@ build/Release
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo
Expand All @@ -53,6 +54,9 @@ typings/
# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
Expand All @@ -68,29 +72,41 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
# dotenv environment variable files
.env
.env.test
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

Expand All @@ -102,3 +118,17 @@ dist

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# macOS
.DS_Store
.vercel
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"printWidth": 120,
"useTabs": true,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "all",
"endOfLine": "lf"
}
27 changes: 27 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"exclude": [
".*/types/.*\\.ts$"
],
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true,
"treatConstEnumAsEnum": true,
"useDefineForClassFields": true
},
"target": "es2022",
"keepClassNames": true,
"preserveAllComments": false,
"externalHelpers": true
},
"module": {
"type": "nodenext"
},
"sourceMaps": true,
"isModule": true
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": false
},
"eslint.workingDirectories": [{ "pattern": "./packages/*" }]
JPBM135 marked this conversation as resolved.
Show resolved Hide resolved
}
541 changes: 541 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

550 changes: 550 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

783 changes: 783 additions & 0 deletions .yarn/releases/yarn-3.2.2.cjs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: '@yarnpkg/plugin-version'

yarnPath: .yarn/releases/yarn-3.2.2.cjs
43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "fishfish-js",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "vitest run",
"build:clean": "del-cli dist",
"build:check": "tsc --emitDeclarationOnly",
"build:esm": "swc ./src --out-dir ./dist",
"build": "yarn build:clean && yarn build:check && yarn build:esm",
"lint": "prettier --check . && eslint src --ext ts",
"format": "prettier --write . && eslint src --ext ts --fix",
"fmt": "yarn format",
"prepack": "yarn build && yarn lint"
},
"type": "module",
"keywords": [
"fishfish",
"anti-scam",
"api",
"wrapper"
],
"author": "JPBM135 <jpedrobm0@gmail.com>",
"license": "AGPL-3.0",
"devDependencies": {
"@swc/cli": "^0.1.57",
"@swc/core": "^1.3.3",
"@types/node": "^18.7.23",
"del-cli": "^5.0.0",
"eslint": "^8.22.0",
"eslint-config-neon": "^0.1.33",
"prettier": "^2.7.1",
"typescript": "^4.7.4",
"vitest": "^0.24.3"
},
"engines": {
"node": ">=17.9.0"
},
"packageManager": "yarn@3.2.2",
"dependencies": {
"undici": "^5.11.0"
}
}
18 changes: 18 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const API_BASE_URL = 'https://api.fishfish.gg/v1';

/**
* The categories of entries.
*/
export enum Category {
Malware = 'malware',
Phishing = 'phishing',
Safe = 'safe',
}

/**
* The permissions for the session token.
*/
export enum Permission {
Domains = 'domains',
Urls = 'urls',
}
11 changes: 11 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export enum ErrorsMessages {
API_KEY_UNAUTHORIZED = 'The API key provided is invalid or does not have the required permissions.',
CACHE_DISABLED = "Cannot get cache because it's explicitly disabled.",
INVALID_TYPE = 'Expected a string but received: ',
MISSING_CATEGORY = 'You need to provide a category to fetch all entries.',
MISSING_DEFAULT_PERMISSIONS = 'You need to provide at least one permission for the session token.',
MISSING_FIELD_CREATE = 'The category and description fields are required when creating a new entry.',
MISSING_FIELD_UPDATE = 'You need to provide at least one field to update.',
RATE_LIMITED = 'You are being rate limited.',
SESSION_TOKEN_UNAUTHORIZED = 'The session token provided is invalid or has expired.',
}
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './constants.js';
export * from './errors.js';
export * from './types.js';
export * from './main.js';
Loading