@ckb-ccc/did-ckb 0.0.0-canary-20260106175902
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +41 -0
- package/dist/barrel-Cn3jQCCZ.mjs +2 -0
- package/dist/barrel-Cn3jQCCZ.mjs.map +1 -0
- package/dist/barrel.d.mts +144 -0
- package/dist/barrel.d.mts.map +1 -0
- package/dist/barrel.mjs +1 -0
- package/dist/chunk-CRnh9GRf.mjs +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/package.json +3 -0
- package/dist.commonjs/barrel-3QHu103S.js +1 -0
- package/dist.commonjs/barrel-D5mx-XKy.d.ts +146 -0
- package/dist.commonjs/barrel-D5mx-XKy.d.ts.map +1 -0
- package/dist.commonjs/barrel.d.ts +2 -0
- package/dist.commonjs/barrel.js +1 -0
- package/dist.commonjs/index.d.ts +2 -0
- package/dist.commonjs/index.js +1 -0
- package/dist.commonjs/package.json +3 -0
- package/package.json +53 -0
- package/prettier.config.cjs +11 -0
- package/src/barrel.ts +2 -0
- package/src/codec.ts +149 -0
- package/src/didCkb.ts +30 -0
- package/src/index.ts +1 -0
- package/tsdown.config.mts +33 -0
- package/typedoc.json +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @ckb-ccc/did-ckb
|
|
2
|
+
|
|
3
|
+
## 0.0.0-canary-20260106175902
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#337](https://github.com/ckb-devrel/ccc/pull/337) [`042fa01`](https://github.com/ckb-devrel/ccc/commit/042fa013c30d9426eb76e6cf2fb11addf1a453ef) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(did-ckb): add did-ckb package for basic did operations
|
|
9
|
+
|
|
10
|
+
- Updated dependencies [[`f593970`](https://github.com/ckb-devrel/ccc/commit/f593970627a1430ed22997fda3380ee30d838e5c), [`ae8e8c8`](https://github.com/ckb-devrel/ccc/commit/ae8e8c8c14bff70fe22f91b1a1b248be06114d6b)]:
|
|
11
|
+
- @ckb-ccc/type-id@0.0.0-canary-20260106175902
|
|
12
|
+
- @ckb-ccc/core@0.0.0-canary-20260106175902
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://app.ckbccc.com/">
|
|
3
|
+
<img alt="Logo" src="https://raw.githubusercontent.com/ckb-devrel/ccc/master/assets/logoAndText.svg" style="height: 8rem; max-width: 90%; padding: 0.5rem 0;" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center" style="font-size: 48px;">
|
|
8
|
+
CCC's Support for DID CKB
|
|
9
|
+
</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@ckb-ccc/did-ckb"><img
|
|
13
|
+
alt="NPM Version" src="https://img.shields.io/npm/v/%40ckb-ccc%2Fdid-ckb"
|
|
14
|
+
/></a>
|
|
15
|
+
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/ckb-devrel/ccc" />
|
|
16
|
+
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/ckb-devrel/ccc/master" />
|
|
17
|
+
<img alt="GitHub branch check runs" src="https://img.shields.io/github/check-runs/ckb-devrel/ccc/master" />
|
|
18
|
+
<a href="https://live.ckbccc.com/"><img
|
|
19
|
+
alt="Playground" src="https://img.shields.io/website?url=https%3A%2F%2Flive.ckbccc.com%2F&label=Playground"
|
|
20
|
+
/></a>
|
|
21
|
+
<a href="https://app.ckbccc.com/"><img
|
|
22
|
+
alt="App" src="https://img.shields.io/website?url=https%3A%2F%2Fapp.ckbccc.com%2F&label=App"
|
|
23
|
+
/></a>
|
|
24
|
+
<a href="https://docs.ckbccc.com/"><img
|
|
25
|
+
alt="Docs" src="https://img.shields.io/website?url=https%3A%2F%2Fdocs.ckbccc.com%2F&label=Docs"
|
|
26
|
+
/></a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
CCC - CKBers' Codebase is a one-stop solution for your CKB JS/TS ecosystem development.
|
|
31
|
+
<br />
|
|
32
|
+
Empower yourself with CCC to discover the unlimited potential of CKB.
|
|
33
|
+
<br />
|
|
34
|
+
Interoperate with wallets from different chain ecosystems.
|
|
35
|
+
<br />
|
|
36
|
+
Fully enabling CKB's Turing completeness and cryptographic freedom power.
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<h3 align="center">
|
|
40
|
+
Read more about CCC on <a href="https://docs.ckbccc.com">our website</a> or <a href="https://github.com/ckb-devrel/ccc">GitHub Repo</a>.
|
|
41
|
+
</h3>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./chunk-CRnh9GRf.mjs";import{ccc as t}from"@ckb-ccc/core";import{decode as n,encode as r}from"@ipld/dag-cbor";import{typeIdA as i}from"@ckb-ccc/type-id/advanced";function a(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var o,s,c,l;let u=o=class extends t.mol.Entity.Base(){constructor(e,t){super(),this.document=e,this.localId=t}static from(e){return e instanceof o?e:new o(e.document,e.localId??void 0)}};u=o=a([t.mol.codec(t.mol.table({document:t.mol.Bytes,localId:t.mol.StringOpt}).map({inMap:e=>({...e,document:t.hexFrom(r(e.document))}),outMap:e=>({...e,document:n(t.bytesFrom(e.document))})}))],u);let d=s=class extends t.mol.Entity.Base(){constructor(e,t){super(),this.type=e,this.value=t}static from(e){return e instanceof s?e:new s(e.type??`v1`,u.from(e.value))}static fromV1(e){return new s(`v1`,u.from(e))}};d=s=a([t.mol.codec(t.mol.union({v1:u}))],d);let f=c=class extends t.mol.Entity.Base(){constructor(e,t,n){super(),this.history=e,this.sig=t,this.rotationKeyIndices=n}static from(e){return e instanceof c?e:new c(e.history,t.hexFrom(e.sig),e.rotationKeyIndices.map(t.numFrom))}};f=c=a([t.mol.codec(t.mol.table({history:t.mol.BytesVec,sig:t.mol.Bytes,rotationKeyIndices:t.mol.Uint8Vec}).map({inMap:e=>({...e,history:e.history.map(e=>t.hexFrom(r(e)))}),outMap:e=>({...e,history:e.history.map(e=>n(t.bytesFrom(e)))})}))],f);let p=l=class extends t.mol.Entity.Base(){constructor(e){super(),this.localIdAuthorization=e}static from(e){return e instanceof l?e:new l(f.from(e.localIdAuthorization))}};p=l=a([t.mol.codec(t.mol.table({localIdAuthorization:f}))],p);const m=i.buildTypeIdOperations({async getScriptInfo(e){return e.getKnownScript(t.KnownScript.DidCkb)}}),{transfer:h,destroy:g}=m;function _({signer:e,data:t,receiver:n,tx:r}){return m.create({signer:e,data:d.from(t).toBytes(),receiver:n,tx:r})}var v=e({DidCkbData:()=>d,DidCkbDataV1:()=>u,DidCkbWitness:()=>p,PlcAuthorization:()=>f,createDidCkb:()=>_,destroyDidCkb:()=>g,transferDidCkb:()=>h});export{d as a,f as c,h as i,_ as n,u as o,g as r,p as s,v as t};
|
|
2
|
+
//# sourceMappingURL=barrel-Cn3jQCCZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel-Cn3jQCCZ.mjs","names":["DidCkbDataV1","cborEncode","cborDecode","DidCkbData","PlcAuthorization","DidCkbWitness"],"sources":["../src/codec.ts","../src/didCkb.ts","../src/barrel.ts"],"sourcesContent":["import { ccc } from \"@ckb-ccc/core\";\nimport { decode as cborDecode, encode as cborEncode } from \"@ipld/dag-cbor\";\n\nexport type DidCkbDataV1Like = {\n document: object;\n localId?: string | null;\n};\n@ccc.mol.codec(\n ccc.mol\n .table({\n document: ccc.mol.Bytes,\n localId: ccc.mol.StringOpt,\n })\n .map({\n inMap: (data: DidCkbDataV1Like) => ({\n ...data,\n document: ccc.hexFrom(cborEncode(data.document)),\n }),\n outMap: (data) => ({\n ...data,\n document: cborDecode<object>(ccc.bytesFrom(data.document)),\n }),\n }),\n)\nexport class DidCkbDataV1 extends ccc.mol.Entity.Base<\n DidCkbDataV1Like,\n DidCkbDataV1\n>() {\n constructor(\n public document: object,\n public localId?: string,\n ) {\n super();\n }\n\n static from(data: DidCkbDataV1Like): DidCkbDataV1 {\n if (data instanceof DidCkbDataV1) {\n return data;\n }\n\n return new DidCkbDataV1(data.document, data.localId ?? undefined);\n }\n}\n\nexport type DidCkbDataLike = {\n type?: \"v1\" | null;\n value: DidCkbDataV1Like;\n};\n@ccc.mol.codec(\n ccc.mol.union({\n v1: DidCkbDataV1,\n }),\n)\nexport class DidCkbData extends ccc.mol.Entity.Base<\n DidCkbDataLike,\n DidCkbData\n>() {\n constructor(\n public type: \"v1\",\n public value: DidCkbDataV1,\n ) {\n super();\n }\n\n static from(data: DidCkbDataLike): DidCkbData {\n if (data instanceof DidCkbData) {\n return data;\n }\n return new DidCkbData(data.type ?? \"v1\", DidCkbDataV1.from(data.value));\n }\n\n static fromV1(\n data: DidCkbDataV1Like,\n ): DidCkbData & { type: \"v1\"; value: DidCkbDataV1 } {\n return new DidCkbData(\"v1\", DidCkbDataV1.from(data));\n }\n}\n\nexport type PlcAuthorizationLike = {\n history: object[];\n sig: ccc.HexLike;\n rotationKeyIndices: ccc.NumLike[];\n};\n@ccc.mol.codec(\n ccc.mol\n .table({\n history: ccc.mol.BytesVec,\n sig: ccc.mol.Bytes,\n rotationKeyIndices: ccc.mol.Uint8Vec,\n })\n\n .map({\n inMap: (data: PlcAuthorizationLike) => ({\n ...data,\n history: data.history.map((h) => ccc.hexFrom(cborEncode(h))),\n }),\n outMap: (data) => ({\n ...data,\n history: data.history.map((h) => cborDecode<object>(ccc.bytesFrom(h))),\n }),\n }),\n)\nexport class PlcAuthorization extends ccc.mol.Entity.Base<\n PlcAuthorizationLike,\n PlcAuthorization\n>() {\n constructor(\n public history: object[],\n public sig: ccc.Hex,\n public rotationKeyIndices: ccc.Num[],\n ) {\n super();\n }\n\n static from(data: PlcAuthorizationLike): PlcAuthorization {\n if (data instanceof PlcAuthorization) {\n return data;\n }\n return new PlcAuthorization(\n data.history,\n ccc.hexFrom(data.sig),\n data.rotationKeyIndices.map(ccc.numFrom),\n );\n }\n}\n\nexport type DidCkbWitnessLike = {\n localIdAuthorization: PlcAuthorizationLike;\n};\n@ccc.mol.codec(\n ccc.mol.table({\n localIdAuthorization: PlcAuthorization,\n }),\n)\nexport class DidCkbWitness extends ccc.mol.Entity.Base<\n DidCkbWitnessLike,\n DidCkbWitness\n>() {\n constructor(public localIdAuthorization: PlcAuthorization) {\n super();\n }\n\n static from(data: DidCkbWitnessLike): DidCkbWitness {\n if (data instanceof DidCkbWitness) {\n return data;\n }\n return new DidCkbWitness(PlcAuthorization.from(data.localIdAuthorization));\n }\n}\n","import { ccc } from \"@ckb-ccc/core\";\nimport { typeIdA } from \"@ckb-ccc/type-id/advanced\";\nimport { DidCkbData, DidCkbDataLike } from \"./codec\";\n\nconst OPERATIONS = typeIdA.buildTypeIdOperations({\n async getScriptInfo(client: ccc.Client): Promise<ccc.ScriptInfo> {\n return client.getKnownScript(ccc.KnownScript.DidCkb);\n },\n});\n\nexport const { transfer: transferDidCkb, destroy: destroyDidCkb } = OPERATIONS;\n\nexport function createDidCkb({\n signer,\n data,\n receiver,\n tx: txLike,\n}: {\n signer: ccc.Signer;\n data: DidCkbDataLike;\n receiver?: ccc.ScriptLike | null;\n tx?: ccc.TransactionLike | null;\n}) {\n return OPERATIONS.create({\n signer,\n data: DidCkbData.from(data).toBytes(),\n receiver,\n tx: txLike,\n });\n}\n","export * from \"./codec.js\";\nexport * from \"./didCkb.js\";\n"],"mappings":"sgBAwBO,IAAA,EAAA,EAAA,cAA2B,EAAI,IAAI,OAAO,MAG9C,AAAC,CACF,YACE,EACA,EACA,CACA,OAAO,CAHA,KAAA,SAAA,EACA,KAAA,QAAA,EAKT,OAAO,KAAK,EAAsC,CAKhD,OAJI,aAAA,EACK,EAGF,IAAA,EAAiB,EAAK,SAAU,EAAK,SAAW,IAAA,GAAU,UAjCpE,EAAI,IAAI,MACP,EAAI,IACD,MAAM,CACL,SAAU,EAAI,IAAI,MAClB,QAAS,EAAI,IAAI,UAClB,CAAC,CACD,IAAI,CACH,MAAQ,IAA4B,CAClC,GAAG,EACH,SAAU,EAAI,QAAQC,EAAW,EAAK,SAAS,CAAC,CACjD,EACD,OAAS,IAAU,CACjB,GAAG,EACH,SAAUC,EAAmB,EAAI,UAAU,EAAK,SAAS,CAAC,CAC3D,EACF,CAAC,CACL,CAAA,CAAA,EAAA,CA8BM,IAAA,EAAA,EAAA,cAAyB,EAAI,IAAI,OAAO,MAG5C,AAAC,CACF,YACE,EACA,EACA,CACA,OAAO,CAHA,KAAA,KAAA,EACA,KAAA,MAAA,EAKT,OAAO,KAAK,EAAkC,CAI5C,OAHI,aAAA,EACK,EAEF,IAAA,EAAe,EAAK,MAAQ,KAAM,EAAa,KAAK,EAAK,MAAM,CAAC,CAGzE,OAAO,OACL,EACkD,CAClD,OAAO,IAAA,EAAe,KAAM,EAAa,KAAK,EAAK,CAAC,UA1BvD,EAAI,IAAI,MACP,EAAI,IAAI,MAAM,CACZ,GAAI,EACL,CAAC,CACH,CAAA,CAAA,EAAA,CAkDM,IAAA,EAAA,EAAA,cAA+B,EAAI,IAAI,OAAO,MAGlD,AAAC,CACF,YACE,EACA,EACA,EACA,CACA,OAAO,CAJA,KAAA,QAAA,EACA,KAAA,IAAA,EACA,KAAA,mBAAA,EAKT,OAAO,KAAK,EAA8C,CAIxD,OAHI,aAAA,EACK,EAEF,IAAA,EACL,EAAK,QACL,EAAI,QAAQ,EAAK,IAAI,CACrB,EAAK,mBAAmB,IAAI,EAAI,QAAQ,CACzC,UAvCJ,EAAI,IAAI,MACP,EAAI,IACD,MAAM,CACL,QAAS,EAAI,IAAI,SACjB,IAAK,EAAI,IAAI,MACb,mBAAoB,EAAI,IAAI,SAC7B,CAAC,CAED,IAAI,CACH,MAAQ,IAAgC,CACtC,GAAG,EACH,QAAS,EAAK,QAAQ,IAAK,GAAM,EAAI,QAAQD,EAAW,EAAE,CAAC,CAAC,CAC7D,EACD,OAAS,IAAU,CACjB,GAAG,EACH,QAAS,EAAK,QAAQ,IAAK,GAAMC,EAAmB,EAAI,UAAU,EAAE,CAAC,CAAC,CACvE,EACF,CAAC,CACL,CAAA,CAAA,EAAA,CAiCM,IAAA,EAAA,EAAA,cAA4B,EAAI,IAAI,OAAO,MAG/C,AAAC,CACF,YAAY,EAA+C,CACzD,OAAO,CADU,KAAA,qBAAA,EAInB,OAAO,KAAK,EAAwC,CAIlD,OAHI,aAAA,EACK,EAEF,IAAA,EAAkB,EAAiB,KAAK,EAAK,qBAAqB,CAAC,UAjB7E,EAAI,IAAI,MACP,EAAI,IAAI,MAAM,CACZ,qBAAsB,EACvB,CAAC,CACH,CAAA,CAAA,EAAA,CCjID,MAAM,EAAa,EAAQ,sBAAsB,CAC/C,MAAM,cAAc,EAA6C,CAC/D,OAAO,EAAO,eAAe,EAAI,YAAY,OAAO,EAEvD,CAAC,CAEW,CAAE,SAAU,EAAgB,QAAS,GAAkB,EAEpE,SAAgB,EAAa,CAC3B,SACA,OACA,WACA,GAAI,GAMH,CACD,OAAO,EAAW,OAAO,CACvB,SACA,KAAM,EAAW,KAAK,EAAK,CAAC,SAAS,CACrC,WACA,GAAI,EACL,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
|
|
3
|
+
//#region src/codec.d.ts
|
|
4
|
+
type DidCkbDataV1Like = {
|
|
5
|
+
document: object;
|
|
6
|
+
localId?: string | null;
|
|
7
|
+
};
|
|
8
|
+
declare const DidCkbDataV1_base: (abstract new () => {
|
|
9
|
+
toBytes(): ccc.Bytes;
|
|
10
|
+
clone(): DidCkbDataV1;
|
|
11
|
+
eq(other: DidCkbDataV1Like): boolean;
|
|
12
|
+
hash(): ccc.Hex;
|
|
13
|
+
}) & {
|
|
14
|
+
byteLength?: number;
|
|
15
|
+
encode(_: DidCkbDataV1Like): ccc.Bytes;
|
|
16
|
+
decode(_: ccc.BytesLike): DidCkbDataV1;
|
|
17
|
+
fromBytes(_bytes: ccc.BytesLike): DidCkbDataV1;
|
|
18
|
+
from(_: DidCkbDataV1Like): DidCkbDataV1;
|
|
19
|
+
};
|
|
20
|
+
declare class DidCkbDataV1 extends DidCkbDataV1_base {
|
|
21
|
+
document: object;
|
|
22
|
+
localId?: string | undefined;
|
|
23
|
+
constructor(document: object, localId?: string | undefined);
|
|
24
|
+
static from(data: DidCkbDataV1Like): DidCkbDataV1;
|
|
25
|
+
}
|
|
26
|
+
type DidCkbDataLike = {
|
|
27
|
+
type?: "v1" | null;
|
|
28
|
+
value: DidCkbDataV1Like;
|
|
29
|
+
};
|
|
30
|
+
declare const DidCkbData_base: (abstract new () => {
|
|
31
|
+
toBytes(): ccc.Bytes;
|
|
32
|
+
clone(): DidCkbData;
|
|
33
|
+
eq(other: DidCkbDataLike): boolean;
|
|
34
|
+
hash(): ccc.Hex;
|
|
35
|
+
}) & {
|
|
36
|
+
byteLength?: number;
|
|
37
|
+
encode(_: DidCkbDataLike): ccc.Bytes;
|
|
38
|
+
decode(_: ccc.BytesLike): DidCkbData;
|
|
39
|
+
fromBytes(_bytes: ccc.BytesLike): DidCkbData;
|
|
40
|
+
from(_: DidCkbDataLike): DidCkbData;
|
|
41
|
+
};
|
|
42
|
+
declare class DidCkbData extends DidCkbData_base {
|
|
43
|
+
type: "v1";
|
|
44
|
+
value: DidCkbDataV1;
|
|
45
|
+
constructor(type: "v1", value: DidCkbDataV1);
|
|
46
|
+
static from(data: DidCkbDataLike): DidCkbData;
|
|
47
|
+
static fromV1(data: DidCkbDataV1Like): DidCkbData & {
|
|
48
|
+
type: "v1";
|
|
49
|
+
value: DidCkbDataV1;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
type PlcAuthorizationLike = {
|
|
53
|
+
history: object[];
|
|
54
|
+
sig: ccc.HexLike;
|
|
55
|
+
rotationKeyIndices: ccc.NumLike[];
|
|
56
|
+
};
|
|
57
|
+
declare const PlcAuthorization_base: (abstract new () => {
|
|
58
|
+
toBytes(): ccc.Bytes;
|
|
59
|
+
clone(): PlcAuthorization;
|
|
60
|
+
eq(other: PlcAuthorizationLike): boolean;
|
|
61
|
+
hash(): ccc.Hex;
|
|
62
|
+
}) & {
|
|
63
|
+
byteLength?: number;
|
|
64
|
+
encode(_: PlcAuthorizationLike): ccc.Bytes;
|
|
65
|
+
decode(_: ccc.BytesLike): PlcAuthorization;
|
|
66
|
+
fromBytes(_bytes: ccc.BytesLike): PlcAuthorization;
|
|
67
|
+
from(_: PlcAuthorizationLike): PlcAuthorization;
|
|
68
|
+
};
|
|
69
|
+
declare class PlcAuthorization extends PlcAuthorization_base {
|
|
70
|
+
history: object[];
|
|
71
|
+
sig: ccc.Hex;
|
|
72
|
+
rotationKeyIndices: ccc.Num[];
|
|
73
|
+
constructor(history: object[], sig: ccc.Hex, rotationKeyIndices: ccc.Num[]);
|
|
74
|
+
static from(data: PlcAuthorizationLike): PlcAuthorization;
|
|
75
|
+
}
|
|
76
|
+
type DidCkbWitnessLike = {
|
|
77
|
+
localIdAuthorization: PlcAuthorizationLike;
|
|
78
|
+
};
|
|
79
|
+
declare const DidCkbWitness_base: (abstract new () => {
|
|
80
|
+
toBytes(): ccc.Bytes;
|
|
81
|
+
clone(): DidCkbWitness;
|
|
82
|
+
eq(other: DidCkbWitnessLike): boolean;
|
|
83
|
+
hash(): ccc.Hex;
|
|
84
|
+
}) & {
|
|
85
|
+
byteLength?: number;
|
|
86
|
+
encode(_: DidCkbWitnessLike): ccc.Bytes;
|
|
87
|
+
decode(_: ccc.BytesLike): DidCkbWitness;
|
|
88
|
+
fromBytes(_bytes: ccc.BytesLike): DidCkbWitness;
|
|
89
|
+
from(_: DidCkbWitnessLike): DidCkbWitness;
|
|
90
|
+
};
|
|
91
|
+
declare class DidCkbWitness extends DidCkbWitness_base {
|
|
92
|
+
localIdAuthorization: PlcAuthorization;
|
|
93
|
+
constructor(localIdAuthorization: PlcAuthorization);
|
|
94
|
+
static from(data: DidCkbWitnessLike): DidCkbWitness;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/didCkb.d.ts
|
|
98
|
+
declare const transferDidCkb: (this: void, {
|
|
99
|
+
client,
|
|
100
|
+
id,
|
|
101
|
+
receiver,
|
|
102
|
+
tx: txLike
|
|
103
|
+
}: {
|
|
104
|
+
client: ccc.Client;
|
|
105
|
+
id: ccc.HexLike;
|
|
106
|
+
receiver: ccc.ScriptLike;
|
|
107
|
+
tx?: ccc.TransactionLike | null;
|
|
108
|
+
}) => Promise<{
|
|
109
|
+
tx: ccc.Transaction;
|
|
110
|
+
inIndex: number;
|
|
111
|
+
outIndex: number;
|
|
112
|
+
}>, destroyDidCkb: (this: void, {
|
|
113
|
+
client,
|
|
114
|
+
id,
|
|
115
|
+
tx: txLike
|
|
116
|
+
}: {
|
|
117
|
+
client: ccc.Client;
|
|
118
|
+
id: ccc.HexLike;
|
|
119
|
+
tx?: ccc.TransactionLike | null;
|
|
120
|
+
}) => Promise<{
|
|
121
|
+
tx: ccc.Transaction;
|
|
122
|
+
index: number;
|
|
123
|
+
}>;
|
|
124
|
+
declare function createDidCkb({
|
|
125
|
+
signer,
|
|
126
|
+
data,
|
|
127
|
+
receiver,
|
|
128
|
+
tx: txLike
|
|
129
|
+
}: {
|
|
130
|
+
signer: ccc.Signer;
|
|
131
|
+
data: DidCkbDataLike;
|
|
132
|
+
receiver?: ccc.ScriptLike | null;
|
|
133
|
+
tx?: ccc.TransactionLike | null;
|
|
134
|
+
}): Promise<{
|
|
135
|
+
tx: ccc.Transaction;
|
|
136
|
+
id: ccc.Hex;
|
|
137
|
+
index: number;
|
|
138
|
+
}>;
|
|
139
|
+
declare namespace barrel_d_exports {
|
|
140
|
+
export { DidCkbData, DidCkbDataLike, DidCkbDataV1, DidCkbDataV1Like, DidCkbWitness, DidCkbWitnessLike, PlcAuthorization, PlcAuthorizationLike, createDidCkb, destroyDidCkb, transferDidCkb };
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { DidCkbData, DidCkbDataLike, DidCkbDataV1, DidCkbDataV1Like, DidCkbWitness, DidCkbWitnessLike, PlcAuthorization, PlcAuthorizationLike, createDidCkb, destroyDidCkb, barrel_d_exports as t, transferDidCkb };
|
|
144
|
+
//# sourceMappingURL=barrel.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel.d.mts","names":[],"sources":["../src/codec.ts","../src/didCkb.ts","../src/barrel.ts"],"sourcesContent":[],"mappings":";;;KAGY,gBAAA;;;AAAZ,CAAA;AAGE,cAAA,iBAAA,EAAA,CAAA,gBAAA,GAAA;;;;;;;;;;;;cAkBW,YAAA,SAAqB,iBAAA;;EAArB,OAAA,CAAA,EAAA,MAAa,GAAA,SAAA;EAWN,WAAA,CAAA,QAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAAmB,OAAA,IAAA,CAAA,IAAA,EAAnB,gBAAmB,CAAA,EAAA,YAAA;;AARpC,KAiBS,cAAA,GAjBT;EAiBS,IAAA,CAAA,EAAA,IAAA,GAAA,IAAc;EAGxB,KAAA,EADO,gBACP;;cAAA;;;;;;;;;;;;AAMW,cAAA,UAAA,SAAmB,eAAA,CAAR;EAMN,IAAA,EAAA,IAAA;EAAA,KAAA,EAAA,YAAA;EAKE,WAAA,CAAA,IAAA,EAAA,IAAA,EAAA,KAAA,EALF,YAKE;EAAiB,OAAA,IAAA,CAAA,IAAA,EAAjB,cAAiB,CAAA,EAAA,UAAA;EAQ3B,OAAA,MAAA,CAAA,IAAA,EAAA,gBAAA,CAAA,EACL,UADK,GAAA;IACL,IAAA,EAAA,IAAA;IAAkC,KAAA,EAAA,YAAA;EApBP,CAAA;;AAyBpB,KAAA,oBAAA,GAAoB;EAI9B,OAAA,EAAA,MAAA,EAAA;OAFK,GAAA,CAAI;sBACW,GAAA,CAAI;;cACxB;;;;;;;;;;EAoBW,IAAA,CAAA,CAAA,sBAAiB,CAAA,kBAAA;CAMd;AACmB,cAPtB,gBAAA,SAAyB,qBAAA,CAOH;EADnB,OAAI,EAAA,MAAA,EAAA;EACW,GAAI,EADnB,GAAA,CAAI,GACe;EAKf,kBAAA,EALW,GAAA,CAAI,GAKf,EAAA;EAAuB,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,EAAA,GAAA,EAN3B,GAAA,CAAI,GAMuB,EAAA,kBAAA,EALZ,GAAA,CAAI,GAKQ,EAAA;EAZL,OAAA,IAAA,CAAA,IAAA,EAYlB,oBAZkB,CAAA,EAYK,gBAZL;;AAwB1B,KAAA,iBAAA,GAAiB;EAE3B,oBAAA,EADsB,oBACtB;;cAAA;;;;;;;;;;;;AAMW,cAAA,aAAA,SAAsB,kBAAA,CAAR;EAIgB,oBAAA,EAAA,gBAAA;EAAA,WAAA,CAAA,oBAAA,EAAA,gBAAA;EAIvB,OAAA,IAAA,CAAA,IAAA,EAAA,iBAAA,CAAA,EAAoB,aAApB;;;;cCpIK;;;;QAAc;;;IDP3B,EAAA,aAAA;IAGV,QAAA,gBAAA;SCwBsH,GAAA,CAAA;;;;;;;;QApBzD;;;;SAoBuS,GAAA,CAAA;;;;;ADNzV,iBCZG,YAAA,CDYU;EAAA,MAAA;EAAA,IAAA;EAAA,QAAA;EAAA,EAAA,ECRpB;AD4BN,CApB0B,EAAA;EAWN,MAAA,ECjBV,GAAA,CAAI,MDiBM;EAAmB,IAAA,EChB/B,cDgB+B;EAXL,QAAA,CAAA,ECJrB,GAAA,CAAI,UDIiB,GAAA,IAAA;EAG/B,EAAA,CAAA,ECNI,GAAA,CAAI,eDMR,GAAA,IAAA;AAiBH,CAAA,CAAA,ECtBC,ODsBW,CAAA;EAGV,EAAA,iBAAA"}
|
package/dist/barrel.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o}from"./barrel-Cn3jQCCZ.mjs";export{e as DidCkbData,i as DidCkbDataV1,o as DidCkbWitness,t as PlcAuthorization,r as createDidCkb,a as destroyDidCkb,n as transferDidCkb};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&&e(r,Symbol.toStringTag,{value:`Module`}),r};export{t};
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./barrel-Cn3jQCCZ.mjs";export{e as didCkb};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&&e(r,Symbol.toStringTag,{value:`Module`}),r};let n=require(`@ckb-ccc/core`),r=require(`@ckb-ccc/type-id/advanced`);const i=[`string`,`number`,`bigint`,`symbol`],a=`Function.Generator.AsyncGenerator.GeneratorFunction.AsyncGeneratorFunction.AsyncFunction.Observable.Array.Buffer.Object.RegExp.Date.Error.Map.Set.WeakMap.WeakSet.ArrayBuffer.SharedArrayBuffer.DataView.Promise.URL.HTMLElement.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Uint16Array.Int32Array.Uint32Array.Float32Array.Float64Array.BigInt64Array.BigUint64Array`.split(`.`);function o(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(e===!0||e===!1)return`boolean`;let t=typeof e;return i.includes(t)?t:t===`function`?`Function`:Array.isArray(e)?`Array`:s(e)?`Buffer`:c(e)||`Object`}function s(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function c(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(a.includes(t))return t}var l=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};l.uint=new l(0,`uint`,!0),l.negint=new l(1,`negint`,!0),l.bytes=new l(2,`bytes`,!0),l.string=new l(3,`string`,!0),l.array=new l(4,`array`,!1),l.map=new l(5,`map`,!1),l.tag=new l(6,`tag`,!1),l.float=new l(7,`float`,!0),l.false=new l(7,`false`,!0),l.true=new l(7,`true`,!0),l.null=new l(7,`null`,!0),l.undefined=new l(7,`undefined`,!0),l.break=new l(7,`break`,!0);var u=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};const d=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer==`function`,f=new TextDecoder,p=new TextEncoder;function m(e){return d&&globalThis.Buffer.isBuffer(e)}function h(e){return e instanceof Uint8Array?m(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}const ee=d?(e,t,n)=>n-t>64?globalThis.Buffer.from(e.subarray(t,n)).toString(`utf8`):se(e,t,n):(e,t,n)=>n-t>64?f.decode(e.subarray(t,n)):se(e,t,n),te=d?e=>e.length>64?globalThis.Buffer.from(e):oe(e):e=>e.length>64?p.encode(e):oe(e),g=e=>Uint8Array.from(e),ne=d?(e,t,n)=>m(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n),re=d?(e,t)=>(e=e.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),h(globalThis.Buffer.concat(e,t))):(e,t)=>{let n=new Uint8Array(t),r=0;for(let t of e)r+t.length>n.length&&(t=t.subarray(0,n.length-r)),n.set(t,r),r+=t.length;return n},ie=d?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function ae(e,t){if(m(e)&&m(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}function oe(e){let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t}function se(e,t,n){let r=[];for(;t<n;){let i=e[t],a=null,o=i>239?4:i>223?3:i>191?2:1;if(t+o<=n){let n,r,s,c;switch(o){case 1:i<128&&(a=i);break;case 2:n=e[t+1],(n&192)==128&&(c=(i&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[t+1],r=e[t+2],(n&192)==128&&(r&192)==128&&(c=(i&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[t+1],r=e[t+2],s=e[t+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(i&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),t+=o}return le(r)}const ce=4096;function le(e){let t=e.length;if(t<=ce)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=ce));return n}const ue=256;var de=class{constructor(e=256){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let n=t.length-(this.maxCursor-this.cursor)-1;t.set(e,n)}else{if(t){let e=t.length-(this.maxCursor-this.cursor)-1;e<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,e),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=ie(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=ne(n,0,this.cursor)}else t=re(this.chunks,this.cursor);return e&&this.reset(),t}};const _=`CBOR decode error:`,fe=`CBOR encode error:`,v=[];v[23]=1,v[24]=2,v[25]=3,v[26]=5,v[27]=9;function y(e,t,n){if(e.length-t<n)throw Error(`${_} not enough data for type`)}const b=[24,256,65536,4294967296,BigInt(`18446744073709551616`)];function x(e,t,n){y(e,t,1);let r=e[t];if(n.strict===!0&&r<b[0])throw Error(`${_} integer encoded in more bytes than necessary (strict decode)`);return r}function S(e,t,n){y(e,t,2);let r=e[t]<<8|e[t+1];if(n.strict===!0&&r<b[1])throw Error(`${_} integer encoded in more bytes than necessary (strict decode)`);return r}function C(e,t,n){y(e,t,4);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(n.strict===!0&&r<b[2])throw Error(`${_} integer encoded in more bytes than necessary (strict decode)`);return r}function w(e,t,n){y(e,t,8);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],i=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],a=(BigInt(r)<<BigInt(32))+BigInt(i);if(n.strict===!0&&a<b[3])throw Error(`${_} integer encoded in more bytes than necessary (strict decode)`);if(a<=2**53-1)return Number(a);if(n.allowBigInt===!0)return a;throw Error(`${_} integers outside of the safe integer range are not supported`)}function pe(e,t,n,r){return new u(l.uint,x(e,t+1,r),2)}function me(e,t,n,r){return new u(l.uint,S(e,t+1,r),3)}function he(e,t,n,r){return new u(l.uint,C(e,t+1,r),5)}function ge(e,t,n,r){return new u(l.uint,w(e,t+1,r),9)}function T(e,t){return E(e,0,t.value)}function E(e,t,n){if(n<b[0]){let r=Number(n);e.push([t|r])}else if(n<b[1]){let r=Number(n);e.push([t|24,r])}else if(n<b[2]){let r=Number(n);e.push([t|25,r>>>8,r&255])}else if(n<b[3]){let r=Number(n);e.push([t|26,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}else{let r=BigInt(n);if(r<b[4]){let n=[t|27,0,0,0,0,0,0,0],i=Number(r&BigInt(4294967295)),a=Number(r>>BigInt(32)&BigInt(4294967295));n[8]=i&255,i>>=8,n[7]=i&255,i>>=8,n[6]=i&255,i>>=8,n[5]=i&255,n[4]=a&255,a>>=8,n[3]=a&255,a>>=8,n[2]=a&255,a>>=8,n[1]=a&255,e.push(n)}else throw Error(`${_} encountered BigInt larger than allowable range`)}}T.encodedSize=function(e){return E.encodedSize(e.value)},E.encodedSize=function(e){return e<b[0]?1:e<b[1]?2:e<b[2]?3:e<b[3]?5:9},T.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function _e(e,t,n,r){return new u(l.negint,-1-x(e,t+1,r),2)}function ve(e,t,n,r){return new u(l.negint,-1-S(e,t+1,r),3)}function ye(e,t,n,r){return new u(l.negint,-1-C(e,t+1,r),5)}const be=BigInt(-1),xe=BigInt(1);function Se(e,t,n,r){let i=w(e,t+1,r);if(typeof i!=`bigint`){let e=-1-i;if(e>=-(2**53-1))return new u(l.negint,e,9)}if(r.allowBigInt!==!0)throw Error(`${_} integers outside of the safe integer range are not supported`);return new u(l.negint,be-BigInt(i),9)}function Ce(e,t){let n=t.value,r=typeof n==`bigint`?n*be-xe:n*-1-1;E(e,t.type.majorEncoded,r)}Ce.encodedSize=function(e){let t=e.value,n=typeof t==`bigint`?t*be-xe:t*-1-1;return n<b[0]?1:n<b[1]?2:n<b[2]?3:n<b[3]?5:9},Ce.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function D(e,t,n,r){y(e,t,n+r);let i=ne(e,t+n,t+n+r);return new u(l.bytes,i,n+r)}function we(e,t,n,r){return D(e,t,1,n)}function Te(e,t,n,r){return D(e,t,2,x(e,t+1,r))}function Ee(e,t,n,r){return D(e,t,3,S(e,t+1,r))}function De(e,t,n,r){return D(e,t,5,C(e,t+1,r))}function Oe(e,t,n,r){let i=w(e,t+1,r);if(typeof i==`bigint`)throw Error(`${_} 64-bit integer bytes lengths not supported`);return D(e,t,9,i)}function ke(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===l.string?te(e.value):e.value),e.encodedBytes}function Ae(e,t){let n=ke(t);E(e,t.type.majorEncoded,n.length),e.push(n)}Ae.encodedSize=function(e){let t=ke(e);return E.encodedSize(t.length)+t.length},Ae.compareTokens=function(e,t){return je(ke(e),ke(t))};function je(e,t){return e.length<t.length?-1:e.length>t.length?1:ae(e,t)}function O(e,t,n,r,i){let a=n+r;y(e,t,a);let o=new u(l.string,ee(e,t+n,t+a),a);return i.retainStringBytes===!0&&(o.byteValue=ne(e,t+n,t+a)),o}function Me(e,t,n,r){return O(e,t,1,n,r)}function Ne(e,t,n,r){return O(e,t,2,x(e,t+1,r),r)}function Pe(e,t,n,r){return O(e,t,3,S(e,t+1,r),r)}function Fe(e,t,n,r){return O(e,t,5,C(e,t+1,r),r)}function Ie(e,t,n,r){let i=w(e,t+1,r);if(typeof i==`bigint`)throw Error(`${_} 64-bit integer string lengths not supported`);return O(e,t,9,i,r)}const Le=Ae;function k(e,t,n,r){return new u(l.array,r,n)}function Re(e,t,n,r){return k(e,t,1,n)}function ze(e,t,n,r){return k(e,t,2,x(e,t+1,r))}function Be(e,t,n,r){return k(e,t,3,S(e,t+1,r))}function Ve(e,t,n,r){return k(e,t,5,C(e,t+1,r))}function He(e,t,n,r){let i=w(e,t+1,r);if(typeof i==`bigint`)throw Error(`${_} 64-bit integer array lengths not supported`);return k(e,t,9,i)}function Ue(e,t,n,r){if(r.allowIndefinite===!1)throw Error(`${_} indefinite length items not allowed`);return k(e,t,1,1/0)}function We(e,t){E(e,l.array.majorEncoded,t.value)}We.compareTokens=T.compareTokens,We.encodedSize=function(e){return E.encodedSize(e.value)};function A(e,t,n,r){return new u(l.map,r,n)}function Ge(e,t,n,r){return A(e,t,1,n)}function Ke(e,t,n,r){return A(e,t,2,x(e,t+1,r))}function qe(e,t,n,r){return A(e,t,3,S(e,t+1,r))}function Je(e,t,n,r){return A(e,t,5,C(e,t+1,r))}function Ye(e,t,n,r){let i=w(e,t+1,r);if(typeof i==`bigint`)throw Error(`${_} 64-bit integer map lengths not supported`);return A(e,t,9,i)}function Xe(e,t,n,r){if(r.allowIndefinite===!1)throw Error(`${_} indefinite length items not allowed`);return A(e,t,1,1/0)}function Ze(e,t){E(e,l.map.majorEncoded,t.value)}Ze.compareTokens=T.compareTokens,Ze.encodedSize=function(e){return E.encodedSize(e.value)};function Qe(e,t,n,r){return new u(l.tag,n,1)}function $e(e,t,n,r){return new u(l.tag,x(e,t+1,r),2)}function et(e,t,n,r){return new u(l.tag,S(e,t+1,r),3)}function tt(e,t,n,r){return new u(l.tag,C(e,t+1,r),5)}function nt(e,t,n,r){return new u(l.tag,w(e,t+1,r),9)}function rt(e,t){E(e,l.tag.majorEncoded,t.value)}rt.compareTokens=T.compareTokens,rt.encodedSize=function(e){return E.encodedSize(e.value)};const it=20,at=21,ot=22,st=23;function ct(e,t,n,r){if(r.allowUndefined===!1)throw Error(`${_} undefined values are not supported`);return r.coerceUndefinedToNull===!0?new u(l.null,null,1):new u(l.undefined,void 0,1)}function lt(e,t,n,r){if(r.allowIndefinite===!1)throw Error(`${_} indefinite length items not allowed`);return new u(l.break,void 0,1)}function ut(e,t,n){if(n){if(n.allowNaN===!1&&Number.isNaN(e))throw Error(`${_} NaN values are not supported`);if(n.allowInfinity===!1&&(e===1/0||e===-1/0))throw Error(`${_} Infinity values are not supported`)}return new u(l.float,e,t)}function dt(e,t,n,r){return ut(_t(e,t+1),3,r)}function ft(e,t,n,r){return ut(yt(e,t+1),5,r)}function pt(e,t,n,r){return ut(xt(e,t+1),9,r)}function mt(e,t,n){let r=t.value;if(r===!1)e.push([l.float.majorEncoded|20]);else if(r===!0)e.push([l.float.majorEncoded|21]);else if(r===null)e.push([l.float.majorEncoded|22]);else if(r===void 0)e.push([l.float.majorEncoded|23]);else{let t,i=!1;(!n||n.float64!==!0)&&(gt(r),t=_t(M,1),r===t||Number.isNaN(r)?(M[0]=249,e.push(M.slice(0,3)),i=!0):(vt(r),t=yt(M,1),r===t&&(M[0]=250,e.push(M.slice(0,5)),i=!0))),i||(bt(r),t=xt(M,1),M[0]=251,e.push(M.slice(0,9)))}}mt.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n==null)return 1;if(!t||t.float64!==!0){gt(n);let e=_t(M,1);if(n===e||Number.isNaN(n))return 3;if(vt(n),e=yt(M,1),n===e)return 5}return 9};const ht=new ArrayBuffer(9),j=new DataView(ht,1),M=new Uint8Array(ht,0);function gt(e){if(e===1/0)j.setUint16(0,31744,!1);else if(e===-1/0)j.setUint16(0,64512,!1);else if(Number.isNaN(e))j.setUint16(0,32256,!1);else{j.setFloat32(0,e);let t=j.getUint32(0),n=(t&2139095040)>>23,r=t&8388607;if(n===255)j.setUint16(0,31744,!1);else if(n===0)j.setUint16(0,(e&2147483648)>>16|r>>13,!1);else{let e=n-127;e<-24?j.setUint16(0,0):e<-14?j.setUint16(0,(t&2147483648)>>16|1<<24+e,!1):j.setUint16(0,(t&2147483648)>>16|e+15<<10|r>>13,!1)}}}function _t(e,t){if(e.length-t<2)throw Error(`${_} not enough data for float16`);let n=(e[t]<<8)+e[t+1];if(n===31744)return 1/0;if(n===64512)return-1/0;if(n===32256)return NaN;let r=n>>10&31,i=n&1023,a;return a=r===0?i*2**-24:r===31?i===0?1/0:NaN:(i+1024)*2**(r-25),n&32768?-a:a}function vt(e){j.setFloat32(0,e,!1)}function yt(e,t){if(e.length-t<4)throw Error(`${_} not enough data for float32`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function bt(e){j.setFloat64(0,e,!1)}function xt(e,t){if(e.length-t<8)throw Error(`${_} not enough data for float64`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}mt.compareTokens=T.compareTokens;function N(e,t,n){throw Error(`${_} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function P(e){return()=>{throw Error(`${_} ${e}`)}}const F=[];for(let e=0;e<=23;e++)F[e]=N;F[24]=pe,F[25]=me,F[26]=he,F[27]=ge,F[28]=N,F[29]=N,F[30]=N,F[31]=N;for(let e=32;e<=55;e++)F[e]=N;F[56]=_e,F[57]=ve,F[58]=ye,F[59]=Se,F[60]=N,F[61]=N,F[62]=N,F[63]=N;for(let e=64;e<=87;e++)F[e]=we;F[88]=Te,F[89]=Ee,F[90]=De,F[91]=Oe,F[92]=N,F[93]=N,F[94]=N,F[95]=P(`indefinite length bytes/strings are not supported`);for(let e=96;e<=119;e++)F[e]=Me;F[120]=Ne,F[121]=Pe,F[122]=Fe,F[123]=Ie,F[124]=N,F[125]=N,F[126]=N,F[127]=P(`indefinite length bytes/strings are not supported`);for(let e=128;e<=151;e++)F[e]=Re;F[152]=ze,F[153]=Be,F[154]=Ve,F[155]=He,F[156]=N,F[157]=N,F[158]=N,F[159]=Ue;for(let e=160;e<=183;e++)F[e]=Ge;F[184]=Ke,F[185]=qe,F[186]=Je,F[187]=Ye,F[188]=N,F[189]=N,F[190]=N,F[191]=Xe;for(let e=192;e<=215;e++)F[e]=Qe;F[216]=$e,F[217]=et,F[218]=tt,F[219]=nt,F[220]=N,F[221]=N,F[222]=N,F[223]=N;for(let e=224;e<=243;e++)F[e]=P(`simple values are not supported`);F[244]=N,F[245]=N,F[246]=N,F[247]=ct,F[248]=P(`simple values are not supported`),F[249]=dt,F[250]=ft,F[251]=pt,F[252]=N,F[253]=N,F[254]=N,F[255]=lt;const I=[];for(let e=0;e<24;e++)I[e]=new u(l.uint,e,1);for(let e=-1;e>=-24;e--)I[31-e]=new u(l.negint,e,1);I[64]=new u(l.bytes,new Uint8Array,1),I[96]=new u(l.string,``,1),I[128]=new u(l.array,0,1),I[160]=new u(l.map,0,1),I[244]=new u(l.false,!1,1),I[245]=new u(l.true,!0,1),I[246]=new u(l.null,null,1);function St(e){switch(e.type){case l.false:return g([244]);case l.true:return g([245]);case l.null:return g([246]);case l.bytes:return e.value.length?void 0:g([64]);case l.string:return e.value===``?g([96]):void 0;case l.array:return e.value===0?g([128]):void 0;case l.map:return e.value===0?g([160]):void 0;case l.uint:return e.value<24?g([Number(e.value)]):void 0;case l.negint:if(e.value>=-24)return g([31-Number(e.value)])}}const Ct={float64:!1,mapSorter:At,quickEncodeToken:St},wt=Object.freeze({float64:!0,mapSorter:jt,quickEncodeToken:St});function Tt(){let e=[];return e[l.uint.major]=T,e[l.negint.major]=Ce,e[l.bytes.major]=Ae,e[l.string.major]=Le,e[l.array.major]=We,e[l.map.major]=Ze,e[l.tag.major]=rt,e[l.float.major]=mt,e}const Et=Tt(),Dt=new de;var Ot=class e{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(t,n){if(t&&t.includes(n))throw Error(`${fe} object contains circular references`);return new e(n,t)}};const L={null:new u(l.null,null),undefined:new u(l.undefined,void 0),true:new u(l.true,!0),false:new u(l.false,!1),emptyArray:new u(l.array,0),emptyMap:new u(l.map,0)},R={number(e,t,n,r){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new u(l.float,e):e>=0?new u(l.uint,e):new u(l.negint,e)},bigint(e,t,n,r){return e>=BigInt(0)?new u(l.uint,e):new u(l.negint,e)},Uint8Array(e,t,n,r){return new u(l.bytes,e)},string(e,t,n,r){return new u(l.string,e)},boolean(e,t,n,r){return e?L.true:L.false},null(e,t,n,r){return L.null},undefined(e,t,n,r){return L.undefined},ArrayBuffer(e,t,n,r){return new u(l.bytes,new Uint8Array(e))},DataView(e,t,n,r){return new u(l.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,n,r){if(!e.length)return n.addBreakTokens===!0?[L.emptyArray,new u(l.break)]:L.emptyArray;r=Ot.createCheck(r,e);let i=[],a=0;for(let t of e)i[a++]=z(t,n,r);return n.addBreakTokens?[new u(l.array,e.length),i,new u(l.break)]:[new u(l.array,e.length),i]},Object(e,t,n,r){let i=t!==`Object`,a=i?e.keys():Object.keys(e),o=i?e.size:a.length;if(!o)return n.addBreakTokens===!0?[L.emptyMap,new u(l.break)]:L.emptyMap;r=Ot.createCheck(r,e);let s=[],c=0;for(let t of a)s[c++]=[z(t,n,r),z(i?e.get(t):e[t],n,r)];return kt(s,n),n.addBreakTokens?[new u(l.map,o),s,new u(l.break)]:[new u(l.map,o),s]}};R.Map=R.Object,R.Buffer=R.Uint8Array;for(let e of`Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64`.split(` `))R[`${e}Array`]=R.DataView;function z(e,t={},n){let r=o(e),i=t&&t.typeEncoders&&t.typeEncoders[r]||R[r];if(typeof i==`function`){let a=i(e,r,t,n);if(a!=null)return a}let a=R[r];if(!a)throw Error(`${fe} unsupported type: ${r}`);return a(e,r,t,n)}function kt(e,t){t.mapSorter&&e.sort(t.mapSorter)}function At(e,t){let n=Array.isArray(e[0])?e[0][0]:e[0],r=Array.isArray(t[0])?t[0][0]:t[0];if(n.type!==r.type)return n.type.compare(r.type);let i=Et[n.type.major].compareTokens(n,r);return i===0&&console.warn(`WARNING: complex key types used, CBOR key sorting guarantees are gone`),i}function jt(e,t){if(e[0]instanceof u&&t[0]instanceof u){let n=e[0],r=t[0];return n._keyBytes||=Mt(n.value),r._keyBytes||=Mt(r.value),ae(n._keyBytes,r._keyBytes)}throw Error(`rfc8949MapSorter: complex key types are not supported yet`)}function Mt(e){return Pt(e,Et,wt)}function Nt(e,t,n,r){if(Array.isArray(t))for(let i of t)Nt(e,i,n,r);else n[t.type.major](e,t,r)}function Pt(e,t,n){let r=z(e,n);if(!Array.isArray(r)&&n.quickEncodeToken){let e=n.quickEncodeToken(r);if(e)return e;let i=t[r.type.major];if(i.encodedSize){let e=new de(i.encodedSize(r,n));if(i(e,r,n),e.chunks.length!==1)throw Error(`Unexpected error: pre-calculated length for ${r} was wrong`);return h(e.chunks[0])}}return Dt.reset(),Nt(Dt,r,t,n),Dt.toBytes(!0)}function Ft(e,t){return t=Object.assign({},Ct,t),Pt(e,Et,t)}const It={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};var Lt=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=I[e];if(t===void 0){let n=F[e];if(!n)throw Error(`${_} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,`0`)})`);let r=e&31;t=n(this.data,this._pos,r,this.options)}return this._pos+=t.encodedLength,t}};const B=Symbol.for(`DONE`),V=Symbol.for(`BREAK`);function Rt(e,t,n){let r=[];for(let i=0;i<e.value;i++){let a=H(t,n);if(a===V){if(e.value===1/0)break;throw Error(`${_} got unexpected break to lengthed array`)}if(a===B)throw Error(`${_} found array but not enough entries (got ${i}, expected ${e.value})`);r[i]=a}return r}function zt(e,t,n){let r=n.useMaps===!0,i=r?void 0:{},a=r?new Map:void 0;for(let o=0;o<e.value;o++){let s=H(t,n);if(s===V){if(e.value===1/0)break;throw Error(`${_} got unexpected break to lengthed map`)}if(s===B)throw Error(`${_} found map but not enough entries (got ${o} [no key], expected ${e.value})`);if(r!==!0&&typeof s!=`string`)throw Error(`${_} non-string keys not supported (got ${typeof s})`);if(n.rejectDuplicateMapKeys===!0&&(r&&a.has(s)||!r&&s in i))throw Error(`${_} found repeat map key "${s}"`);let c=H(t,n);if(c===B)throw Error(`${_} found map but not enough entries (got ${o} [no value], expected ${e.value})`);r?a.set(s,c):i[s]=c}return r?a:i}function H(e,t){if(e.done())return B;let n=e.next();if(n.type===l.break)return V;if(n.type.terminal)return n.value;if(n.type===l.array)return Rt(n,e,t);if(n.type===l.map)return zt(n,e,t);if(n.type===l.tag){if(t.tags&&typeof t.tags[n.value]==`function`){let r=H(e,t);return t.tags[n.value](r)}throw Error(`${_} tag not supported (${n.value})`)}throw Error(`unsupported`)}function Bt(e,t){if(!(e instanceof Uint8Array))throw Error(`${_} data to decode must be a Uint8Array`);t=Object.assign({},It,t);let n=t.tokenizer||new Lt(e,t),r=H(n,t);if(r===B)throw Error(`${_} did not find any content to decode`);if(r===V)throw Error(`${_} got unexpected break`);return[r,e.subarray(n.pos())]}function Vt(e,t){let[n,r]=Bt(e,t);if(r.length>0)throw Error(`${_} too many terminals, data makes no sense`);return n}const Ht=new Uint8Array;function Ut(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}function Wt(e){if(e instanceof Uint8Array&&e.constructor.name===`Uint8Array`)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error(`Unknown type, must be binary type`)}function Gt(e,t){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(n[o]!==255)throw TypeError(a+` is ambiguous`);n[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError(`Expected Uint8Array`);if(t.length===0)return``;for(var n=0,r=0,i=0,a=t.length;i!==a&&t[i]===0;)i++,n++;for(var o=(a-i)*u+1>>>0,l=new Uint8Array(o);i!==a;){for(var d=t[i],f=0,p=o-1;(d!==0||f<r)&&p!==-1;p--,f++)d+=256*l[p]>>>0,l[p]=d%s>>>0,d=d/s>>>0;if(d!==0)throw Error(`Non-zero carry`);r=f,i++}for(var m=o-r;m!==o&&l[m]===0;)m++;for(var h=c.repeat(n);m<o;++m)h+=e.charAt(l[m]);return h}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return new Uint8Array;var t=0;if(e[t]!==` `){for(var r=0,i=0;e[t]===c;)r++,t++;for(var a=(e.length-t)*l+1>>>0,o=new Uint8Array(a);e[t];){var u=n[e.charCodeAt(t)];if(u===255)return;for(var d=0,f=a-1;(u!==0||d<i)&&f!==-1;f--,d++)u+=s*o[f]>>>0,o[f]=u%256>>>0,u=u/256>>>0;if(u!==0)throw Error(`Non-zero carry`);i=d,t++}if(e[t]!==` `){for(var p=a-i;p!==a&&o[p]===0;)p++;for(var m=new Uint8Array(r+(a-p)),h=r;p!==a;)m[h++]=o[p++];return m}}}function p(e){var n=f(e);if(n)return n;throw Error(`Non-${t} character`)}return{encode:d,decodeUnsafe:f,decode:p}}var Kt=Gt,qt=Kt,Jt=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error(`Unknown type, must be binary type`)}},Yt=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let r=t.codePointAt(0);if(r===void 0)throw Error(`Invalid prefix character`);this.prefixCodePoint=r,this.baseDecode=n}decode(e){if(typeof e==`string`){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error(`Can only multibase decode strings`)}or(e){return Zt(this,e)}},Xt=class{decoders;constructor(e){this.decoders=e}or(e){return Zt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Zt(e,t){return new Xt({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Qt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,r){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=r,this.encoder=new Jt(e,t,n),this.decoder=new Yt(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function $t({name:e,prefix:t,encode:n,decode:r}){return new Qt(e,t,n,r)}function U({name:e,prefix:t,alphabet:n}){let{encode:r,decode:i}=qt(n,e);return $t({prefix:t,name:e,encode:r,decode:e=>Wt(i(e))})}function en(e,t,n,r){let i=e.length;for(;e[i-1]===`=`;)--i;let a=new Uint8Array(i*n/8|0),o=0,s=0,c=0;for(let l=0;l<i;++l){let i=t[e[l]];if(i===void 0)throw SyntaxError(`Non-${r} character`);s=s<<n|i,o+=n,o>=8&&(o-=8,a[c++]=255&s>>o)}if(o>=n||255&s<<8-o)throw SyntaxError(`Unexpected end of data`);return a}function tn(e,t,n){let r=t[t.length-1]===`=`,i=(1<<n)-1,a=``,o=0,s=0;for(let r=0;r<e.length;++r)for(s=s<<8|e[r],o+=8;o>n;)o-=n,a+=t[i&s>>o];if(o!==0&&(a+=t[i&s<<n-o]),r)for(;a.length*n&7;)a+=`=`;return a}function nn(e){let t={};for(let n=0;n<e.length;++n)t[e[n]]=n;return t}function W({name:e,prefix:t,bitsPerChar:n,alphabet:r}){let i=nn(r);return $t({prefix:t,name:e,encode(e){return tn(e,r,n)},decode(t){return en(t,i,n,e)}})}const G=W({prefix:`b`,name:`base32`,alphabet:`abcdefghijklmnopqrstuvwxyz234567`,bitsPerChar:5}),rn=W({prefix:`B`,name:`base32upper`,alphabet:`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,bitsPerChar:5}),an=W({prefix:`c`,name:`base32pad`,alphabet:`abcdefghijklmnopqrstuvwxyz234567=`,bitsPerChar:5}),on=W({prefix:`C`,name:`base32padupper`,alphabet:`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=`,bitsPerChar:5}),sn=W({prefix:`v`,name:`base32hex`,alphabet:`0123456789abcdefghijklmnopqrstuv`,bitsPerChar:5}),cn=W({prefix:`V`,name:`base32hexupper`,alphabet:`0123456789ABCDEFGHIJKLMNOPQRSTUV`,bitsPerChar:5}),ln=W({prefix:`t`,name:`base32hexpad`,alphabet:`0123456789abcdefghijklmnopqrstuv=`,bitsPerChar:5}),un=W({prefix:`T`,name:`base32hexpadupper`,alphabet:`0123456789ABCDEFGHIJKLMNOPQRSTUV=`,bitsPerChar:5}),dn=W({prefix:`h`,name:`base32z`,alphabet:`ybndrfg8ejkmcpqxot1uwisza345h769`,bitsPerChar:5}),fn=U({prefix:`k`,name:`base36`,alphabet:`0123456789abcdefghijklmnopqrstuvwxyz`}),pn=U({prefix:`K`,name:`base36upper`,alphabet:`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ`}),K=U({name:`base58btc`,prefix:`z`,alphabet:`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`}),mn=U({name:`base58flickr`,prefix:`Z`,alphabet:`123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ`});var hn=yn,gn=128,_n=-128,vn=2**31;function yn(e,t,n){t||=[],n||=0;for(var r=n;e>=vn;)t[n++]=e&255|gn,e/=128;for(;e&_n;)t[n++]=e&255|gn,e>>>=7;return t[n]=e|0,yn.bytes=n-r+1,t}var bn=Cn,xn=128,Sn=127;function Cn(e,t){var n=0,t=t||0,r=0,i=t,a,o=e.length;do{if(i>=o)throw Cn.bytes=0,RangeError(`Could not decode varint`);a=e[i++],n+=r<28?(a&Sn)<<r:(a&Sn)*2**r,r+=7}while(a>=xn);return Cn.bytes=i-t,n}var wn=2**7,Tn=2**14,En=2**21,Dn=2**28,On=2**35,kn=2**42,An=2**49,jn=2**56,Mn=2**63,Nn=function(e){return e<wn?1:e<Tn?2:e<En?3:e<Dn?4:e<On?5:e<kn?6:e<An?7:e<jn?8:e<Mn?9:10},Pn={encode:hn,decode:bn,encodingLength:Nn},q=Pn;function Fn(e,t=0){return[q.decode(e,t),q.decode.bytes]}function J(e,t,n=0){return q.encode(e,t,n),t}function In(e){return q.encodingLength(e)}function Ln(e,t){let n=t.byteLength,r=In(e),i=r+In(n),a=new Uint8Array(i+n);return J(e,a,0),J(n,a,r),a.set(t,i),new Bn(e,n,t,a)}function Rn(e){let t=Wt(e),[n,r]=Fn(t),[i,a]=Fn(t.subarray(r)),o=t.subarray(r+a);if(o.byteLength!==i)throw Error(`Incorrect length`);return new Bn(n,i,o,t)}function zn(e,t){if(e===t)return!0;{let n=t;return e.code===n.code&&e.size===n.size&&n.bytes instanceof Uint8Array&&Ut(e.bytes,n.bytes)}}var Bn=class{code;size;digest;bytes;constructor(e,t,n,r){this.code=e,this.size=t,this.digest=n,this.bytes=r}};function Vn(e,t){let{bytes:n,version:r}=e;switch(r){case 0:return Kn(n,Un(e),t??K.encoder);default:return qn(n,Un(e),t??G.encoder)}}const Hn=new WeakMap;function Un(e){let t=Hn.get(e);if(t==null){let t=new Map;return Hn.set(e,t),t}return t}var Wn=class e{code;version;multihash;bytes;"/";constructor(e,t,n,r){this.code=t,this.version=e,this.multihash=n,this.bytes=r,this[`/`]=r}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:n}=this;if(t!==Y)throw Error(`Cannot convert a non dag-pb CID to CIDv0`);if(n.code!==Jn)throw Error(`Cannot convert non sha2-256 multihash CID to CIDv0`);return e.createV0(n)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:n}=this.multihash,r=Ln(t,n);return e.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&zn(e.multihash,n.multihash)}toString(e){return Vn(this,e)}toJSON(){return{"/":Vn(this)}}link(){return this}[Symbol.toStringTag]=`CID`;[Symbol.for(`nodejs.util.inspect.custom`)](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let n=t;if(n instanceof e)return n;if(n[`/`]!=null&&n[`/`]===n.bytes||n.asCID===n){let{version:t,code:r,multihash:i,bytes:a}=n;return new e(t,r,i,a??Yn(t,r,i.bytes))}else if(n[Xn]===!0){let{version:t,multihash:r,code:i}=n,a=Rn(r);return e.create(t,i,a)}else return null}static create(t,n,r){if(typeof n!=`number`)throw Error(`String codecs are no longer supported`);if(!(r.bytes instanceof Uint8Array))throw Error(`Invalid digest`);switch(t){case 0:if(n!==Y)throw Error(`Version 0 CID must use dag-pb (code: ${Y}) block encoding`);return new e(t,n,r,r.bytes);case 1:return new e(t,n,r,Yn(t,n,r.bytes));default:throw Error(`Invalid version`)}}static createV0(t){return e.create(0,Y,t)}static createV1(t,n){return e.create(1,t,n)}static decode(t){let[n,r]=e.decodeFirst(t);if(r.length!==0)throw Error(`Incorrect length`);return n}static decodeFirst(t){let n=e.inspectBytes(t),r=n.size-n.multihashSize,i=Wt(t.subarray(r,r+n.multihashSize));if(i.byteLength!==n.multihashSize)throw Error(`Incorrect length`);let a=i.subarray(n.multihashSize-n.digestSize),o=new Bn(n.multihashCode,n.digestSize,a,i);return[n.version===0?e.createV0(o):e.createV1(n.codec,o),t.subarray(n.size)]}static inspectBytes(e){let t=0,n=()=>{let[n,r]=Fn(e.subarray(t));return t+=r,n},r=n(),i=Y;if(r===18?(r=0,t=0):i=n(),r!==0&&r!==1)throw RangeError(`Invalid CID version ${r}`);let a=t,o=n(),s=n(),c=t+s,l=c-a;return{version:r,codec:i,multihashCode:o,digestSize:s,multihashSize:l,size:c}}static parse(t,n){let[r,i]=Gn(t,n),a=e.decode(i);if(a.version===0&&t[0]!==`Q`)throw Error(`Version 0 CID string must not include multibase prefix`);return Un(a).set(r,t),a}};function Gn(e,t){switch(e[0]){case`Q`:{let n=t??K;return[K.prefix,n.decode(`${K.prefix}${e}`)]}case K.prefix:{let n=t??K;return[K.prefix,n.decode(e)]}case G.prefix:{let n=t??G;return[G.prefix,n.decode(e)]}case fn.prefix:{let n=t??fn;return[fn.prefix,n.decode(e)]}default:if(t==null)throw Error(`To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided`);return[e[0],t.decode(e)]}}function Kn(e,t,n){let{prefix:r}=n;if(r!==K.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let i=t.get(r);if(i==null){let i=n.encode(e).slice(1);return t.set(r,i),i}else return i}function qn(e,t,n){let{prefix:r}=n,i=t.get(r);if(i==null){let i=n.encode(e);return t.set(r,i),i}else return i}const Y=112,Jn=18;function Yn(e,t,n){let r=In(e),i=r+In(t),a=new Uint8Array(i+n.byteLength);return J(e,a,0),J(t,a,r),a.set(n,i),a}const Xn=Symbol.for(`@ipld/js-cid/CID`),Zn=42;function Qn(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function $n(e){if(e.asCID!==e&&e[`/`]!==e.bytes)return null;let t=Wn.asCID(e);if(!t)return null;let n=new Uint8Array(t.bytes.byteLength+1);return n.set(t.bytes,1),[new u(l.tag,42),new u(l.bytes,n)]}function er(){throw Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function tr(e){if(Number.isNaN(e))throw Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}function nr(e){for(let t of e.keys())if(typeof t!=`string`||t.length===0)throw Error(`Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded`);return null}const rr={float64:!0,typeEncoders:{Map:nr,Object:$n,undefined:er,number:tr}},ir={...rr,typeEncoders:{...rr.typeEncoders}};function ar(e){if(e[0]!==0)throw Error(`Invalid CID for CBOR tag 42; expected leading 0x00`);return Wn.decode(e.subarray(1))}const or={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};or.tags[42]=ar;const sr={...or,tags:or.tags.slice()},cr=e=>Ft(e,rr),lr=e=>Vt(Qn(e),or);function ur(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var dr,X,fr,pr;let Z=dr=class extends n.ccc.mol.Entity.Base(){constructor(e,t){super(),this.document=e,this.localId=t}static from(e){return e instanceof dr?e:new dr(e.document,e.localId??void 0)}};Z=dr=ur([n.ccc.mol.codec(n.ccc.mol.table({document:n.ccc.mol.Bytes,localId:n.ccc.mol.StringOpt}).map({inMap:e=>({...e,document:n.ccc.hexFrom(cr(e.document))}),outMap:e=>({...e,document:lr(n.ccc.bytesFrom(e.document))})}))],Z);let Q=X=class extends n.ccc.mol.Entity.Base(){constructor(e,t){super(),this.type=e,this.value=t}static from(e){return e instanceof X?e:new X(e.type??`v1`,Z.from(e.value))}static fromV1(e){return new X(`v1`,Z.from(e))}};Q=X=ur([n.ccc.mol.codec(n.ccc.mol.union({v1:Z}))],Q);let $=fr=class extends n.ccc.mol.Entity.Base(){constructor(e,t,n){super(),this.history=e,this.sig=t,this.rotationKeyIndices=n}static from(e){return e instanceof fr?e:new fr(e.history,n.ccc.hexFrom(e.sig),e.rotationKeyIndices.map(n.ccc.numFrom))}};$=fr=ur([n.ccc.mol.codec(n.ccc.mol.table({history:n.ccc.mol.BytesVec,sig:n.ccc.mol.Bytes,rotationKeyIndices:n.ccc.mol.Uint8Vec}).map({inMap:e=>({...e,history:e.history.map(e=>n.ccc.hexFrom(cr(e)))}),outMap:e=>({...e,history:e.history.map(e=>lr(n.ccc.bytesFrom(e)))})}))],$);let mr=pr=class extends n.ccc.mol.Entity.Base(){constructor(e){super(),this.localIdAuthorization=e}static from(e){return e instanceof pr?e:new pr($.from(e.localIdAuthorization))}};mr=pr=ur([n.ccc.mol.codec(n.ccc.mol.table({localIdAuthorization:$}))],mr);const hr=r.typeIdA.buildTypeIdOperations({async getScriptInfo(e){return e.getKnownScript(n.ccc.KnownScript.DidCkb)}}),{transfer:gr,destroy:_r}=hr;function vr({signer:e,data:t,receiver:n,tx:r}){return hr.create({signer:e,data:Q.from(t).toBytes(),receiver:n,tx:r})}var yr=t({DidCkbData:()=>Q,DidCkbDataV1:()=>Z,DidCkbWitness:()=>mr,PlcAuthorization:()=>$,createDidCkb:()=>vr,destroyDidCkb:()=>_r,transferDidCkb:()=>gr});Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return gr}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return vr}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return _r}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return mr}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return yr}});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/codec.d.ts
|
|
6
|
+
type DidCkbDataV1Like = {
|
|
7
|
+
document: object;
|
|
8
|
+
localId?: string | null;
|
|
9
|
+
};
|
|
10
|
+
declare const DidCkbDataV1_base: (abstract new () => {
|
|
11
|
+
toBytes(): ccc.Bytes;
|
|
12
|
+
clone(): DidCkbDataV1;
|
|
13
|
+
eq(other: DidCkbDataV1Like): boolean;
|
|
14
|
+
hash(): ccc.Hex;
|
|
15
|
+
}) & {
|
|
16
|
+
byteLength?: number;
|
|
17
|
+
encode(_: DidCkbDataV1Like): ccc.Bytes;
|
|
18
|
+
decode(_: ccc.BytesLike): DidCkbDataV1;
|
|
19
|
+
fromBytes(_bytes: ccc.BytesLike): DidCkbDataV1;
|
|
20
|
+
from(_: DidCkbDataV1Like): DidCkbDataV1;
|
|
21
|
+
};
|
|
22
|
+
declare class DidCkbDataV1 extends DidCkbDataV1_base {
|
|
23
|
+
document: object;
|
|
24
|
+
localId?: string | undefined;
|
|
25
|
+
constructor(document: object, localId?: string | undefined);
|
|
26
|
+
static from(data: DidCkbDataV1Like): DidCkbDataV1;
|
|
27
|
+
}
|
|
28
|
+
type DidCkbDataLike = {
|
|
29
|
+
type?: "v1" | null;
|
|
30
|
+
value: DidCkbDataV1Like;
|
|
31
|
+
};
|
|
32
|
+
declare const DidCkbData_base: (abstract new () => {
|
|
33
|
+
toBytes(): ccc.Bytes;
|
|
34
|
+
clone(): DidCkbData;
|
|
35
|
+
eq(other: DidCkbDataLike): boolean;
|
|
36
|
+
hash(): ccc.Hex;
|
|
37
|
+
}) & {
|
|
38
|
+
byteLength?: number;
|
|
39
|
+
encode(_: DidCkbDataLike): ccc.Bytes;
|
|
40
|
+
decode(_: ccc.BytesLike): DidCkbData;
|
|
41
|
+
fromBytes(_bytes: ccc.BytesLike): DidCkbData;
|
|
42
|
+
from(_: DidCkbDataLike): DidCkbData;
|
|
43
|
+
};
|
|
44
|
+
declare class DidCkbData extends DidCkbData_base {
|
|
45
|
+
type: "v1";
|
|
46
|
+
value: DidCkbDataV1;
|
|
47
|
+
constructor(type: "v1", value: DidCkbDataV1);
|
|
48
|
+
static from(data: DidCkbDataLike): DidCkbData;
|
|
49
|
+
static fromV1(data: DidCkbDataV1Like): DidCkbData & {
|
|
50
|
+
type: "v1";
|
|
51
|
+
value: DidCkbDataV1;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
type PlcAuthorizationLike = {
|
|
55
|
+
history: object[];
|
|
56
|
+
sig: ccc.HexLike;
|
|
57
|
+
rotationKeyIndices: ccc.NumLike[];
|
|
58
|
+
};
|
|
59
|
+
declare const PlcAuthorization_base: (abstract new () => {
|
|
60
|
+
toBytes(): ccc.Bytes;
|
|
61
|
+
clone(): PlcAuthorization;
|
|
62
|
+
eq(other: PlcAuthorizationLike): boolean;
|
|
63
|
+
hash(): ccc.Hex;
|
|
64
|
+
}) & {
|
|
65
|
+
byteLength?: number;
|
|
66
|
+
encode(_: PlcAuthorizationLike): ccc.Bytes;
|
|
67
|
+
decode(_: ccc.BytesLike): PlcAuthorization;
|
|
68
|
+
fromBytes(_bytes: ccc.BytesLike): PlcAuthorization;
|
|
69
|
+
from(_: PlcAuthorizationLike): PlcAuthorization;
|
|
70
|
+
};
|
|
71
|
+
declare class PlcAuthorization extends PlcAuthorization_base {
|
|
72
|
+
history: object[];
|
|
73
|
+
sig: ccc.Hex;
|
|
74
|
+
rotationKeyIndices: ccc.Num[];
|
|
75
|
+
constructor(history: object[], sig: ccc.Hex, rotationKeyIndices: ccc.Num[]);
|
|
76
|
+
static from(data: PlcAuthorizationLike): PlcAuthorization;
|
|
77
|
+
}
|
|
78
|
+
type DidCkbWitnessLike = {
|
|
79
|
+
localIdAuthorization: PlcAuthorizationLike;
|
|
80
|
+
};
|
|
81
|
+
declare const DidCkbWitness_base: (abstract new () => {
|
|
82
|
+
toBytes(): ccc.Bytes;
|
|
83
|
+
clone(): DidCkbWitness;
|
|
84
|
+
eq(other: DidCkbWitnessLike): boolean;
|
|
85
|
+
hash(): ccc.Hex;
|
|
86
|
+
}) & {
|
|
87
|
+
byteLength?: number;
|
|
88
|
+
encode(_: DidCkbWitnessLike): ccc.Bytes;
|
|
89
|
+
decode(_: ccc.BytesLike): DidCkbWitness;
|
|
90
|
+
fromBytes(_bytes: ccc.BytesLike): DidCkbWitness;
|
|
91
|
+
from(_: DidCkbWitnessLike): DidCkbWitness;
|
|
92
|
+
};
|
|
93
|
+
declare class DidCkbWitness extends DidCkbWitness_base {
|
|
94
|
+
localIdAuthorization: PlcAuthorization;
|
|
95
|
+
constructor(localIdAuthorization: PlcAuthorization);
|
|
96
|
+
static from(data: DidCkbWitnessLike): DidCkbWitness;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/didCkb.d.ts
|
|
100
|
+
declare const transferDidCkb: (this: void, {
|
|
101
|
+
client,
|
|
102
|
+
id,
|
|
103
|
+
receiver,
|
|
104
|
+
tx: txLike
|
|
105
|
+
}: {
|
|
106
|
+
client: ccc.Client;
|
|
107
|
+
id: ccc.HexLike;
|
|
108
|
+
receiver: ccc.ScriptLike;
|
|
109
|
+
tx?: ccc.TransactionLike | null;
|
|
110
|
+
}) => Promise<{
|
|
111
|
+
tx: ccc.Transaction;
|
|
112
|
+
inIndex: number;
|
|
113
|
+
outIndex: number;
|
|
114
|
+
}>, destroyDidCkb: (this: void, {
|
|
115
|
+
client,
|
|
116
|
+
id,
|
|
117
|
+
tx: txLike
|
|
118
|
+
}: {
|
|
119
|
+
client: ccc.Client;
|
|
120
|
+
id: ccc.HexLike;
|
|
121
|
+
tx?: ccc.TransactionLike | null;
|
|
122
|
+
}) => Promise<{
|
|
123
|
+
tx: ccc.Transaction;
|
|
124
|
+
index: number;
|
|
125
|
+
}>;
|
|
126
|
+
declare function createDidCkb({
|
|
127
|
+
signer,
|
|
128
|
+
data,
|
|
129
|
+
receiver,
|
|
130
|
+
tx: txLike
|
|
131
|
+
}: {
|
|
132
|
+
signer: ccc.Signer;
|
|
133
|
+
data: DidCkbDataLike;
|
|
134
|
+
receiver?: ccc.ScriptLike | null;
|
|
135
|
+
tx?: ccc.TransactionLike | null;
|
|
136
|
+
}): Promise<{
|
|
137
|
+
tx: ccc.Transaction;
|
|
138
|
+
id: ccc.Hex;
|
|
139
|
+
index: number;
|
|
140
|
+
}>;
|
|
141
|
+
declare namespace barrel_d_exports {
|
|
142
|
+
export { DidCkbData, DidCkbDataLike, DidCkbDataV1, DidCkbDataV1Like, DidCkbWitness, DidCkbWitnessLike, PlcAuthorization, PlcAuthorizationLike, createDidCkb, destroyDidCkb, transferDidCkb };
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { DidCkbData as a, DidCkbDataV1Like as c, PlcAuthorization as d, PlcAuthorizationLike as f, transferDidCkb as i, DidCkbWitness as l, createDidCkb as n, DidCkbDataLike as o, destroyDidCkb as r, DidCkbDataV1 as s, barrel_d_exports as t, DidCkbWitnessLike as u };
|
|
146
|
+
//# sourceMappingURL=barrel-D5mx-XKy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel-D5mx-XKy.d.ts","names":[],"sources":["../src/codec.ts","../src/didCkb.ts","../src/barrel.ts"],"sourcesContent":[],"mappings":";;;;;KAGY,gBAAA;;;;cAGV;;;;;;;;;;;;cAkBW,YAAA,SAAqB,iBAAA;;;EArBtB,WAAA,CAAA,QAAgB,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAG1B,OAAA,IAAA,CAAA,IAAA,EA6BkB,gBA7BlB,CAAA,EA6BqC,YA7BrC;;KAsCU,cAAA;;SAEH;;cACP;;;;;;;;EAvBW,MAAA,CAAA,CAAA,eAAa,CAAA,YAAA;EAWN,SAAA,CAAA,MAAA,eAAA,CAAA,YAAA;EAAmB,IAAA,CAAA,CAAA,gBAAA,CAAA,YAAA;CAXL;AAG/B,cA0BU,UAAA,SAAmB,eAAA,CA1B7B;EAiBS,IAAA,EAAA,IAAA;EAGV,KAAA,EAYgB,YAZhB;iCAYgB;oBAKE,iBAAiB;sBAQ3B,mBACL;;WAAkC;;;KAK3B,oBAAA;;OAEL,GAAA,CAAI;sBACW,GAAA,CAAI;;cACxB;EA7BW,OAAA,EAAA,WAAW;EAMN,KAAA,EAAA,kBAAA;EAAA,EAAA,CAAA,KAAA,sBAAA,CAAA,EAAA,OAAA;EAKE,IAAA,EAAA,SAAA;CAAiB,CAAA,GAAA;EAQ3B,UAAA,CAAA,EAAA,MAAA;EACL,MAAA,CAAA,CAAA,sBAAA,CAAA,WAAA;EAAkC,MAAA,CAAA,CAAA,eAAA,CAAA,kBAAA;EApBP,SAAA,CAAA,MAAA,eAAA,CAAA,kBAAA;EAG7B,IAAA,CAAA,CAAA,sBAAA,CAAA,kBAAA;AAsBH,CAAA;AAIE,cAoBW,gBAAA,SAAyB,qBAAA,CApBpC;;OA0Bc,GAAA,CAAI;sBACW,GAAA,CAAI;sCADnB,GAAA,CAAI,yBACW,GAAA,CAAI;oBAKf,uBAAuB;;KAY/B,iBAAA;wBACY;;cACtB;;;;EA1BW,IAAA,EAAA,SAAA;CAMG,CAAA,GAAI;EACW,UAAI,CAAA,EAAA,MAAA;EADnB,MAAI,CAAA,CAAA,mBAAA,CAAA,WAAA;EACW,MAAI,CAAA,CAAA,eAAA,CAAA,eAAA;EAKf,SAAA,CAAA,MAAA,eAAA,CAAA,eAAA;EAAuB,IAAA,CAAA,CAAA,mBAAA,CAAA,eAAA;CAZL;AAGnC,cA6BU,aAAA,SAAsB,kBAAA,CA7BhC;EAqBS,oBAAiB,EAYc,gBAXnB;EACtB,WAAA,CAAA,oBAAA,EAUyC,gBAVzC;oBAckB,oBAAoB;;;;cCpIf;;;;QAAc;;;;;SAoBiF,GAAA,CAAA;;;;;;;;QApBzD;;;;SAoBuS,GAAA,CAAA;;;;;iBAlBtV,YAAA;;;;MAIV;;EDbM,MAAA,ECeF,GAAA,CAAI,MDfF;EAGV,IAAA,ECaM,cDbN;aCcW,GAAA,CAAI;OACV,GAAA,CAAI;IACV"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DidCkbData, c as DidCkbDataV1Like, d as PlcAuthorization, f as PlcAuthorizationLike, i as transferDidCkb, l as DidCkbWitness, n as createDidCkb, o as DidCkbDataLike, r as destroyDidCkb, s as DidCkbDataV1, u as DidCkbWitnessLike } from "./barrel-D5mx-XKy.js";
|
|
2
|
+
export { DidCkbData, DidCkbDataLike, DidCkbDataV1, DidCkbDataV1Like, DidCkbWitness, DidCkbWitnessLike, PlcAuthorization, PlcAuthorizationLike, createDidCkb, destroyDidCkb, transferDidCkb };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./barrel-3QHu103S.js`);Object.defineProperty(exports,`DidCkbData`,{enumerable:!0,get:function(){return e.a}}),Object.defineProperty(exports,`DidCkbDataV1`,{enumerable:!0,get:function(){return e.o}}),Object.defineProperty(exports,`DidCkbWitness`,{enumerable:!0,get:function(){return e.s}}),Object.defineProperty(exports,`PlcAuthorization`,{enumerable:!0,get:function(){return e.c}}),exports.createDidCkb=e.n,exports.destroyDidCkb=e.r,exports.transferDidCkb=e.i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./barrel-3QHu103S.js`);Object.defineProperty(exports,`didCkb`,{enumerable:!0,get:function(){return e.t}});
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ckb-ccc/did-ckb",
|
|
3
|
+
"version": "0.0.0-canary-20260106175902",
|
|
4
|
+
"description": "CCC - CKBer's Codebase. CCC's support for DID on CKB",
|
|
5
|
+
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"private": false,
|
|
8
|
+
"homepage": "https://github.com/ckb-devrel/ccc",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git://github.com/ckb-devrel/ccc.git"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist.commonjs/index.js",
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"require": "./dist.commonjs/index.js",
|
|
18
|
+
"import": "./dist/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"./barrel": {
|
|
21
|
+
"require": "./dist.commonjs/barrel.js",
|
|
22
|
+
"import": "./dist/barrel.mjs"
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@eslint/js": "^9.34.0",
|
|
28
|
+
"@types/node": "^24.3.0",
|
|
29
|
+
"eslint": "^9.34.0",
|
|
30
|
+
"eslint-config-prettier": "^10.1.8",
|
|
31
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
32
|
+
"prettier": "^3.6.2",
|
|
33
|
+
"prettier-plugin-organize-imports": "^4.2.0",
|
|
34
|
+
"tsdown": "0.19.0-beta.3",
|
|
35
|
+
"typescript": "^5.9.2",
|
|
36
|
+
"typescript-eslint": "^8.41.0"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@ipld/dag-cbor": "^9.2.5",
|
|
43
|
+
"@ckb-ccc/core": "0.0.0-canary-20260106175902",
|
|
44
|
+
"@ckb-ccc/type-id": "0.0.0-canary-20260106175902"
|
|
45
|
+
},
|
|
46
|
+
"types": "./dist.commonjs/index.d.ts",
|
|
47
|
+
"scripts": {
|
|
48
|
+
"test": "jest",
|
|
49
|
+
"build": "tsdown",
|
|
50
|
+
"lint": "eslint ./src",
|
|
51
|
+
"format": "prettier --write . && eslint --fix ./src"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://prettier.io/docs/configuration
|
|
3
|
+
* @type {import("prettier").Config}
|
|
4
|
+
*/
|
|
5
|
+
const config = {
|
|
6
|
+
singleQuote: false,
|
|
7
|
+
trailingComma: "all",
|
|
8
|
+
plugins: [require.resolve("prettier-plugin-organize-imports")],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
module.exports = config;
|
package/src/barrel.ts
ADDED
package/src/codec.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
|
|
3
|
+
|
|
4
|
+
export type DidCkbDataV1Like = {
|
|
5
|
+
document: object;
|
|
6
|
+
localId?: string | null;
|
|
7
|
+
};
|
|
8
|
+
@ccc.mol.codec(
|
|
9
|
+
ccc.mol
|
|
10
|
+
.table({
|
|
11
|
+
document: ccc.mol.Bytes,
|
|
12
|
+
localId: ccc.mol.StringOpt,
|
|
13
|
+
})
|
|
14
|
+
.map({
|
|
15
|
+
inMap: (data: DidCkbDataV1Like) => ({
|
|
16
|
+
...data,
|
|
17
|
+
document: ccc.hexFrom(cborEncode(data.document)),
|
|
18
|
+
}),
|
|
19
|
+
outMap: (data) => ({
|
|
20
|
+
...data,
|
|
21
|
+
document: cborDecode<object>(ccc.bytesFrom(data.document)),
|
|
22
|
+
}),
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
25
|
+
export class DidCkbDataV1 extends ccc.mol.Entity.Base<
|
|
26
|
+
DidCkbDataV1Like,
|
|
27
|
+
DidCkbDataV1
|
|
28
|
+
>() {
|
|
29
|
+
constructor(
|
|
30
|
+
public document: object,
|
|
31
|
+
public localId?: string,
|
|
32
|
+
) {
|
|
33
|
+
super();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static from(data: DidCkbDataV1Like): DidCkbDataV1 {
|
|
37
|
+
if (data instanceof DidCkbDataV1) {
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return new DidCkbDataV1(data.document, data.localId ?? undefined);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type DidCkbDataLike = {
|
|
46
|
+
type?: "v1" | null;
|
|
47
|
+
value: DidCkbDataV1Like;
|
|
48
|
+
};
|
|
49
|
+
@ccc.mol.codec(
|
|
50
|
+
ccc.mol.union({
|
|
51
|
+
v1: DidCkbDataV1,
|
|
52
|
+
}),
|
|
53
|
+
)
|
|
54
|
+
export class DidCkbData extends ccc.mol.Entity.Base<
|
|
55
|
+
DidCkbDataLike,
|
|
56
|
+
DidCkbData
|
|
57
|
+
>() {
|
|
58
|
+
constructor(
|
|
59
|
+
public type: "v1",
|
|
60
|
+
public value: DidCkbDataV1,
|
|
61
|
+
) {
|
|
62
|
+
super();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static from(data: DidCkbDataLike): DidCkbData {
|
|
66
|
+
if (data instanceof DidCkbData) {
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
69
|
+
return new DidCkbData(data.type ?? "v1", DidCkbDataV1.from(data.value));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static fromV1(
|
|
73
|
+
data: DidCkbDataV1Like,
|
|
74
|
+
): DidCkbData & { type: "v1"; value: DidCkbDataV1 } {
|
|
75
|
+
return new DidCkbData("v1", DidCkbDataV1.from(data));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type PlcAuthorizationLike = {
|
|
80
|
+
history: object[];
|
|
81
|
+
sig: ccc.HexLike;
|
|
82
|
+
rotationKeyIndices: ccc.NumLike[];
|
|
83
|
+
};
|
|
84
|
+
@ccc.mol.codec(
|
|
85
|
+
ccc.mol
|
|
86
|
+
.table({
|
|
87
|
+
history: ccc.mol.BytesVec,
|
|
88
|
+
sig: ccc.mol.Bytes,
|
|
89
|
+
rotationKeyIndices: ccc.mol.Uint8Vec,
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
.map({
|
|
93
|
+
inMap: (data: PlcAuthorizationLike) => ({
|
|
94
|
+
...data,
|
|
95
|
+
history: data.history.map((h) => ccc.hexFrom(cborEncode(h))),
|
|
96
|
+
}),
|
|
97
|
+
outMap: (data) => ({
|
|
98
|
+
...data,
|
|
99
|
+
history: data.history.map((h) => cborDecode<object>(ccc.bytesFrom(h))),
|
|
100
|
+
}),
|
|
101
|
+
}),
|
|
102
|
+
)
|
|
103
|
+
export class PlcAuthorization extends ccc.mol.Entity.Base<
|
|
104
|
+
PlcAuthorizationLike,
|
|
105
|
+
PlcAuthorization
|
|
106
|
+
>() {
|
|
107
|
+
constructor(
|
|
108
|
+
public history: object[],
|
|
109
|
+
public sig: ccc.Hex,
|
|
110
|
+
public rotationKeyIndices: ccc.Num[],
|
|
111
|
+
) {
|
|
112
|
+
super();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static from(data: PlcAuthorizationLike): PlcAuthorization {
|
|
116
|
+
if (data instanceof PlcAuthorization) {
|
|
117
|
+
return data;
|
|
118
|
+
}
|
|
119
|
+
return new PlcAuthorization(
|
|
120
|
+
data.history,
|
|
121
|
+
ccc.hexFrom(data.sig),
|
|
122
|
+
data.rotationKeyIndices.map(ccc.numFrom),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type DidCkbWitnessLike = {
|
|
128
|
+
localIdAuthorization: PlcAuthorizationLike;
|
|
129
|
+
};
|
|
130
|
+
@ccc.mol.codec(
|
|
131
|
+
ccc.mol.table({
|
|
132
|
+
localIdAuthorization: PlcAuthorization,
|
|
133
|
+
}),
|
|
134
|
+
)
|
|
135
|
+
export class DidCkbWitness extends ccc.mol.Entity.Base<
|
|
136
|
+
DidCkbWitnessLike,
|
|
137
|
+
DidCkbWitness
|
|
138
|
+
>() {
|
|
139
|
+
constructor(public localIdAuthorization: PlcAuthorization) {
|
|
140
|
+
super();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static from(data: DidCkbWitnessLike): DidCkbWitness {
|
|
144
|
+
if (data instanceof DidCkbWitness) {
|
|
145
|
+
return data;
|
|
146
|
+
}
|
|
147
|
+
return new DidCkbWitness(PlcAuthorization.from(data.localIdAuthorization));
|
|
148
|
+
}
|
|
149
|
+
}
|
package/src/didCkb.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { typeIdA } from "@ckb-ccc/type-id/advanced";
|
|
3
|
+
import { DidCkbData, DidCkbDataLike } from "./codec";
|
|
4
|
+
|
|
5
|
+
const OPERATIONS = typeIdA.buildTypeIdOperations({
|
|
6
|
+
async getScriptInfo(client: ccc.Client): Promise<ccc.ScriptInfo> {
|
|
7
|
+
return client.getKnownScript(ccc.KnownScript.DidCkb);
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const { transfer: transferDidCkb, destroy: destroyDidCkb } = OPERATIONS;
|
|
12
|
+
|
|
13
|
+
export function createDidCkb({
|
|
14
|
+
signer,
|
|
15
|
+
data,
|
|
16
|
+
receiver,
|
|
17
|
+
tx: txLike,
|
|
18
|
+
}: {
|
|
19
|
+
signer: ccc.Signer;
|
|
20
|
+
data: DidCkbDataLike;
|
|
21
|
+
receiver?: ccc.ScriptLike | null;
|
|
22
|
+
tx?: ccc.TransactionLike | null;
|
|
23
|
+
}) {
|
|
24
|
+
return OPERATIONS.create({
|
|
25
|
+
signer,
|
|
26
|
+
data: DidCkbData.from(data).toBytes(),
|
|
27
|
+
receiver,
|
|
28
|
+
tx: txLike,
|
|
29
|
+
});
|
|
30
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as didCkb from "./barrel.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
|
|
3
|
+
const common = {
|
|
4
|
+
minify: true,
|
|
5
|
+
dts: true,
|
|
6
|
+
platform: "neutral" as const,
|
|
7
|
+
exports: true,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default defineConfig(
|
|
11
|
+
(
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
entry: {
|
|
15
|
+
index: "src/index.ts",
|
|
16
|
+
barrel: "src/barrel.ts",
|
|
17
|
+
},
|
|
18
|
+
format: "esm",
|
|
19
|
+
copy: "./misc/basedirs/dist/*",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
entry: {
|
|
23
|
+
index: "src/index.ts",
|
|
24
|
+
barrel: "src/barrel.ts",
|
|
25
|
+
},
|
|
26
|
+
noExternal: ["@ipld/dag-cbor"] as string[],
|
|
27
|
+
format: "cjs",
|
|
28
|
+
outDir: "dist.commonjs",
|
|
29
|
+
copy: "./misc/basedirs/dist.commonjs/*",
|
|
30
|
+
},
|
|
31
|
+
] as const
|
|
32
|
+
).map((c) => ({ ...c, ...common })),
|
|
33
|
+
);
|