https://github.com/open-frames/types
https://github.com/open-frames/types
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/open-frames/types
- Owner: open-frames
- License: mit
- Created: 2024-02-09T01:25:35.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-30T21:44:05.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T10:11:28.152Z (about 1 year ago)
- Language: TypeScript
- Size: 82 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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 },
};
}
}
```