Skip to content

Commit 2da5f2f

Browse files
committed
Update to new ID format
* Update all dependencies * Don't save Item create/update response in DB * Update references to old ID format
1 parent d8d628b commit 2da5f2f

File tree

6 files changed

+59
-77
lines changed

6 files changed

+59
-77
lines changed

import_map.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
22
"imports": {
3-
"@truestamp/id": "https://esm.sh/v94/@truestamp/[email protected]",
4-
"@truestamp/truestamp-js": "https://esm.sh/v94/@truestamp/[email protected]",
5-
"@truestamp/verify": "https://esm.sh/v94/@truestamp/[email protected]",
6-
"dotenv": "https://esm.sh/v94/[email protected]",
7-
"dotenv/": "https://esm.sh/v94/[email protected]/",
3+
"@truestamp/id": "https://esm.sh/v94/@truestamp/[email protected]",
4+
"@truestamp/truestamp-js": "https://esm.sh/v94/@truestamp/[email protected]",
5+
"@truestamp/verify": "https://esm.sh/v94/@truestamp/[email protected]",
6+
"dotenv": "https://esm.sh/v94/[email protected]",
7+
"dotenv/": "https://esm.sh/v94/[email protected]/",
8+
"dotenv/@16.0": "https://esm.sh/v94/[email protected]/@16.0",
89
"zod": "https://esm.sh/v94/[email protected]",
9-
"zod/": "https://esm.sh/v94/[email protected]/"
10+
"zod/": "https://esm.sh/v94/[email protected]/",
11+
"zod/@3.19": "https://esm.sh/v94/[email protected]/@3.19"
1012
},
1113
"scopes": {
1214
"zod": {},

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const outputType = new EnumType(["silent", "text", "json"])
2424
const cmd = new Command()
2525
.throwErrors()
2626
.name("truestamp")
27-
.version("0.0.21") // RELEASE VERSION : BUMP VERSION HERE
27+
.version("0.0.22") // RELEASE VERSION : BUMP VERSION HERE
2828
.description("Truestamp CLI")
2929
.meta("deno", Deno.version.deno)
3030
.meta("v8", Deno.version.v8)

src/commands/commitments.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const commitmentsRead = new Command<{
2929
"Read a Commitment",
3030
`Using a previously generated test Item ID:
3131
32-
$ truestamp commitments read --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw
32+
$ truestamp commitments read --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy
3333
3434
`
3535
)
@@ -80,7 +80,7 @@ const commitmentsVerify = new Command<{
8080
8181
All cryptographic operations, and on-chain verifications, performed via API server by default:
8282
83-
$ truestamp commitments verify --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw
83+
$ truestamp commitments verify --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy
8484
8585
`
8686
)
@@ -94,7 +94,7 @@ Verified public keys will be retrieved from https://keys.truestamp.com.
9494
9595
HTTP request to third-party blockchain API servers will originate from this local client.
9696
97-
$ truestamp commitments verify --local --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw
97+
$ truestamp commitments verify --local --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy
9898
9999
`
100100
)

src/commands/items.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,7 @@ Pipe JSON content to the 'items create' command using '--input json' plus the '-
329329
const { id } = data
330330

331331
// store the item in the local database
332-
writeItemToDb(options.env, id, itemResp)
333-
334-
// console.log(getItemHashById(getEnv(options), itemResp.id));
332+
writeItemToDb(options.env, id)
335333

336334
// If a path or STDIN was provided it is helpful to archive the contents of the file
337335
// and tightly associate it with the returned Item Id/envelope.
@@ -444,7 +442,7 @@ See the example sections below for detailed usage examples.
444442
$ echo -n 'Hello World Again' | sha256sum
445443
63df103e8ebcabdf86d8f13e98a02063fef1da8065335ec0dd978378951534d6 -
446444
447-
$ truestamp items update --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw --hash 63df103e8ebcabdf86d8f13e98a02063fef1da8065335ec0dd978378951534d6 --hash-type sha-256
445+
$ truestamp items update --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy --hash 63df103e8ebcabdf86d8f13e98a02063fef1da8065335ec0dd978378951534d6 --hash-type sha-256
448446
449447
`
450448
)
@@ -454,19 +452,19 @@ See the example sections below for detailed usage examples.
454452
455453
Pipe content to the 'items update' command using the '--stdin' option or the '-' path:
456454
457-
$ echo -n 'Hello World' | truestamp items update --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw --input binary -
458-
$ echo -n "Hello World" | truestamp items update --stdin --input binary --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw
455+
$ echo -n 'Hello World' | truestamp items update --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy --input binary -
456+
$ echo -n "Hello World" | truestamp items update --stdin --input binary --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy
459457
460-
$ cat hello.txt | truestamp items update --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw --input binary -
461-
$ cat hello.txt | truestamp items update --stdin --input binary --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw
458+
$ cat hello.txt | truestamp items update --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy --input binary -
459+
$ cat hello.txt | truestamp items update --stdin --input binary --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy
462460
463461
`
464462
)
465463
.example(
466464
"FILE Path",
467465
`Pass an '--id' and a file path to the 'items update' command:
468466
469-
$ truestamp items update --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw --input binary hello.txt
467+
$ truestamp items update --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy --input binary hello.txt
470468
471469
`
472470
)
@@ -476,22 +474,22 @@ Pipe content to the 'items update' command using the '--stdin' option or the '-'
476474
477475
Pipe JSON content to the 'items update' command using '--input json' plus the '--stdin' option or the '-' path:
478476
479-
$ echo -n '{"hash": "63df103e8ebcabdf86d8f13e98a02063fef1da8065335ec0dd978378951534d6", "hashType": "sha-256"}' | truestamp items update --input json --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw -
480-
$ echo -n '{"hash": "63df103e8ebcabdf86d8f13e98a02063fef1da8065335ec0dd978378951534d6", "hashType": "sha-256"}' | truestamp items update --input json --stdin --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw
477+
$ echo -n '{"hash": "63df103e8ebcabdf86d8f13e98a02063fef1da8065335ec0dd978378951534d6", "hashType": "sha-256"}' | truestamp items update --input json --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy -
478+
$ echo -n '{"hash": "63df103e8ebcabdf86d8f13e98a02063fef1da8065335ec0dd978378951534d6", "hashType": "sha-256"}' | truestamp items update --input json --stdin --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy
481479
482480
# Can be full complexity JSON Item data
483481
$ echo -n '{"hash": "63df103e8ebcabdf86d8f13e98a02063fef1da8065335ec0dd978378951534d6", "hashType": "sha-256"}' > hello.json
484482
485-
$ cat hello.json | truestamp items update --input json --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw -
486-
$ cat hello.json | truestamp items update --input json --stdin --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw
483+
$ cat hello.json | truestamp items update --input json --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy -
484+
$ cat hello.json | truestamp items update --input json --stdin --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy
487485
488486
`
489487
)
490488
.example(
491489
"JSON FILE Path",
492490
`Pass the '--input json' option and a file path argument to the 'items update' command:
493491
494-
$ truestamp items update --input json --id truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw hello.json
492+
$ truestamp items update --input json --id ts_11SHyexF6pqKpTgvnxu5UvHveboF763B41JsZCYcjveSNgqXnL2k7K4LrUuy hello.json
495493
496494
`
497495
)
@@ -617,7 +615,7 @@ Pipe JSON content to the 'items update' command using '--input json' plus the '-
617615
const { id } = data
618616

619617
// store the item in the local database
620-
writeItemToDb(options.env, id, itemResp)
618+
writeItemToDb(options.env, id)
621619

622620
logSelectedOutputFormat({ text: id, json: { id: id } }, options.output)
623621
})

src/db.ts

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright © 2020-2022 Truestamp Inc. All rights reserved.
22

3-
import { appPaths, DB, Row } from "./deps.ts"
3+
import { appPaths, DB } from "./deps.ts"
44

55
import { decodeUnsafely } from "@truestamp/id"
66

@@ -11,30 +11,24 @@ export function createDataDir(env: string): string {
1111
return appDir.data
1212
}
1313

14-
export function writeItemToDb(
15-
env: string,
16-
id: string,
17-
// deno-lint-ignore no-explicit-any
18-
envelope: Record<string, any>
19-
): void {
14+
export function writeItemToDb(env: string, id: string): void {
2015
const dbDir = createDataDir(env)
2116
// console.log(`${dbDir}/db.sqlite3`)
2217
const db = new DB(`${dbDir}/db.sqlite3`)
2318

2419
db.query(`
2520
CREATE TABLE IF NOT EXISTS items (
2621
id TEXT NOT NULL UNIQUE PRIMARY KEY,
27-
id_json TEXT NOT NULL,
28-
envelope_json TEXT NOT NULL
22+
id_json TEXT NOT NULL
2923
)
3024
`)
3125

3226
const decodedId = decodeUnsafely(id)
3327

34-
db.query(
35-
"INSERT INTO items (id, id_json, envelope_json) VALUES (?, json(?), json(?))",
36-
[id, JSON.stringify(decodedId), JSON.stringify(envelope)]
37-
)
28+
db.query("INSERT INTO items (id, id_json) VALUES (?, json(?))", [
29+
id,
30+
JSON.stringify(decodedId),
31+
])
3832

3933
// // Print out data in table
4034
// for (const [id] of db.query("SELECT id FROM items")) {
@@ -45,34 +39,22 @@ CREATE TABLE IF NOT EXISTS items (
4539
}
4640

4741
// See : https://stackoverflow.com/questions/33432421/sqlite-json1-example-for-json-extract-set
42+
// e.g. sqlite3 "/Users/glenn/Library/Application Support/com.truestamp.cli.development/db.sqlite3"
4843
// sqlite> select json_extract(items.id_json, '$.ulid') from items;
49-
// 01GABY7BPZTMW0J7SA8DGR2JAZ
50-
51-
// sqlite> select i.* from items i where json_extract(id_json, '$.ulid') LIKE '01GABY7BPZTMW0J7SA8DGR2JAZ';
52-
// truestamp-2SF5JQLhBHmtRC35G6z4M7bjhcnJrGs99nEg6reqW61ThzXLx1pzk3VXjNQsw|{"test":true,"ulid":"01FZV53XYHS0AWTHT8G8STSB93","timestamp":1649105041590000}|{"hash":"47ccf5f773af45059af050cfdfafcbc36ca9b4a81ad5fafc516334b199804299","hashType":"sha-256","data":{"hash":"72ef467524c22a2d17607ad7a818c30ce17d21d51b8a8ef0b36c0f2c4e2b679b","hashType":"sha-256","type":"item","request":{"type":"item_req_props","asn":701,"colo":"IAD","country":"US","city":"Ashburn","continent":"NA","latitude":"39.01800","longitude":"-77.53900","postalCode":"20147","metroCode":"511","region":"Virginia","regionCode":"VA","timezone":"America/New_York"},"observableEntropy":"bc137c5569cdd1910dd227a574a38d30689c9806d9ca9af740f7a387c1e1a96d"},"signatures":[{"type":"signature","publicKey":"Qrx1usC1HsvSNNuod9HM7eVc93p9n5Zt9Rd_v1YnBr0=","signature":"qTN_IWnaw_6G0AsB_W68BUntk_hfvdJWTPILndOhUAUo-m5_yYdwpgXJnYHFR57LQbflELQH0iNjjt5TPy8WDQ==","signatureType":"ed25519","signer":{"type":"person","organizationName":"Truestamp Inc.","email":"[email protected]","uri":"https://www.truestamp.com"}}],"id":"T11_01FZV53XYHS0AWTHT8G8STSB93_1649105041590000_3B3F3607558F8590ABA6AE6B9D579E8F","timestamp":"2022-04-04T20:44:01.590+00:00","type":"envelope"}
53-
54-
// sqlite> SELECT json_extract(items.envelope_json, '$.data.hash') FROM items WHERE json_extract(id_json, '$.ulid') LIKE '01FZV53XYHS0AWTHT8G8STSB93';
55-
// 72ef467524c22a2d17607ad7a818c30ce17d21d51b8a8ef0b36c0f2c4e2b679b
56-
// 72ef467524c22a2d17607ad7a818c30ce17d21d51b8a8ef0b36c0f2c4e2b679b
57-
58-
export function getItemEnvelopesByUlid(env: string, ulid: string): Row[] {
59-
const dbDir = createDataDir(env)
60-
const db = new DB(`${dbDir}/db.sqlite3`)
61-
const result = db.query(
62-
"SELECT envelope_json FROM items WHERE json_extract(id_json, '$.ulid') IS ?",
63-
[ulid]
64-
)
65-
db.close()
66-
return result
67-
}
68-
69-
export function getItemHashById(env: string, id: string): Row[] {
70-
const dbDir = createDataDir(env)
71-
const db = new DB(`${dbDir}/db.sqlite3`)
72-
const result = db.query(
73-
"SELECT json_extract(items.envelope_json, '$.data.hash') FROM items WHERE id IS ?;",
74-
[id]
75-
)
76-
db.close()
77-
return result
78-
}
44+
// 01GFW799RWQ03ZHCBFQK7EDZ5N
45+
// sqlite> select i.* from items i where json_extract(id_json, '$.ulid') LIKE '01GFW799RWQ03ZHCBFQK7EDZ5N';
46+
// ts_11SHzvRaFSVkLu4qpcDx4Aqxrg6dsxHTDcMhrjH1dYbGkfdAWxHenuNa2uVo|{"test":false,"timestamp":"1666320738370000","ulid":"01GFW799RWQ03ZHCBFQK7EDZ5N"}
47+
// sqlite> SELECT json_extract(items.id_json, '$.timestamp') FROM items WHERE json_extract(id_json, '$.ulid') LIKE '01GFW799RWQ03ZHCBFQK7EDZ5N';
48+
// 1666320738370000
49+
// sqlite>
50+
51+
// export function getItemEnvelopesByUlid(env: string, ulid: string): Row[] {
52+
// const dbDir = createDataDir(env)
53+
// const db = new DB(`${dbDir}/db.sqlite3`)
54+
// const result = db.query(
55+
// "SELECT envelope_json FROM items WHERE json_extract(id_json, '$.ulid') IS ?",
56+
// [ulid]
57+
// )
58+
// db.close()
59+
// return result
60+
// }

src/deps.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
// Copyright © 2020-2022 Truestamp Inc. All rights reserved.
22

3-
import { crypto } from "https://deno.land/std@0.155.0/crypto/mod.ts"
4-
import { parse } from "https://deno.land/std@0.155.0/path/mod.ts"
3+
import { crypto } from "https://deno.land/std@0.160.0/crypto/mod.ts"
4+
import { parse } from "https://deno.land/std@0.160.0/path/mod.ts"
55
import {
66
copy,
77
readAllSync,
8-
} from "https://deno.land/std@0.155.0/streams/conversion.ts"
8+
} from "https://deno.land/std@0.160.0/streams/conversion.ts"
99

1010
import { sleep } from "https://deno.land/x/[email protected]/mod.ts"
1111

1212
import { decode, validate } from "https://deno.land/x/[email protected]/mod.ts"
1313

1414
import { DB } from "https://deno.land/x/[email protected]/mod.ts"
1515

16-
import { colors } from "https://deno.land/x/[email protected].1/ansi/colors.ts"
17-
import { CompletionsCommand } from "https://deno.land/x/[email protected].1/command/completions/mod.ts"
18-
import { HelpCommand } from "https://deno.land/x/[email protected].1/command/help/mod.ts"
16+
import { colors } from "https://deno.land/x/[email protected].2/ansi/colors.ts"
17+
import { CompletionsCommand } from "https://deno.land/x/[email protected].2/command/completions/mod.ts"
18+
import { HelpCommand } from "https://deno.land/x/[email protected].2/command/help/mod.ts"
1919
import {
2020
Command,
2121
EnumType,
2222
ValidationError,
23-
} from "https://deno.land/x/[email protected].1/command/mod.ts"
23+
} from "https://deno.land/x/[email protected].2/command/mod.ts"
2424

2525
import Conf from "https://raw.githubusercontent.com/truestamp/deno-conf/v1.0.6/mod.ts"
2626

@@ -42,9 +42,9 @@ import {
4242

4343
import { createTruestampClient } from "./truestamp.ts"
4444

45-
import { Table } from "https://deno.land/x/[email protected].1/table/mod.ts"
45+
import { Table } from "https://deno.land/x/[email protected].2/table/mod.ts"
4646

47-
export type { ITypeInfo } from "https://deno.land/x/[email protected].1/flags/mod.ts"
47+
export type { ITypeInfo } from "https://deno.land/x/[email protected].2/flags/mod.ts"
4848
export type { Payload } from "https://deno.land/x/[email protected]/mod.ts"
4949
export type { Row } from "https://deno.land/x/[email protected]/mod.ts"
5050
export type {

0 commit comments

Comments
 (0)