open-index/open-npm huggingface dataset:
npm package: @kejistan/enum
Description: Enum utilities for typescript, inspired by flow enums
Author: Sean Nicolay
Latest version: 0.0.2

# @kejistan/enum

Inspired by [the enum implementation in Flow](https://flow.org/en/docs/enums/). This attempts to bring some similar sanity to TypeScript.

## Usage

Define enums via `Enum` and `EnumValue`. Enum keys must be capitalized, lowercased names will result in type errors to avoid potential collisions with enum methods. Values can be strings or numbers, but all values must be of the same type:

```ts
import { Enum, EnumValue } from "@kejistan/enum";

const MyStringEnum = Enum({
  ValueOne: "one",
  ValueTwo: "two",
});

type MyStringEnum = EnumValue<typeof MyStringEnum>;

const MyNumericEnum = Enum({
  ValueOne: 1,
  ValueTwo: 2,
});

type MyNumericEnum = EnumValue<typeof MyNumericEnum>;
```

You can use the enum to access the specific values or to check and coerce unchecked values:

```ts
function doSomethingWithAnEnumValue(value: MyStringEnum) {
  switch (value) {
    case MyStringEnum.ValueOne:
      // ...
      break;
    case MyStringEnum.ValueTwo:
      // ...
      break;
  }
}

function processRawString(value: string) {
  const enumValue = MyStringEnum.cast(value) ?? MyStringEnum.ValueOne;
  doSomethingWithAnEnumValue(enumValue);
}

function somethingElseWithAString(value: string) {
  if (MyStringEnum.isValid(value)) {
    doSomethingWithAnEnumValue(value);
  }
}
```

## Missing features

Mirrored enum definitions. Currently you need to manually define both the name and the value. This is verbose for the common usecase of name === value.

Enum values are not their own nominative types. This means that overlapping enum values are comparable. Values are also implicitly convertible to their representation type (i.e. string or number).

Enums with unknown members aren't implemented as I don't know of a mechanism to describe that in TypeScript.

The Enum value type and the Enum collection are not exported via a single definition statement (this is the need for the extra `EnumValue` declaration). I'm not sure how to replicate this in TypeScript
npm package: @kejistan/eslint-plugin-relay
Description: Additional eslint rules about relay best practices
Author: Sean Nicolay
Latest version: 1.0.1

# eslint-plugin-relay

Additional eslint rules about relay best practices

## Installation

You'll first need to install [ESLint](https://eslint.org/):

```sh
npm i eslint --save-dev
```

Next, install `@kejistan/eslint-plugin-relay`:

```sh
npm install @kejistan/eslint-plugin-relay --save-dev
```

## Usage

Add `@kejistan/relay` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:

```json
{
  "plugins": ["@kejistan/relay"]
}
```

Then configure the rules you want to use under the rules section.

```json
{
  "rules": {
    "@kejistan/relay/check-generic-annotations": "error",
    "@kejistan/relay/no-external-imports": "error"
  }
}
```

## Supported Rules

- **check-generic-annotations** Check that functions which require generic annotations are specifying the right generated type
- **no-external-imports** Forbid imports of relay code generated by other files
npm package: @kejun/cert-tools
Description: Decode X.509 certificates and CSRs (Certificate Signing Requests) from PEM or DER
Latest version: 0.2.0

# cert-tools

Decode X.509 certificates and CSRs (Certificate Signing Requests) from PEM format in Node.js.

## Install

```bash
npm install @kejun/cert-tools
```

## Usage

### Decode X.509 Certificate

```ts
import { decodeX509 } from "@kejun/cert-tools";

const pem = `-----BEGIN CERTIFICATE-----
MIICpTCCAY2gAwIBAgIB...
-----END CERTIFICATE-----`;

const certs = await decodeX509(pem);
console.log(certs[0].subject);       // "CN=localhost"
console.log(certs[0].issuer);
console.log(certs[0].isValid);       // true/false
console.log(certs[0].thumbprintSha256);
```

### Decode CSR

```ts
import { decodeCsr } from "@kejun/cert-tools";

const pem = `-----BEGIN CERTIFICATE REQUEST-----
MIICgDCCAWgCAQAwOzEZ...
-----END CERTIFICATE REQUEST-----`;

const info = decodeCsr(pem);
console.log(info.subject);           // { "Common Name (CN)": "example.com", ... }
console.log(info.publicKeyAlgorithm); // "RSA"
console.log(info.publicKeySize);      // "2048 bits"
console.log(info.subjectAltNames);    // ["DNS: example.com", ...]
```

## API

### `decodeX509(pem: string): Promise<CertInfo[]>`

Parses one or more PEM-encoded X.509 certificates. Returns an array of `CertInfo` objects with:

`subject`, `issuer`, `serialNumber`, `notBefore`, `notAfter`, `isValid`, `signatureAlgorithm`, `publicKeyAlgorithm`, `publicKeySize`, `thumbprintSha1`, `thumbprintSha256`, `extensions`, `subjectAltNames`, `pem`

### `decodeCsr(pem: string): CsrInfo`

Parses a PEM-encoded CSR. Returns a `CsrInfo` object with:

`subject`, `publicKeyAlgorithm`, `publicKeySize`, `signatureAlgorithm`, `attributes`, `subjectAltNames`

## License

MIT