Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/502-rename-types-package #508

Merged
merged 9 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ciChecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: pnpm install

# Build and test packages
- name: Build & test @simplewebauthn/typescript-types
- name: Build & test @simplewebauthn/types
run: npm run build:types # browser tests will need this to be built
- name: Build & test @simplewebauthn/server
run: npm run build:server # dnt will test everything in Node too
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"deno.path": "/opt/homebrew/bin/deno",
"deno.enablePaths": [
"./packages/server",
"./packages/typescript-types"
"./packages/types"
],
"editor.rulers": [
100
Expand Down
11 changes: 5 additions & 6 deletions HANDBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Notes for myself that I don't want cluttering up the README

#### Did you update the version of `"typescript"` in the monorepo's root **package.json** file?

Run this first to update **packages/typescript-types/dom.ts** then commit the changes:
Run this first to update **packages/types/dom.ts** then commit the changes:

```
(cd packages/typescript-types; pnpm run extract-dom-types)
(cd packages/types; pnpm run extract-dom-types)
```

### Step 1: Determine which packages need to be published
Expand All @@ -28,7 +28,7 @@ pnpm run update-version
Add entries to CHANGELOG.md, then re-run the command above **but go all the way through with it this
time** so that the latest changes have an entry in the CHANGELOG that gets bundled with the release.

### Step 3: Need to publish `typescript-types`?
### Step 3: Need to publish `types`?

```
pnpm run publish:types
Expand All @@ -43,10 +43,9 @@ pnpm run publish:browser
### Step 5: Need to publish `server`?

1.
- [ ] Make sure the correct version of `typescript-types` is on NPM
- [ ] Make sure the correct version of `types` is on NPM
- The `npm install` step that dnt performs while building the project pulls from NPM. The build
will fail if the version of `typescript-types` specified in `mappings` in **build_npm.ts** is
unavailable.
will fail if the version of `types` specified in `mappings` in **build_npm.ts** is unavailable.

```
pnpm run publish:server
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ incorporate WebAuthn into a website. The following packages are maintained here:

An additional package is also included that contains shared TypeScript definitions:

- [@simplewebauthn/typescript-types](https://github.com/MasterKale/SimpleWebAuthn/tree/master/packages/typescript-types/)
- [@simplewebauthn/types](https://github.com/MasterKale/SimpleWebAuthn/tree/master/packages/types/)

See these packages' READMEs for more specific implementation information.

Expand All @@ -35,15 +35,15 @@ These packages are all available on **npm** for use in **Node LTS 16.x** project
```sh
npm install @simplewebauthn/browser
npm install @simplewebauthn/server
npm install @simplewebauthn/typescript-types
npm install @simplewebauthn/types
```

The **server** and **typescript-types** packages are also available for import into **Deno v1.33.x**
projects from **deno.land/x**:
The **server** and **types** packages are also available for import into **Deno v1.33.x** projects
from **deno.land/x**:

```ts
import {...} from 'https://deno.land/x/simplewebauthn/deno/server.ts';
import type {...} from 'https://deno.land/x/simplewebauthn/deno/typescript-types.ts';
import type {...} from 'https://deno.land/x/simplewebauthn/deno/types.ts';
```

## Example
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install root dependencies without trying to link workspace packages
pnpm install --ignore-workspace
# Built typescript-types so server can build
# Build types so server can build
pnpm run build:types --skip-nx-cache
# If we can't run tests on a fresh pull then it might mean we need to refresh the Deno lock file
pnpm run test:server --skip-nx-cache
Expand Down
6 changes: 3 additions & 3 deletions deno/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ importing SimpleWebAuthn from https://deno.land/x/simplewebauthn.

## Installation

For example, to import the **server** or **typescript-types** packages into your Deno project, add
the following to your **deps.ts** file:
For example, to import the **server** or **types** packages into your Deno project, add the
following to your **deps.ts** file:

```ts
import {
Expand All @@ -15,5 +15,5 @@ import {

import {
// ...
} from 'https://deno.land/x/simplewebauthn/deno/typescript-types.ts';
} from 'https://deno.land/x/simplewebauthn/deno/types.ts';
```
2 changes: 2 additions & 0 deletions deno/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// For simpler imports in Deno projects
export * from '../packages/types/src/index.ts';
2 changes: 0 additions & 2 deletions deno/typescript-types.ts

This file was deleted.

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"packages": [
"packages/browser",
"packages/server",
"packages/typescript-types"
"packages/types"
],
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"test": "pnpm run test:browser; pnpm run test:server",
"test:browser": "lerna run test --scope=@simplewebauthn/browser",
"test:server": "lerna run test --scope=@simplewebauthn/server",
"build:types": "lerna run build --scope=@simplewebauthn/typescript-types",
"build:types": "lerna run build --scope=@simplewebauthn/types",
"build:browser": "lerna run build --scope=@simplewebauthn/browser",
"build:server": "lerna run build --scope=@simplewebauthn/server",
"update-version": "lerna version --no-push",
"publish:types": "pnpm run build:types && (cd packages/typescript-types/npm; pnpm publish)",
"publish:types": "pnpm run build:types && (cd packages/types/npm; pnpm publish)",
"publish:browser": "pnpm run build:browser && (cd packages/browser; pnpm publish)",
"publish:server": "pnpm run build:server && (cd packages/server/npm; pnpm publish)",
"dev:browser": "lerna run test:watch --scope=@simplewebauthn/browser",
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"umd"
],
"dependencies": {
"@simplewebauthn/typescript-types": "workspace:^"
"@simplewebauthn/types": "workspace:^"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PublicKeyCredentialFuture } from '@simplewebauthn/typescript-types';
import { PublicKeyCredentialFuture } from '@simplewebauthn/types';

/**
* Determine if the browser supports conditional UI, so that WebAuthn credentials can
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/helpers/toAuthenticatorAttachment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthenticatorAttachment } from '@simplewebauthn/typescript-types';
import { AuthenticatorAttachment } from '@simplewebauthn/types';

const attachments: AuthenticatorAttachment[] = ['cross-platform', 'platform'];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PublicKeyCredentialDescriptorJSON } from '@simplewebauthn/typescript-types';
import type { PublicKeyCredentialDescriptorJSON } from '@simplewebauthn/types';

import { base64URLStringToBuffer } from './base64URLStringToBuffer';

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/methods/startAuthentication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
AuthenticationExtensionsClientInputs,
AuthenticationExtensionsClientOutputs,
PublicKeyCredentialRequestOptionsJSON,
} from '@simplewebauthn/typescript-types';
} from '@simplewebauthn/types';

import { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn';
import { browserSupportsWebAuthnAutofill } from '../helpers/browserSupportsWebAuthnAutofill';
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/methods/startAuthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
AuthenticationCredential,
AuthenticationResponseJSON,
PublicKeyCredentialRequestOptionsJSON,
} from '@simplewebauthn/typescript-types';
} from '@simplewebauthn/types';

import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString';
import { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer';
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/methods/startRegistration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
AuthenticationExtensionsClientOutputs,
PublicKeyCredentialCreationOptionsJSON,
RegistrationCredential,
} from '@simplewebauthn/typescript-types';
} from '@simplewebauthn/types';
import { generateCustomError } from '../helpers/__jest__/generateCustomError';
import { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn';
import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString';
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/methods/startRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PublicKeyCredentialCreationOptionsJSON,
RegistrationCredential,
RegistrationResponseJSON,
} from '@simplewebauthn/typescript-types';
} from '@simplewebauthn/types';

import { utf8StringToBuffer } from '../helpers/utf8StringToBuffer';
import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString';
Expand Down
11 changes: 7 additions & 4 deletions packages/server/build_npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const lernaPackageJSON: { version: string } = JSON.parse(
Deno.readTextFileSync('./package.json'),
);
const typesPackageJSON: { version: string } = JSON.parse(
Deno.readTextFileSync('../typescript-types/npm/package.json'),
Deno.readTextFileSync('../types/npm/package.json'),
);

await emptyDir(outDir);
Expand Down Expand Up @@ -99,10 +99,13 @@ await build({
name: '@peculiar/asn1-android',
version: '^2.3.10',
},
// Mapping for '../../typescript-types/src/index.ts' in deps.ts
'../typescript-types/src/index.ts': {
// Mapping for '../../types/src/index.ts' in deps.ts
'../types/src/index.ts': {
// TODO: Update this to point to @simplewebauthn/types after publishing it to NPM
name: '@simplewebauthn/typescript-types',
version: `^${typesPackageJSON.version}`,
version: '^8.3.4',
// name: '@simplewebauthn/types',
// version: `^${typesPackageJSON.version}`,
},
},
// TypeScript tsconfig.json config
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/deps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @simplewebauthn/typescript-types
// @simplewebauthn/types
export type {
AttestationConveyancePreference,
AuthenticationExtensionsClientInputs,
Expand All @@ -15,7 +15,7 @@ export type {
PublicKeyCredentialRequestOptionsJSON,
RegistrationResponseJSON,
UserVerificationRequirement,
} from '../../typescript-types/src/index.ts';
} from '../../types/src/index.ts';

// cbor (a.k.a. cbor-x in Node land)
export * as cborx from 'https://deno.land/x/cbor@v1.5.2/encode.js';
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @simplewebauthn/typescript-types <!-- omit in toc -->
# @simplewebauthn/types <!-- omit in toc -->

![WebAuthn](https://img.shields.io/badge/WebAuthn-Simplified-blueviolet?style=for-the-badge&logo=WebAuthn)
[![npm (scoped)](https://img.shields.io/npm/v/@simplewebauthn/typescript-types?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@simplewebauthn/typescript-types)
[![npm (scoped)](https://img.shields.io/npm/v/@simplewebauthn/types?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@simplewebauthn/types)

TypeScript typings for **@simplewebauthn/server** and **@simplewebauthn/browser**

Expand All @@ -16,13 +16,13 @@ TypeScript typings for **@simplewebauthn/server** and **@simplewebauthn/browser*
This package is available on **npm**:

```sh
npm install @simplewebauthn/typescript-types
npm install @simplewebauthn/types
```

### Deno v1.33.x or higher

It is also available for import into Deno projects from **deno.land/x**:

```ts
import {...} from 'https://deno.land/x/simplewebauthn/deno/typescript-types.ts';
import {...} from 'https://deno.land/x/simplewebauthn/deno/types.ts';
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ await build({
test: false,
// package.json values
package: {
name: '@simplewebauthn/typescript-types',
name: '@simplewebauthn/types',
version: lernaPackageJSON.version,
description: 'TypeScript types used by the @simplewebauthn series of libraries',
license: 'MIT',
author: 'Matthew Miller <matthew@millerti.me>',
repository: {
type: 'git',
url: 'git+https://github.com/MasterKale/SimpleWebAuthn.git',
directory: 'packages/typescript-types',
directory: 'packages/types',
},
homepage:
'https://github.com/MasterKale/SimpleWebAuthn/tree/master/packages/typescript-types#readme',
homepage: 'https://github.com/MasterKale/SimpleWebAuthn/tree/master/packages/types#readme',
publishConfig: {
access: 'public',
},
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ outputSourceFile.addStatements([
`/**`,
` * Generated from typescript@${version} ${domSourcePath}`,
` * To regenerate, run the following command from the project root:`,
` * npx lerna --scope=@simplewebauthn/typescript-types exec -- npm run extract-dom-types`,
` * npx lerna --scope=@simplewebauthn/types exec -- npm run extract-dom-types`,
` */`,
`// BEGIN CODEGEN`,
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@simplewebauthn/typescript-types",
"name": "@simplewebauthn/types",
"version": "8.3.4",
"description": "Lerna/npm wrapper around Deno for @simplewebauthn/typescript-types",
"description": "Lerna/npm wrapper around Deno for @simplewebauthn/types",
"scripts": {
"build": "deno task build",
"extract-dom-types": "ts-node extract-dom-types.ts"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Generated from typescript@5.1.6 typescript/lib/lib.dom.d.ts
* To regenerate, run the following command from the project root:
* npx lerna --scope=@simplewebauthn/typescript-types exec -- npm run extract-dom-types
* npx lerna --scope=@simplewebauthn/types exec -- npm run extract-dom-types
*/
// BEGIN CODEGEN
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module @simplewebauthn/typescript-types
* @module @simplewebauthn/types
*/

import type {
Expand Down
12 changes: 8 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages:
- "packages/browser"
- "packages/server/npm"
- "packages/typescript-types/npm"
- "packages/types/npm"
Loading