@opengovsg/refx-ts-sdk 0.0.0-develop-1759151439 → 0.0.0-develop-alpha-1762412839
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/README.md +18 -0
- package/api/resources/eligibility/client/Client.d.ts +3 -0
- package/api/resources/eligibility/client/Client.js +7 -10
- package/api/resources/eligibility/client/requests/EligibilityGetRequest.d.ts +8 -5
- package/api/resources/health/client/Client.js +1 -1
- package/api/resources/index.d.ts +2 -1
- package/api/resources/index.js +3 -2
- package/api/resources/links/client/Client.js +1 -1
- package/api/resources/links/client/requests/CreateLinkReqUpsert.d.ts +8 -0
- package/api/resources/links/types/CreateLinkReqUpsertClinicType.d.ts +11 -0
- package/api/resources/links/types/CreateLinkReqUpsertClinicType.js +10 -0
- package/api/resources/links/types/index.d.ts +1 -0
- package/api/resources/links/types/index.js +1 -0
- package/api/resources/notes/client/Client.js +1 -1
- package/api/resources/offerings/client/Client.d.ts +6 -2
- package/api/resources/offerings/client/Client.js +13 -15
- package/api/resources/offerings/client/requests/OfferingsListRequest.d.ts +10 -6
- package/api/resources/public/client/Client.js +1 -1
- package/api/resources/referrals/client/Client.js +9 -9
- package/api/resources/referrals/client/requests/CreateReferralReq.d.ts +6 -0
- package/api/resources/referrals/index.d.ts +1 -0
- package/api/resources/referrals/index.js +1 -0
- package/api/resources/referrals/types/CreateReferralReqClinicType.d.ts +11 -0
- package/api/resources/referrals/types/CreateReferralReqClinicType.js +10 -0
- package/api/resources/referrals/types/index.d.ts +1 -0
- package/api/resources/referrals/types/index.js +17 -0
- package/api/resources/webhooks/client/Client.js +2 -2
- package/api/types/AdditionalReferralField.d.ts +2 -1
- package/api/types/AdditionalReferralField.js +1 -0
- package/api/types/AppointmentDto.d.ts +12 -0
- package/api/types/AppointmentDto.js +5 -0
- package/api/types/AppointmentDtoStatus.d.ts +11 -0
- package/api/types/AppointmentDtoStatus.js +13 -0
- package/api/types/CreatePatientReq.d.ts +2 -0
- package/api/types/FullReferralDto.d.ts +7 -0
- package/api/types/FullReferralDtoClinicType.d.ts +11 -0
- package/api/types/FullReferralDtoClinicType.js +10 -0
- package/api/types/GetReferralPatientDto.d.ts +2 -0
- package/api/types/PublicReferralDto.d.ts +6 -0
- package/api/types/PublicReferralDtoClinicType.d.ts +11 -0
- package/api/types/PublicReferralDtoClinicType.js +10 -0
- package/api/types/ReferralDto.d.ts +6 -0
- package/api/types/ReferralDtoClinicType.d.ts +11 -0
- package/api/types/ReferralDtoClinicType.js +10 -0
- package/api/types/ReferralLinkType.d.ts +2 -1
- package/api/types/ReferralLinkType.js +1 -0
- package/api/types/ReferrerIdType.d.ts +2 -1
- package/api/types/ReferrerIdType.js +1 -0
- package/api/types/UpdateEmailAckOfferingReq.d.ts +9 -0
- package/api/types/UpdateEmailAckOfferingReq.js +5 -0
- package/api/types/index.d.ts +6 -0
- package/api/types/index.js +6 -0
- package/browser/jsonwebtoken-stub.d.ts +5 -0
- package/browser/jsonwebtoken-stub.js +10 -0
- package/dist/api/resources/eligibility/client/Client.d.ts +3 -0
- package/dist/api/resources/eligibility/client/Client.js +7 -10
- package/dist/api/resources/eligibility/client/requests/EligibilityGetRequest.d.ts +8 -5
- package/dist/api/resources/health/client/Client.js +1 -1
- package/dist/api/resources/index.d.ts +2 -1
- package/dist/api/resources/index.js +3 -2
- package/dist/api/resources/links/client/Client.js +1 -1
- package/dist/api/resources/links/client/requests/CreateLinkReqUpsert.d.ts +8 -0
- package/dist/api/resources/links/types/CreateLinkReqUpsertClinicType.d.ts +11 -0
- package/dist/api/resources/links/types/CreateLinkReqUpsertClinicType.js +10 -0
- package/dist/api/resources/links/types/index.d.ts +1 -0
- package/dist/api/resources/links/types/index.js +1 -0
- package/dist/api/resources/notes/client/Client.js +1 -1
- package/dist/api/resources/offerings/client/Client.d.ts +6 -2
- package/dist/api/resources/offerings/client/Client.js +13 -15
- package/dist/api/resources/offerings/client/requests/OfferingsListRequest.d.ts +10 -6
- package/dist/api/resources/public/client/Client.js +1 -1
- package/dist/api/resources/referrals/client/Client.js +9 -9
- package/dist/api/resources/referrals/client/requests/CreateReferralReq.d.ts +6 -0
- package/dist/api/resources/referrals/index.d.ts +1 -0
- package/dist/api/resources/referrals/index.js +1 -0
- package/dist/api/resources/referrals/types/CreateReferralReqClinicType.d.ts +11 -0
- package/dist/api/resources/referrals/types/CreateReferralReqClinicType.js +10 -0
- package/dist/api/resources/referrals/types/index.d.ts +1 -0
- package/dist/api/resources/referrals/types/index.js +17 -0
- package/dist/api/resources/webhooks/client/Client.js +2 -2
- package/dist/api/types/AdditionalReferralField.d.ts +2 -1
- package/dist/api/types/AdditionalReferralField.js +1 -0
- package/dist/api/types/AppointmentDto.d.ts +12 -0
- package/dist/api/types/AppointmentDto.js +5 -0
- package/dist/api/types/AppointmentDtoStatus.d.ts +11 -0
- package/dist/api/types/AppointmentDtoStatus.js +13 -0
- package/dist/api/types/CreatePatientReq.d.ts +2 -0
- package/dist/api/types/FullReferralDto.d.ts +7 -0
- package/dist/api/types/FullReferralDtoClinicType.d.ts +11 -0
- package/dist/api/types/FullReferralDtoClinicType.js +10 -0
- package/dist/api/types/GetReferralPatientDto.d.ts +2 -0
- package/dist/api/types/PublicReferralDto.d.ts +6 -0
- package/dist/api/types/PublicReferralDtoClinicType.d.ts +11 -0
- package/dist/api/types/PublicReferralDtoClinicType.js +10 -0
- package/dist/api/types/ReferralDto.d.ts +6 -0
- package/dist/api/types/ReferralDtoClinicType.d.ts +11 -0
- package/dist/api/types/ReferralDtoClinicType.js +10 -0
- package/dist/api/types/ReferralLinkType.d.ts +2 -1
- package/dist/api/types/ReferralLinkType.js +1 -0
- package/dist/api/types/ReferrerIdType.d.ts +2 -1
- package/dist/api/types/ReferrerIdType.js +1 -0
- package/dist/api/types/UpdateEmailAckOfferingReq.d.ts +9 -0
- package/dist/api/types/UpdateEmailAckOfferingReq.js +5 -0
- package/dist/api/types/index.d.ts +6 -0
- package/dist/api/types/index.js +6 -0
- package/dist/browser/jsonwebtoken-stub.d.ts +5 -0
- package/dist/browser/jsonwebtoken-stub.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wrapper/ReferralExchangeJwtClient.d.ts +10 -0
- package/dist/wrapper/ReferralExchangeJwtClient.js +81 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +6 -2
- package/reference.md +8 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/wrapper/ReferralExchangeJwtClient.d.ts +10 -0
- package/wrapper/ReferralExchangeJwtClient.js +81 -0
|
@@ -0,0 +1,81 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ReferralExchangeJwtClient = void 0;
|
|
27
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
28
|
+
const Client_1 = require("../Client");
|
|
29
|
+
const Fetcher_1 = require("../core/fetcher/Fetcher");
|
|
30
|
+
const JWT_TTL_SECONDS = 15;
|
|
31
|
+
class ReferralExchangeJwtClient extends Client_1.ReferralExchangeClient {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
const { privateKey, apiKeyName } = options, baseOptions = __rest(options, ["privateKey", "apiKeyName"]);
|
|
34
|
+
const signer = new JwtSigner({ privateKey, issuer: apiKeyName });
|
|
35
|
+
const fetcher = createJwtFetcher(signer);
|
|
36
|
+
super(Object.assign(Object.assign({}, baseOptions), { fetcher }));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.ReferralExchangeJwtClient = ReferralExchangeJwtClient;
|
|
40
|
+
class JwtSigner {
|
|
41
|
+
constructor({ privateKey, issuer }) {
|
|
42
|
+
this.privateKey = privateKey;
|
|
43
|
+
this.issuer = issuer;
|
|
44
|
+
}
|
|
45
|
+
getToken() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const nowSeconds = Math.floor(Date.now() / 1000);
|
|
48
|
+
if (this.cachedToken != null && nowSeconds < this.cachedToken.expiresAtEpochSeconds - 1) {
|
|
49
|
+
return this.cachedToken.token;
|
|
50
|
+
}
|
|
51
|
+
const { token, expiresAtEpochSeconds } = createSignedJwt({
|
|
52
|
+
privateKey: this.privateKey,
|
|
53
|
+
issuer: this.issuer,
|
|
54
|
+
});
|
|
55
|
+
this.cachedToken = { token, expiresAtEpochSeconds };
|
|
56
|
+
return token;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function createJwtFetcher(signer) {
|
|
61
|
+
return (args) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
var _a;
|
|
63
|
+
const token = yield signer.getToken();
|
|
64
|
+
const headers = Object.assign({}, ((_a = args.headers) !== null && _a !== void 0 ? _a : {}));
|
|
65
|
+
headers.Authorization = `Bearer ${token}`;
|
|
66
|
+
return (0, Fetcher_1.fetcherImpl)(Object.assign(Object.assign({}, args), { headers }));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function createSignedJwt({ privateKey, issuer }) {
|
|
70
|
+
const issuedAt = Math.floor(Date.now() / 1000);
|
|
71
|
+
const expiresAtEpochSeconds = issuedAt + JWT_TTL_SECONDS;
|
|
72
|
+
const token = jsonwebtoken_1.default.sign({}, privateKey, {
|
|
73
|
+
algorithm: "ES256",
|
|
74
|
+
issuer,
|
|
75
|
+
expiresIn: JWT_TTL_SECONDS,
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
token,
|
|
79
|
+
expiresAtEpochSeconds,
|
|
80
|
+
};
|
|
81
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * as ReferralExchange from "./api";
|
|
2
2
|
export { ReferralExchangeClient } from "./Client";
|
|
3
|
+
export { ReferralExchangeJwtClient } from "./wrapper/ReferralExchangeJwtClient";
|
|
3
4
|
export { ReferralExchangeEnvironment } from "./environments";
|
|
4
5
|
export { ReferralExchangeError, ReferralExchangeTimeoutError } from "./errors";
|
package/index.js
CHANGED
|
@@ -33,10 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ReferralExchangeTimeoutError = exports.ReferralExchangeError = exports.ReferralExchangeEnvironment = exports.ReferralExchangeClient = exports.ReferralExchange = void 0;
|
|
36
|
+
exports.ReferralExchangeTimeoutError = exports.ReferralExchangeError = exports.ReferralExchangeEnvironment = exports.ReferralExchangeJwtClient = exports.ReferralExchangeClient = exports.ReferralExchange = void 0;
|
|
37
37
|
exports.ReferralExchange = __importStar(require("./api"));
|
|
38
38
|
var Client_1 = require("./Client");
|
|
39
39
|
Object.defineProperty(exports, "ReferralExchangeClient", { enumerable: true, get: function () { return Client_1.ReferralExchangeClient; } });
|
|
40
|
+
var ReferralExchangeJwtClient_1 = require("./wrapper/ReferralExchangeJwtClient");
|
|
41
|
+
Object.defineProperty(exports, "ReferralExchangeJwtClient", { enumerable: true, get: function () { return ReferralExchangeJwtClient_1.ReferralExchangeJwtClient; } });
|
|
40
42
|
var environments_1 = require("./environments");
|
|
41
43
|
Object.defineProperty(exports, "ReferralExchangeEnvironment", { enumerable: true, get: function () { return environments_1.ReferralExchangeEnvironment; } });
|
|
42
44
|
var errors_1 = require("./errors");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengovsg/refx-ts-sdk",
|
|
3
|
-
"version": "0.0.0-develop-
|
|
3
|
+
"version": "0.0.0-develop-alpha-1762412839",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": "https://github.com/opengovsg/refer-ts-sdk",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
"format": "prettier . --write --ignore-unknown",
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"prepack": "cp -rv dist/. .",
|
|
12
|
+
"pretest": "yarn build",
|
|
12
13
|
"test": "jest"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"url-join": "4.0.1",
|
|
16
17
|
"form-data": "^4.0.0",
|
|
17
18
|
"formdata-node": "^6.0.3",
|
|
19
|
+
"jsonwebtoken": "^9.0.2",
|
|
18
20
|
"node-fetch": "^2.7.0",
|
|
19
21
|
"qs": "^6.13.1",
|
|
20
22
|
"readable-stream": "^4.5.2"
|
|
@@ -23,6 +25,7 @@
|
|
|
23
25
|
"@types/url-join": "4.0.1",
|
|
24
26
|
"@types/qs": "^6.9.17",
|
|
25
27
|
"@types/node-fetch": "^2.6.12",
|
|
28
|
+
"@types/jsonwebtoken": "^9.0.7",
|
|
26
29
|
"@types/readable-stream": "^4.0.18",
|
|
27
30
|
"webpack": "^5.97.1",
|
|
28
31
|
"ts-loader": "^9.5.1",
|
|
@@ -37,6 +40,7 @@
|
|
|
37
40
|
"browser": {
|
|
38
41
|
"fs": false,
|
|
39
42
|
"os": false,
|
|
40
|
-
"path": false
|
|
43
|
+
"path": false,
|
|
44
|
+
"jsonwebtoken": "./dist/browser/jsonwebtoken-stub.js"
|
|
41
45
|
}
|
|
42
46
|
}
|
package/reference.md
CHANGED
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
await client.eligibility.get({
|
|
19
|
+
referrerId: "referrerId",
|
|
20
|
+
referrerIdType: "mcr",
|
|
21
|
+
referrerInstitutionId: "referrerInstitutionId",
|
|
19
22
|
uin: "uin",
|
|
20
23
|
offeringId: "offeringId",
|
|
21
24
|
});
|
|
@@ -631,7 +634,11 @@ await client.notes.create("referralId", {
|
|
|
631
634
|
<dd>
|
|
632
635
|
|
|
633
636
|
```typescript
|
|
634
|
-
await client.offerings.list(
|
|
637
|
+
await client.offerings.list({
|
|
638
|
+
referrerId: "referrerId",
|
|
639
|
+
referrerIdType: "mcr",
|
|
640
|
+
referrerInstitutionId: "referrerInstitutionId",
|
|
641
|
+
});
|
|
635
642
|
```
|
|
636
643
|
|
|
637
644
|
</dd>
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.0.
|
|
1
|
+
export declare const SDK_VERSION = "0.0.54";
|
package/version.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReferralExchangeClient } from "../Client";
|
|
2
|
+
export declare namespace ReferralExchangeJwtClient {
|
|
3
|
+
interface Options extends Omit<ReferralExchangeClient.Options, "fetcher" | "apiKey"> {
|
|
4
|
+
privateKey: string;
|
|
5
|
+
apiKeyName: string;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class ReferralExchangeJwtClient extends ReferralExchangeClient {
|
|
9
|
+
constructor(options: ReferralExchangeJwtClient.Options);
|
|
10
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ReferralExchangeJwtClient = void 0;
|
|
27
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
28
|
+
const Client_1 = require("../Client");
|
|
29
|
+
const Fetcher_1 = require("../core/fetcher/Fetcher");
|
|
30
|
+
const JWT_TTL_SECONDS = 15;
|
|
31
|
+
class ReferralExchangeJwtClient extends Client_1.ReferralExchangeClient {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
const { privateKey, apiKeyName } = options, baseOptions = __rest(options, ["privateKey", "apiKeyName"]);
|
|
34
|
+
const signer = new JwtSigner({ privateKey, issuer: apiKeyName });
|
|
35
|
+
const fetcher = createJwtFetcher(signer);
|
|
36
|
+
super(Object.assign(Object.assign({}, baseOptions), { fetcher }));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.ReferralExchangeJwtClient = ReferralExchangeJwtClient;
|
|
40
|
+
class JwtSigner {
|
|
41
|
+
constructor({ privateKey, issuer }) {
|
|
42
|
+
this.privateKey = privateKey;
|
|
43
|
+
this.issuer = issuer;
|
|
44
|
+
}
|
|
45
|
+
getToken() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const nowSeconds = Math.floor(Date.now() / 1000);
|
|
48
|
+
if (this.cachedToken != null && nowSeconds < this.cachedToken.expiresAtEpochSeconds - 1) {
|
|
49
|
+
return this.cachedToken.token;
|
|
50
|
+
}
|
|
51
|
+
const { token, expiresAtEpochSeconds } = createSignedJwt({
|
|
52
|
+
privateKey: this.privateKey,
|
|
53
|
+
issuer: this.issuer,
|
|
54
|
+
});
|
|
55
|
+
this.cachedToken = { token, expiresAtEpochSeconds };
|
|
56
|
+
return token;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function createJwtFetcher(signer) {
|
|
61
|
+
return (args) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
var _a;
|
|
63
|
+
const token = yield signer.getToken();
|
|
64
|
+
const headers = Object.assign({}, ((_a = args.headers) !== null && _a !== void 0 ? _a : {}));
|
|
65
|
+
headers.Authorization = `Bearer ${token}`;
|
|
66
|
+
return (0, Fetcher_1.fetcherImpl)(Object.assign(Object.assign({}, args), { headers }));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function createSignedJwt({ privateKey, issuer }) {
|
|
70
|
+
const issuedAt = Math.floor(Date.now() / 1000);
|
|
71
|
+
const expiresAtEpochSeconds = issuedAt + JWT_TTL_SECONDS;
|
|
72
|
+
const token = jsonwebtoken_1.default.sign({}, privateKey, {
|
|
73
|
+
algorithm: "ES256",
|
|
74
|
+
issuer,
|
|
75
|
+
expiresIn: JWT_TTL_SECONDS,
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
token,
|
|
79
|
+
expiresAtEpochSeconds,
|
|
80
|
+
};
|
|
81
|
+
}
|