├── .eslintrc.cjs ├── .github └── workflows │ ├── release.yml │ └── test.yml ├── .gitignore ├── README.md ├── dist ├── saturn-sw-core.js ├── saturn-sw.js └── widget.js ├── package-lock.json ├── package.json ├── public ├── index.html ├── mock-node.js └── test.mjs ├── src ├── constants.js ├── sw │ ├── controller.js │ ├── interceptor.js │ ├── saturn-sw-core.js │ └── saturn-sw.js ├── utils.js └── widget │ ├── widget-config.js │ └── widget.js ├── test ├── utils.spec.js └── widget-config.spec.js └── webpack.config.js /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true, 4 | node: true, 5 | es6: true 6 | }, 7 | extends: 'eslint:recommended', 8 | rules: { 9 | 'comma-dangle': 0, 10 | indent: ['error', 4], 11 | 'linebreak-style': [ 12 | 'error', 13 | 'unix' 14 | ], 15 | 'max-len': ['error', { code: 100, ignoreUrls: true }], 16 | 'no-unused-vars': ['error', { 17 | varsIgnorePattern: '^_|cl', 18 | ignoreRestSiblings: true 19 | }], 20 | 'prefer-const': 1, 21 | 'quotes': ['error', 'single'], 22 | 'semi': ['error', 'never'] 23 | }, 24 | parser: '@babel/eslint-parser', 25 | parserOptions: { 26 | requireConfigFile: false 27 | }, 28 | globals: { 29 | cl: true, 30 | cljson: true, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - "main" 6 | tags: ["*"] 7 | jobs: 8 | cicd: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | 13 | - uses: actions/setup-node@v2 14 | with: 15 | node-version: "16" 16 | 17 | - name: Install dependencies 18 | run: npm ci 19 | 20 | - name: Run Tests 21 | run: npm run test 22 | 23 | # Just checking if build succeeds. 24 | - name: Build 25 | env: 26 | STATIC_FILE_ORIGIN: https://saturn-test.network 27 | L1_ORIGIN: https://l1s.saturn-test.ms 28 | TRUSTED_L1_ORIGIN: https://saturn-test.ms 29 | LOG_INGESTOR_URL: https://p6wofrb2zgwrf26mcxjpprivie0lshfx.lambda-url.us-west-2.on.aws 30 | JWT_AUTH_URL: https://fz3dyeyxmebszwhuiky7vggmsu0rlkoy.lambda-url.us-west-2.on.aws/ 31 | ORCHESTRATOR_URL: https://orchestrator.strn-test.pl/nodes?maxNodes=100 32 | run: npm run build 33 | 34 | - name: Set Staging Environment Variables 35 | if: github.ref_type != 'tag' 36 | run: | 37 | echo "FLEEK_SITE_SLUG=saturn-staging" >> $GITHUB_ENV 38 | 39 | - name: Set Production Environment Variables 40 | if: github.ref_type == 'tag' 41 | run: | 42 | echo "FLEEK_SITE_SLUG=saturn-tech" >> $GITHUB_ENV 43 | 44 | # Trigger fleek homepage deploy, which will build and host the browser-client files. 45 | - name: Deploy 46 | run: | 47 | siteJson=$( 48 | curl -sS https://api.fleek.co/graphql -H "Authorization: ${{secrets.FLEEK_HOSTING_API_KEY}}" \ 49 | -H "Content-Type: application/json" \ 50 | -d '{ "query": "query { getSiteBySlug(slug: \"'"$FLEEK_SITE_SLUG"'\") { id publishedDeploy { id } }}" }' 51 | ) 52 | 53 | siteId=$(echo $siteJson | jq --raw-output '.data.getSiteBySlug.id') 54 | latestDeployId=$(echo $siteJson | jq --raw-output '.data.getSiteBySlug.publishedDeploy.id') 55 | 56 | echo "siteSlug=$FLEEK_SITE_SLUG" 57 | echo "siteId=$siteId" 58 | echo "latestDeployId=$latestDeployId" 59 | 60 | # Retry deploy will cause fleek to download the latest browser-client, while also 61 | # keeping the currently deployed homepage version. 62 | curl -sS -H "Authorization: ${{secrets.FLEEK_HOSTING_API_KEY}}" \ 63 | -H "Content-Type: application/json" \ 64 | -d '{ "query": "mutation { retryDeploy(siteId: \"'"$siteId"'\", deployId: \"'"$latestDeployId"'\") { id status } }" }' \ 65 | https://api.fleek.co/graphql | jq 66 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | branches: 5 | - main 6 | tags: 7 | - '*' 8 | pull_request: 9 | branches: 10 | - main 11 | jobs: 12 | test: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - uses: actions/setup-node@v2 18 | with: 19 | node-version: '18' 20 | 21 | - name: Install dependencies 22 | run: npm ci 23 | 24 | - name: Run Tests 25 | run: npm run test 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .local 3 | node_modules 4 | test-files 5 | 6 | dist/ 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Saturn Browser Client 2 | 3 | [](https://protocol.ai/) 4 | [](https://filecoin.io/) 5 | 6 | The Saturn Browser Client is a service worker that serves websites' [CID](https://docs.ipfs.io/concepts/content-addressing/) requests with [CAR files](https://ipld.io/specs/transport/car/carv1/). CAR files are verifiable, which is 7 | a requirement when retrieving content in a trustless manner from community hosted 8 | [Saturn Nodes](https://github.com/filecoin-project/L1-node). 9 | 10 | ## Install 11 | 12 | `$ npm install` 13 | 14 | ## Development 15 | 16 | `$ npm run dev` 17 | 18 | ## Adding the Browser Client to your website 19 | 20 | 1. Add this script tag to the `
` tag. This will install the service worker. 21 | 22 | ```html 23 | 6 | 29 | 30 | 31 | 32 |