JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q38193F
  • License MIT

Shared types for OpenFrames implementations

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@open-frames/types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    OpenFrames Types

    A shared set of types for all OpenFrames implementations

    Usage

    type RequestType = {
      clientProtocol: "test";
      untrustedData: OpenFramesUntrustedData & { foo: string };
      trustedData: {
        messageBytes: string;
      };
    };
    
    type ValidationResponseType = {
      foo: string;
    };
    
    class ExampleValidator
      implements RequestValidator<RequestType, ValidationResponseType, "test">
    {
      readonly protocolIdentifier = "test";
    
      minProtocolVersion(): string {
        return `${this.protocolIdentifier}@VNext`;
      }
    
      isSupported(payload: OpenFramesRequest): payload is RequestType {
        return true;
      }
    
      async validate(
        payload: RequestType
      ): Promise<
        ValidationResponse<ValidationResponseType, typeof this.protocolIdentifier>
      > {
        return {
          isValid: true,
          clientProtocol: this.protocolIdentifier,
          data: { foo: payload.untrustedData.foo },
        };
      }
    }