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

deps(dev): bump aegir from 37.12.1 to 42.2.3 #90

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ updates:
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
open-pull-requests-limit: 20
commit-message:
prefix: "deps"
prefix-development: "deps(dev)"
2 changes: 2 additions & 0 deletions .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:

permissions:
contents: write
id-token: write
packages: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Semantic PR

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
uses: pl-strflt/.github/.github/workflows/[email protected]
13 changes: 13 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Close and mark stale issue

on:
schedule:
- cron: '0 0 * * *'

permissions:
issues: write
pull-requests: write

jobs:
stale:
uses: pl-strflt/.github/.github/workflows/[email protected]
46 changes: 7 additions & 39 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
package-lock.json
yarn.lock

# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

build
dist
lib
docs
.docs
.coverage
node_modules
package-lock.json
yarn.lock
.vscode
1 change: 0 additions & 1 deletion .npmignore

This file was deleted.

160 changes: 19 additions & 141 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,18 @@

> A set of utilities to help identify IPFS resources on the web

## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Usage](#usage)
- [API](#api)
- [Content Identifiers](#content-identifiers)
- [`isIPFS.multihash(hash)`](#isipfsmultihashhash)
- [`isIPFS.cid(hash)`](#isipfscidhash)
- [`isIPFS.base32cid(hash)`](#isipfsbase32cidhash)
- [URLs](#urls)
- [`isIPFS.url(url)`](#isipfsurlurl)
- [`isIPFS.ipfsUrl(url)`](#isipfsipfsurlurl)
- [`isIPFS.ipnsUrl(url)`](#isipfsipnsurlurl)
- [Paths](#paths)
- [`isIPFS.path(path)`](#isipfspathpath)
- [`isIPFS.urlOrPath(path)`](#isipfsurlorpathpath)
- [`isIPFS.ipfsPath(path)`](#isipfsipfspathpath)
- [`isIPFS.ipnsPath(path)`](#isipfsipnspathpath)
- [`isIPFS.cidPath(path)`](#isipfscidpathpath)
- [Subdomains](#subdomains)
- [`isIPFS.subdomain(url)`](#isipfssubdomainurl)
- [`isIPFS.ipfsSubdomain(url)`](#isipfsipfssubdomainurl)
- [`isIPFS.ipnsSubdomain(url)`](#isipfsipnssubdomainurl)
- [Multiaddrs](#multiaddrs)
- [`isIPFS.multiaddr(addr)`](#isipfsmultiaddraddr)
- [`isIPFS.peerMultiaddr(addr)`](#isipfspeermultiaddraddr)
- [API Docs](#api-docs)
- [License](#license)
- [Contribution](#contribution)

## Install
# About

```console
$ npm i is-ipfs
```

### Browser `<script>` tag
A suite of util methods that provides efficient validation.

Loading this module through a script tag will make it's exports available as `IsIpfs` in the global namespace.
Detection of IPFS Paths and identifiers in URLs is a two-stage process:

```html
<script src="https://unpkg.com/is-ipfs/dist/index.min.js"></script>
```
1. `pathPattern`/`pathGatewayPattern`/`subdomainGatewayPattern` regex is applied to quickly identify potential candidates
2. proper CID validation is applied to remove false-positives

## Usage
## Example

```javascript
```TypeScript
import * as isIPFS from 'is-ipfs'

isIPFS.multihash('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true
Expand Down Expand Up @@ -134,117 +98,31 @@ isIPFS.peerMultiaddr('/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQ
isIPFS.peerMultiaddr('/ip4/127.0.0.1/udp/1234') // false (key missing)
```

## API

A suite of util methods that provides efficient validation.

Detection of IPFS Paths and identifiers in URLs is a two-stage process:

1. `pathPattern`/`pathGatewayPattern`/`subdomainGatewayPattern` regex is applied to quickly identify potential candidates
2. proper CID validation is applied to remove false-positives

### Content Identifiers

#### `isIPFS.multihash(hash)`

Returns `true` if the provided string or `Uint8Array` is a valid `multihash` or `false` otherwise.

#### `isIPFS.cid(hash)`

Returns `true` if the provided string, `Uint8Array` or [`CID`](https://github.com/multiformats/js-multiformats/#readme) object represents a valid [CID](https://docs.ipfs.io/guides/concepts/cid/) or `false` otherwise.

#### `isIPFS.base32cid(hash)`

Returns `true` if the provided string is a valid `CID` in Base32 encoding or `false` otherwise.

### URLs

#### `isIPFS.url(url)`

Returns `true` if the provided string is a valid IPFS or IPNS url or `false` otherwise.

#### `isIPFS.ipfsUrl(url)`

Returns `true` if the provided string is a valid IPFS url or `false` otherwise.

#### `isIPFS.ipnsUrl(url)`

Returns `true` if the provided string is a valid IPNS url or `false` otherwise.
# Install

### Paths

Standalone validation of IPFS Paths: `/ip(f|n)s/<cid>/..`

#### `isIPFS.path(path)`

Returns `true` if the provided string is a valid IPFS or IPNS path or `false` otherwise.

#### `isIPFS.urlOrPath(path)`

Returns `true` if the provided string is a valid IPFS or IPNS url or path or `false` otherwise.

#### `isIPFS.ipfsPath(path)`

Returns `true` if the provided string is a valid IPFS path or `false` otherwise.

#### `isIPFS.ipnsPath(path)`

Returns `true` if the provided string is a valid IPNS path or `false` otherwise.

#### `isIPFS.cidPath(path)`

Returns `true` if the provided string is a valid "CID path" (IPFS path without `/ipfs/` prefix) or `false` otherwise.

### Subdomains

Validated subdomain convention: `cidv1b32.ip(f|n)s.domain.tld`

#### `isIPFS.subdomain(url)`

Returns `true` if the provided `url` string includes a valid IPFS, looks like IPNS/DNSLink subdomain or `false` otherwise.

#### `isIPFS.ipfsSubdomain(url)`

Returns `true` if the provided `url` string includes a valid IPFS subdomain (case-insensitive CIDv1) or `false` otherwise.

#### `isIPFS.ipnsSubdomain(url)`

Returns `true` if the provided `url` string looks like a valid IPNS subdomain
(CIDv1 with `libp2p-key` multicodec or something that looks like a FQDN, for example `en.wikipedia-on-ipfs.org.ipns.localhost:8080`) or `false`
otherwise.

**Note:** `ipnsSubdomain` method works in offline mode: it does not perform
actual IPNS record lookup over DHT or other content routing method. It may
return false-positives:

- To ensure IPNS record exists, make a call to `/api/v0/name/resolve?arg=<ipnsid>`
- To ensure DNSLink exists, make a call to `/api/v0/dns?arg=<fqdn>`

### Multiaddrs

Below methods provide basic detection of [multiaddr](https://github.com/multiformats/multiaddr)s: composable and future-proof network addresses.

Complex validation of multiaddr can be built using `isIPFS.multiaddr` and [`mafmt`](https://github.com/multiformats/js-mafmt) library.

#### `isIPFS.multiaddr(addr)`
```console
$ npm i is-ipfs
```

Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr) or `Uint8Array` represents a valid multiaddr or `false` otherwise.
## Browser `<script>` tag

#### `isIPFS.peerMultiaddr(addr)`
Loading this module through a script tag will make it's exports available as `IsIpfs` in the global namespace.

Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr) or `Uint8Array` represents a valid libp2p peer multiaddr (matching [`P2P` format from `mafmt`](https://github.com/multiformats/js-mafmt#api)) or `false` otherwise.
```html
<script src="https://unpkg.com/is-ipfs/dist/index.min.js"></script>
```

## API Docs
# API Docs

- <https://ipfs-shipyard.github.io/is-ipfs>

## License
# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribution
# Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"bugs": {
"url": "https://github.com/ipfs-shipyard/is-ipfs/issues"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"keywords": [
"dnslink",
"gateway",
"ipfs",
"ipns",
"js-ipfs"
],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"type": "module",
"types": "./dist/src/index.d.ts",
"files": [
Expand All @@ -40,6 +40,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"project": true,
"sourceType": "module"
}
},
Expand Down Expand Up @@ -129,18 +130,16 @@
]
},
"scripts": {
"clean": "aegir clean",
"lint": "aegir lint",
"dep-check": "aegir dep-check",
"generate": "protons src/pb/peer.proto src/pb/tags.proto",
"build": "aegir build",
"test": "aegir test",
"test:chrome": "aegir test -t browser",
"test:node": "aegir test -t node --cov",
"test:chrome": "aegir test -t browser --cov",
"test:chrome-webworker": "aegir test -t webworker",
"test:firefox": "aegir test -t browser -- --browser firefox",
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"test:node": "aegir test -t node",
"test:electron-main": "aegir test -t electron-main",
"lint": "aegir lint",
"dep-check": "aegir dep-check",
"release": "aegir release",
"docs": "aegir docs"
},
Expand All @@ -152,9 +151,11 @@
"uint8arrays": "^4.0.2"
},
"devDependencies": {
"aegir": "^37.10.1"
"aegir": "^42.2.3"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"browser": {
"fs": false
}
"sideEffects": false
}
Loading
Loading