@parra/parra-js-sdk 0.0.25 → 0.2.0
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.
- package/dist/AccessToken.d.ts +1 -0
- package/dist/AccessToken.js +63 -0
- package/dist/ParraAPI.d.ts +216 -563
- package/dist/ParraAPI.js +51 -552
- package/dist/index.d.ts +3 -5
- package/dist/index.js +5 -7
- package/package.json +5 -1
- package/dist/AuthInterceptor.d.ts +0 -13
- package/dist/AuthInterceptor.js +0 -99
- package/dist/HTTPClient.d.ts +0 -30
- package/dist/HTTPClient.js +0 -158
- package/dist/HTTPInterceptor.d.ts +0 -5
- package/dist/HTTPInterceptor.js +0 -2
- package/dist/URLBuilder.d.ts +0 -7
- package/dist/URLBuilder.js +0 -24
- package/dist/models/AdminUser.d.ts +0 -12
- package/dist/models/AdminUser.js +0 -2
- package/dist/models/Business.d.ts +0 -23
- package/dist/models/Business.js +0 -2
- package/dist/models/BusinessProfile.d.ts +0 -10
- package/dist/models/BusinessProfile.js +0 -2
- package/dist/models/Category.d.ts +0 -18
- package/dist/models/Category.js +0 -2
- package/dist/models/City.d.ts +0 -7
- package/dist/models/City.js +0 -2
- package/dist/models/CollectionResponse.d.ts +0 -6
- package/dist/models/CollectionResponse.js +0 -2
- package/dist/models/Coordinate.d.ts +0 -4
- package/dist/models/Coordinate.js +0 -2
- package/dist/models/Employee.d.ts +0 -22
- package/dist/models/Employee.js +0 -2
- package/dist/models/EmployeeProfile.d.ts +0 -6
- package/dist/models/EmployeeProfile.js +0 -2
- package/dist/models/Entity.d.ts +0 -6
- package/dist/models/Entity.js +0 -2
- package/dist/models/Feature.d.ts +0 -7
- package/dist/models/Feature.js +0 -2
- package/dist/models/ImageAsset.d.ts +0 -10
- package/dist/models/ImageAsset.js +0 -2
- package/dist/models/Industry.d.ts +0 -9
- package/dist/models/Industry.js +0 -2
- package/dist/models/Location.d.ts +0 -39
- package/dist/models/Location.js +0 -2
- package/dist/models/LocationAddress.d.ts +0 -17
- package/dist/models/LocationAddress.js +0 -2
- package/dist/models/LocationPhoto.d.ts +0 -10
- package/dist/models/LocationPhoto.js +0 -2
- package/dist/models/LocationProfile.d.ts +0 -12
- package/dist/models/LocationProfile.js +0 -2
- package/dist/models/LocationRating.d.ts +0 -10
- package/dist/models/LocationRating.js +0 -2
- package/dist/models/LocationReview.d.ts +0 -22
- package/dist/models/LocationReview.js +0 -2
- package/dist/models/LocationReviewSource.d.ts +0 -5
- package/dist/models/LocationReviewSource.js +0 -2
- package/dist/models/LocationReviewer.d.ts +0 -4
- package/dist/models/LocationReviewer.js +0 -2
- package/dist/models/LocationService.d.ts +0 -9
- package/dist/models/LocationService.js +0 -2
- package/dist/models/LocationServiceArea.d.ts +0 -11
- package/dist/models/LocationServiceArea.js +0 -2
- package/dist/models/Pagination.d.ts +0 -2
- package/dist/models/Pagination.js +0 -2
- package/dist/models/Query.d.ts +0 -9
- package/dist/models/Query.js +0 -2
- package/dist/models/StripeAccountLink.d.ts +0 -10
- package/dist/models/StripeAccountLink.js +0 -2
- package/dist/models/Tag.d.ts +0 -11
- package/dist/models/Tag.js +0 -2
- package/dist/models/User.d.ts +0 -12
- package/dist/models/User.js +0 -2
- package/dist/models/index.d.ts +0 -8
- package/dist/models/index.js +0 -20
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var assert_1 = __importDefault(require("assert"));
|
|
7
|
+
var jwt = require('jsonwebtoken');
|
|
8
|
+
var AccessToken = /** @class */ (function () {
|
|
9
|
+
/**
|
|
10
|
+
* @constructor
|
|
11
|
+
* @param {string} tenantId - The account's unique ID to which access is scoped
|
|
12
|
+
* @param {string} apiKeyId - The signing key's unique ID
|
|
13
|
+
* @param {string} apiKeySecret - The apiKeySecret to sign the token with
|
|
14
|
+
* @param {object} options - ...
|
|
15
|
+
* @param {number} [options.ttl=3600] - Time to live in seconds
|
|
16
|
+
* @param {string} [options.identity] - The identity of the first person
|
|
17
|
+
*/
|
|
18
|
+
function AccessToken(options) {
|
|
19
|
+
assert_1.default(options.tenantId, 'tenantId is required');
|
|
20
|
+
assert_1.default(options.apiKeyId, 'apiKeyId is required');
|
|
21
|
+
assert_1.default(options.apiKeySecret, 'apiKeySecret is required');
|
|
22
|
+
this.tenantId = options.tenantId;
|
|
23
|
+
this.apiKeyId = options.apiKeyId;
|
|
24
|
+
this.apiKeySecret = options.apiKeySecret;
|
|
25
|
+
this.ttl = options.ttl || 3600;
|
|
26
|
+
this.identity = String(options.identity);
|
|
27
|
+
this.nbf = options.nbf;
|
|
28
|
+
this.grants = [];
|
|
29
|
+
}
|
|
30
|
+
AccessToken.prototype.addGrant = function (grant) {
|
|
31
|
+
this.grants.push(grant);
|
|
32
|
+
};
|
|
33
|
+
AccessToken.prototype.toJwt = function (algorithm) {
|
|
34
|
+
algorithm = algorithm || AccessToken.DEFAULT_ALGORITHM;
|
|
35
|
+
if (!AccessToken.ALGORITHMS.includes(algorithm)) {
|
|
36
|
+
throw new Error('Algorithm not supported. Allowed values are ' + AccessToken.ALGORITHMS.join(', '));
|
|
37
|
+
}
|
|
38
|
+
var grants = this.grants.reduce(function (acc, grant) {
|
|
39
|
+
acc[grant.key] = grant.toPayload();
|
|
40
|
+
}, { identity: this.identity });
|
|
41
|
+
var now = Math.floor(Date.now() / 1000);
|
|
42
|
+
var payload = {
|
|
43
|
+
jti: this.apiKeyId + '-' + now,
|
|
44
|
+
grants: grants,
|
|
45
|
+
nbf: this.nbf,
|
|
46
|
+
};
|
|
47
|
+
var header = {
|
|
48
|
+
cty: 'parra-fpa;v=1',
|
|
49
|
+
typ: 'JWT',
|
|
50
|
+
};
|
|
51
|
+
return jwt.sign(payload, this.apiKeySecret, {
|
|
52
|
+
header: header,
|
|
53
|
+
algorithm: algorithm,
|
|
54
|
+
issuer: this.apiKeyId,
|
|
55
|
+
subject: this.tenantId,
|
|
56
|
+
expiresIn: this.ttl,
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
AccessToken.DEFAULT_ALGORITHM = 'HS256';
|
|
60
|
+
AccessToken.ALGORITHMS = ['HS256', 'HS384', 'HS512'];
|
|
61
|
+
return AccessToken;
|
|
62
|
+
}());
|
|
63
|
+
module.exports = AccessToken;
|