Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
b870c9c
remove unsafe args from contract-builder
Canvinus Dec 8, 2023
d727b4c
set specific versions
Canvinus Dec 8, 2023
5f9aeae
use node 18
Canvinus Dec 8, 2023
2208f65
decrease env exposure to nginx container
Canvinus Dec 8, 2023
8af2044
Merge branch 'main' into test
Canvinus Jan 3, 2024
021fd3c
use cargo-near0.5.0 container
Canvinus Feb 8, 2024
857ad55
increase nginx timeouts
Canvinus Feb 8, 2024
64a5de4
change source path for wasm
Canvinus Feb 8, 2024
84dc775
custom timeout on compile route
Canvinus Feb 8, 2024
db7df89
update read wasm file method
Canvinus Feb 8, 2024
c28041d
update compile controller
Canvinus Feb 8, 2024
21355a0
fixes
Canvinus Feb 8, 2024
77be4b8
read wasm from entry path
Canvinus Feb 8, 2024
2437d29
remove delete release folder
Canvinus Feb 8, 2024
ea1b420
use sourcescan/cargo-near:0.6.0
Canvinus Feb 8, 2024
7892bb6
update cors
Canvinus Feb 8, 2024
23d34da
add compilation attributes
Canvinus Feb 8, 2024
b75280b
fix attributes
Canvinus Feb 8, 2024
8afdd6b
add dynamic builder image fetching
Canvinus Feb 8, 2024
d256b31
update .env.example
Canvinus Feb 8, 2024
e392719
update rust compilation script
Canvinus Feb 8, 2024
90aeaf4
use bash to run scripts
Canvinus Feb 8, 2024
9b7e261
update nginx conf
Canvinus Feb 8, 2024
9cc7bb3
update nginx.conf
Canvinus Feb 8, 2024
e977b62
merge
Canvinus Mar 18, 2024
99111bc
update docker-compose.yml
Canvinus May 23, 2024
0122890
check codehash before compile
Canvinus May 23, 2024
aaaebb7
add rpc view call for contract_source_metadata
Canvinus May 23, 2024
bd84c92
remove unnecessary codebase
Canvinus May 23, 2024
5436d40
update verificaiton flow
Canvinus May 24, 2024
54a20d2
remove contract-builder container
Canvinus May 24, 2024
a12b82b
remove AuthService
Canvinus May 24, 2024
c5d7920
refactor compilation flow: use docker-ce
Canvinus May 24, 2024
c2ad5a8
use host for nginx
Canvinus May 24, 2024
f84df9a
update .env.example
Canvinus May 24, 2024
16d9a85
remove unable from error indicators
Canvinus May 24, 2024
2f59115
return stdout for testing
Canvinus May 24, 2024
49f934a
use amd64 for production dind container
Canvinus May 24, 2024
066e518
use dind alpine image for optimization
Canvinus May 24, 2024
a6fa7df
update rust installation
Canvinus May 24, 2024
b5afea3
return logs as string[]
Canvinus May 25, 2024
2db45bc
extract binary path from compilation output
Canvinus May 25, 2024
4b281b4
update verifier flow
Canvinus May 26, 2024
5599cc0
update verify controller
Canvinus May 26, 2024
a70b1fd
fix: await for deleteFolder
Canvinus May 26, 2024
b996b14
add optional blockId
Canvinus Jun 8, 2024
c41c14b
fix description for blockId
Canvinus Jun 8, 2024
78a3cb9
fix httpExceptionFilter interception with validation pipe errors
Canvinus Jun 10, 2024
78d9fa3
add block_height check
Canvinus Jun 10, 2024
6f2f3a5
chore: add branch env var
Canvinus Jul 10, 2024
c5965f6
chore: use host var
Canvinus Jul 10, 2024
50cd6d9
feat: pin cid to quicknode ipfs provider
Canvinus Aug 11, 2024
ef54a76
fix: install rust under root
Canvinus Aug 11, 2024
8f98211
fix: use usr/local/
Canvinus Aug 11, 2024
82ac884
fix: use usr/local/
Canvinus Aug 11, 2024
e04ddec
fix: skip pinning if cid pinned
Canvinus Aug 11, 2024
cea097e
refactor: when pining use external ip from .env
Canvinus Aug 11, 2024
cb3de4f
chore: allow all cors
Canvinus Sep 5, 2024
4a4bcf8
Merge branch 'api-v2' of https://github.com/SourceScan/verifier-back …
Canvinus Sep 5, 2024
ff5d072
feat: checkout latest release tree
Canvinus Sep 11, 2024
7773310
fix: fix checkout in dockerfile
Canvinus Sep 11, 2024
d9251cf
chore: extend nginx cors
Canvinus Sep 21, 2024
fd794cb
chore: extend chors in main.ts
Canvinus Sep 21, 2024
5840800
refactor: move cors into location block
Canvinus Sep 21, 2024
4fde20a
refactor: rm cors from main.ts
Canvinus Sep 21, 2024
9cc3da7
refactor: rm cors from nginx
Canvinus Sep 21, 2024
76c7e0d
refactor: change cors in main.ts
Canvinus Sep 21, 2024
676170f
refactor: change cors in main.ts
Canvinus Sep 21, 2024
9d8b82d
chore: switch to release 0.9.0
Canvinus Oct 4, 2024
0306813
chore: use env var to specify sha of cargo-near used for builds
Canvinus Oct 21, 2024
931b378
feat: add support for cargo-near variants and Docker reproducible builds
Canvinus Aug 29, 2025
dd1e2d1
feat: migrate to near.cli.rs
Canvinus Aug 30, 2025
7ee365f
fix: pass numeric block height to verifier contract
Canvinus Aug 30, 2025
bfb1d64
feat: add pre-verification checks for repository and Docker image acc…
Canvinus Aug 30, 2025
7a40cd2
fix: make QuickNode pinning non-fatal and fix temp cleanup timing
Canvinus Nov 30, 2025
51bd2e2
feat!: v3.0 API consolidation and infrastructure upgrade
Canvinus Dec 1, 2025
7fd3a58
feat: generate htpasswd from env vars at container startup
Canvinus Dec 1, 2025
d8fc41a
chore(deps): update dependencies to latest compatible versions
Canvinus Dec 1, 2025
98616ae
feat(cleanup): add automated Docker resource cleanup service
Canvinus Dec 1, 2025
a2fd797
refactor: replace ipfs-http-client with direct API calls and fix dock…
Canvinus Dec 1, 2025
56a30c0
chore(deps): upgrade to NestJS 11 and update dependencies
Canvinus Dec 1, 2025
0f24593
chore(deps): upgrade to Node 24 LTS, near-api-js 6, and Jest 30
Canvinus Dec 1, 2025
fb71000
chore(deps): migrate to eslint 9, @scure/base, and update tsconfig
Canvinus Dec 1, 2025
9c4d986
refactor: remove baseUrl by converting to relative imports
Canvinus Dec 1, 2025
8d3ae21
refactor: remove dead code and unused files
Canvinus Dec 1, 2025
c0ef69c
fix: add missing class-transformer dependency for ValidationPipe
Canvinus Dec 1, 2025
830fd53
fix: resolve near-api-js deprecations and update dependencies
Canvinus Dec 1, 2025
1ebc4c0
docs: add firewall configuration and port reference
Canvinus Dec 1, 2025
cc8c740
fix: eliminate remaining near-api-js deprecation warnings
Canvinus Dec 1, 2025
48260f9
chore: merge main into api-v3-refactor, resolve conflicts with v3
Canvinus Dec 2, 2025
de58608
feat: add contracts count and by-code-hash API endpoints
Canvinus Dec 2, 2025
2abbb66
refactor: remove QuickNode pinning, use local IPFS node only
Canvinus Dec 2, 2025
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
28 changes: 17 additions & 11 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
## Environment Variables

