Skip to content

mainawycliffe/aws-appsync-identity-typescript-guard

Repository files navigation

AWS AppSync Identity Typescript Guard

Test Release & Publish

This is a Typescript Library to check the type AppsyncIdentity before use. It checks whether an AppsyncIdentity from aws-lambda types defined at DefinitelyTyped.

It uses custom type guards, so that Typescript is able to do type narrowing within the control flow. This custom guards are also available in production, as Javascript projects, meaning the checks work at both development and runtime.

Examples

IAM

if (isIAMAppsyncIdentity(identity)) {
  // do something with IAM Identity
}

Cognito

if (isCognitoAppsyncIdentity(identity)) {
  // do something with Cognito Identity
}

OIDC

if (isAppSyncIdentityOIDC(identity)) {
  // do something with OIDC Identity
}

Lambda Authorization

if (isAppSyncIdentityLambda(identity)) {
  // do something with Lambda Authorization
}

About

A typescript custom guard to check the AppSync Identity of a certain type

Resources

License

Stars

Watchers

Forks

Packages