Skip to content

Commit

Permalink
Fixed entrypoint, fixed configuration validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kugelschieber committed Oct 3, 2023
1 parent 4769474 commit e2783e5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.4.1

* fixed entrypoint
* fixed configuration validation

## 2.4.0

* added new custom metric fields
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "pirsch-sdk",
"version": "2.4.0",
"description": "JavaScript client SDK for Pirsch.",
"main": "index.js",
"types": "index.d.ts",
"version": "2.4.1",
"description": "TypeScript/JavaScript client SDK for Pirsch.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf dist && tsc",
"watch": "tsc --watch",
Expand Down
4 changes: 2 additions & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from "./constants";

export abstract class PirschCommon {
protected assertOauthCredentials({ clientId, clientSecret }: { clientId: string; clientSecret: string }) {
if (clientId.length !== PIRSCH_CLIENT_ID_LENGTH) {
protected assertOauthCredentials({ clientId, clientSecret }: { clientId?: string; clientSecret: string }) {
if (clientId?.length !== PIRSCH_CLIENT_ID_LENGTH) {
throw new Error(`Invalid Client ID, should be of length '${PIRSCH_CLIENT_ID_LENGTH}'!`);
}

Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export abstract class PirschCoreClient extends PirschCommon {
this.assertAccessTokenCredentials({ accessToken });
this.accessToken = accessToken;
this.accessMode = "access-token";
} else if ("clientId" in configuration && "clientSecret" in configuration) {
} else if ("clientId" in configuration || "clientSecret" in configuration) {
const { clientId, clientSecret } = configuration;
this.assertOauthCredentials({ clientId, clientSecret });
this.clientId = clientId;
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface PirschOAuthClientConfig extends PirschClientConfigBase {
/**
* The OAuth client ID
*/
clientId: string;
clientId?: string;
/**
* The OAuth client secret
*/
Expand Down

0 comments on commit e2783e5

Please sign in to comment.