Add mintsturdyref
Formally a utility hidden in the syndicate/capabilities module.
This commit is contained in:
parent
fe7b0f469d
commit
c08ed920b5
|
@ -10,6 +10,10 @@ Utility to communicate with sockets that send and receive lines of JSON using `<
|
|||
|
||||
Do not send messages immediately to the dataspace passed `json_socket_translator`, wait until it asserts `<connected @socketPath string>`.
|
||||
|
||||
## mintsturdyref
|
||||
|
||||
A utility for minting [Sturdyrefs](https://synit.org/book/operation/builtin/gatekeeper.html#sturdyrefs).
|
||||
|
||||
## msg
|
||||
|
||||
A utility that sends a message to `$SYNDICATE_SOCK` in the form `<ARGV0 ARG1 … ARGVn>`.
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
from os import commandLineParams
|
||||
import preserves, syndicate/capabilities
|
||||
|
||||
const usage = """
|
||||
mintsturdyref OID < SECRET_KEY
|
||||
|
||||
Mint Sturdyrefs using a sixteen-byte secret key read from stdin using OIDs
|
||||
passed as command-line parameters.
|
||||
|
||||
Example:
|
||||
mintsturdyref '"syndicate"' < /dev/null
|
||||
|
||||
See:
|
||||
https://synit.org/book/operation/builtin/gatekeeper.html#sturdyrefs
|
||||
https://synit.org/book/glossary.html?highlight=oid#oid
|
||||
"""
|
||||
|
||||
proc main =
|
||||
var oids: seq[Preserve[void]]
|
||||
for p in commandLineParams():
|
||||
case p
|
||||
of "-h", "--help", "?":
|
||||
quit(usage)
|
||||
else:
|
||||
add(oids, parsePreserves p)
|
||||
if oids.len == 0:
|
||||
stderr.writeLine """using the "syndicate" OID"""
|
||||
oids.add(toPreserve "syndicate")
|
||||
|
||||
var key: array[16, byte]
|
||||
case readBytes(stdin, key, 0, 16)
|
||||
of 16: discard
|
||||
of 0: stderr.writeLine "using null key"
|
||||
else: quit "expected sixteen bytes of key from stdin"
|
||||
|
||||
for oid in oids:
|
||||
let sturdy = mint(key, oid)
|
||||
doAssert validate(key, sturdy)
|
||||
stdout.writeLine(sturdy)
|
||||
|
||||
main()
|
|
@ -5,7 +5,7 @@ author = "Emery Hemingway"
|
|||
description = "Utilites for Syndicated Actors and Synit"
|
||||
license = "unlicense"
|
||||
srcDir = "src"
|
||||
bin = @["json_socket_translator", "json_translator", "msg", "net_mapper", "preserve_process_environment", "syndex_card", "syndump"]
|
||||
bin = @["json_socket_translator", "json_translator", "mintsturdyref", "msg", "net_mapper", "preserve_process_environment", "syndex_card", "syndump"]
|
||||
|
||||
|
||||
# Dependencies
|
||||
|
|
Loading…
Reference in New Issue