diff --git a/identity-and-access/go/seats/meshvault/contract.go b/identity-and-access/go/seats/meshvault/contract.go index 07a19f4..8529393 100644 --- a/identity-and-access/go/seats/meshvault/contract.go +++ b/identity-and-access/go/seats/meshvault/contract.go @@ -31,11 +31,12 @@ const ( VerbAbandon = "abandon" VerbRetire = "retire" VerbLicencePut = "licence-put" + VerbOwnPut = "own-put" ) // Verbs is every verb the seat serves, in its definition's order: a new copy each call. func Verbs() []string { - return []string{VerbGet, VerbSecretAsk, VerbIssued, VerbRotate, VerbMoveIn, VerbNodeKey, VerbOwn, VerbIssueAccount, VerbSign, VerbEnrolmentToken, VerbNodeAccount, VerbRotateNode, VerbNodeAccountConfirm, VerbAbandon, VerbRetire, VerbLicencePut} + return []string{VerbGet, VerbSecretAsk, VerbIssued, VerbRotate, VerbMoveIn, VerbNodeKey, VerbOwn, VerbIssueAccount, VerbSign, VerbEnrolmentToken, VerbNodeAccount, VerbRotateNode, VerbNodeAccountConfirm, VerbAbandon, VerbRetire, VerbLicencePut, VerbOwnPut} } // The holder's own events, listed beside the seat and published under the holder's subjects (ADR 0620 §2). @@ -524,6 +525,19 @@ type LicencePutInput struct { // LicencePutAnswer is what licence-put answers. type LicencePutAnswer = map[string]any +// OwnPutInput is what own-put takes. +type OwnPutInput struct { + // the second step: the call the first step answered + Call string `json:"call,omitempty"` + // the first step: the secret's name, among the calling module's own + Name string `json:"name,omitempty"` + // the second step: the value sealed to the call's key — never the value + Sealed string `json:"sealed,omitempty"` +} + +// OwnPutAnswer is what own-put answers. +type OwnPutAnswer = map[string]any + // SignedHolderEvent is the body of the holder's event signed. type SignedHolderEvent struct { // when it was signed, RFC 3339 diff --git a/identity-and-access/go/seats/meshvault/contract_test.go b/identity-and-access/go/seats/meshvault/contract_test.go index 8b8c520..1fda141 100644 --- a/identity-and-access/go/seats/meshvault/contract_test.go +++ b/identity-and-access/go/seats/meshvault/contract_test.go @@ -51,6 +51,12 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v EnrolmentTokenAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a node account retired", subject: "", given: "{\"node\":\"ace\",\"retired\":true}", wire: "{\"node\":\"ace\",\"retired\":true}", decode: func(b []byte) (any, error) { var v NodeAccountAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "own-put's first step names the secret", subject: "", given: "{\"name\":\"forge-token\"}", wire: "{\"name\":\"forge-token\"}", + decode: func(b []byte) (any, error) { var v OwnPutInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "own-put's second step sends the call and the sealed value", subject: "", given: "{\"call\":\"c-1\",\"sealed\":\"AAAA\"}", wire: "{\"call\":\"c-1\",\"sealed\":\"AAAA\"}", + decode: func(b []byte) (any, error) { var v OwnPutInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "own-put's first step answers the call and the key to seal to", subject: "", given: "{\"call\":\"c-1\",\"seal_to\":\"-----BEGIN PUBLIC KEY-----\"}", wire: "{\"call\":\"c-1\",\"seal_to\":\"-----BEGIN PUBLIC KEY-----\"}", + decode: func(b []byte) (any, error) { var v OwnPutAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/identity-and-access/seats/mesh-vault/fixtures/verbs.json b/identity-and-access/seats/mesh-vault/fixtures/verbs.json index 49b29f3..2767436 100644 --- a/identity-and-access/seats/mesh-vault/fixtures/verbs.json +++ b/identity-and-access/seats/mesh-vault/fixtures/verbs.json @@ -39,5 +39,28 @@ "node": "ace", "retired": true } + }, + { + "name": "own-put's first step names the secret", + "of": "verb:own-put.input", + "given": { + "name": "forge-token" + } + }, + { + "name": "own-put's second step sends the call and the sealed value", + "of": "verb:own-put.input", + "given": { + "call": "c-1", + "sealed": "AAAA" + } + }, + { + "name": "own-put's first step answers the call and the key to seal to", + "of": "verb:own-put.answer", + "given": { + "call": "c-1", + "seal_to": "-----BEGIN PUBLIC KEY-----" + } } ] diff --git a/identity-and-access/seats/mesh-vault/seat.json b/identity-and-access/seats/mesh-vault/seat.json index 95c08b6..57afdfc 100644 --- a/identity-and-access/seats/mesh-vault/seat.json +++ b/identity-and-access/seats/mesh-vault/seat.json @@ -9,7 +9,7 @@ "verbs": [ { "name": "get", - "description": "One secret, sealed to the public key the asker sends (the sealed box of ADR 0206), with its generation; answered only to an asker the vault allows, as the bus proved it. Never the value in the clear, and never to a private key.", + "description": "One secret, sealed to the public key the asker sends (the sealed box of ADR 0206), with its generation; answered only to an asker the vault allows, as the bus proved it, and a module's own secret put through own-put only to a process of the same module (design 47 H2 §822). Never the value in the clear, and never to a private key.", "optional": true, "input": { "properties": { @@ -676,6 +676,32 @@ "type": "object", "description": "the holder's answer" } + }, + { + "name": "own-put", + "description": "Store a secret as the calling module's own, in two steps modelled on licence-put (design 47 H2 §822, H-A-345, H-A-349 DQ-7): name the secret and get a call and a key made for it (call, seal_to); then send the call and the value sealed to that key, and the vault keeps it under that name as the module's own, the module named by the caller's account as the bus proved it, never by an argument, keeping its newest generation only (name, generation). get answers it to a process of the same module, sealed to the process's key. The holder says each write in its journal without the value.", + "optional": true, + "input": { + "properties": { + "call": { + "description": "the second step: the call the first step answered", + "type": "string" + }, + "name": { + "description": "the first step: the secret's name, among the calling module's own", + "type": "string" + }, + "sealed": { + "description": "the second step: the value sealed to the call's key — never the value", + "type": "string" + } + }, + "type": "object" + }, + "answer": { + "type": "object", + "description": "the holder's answer: to the first step the call and the key to seal to (call, seal_to); to the second the secret's name and the generation kept (name, generation)" + } } ], "description": "The mesh's secrets. accept and move-asks, which no holder served and nothing called, are left out (ADR 0620 §3). The vault's own events stay under its own subjects (ADR 0620 §2).", diff --git a/identity-and-access/ts/seats/meshvault/index.d.ts b/identity-and-access/ts/seats/meshvault/index.d.ts index 646d66f..6485559 100644 --- a/identity-and-access/ts/seats/meshvault/index.d.ts +++ b/identity-and-access/ts/seats/meshvault/index.d.ts @@ -21,6 +21,7 @@ export declare const verbs: { readonly abandon: "abandon"; readonly retire: "retire"; readonly licencePut: "licence-put"; + readonly ownPut: "own-put"; }; export declare const holderEvents: { @@ -387,6 +388,19 @@ export interface LicencePutInput { /** is what licence-put answers. */ export type LicencePutAnswer = Record; +/** is what own-put takes. */ +export interface OwnPutInput { + /** the second step: the call the first step answered */ + "call"?: string; + /** the first step: the secret's name, among the calling module's own */ + "name"?: string; + /** the second step: the value sealed to the call's key — never the value */ + "sealed"?: string; +} + +/** is what own-put answers. */ +export type OwnPutAnswer = Record; + /** is the body of the holder's event signed. */ export interface SignedHolderEvent { /** when it was signed, RFC 3339 */ diff --git a/identity-and-access/ts/seats/meshvault/index.js b/identity-and-access/ts/seats/meshvault/index.js index 54bc9f7..c61607a 100644 --- a/identity-and-access/ts/seats/meshvault/index.js +++ b/identity-and-access/ts/seats/meshvault/index.js @@ -21,6 +21,7 @@ export const verbs = { abandon: "abandon", retire: "retire", licencePut: "licence-put", + ownPut: "own-put", }; export const holderEvents = {