@boxyhq/saml-jackson 0.3.6-beta.642 → 0.3.6-beta.644
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/controller/api.js
CHANGED
@@ -34,6 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.APIController = void 0;
|
35
35
|
const crypto_1 = __importDefault(require("crypto"));
|
36
36
|
const dbutils = __importStar(require("../db/utils"));
|
37
|
+
const metrics = __importStar(require("../opentelemetry/metrics"));
|
37
38
|
const saml_1 = __importDefault(require("../saml/saml"));
|
38
39
|
const x509_1 = __importDefault(require("../saml/x509"));
|
39
40
|
const error_1 = require("./error");
|
@@ -124,6 +125,7 @@ class APIController {
|
|
124
125
|
config(body) {
|
125
126
|
return __awaiter(this, void 0, void 0, function* () {
|
126
127
|
const { encodedRawMetadata, rawMetadata, defaultRedirectUrl, redirectUrl, tenant, product } = body;
|
128
|
+
metrics.increment('createConfig');
|
127
129
|
this._validateIdPConfig(body);
|
128
130
|
let metaData = rawMetadata;
|
129
131
|
if (encodedRawMetadata) {
|
@@ -214,6 +216,7 @@ class APIController {
|
|
214
216
|
getConfig(body) {
|
215
217
|
return __awaiter(this, void 0, void 0, function* () {
|
216
218
|
const { clientID, tenant, product } = body;
|
219
|
+
metrics.increment('getConfig');
|
217
220
|
if (clientID) {
|
218
221
|
const samlConfig = yield this.configStore.get(clientID);
|
219
222
|
return samlConfig ? { provider: samlConfig.idpMetadata.provider } : {};
|
@@ -271,6 +274,7 @@ class APIController {
|
|
271
274
|
deleteConfig(body) {
|
272
275
|
return __awaiter(this, void 0, void 0, function* () {
|
273
276
|
const { clientID, clientSecret, tenant, product } = body;
|
277
|
+
metrics.increment('deleteConfig');
|
274
278
|
if (clientID && clientSecret) {
|
275
279
|
const samlConfig = yield this.configStore.get(clientID);
|
276
280
|
if (!samlConfig) {
|
package/dist/controller/oauth.js
CHANGED
@@ -33,15 +33,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
34
34
|
exports.OAuthController = void 0;
|
35
35
|
const crypto_1 = __importDefault(require("crypto"));
|
36
|
+
const util_1 = require("util");
|
37
|
+
const zlib_1 = require("zlib");
|
36
38
|
const dbutils = __importStar(require("../db/utils"));
|
39
|
+
const metrics = __importStar(require("../opentelemetry/metrics"));
|
37
40
|
const saml_1 = __importDefault(require("../saml/saml"));
|
38
41
|
const error_1 = require("./error");
|
39
42
|
const allowed = __importStar(require("./oauth/allowed"));
|
40
43
|
const codeVerifier = __importStar(require("./oauth/code-verifier"));
|
41
44
|
const redirect = __importStar(require("./oauth/redirect"));
|
42
45
|
const utils_1 = require("./utils");
|
43
|
-
const util_1 = require("util");
|
44
|
-
const zlib_1 = require("zlib");
|
45
46
|
const deflateRawAsync = (0, util_1.promisify)(zlib_1.deflateRaw);
|
46
47
|
const relayStatePrefix = 'boxyhq_jackson_';
|
47
48
|
function getEncodedClientId(client_id) {
|
@@ -74,6 +75,7 @@ class OAuthController {
|
|
74
75
|
const { response_type = 'code', client_id, redirect_uri, state, tenant, product, code_challenge, code_challenge_method = '',
|
75
76
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
76
77
|
provider = 'saml', } = body;
|
78
|
+
metrics.increment('oauthAuthorize');
|
77
79
|
if (!redirect_uri) {
|
78
80
|
throw new error_1.JacksonError('Please specify a redirect URL.', 400);
|
79
81
|
}
|
@@ -262,6 +264,7 @@ class OAuthController {
|
|
262
264
|
token(body) {
|
263
265
|
return __awaiter(this, void 0, void 0, function* () {
|
264
266
|
const { client_id, client_secret, code_verifier, code, grant_type = 'authorization_code' } = body;
|
267
|
+
metrics.increment('oauthToken');
|
265
268
|
if (grant_type !== 'authorization_code') {
|
266
269
|
throw new error_1.JacksonError('Unsupported grant_type', 400);
|
267
270
|
}
|
@@ -339,6 +342,7 @@ class OAuthController {
|
|
339
342
|
userInfo(token) {
|
340
343
|
return __awaiter(this, void 0, void 0, function* () {
|
341
344
|
const rsp = yield this.tokenStore.get(token);
|
345
|
+
metrics.increment('oauthUserInfo');
|
342
346
|
if (!rsp || !rsp.claims) {
|
343
347
|
throw new error_1.JacksonError('Invalid token', 403);
|
344
348
|
}
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { JacksonOption } from './typings';
|
2
1
|
import { APIController } from './controller/api';
|
3
2
|
import { OAuthController } from './controller/oauth';
|
3
|
+
import { JacksonOption } from './typings';
|
4
4
|
export declare const controllers: (opts: JacksonOption) => Promise<{
|
5
5
|
apiController: APIController;
|
6
6
|
oauthController: OAuthController;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.increment = void 0;
|
4
|
+
const api_metrics_1 = require("@opentelemetry/api-metrics");
|
5
|
+
const counters = {
|
6
|
+
createConfig: {
|
7
|
+
name: 'saml.config.create',
|
8
|
+
description: 'Number of SAML config create requests',
|
9
|
+
},
|
10
|
+
getConfig: {
|
11
|
+
name: 'saml.config.get',
|
12
|
+
description: 'Number of SAML config get requests',
|
13
|
+
},
|
14
|
+
deleteConfig: {
|
15
|
+
name: 'saml.config.delete',
|
16
|
+
description: 'Number of SAML config delete requests',
|
17
|
+
},
|
18
|
+
oauthAuthorize: {
|
19
|
+
name: 'saml.oauth.authorize',
|
20
|
+
description: 'Number of SAML oauth authorize requests',
|
21
|
+
},
|
22
|
+
oauthToken: {
|
23
|
+
name: 'saml.oauth.token',
|
24
|
+
description: 'Number of SAML oauth token requests',
|
25
|
+
},
|
26
|
+
oauthUserInfo: {
|
27
|
+
name: 'saml.oauth.userinfo',
|
28
|
+
description: 'Number of SAML oauth user info requests',
|
29
|
+
}
|
30
|
+
};
|
31
|
+
const createCounter = (action) => {
|
32
|
+
const meter = api_metrics_1.metrics.getMeterProvider().getMeter('saml-jackson');
|
33
|
+
const counter = counters[action];
|
34
|
+
return meter.createCounter(counter.name, {
|
35
|
+
description: counter.description,
|
36
|
+
});
|
37
|
+
};
|
38
|
+
const increment = (action) => {
|
39
|
+
const counter = createCounter(action);
|
40
|
+
counter.add(1);
|
41
|
+
};
|
42
|
+
exports.increment = increment;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@boxyhq/saml-jackson",
|
3
|
-
"version": "0.3.6-beta.
|
3
|
+
"version": "0.3.6-beta.644",
|
4
4
|
"description": "SAML 2.0 service",
|
5
5
|
"keywords": [
|
6
6
|
"SAML 2.0"
|
@@ -37,6 +37,7 @@
|
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
39
|
"@boxyhq/saml20": "0.2.0",
|
40
|
+
"@opentelemetry/api-metrics": "0.27.0",
|
40
41
|
"@peculiar/webcrypto": "1.2.3",
|
41
42
|
"@peculiar/x509": "1.6.1",
|
42
43
|
"cors": "2.8.5",
|