@boxyhq/saml-jackson 0.3.6-beta.606 → 0.3.6-beta.618

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.
@@ -14,7 +14,6 @@ export declare class OAuthController implements IOAuthController {
14
14
  });
15
15
  authorize(body: OAuthReqBody): Promise<{
16
16
  redirect_url: string;
17
- authorize_form: string;
18
17
  }>;
19
18
  samlResponse(body: SAMLResponsePayload): Promise<{
20
19
  redirect_url: string;
@@ -40,6 +40,9 @@ const allowed = __importStar(require("./oauth/allowed"));
40
40
  const codeVerifier = __importStar(require("./oauth/code-verifier"));
41
41
  const redirect = __importStar(require("./oauth/redirect"));
42
42
  const utils_1 = require("./utils");
43
+ const util_1 = require("util");
44
+ const zlib_1 = require("zlib");
45
+ const deflateRawAsync = (0, util_1.promisify)(zlib_1.deflateRaw);
43
46
  const relayStatePrefix = 'boxyhq_jackson_';
44
47
  function getEncodedClientId(client_id) {
45
48
  try {
@@ -130,26 +133,13 @@ class OAuthController {
130
133
  code_challenge,
131
134
  code_challenge_method,
132
135
  });
133
- const relayState = relayStatePrefix + sessionId;
134
- const samlReqEnc = Buffer.from(samlReq.request).toString('base64');
135
- const { sso } = samlConfig.idpMetadata;
136
- let redirectUrl = '';
137
- let authorizeForm = '';
138
- // HTTP redirect binding
139
- if ('redirectUrl' in sso) {
140
- redirectUrl = redirect.success(sso.redirectUrl, {
141
- RelayState: relayState,
142
- SAMLRequest: samlReqEnc,
143
- });
144
- }
145
- // HTTP POST binding
146
- if ('postUrl' in sso) {
147
- authorizeForm = (0, utils_1.createAuthorizeForm)(relayState, samlReqEnc, sso.postUrl);
148
- }
149
- return {
150
- redirect_url: redirectUrl,
151
- authorize_form: authorizeForm,
152
- };
136
+ // deepak: When supporting HTTP-POST skip deflate
137
+ const samlReqEnc = yield deflateRawAsync(samlReq.request);
138
+ const redirectUrl = redirect.success(samlConfig.idpMetadata.sso.redirectUrl, {
139
+ RelayState: relayStatePrefix + sessionId,
140
+ SAMLRequest: Buffer.from(samlReqEnc).toString('base64'),
141
+ });
142
+ return { redirect_url: redirectUrl };
153
143
  });
154
144
  }
