@ckb-ccc/did-ckb 0.2.14 → 0.2.16
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 +17 -0
- package/dist/barrel-BYdcNWd1.d.mts +431 -0
- package/dist/barrel-BYdcNWd1.d.mts.map +1 -0
- package/dist/barrel-CRigE_Kq.mjs +2 -0
- package/dist/barrel-CRigE_Kq.mjs.map +1 -0
- package/dist/barrel.d.mts +3 -440
- package/dist/barrel.mjs +1 -1
- package/{dist.commonjs/index-DbyAhugH.d.ts → dist/index-C0QY5P5_.d.mts} +2 -3
- package/dist/{index-PkKhX08A.d.mts.map → index-C0QY5P5_.d.mts.map} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/plc-CAHX4f5y.mjs +2 -0
- package/dist/plc-CAHX4f5y.mjs.map +1 -0
- package/dist/plc.d.mts +1 -1
- package/dist/plc.mjs +1 -2
- package/dist/rolldown-runtime-P3Pd_6ND.mjs +1 -0
- package/dist.commonjs/barrel-9fYvfkI1.d.ts +431 -0
- package/dist.commonjs/barrel-9fYvfkI1.d.ts.map +1 -0
- package/dist.commonjs/barrel-BWApUcdp.js +6 -0
- package/dist.commonjs/barrel-BWApUcdp.js.map +1 -0
- package/dist.commonjs/barrel.d.ts +3 -440
- package/dist.commonjs/barrel.js +1 -1
- package/{dist/index-PkKhX08A.d.mts → dist.commonjs/index-C0QY5P5_.d.ts} +1 -2
- package/dist.commonjs/{index-DbyAhugH.d.ts.map → index-C0QY5P5_.d.ts.map} +1 -1
- package/dist.commonjs/index.d.ts +2 -2
- package/dist.commonjs/index.js +1 -1
- package/dist.commonjs/plc-DMi9GhTp.js +2 -0
- package/dist.commonjs/{plc.js.map → plc-DMi9GhTp.js.map} +1 -1
- package/dist.commonjs/plc.d.ts +1 -1
- package/dist.commonjs/plc.js +1 -2
- package/package.json +3 -3
- package/src/history.ts +4 -8
- package/dist/barrel-DEJnxd4o.mjs +0 -2
- package/dist/barrel-DEJnxd4o.mjs.map +0 -1
- package/dist/barrel.d.mts.map +0 -1
- package/dist/plc.mjs.map +0 -1
- package/dist/rolldown-runtime-DK3Fl9T5.mjs +0 -1
- package/dist.commonjs/barrel-C62ZxemC.js +0 -2
- package/dist.commonjs/barrel-C62ZxemC.js.map +0 -1
- package/dist.commonjs/barrel.d.ts.map +0 -1
- package/dist.commonjs/rolldown-runtime-BIInC43l.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ckb-ccc/did-ckb
|
|
2
2
|
|
|
3
|
+
## 0.2.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#608](https://github.com/ckb-devrel/ccc/pull/608) [`0abf78e`](https://github.com/ckb-devrel/ccc/commit/0abf78e5f469216e82a24de8d4051e757368af90) Thanks [@Hanssen0-Alter-Ego](https://github.com/Hanssen0-Alter-Ego)! - Propagate input cell lookup failures in `getDidCkbHistory` instead of misclassifying updates as CREATE or MIGRATE and silently truncating history.
|
|
8
|
+
- Updated dependencies [[`153844d`](https://github.com/ckb-devrel/ccc/commit/153844d4b7a542b0389b6a58a8e52c7c36433296), [`df37b27`](https://github.com/ckb-devrel/ccc/commit/df37b2778c5b2172e2344ccdd74e7f9f5e20ea43), [`f60bb74`](https://github.com/ckb-devrel/ccc/commit/f60bb7441bf8f01fc62065df767815dee920e24e), [`b1771d8`](https://github.com/ckb-devrel/ccc/commit/b1771d8ab57df4e748202cec4794b1e9daf2fc7c), [`b827462`](https://github.com/ckb-devrel/ccc/commit/b827462aebba537f2785d6a4abb506954189f96e), [`0337906`](https://github.com/ckb-devrel/ccc/commit/0337906cdb6925f6ec46b1a4c643bb8cb042487c), [`917545b`](https://github.com/ckb-devrel/ccc/commit/917545b0479e22d41a95690ce4d0578776e230c4)]:
|
|
9
|
+
- @ckb-ccc/core@1.23.1
|
|
10
|
+
- @ckb-ccc/type-id@0.1.16
|
|
11
|
+
|
|
12
|
+
## 0.2.15
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`bb6cbf4`](https://github.com/ckb-devrel/ccc/commit/bb6cbf4ad68438c84faed61d8516530c643f3f4e), [`b21b27d`](https://github.com/ckb-devrel/ccc/commit/b21b27d4d29484b255d95105f6079ebb688b0e5c), [`21bf250`](https://github.com/ckb-devrel/ccc/commit/21bf2505cd9992a000da7a0c6a18b78aac67b34a), [`8b650f0`](https://github.com/ckb-devrel/ccc/commit/8b650f0f06853923a6fa8cf9202f2854d215cf33), [`a7bcb6d`](https://github.com/ckb-devrel/ccc/commit/a7bcb6d4db3e5255d9178a654a872050f86523ce), [`6946dd1`](https://github.com/ckb-devrel/ccc/commit/6946dd123400954a21eccfa71a0fb5b4af271051), [`3506c09`](https://github.com/ckb-devrel/ccc/commit/3506c09a5d16f4ec33ed379b73951b47434e2370), [`665931f`](https://github.com/ckb-devrel/ccc/commit/665931f2e040cc19503f4924453cf9d8d8bec5e8), [`de94e2c`](https://github.com/ckb-devrel/ccc/commit/de94e2c06778af3bcc413dd10f755806874afe45), [`2c91baa`](https://github.com/ckb-devrel/ccc/commit/2c91baaeb7090442264c2067defaa2c34d1d067f)]:
|
|
17
|
+
- @ckb-ccc/core@1.23.0
|
|
18
|
+
- @ckb-ccc/type-id@0.1.15
|
|
19
|
+
|
|
3
20
|
## 0.2.14
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { n as PlcOperation, s as index_d_exports, t as Curve } from "./index-C0QY5P5_.mjs";
|
|
2
|
+
import { ccc } from "@ckb-ccc/core";
|
|
3
|
+
type DidCkbDataV1Like = {
|
|
4
|
+
document: unknown;
|
|
5
|
+
localId?: string | null;
|
|
6
|
+
};
|
|
7
|
+
declare const DidCkbDataV1_base: (abstract new () => {
|
|
8
|
+
toBytes(): ccc.Bytes;
|
|
9
|
+
clone(): DidCkbDataV1;
|
|
10
|
+
eq(other: DidCkbDataV1Like): boolean;
|
|
11
|
+
hash(): ccc.Hex;
|
|
12
|
+
toHex(): ccc.Hex;
|
|
13
|
+
}) & {
|
|
14
|
+
byteLength?: number;
|
|
15
|
+
encode(_: DidCkbDataV1Like): ccc.Bytes;
|
|
16
|
+
decode(_: ccc.BytesLike, _context?: any): DidCkbDataV1;
|
|
17
|
+
fromBytes(_bytes: ccc.BytesLike, _context?: any): DidCkbDataV1;
|
|
18
|
+
from(_: DidCkbDataV1Like): DidCkbDataV1;
|
|
19
|
+
Base<SubTypeLike, SubType = SubTypeLike, Context = any>(): any;
|
|
20
|
+
BaseUnion<CodecType extends ccc.CodecLike<any, ccc.mol.UnionDecoded<any, any>, any>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: ccc.DecodedType<CodecType>) => {
|
|
21
|
+
readonly inner: ccc.DecodedType<CodecType>;
|
|
22
|
+
match<Result>(handlers: ccc.mol.UnionMatchHandlers<CodecType, Result> & {
|
|
23
|
+
_?: undefined | null;
|
|
24
|
+
}): Result;
|
|
25
|
+
match<Result>(handlers: Partial<ccc.mol.UnionMatchHandlers<CodecType, Result>> & {
|
|
26
|
+
_: (inner: ccc.DecodedType<CodecType>) => Result;
|
|
27
|
+
}): Result;
|
|
28
|
+
toBytes(): ccc.Bytes;
|
|
29
|
+
clone(): SubType_1;
|
|
30
|
+
eq(other: SubTypeLike_1): boolean;
|
|
31
|
+
hash(): ccc.Hex;
|
|
32
|
+
toHex(): ccc.Hex;
|
|
33
|
+
}) & {
|
|
34
|
+
byteLength?: number;
|
|
35
|
+
encode(_: SubTypeLike_1): ccc.Bytes;
|
|
36
|
+
decode(_: ccc.BytesLike, _context?: ccc.ContextType<CodecType> | undefined): SubType_1;
|
|
37
|
+
fromBytes(_bytes: ccc.BytesLike, _context?: ccc.ContextType<CodecType> | undefined): SubType_1;
|
|
38
|
+
from(_: SubTypeLike_1): SubType_1;
|
|
39
|
+
Base<SubTypeLike, SubType = SubTypeLike, Context = any>(): any;
|
|
40
|
+
BaseUnion<CodecType_1 extends ccc.CodecLike<any, ccc.mol.UnionDecoded<any, any>, any>, SubTypeLike_1_1, SubType_1_1 = SubTypeLike_1_1>(): any;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
declare class DidCkbDataV1 extends DidCkbDataV1_base {
|
|
44
|
+
document: unknown;
|
|
45
|
+
localId?: string | undefined;
|
|
46
|
+
constructor(document: unknown, localId?: string | undefined);
|
|
47
|
+
static from(data: DidCkbDataV1Like): DidCkbDataV1;
|
|
48
|
+
}
|
|
49
|
+
type DidCkbDataLike = {
|
|
50
|
+
type?: "v1" | null;
|
|
51
|
+
value: DidCkbDataV1Like;
|
|
52
|
+
} | {
|
|
53
|
+
inner: {
|
|
54
|
+
type?: "v1" | null;
|
|
55
|
+
value: DidCkbDataV1Like;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
declare const DidCkbData_base: (abstract new (inner: {
|
|
59
|
+
type: "v1";
|
|
60
|
+
value: DidCkbDataV1;
|
|
61
|
+
}) => {
|
|
62
|
+
readonly inner: {
|
|
63
|
+
type: "v1";
|
|
64
|
+
value: DidCkbDataV1;
|
|
65
|
+
};
|
|
66
|
+
match<Result>(handlers: ccc.mol.UnionMatchHandlers<ccc.Codec<{
|
|
67
|
+
type: "v1";
|
|
68
|
+
value: DidCkbDataV1Like;
|
|
69
|
+
} | {
|
|
70
|
+
inner: {
|
|
71
|
+
type: "v1";
|
|
72
|
+
value: DidCkbDataV1Like;
|
|
73
|
+
};
|
|
74
|
+
}, {
|
|
75
|
+
type: "v1";
|
|
76
|
+
value: DidCkbDataV1;
|
|
77
|
+
}, unknown>, Result> & {
|
|
78
|
+
_?: undefined | null;
|
|
79
|
+
}): Result;
|
|
80
|
+
match<Result>(handlers: Partial<ccc.mol.UnionMatchHandlers<ccc.Codec<{
|
|
81
|
+
type: "v1";
|
|
82
|
+
value: DidCkbDataV1Like;
|
|
83
|
+
} | {
|
|
84
|
+
inner: {
|
|
85
|
+
type: "v1";
|
|
86
|
+
value: DidCkbDataV1Like;
|
|
87
|
+
};
|
|
88
|
+
}, {
|
|
89
|
+
type: "v1";
|
|
90
|
+
value: DidCkbDataV1;
|
|
91
|
+
}, unknown>, Result>> & {
|
|
92
|
+
_: (inner: {
|
|
93
|
+
type: "v1";
|
|
94
|
+
value: DidCkbDataV1;
|
|
95
|
+
}) => Result;
|
|
96
|
+
}): Result;
|
|
97
|
+
toBytes(): ccc.Bytes;
|
|
98
|
+
clone(): DidCkbData;
|
|
99
|
+
eq(other: DidCkbDataLike): boolean;
|
|
100
|
+
hash(): ccc.Hex;
|
|
101
|
+
toHex(): ccc.Hex;
|
|
102
|
+
}) & {
|
|
103
|
+
byteLength?: number;
|
|
104
|
+
encode(_: DidCkbDataLike): ccc.Bytes;
|
|
105
|
+
decode(_: ccc.BytesLike, _context?: unknown): DidCkbData;
|
|
106
|
+
fromBytes(_bytes: ccc.BytesLike, _context?: unknown): DidCkbData;
|
|
107
|
+
from(_: DidCkbDataLike): DidCkbData;
|
|
108
|
+
Base<SubTypeLike_1, SubType_1 = SubTypeLike_1, Context = any>(): (abstract new () => {
|
|
109
|
+
toBytes(): ccc.Bytes;
|
|
110
|
+
clone(): SubType_1;
|
|
111
|
+
eq(other: SubTypeLike_1): boolean;
|
|
112
|
+
hash(): ccc.Hex;
|
|
113
|
+
toHex(): ccc.Hex;
|
|
114
|
+
}) & {
|
|
115
|
+
byteLength?: number;
|
|
116
|
+
encode(_: SubTypeLike_1): ccc.Bytes;
|
|
117
|
+
decode(_: ccc.BytesLike, _context?: Context): SubType_1;
|
|
118
|
+
fromBytes(_bytes: ccc.BytesLike, _context?: Context): SubType_1;
|
|
119
|
+
from(_: SubTypeLike_1): SubType_1;
|
|
120
|
+
Base<SubTypeLike_1_1, SubType_1_1 = SubTypeLike_1_1, Context_1 = any>(): any;
|
|
121
|
+
BaseUnion<CodecType extends ccc.CodecLike<any, ccc.mol.UnionDecoded<any, any>, any>, SubTypeLike, SubType = SubTypeLike>(): any;
|
|
122
|
+
};
|
|
123
|
+
BaseUnion<CodecType extends ccc.CodecLike<any, ccc.mol.UnionDecoded<any, any>, any>, SubTypeLike, SubType = SubTypeLike>(): any;
|
|
124
|
+
};
|
|
125
|
+
declare class DidCkbData extends DidCkbData_base {
|
|
126
|
+
type: "v1";
|
|
127
|
+
value: DidCkbDataV1;
|
|
128
|
+
constructor(type: "v1", value: DidCkbDataV1);
|
|
129
|
+
static from(data: DidCkbDataLike): DidCkbData;
|
|
130
|
+
static fromV1(data: DidCkbDataV1Like): DidCkbData & {
|
|
131
|
+
type: "v1";
|
|
132
|
+
value: DidCkbDataV1;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
type PlcAuthorizationLike = {
|
|
136
|
+
history: object[];
|
|
137
|
+
sig: ccc.HexLike;
|
|
138
|
+
rotationKeyIndices: ccc.NumLike[];
|
|
139
|
+
};
|
|
140
|
+
declare const PlcAuthorization_base: (abstract new () => {
|
|
141
|
+
toBytes(): ccc.Bytes;
|
|
142
|
+
clone(): PlcAuthorization;
|
|
143
|
+
eq(other: PlcAuthorizationLike): boolean;
|
|
144
|
+
hash(): ccc.Hex;
|
|
145
|
+
toHex(): ccc.Hex;
|
|
146
|
+
}) & {
|
|
147
|
+
byteLength?: number;
|
|
148
|
+
encode(_: PlcAuthorizationLike): ccc.Bytes;
|
|
149
|
+
decode(_: ccc.BytesLike, _context?: any): PlcAuthorization;
|
|
150
|
+
fromBytes(_bytes: ccc.BytesLike, _context?: any): PlcAuthorization;
|
|
151
|
+
from(_: PlcAuthorizationLike): PlcAuthorization;
|
|
152
|
+
Base<SubTypeLike, SubType = SubTypeLike, Context = any>(): any;
|
|
153
|
+
BaseUnion<CodecType extends ccc.CodecLike<any, ccc.mol.UnionDecoded<any, any>, any>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: ccc.DecodedType<CodecType>) => {
|
|
154
|
+
readonly inner: ccc.DecodedType<CodecType>;
|
|
155
|
+
match<Result>(handlers: ccc.mol.UnionMatchHandlers<CodecType, Result> & {
|
|
156
|
+
_?: undefined | null;
|
|
157
|
+
}): Result;
|
|
158
|
+
match<Result>(handlers: Partial<ccc.mol.UnionMatchHandlers<CodecType, Result>> & {
|
|
159
|
+
_: (inner: ccc.DecodedType<CodecType>) => Result;
|
|
160
|
+
}): Result;
|
|
161
|
+
toBytes(): ccc.Bytes;
|
|
162
|
+
clone(): SubType_1;
|
|
163
|
+
eq(other: SubTypeLike_1): boolean;
|
|
164
|
+
hash(): ccc.Hex;
|
|
165
|
+
toHex(): ccc.Hex;
|
|
166
|
+
}) & {
|
|
167
|
+
byteLength?: number;
|
|
168
|
+
encode(_: SubTypeLike_1): ccc.Bytes;
|
|
169
|
+
decode(_: ccc.BytesLike, _context?: ccc.ContextType<CodecType> | undefined): SubType_1;
|
|
170
|
+
fromBytes(_bytes: ccc.BytesLike, _context?: ccc.ContextType<CodecType> | undefined): SubType_1;
|
|
171
|
+
from(_: SubTypeLike_1): SubType_1;
|
|
172
|
+
Base<SubTypeLike, SubType = SubTypeLike, Context = any>(): any;
|
|
173
|
+
BaseUnion<CodecType_1 extends ccc.CodecLike<any, ccc.mol.UnionDecoded<any, any>, any>, SubTypeLike_1_1, SubType_1_1 = SubTypeLike_1_1>(): any;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
declare class PlcAuthorization extends PlcAuthorization_base {
|
|
177
|
+
history: object[];
|
|
178
|
+
sig: ccc.Hex;
|
|
179
|
+
rotationKeyIndices: ccc.Num[];
|
|
180
|
+
constructor(history: object[], sig: ccc.Hex, rotationKeyIndices: ccc.Num[]);
|
|
181
|
+
static from(data: PlcAuthorizationLike): PlcAuthorization;
|
|
182
|
+
}
|
|
183
|
+
type DidCkbWitnessLike = {
|
|
184
|
+
localIdAuthorization: PlcAuthorizationLike;
|
|
185
|
+
};
|
|
186
|
+
declare const DidCkbWitness_base: (abstract new () => {
|
|
187
|
+
toBytes(): ccc.Bytes;
|
|
188
|
+
clone(): DidCkbWitness;
|
|
189
|
+
eq(other: DidCkbWitnessLike): boolean;
|
|
190
|
+
hash(): ccc.Hex;
|
|
191
|
+
toHex(): ccc.Hex;
|
|
192
|
+
}) & {
|
|
193
|
+
byteLength?: number;
|
|
194
|
+
encode(_: DidCkbWitnessLike): ccc.Bytes;
|
|
195
|
+
decode(_: ccc.BytesLike, _context?: any): DidCkbWitness;
|
|
196
|
+
fromBytes(_bytes: ccc.BytesLike, _context?: any): DidCkbWitness;
|
|
197
|
+
from(_: DidCkbWitnessLike): DidCkbWitness;
|
|
198
|
+
Base<SubTypeLike, SubType = SubTypeLike, Context = any>(): any;
|
|
199
|
+
BaseUnion<CodecType extends ccc.CodecLike<any, ccc.mol.UnionDecoded<any, any>, any>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: ccc.DecodedType<CodecType>) => {
|
|
200
|
+
readonly inner: ccc.DecodedType<CodecType>;
|
|
201
|
+
match<Result>(handlers: ccc.mol.UnionMatchHandlers<CodecType, Result> & {
|
|
202
|
+
_?: undefined | null;
|
|
203
|
+
}): Result;
|
|
204
|
+
match<Result>(handlers: Partial<ccc.mol.UnionMatchHandlers<CodecType, Result>> & {
|
|
205
|
+
_: (inner: ccc.DecodedType<CodecType>) => Result;
|
|
206
|
+
}): Result;
|
|
207
|
+
toBytes(): ccc.Bytes;
|
|
208
|
+
clone(): SubType_1;
|
|
209
|
+
eq(other: SubTypeLike_1): boolean;
|
|
210
|
+
hash(): ccc.Hex;
|
|
211
|
+
toHex(): ccc.Hex;
|
|
212
|
+
}) & {
|
|
213
|
+
byteLength?: number;
|
|
214
|
+
encode(_: SubTypeLike_1): ccc.Bytes;
|
|
215
|
+
decode(_: ccc.BytesLike, _context?: ccc.ContextType<CodecType> | undefined): SubType_1;
|
|
216
|
+
fromBytes(_bytes: ccc.BytesLike, _context?: ccc.ContextType<CodecType> | undefined): SubType_1;
|
|
217
|
+
from(_: SubTypeLike_1): SubType_1;
|
|
218
|
+
Base<SubTypeLike, SubType = SubTypeLike, Context = any>(): any;
|
|
219
|
+
BaseUnion<CodecType_1 extends ccc.CodecLike<any, ccc.mol.UnionDecoded<any, any>, any>, SubTypeLike_1_1, SubType_1_1 = SubTypeLike_1_1>(): any;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
declare class DidCkbWitness extends DidCkbWitness_base {
|
|
223
|
+
localIdAuthorization: PlcAuthorization;
|
|
224
|
+
constructor(localIdAuthorization: PlcAuthorization);
|
|
225
|
+
static from(data: DidCkbWitnessLike): DidCkbWitness;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Create a DID CKB cell.
|
|
229
|
+
*
|
|
230
|
+
* @param props The arguments for creating the cell.
|
|
231
|
+
* @param props.signer The signer to sign the transaction.
|
|
232
|
+
* @param props.receiver The receiver script (optional).
|
|
233
|
+
* @param props.data The output data.
|
|
234
|
+
* @param props.tx The transaction skeleton (optional).
|
|
235
|
+
*/
|
|
236
|
+
declare function createDidCkb(props: {
|
|
237
|
+
signer: ccc.Signer;
|
|
238
|
+
data: DidCkbDataLike;
|
|
239
|
+
receiver?: ccc.ScriptLike | null;
|
|
240
|
+
tx?: ccc.TransactionLike | null;
|
|
241
|
+
}): Promise<{
|
|
242
|
+
tx: ccc.Transaction;
|
|
243
|
+
id: ccc.Hex;
|
|
244
|
+
index: number;
|
|
245
|
+
}>;
|
|
246
|
+
/**
|
|
247
|
+
* Transfer a DID CKB cell.
|
|
248
|
+
*
|
|
249
|
+
* @param props The arguments for transferring the cell.
|
|
250
|
+
* @param props.client The client to communicate with CKB.
|
|
251
|
+
* @param props.id The Type ID to transfer.
|
|
252
|
+
* @param props.receiver The new receiver script.
|
|
253
|
+
* @param props.tx The transaction skeleton (optional).
|
|
254
|
+
* @param props.data The new output data or a transformer to update the data (optional).
|
|
255
|
+
*/
|
|
256
|
+
declare function transferDidCkb(props: {
|
|
257
|
+
client: ccc.Client;
|
|
258
|
+
id: ccc.HexLike;
|
|
259
|
+
receiver: ccc.ScriptLike;
|
|
260
|
+
tx?: ccc.TransactionLike | null;
|
|
261
|
+
data?: DidCkbDataLike | ((cell: ccc.Cell, data?: DidCkbData) => DidCkbDataLike | Promise<DidCkbDataLike>) | null;
|
|
262
|
+
}): Promise<{
|
|
263
|
+
tx: ccc.Transaction;
|
|
264
|
+
inIndex: number;
|
|
265
|
+
outIndex: number;
|
|
266
|
+
}>;
|
|
267
|
+
/**
|
|
268
|
+
* Destroy a DID CKB cell.
|
|
269
|
+
*
|
|
270
|
+
* @param props The arguments for destroying the cell.
|
|
271
|
+
* @param props.client The client to communicate with CKB.
|
|
272
|
+
* @param props.id The Type ID to destroy.
|
|
273
|
+
* @param props.tx The transaction skeleton (optional).
|
|
274
|
+
*/
|
|
275
|
+
declare function destroyDidCkb(props: {
|
|
276
|
+
client: ccc.Client;
|
|
277
|
+
id: ccc.HexLike;
|
|
278
|
+
tx?: ccc.TransactionLike | null;
|
|
279
|
+
}): Promise<{
|
|
280
|
+
tx: ccc.Transaction;
|
|
281
|
+
index: number;
|
|
282
|
+
}>;
|
|
283
|
+
type HistoryAction = "CREATE" | "UPDATE" | "MIGRATE";
|
|
284
|
+
type HistoryEntry = {
|
|
285
|
+
/**
|
|
286
|
+
* `CREATE` for a fresh mint, `MIGRATE` for a did:plc import (genesis cell
|
|
287
|
+
* with a `localId` set), `UPDATE` for every subsequent transfer.
|
|
288
|
+
*/
|
|
289
|
+
action: HistoryAction;
|
|
290
|
+
txHash: ccc.Hex;
|
|
291
|
+
outputIndex: ccc.Num;
|
|
292
|
+
blockNumber?: ccc.Num;
|
|
293
|
+
capacity: ccc.Num;
|
|
294
|
+
data: DidCkbData;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Walk the DID cell chain backwards to produce the ordered list of operations
|
|
298
|
+
* applied to a DID.
|
|
299
|
+
*
|
|
300
|
+
* Each `transferDidCkb` consumes the previous DID cell as an input and creates
|
|
301
|
+
* a new one with the same Type ID args; the genesis (`createDidCkb` /
|
|
302
|
+
* `createDidCkb` with localId) has no DID input. We start from the live cell,
|
|
303
|
+
* read its tx, look for the prior DID cell among the inputs, and repeat. The
|
|
304
|
+
* first entry returned is the newest (most recent transfer); the last is the
|
|
305
|
+
* genesis.
|
|
306
|
+
*
|
|
307
|
+
* Cost: roughly one `getTransaction` call per step plus one `input.getCell`
|
|
308
|
+
* lookup per non-DID input on each step. `input.getCell` goes through the
|
|
309
|
+
* client's cell cache, so repeated walks over the same chain are cheap.
|
|
310
|
+
*
|
|
311
|
+
* @throws If an input cell lookup fails or the input cell is unavailable.
|
|
312
|
+
* An unresolved input cannot establish that a transaction is the genesis.
|
|
313
|
+
*/
|
|
314
|
+
declare function getDidCkbHistory(props: {
|
|
315
|
+
client: ccc.Client;
|
|
316
|
+
/**
|
|
317
|
+
* Either the 20-byte Type ID args hex returned by `createDidCkb`, or a
|
|
318
|
+
* `did:ckb:` URI. URIs are converted via `didToArgs`.
|
|
319
|
+
*/
|
|
320
|
+
id: ccc.HexLike | string;
|
|
321
|
+
/** Pre-resolved live cell; if omitted, we fetch it. */
|
|
322
|
+
liveCell?: ccc.Cell;
|
|
323
|
+
/** Safety bound to prevent runaway walks. Default 50. */
|
|
324
|
+
maxSteps?: number;
|
|
325
|
+
}): Promise<HistoryEntry[]>;
|
|
326
|
+
declare function base32Encode(bytes: ccc.BytesLike): string;
|
|
327
|
+
declare function base32Decode(input: string): ccc.Bytes;
|
|
328
|
+
/**
|
|
329
|
+
* Convert 20-byte Type ID args (the `id` returned from `createDidCkb`) to a
|
|
330
|
+
* `did:ckb:` identifier string per WIP-01 §2.2.
|
|
331
|
+
*/
|
|
332
|
+
declare function argsToDid(args: ccc.HexLike): string;
|
|
333
|
+
/**
|
|
334
|
+
* Reverse of `argsToDid`. Validates the prefix, base32 length, and decoded
|
|
335
|
+
* byte count.
|
|
336
|
+
*/
|
|
337
|
+
declare function didToArgs(did: string): ccc.Hex;
|
|
338
|
+
declare function isDidCkb(value: string): boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Build the migration witness payload that authorizes a did:plc -> did:ckb
|
|
341
|
+
* import. Pure: takes a tx hash + signing material, returns a typed
|
|
342
|
+
* `DidCkbWitness` that the caller wraps in a `WitnessArgs.outputType` field.
|
|
343
|
+
*
|
|
344
|
+
* Per WIP-02 §3.1.1 we send only the genesis operation in `history`. The
|
|
345
|
+
* contract recomputes the genesis CID over the CBOR-encoded op, verifies the
|
|
346
|
+
* self-signature inside it, then verifies `sig` against
|
|
347
|
+
* `history[0].rotationKeys[rotationKeyIndex]`.
|
|
348
|
+
*
|
|
349
|
+
* `selfSigIndex` defaults to 0 because PLC genesis ops are conventionally
|
|
350
|
+
* self-signed by the first rotation key; override if the genesis you're
|
|
351
|
+
* migrating used a different one.
|
|
352
|
+
*/
|
|
353
|
+
declare function buildMigrationWitness(props: {
|
|
354
|
+
txHash: ccc.HexLike;
|
|
355
|
+
genesisOperation: PlcOperation;
|
|
356
|
+
rotationKeyIndex: number;
|
|
357
|
+
rotationPrivateKey: ccc.BytesLike;
|
|
358
|
+
curve?: Curve;
|
|
359
|
+
selfSigIndex?: number;
|
|
360
|
+
}): DidCkbWitness;
|
|
361
|
+
/**
|
|
362
|
+
* Build a create tx whose output declares an imported did:plc identifier in
|
|
363
|
+
* its `localId` field. Equivalent to calling `createDidCkb` with
|
|
364
|
+
* `data.value.localId = sourceDid`; provided as a named helper for symmetry
|
|
365
|
+
* with the other DID operations and so `did:plc:` migrations have an
|
|
366
|
+
* obvious entry point.
|
|
367
|
+
*
|
|
368
|
+
* The caller is responsible for: completing inputs + fee, building the
|
|
369
|
+
* migration witness with `buildMigrationWitness`, and setting it at the
|
|
370
|
+
* witness slot of input 0. See `packages/examples/src/migrateDid.ts` for the
|
|
371
|
+
* full flow.
|
|
372
|
+
*/
|
|
373
|
+
declare function migrateDidCkb(props: {
|
|
374
|
+
signer: ccc.Signer;
|
|
375
|
+
sourceDid: string;
|
|
376
|
+
data?: DidCkbDataLike | null;
|
|
377
|
+
receiver?: ccc.ScriptLike | null;
|
|
378
|
+
tx?: ccc.TransactionLike | null;
|
|
379
|
+
}): Promise<{
|
|
380
|
+
tx: ccc.Transaction;
|
|
381
|
+
id: ccc.Hex;
|
|
382
|
+
index: number;
|
|
383
|
+
}>;
|
|
384
|
+
type DidCkbRecord = {
|
|
385
|
+
/** The `did:ckb:` string identifying this cell. */
|
|
386
|
+
did: string;
|
|
387
|
+
/** 20-byte Type ID args (same value `createDidCkb` returned as `id`). */
|
|
388
|
+
id: ccc.Hex;
|
|
389
|
+
/** Decoded DidCkbData; `.value.document` is the CBOR-decoded document. */
|
|
390
|
+
data: DidCkbData;
|
|
391
|
+
/** The live DID Metadata Cell itself. */
|
|
392
|
+
cell: ccc.Cell;
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* Find the live DID Metadata Cell for a given Type ID and decode its data.
|
|
396
|
+
*
|
|
397
|
+
* Returns `undefined` when no live cell exists (the DID was never created or
|
|
398
|
+
* has been destroyed).
|
|
399
|
+
*/
|
|
400
|
+
declare function findDidCkbCell(props: {
|
|
401
|
+
client: ccc.Client;
|
|
402
|
+
id: ccc.HexLike;
|
|
403
|
+
}): Promise<DidCkbRecord | undefined>;
|
|
404
|
+
/**
|
|
405
|
+
* Resolve a `did:ckb:` string to its live cell + decoded document.
|
|
406
|
+
*
|
|
407
|
+
* Throws if `did` is not a syntactically valid did:ckb identifier. Returns
|
|
408
|
+
* `undefined` if the DID was created and then destroyed, or never existed.
|
|
409
|
+
*/
|
|
410
|
+
declare function resolveDidCkb(props: {
|
|
411
|
+
client: ccc.Client;
|
|
412
|
+
did: string;
|
|
413
|
+
}): Promise<DidCkbRecord | undefined>;
|
|
414
|
+
/**
|
|
415
|
+
* List every live DID Metadata Cell owned by the given lock. Useful for
|
|
416
|
+
* dashboards that want to enumerate the DIDs an address controls.
|
|
417
|
+
*
|
|
418
|
+
* Cells whose data fails to decode (e.g. a future on-chain schema version) are
|
|
419
|
+
* skipped, not thrown, so a single bad cell can't break the whole listing.
|
|
420
|
+
*/
|
|
421
|
+
declare function listDidCkbsByLock(props: {
|
|
422
|
+
client: ccc.Client;
|
|
423
|
+
lock: ccc.ScriptLike;
|
|
424
|
+
limit?: number;
|
|
425
|
+
order?: "asc" | "desc";
|
|
426
|
+
}): Promise<DidCkbRecord[]>;
|
|
427
|
+
declare namespace barrel_d_exports {
|
|
428
|
+
export { DidCkbData, DidCkbDataLike, DidCkbDataV1, DidCkbDataV1Like, DidCkbRecord, DidCkbWitness, DidCkbWitnessLike, HistoryAction, HistoryEntry, PlcAuthorization, PlcAuthorizationLike, argsToDid, base32Decode, base32Encode, buildMigrationWitness, createDidCkb, destroyDidCkb, didToArgs, findDidCkbCell, getDidCkbHistory, isDidCkb, listDidCkbsByLock, migrateDidCkb, index_d_exports as plc, resolveDidCkb, transferDidCkb };
|
|
429
|
+
}
|
|
430
|
+
export { DidCkbWitness as C, PlcAuthorizationLike as E, DidCkbDataV1Like as S, PlcAuthorization as T, destroyDidCkb as _, resolveDidCkb as a, DidCkbDataLike as b, argsToDid as c, didToArgs as d, isDidCkb as f, createDidCkb as g, getDidCkbHistory as h, listDidCkbsByLock as i, base32Decode as l, HistoryEntry as m, DidCkbRecord as n, buildMigrationWitness as o, HistoryAction as p, findDidCkbCell as r, migrateDidCkb as s, barrel_d_exports as t, base32Encode as u, transferDidCkb as v, DidCkbWitnessLike as w, DidCkbDataV1 as x, DidCkbData as y };
|
|
431
|
+
//# sourceMappingURL=barrel-BYdcNWd1.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel-BYdcNWd1.d.mts","names":[],"sources":["../src/codec.ts","../src/didCkb.ts","../src/history.ts","../src/identifier.ts","../src/migrate.ts","../src/resolver.ts"],"mappings":";;KAGY;EACV;EACA;;;;;;;;;;;;;;;;;;MAiKu7jC;;;;;;;;;;;IAAs/C;;IAAunB,OAAA,GAAA,IAAA,WAAA,W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Z,MAAM,IAAI;EACV;EACA;IACE,QAAQ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-P3Pd_6ND.mjs";import{a as t,o as n,r}from"./plc-CAHX4f5y.mjs";import{ccc as i}from"@ckb-ccc/core";import{decode as a,encode as o}from"@ipld/dag-cbor";import{typeIdA as s}from"@ckb-ccc/type-id/advanced";function c(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 l,u,d,f;let p=l=class extends i.Entity.Base(){constructor(e,t){super(),this.document=e,this.localId=t}static from(e){return e instanceof l?e:new l(e.document,e.localId??void 0)}};p=l=c([i.codec(i.mol.table({document:i.mol.Bytes,localId:i.mol.StringOpt}).map({inMap:e=>({...e,document:i.hexFrom(o(e.document))}),outMap:e=>({...e,document:a(i.bytesFrom(e.document))})}))],p);const m=i.mol.union({v1:p});let h=u=class extends i.Entity.BaseUnion(){constructor(e,t){super({type:e,value:t}),this.type=e,this.value=t}static from(e){return e instanceof u?e:`inner`in e?new u(e.inner.type??`v1`,p.from(e.inner.value)):new u(e.type??`v1`,p.from(e.value))}static fromV1(e){return new u(`v1`,p.from(e))}};h=u=c([i.codec(m)],h);let g=d=class extends i.Entity.Base(){constructor(e,t,n){super(),this.history=e,this.sig=t,this.rotationKeyIndices=n}static from(e){return e instanceof d?e:new d(e.history,i.hexFrom(e.sig),e.rotationKeyIndices.map(i.numFrom))}};g=d=c([i.codec(i.mol.table({history:i.mol.BytesVec,sig:i.mol.Bytes,rotationKeyIndices:i.mol.Uint8Vec}).map({inMap:e=>({...e,history:e.history.map(e=>i.hexFrom(o(e)))}),outMap:e=>({...e,history:e.history.map(e=>a(i.bytesFrom(e)))})}))],g);let _=f=class extends i.Entity.Base(){constructor(e){super(),this.localIdAuthorization=e}static from(e){return e instanceof f?e:new f(g.from(e.localIdAuthorization))}};_=f=c([i.codec(i.mol.table({localIdAuthorization:g}))],_);const v=s.buildTypeIdOperations({async getScriptInfo(e){return e.getKnownScript(i.KnownScript.DidCkb)},codec:h,async calculateTypeId(e,t){return i.bytesFrom(i.hashTypeId(t.inputs[0],t.outputs.length)).slice(0,20)}});function y(e){return v.create(e)}async function b(e){return v.transfer(e)}async function x(e){return v.destroy(e)}const S=`did:ckb:`,C=`abcdefghijklmnopqrstuvwxyz234567`,w=(()=>{let e={};for(let t=0;t<32;t++)e[C[t]]=t;return e})();function T(e){let t=i.bytesFrom(e),n=0,r=0,a=``;for(let e=0;e<t.length;e++)for(r=r<<8|t[e],n+=8;n>=5;)a+=C[r>>>n-5&31],n-=5;return n>0&&(a+=C[r<<5-n&31]),a}function E(e){let t=e.toLowerCase().replace(/=+$/g,``),n=0,r=0,i=[];for(let e of t){let t=w[e];if(t===void 0)throw Error(`Invalid base32 character "${e}" in input`);r=r<<5|t,n+=5,n>=8&&(i.push(r>>>n-8&255),n-=8)}return Uint8Array.from(i)}function D(e){let t=i.bytesFrom(e);if(t.length!==20)throw Error(`did:ckb args must be 20 bytes, got ${t.length}`);return S+T(t)}function O(e){if(!e.startsWith(S))throw Error(`Expected did:ckb:..., got "${e}"`);let t=e.slice(8);if(t.length!==32)throw Error(`did:ckb identifier must be 32 base32 chars, got ${t.length}`);let n=E(t);if(n.length!==20)throw Error(`did:ckb identifier must decode to 20 bytes, got ${n.length}`);return i.hexFrom(n)}function k(e){if(!e.startsWith(S))return!1;try{return O(e),!0}catch{return!1}}async function A(e,t){let n=await e.getKnownScript(i.KnownScript.DidCkb);return i.Script.from({codeHash:n.codeHash,hashType:n.hashType,args:t})}function j(e,t){return{did:D(t),id:t,data:h.decode(e.outputData),cell:e}}async function M(e){let t=i.hexFrom(e.id),n=await A(e.client,t),r=await e.client.findSingletonCellByType(n,!0);if(r)return j(r,t)}async function N(e){if(!k(e.did))throw Error(`Not a did:ckb identifier: ${e.did}`);return M({client:e.client,id:O(e.did)})}async function P(e){let t=await e.client.getKnownScript(i.KnownScript.DidCkb),n=[];for await(let r of e.client.findCells({script:i.Script.from(e.lock),scriptType:`lock`,scriptSearchMode:`exact`,filter:{script:i.Script.from({codeHash:t.codeHash,hashType:t.hashType,args:`0x`})},withData:!0},e.order,e.limit)){let e=r.cellOutput.type;if(e&&i.bytesFrom(e.args).length===20)try{n.push(j(r,i.hexFrom(e.args)))}catch{}}return n}async function F(e){let t=typeof e.id==`string`&&k(e.id)?O(e.id):i.hexFrom(e.id),n=(await e.client.getKnownScript(i.KnownScript.DidCkb)).codeHash.toLowerCase(),r=t.toLowerCase(),a=e.liveCell??(await M({client:e.client,id:t}))?.cell;if(!a)return[];let o=[],s=e.maxSteps??50,c=0;for(;a&&c<s;){c++;let t=await e.client.getTransaction(a.outPoint.txHash);if(!t)break;let i=L(a,t.blockNumber);if(!i)break;let s=await I(e.client,t.transaction,n,r);if(!s){i.action=i.data.value.localId?`MIGRATE`:`CREATE`,o.push(i);break}i.action=`UPDATE`,o.push(i),a=s}return o}async function I(e,t,n,r){let{inputs:a}=i.Transaction.from(t);for(let t of a){let a=await t.getCell(e),o=a.cellOutput.type;if(o&&o.codeHash.toLowerCase()===n&&i.hexFrom(o.args).toLowerCase()===r)return a}}function L(e,t){try{let n=h.decode(e.outputData);return{action:`UPDATE`,txHash:e.outPoint.txHash,outputIndex:e.outPoint.index,blockNumber:t,capacity:e.cellOutput.capacity,data:n}}catch{return}}function R(e){let t=r(e.genesisOperation);if(!t[e.rotationKeyIndex])throw Error(`rotationKeyIndex ${e.rotationKeyIndex} out of range (genesis has ${t.length} keys)`);let a=e.curve??t[e.rotationKeyIndex].curve,o=n(e.rotationPrivateKey,i.bytesFrom(e.txHash),a);return _.from({localIdAuthorization:{history:[e.genesisOperation],sig:i.hexFrom(o),rotationKeyIndices:[e.selfSigIndex??0,e.rotationKeyIndex]}})}async function z(e){if(!e.sourceDid.startsWith(`did:plc:`))throw Error(`sourceDid must be did:plc:..., got "${e.sourceDid}"`);let t=h.from(e.data??{value:{document:{}}});return t.value.localId=e.sourceDid,y({signer:e.signer,data:t,receiver:e.receiver,tx:e.tx})}var B=/* @__PURE__ */ e({DidCkbData:()=>h,DidCkbDataV1:()=>p,DidCkbWitness:()=>_,PlcAuthorization:()=>g,argsToDid:()=>D,base32Decode:()=>E,base32Encode:()=>T,buildMigrationWitness:()=>R,createDidCkb:()=>y,destroyDidCkb:()=>x,didToArgs:()=>O,findDidCkbCell:()=>M,getDidCkbHistory:()=>F,isDidCkb:()=>k,listDidCkbsByLock:()=>P,migrateDidCkb:()=>z,plc:()=>t,resolveDidCkb:()=>N,transferDidCkb:()=>b});export{p as _,M as a,D as c,O as d,k as f,h as g,b as h,F as i,E as l,x as m,R as n,P as o,y as p,z as r,N as s,B as t,T as u,_ as v,g as y};
|
|
2
|
+
//# sourceMappingURL=barrel-CRigE_Kq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel-CRigE_Kq.mjs","names":["cborEncode","cborDecode","__exportAll","plc_exports","signRotationHash","__decorate","c","r","target","desc","key","d","decorators","i","_DidCkbDataV","_DidCkbData","_PlcAuthorization","_DidCkbWitness","DidCkbDataV1","ccc","document","localId","data","encode","decode","DidCkbDataCodec","DidCkbData","type","value","PlcAuthorization","history","sig","rotationKeyIndices","h","DidCkbWitness","localIdAuthorization","OPERATIONS","typeIdA","client","tx","createDidCkb","props","transferDidCkb","destroyDidCkb","DID_PREFIX","ALPHABET","REVERSE","map","base32Encode","buf","bytes","bits","output","base32Decode","cleaned","input","char","v","argsToDid","args","didToArgs","did","body","isDidCkb","didCkbTypeScript","scriptInfo","id","decodeRecord","cell","findDidCkbCell","resolveDidCkb","listDidCkbsByLock","records","getDidCkbHistory","codeHash","normalizedId","maxSteps","steps","entry","decodeEntry","prior","findPriorDidCell","inputs","buildMigrationWitness","rotationKeys","getRotationKeys","curve","migrateDidCkb","barrel_exports"],"sources":["../src/codec.ts","../src/didCkb.ts","../src/identifier.ts","../src/resolver.ts","../src/history.ts","../src/migrate.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: unknown;\n localId?: string | null;\n};\n@ccc.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(ccc.bytesFrom(data.document)),\n }),\n }),\n)\nexport class DidCkbDataV1 extends ccc.Entity.Base<\n DidCkbDataV1Like,\n DidCkbDataV1\n>() {\n constructor(\n public document: unknown,\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\nconst DidCkbDataCodec = ccc.mol.union({\n v1: DidCkbDataV1,\n});\n\nexport type DidCkbDataLike =\n | {\n type?: \"v1\" | null;\n value: DidCkbDataV1Like;\n }\n | {\n inner: {\n type?: \"v1\" | null;\n value: DidCkbDataV1Like;\n };\n };\n\n@ccc.codec(DidCkbDataCodec)\nexport class DidCkbData extends ccc.Entity.BaseUnion<\n typeof DidCkbDataCodec,\n DidCkbDataLike,\n DidCkbData\n>() {\n constructor(\n public type: \"v1\",\n public value: DidCkbDataV1,\n ) {\n super({ type, value });\n }\n\n static from(data: DidCkbDataLike): DidCkbData {\n if (data instanceof DidCkbData) {\n return data;\n }\n\n if (\"inner\" in data) {\n return new DidCkbData(\n data.inner.type ?? \"v1\",\n DidCkbDataV1.from(data.inner.value),\n );\n }\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.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.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.codec(\n ccc.mol.table({\n localIdAuthorization: PlcAuthorization,\n }),\n)\nexport class DidCkbWitness extends ccc.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 codec: DidCkbData,\n async calculateTypeId(\n _: ccc.Client,\n tx: ccc.Transaction,\n ): Promise<ccc.HexLike> {\n return ccc\n .bytesFrom(ccc.hashTypeId(tx.inputs[0], tx.outputs.length))\n .slice(0, 20);\n },\n});\n\n/**\n * Create a DID CKB cell.\n *\n * @param props The arguments for creating the cell.\n * @param props.signer The signer to sign the transaction.\n * @param props.receiver The receiver script (optional).\n * @param props.data The output data.\n * @param props.tx The transaction skeleton (optional).\n */\nexport function createDidCkb(props: {\n signer: ccc.Signer;\n data: DidCkbDataLike;\n receiver?: ccc.ScriptLike | null;\n tx?: ccc.TransactionLike | null;\n}): Promise<{\n tx: ccc.Transaction;\n id: ccc.Hex;\n index: number;\n}> {\n return OPERATIONS.create(props);\n}\n\n/**\n * Transfer a DID CKB cell.\n *\n * @param props The arguments for transferring the cell.\n * @param props.client The client to communicate with CKB.\n * @param props.id The Type ID to transfer.\n * @param props.receiver The new receiver script.\n * @param props.tx The transaction skeleton (optional).\n * @param props.data The new output data or a transformer to update the data (optional).\n */\nexport async function transferDidCkb(props: {\n client: ccc.Client;\n id: ccc.HexLike;\n receiver: ccc.ScriptLike;\n tx?: ccc.TransactionLike | null;\n data?:\n | DidCkbDataLike\n | ((\n cell: ccc.Cell,\n data?: DidCkbData,\n ) => DidCkbDataLike | Promise<DidCkbDataLike>)\n | null;\n}): Promise<{\n tx: ccc.Transaction;\n inIndex: number;\n outIndex: number;\n}> {\n return OPERATIONS.transfer(props);\n}\n\n/**\n * Destroy a DID CKB cell.\n *\n * @param props The arguments for destroying the cell.\n * @param props.client The client to communicate with CKB.\n * @param props.id The Type ID to destroy.\n * @param props.tx The transaction skeleton (optional).\n */\nexport async function destroyDidCkb(props: {\n client: ccc.Client;\n id: ccc.HexLike;\n tx?: ccc.TransactionLike | null;\n}): Promise<{\n tx: ccc.Transaction;\n index: number;\n}> {\n return OPERATIONS.destroy(props);\n}\n","import { ccc } from \"@ckb-ccc/core\";\n\nconst DID_PREFIX = \"did:ckb:\";\nconst ARGS_LEN_BYTES = 20;\nconst DID_BODY_LEN = 32;\n\n// RFC 4648 base32, lowercase, no padding (WIP-01 §2.2.3).\nconst ALPHABET = \"abcdefghijklmnopqrstuvwxyz234567\";\nconst REVERSE = (() => {\n const map: Record<string, number> = {};\n for (let i = 0; i < ALPHABET.length; i++) {\n map[ALPHABET[i]] = i;\n }\n return map;\n})();\n\nexport function base32Encode(bytes: ccc.BytesLike): string {\n const buf = ccc.bytesFrom(bytes);\n let bits = 0;\n let value = 0;\n let output = \"\";\n for (let i = 0; i < buf.length; i++) {\n value = (value << 8) | buf[i];\n bits += 8;\n while (bits >= 5) {\n output += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n if (bits > 0) {\n output += ALPHABET[(value << (5 - bits)) & 31];\n }\n return output;\n}\n\nexport function base32Decode(input: string): ccc.Bytes {\n const cleaned = input.toLowerCase().replace(/=+$/g, \"\");\n let bits = 0;\n let value = 0;\n const output: number[] = [];\n for (const char of cleaned) {\n const v = REVERSE[char];\n if (v === undefined) {\n throw new Error(`Invalid base32 character \"${char}\" in input`);\n }\n value = (value << 5) | v;\n bits += 5;\n if (bits >= 8) {\n output.push((value >>> (bits - 8)) & 0xff);\n bits -= 8;\n }\n }\n return Uint8Array.from(output);\n}\n\n/**\n * Convert 20-byte Type ID args (the `id` returned from `createDidCkb`) to a\n * `did:ckb:` identifier string per WIP-01 §2.2.\n */\nexport function argsToDid(args: ccc.HexLike): string {\n const bytes = ccc.bytesFrom(args);\n if (bytes.length !== ARGS_LEN_BYTES) {\n throw new Error(\n `did:ckb args must be ${ARGS_LEN_BYTES} bytes, got ${bytes.length}`,\n );\n }\n return DID_PREFIX + base32Encode(bytes);\n}\n\n/**\n * Reverse of `argsToDid`. Validates the prefix, base32 length, and decoded\n * byte count.\n */\nexport function didToArgs(did: string): ccc.Hex {\n if (!did.startsWith(DID_PREFIX)) {\n throw new Error(`Expected did:ckb:..., got \"${did}\"`);\n }\n const body = did.slice(DID_PREFIX.length);\n // 20 bytes encode to exactly 32 base32 chars without padding. Any other\n // length silently truncates leftover bits, so reject it up front.\n if (body.length !== DID_BODY_LEN) {\n throw new Error(\n `did:ckb identifier must be ${DID_BODY_LEN} base32 chars, got ${body.length}`,\n );\n }\n const bytes = base32Decode(body);\n if (bytes.length !== ARGS_LEN_BYTES) {\n throw new Error(\n `did:ckb identifier must decode to ${ARGS_LEN_BYTES} bytes, got ${bytes.length}`,\n );\n }\n return ccc.hexFrom(bytes);\n}\n\nexport function isDidCkb(value: string): boolean {\n if (!value.startsWith(DID_PREFIX)) {\n return false;\n }\n try {\n didToArgs(value);\n return true;\n } catch {\n return false;\n }\n}\n","import { ccc } from \"@ckb-ccc/core\";\nimport { DidCkbData } from \"./codec\";\nimport { argsToDid, didToArgs, isDidCkb } from \"./identifier\";\n\nexport type DidCkbRecord = {\n /** The `did:ckb:` string identifying this cell. */\n did: string;\n /** 20-byte Type ID args (same value `createDidCkb` returned as `id`). */\n id: ccc.Hex;\n /** Decoded DidCkbData; `.value.document` is the CBOR-decoded document. */\n data: DidCkbData;\n /** The live DID Metadata Cell itself. */\n cell: ccc.Cell;\n};\n\nasync function didCkbTypeScript(\n client: ccc.Client,\n id: ccc.HexLike,\n): Promise<ccc.Script> {\n const scriptInfo = await client.getKnownScript(ccc.KnownScript.DidCkb);\n return ccc.Script.from({\n codeHash: scriptInfo.codeHash,\n hashType: scriptInfo.hashType,\n args: id,\n });\n}\n\nfunction decodeRecord(cell: ccc.Cell, id: ccc.Hex): DidCkbRecord {\n return {\n did: argsToDid(id),\n id,\n data: DidCkbData.decode(cell.outputData),\n cell,\n };\n}\n\n/**\n * Find the live DID Metadata Cell for a given Type ID and decode its data.\n *\n * Returns `undefined` when no live cell exists (the DID was never created or\n * has been destroyed).\n */\nexport async function findDidCkbCell(props: {\n client: ccc.Client;\n id: ccc.HexLike;\n}): Promise<DidCkbRecord | undefined> {\n const id = ccc.hexFrom(props.id);\n const type = await didCkbTypeScript(props.client, id);\n const cell = await props.client.findSingletonCellByType(type, true);\n if (!cell) {\n return undefined;\n }\n return decodeRecord(cell, id);\n}\n\n/**\n * Resolve a `did:ckb:` string to its live cell + decoded document.\n *\n * Throws if `did` is not a syntactically valid did:ckb identifier. Returns\n * `undefined` if the DID was created and then destroyed, or never existed.\n */\nexport async function resolveDidCkb(props: {\n client: ccc.Client;\n did: string;\n}): Promise<DidCkbRecord | undefined> {\n if (!isDidCkb(props.did)) {\n throw new Error(`Not a did:ckb identifier: ${props.did}`);\n }\n return findDidCkbCell({ client: props.client, id: didToArgs(props.did) });\n}\n\n/**\n * List every live DID Metadata Cell owned by the given lock. Useful for\n * dashboards that want to enumerate the DIDs an address controls.\n *\n * Cells whose data fails to decode (e.g. a future on-chain schema version) are\n * skipped, not thrown, so a single bad cell can't break the whole listing.\n */\nexport async function listDidCkbsByLock(props: {\n client: ccc.Client;\n lock: ccc.ScriptLike;\n limit?: number;\n order?: \"asc\" | \"desc\";\n}): Promise<DidCkbRecord[]> {\n const scriptInfo = await props.client.getKnownScript(ccc.KnownScript.DidCkb);\n const records: DidCkbRecord[] = [];\n\n // Filter by type.codeHash + hashType (args is prefix-matched against \"0x\",\n // which matches any args). This is the standard indexer pattern for\n // \"any cell of this type, regardless of identifier\".\n for await (const cell of props.client.findCells(\n {\n script: ccc.Script.from(props.lock),\n scriptType: \"lock\",\n scriptSearchMode: \"exact\",\n filter: {\n script: ccc.Script.from({\n codeHash: scriptInfo.codeHash,\n hashType: scriptInfo.hashType,\n args: \"0x\",\n }),\n },\n withData: true,\n },\n props.order,\n props.limit,\n )) {\n const type = cell.cellOutput.type;\n if (!type) {\n continue;\n }\n const argsBytes = ccc.bytesFrom(type.args);\n if (argsBytes.length !== 20) {\n continue;\n }\n try {\n records.push(decodeRecord(cell, ccc.hexFrom(type.args)));\n } catch {\n // Skip unparseable cells rather than fail the whole listing.\n }\n }\n return records;\n}\n","import { ccc } from \"@ckb-ccc/core\";\nimport { DidCkbData } from \"./codec\";\nimport { didToArgs, isDidCkb } from \"./identifier\";\nimport { findDidCkbCell } from \"./resolver\";\n\nexport type HistoryAction = \"CREATE\" | \"UPDATE\" | \"MIGRATE\";\n\nexport type HistoryEntry = {\n /**\n * `CREATE` for a fresh mint, `MIGRATE` for a did:plc import (genesis cell\n * with a `localId` set), `UPDATE` for every subsequent transfer.\n */\n action: HistoryAction;\n txHash: ccc.Hex;\n outputIndex: ccc.Num;\n blockNumber?: ccc.Num;\n capacity: ccc.Num;\n data: DidCkbData;\n};\n\nconst DEFAULT_MAX_STEPS = 50;\n\n/**\n * Walk the DID cell chain backwards to produce the ordered list of operations\n * applied to a DID.\n *\n * Each `transferDidCkb` consumes the previous DID cell as an input and creates\n * a new one with the same Type ID args; the genesis (`createDidCkb` /\n * `createDidCkb` with localId) has no DID input. We start from the live cell,\n * read its tx, look for the prior DID cell among the inputs, and repeat. The\n * first entry returned is the newest (most recent transfer); the last is the\n * genesis.\n *\n * Cost: roughly one `getTransaction` call per step plus one `input.getCell`\n * lookup per non-DID input on each step. `input.getCell` goes through the\n * client's cell cache, so repeated walks over the same chain are cheap.\n *\n * @throws If an input cell lookup fails or the input cell is unavailable.\n * An unresolved input cannot establish that a transaction is the genesis.\n */\nexport async function getDidCkbHistory(props: {\n client: ccc.Client;\n /**\n * Either the 20-byte Type ID args hex returned by `createDidCkb`, or a\n * `did:ckb:` URI. URIs are converted via `didToArgs`.\n */\n id: ccc.HexLike | string;\n /** Pre-resolved live cell; if omitted, we fetch it. */\n liveCell?: ccc.Cell;\n /** Safety bound to prevent runaway walks. Default 50. */\n maxSteps?: number;\n}): Promise<HistoryEntry[]> {\n const id =\n typeof props.id === \"string\" && isDidCkb(props.id)\n ? didToArgs(props.id)\n : ccc.hexFrom(props.id);\n const scriptInfo = await props.client.getKnownScript(ccc.KnownScript.DidCkb);\n const codeHash = scriptInfo.codeHash.toLowerCase();\n const normalizedId = id.toLowerCase();\n\n let cell: ccc.Cell | undefined =\n props.liveCell ??\n (await findDidCkbCell({ client: props.client, id }))?.cell;\n if (!cell) {\n return [];\n }\n\n const history: HistoryEntry[] = [];\n const maxSteps = props.maxSteps ?? DEFAULT_MAX_STEPS;\n let steps = 0;\n\n while (cell && steps < maxSteps) {\n steps++;\n const tx = await props.client.getTransaction(cell.outPoint.txHash);\n if (!tx) {\n break;\n }\n\n const entry = decodeEntry(cell, tx.blockNumber);\n if (!entry) {\n break;\n }\n\n const prior = await findPriorDidCell(\n props.client,\n tx.transaction,\n codeHash,\n normalizedId,\n );\n\n if (!prior) {\n // No DID input means this tx is the genesis. If the genesis carries a\n // `localId` it's a did:plc migration; otherwise a plain CREATE.\n entry.action = entry.data.value.localId ? \"MIGRATE\" : \"CREATE\";\n history.push(entry);\n break;\n }\n\n entry.action = \"UPDATE\";\n history.push(entry);\n cell = prior;\n }\n\n return history;\n}\n\nasync function findPriorDidCell(\n client: ccc.Client,\n tx: ccc.TransactionLike,\n codeHash: string,\n id: string,\n): Promise<ccc.Cell | undefined> {\n const { inputs } = ccc.Transaction.from(tx);\n for (const input of inputs) {\n const cell = await input.getCell(client);\n const type = cell.cellOutput.type;\n if (!type) {\n continue;\n }\n if (type.codeHash.toLowerCase() !== codeHash) {\n continue;\n }\n if (ccc.hexFrom(type.args).toLowerCase() !== id) {\n continue;\n }\n return cell;\n }\n return undefined;\n}\n\nfunction decodeEntry(\n cell: ccc.Cell,\n blockNumber?: ccc.Num,\n): HistoryEntry | undefined {\n try {\n const data = DidCkbData.decode(cell.outputData);\n return {\n action: \"UPDATE\",\n txHash: cell.outPoint.txHash,\n outputIndex: cell.outPoint.index,\n blockNumber,\n capacity: cell.cellOutput.capacity,\n data,\n };\n } catch {\n return undefined;\n }\n}\n","import { ccc } from \"@ckb-ccc/core\";\nimport { DidCkbData, DidCkbDataLike, DidCkbWitness } from \"./codec\";\nimport { createDidCkb } from \"./didCkb\";\nimport {\n getRotationKeys,\n signRotationHash,\n type Curve,\n type PlcOperation,\n} from \"./plc\";\n\n/**\n * Build the migration witness payload that authorizes a did:plc -> did:ckb\n * import. Pure: takes a tx hash + signing material, returns a typed\n * `DidCkbWitness` that the caller wraps in a `WitnessArgs.outputType` field.\n *\n * Per WIP-02 §3.1.1 we send only the genesis operation in `history`. The\n * contract recomputes the genesis CID over the CBOR-encoded op, verifies the\n * self-signature inside it, then verifies `sig` against\n * `history[0].rotationKeys[rotationKeyIndex]`.\n *\n * `selfSigIndex` defaults to 0 because PLC genesis ops are conventionally\n * self-signed by the first rotation key; override if the genesis you're\n * migrating used a different one.\n */\nexport function buildMigrationWitness(props: {\n txHash: ccc.HexLike;\n genesisOperation: PlcOperation;\n rotationKeyIndex: number;\n rotationPrivateKey: ccc.BytesLike;\n curve?: Curve;\n selfSigIndex?: number;\n}): DidCkbWitness {\n const rotationKeys = getRotationKeys(props.genesisOperation);\n if (!rotationKeys[props.rotationKeyIndex]) {\n throw new Error(\n `rotationKeyIndex ${props.rotationKeyIndex} out of range (genesis has ${rotationKeys.length} keys)`,\n );\n }\n const curve = props.curve ?? rotationKeys[props.rotationKeyIndex].curve;\n const sig = signRotationHash(\n props.rotationPrivateKey,\n ccc.bytesFrom(props.txHash),\n curve,\n );\n return DidCkbWitness.from({\n localIdAuthorization: {\n history: [props.genesisOperation],\n sig: ccc.hexFrom(sig),\n rotationKeyIndices: [props.selfSigIndex ?? 0, props.rotationKeyIndex],\n },\n });\n}\n\n/**\n * Build a create tx whose output declares an imported did:plc identifier in\n * its `localId` field. Equivalent to calling `createDidCkb` with\n * `data.value.localId = sourceDid`; provided as a named helper for symmetry\n * with the other DID operations and so `did:plc:` migrations have an\n * obvious entry point.\n *\n * The caller is responsible for: completing inputs + fee, building the\n * migration witness with `buildMigrationWitness`, and setting it at the\n * witness slot of input 0. See `packages/examples/src/migrateDid.ts` for the\n * full flow.\n */\nexport async function migrateDidCkb(props: {\n signer: ccc.Signer;\n sourceDid: string;\n data?: DidCkbDataLike | null;\n receiver?: ccc.ScriptLike | null;\n tx?: ccc.TransactionLike | null;\n}): Promise<{\n tx: ccc.Transaction;\n id: ccc.Hex;\n index: number;\n}> {\n if (!props.sourceDid.startsWith(\"did:plc:\")) {\n throw new Error(`sourceDid must be did:plc:..., got \"${props.sourceDid}\"`);\n }\n\n const data = DidCkbData.from(\n props.data ?? {\n value: { document: {} },\n },\n );\n data.value.localId = props.sourceDid;\n return createDidCkb({\n signer: props.signer,\n data,\n receiver: props.receiver,\n tx: props.tx,\n });\n}\n","export * from \"./codec.js\";\nexport * from \"./didCkb.js\";\nexport * from \"./history.js\";\nexport * from \"./identifier.js\";\nexport * from \"./migrate.js\";\nexport * as plc from \"./plc/index.js\";\nexport * from \"./resolver.js\";\n"],"mappings":"A,ikBAwBO,IAAMkB,EAAA,EAAN,cAA2BC,EAAI,OAAO,KAG3C,CAAC,AAAC,CACF,YACE,EACA,EACA,CACA,MAAM,EAHC,KAAA,SAAAC,EACA,KAAA,QAAAC,CAGT,CAEA,OAAO,KAAK,EAAsC,CAKhD,OAJIC,aAAAR,EACKQ,EAGF,IAAAR,EAAiBQ,EAAK,SAAUA,EAAK,SAAW,IAAA,EAAS,CAClE,CACF,EAnCC,EAAA,EAAAjB,EAAA,CAAAc,EAAI,MACHA,EAAI,IACD,MAAM,CACL,SAAUA,EAAI,IAAI,MAClB,QAASA,EAAI,IAAI,SACnB,CAAC,CAAC,CACD,IAAI,CACH,MAAQ,IAA4B,CAClC,GAAGG,EACH,SAAUH,EAAI,QAAQnB,EAAWsB,EAAK,QAAQ,CAAC,CACjD,GACA,OAAS,IAAU,CACjB,GAAGA,EACH,SAAUrB,EAAWkB,EAAI,UAAUG,EAAK,QAAQ,CAAC,CACnD,EACF,CAAC,CACL,CAAA,EAAAJ,CAAA,EAqBA,MAAMO,EAAkBN,EAAI,IAAI,MAAM,CACpC,GAAID,CACN,CAAC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