@ceramicnetwork/streamid 2.3.2-rc.0 → 2.3.3
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/README.md +129 -129
- package/lib/commit-id.d.ts +0 -0
- package/lib/commit-id.d.ts.map +0 -0
- package/lib/commit-id.js +0 -0
- package/lib/commit-id.js.map +0 -0
- package/lib/constants.d.ts +0 -0
- package/lib/constants.d.ts.map +0 -0
- package/lib/constants.js +0 -0
- package/lib/constants.js.map +0 -0
- package/lib/index.d.ts +0 -0
- package/lib/index.d.ts.map +0 -0
- package/lib/index.js +0 -0
- package/lib/index.js.map +0 -0
- package/lib/reading-bytes.d.ts +0 -0
- package/lib/reading-bytes.d.ts.map +0 -0
- package/lib/reading-bytes.js +0 -0
- package/lib/reading-bytes.js.map +0 -0
- package/lib/stream-id.d.ts +0 -0
- package/lib/stream-id.d.ts.map +0 -0
- package/lib/stream-id.js +0 -0
- package/lib/stream-id.js.map +0 -0
- package/lib/stream-ref.d.ts +0 -0
- package/lib/stream-ref.d.ts.map +0 -0
- package/lib/stream-ref.js +0 -0
- package/lib/stream-ref.js.map +0 -0
- package/lib/stream-type.d.ts +0 -0
- package/lib/stream-type.d.ts.map +0 -0
- package/lib/stream-type.js +0 -0
- package/lib/stream-type.js.map +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
# Ceramic StreamID
|
|
2
|
-

