An open API service indexing awesome lists of open source software.

https://github.com/open-frames/types


https://github.com/open-frames/types

Last synced: about 1 year ago
JSON representation

Awesome Lists containing this project

README

          

# Open Frames Types

A shared set of types for all Open Frames implementations

## Usage

```ts
import {
OpenFramesUntrustedData,
OpenFramesTrustedData,
OpenFramesRequest,
ValidationResponse,
RequestValidator,
} from "@open-frames/types";

type RequestType = {
clientProtocol: "test";
untrustedData: OpenFramesUntrustedData & { foo: string };
trustedData: OpenFramesTrustedData;
};

type ValidationResponseType = {
foo: string;
};

class ExampleValidator
implements RequestValidator
{
readonly protocolIdentifier = "test";

minProtocolVersion(): string {
return `${this.protocolIdentifier}@VNext`;
}

isSupported(payload: OpenFramesRequest): payload is RequestType {
return true;
}

async validate(
payload: RequestType
): Promise<
ValidationResponse
> {
return {
isValid: true,
clientProtocol: payload.clientProtocol,
message: { foo: payload.untrustedData.foo },
};
}
}
```