155
145
  samlResponse(body) {
@@ -2,4 +2,3 @@ export declare enum IndexNames {
2
2
  EntityID = "entityID",
3
3
  TenantProduct = "tenantProduct"
4
4
  }
5
- export declare const createAuthorizeForm: (relayState: string, samlReqEnc: string, postUrl: string) => string;
@@ -1,32 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAuthorizeForm = exports.IndexNames = void 0;
3
+ exports.IndexNames = void 0;
4
4
  var IndexNames;
5
5
  (function (IndexNames) {
6
6
  IndexNames["EntityID"] = "entityID";
7
7
  IndexNames["TenantProduct"] = "tenantProduct";
8
8
  })(IndexNames = exports.IndexNames || (exports.IndexNames = {}));
9
- const createAuthorizeForm = (relayState, samlReqEnc, postUrl) => {
10
- const formElements = [
11
- '<!DOCTYPE html>',
12
- '<html>',
13
- '<head>',
14
- '<meta charset="utf-8">',
15
- '<meta http-equiv="x-ua-compatible" content="ie=edge">',
16
- '</head>',
17
- '<body onload="document.forms[0].submit()">',
18
- '<noscript>',
19
- '<p>Note: Since your browser does not support JavaScript, you must press the Continue button once to proceed.</p>',
20
- '</noscript>',
21
- '<form method="post" action="' + encodeURI(postUrl) + '">',
22
- '<input type="hidden" name="RelayState" value="' + relayState + '"/>',
23
- '<input type="hidden" name="SAMLRequest" value="' + samlReqEnc + '"/>',
24
- '<input type="submit" value="Continue" />',
25
- '</form>',
26
- '<script>document.forms[0].style.display="none";</script>',
27
- '</body>',
28
- '</html>',
29
- ];
30
- return formElements.join('');
31
- };
32
- exports.createAuthorizeForm = createAuthorizeForm;
package/dist/saml/saml.js CHANGED
@@ -68,7 +68,7 @@ const request = ({ ssoUrl, entityID, callbackUrl, isPassive = false, forceAuthn
68
68
  '@ID': id,
69
69
  '@Version': '2.0',
70
70
  '@IssueInstant': date,
71
- '@ProtocolBinding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
71
+ '@ProtocolBinding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
72
72
  '@Destination': ssoUrl,
73
73
  'saml:Issuer': {
74
74
  '@xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
package/dist/typings.d.ts CHANGED
@@ -28,7 +28,6 @@ export interface IAPIController {
28
28
  export interface IOAuthController {
29
29
  authorize(body: OAuthReqBody): Promise<{
30
30
  redirect_url: string;
31
- authorize_form: string;
32
31
  }>;
33
32
  samlResponse(body: SAMLResponsePayload): Promise<{
34
33
  redirect_url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boxyhq/saml-jackson",
3
- "version": "0.3.6-beta.606",
3
+ "version": "0.3.6-beta.618",
4
4
  "description": "SAML 2.0 service",
5
5
  "keywords": [
6
6
  "SAML 2.0"
@@ -18,7 +18,12 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "build": "tsc -p tsconfig.build.json",
21
- "db:migration:generate": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:generate --config ormconfig.js -n Initial",
21
+ "db:migration:generate:postgres": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:generate --config ormconfig.js -n Initial",
22
+ "db:migration:generate:mysql": "cross-env DB_TYPE=mysql DB_URL=mysql://root:mysql@localhost:3307/mysql ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:generate --config ormconfig.js -n Initial",
23
+ "db:migration:generate:mariadb": "cross-env DB_TYPE=mariadb DB_URL=mariadb://root@localhost:3306/mysql ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:generate --config ormconfig.js -n Initial",
24
+ "db:migration:run:postgres": "ts-node --transpile-only ./node_modules/typeorm/cli.js migration:run",
25
+ "db:migration:run:mysql": "cross-env DB_TYPE=mysql DB_URL=mysql://root:mysql@localhost:3307/mysql ts-node --transpile-only ./node_modules/typeorm/cli.js migration:run",
26
+ "db:migration:run:mariadb": "cross-env DB_TYPE=mariadb DB_URL=mariadb://root@localhost:3306/mysql ts-node --transpile-only ./node_modules/typeorm/cli.js migration:run",
22
27
  "prepublishOnly": "npm run build",
23
28
  "test": "tap --ts --timeout=100 --coverage test/**/*.test.ts",
24
29
  "sort": "npx sort-package-json"
@@ -34,6 +39,8 @@
34
39
  "@boxyhq/saml20": "0.2.0",
35
40
  "@peculiar/webcrypto": "1.2.3",
36
41
  "@peculiar/x509": "1.6.1",
42
+ "cors": "2.8.5",
43
+ "express": "4.17.2",
37
44
  "mongodb": "4.3.0",
38
45
  "mysql2": "2.3.3",
39
46
  "pg": "8.7.1",
@@ -48,11 +55,13 @@
48
55
  "xmlbuilder": "15.1.1"
49
56
  },
50
57
  "devDependencies": {
58
+ "@types/express": "4.17.13",
51
59
  "@types/node": "16.11.17",
52
60
  "@types/sinon": "10.0.6",
53
61
  "@types/tap": "15.0.5",
54
62
  "@typescript-eslint/eslint-plugin": "5.8.1",
55
63
  "@typescript-eslint/parser": "5.8.1",
64
+ "cross-env": "7.0.3",
56
65
  "eslint": "8.5.0",
57
66
  "eslint-config-prettier": "8.3.0",
58
67
  "prettier": "2.5.1",