@bugsplat/js-api-client 1.0.3 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/common/client/bugsplat-api-client/bugsplat-api-client.js +1 -1
  3. package/dist/cjs/common/client/bugsplat-api-client/bugsplat-api-client.js.map +1 -1
  4. package/dist/cjs/common/client/index.d.ts +1 -0
  5. package/dist/cjs/common/client/index.js +3 -1
  6. package/dist/cjs/common/client/index.js.map +1 -1
  7. package/dist/cjs/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.d.ts +16 -0
  8. package/dist/cjs/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.js +129 -0
  9. package/dist/cjs/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.js.map +1 -0
  10. package/dist/cjs/common/data/table-data/index.d.ts +1 -0
  11. package/dist/cjs/common/data/table-data/index.js +3 -1
  12. package/dist/cjs/common/data/table-data/index.js.map +1 -1
  13. package/dist/cjs/common/file/bugsplat-file.d.ts +2 -2
  14. package/dist/cjs/common/file/bugsplat-file.js.map +1 -1
  15. package/dist/esm/common/client/bugsplat-api-client/bugsplat-api-client.js +1 -1
  16. package/dist/esm/common/client/bugsplat-api-client/bugsplat-api-client.js.map +1 -1
  17. package/dist/esm/common/client/index.d.ts +1 -0
  18. package/dist/esm/common/client/index.js +1 -0
  19. package/dist/esm/common/client/index.js.map +1 -1
  20. package/dist/esm/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.d.ts +16 -0
  21. package/dist/esm/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.js +61 -0
  22. package/dist/esm/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.js.map +1 -0
  23. package/dist/esm/common/data/table-data/index.d.ts +1 -0
  24. package/dist/esm/common/data/table-data/index.js +1 -0
  25. package/dist/esm/common/data/table-data/index.js.map +1 -1
  26. package/dist/esm/common/file/bugsplat-file.d.ts +2 -2
  27. package/dist/esm/common/file/bugsplat-file.js.map +1 -1
  28. package/package.json +23 -3
package/README.md CHANGED
@@ -33,7 +33,7 @@ The `host` value used to create a new instance of `BugSplatApiClient` is `https:
33
33
  The static factory function `createAuthenticatedClientForNode` can be used to return an authenticated instance of `BugSplatApiClient` in Node.js environments.
34
34
 
35
35
  ```ts
36
- const bugsplat = await BugSplatApiClient.createAuthenticatedClientForNode(host, email, password);
36
+ const bugsplat = await BugSplatApiClient.createAuthenticatedClientForNode(email, password, host);
37
37
  ```
38
38
 
39
39
  If you need to authenticate at a later time, you can create an instance of `BugSplatApiClient` and call `login` manually.
@@ -48,7 +48,7 @@ await bugsplat.login(email, password);
48
48
  The static factory function `createAuthenticatedClientForWebBrowser` can be used to return an authenticated instance of `BugSplatApiClient`.
49
49
 
50
50
  ```ts
