|
1 | 1 | /* eslint-disable */
|
2 |
| -// sessions v0.0.1 67f782e8acfe452f905078a7423ed5d27c6639a8 |
| 2 | +// sessions v0.0.1 48681273e3b0249c5feb593b9af1b59dc6a14869 |
3 | 3 | // --
|
4 |
| -// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. |
| 4 | +// Code generated by webrpc-gen@v0.21.3 with typescript generator. DO NOT EDIT. |
5 | 5 | //
|
6 | 6 | // webrpc-gen -schema=sessions.ridl -target=typescript -client -out=./clients/sessions.gen.ts
|
7 | 7 |
|
| 8 | +export const WebrpcHeader = "Webrpc" |
| 9 | + |
| 10 | + |
| 11 | + |
8 | 12 | // WebRPC description and code-gen version
|
9 | 13 | export const WebRPCVersion = "v1"
|
10 | 14 |
|
11 | 15 | // Schema version of your RIDL schema
|
12 | 16 | export const WebRPCSchemaVersion = "v0.0.1"
|
13 | 17 |
|
14 | 18 | // Schema hash generated from your RIDL schema
|
15 |
| -export const WebRPCSchemaHash = "67f782e8acfe452f905078a7423ed5d27c6639a8" |
| 19 | +export const WebRPCSchemaHash = "48681273e3b0249c5feb593b9af1b59dc6a14869" |
| 20 | + |
| 21 | +type WebrpcGenVersions = { |
| 22 | + webrpcGenVersion: string; |
| 23 | + codeGenName: string; |
| 24 | + codeGenVersion: string; |
| 25 | + schemaName: string; |
| 26 | + schemaVersion: string; |
| 27 | +}; |
| 28 | + |
| 29 | +export function VersionFromHeader(headers: Headers): WebrpcGenVersions { |
| 30 | + const headerValue = headers.get(WebrpcHeader); |
| 31 | + if (!headerValue) { |
| 32 | + return { |
| 33 | + webrpcGenVersion: "", |
| 34 | + codeGenName: "", |
| 35 | + codeGenVersion: "", |
| 36 | + schemaName: "", |
| 37 | + schemaVersion: "", |
| 38 | + }; |
| 39 | + } |
| 40 | + |
| 41 | + return parseWebrpcGenVersions(headerValue); |
| 42 | +} |
| 43 | + |
| 44 | +function parseWebrpcGenVersions(header: string): WebrpcGenVersions { |
| 45 | + const versions = header.split(";"); |
| 46 | + if (versions.length < 3) { |
| 47 | + return { |
| 48 | + webrpcGenVersion: "", |
| 49 | + codeGenName: "", |
| 50 | + codeGenVersion: "", |
| 51 | + schemaName: "", |
| 52 | + schemaVersion: "", |
| 53 | + }; |
| 54 | + } |
| 55 | + |
| 56 | + const [_, webrpcGenVersion] = versions[0].split("@"); |
| 57 | + const [codeGenName, codeGenVersion] = versions[1].split("@"); |
| 58 | + const [schemaName, schemaVersion] = versions[2].split("@"); |
| 59 | + |
| 60 | + return { |
| 61 | + webrpcGenVersion, |
| 62 | + codeGenName, |
| 63 | + codeGenVersion, |
| 64 | + schemaName, |
| 65 | + schemaVersion, |
| 66 | + }; |
| 67 | +} |
16 | 68 |
|
17 | 69 | //
|
18 | 70 | // Types
|
@@ -128,9 +180,9 @@ export interface Signature {
|
128 | 180 | }
|
129 | 181 |
|
130 | 182 | export interface SignerSignature {
|
131 |
| - referenceChainID?: string |
132 | 183 | signer?: string
|
133 | 184 | signature: string
|
| 185 | + referenceChainID?: string |
134 | 186 | }
|
135 | 187 |
|
136 | 188 | export interface ConfigUpdate {
|
@@ -459,9 +511,12 @@ export class Sessions implements Sessions {
|
459 | 511 | }
|
460 | 512 |
|
461 | 513 | const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
|
| 514 | + const reqHeaders: {[key: string]: string} = { ...headers, 'Content-Type': 'application/json' } |
| 515 | + reqHeaders[WebrpcHeader] = WebrpcHeaderValue |
| 516 | + |
462 | 517 | return {
|
463 | 518 | method: 'POST',
|
464 |
| - headers: { ...headers, 'Content-Type': 'application/json' }, |
| 519 | + headers: reqHeaders, |
465 | 520 | body: JSON.stringify(body || {}),
|
466 | 521 | signal
|
467 | 522 | }
|
|
0 commit comments