|
|
3
|
-
[](https://lbesson.mit-license.org/)
|
|
4
|
-
[](https://discord.gg/6VRZpGP)
|
|
5
|
-
[](https://twitter.com/ceramicnetwork)
|
|
6
|
-
|
|
7
|
-
> This package contains Ceramic StreamID and CommitID implementation.
|
|
8
|
-
|
|
9
|
-
Implements Ceramic streamIDs as defined in ceramic spec and [CIP](https://github.com/ceramicnetwork/CIP/blob/master/CIPs/CIP-59/CIP-59.md),
|
|
10
|
-
represented as StreamID and CommitID for API clarity.
|
|
11
|
-
|
|
12
|
-
StreamID represents a reference to a stream as a whole, thus does not contain commit information.
|
|
13
|
-
|
|
14
|
-
CommitID represents a reference to a particular commit in the stream evolution.
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
<streamid> ::= <multibase-prefix><multicodec-streamid><type><genesis-cid-bytes>
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
or including StreamID commit
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
<streamid> ::= <multibase-prefix><multicodec-streamid><type><genesis-cid-bytes><commit-cid-bytes>
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Getting started
|
|
27
|
-
|
|
28
|
-
### Installation
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
$ npm install @ceramicnetwork/streamid
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Usage
|
|
35
|
-
|
|
36
|
-
See the [ceramic developer site](https://developers.ceramic.network/) for more details about how to use this package.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
To reference a stream as a whole, use `StreamID`. You can create an instance from the parts. stream type string or integer and CID instance or string are required.
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import { StreamID } from '@ceramicnetwork/streamid';
|
|
43
|
-
|
|
44
|
-
const streamid = new StreamID('tile', 'bagcqcerakszw2vsov...');
|
|
45
|
-
|
|
46
|
-
streamid.type; // 0
|
|
47
|
-
streamid.typeName; // 'tile'
|
|
48
|
-
streamid.bytes; // Uint8Array(41) [ 206, 1, 0, 0, 1, 133, 1, ...]
|
|
49
|
-
streamid.cid; // CID('bagcqcerakszw2vsov...')
|
|
50
|
-
streamid.toString();
|
|
51
|
-
//k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws
|
|
52
|
-
streamid.toUrl();
|
|
53
|
-
//ceramic://k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
You can also create StreamID instance from StreamID string or bytes.
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
const streamid = StreamID.fromString('k3y52l7mkcvtg023bt9txe...');
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
const streamid = StreamID.fromBytes(Uint8Array(41) [ 206, 1, 0, 0, 1, 133, 1, ...])
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
To reference particular point in a stream evolution, use `CommitID`.
|
|
67
|
-
In addition to stream type (string or integer) and genesis reference (CID instance or string),
|
|
68
|
-
one is expected to provide a reference to commit (CID instance or string). If you pass `0` or `'0'` (as string), `null`
|
|
69
|
-
or just omit the value, this would reference a genesis commit.
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
import { CommitID } from '@ceramicnetwork/streamid';
|
|
73
|
-
|
|
74
|
-
const commitId = new CommitID('tile', 'bagcqcerakszw2vsov...', 'bagcqcerakszw2vsov...');
|
|
75
|
-
|
|
76
|
-
commitId.type; // 0
|
|
77
|
-
commitId.typeName; // 'tile'
|
|
78
|
-
commitId.bytes; // Uint8Array(41) [ 206, 1, 0, 0, 1, 133, 1, ...]
|
|
79
|
-
commitId.cid; // CID('bagcqcerakszw2vsov...')
|
|
80
|
-
commitId.commit; // CID('bagcqcerakszw2vsov...')
|
|
81
|
-
|
|
82
|
-
commitId.toString();
|
|
83
|
-
// k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws
|
|
84
|
-
commitId.toUrl();
|
|
85
|
-
// ceramic://k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws?version=k3y52l7mkcvt...
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
To reference specific CID from `StreamID` or to change commit reference in `CommitID`, use `atCommit` method:
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
commitId.atCommit('bagcqcerakszw2vsov...'); // #=> new CommitID for the same stream
|
|
92
|
-
streamId.atCommit('bagcqcerakszw2vsov...'); // #=> new CommitID for the same stream
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
`CommitID` (`StreamID` for compatibility also) can get you base `StreamID` via `#baseID`:
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
commitId.baseID; // #=> StreamID reference to the stream
|
|
99
|
-
streamId.baseID; // #=> new StreamID reference to the same stream, effectively a shallow clone.
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
To parse an unknown input into proper CommitID or StreamID, you could use `streamRef.from`:
|
|
103
|
-
```typescript
|
|
104
|
-
import { streamRef } from '@ceramicnetwork/streamid';
|
|
105
|
-
const input = 'bagcqcerakszw2vsov...' // could be instance of Uint8Array, StreamID, CommitID either; or in URL form
|
|
106
|
-
const streamIdOrCommitId = streamRef.from(input) // throws if can not properly parse it into CommitID or StreamID
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## Development
|
|
110
|
-
|
|
111
|
-
Run tests:
|
|
112
|
-
|
|
113
|
-
```shell
|
|
114
|
-
npm test
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Run linter:
|
|
118
|
-
|
|
119
|
-
```shell
|
|
120
|
-
npm run lint
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## Contributing
|
|
124
|
-
|
|
125
|
-
We are happy to accept small and large contributions. Make sure to check out the [Ceramic specifications](https://github.com/ceramicnetwork/ceramic/blob/main/SPECIFICATION.md) for details of how the protocol works.
|
|
126
|
-
|
|
127
|
-
## License
|
|
128
|
-
|
|
129
|
-
MIT or Apache-2.0
|
|
1
|
+
# Ceramic StreamID
|
|
2
|
+

|
|
3
|
+
[](https://lbesson.mit-license.org/)
|
|
4
|
+
[](https://discord.gg/6VRZpGP)
|
|
5
|
+
[](https://twitter.com/ceramicnetwork)
|
|
6
|
+
|
|
7
|
+
> This package contains Ceramic StreamID and CommitID implementation.
|
|
8
|
+
|
|
9
|
+
Implements Ceramic streamIDs as defined in ceramic spec and [CIP](https://github.com/ceramicnetwork/CIP/blob/master/CIPs/CIP-59/CIP-59.md),
|
|
10
|
+
represented as StreamID and CommitID for API clarity.
|
|
11
|
+
|
|
12
|
+
StreamID represents a reference to a stream as a whole, thus does not contain commit information.
|
|
13
|
+
|
|
14
|
+
CommitID represents a reference to a particular commit in the stream evolution.
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
<streamid> ::= <multibase-prefix><multicodec-streamid><type><genesis-cid-bytes>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
or including StreamID commit
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
<streamid> ::= <multibase-prefix><multicodec-streamid><type><genesis-cid-bytes><commit-cid-bytes>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Getting started
|
|
27
|
+
|
|
28
|
+
### Installation
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
$ npm install @ceramicnetwork/streamid
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Usage
|
|
35
|
+
|
|
36
|
+
See the [ceramic developer site](https://developers.ceramic.network/) for more details about how to use this package.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
To reference a stream as a whole, use `StreamID`. You can create an instance from the parts. stream type string or integer and CID instance or string are required.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { StreamID } from '@ceramicnetwork/streamid';
|
|
43
|
+
|
|
44
|
+
const streamid = new StreamID('tile', 'bagcqcerakszw2vsov...');
|
|
45
|
+
|
|
46
|
+
streamid.type; // 0
|
|
47
|
+
streamid.typeName; // 'tile'
|
|
48
|
+
streamid.bytes; // Uint8Array(41) [ 206, 1, 0, 0, 1, 133, 1, ...]
|
|
49
|
+
streamid.cid; // CID('bagcqcerakszw2vsov...')
|
|
50
|
+
streamid.toString();
|
|
51
|
+
//k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws
|
|
52
|
+
streamid.toUrl();
|
|
53
|
+
//ceramic://k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
You can also create StreamID instance from StreamID string or bytes.
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const streamid = StreamID.fromString('k3y52l7mkcvtg023bt9txe...');
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
const streamid = StreamID.fromBytes(Uint8Array(41) [ 206, 1, 0, 0, 1, 133, 1, ...])
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
To reference particular point in a stream evolution, use `CommitID`.
|
|
67
|
+
In addition to stream type (string or integer) and genesis reference (CID instance or string),
|
|
68
|
+
one is expected to provide a reference to commit (CID instance or string). If you pass `0` or `'0'` (as string), `null`
|
|
69
|
+
or just omit the value, this would reference a genesis commit.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { CommitID } from '@ceramicnetwork/streamid';
|
|
73
|
+
|
|
74
|
+
const commitId = new CommitID('tile', 'bagcqcerakszw2vsov...', 'bagcqcerakszw2vsov...');
|
|
75
|
+
|
|
76
|
+
commitId.type; // 0
|
|
77
|
+
commitId.typeName; // 'tile'
|
|
78
|
+
commitId.bytes; // Uint8Array(41) [ 206, 1, 0, 0, 1, 133, 1, ...]
|
|
79
|
+
commitId.cid; // CID('bagcqcerakszw2vsov...')
|
|
80
|
+
commitId.commit; // CID('bagcqcerakszw2vsov...')
|
|
81
|
+
|
|
82
|
+
commitId.toString();
|
|
83
|
+
// k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws
|
|
84
|
+
commitId.toUrl();
|
|
85
|
+
// ceramic://k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws?version=k3y52l7mkcvt...
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
To reference specific CID from `StreamID` or to change commit reference in `CommitID`, use `atCommit` method:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
commitId.atCommit('bagcqcerakszw2vsov...'); // #=> new CommitID for the same stream
|
|
92
|
+
streamId.atCommit('bagcqcerakszw2vsov...'); // #=> new CommitID for the same stream
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`CommitID` (`StreamID` for compatibility also) can get you base `StreamID` via `#baseID`:
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
commitId.baseID; // #=> StreamID reference to the stream
|
|
99
|
+
streamId.baseID; // #=> new StreamID reference to the same stream, effectively a shallow clone.
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
To parse an unknown input into proper CommitID or StreamID, you could use `streamRef.from`:
|
|
103
|
+
```typescript
|
|
104
|
+
import { streamRef } from '@ceramicnetwork/streamid';
|
|
105
|
+
const input = 'bagcqcerakszw2vsov...' // could be instance of Uint8Array, StreamID, CommitID either; or in URL form
|
|
106
|
+
const streamIdOrCommitId = streamRef.from(input) // throws if can not properly parse it into CommitID or StreamID
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
Run tests:
|
|
112
|
+
|
|
113
|
+
```shell
|
|
114
|
+
npm test
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Run linter:
|
|
118
|
+
|
|
119
|
+
```shell
|
|
120
|
+
npm run lint
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Contributing
|
|
124
|
+
|
|
125
|
+
We are happy to accept small and large contributions. Make sure to check out the [Ceramic specifications](https://github.com/ceramicnetwork/ceramic/blob/main/SPECIFICATION.md) for details of how the protocol works.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
MIT or Apache-2.0
|
package/lib/commit-id.d.ts
CHANGED
|
File without changes
|
package/lib/commit-id.d.ts.map
CHANGED
|
File without changes
|
package/lib/commit-id.js
CHANGED
|
File without changes
|
package/lib/commit-id.js.map
CHANGED
|
File without changes
|
package/lib/constants.d.ts
CHANGED
|
File without changes
|
package/lib/constants.d.ts.map
CHANGED
|
File without changes
|
package/lib/constants.js
CHANGED
|
File without changes
|
package/lib/constants.js.map
CHANGED
|
File without changes
|
package/lib/index.d.ts
CHANGED
|
File without changes
|
package/lib/index.d.ts.map
CHANGED
|
File without changes
|
package/lib/index.js
CHANGED
|
File without changes
|
package/lib/index.js.map
CHANGED
|
File without changes
|
package/lib/reading-bytes.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/reading-bytes.js
CHANGED
|
File without changes
|
package/lib/reading-bytes.js.map
CHANGED
|
File without changes
|
package/lib/stream-id.d.ts
CHANGED
|
File without changes
|
package/lib/stream-id.d.ts.map
CHANGED
|
File without changes
|
package/lib/stream-id.js
CHANGED
|
File without changes
|
package/lib/stream-id.js.map
CHANGED
|
File without changes
|
package/lib/stream-ref.d.ts
CHANGED
|
File without changes
|
package/lib/stream-ref.d.ts.map
CHANGED
|
File without changes
|
package/lib/stream-ref.js
CHANGED
|
File without changes
|
package/lib/stream-ref.js.map
CHANGED
|
File without changes
|
package/lib/stream-type.d.ts
CHANGED
|
File without changes
|
package/lib/stream-type.d.ts.map
CHANGED
|
File without changes
|
package/lib/stream-type.js
CHANGED
|
File without changes
|
package/lib/stream-type.js.map
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ceramicnetwork/streamid",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"description": "Ceramic Stream Ids",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ceramic",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "528fa95d4a59c9325f780d1acd0ba3c84eb23d9c"
|
|
43
43
|
}
|