Skip to content

Commit be57ded

Browse files
authored
feat(farcaster-js-hub-rest): add validate-message and frames types (#747)
* feat(farcaster-js-hub-rest): add validate-message endpoint and types for frames affects: @standard-crypto/farcaster-js-hub-rest * feat(farcaster-js): prep for release affects: @standard-crypto/farcaster-js-hub-rest, @standard-crypto/farcaster-js * feat(farcaster-js): prep for release affects: @standard-crypto/farcaster-js-hub-rest, @standard-crypto/farcaster-js * docs(farcaster-js): update changelog
1 parent 83a3a37 commit be57ded

33 files changed

+1037
-73
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [7.2.0](https://github.com/standard-crypto/farcaster-js/compare/v7.1.0...v7.2.0) (2024-01-29)
2+
3+
### Features
4+
5+
* Updates the openAPI spec to add types for Frames and the `/validateMessage` endpoint
6+
* Implements validate message logic
7+
18
# [7.1.1](https://github.com/standard-crypto/farcaster-js/compare/v7.0.0...v7.1.0) (2023-12-20)
29

310
### Features

packages/farcaster-js-hub-rest/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ A tool for interacting with the REST API of a Farcaster hub.
1515
- [Follow a User](#follow-a-user)
1616
- [Fetch a Cast](#fetch-a-cast)
1717
- [List a User's Casts](#list-a-users-casts)
18+
- [Validate a Message](#validate-a-message)
1819
- [Fetch Hub Info](#fetch-hub-info)
1920
- [Documentation](#documentation)
2021
- [HubRestAPIClient](#hubrestapiclient)
@@ -135,6 +136,21 @@ for await (const cast of casts) {
135136
```
136137
<!-- AUTO-GENERATED-CONTENT:END -->
137138

139+
### Validate a Message
140+
141+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/validateMessage.ts) -->
142+
<!-- The below code snippet is automatically added from ./examples/validateMessage.ts -->
143+
```ts
144+
import { HubRestAPIClient } from '@standard-crypto/farcaster-js-hub-rest';
145+
146+
const client = new HubRestAPIClient();
147+
const rawMessageBytes = '0x0a42080d10c4aa0118c6d1922e20018201320a12687474703a2f2f6578616d706c652e636f6d10011a1a08c4aa0112141fd48ddc9d5910046acfa5e1b91d253763e320c31214230a1291ae8e220bf9173d9090716981402bdd3d18012240f08c907486afe1c3311565b7a27c1f0011c74bd22ba167abe8ba30a35e808cbeae674aef7b74d3161c6186e48e3cc4d843c5ec9dc1dce9c6b71547adcc02c90c28013220196a70ac9847d59e039d0cfcf0cde1adac12f5fb447bb53334d67ab18246306c';
148+
149+
const validateCastResponse = await client.validateMessage(rawMessageBytes);
150+
console.log(`valid message: ${validateCastResponse.valid}`);
151+
```
152+
<!-- AUTO-GENERATED-CONTENT:END -->
153+
138154
### Fetch Hub Info
139155

140156
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/hubInfo.ts) -->

packages/farcaster-js-hub-rest/docs/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ A tool for interacting with the REST API of a Farcaster hub.
1717
- [Follow a User](#follow-a-user)
1818
- [Fetch a Cast](#fetch-a-cast)
1919
- [List a User's Casts](#list-a-users-casts)
20+
- [Validate a Message](#validate-a-message)
2021
- [Fetch Hub Info](#fetch-hub-info)
2122
- [Documentation](#documentation)
2223
- [HubRestAPIClient](#hubrestapiclient)
@@ -137,6 +138,21 @@ for await (const cast of casts) {
137138
```
138139
<!-- AUTO-GENERATED-CONTENT:END -->
139140

141+
### Validate a Message
142+
143+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/validateMessage.ts) -->
144+
<!-- The below code snippet is automatically added from ./examples/validateMessage.ts -->
145+
```ts
146+
import { HubRestAPIClient } from '@standard-crypto/farcaster-js-hub-rest';
147+
148+
const client = new HubRestAPIClient();
149+
const rawMessageBytes = '0x0a42080d10c4aa0118c6d1922e20018201320a12687474703a2f2f6578616d706c652e636f6d10011a1a08c4aa0112141fd48ddc9d5910046acfa5e1b91d253763e320c31214230a1291ae8e220bf9173d9090716981402bdd3d18012240f08c907486afe1c3311565b7a27c1f0011c74bd22ba167abe8ba30a35e808cbeae674aef7b74d3161c6186e48e3cc4d843c5ec9dc1dce9c6b71547adcc02c90c28013220196a70ac9847d59e039d0cfcf0cde1adac12f5fb447bb53334d67ab18246306c';
150+
151+
const validateCastResponse = await client.validateMessage(rawMessageBytes);
152+
console.log(`valid message: ${validateCastResponse.valid}`);
153+
```
154+
<!-- AUTO-GENERATED-CONTENT:END -->
155+
140156
### Fetch Hub Info
141157

142158
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/hubInfo.ts) -->

packages/farcaster-js-hub-rest/docs/classes/hubRestApiClient.HubRestAPIClient.md

Lines changed: 64 additions & 37 deletions
Large diffs are not rendered by default.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
[@standard-crypto/farcaster-js-hub-rest](../README.md) / [Modules](../modules.md) / [openapi](../modules/openapi.md) / ValidateMessageApi
2+
3+
# Class: ValidateMessageApi
4+
5+
[openapi](../modules/openapi.md).ValidateMessageApi
6+
7+
ValidateMessageApi - object-oriented interface
8+
9+
**`Export`**
10+
11+
## Hierarchy
12+
13+
- `BaseAPI`
14+
15+
**`ValidateMessageApi`**
16+
17+
## Table of contents
18+
19+
### Constructors
20+
21+
- [constructor](openapi.ValidateMessageApi.md#constructor)
22+
23+
### Properties
24+
25+
- [axios](openapi.ValidateMessageApi.md#axios)
26+
- [basePath](openapi.ValidateMessageApi.md#basepath)
27+
- [configuration](openapi.ValidateMessageApi.md#configuration)
28+
29+
### Methods
30+
31+
- [validateMessage](openapi.ValidateMessageApi.md#validatemessage)
32+
33+
## Constructors
34+
35+
### constructor
36+
37+
**new ValidateMessageApi**(`configuration?`, `basePath?`, `axios?`): [`ValidateMessageApi`](openapi.ValidateMessageApi.md)
38+
39+
#### Parameters
40+
41+
| Name | Type | Default value |
42+
| :------ | :------ | :------ |
43+
| `configuration?` | [`Configuration`](openapi.Configuration.md) | `undefined` |
44+
| `basePath` | `string` | `BASE_PATH` |
45+
| `axios` | `AxiosInstance` | `globalAxios` |
46+
47+
#### Returns
48+
49+
[`ValidateMessageApi`](openapi.ValidateMessageApi.md)
50+
51+
#### Inherited from
52+
53+
BaseAPI.constructor
54+
55+
#### Defined in
56+
57+
[packages/farcaster-js-hub-rest/src/openapi/generated/base.ts:53](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/base.ts#L53)
58+
59+
## Properties
60+
61+
### axios
62+
63+
`Protected` **axios**: `AxiosInstance` = `globalAxios`
64+
65+
#### Inherited from
66+
67+
BaseAPI.axios
68+
69+
#### Defined in
70+
71+
[packages/farcaster-js-hub-rest/src/openapi/generated/base.ts:53](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/base.ts#L53)
72+
73+
___
74+
75+
### basePath
76+
77+
`Protected` **basePath**: `string` = `BASE_PATH`
78+
79+
#### Inherited from
80+
81+
BaseAPI.basePath
82+
83+
#### Defined in
84+
85+
[packages/farcaster-js-hub-rest/src/openapi/generated/base.ts:53](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/base.ts#L53)
86+
87+
___
88+
89+
### configuration
90+
91+
`Protected` **configuration**: `undefined` \| [`Configuration`](openapi.Configuration.md)
92+
93+
#### Inherited from
94+
95+
BaseAPI.configuration
96+
97+
#### Defined in
98+
99+
[packages/farcaster-js-hub-rest/src/openapi/generated/base.ts:51](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/base.ts#L51)
100+
101+
## Methods
102+
103+
### validateMessage
104+
105+
**validateMessage**(`requestParameters`, `options?`): `Promise`\<`AxiosResponse`\<[`ValidateMessageResponse`](../interfaces/openapi.ValidateMessageResponse.md), `any`\>\>
106+
107+
#### Parameters
108+
109+
| Name | Type | Description |
110+
| :------ | :------ | :------ |
111+
| `requestParameters` | [`ValidateMessageApiValidateMessageRequest`](../interfaces/openapi.ValidateMessageApiValidateMessageRequest.md) | Request parameters. |
112+
| `options?` | `AxiosRequestConfig`\<`any`\> | Override http request option. |
113+
114+
#### Returns
115+
116+
`Promise`\<`AxiosResponse`\<[`ValidateMessageResponse`](../interfaces/openapi.ValidateMessageResponse.md), `any`\>\>
117+
118+
**`Summary`**
119+
120+
Validate a signed protobuf-serialized message with the Hub
121+
122+
**`Throws`**
123+
124+
**`Memberof`**
125+
126+
ValidateMessageApi
127+
128+
#### Defined in
129+
130+
[packages/farcaster-js-hub-rest/src/openapi/generated/apis/validate-message-api.ts:147](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/apis/validate-message-api.ts#L147)

packages/farcaster-js-hub-rest/docs/enums/openapi.MessageType.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[openapi](../modules/openapi.md).MessageType
66

7-
Type of the MessageBody. - MESSAGE_TYPE_CAST_ADD: Add a new Cast - MESSAGE_TYPE_CAST_REMOVE: Remove an existing Cast - MESSAGE_TYPE_REACTION_ADD: Add a Reaction to a Cast - MESSAGE_TYPE_REACTION_REMOVE: Remove a Reaction from a Cast - MESSAGE_TYPE_LINK_ADD: Add a new Link - MESSAGE_TYPE_LINK_REMOVE: Remove an existing Link - MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS: Add a Verification of an Ethereum Address - MESSAGE_TYPE_VERIFICATION_REMOVE: Remove a Verification - MESSAGE_TYPE_USER_DATA_ADD: Deprecated MESSAGE_TYPE_SIGNER_ADD = 9; // Add a new Ed25519 key pair that signs messages for a user MESSAGE_TYPE_SIGNER_REMOVE = 10; // Remove an Ed25519 key pair that signs messages for a user Add metadata about a user - MESSAGE_TYPE_USERNAME_PROOF: Add or replace a username proof
7+
Type of the MessageBody. - MESSAGE_TYPE_CAST_ADD: Add a new Cast - MESSAGE_TYPE_CAST_REMOVE: Remove an existing Cast - MESSAGE_TYPE_REACTION_ADD: Add a Reaction to a Cast - MESSAGE_TYPE_REACTION_REMOVE: Remove a Reaction from a Cast - MESSAGE_TYPE_LINK_ADD: Add a new Link - MESSAGE_TYPE_LINK_REMOVE: Remove an existing Link - MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS: Add a Verification of an Ethereum Address - MESSAGE_TYPE_VERIFICATION_REMOVE: Remove a Verification - MESSAGE_TYPE_USER_DATA_ADD: Add metadata about a user - MESSAGE_TYPE_USERNAME_PROOF: Add or replace a username proof - MESSAGE_TYPE_FRAME_ACTION: A Farcaster Frame action
88

99
**`Export`**
1010

@@ -14,6 +14,7 @@ Type of the MessageBody. - MESSAGE_TYPE_CAST_ADD: Add a new Cast - MESSAGE_TYPE
1414

1515
- [CastAdd](openapi.MessageType.md#castadd)
1616
- [CastRemove](openapi.MessageType.md#castremove)
17+
- [FrameAction](openapi.MessageType.md#frameaction)
1718
- [LinkAdd](openapi.MessageType.md#linkadd)
1819
- [LinkRemove](openapi.MessageType.md#linkremove)
1920
- [ReactionAdd](openapi.MessageType.md#reactionadd)
@@ -45,6 +46,16 @@ ___
4546

4647
___
4748

49+
### FrameAction
50+
51+
**FrameAction** = ``"MESSAGE_TYPE_FRAME_ACTION"``
52+
53+
#### Defined in
54+
55+
[packages/farcaster-js-hub-rest/src/openapi/generated/models/message-type.ts:34](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/models/message-type.ts#L34)
56+
57+
___
58+
4859
### LinkAdd
4960

5061
**LinkAdd** = ``"MESSAGE_TYPE_LINK_ADD"``

packages/farcaster-js-hub-rest/docs/interfaces/hubRestApiClient.HubRestAPIClientConfig.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#### Defined in
2222

23-
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:84](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L84)
23+
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:86](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L86)
2424

2525
___
2626

@@ -30,7 +30,7 @@ ___
3030

3131
#### Defined in
3232

33-
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:85](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L85)
33+
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:87](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L87)
3434

3535
___
3636

@@ -40,4 +40,4 @@ ___
4040

4141
#### Defined in
4242

43-
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:86](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L86)
43+
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:88](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L88)

packages/farcaster-js-hub-rest/docs/interfaces/hubRestApiClient.PaginationOptions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#### Defined in
2121

22-
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:90](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L90)
22+
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:92](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L92)
2323

2424
___
2525

@@ -29,4 +29,4 @@ ___
2929

3030
#### Defined in
3131

32-
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:91](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L91)
32+
[packages/farcaster-js-hub-rest/src/hubRestApiClient.ts:93](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/hubRestApiClient.ts#L93)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[@standard-crypto/farcaster-js-hub-rest](../README.md) / [Modules](../modules.md) / [openapi](../modules/openapi.md) / FrameActionBody
2+
3+
# Interface: FrameActionBody
4+
5+
[openapi](../modules/openapi.md).FrameActionBody
6+
7+
A Farcaster Frame action
8+
9+
**`Export`**
10+
11+
FrameActionBody
12+
13+
## Table of contents
14+
15+
### Properties
16+
17+
- [buttonIndex](openapi.FrameActionBody.md#buttonindex)
18+
- [castId](openapi.FrameActionBody.md#castid)
19+
- [url](openapi.FrameActionBody.md#url)
20+
21+
## Properties
22+
23+
### buttonIndex
24+
25+
**buttonIndex**: `number`
26+
27+
**`Memberof`**
28+
29+
FrameActionBody
30+
31+
#### Defined in
32+
33+
[packages/farcaster-js-hub-rest/src/openapi/generated/models/frame-action-body.ts:37](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/models/frame-action-body.ts#L37)
34+
35+
___
36+
37+
### castId
38+
39+
**castId**: [`CastId`](openapi.CastId.md)
40+
41+
**`Memberof`**
42+
43+
FrameActionBody
44+
45+
#### Defined in
46+
47+
[packages/farcaster-js-hub-rest/src/openapi/generated/models/frame-action-body.ts:43](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/models/frame-action-body.ts#L43)
48+
49+
___
50+
51+
### url
52+
53+
**url**: `string`
54+
55+
**`Memberof`**
56+
57+
FrameActionBody
58+
59+
#### Defined in
60+
61+
[packages/farcaster-js-hub-rest/src/openapi/generated/models/frame-action-body.ts:31](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/models/frame-action-body.ts#L31)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[@standard-crypto/farcaster-js-hub-rest](../README.md) / [Modules](../modules.md) / [openapi](../modules/openapi.md) / MessageDataFrameActionAllOf
2+
3+
# Interface: MessageDataFrameActionAllOf
4+
5+
[openapi](../modules/openapi.md).MessageDataFrameActionAllOf
6+
7+
**`Export`**
8+
9+
MessageDataFrameActionAllOf
10+
11+
## Table of contents
12+
13+
### Properties
14+
15+
- [frameActionBody](openapi.MessageDataFrameActionAllOf.md#frameactionbody)
16+
17+
## Properties
18+
19+
### frameActionBody
20+
21+
**frameActionBody**: [`FrameActionBody`](openapi.FrameActionBody.md)
22+
23+
**`Memberof`**
24+
25+
MessageDataFrameActionAllOf
26+
27+
#### Defined in
28+
29+
[packages/farcaster-js-hub-rest/src/openapi/generated/models/message-data-frame-action-all-of.ts:31](https://github.com/standard-crypto/farcaster-js/blob/main/packages/farcaster-js-hub-rest/src/openapi/generated/models/message-data-frame-action-all-of.ts#L31)

0 commit comments

Comments
 (0)