Compare commits

...

17 Commits

Author SHA1 Message Date
Derrick Hammer 3354ff1247
Merge remote-tracking branch 'origin/develop' into develop 2023-09-04 06:46:37 -04:00
Derrick Hammer c197e83894
chore: update module cid 2023-09-04 06:46:33 -04:00
semantic-release-bot a88f49ea39 chore(release): 0.1.0-develop.4 [skip ci]
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/resolver-module-cid/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-09-04)
2023-09-04 10:41:41 +00:00
Derrick Hammer 3e78fcc9a1
dep: update kernel-libresolver 2023-09-04 06:40:17 -04:00
Derrick Hammer 6bc8aafbf5
Merge remote-tracking branch 'origin/develop' into develop 2023-09-03 01:52:08 -04:00
Derrick Hammer 1a241d7341
chore: update module cid 2023-09-03 01:52:01 -04:00
semantic-release-bot 2c354e8fa4 chore(release): 0.1.0-develop.3 [skip ci]
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/resolver-module-cid/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-09-03)
2023-09-03 05:51:00 +00:00
Derrick Hammer 094bb7e053
Merge remote-tracking branch 'origin/develop' into develop 2023-09-03 01:50:01 -04:00
Derrick Hammer 067752306e
dep: update kernel-libresolver 2023-09-03 01:49:52 -04:00
semantic-release-bot 8372f24fca chore(release): 0.1.0-develop.2 [skip ci]
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/resolver-module-cid/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-09-02)
2023-09-02 18:23:37 +00:00
Derrick Hammer e5ac574dc4
Merge remote-tracking branch 'origin/develop' into develop 2023-09-02 14:22:30 -04:00
Derrick Hammer fa48df2051
chore: add module cid to README.md 2023-09-02 14:22:14 -04:00
Derrick Hammer 06c9ac563e
dep: update kernel-libresolver 2023-09-02 14:20:22 -04:00
semantic-release-bot be82577783 chore(release): 0.1.0-develop.1 [skip ci]
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/resolver-module-cid/compare/v0.0.1...v0.1.0-develop.1) (2023-07-31)

### Features

* initial version ([6d8e0c3](6d8e0c3aad))
2023-07-31 16:49:06 +00:00
Derrick Hammer ecf512bbf4
ci: add npm-shrinkwrap.json 2023-07-31 12:31:19 -04:00
Derrick Hammer da7583b809
ci: setup 2023-07-31 10:28:46 -04:00
Derrick Hammer 6d8e0c3aad
feat: initial version 2023-07-31 10:28:16 -04:00
8 changed files with 19946 additions and 0 deletions

13
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Build/Publish
on:
push:
branches:
- master
- develop
- develop-*
jobs:
main:
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
secrets: inherit

8
.presetterrc.json Normal file
View File

@ -0,0 +1,8 @@
{
"preset": [
"@lumeweb/presetter-kernel-module-preset"
],
"config": {
"official": true
}
}

12
CHANGELOG.md Normal file
View File

@ -0,0 +1,12 @@
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/resolver-module-cid/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-09-04)
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/resolver-module-cid/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-09-03)
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/resolver-module-cid/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-09-02)
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/resolver-module-cid/compare/v0.0.1...v0.1.0-develop.1) (2023-07-31)
### Features
* initial version ([6d8e0c3](https://git.lumeweb.com/LumeWeb/resolver-module-cid/commit/6d8e0c3aadbedfbdf2a2764d8d85ebce41348f13))

View File

@ -1,2 +1,3 @@
# resolver-module-cid
Module CID: zdiJdDdBJWAdYFTcRa9So5TQQ9f1pYMiMy4dqYcKp9imomQtR11LJUyJyV

19827
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

21
package.json Normal file
View File

@ -0,0 +1,21 @@
{
"name": "@lumeweb/resolver-module-cid",
"version": "0.1.0-develop.4",
"type": "module",
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/resolver-module-cid.git"
},
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
},
"dependencies": {
"@lumeweb/kernel-libresolver": "^0.1.0-develop.9"
},
"devDependencies": {
"@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.44"
}
}

6
src/index.ts Normal file
View File

@ -0,0 +1,6 @@
import { setup } from "@lumeweb/kernel-libresolver";
import CID from "./resolver.js";
// @ts-ignore
setup(new CID());

58
src/resolver.ts Normal file
View File

@ -0,0 +1,58 @@
import {
AbstractResolverModule,
DNS_RECORD_TYPE,
DNSResult,
resolverEmptyResponse,
ResolverOptions,
resolveSuccess,
} from "@lumeweb/kernel-libresolver";
const NETWORK_MAP = new Map(
Object.entries({
IPFS: "ipfs://",
IPNS: "ipns://",
}),
);
const NAMESPACE = "lume";
export default class CID extends AbstractResolverModule {
ready(): Promise<void> {
return Promise.resolve(true) as any;
}
async resolve(
domain: string,
options: ResolverOptions,
bypassCache: boolean,
): Promise<DNSResult> {
if (!domain.includes(".")) {
return resolverEmptyResponse();
}
const domainParts = domain.split(".");
const last = domainParts.slice()?.pop();
if (last !== NAMESPACE) {
return resolverEmptyResponse();
}
const network = domainParts.slice(1).shift()?.toUpperCase() as string;
if (!NETWORK_MAP.has(network)) {
return resolverEmptyResponse();
}
const cid = domainParts.slice()?.shift();
if (!cid) {
return resolverEmptyResponse();
}
return resolveSuccess([
{
type: DNS_RECORD_TYPE.CONTENT,
value: NETWORK_MAP.get(network) + cid,
},
]);
}
}