51
- const bugsplat = await BugSplatApiClient.createAuthenticatedClientForBrowser(host, email, password);
51
+ const bugsplat = await BugSplatApiClient.createAuthenticatedClientForBrowser(email, password, host);
52
52
  ```
53
53
 
54
54
  If you need to authenticate at a later time, you can create an instance of `BugSplatApiClient` and call `login` manually.
@@ -138,7 +138,7 @@ var BugSplatApiClient = (function () {
138
138
  case 1:
139
139
  response = _a.sent();
140
140
  if (response.status === 401) {
141
- throw new Error('Invalid email or password');
141
+ throw new Error('Could not authenticate, check credentials and try again');
142
142
  }
143
143
  if (this._environment === _common_1.Environment.Node) {
144
144
  cookie = this.parseCookies(response);
@@ -1 +1 @@
1
- {"version":3,"file":"bugsplat-api-client.js","sourceRoot":"","sources":["../../../../../src/common/client/bugsplat-api-client/bugsplat-api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAuF;AACvF,kEAA2C;AAC3C,wDAAiC;AAEjC;IAKI,2BACY,KAAkC,EAClC,YAA4C;QAD5C,sBAAA,EAAA,QAAgB,4BAAkB;QAClC,6BAAA,EAAA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AI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;4BAC9C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;4BACjC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;yBAC3C;wBAED,WAAO,QAAQ,EAAC;;;;KACnB;IAEO,wCAAY,GAApB,UAAqB,QAAkB;;QACnC,OAAO,MAAA,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,mCAAI,EAAE,CAAC;IACpD,CAAC;IAEO,0CAAc,GAAtB,UAAuB,MAAc;QACjC,IAAM,KAAK,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC9C,IAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;QAED,IAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,SAAS,CAAC;IACrB,CAAC;IACL,wBAAC;AAAD,CAAC,AA7FD,IA6FC;AA7FY,8CAAiB"}
1
+ {"version":3,"file":"bugsplat-api-client.js","sourceRoot":"","sources":["../../../../../src/common/client/bugsplat-api-client/bugsplat-api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAuF;AACvF,kEAA2C;AAC3C,wDAAiC;AAEjC;IAKI,2BACY,KAAkC,EAClC,YAA4C;QAD5C,sBAAA,EAAA,QAAgB,4BAAkB;QAClC,6BAAA,EAAA,eAA4B,qBAAW,CAAC,IAAI;QAD5C,UAAK,GAAL,KAAK,CAA6B;QAClC,iBAAY,GAAZ,YAAY,CAAgC;QANhD,oBA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C;4BACjC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;yBAC3C;wBAED,WAAO,QAAQ,EAAC;;;;KACnB;IAEO,wCAAY,GAApB,UAAqB,QAAkB;;QACnC,OAAO,MAAA,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,mCAAI,EAAE,CAAC;IACpD,CAAC;IAEO,0CAAc,GAAtB,UAAuB,MAAc;QACjC,IAAM,KAAK,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC9C,IAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;QAED,IAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,SAAS,CAAC;IACrB,CAAC;IACL,wBAAC;AAAD,CAAC,AA7FD,IA6FC;AA7FY,8CAAiB"}
@@ -1,3 +1,4 @@
1
1
  export { ApiClient, BugSplatResponse } from './api-client';
2
2
  export { BugSplatApiClient } from './bugsplat-api-client/bugsplat-api-client';
3
+ export { OAuthClientCredentialsClient } from './oauth-client-credentials-api-client/oauth-client-credentials-api-client';
3
4
  export { S3ApiClient } from './s3-api-client/s3-api-client';
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.S3ApiClient = exports.BugSplatApiClient = void 0;
3
+ exports.S3ApiClient = exports.OAuthClientCredentialsClient = exports.BugSplatApiClient = void 0;
4
4
  var bugsplat_api_client_1 = require("./bugsplat-api-client/bugsplat-api-client");
5
5
  Object.defineProperty(exports, "BugSplatApiClient", { enumerable: true, get: function () { return bugsplat_api_client_1.BugSplatApiClient; } });
6
+ var oauth_client_credentials_api_client_1 = require("./oauth-client-credentials-api-client/oauth-client-credentials-api-client");
7
+ Object.defineProperty(exports, "OAuthClientCredentialsClient", { enumerable: true, get: function () { return oauth_client_credentials_api_client_1.OAuthClientCredentialsClient; } });
6
8
  var s3_api_client_1 = require("./s3-api-client/s3-api-client");
7
9
  Object.defineProperty(exports, "S3ApiClient", { enumerable: true, get: function () { return s3_api_client_1.S3ApiClient; } });
8
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/client/index.ts"],"names":[],"mappings":";;;AACA,iFAA8E;AAArE,wHAAA,iBAAiB,OAAA;AAC1B,+DAA4D;AAAnD,4GAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/client/index.ts"],"names":[],"mappings":";;;AACA,iFAA8E;AAArE,wHAAA,iBAAiB,OAAA;AAC1B,iIAAyH;AAAhH,mJAAA,4BAA4B,OAAA;AACrC,+DAA4D;AAAnD,4GAAA,WAAW,OAAA"}
@@ -0,0 +1,16 @@
1
+ import { ApiClient, BugSplatResponse } from '../../index';
2
+ import FormData from 'form-data';
3
+ export declare class OAuthClientCredentialsClient implements ApiClient {
4
+ private _clientId;
5
+ private _clientSecret;
6
+ private _host;
7
+ private _accessToken;
8
+ private _tokenType;
9
+ private _createFormData;
10
+ private _fetch;
11
+ constructor(_clientId: string, _clientSecret: string, _host?: string);
12
+ static createAuthenticatedClient(clientId: string, clientSecret: string, host?: string): Promise<OAuthClientCredentialsClient>;
13
+ login(): Promise<BugSplatResponse>;
14
+ createFormData(): FormData;
15
+ fetch(route: string, init?: RequestInit): Promise<BugSplatResponse>;
16
+ }
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.OAuthClientCredentialsClient = void 0;
43
+ var _common_1 = require("../../index");
44
+ var fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
45
+ var form_data_1 = __importDefault(require("form-data"));
46
+ var OAuthClientCredentialsClient = (function () {
47
+ function OAuthClientCredentialsClient(_clientId, _clientSecret, _host) {
48
+ if (_host === void 0) { _host = _common_1.bugsplatAppHostUrl; }
49
+ this._clientId = _clientId;
50
+ this._clientSecret = _clientSecret;
51
+ this._host = _host;
52
+ this._accessToken = '';
53
+ this._tokenType = '';
54
+ this._createFormData = function () { return new form_data_1.default(); };
55
+ this._fetch = (0, fetch_ponyfill_1.default)().fetch;
56
+ }
57
+ OAuthClientCredentialsClient.createAuthenticatedClient = function (clientId, clientSecret, host) {
58
+ if (host === void 0) { host = _common_1.bugsplatAppHostUrl; }
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ var client;
61
+ return __generator(this, function (_a) {
62
+ switch (_a.label) {
63
+ case 0:
64
+ client = new OAuthClientCredentialsClient(clientId, clientSecret, host);
65
+ return [4, client.login()];
66
+ case 1:
67
+ _a.sent();
68
+ return [2, client];
69
+ }
70
+ });
71
+ });
72
+ };
73
+ OAuthClientCredentialsClient.prototype.login = function () {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var url, method, body, request, response, responseJson, status, json;
76
+ var _this = this;
77
+ return __generator(this, function (_a) {
78
+ switch (_a.label) {
79
+ case 0:
80
+ url = this._host + "/oauth2/authorize";
81
+ method = 'POST';
82
+ body = this.createFormData();
83
+ body.append('grant_type', 'client_credentials');
84
+ body.append('client_id', this._clientId);
85
+ body.append('client_secret', this._clientSecret);
86
+ body.append('scope', 'restricted');
87
+ request = {
88
+ method: method,
89
+ body: body
90
+ };
91
+ return [4, this.fetch(url, request)];
92
+ case 1:
93
+ response = _a.sent();
94
+ return [4, response.json()];
95
+ case 2:
96
+ responseJson = _a.sent();
97
+ status = response.status;
98
+ if (responseJson.error === 'invalid_client') {
99
+ throw new Error('Could not authenticate, check credentials and try again');
100
+ }
101
+ this._accessToken = responseJson.access_token;
102
+ this._tokenType = responseJson.token_type;
103
+ json = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
104
+ return [2, responseJson];
105
+ }); }); };
106
+ return [2, {
107
+ status: status,
108
+ json: json
109
+ }];
110
+ }
111
+ });
112
+ });
113
+ };
114
+ OAuthClientCredentialsClient.prototype.createFormData = function () {
115
+ return this._createFormData();
116
+ };
117
+ OAuthClientCredentialsClient.prototype.fetch = function (route, init) {
118
+ var url = new URL(route, this._host);
119
+ init = init !== null && init !== void 0 ? init : {};
120
+ if (!init.headers) {
121
+ init.headers = {};
122
+ }
123
+ init.headers['Authorization'] = this._tokenType + " " + this._accessToken;
124
+ return this._fetch(url.href, init);
125
+ };
126
+ return OAuthClientCredentialsClient;
127
+ }());
128
+ exports.OAuthClientCredentialsClient = OAuthClientCredentialsClient;
129
+ //# sourceMappingURL=oauth-client-credentials-api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-client-credentials-api-client.js","sourceRoot":"","sources":["../../../../../src/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA0E;AAC1E,kEAA2C;AAC3C,wDAAiC;AAEjC;IAOI,sCACY,SAAiB,EACjB,aAAqB,EACrB,KAAkC;QAAlC,sBAAA,EAAA,QAAgB,4BAAkB;QAFlC,cAAS,GAAT,SAAS,CAAQ;QACjB,kBAAa,GAAb,aAAa,CAAQ;QACrB,UAAK,GAAL,KAAK,CAA6B;QARtC,iBAAY,GAAG,EAAE,CAAC;QAClB,eAAU,GAAG,EAAE,CAAC;QAChB,oBAAe,GAAG,cAAM,OAAA,IAAI,mBAAQ,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G,YAAY,CAAC,YAAY,CAAC;wBAC9C,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;wBAEpC,IAAI,GAAG;4BAAY,WAAA,YAAY,EAAA;iCAAA,CAAC;wBACtC,WAAO;gCACH,MAAM,QAAA;gCACN,IAAI,MAAA;6BACP,EAAC;;;;KACL;IAED,qDAAc,GAAd;QACI,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAClC,CAAC;IAED,4CAAK,GAAL,UAAM,KAAa,EAAE,IAAkB;QACnC,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC;QAElB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;SACrB;QAED,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,GAAM,IAAI,CAAC,UAAU,SAAI,IAAI,CAAC,YAAc,CAAC;QAE1E,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IACL,mCAAC;AAAD,CAAC,AA1ED,IA0EC;AA1EY,oEAA4B"}
@@ -1,3 +1,4 @@
1
1
  export { TableDataClient } from './table-data-client/table-data-client';
2
2
  export { TableDataRequest } from './table-data-client/table-data-request';
3
3
  export { TableDataResponse } from './table-data-client/table-data-response';
4
+ export { TableDataFormDataBuilder } from './table-data-form-data-builder/table-data-form-data-builder';
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TableDataClient = void 0;
3
+ exports.TableDataFormDataBuilder = exports.TableDataClient = void 0;
4
4
  var table_data_client_1 = require("./table-data-client/table-data-client");
5
5
  Object.defineProperty(exports, "TableDataClient", { enumerable: true, get: function () { return table_data_client_1.TableDataClient; } });
6
+ var table_data_form_data_builder_1 = require("./table-data-form-data-builder/table-data-form-data-builder");
7
+ Object.defineProperty(exports, "TableDataFormDataBuilder", { enumerable: true, get: function () { return table_data_form_data_builder_1.TableDataFormDataBuilder; } });
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/common/data/table-data/index.ts"],"names":[],"mappings":";;;AAAA,2EAAwE;AAA/D,oHAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/common/data/table-data/index.ts"],"names":[],"mappings":";;;AAAA,2EAAwE;AAA/D,oHAAA,eAAe,OAAA;AAGxB,4GAAuG;AAA9F,wIAAA,wBAAwB,OAAA"}
@@ -3,6 +3,6 @@ import type fs from 'fs';
3
3
  export declare class UploadableFile {
4
4
  readonly name: string;
5
5
  readonly size: number;
6
- readonly file: File | fs.ReadStream;
7
- constructor(name: string, size: number, file: File | fs.ReadStream);
6
+ readonly file: File | fs.ReadStream | Buffer;
7
+ constructor(name: string, size: number, file: File | fs.ReadStream | Buffer);
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bugsplat-file.js","sourceRoot":"","sources":["../../../../src/common/file/bugsplat-file.ts"],"names":[],"mappings":";;;AAEA;IACI,wBACoB,IAAY,EACZ,IAAY,EACZ,IAA0B;QAF1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAsB;IAC1C,CAAC;IACT,qBAAC;AAAD,CAAC,AAND,IAMC;AANY,wCAAc"}
1
+ {"version":3,"file":"bugsplat-file.js","sourceRoot":"","sources":["../../../../src/common/file/bugsplat-file.ts"],"names":[],"mappings":";;;AAEA;IACI,wBACoB,IAAY,EACZ,IAAY,EACZ,IAAmC;QAFnC,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAA+B;IACnD,CAAC;IACT,qBAAC;AAAD,CAAC,AAND,IAMC;AANY,wCAAc"}
@@ -50,7 +50,7 @@ export class BugSplatApiClient {
50
50
  redirect: 'follow'
51
51
  });
52
52
  if (response.status === 401) {
53
- throw new Error('Invalid email or password');
53
+ throw new Error('Could not authenticate, check credentials and try again');
54
54
  }
55
55
  if (this._environment === Environment.Node) {
56
56
  const cookie = this.parseCookies(response);
@@ -1 +1 @@
1
- {"version":3,"file":"bugsplat-api-client.js","sourceRoot":"","sources":["../../../../../src/common/client/bugsplat-api-client/bugsplat-api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,kBAAkB,EAAoB,WAAW,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,MAAM,OAAO,iBAAiB;IAMd;IACA;IANJ,eAAe,GAAG,GAAG,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC;IACvC,MAAM,GAAG,aAAa,EAAE,CAAC,KAAK,CAAC;IAC/B,QAAQ,GAAG,EAAE,CAAC;IAEtB,YACY,QAAgB,kBAAkB,EAClC,eAA4B,WAAW,CAAC,IAAI;QAD5C,UAAK,GAAL,KAAK,CAA6B;QAClC,iBAAY,GAAZ,YAAY,CAAgC;IACpD,CAAC;IAEL,MAAM,CAAC,KAAK,CAAC,gCAAgC,CACzC,KAAa,EACb,QAAgB,EAChB,OAAe,kBAAkB;QAEjC,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QAC7D,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,sCAAsC,CAC/C,KAAa,EACb,QAAgB,EAChB,OAAe,kBAAkB;QAEjC,MAAM,MAAM,GAAG,IAAI,iBAAiB,CA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AC,yDAAyD,CAAC,CAAC;SAC9E;QAED,IAAI,IAAI,CAAC,YAAY,KAAK,WAAW,CAAC,IAAI,EAAE;YACxC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAC9C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;YACjC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;SAC3C;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,YAAY,CAAC,QAAkB;QACnC,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IACpD,CAAC;IAEO,cAAc,CAAC,MAAc;QACjC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -1,3 +1,4 @@
1
1
  export { ApiClient, BugSplatResponse } from './api-client';
2
2
  export { BugSplatApiClient } from './bugsplat-api-client/bugsplat-api-client';
3
+ export { OAuthClientCredentialsClient } from './oauth-client-credentials-api-client/oauth-client-credentials-api-client';
3
4
  export { S3ApiClient } from './s3-api-client/s3-api-client';
@@ -1,3 +1,4 @@
1
1
  export { BugSplatApiClient } from './bugsplat-api-client/bugsplat-api-client';
2
+ export { OAuthClientCredentialsClient } from './oauth-client-credentials-api-client/oauth-client-credentials-api-client';
2
3
  export { S3ApiClient } from './s3-api-client/s3-api-client';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,2EAA2E,CAAC;AACzH,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { ApiClient, BugSplatResponse } from '../../index';
2
+ import FormData from 'form-data';
3
+ export declare class OAuthClientCredentialsClient implements ApiClient {
4
+ private _clientId;
5
+ private _clientSecret;
6
+ private _host;
7
+ private _accessToken;
8
+ private _tokenType;
9
+ private _createFormData;
10
+ private _fetch;
11
+ constructor(_clientId: string, _clientSecret: string, _host?: string);
12
+ static createAuthenticatedClient(clientId: string, clientSecret: string, host?: string): Promise<OAuthClientCredentialsClient>;
13
+ login(): Promise<BugSplatResponse>;
14
+ createFormData(): FormData;
15
+ fetch(route: string, init?: RequestInit): Promise<BugSplatResponse>;
16
+ }
@@ -0,0 +1,61 @@
1
+ import { bugsplatAppHostUrl } from '../../index';
2
+ import fetchPonyfill from 'fetch-ponyfill';
3
+ import FormData from 'form-data';
4
+ export class OAuthClientCredentialsClient {
5
+ _clientId;
6
+ _clientSecret;
7
+ _host;
8
+ _accessToken = '';
9
+ _tokenType = '';
10
+ _createFormData = () => new FormData();
11
+ _fetch = fetchPonyfill().fetch;
12
+ constructor(_clientId, _clientSecret, _host = bugsplatAppHostUrl) {
13
+ this._clientId = _clientId;
14
+ this._clientSecret = _clientSecret;
15
+ this._host = _host;
16
+ }
17
+ static async createAuthenticatedClient(clientId, clientSecret, host = bugsplatAppHostUrl) {
18
+ const client = new OAuthClientCredentialsClient(clientId, clientSecret, host);
19
+ await client.login();
20
+ return client;
21
+ }
22
+ async login() {
23
+ const url = `${this._host}/oauth2/authorize`;
24
+ const method = 'POST';
25
+ const body = this.createFormData();
26
+ body.append('grant_type', 'client_credentials');
27
+ body.append('client_id', this._clientId);
28
+ body.append('client_secret', this._clientSecret);
29
+ body.append('scope', 'restricted');
30
+ const request = {
31
+ method,
32
+ body
33
+ };
34
+ const response = await this.fetch(url, request);
35
+ const responseJson = await response.json();
36
+ const status = response.status;
37
+ if (responseJson.error === 'invalid_client') {
38
+ throw new Error('Could not authenticate, check credentials and try again');
39
+ }
40
+ this._accessToken = responseJson.access_token;
41
+ this._tokenType = responseJson.token_type;
42
+ const json = async () => responseJson;
43
+ return {
44
+ status,
45
+ json
46
+ };
47
+ }
48
+ createFormData() {
49
+ return this._createFormData();
50
+ }
51
+ fetch(route, init) {
52
+ const url = new URL(route, this._host);
53
+ init = init ?? {};
54
+ if (!init.headers) {
55
+ init.headers = {};
56
+ }
57
+ init.headers['Authorization'] = `${this._tokenType} ${this._accessToken}`;
58
+ return this._fetch(url.href, init);
59
+ }
60
+ }
61
+ //# sourceMappingURL=oauth-client-credentials-api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-client-credentials-api-client.js","sourceRoot":"","sources":["../../../../../src/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,kBAAkB,EAAoB,MAAM,SAAS,CAAC;AAC1E,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,MAAM,OAAO,4BAA4B;IAQzB;IACA;IACA;IARJ,YAAY,GAAG,EAAE,CAAC;IAClB,UAAU,GAAG,EAAE,CAAC;IAChB,eAAe,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AC,KAAK,KAAK,gBAAgB,EAAE;YACzC,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;SAC9E;QAED,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;QAE1C,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC,YAAY,CAAC;QACtC,OAAO;YACH,MAAM;YACN,IAAI;SACP,CAAC;IACN,CAAC;IAED,cAAc;QACV,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,KAAa,EAAE,IAAkB;QACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAElB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;SACrB;QAED,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QAE1E,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;CACJ"}
@@ -1,3 +1,4 @@
1
1
  export { TableDataClient } from './table-data-client/table-data-client';
2
2
  export { TableDataRequest } from './table-data-client/table-data-request';
3
3
  export { TableDataResponse } from './table-data-client/table-data-response';
4
+ export { TableDataFormDataBuilder } from './table-data-form-data-builder/table-data-form-data-builder';
@@ -1,2 +1,3 @@
1
1
  export { TableDataClient } from './table-data-client/table-data-client';
2
+ export { TableDataFormDataBuilder } from './table-data-form-data-builder/table-data-form-data-builder';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/common/data/table-data/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/common/data/table-data/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6DAA6D,CAAC"}
@@ -3,6 +3,6 @@ import type fs from 'fs';
3
3
  export declare class UploadableFile {
4
4
  readonly name: string;
5
5
  readonly size: number;
6
- readonly file: File | fs.ReadStream;
7
- constructor(name: string, size: number, file: File | fs.ReadStream);
6
+ readonly file: File | fs.ReadStream | Buffer;
7
+ constructor(name: string, size: number, file: File | fs.ReadStream | Buffer);
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bugsplat-file.js","sourceRoot":"","sources":["../../../../src/common/file/bugsplat-file.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IAEH;IACA;IACA;IAHpB,YACoB,IAAY,EACZ,IAAY,EACZ,IAA0B;QAF1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAsB;IAC1C,CAAC;CACR"}
1
+ {"version":3,"file":"bugsplat-file.js","sourceRoot":"","sources":["../../../../src/common/file/bugsplat-file.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IAEH;IACA;IACA;IAHpB,YACoB,IAAY,EACZ,IAAY,EACZ,IAAmC;QAFnC,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAA+B;IACnD,CAAC;CACR"}
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@bugsplat/js-api-client",
3
3
  "description": "JS client for consuming the BugSplat API",
4
- "version": "1.0.3",
4
+ "version": "1.1.3",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
7
7
  "files": [
8
8
  "dist"
9
9
  ],
10
10
  "scripts": {
11
+ "prepare": "husky install",
11
12
  "pretest": "npm run lint:fix",
12
13
  "test": "ts-node -r tsconfig-paths/register node_modules/jasmine/bin/jasmine --config=spec/support/jasmine.spec.json",
13
14
  "test:teamcity": "ts-node -r tsconfig-paths/register node_modules/jasmine/bin/jasmine --config=spec/support/jasmine.teamcity.spec.json",
@@ -20,11 +21,12 @@
20
21
  "build:cjs": "tsc -p tsconfig.cjs.json && tsconfig-replace-paths -p tsconfig.json -o ./dist/cjs -s ./src",
21
22
  "build:esm": "tsc -p tsconfig.esm.json && tsconfig-replace-paths -p tsconfig.json -o ./dist/esm -s ./src",
22
23
  "watch:cjs": "tsc -p tsconfig.cjs.json -w",
23
- "watch:esm": "tsc -p tsconfig.esm.json -w"
24
+ "watch:esm": "tsc -p tsconfig.esm.json -w",
25
+ "semantic-release": "semantic-release"
24
26
  },
25
27
  "repository": {
26
28
  "type": "git",
27
- "url": "git+https://github.com/BugSplat-Git/bugsplat-js-api-client.git"
29
+ "url": "https://github.com/BugSplat-Git/bugsplat-js-api-client.git"
28
30
  },
29
31
  "author": "@bobbyg603",
30
32
  "license": "MIT",
@@ -32,6 +34,18 @@
32
34
  "url": "https://github.com/BugSplat-Git/bugsplat-js-api-client/issues"
33
35
  },
34
36
  "homepage": "https://github.com/BugSplat-Git/bugsplat-js-api-client#readme",
37
+ "release": {
38
+ "branches": [
39
+ "main"
40
+ ],
41
+ "plugins": [
42
+ "@semantic-release/release-notes-generator",
43
+ "@semantic-release/changelog",
44
+ "@semantic-release/npm",
45
+ "@semantic-release/git",
46
+ "@semantic-release/github"
47
+ ]
48
+ },
35
49
  "dependencies": {
36
50
  "argument-contracts": "^1.2.3",
37
51
  "fetch-ponyfill": "^7.1.0",
@@ -40,14 +54,20 @@
40
54
  "rxjs": "^7.1.0"
41
55
  },
42
56
  "devDependencies": {
57
+ "@commitlint/cli": "^15.0.0",
58
+ "@commitlint/config-conventional": "^15.0.0",
59
+ "@semantic-release/changelog": "^6.0.1",
60
+ "@semantic-release/git": "^10.0.1",
43
61
  "@types/jasmine": "^3.7.4",
44
62
  "@types/node": "^15.6.1",
45
63
  "@typescript-eslint/eslint-plugin": "^4.31.0",
46
64
  "@typescript-eslint/parser": "^4.31.0",
47
65
  "dotenv": "^10.0.0",
48
66
  "eslint": "^7.32.0",
67
+ "husky": "^7.0.4",
49
68
  "jasmine": "^3.7.0",
50
69
  "jasmine-reporters": "^2.4.0",
70
+ "semantic-release": "^18.0.0",
51
71
  "ts-node": "^10.0.0",
52
72
  "tsconfig-paths": "^3.11.0",
53
73
  "tsconfig-replace-paths": "^0.0.5",