From 549f128bd3b2d752709feaa945afcb47835cc669 Mon Sep 17 00:00:00 2001 From: Abhay Raizada Date: Tue, 23 Apr 2024 10:59:28 +0530 Subject: [PATCH 1/8] NIP-101: Forms on nostr --- 101.md | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 101.md diff --git a/101.md b/101.md new file mode 100644 index 00000000..70c75181 --- /dev/null +++ b/101.md @@ -0,0 +1,88 @@ +# NIP-101 - Forms On Nostr + +`draft` `optional` `author:abhay-raizada` `author:rramaa` + +## Form Template + +Form template is stored in a parameterized replaceable event of `kind: 30168`. +The event structure is: + +``` +{ + "kind": 30168, + "content" : "
" + "tags": [["d", ""]], + "pubkey": "" +} +``` + +Content is a stringified JSON object with the following attributes: +|Attribute | Description | +|----------|-------------| +| name |name of the form| +| description | description of the form, may support markdown| +| schemaId | identifier for the schema that describes the structure of the fields and settings key of the form| +| fields |Client specific object holding the form structure: questions, metadata, optionally encrypted by a sha256 hash of a shared password, follows the schema as mentioned in the schemaId field| +| settings |Client specific object holding the settings for the form| + +Clients may wish to add additional keys depending on the use-case. + +A list of schemaIds with the specification may optionally be collated in the table below: + +| SchemaId | Link to the structure| +|----------|----------------------| +|formstrV1| https://github.com/abhay-raizada/nostr-forms/blob/master/packages/formstr-sdk/src/form-schemas/v1/form-spec.json + +Fields and settings maybe client specific, but a form is expected to have name, description and schema as part of the content JSON for interoperability. + +### Sharing Links + +Links would need to parameters from the users: the npub of the author and form identifier. + +For example: `https://formstr.app/#f//` +The form identifier is the d tag of the form template event. + +### Groups + +If a user wants to share a form with a group, they would need to create a shared user and share the private key of this user with their group. + +### Private Forms + +The fields key in the form template can be plain-text or encrypted using a symmetric key derived from a sha-256 hash of a password that can be shared with the participants. This would protect the form from being viewed by public querying of the relays. The password can be part of the shared url itself. + +Example `https://formstr.app/#f//?pwd=` + +## Responses + +Response events are attached to a form(3068 kind event), and the event data is stored in a `kind: 30169` event + +Response structure: + +``` +{ + "kind": 30169, + "content" : "", + "tags": [["a", "30168::"]], + "pubkey": "Author of Response" +} +``` + +Content is a stringified JSON, containing the following attributes: + +| Attribute | Description| +|-----------|------------| +|schema|describes the structure of the response key of the content +|response| Client specific object holding the response structure mapped to the form template| +|isPublic| a boolean field that identifies whether the response key is encrypted + +The response key may optionally be encrypted with the author's private key using the specification mentioned in [nip-44 v2](./44.md) + +A list of schemaIds with the specification may optionally be collated in the table below: + +| SchemaId | Link to the structure| +|----------|----------------------| +|formstrV1 | https://github.com/abhay-raizada/nostr-forms/blob/master/packages/formstr-sdk/src/form-schemas/v1/response-spec.json + +### Polls + +Polls is a use-case for forms where public responses are expected. From 9dda0ad2911dee481f2dd991a65194390edac9e8 Mon Sep 17 00:00:00 2001 From: Abhay Raizada Date: Thu, 9 May 2024 01:34:46 +0530 Subject: [PATCH 2/8] Move form spec to tags --- 101.md | 101 +++++++++++++++++++++++++-------------------------------- 1 file changed, 44 insertions(+), 57 deletions(-) diff --git a/101.md b/101.md index 70c75181..4a451a4c 100644 --- a/101.md +++ b/101.md @@ -1,88 +1,75 @@ # NIP-101 - Forms On Nostr -`draft` `optional` `author:abhay-raizada` `author:rramaa` +`draft` `optional` `author:abhay-raizada` -## Form Template -Form template is stored in a parameterized replaceable event of `kind: 30168`. -The event structure is: +The nip provides a way for users to create form templates on nostr, and for other users to be able to fill them. -``` +## Form Template - Public + +Event `30168` describes a form with `field` tags that contain the description of each form field, with optional settings +```js { "kind": 30168, - "content" : "" - "tags": [["d", ""]], + "content" : "" + "tags": [ + ["d", ""], + ["name", "Name of the form"], + ["settings", JSON.stringify({description: "","","