ARCH=amd64
NEST_PORT=3033
HOST=0.0.0.0
BRANCH_NAME=main
HOST=127.0.0.1

# !!! Path should be with " / " at the start !!!
# NestJS
NEST_PORT=3033
NEST_PREFIX=/api
SECRET=
JWT_EXPIRATION=30
API_HOST=https://api.sourcescan.dev

# NGINX
NGINX_PORT=33

# IPFS
IPFS_HOST=sscan-ipfs
IPFS_PORT=5001

# Used for external comunication with ipfs
SWARM_PORT=4001
GATE_PORT=8080
SWARM_PORT=4001
QUICKNODE_API_KEY=

# External IP for IPFS swarm announce (auto-detected if empty)
IPFS_EXTERNAL_IP=

# IPFS WebUI auth
IPFS_ADMIN_USER=admin
IPFS_ADMIN_PASS=

# Near module env
# NEAR
NEAR_MAINNET_RPC=https://rpc.mainnet.near.org
NEAR_MAINNET_ACCOUNT_ID=
NEAR_MAINNET_PRIVATE_KEY=
NEAR_TESTNET_RPC=https://rpc.testnet.near.org
NEAR_TESTNET_ACCOUNT_ID=
NEAR_TESTNET_PRIVATE_KEY=
NEAR_TESTNET_PRIVATE_KEY=
31 changes: 20 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ name: Main CI

