gitmark 0.0.64 → 0.0.67

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.
Files changed (2) hide show
  1. package/bin/git-mark-list +20 -7
  2. package/package.json +1 -1
package/bin/git-mark-list CHANGED
@@ -83,10 +83,12 @@ function addCryptoToCommit(commit) {
83
83
 
84
84
  function renderCommit(commit, type) {
85
85
  if (!commit) return
86
+ commit.tags = commit.tags || []
87
+ if (commit.c) commit.tags.push(["c", commit.c])
86
88
  if (type === 'nostr') {
87
- var canon = [0, commit.pubkey, commit.authorDate, 17, [], commit.hash]
89
+ var canon = [0, commit.pubkey, commit.authorDate, 17, commit.tags, commit.hash]
88
90
 
89
- canon = JSON.stringify(canon)
91
+ canon = JSON.stringify(canon).replace(/\\"/g, '"')
90
92
  var id = sha256(canon)
91
93
 
92
94
  // console.log(canon)
@@ -102,7 +104,7 @@ function renderCommit(commit, type) {
102
104
  // console.log(sig)
103
105
  // var sig = 1
104
106
 
105
- var event = `["EVENT",{"id":"${id}","pubkey":"${commit.pubkey}","created_at":${commit.authorDate},"kind":${KIND_CODE},"tags":[],"content":"${commit.hash}","sig":"${sig}"}]`
107
+ var event = `["EVENT",{"id":"${id}","pubkey":"${commit.pubkey}","created_at":${commit.authorDate},"kind":${KIND_CODE},"tags":${JSON.stringify(commit.tags)},"content":"${commit.hash}","sig":"${sig}"}]`
106
108
 
107
109
  console.log(event)
108
110
  } else {
@@ -136,7 +138,10 @@ function getPrivKey() {
136
138
 
137
139
  // INIT
138
140
  data.privkey = argv._[0] || getPrivKey() || data.privkey
141
+ data.g = argv.g
139
142
  data.count = argv.count
143
+ data.genesis = argv.genesis
144
+ data.created_at = argv.created
140
145
 
141
146
  var POINT = Buffer.from(data.privkey, 'hex')
142
147
 
@@ -152,17 +157,20 @@ var b3
152
157
 
153
158
 
154
159
  // genesis
155
- var genesis = require('../gitmark.json')
156
160
  var genesisCommit = {
157
161
  "hash": "genesis",
158
- "authorDate": genesis.created_at,
159
- "privkey": b1.toString(16)
162
+ "authorDate": data.created_at,
163
+ "privkey": b1.toString(16),
164
+ "c": data.genesis,
160
165
  }
161
166
  var keyPair1 = bitcoin.ECPair.fromPrivateKey(
162
167
  Buffer.from(b1.toString(16), 'hex'),
163
168
  { network: BITMARK }
164
169
  )
165
170
  genesisCommit.pubkey = buf2hex(keyPair1.publicKey).substring(2)
171
+ if (data.g) {
172
+ genesisCommit.tags = [["g", data.g]]
173
+ }
166
174
 
167
175
 
168
176
  // console.log('genesis', genesis)
@@ -192,8 +200,13 @@ for (var i = commits.length - 1; i >= 0; i--) {
192
200
  hash: commits[i + 1]?.hash,
193
201
  subject: commits[i].subject,
194
202
  authorDate: Math.floor(new Date(commits[i].authorDate).getTime() / 1000),
195
- privkey: b1.toString(16)
203
+ privkey: b1.toString(16),
204
+ c: commits[i].subject
205
+ }
206
+ if (commit.c && commit.c.split(":").length <= 2) {
207
+ commit.c = commit.c + ':0'
196
208
  }
209
+ commit.c = commit?.c?.replace('gitmark ', 'gitmark:')
197
210
  commit = addCryptoToCommit(commit)
198
211
  // console.log(commit)
199
212
  gitmarks.push(commit)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitmark",
3
- "version": "0.0.64",
3
+ "version": "0.0.67",
4
4
  "description": "gitmark",
5
5
  "main": "index.js",
6
6
  "scripts": {