Skip to content

Commit

Permalink
expose error types
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicrathbone committed Nov 23, 2020
1 parent dde7a45 commit 2f94c78
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "device-check",
"version": "2.0.0",
"version": "2.0.1",
"license": "MIT",
"description": "A Promise-based Node.js client for the Apple device check API",
"main": "dist/index.js",
Expand Down Expand Up @@ -37,4 +37,4 @@
"url": "https://github.com/PepperHQ/ios-device-check/issues"
},
"homepage": "https://github.com/PepperHQ/ios-device-check#readme"
}
}
11 changes: 3 additions & 8 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// (c) PepperHQ Limited - All Right Reserved
import fetch, { Request, Response } from 'node-fetch';
import fetch, { Request } from 'node-fetch';
import uuid from 'uuid';

export class ApiError extends Error {
constructor(public req: Request, public res: Response | undefined, public wrappedError: Error) {
super(wrappedError.message);
}
}
import { ApiError } from './error';

// API Documentation available at:
// https://developer.apple.com/documentation/devicecheck/accessing_and_modifying_per-device_data
Expand All @@ -32,7 +27,7 @@ export interface QueryDeviceResult {

// TODO: Find a way of using unknown with object typeguards
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isQueryDeviceResult(result: any): result is QueryDeviceResult {
export function isQueryDeviceResult(result: any): result is QueryDeviceResult {
return typeof result.bit0 === 'boolean' &&
typeof result.bit1 === 'boolean' &&
typeof result.last_update_time === 'string';
Expand Down
7 changes: 7 additions & 0 deletions src/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Request, Response } from "node-fetch";

export class ApiError extends Error {
constructor(public req: Request, public res: Response | undefined, public wrappedError: Error) {
super(wrappedError.message);
}
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// (c) PepperHQ Limited - All Right Reserved
export * from './client';
export * from './client';
export * from './error'

0 comments on commit 2f94c78

Please sign in to comment.