on:
push:
branches: [ "main" ]
branches: [ "main", "api-v2" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "api-v2" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 16.x
uses: actions/setup-node@v3
- name: Use Node.js 24.x LTS
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '24.x'
cache: 'npm'
cache-dependency-path: nest/package-lock.json

- name: Install and Build
run: |
Expand All @@ -29,19 +31,26 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 16.x
uses: actions/setup-node@v3
- name: Use Node.js 24.x LTS
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '24.x'
cache: 'npm'
cache-dependency-path: nest/package-lock.json

- name: Install Dependencies
run: |
cd nest
npm ci

- name: Test Nest JS
- name: Lint
run: |
cd nest
npm run lint

- name: Test
run: |
cd nest
npm run test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ pnpm-lock.yaml

docker-data

dist/
dist/

30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
# SourceScan NestJS Back-end and API

## Installation

1. Create .env file
`cp .env.example .env`
```
cp .env.example .env
```
2. Build and run containers
`docker compose up -d --build`
3. Add these lines to **./docker-data/ipfs/config** to open this node to global ipfs
```
docker compose up -d --build
```

## Firewall Configuration

**Open these ports (public access required):**
| Port | Protocol | Service | Description |
|------|----------|---------|-------------|
| 33 | TCP | Nginx | API proxy (NGINX_PORT) |
| 4001 | TCP+UDP | IPFS Swarm | P2P communication (SWARM_PORT) |

**Keep closed (internal only, bound to 127.0.0.1):**
| Port | Service | Description |
|------|---------|-------------|
| 3033 | NestJS | Backend API (NEST_PORT) |
| 5001 | IPFS API | Admin interface (IPFS_PORT) |
| 8080 | IPFS Gateway | Content gateway (GATE_PORT) |

`"AppendAnnounce": [ "/ip4/{hostname}/tcp/{swarm_port}", "/ip4/{hostname}/udp/{swarm_port}/quic", "/ip4/{hostname}/udp/{swarm_port}/quic-v1", "/ip4/{hostname}/udp/{swarm_port}/quic-v1/webtransport" ]`
## IPFS WebUI

After that you need to restart IPFS container
- Local: http://localhost:5001/webui
- Via nginx: http://localhost:33/ipfs-admin/webui (requires IPFS_ADMIN_USER/PASS)
70 changes: 0 additions & 70 deletions compose.yaml

This file was deleted.

70 changes: 70 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
services:
sscan-nest:
build:
context: nest
platform: linux/amd64
container_name: ${BRANCH_NAME:-main}_sscan-nest
restart: always
networks:
- nwk
ports:
- '127.0.0.1:${NEST_PORT}:${NEST_PORT}'
volumes:
- ./nest/scripts:/app/scripts
env_file:
- .env
privileged: true
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The privileged: true flag gives the container full access to the host system, which is a significant security risk. While this may be needed for Docker-in-Docker functionality, consider:

  1. Using more specific capabilities instead (e.g., CAP_SYS_ADMIN)
  2. Documenting why this is necessary
  3. Ensuring this is only used in trusted environments
  4. Consider alternative approaches that don't require privileged mode if possible
Suggested change
privileged: true
# Removed 'privileged: true' for security. Add specific capabilities below if needed.
# cap_add:
# - CAP_SYS_ADMIN

Copilot uses AI. Check for mistakes.

sscan-ipfs:
image: ipfs/kubo:v0.39.0
container_name: ${BRANCH_NAME:-main}_sscan-ipfs
restart: always
environment:
- IPFS_PROFILE=server
- IPFS_PATH=/ipfsdata
- IPFS_EXTERNAL_IP=${IPFS_EXTERNAL_IP}
- SWARM_PORT=${SWARM_PORT}
networks:
- nwk
ports:
- "${SWARM_PORT}:4001"
- "${SWARM_PORT}:4001/udp"
- "127.0.0.1:${IPFS_PORT}:5001"
- "127.0.0.1:${GATE_PORT}:8080"
volumes:
- ./docker-data/ipfs:/ipfsdata
- ./ipfs/001-configure.sh:/container-init.d/001-configure.sh:ro
healthcheck:
test: ["CMD-SHELL", "ipfs swarm peers | head -1"]
interval: 10s
timeout: 5s
retries: 5

sscan-nginx:
image: nginx:1.27
container_name: ${BRANCH_NAME:-main}_sscan-nginx
restart: always
ports:
- '${HOST}:${NGINX_PORT}:${NGINX_PORT}'
networks:
- nwk
volumes:
- ./nginx/:/etc/nginx/templates/
- ./nginx/scripts/entrypoint.sh:/entrypoint.sh:ro
entrypoint: /entrypoint.sh
command: ["nginx", "-g", "daemon off;"]
environment:
- NGINX_PORT=${NGINX_PORT}
- NEST_PORT=${NEST_PORT}
- GATE_PORT=${GATE_PORT}
- IPFS_PORT=${IPFS_PORT}
- IPFS_ADMIN_USER=${IPFS_ADMIN_USER}
- IPFS_ADMIN_PASS=${IPFS_ADMIN_PASS}
depends_on:
- sscan-nest
- sscan-ipfs

networks:
nwk:
name: ${BRANCH_NAME:-main}_nwk
driver: bridge
27 changes: 27 additions & 0 deletions ipfs/001-configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
set -ex

# Configure IPFS API for WebUI access through nginx proxy
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST", "GET"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers '["Authorization", "Content-Type"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting Access-Control-Allow-Origin to ["*"] and Access-Control-Allow-Credentials to ["true"] simultaneously is a security misconfiguration. Browsers will reject this combination as it's not allowed by CORS specifications. If credentials are needed, specify exact origins instead of *. If * is required, set Allow-Credentials to false.

Suggested change
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["false"]'

Copilot uses AI. Check for mistakes.

# Listen on all interfaces (secured by nginx)
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080

# Get external IP (from env or auto-detect)
EXTERNAL_IP="${IPFS_EXTERNAL_IP:-$(curl -4 -s --max-time 5 ifconfig.me || echo "")}"

if [ -n "$EXTERNAL_IP" ] && [ -n "$SWARM_PORT" ]; then
echo "Configuring announce addresses for: $EXTERNAL_IP:$SWARM_PORT"
ipfs config --json Addresses.Announce "[
\"/ip4/${EXTERNAL_IP}/tcp/${SWARM_PORT}\",
\"/ip4/${EXTERNAL_IP}/udp/${SWARM_PORT}/quic-v1\"
]"
else
echo "Skipping announce config (no external IP detected)"
fi

echo "IPFS configured successfully"
25 changes: 0 additions & 25 deletions nest/.eslintrc.js

This file was deleted.

Loading