@availity/native-form 4.0.12 → 5.0.2

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/CHANGELOG.md CHANGED
@@ -1,7 +1,31 @@
1
- # Change Log
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ## [5.0.2](https://github.com/Availity/sdk-js/compare/@availity/native-form@5.0.1...@availity/native-form@5.0.2) (2022-05-24)
6
+
7
+
8
+
9
+ ## [5.0.1](https://github.com/Availity/sdk-js/compare/@availity/native-form@5.0.0...@availity/native-form@5.0.1) (2022-04-28)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * add browser field for output ([0ce7170](https://github.com/Availity/sdk-js/commit/0ce717075a82675b8707e4db0cc07cd4af370f3d))
15
+
16
+
17
+
18
+ # [5.0.0](https://github.com/Availity/sdk-js/compare/@availity/native-form@4.0.12...@availity/native-form@5.0.0) (2022-04-28)
19
+
20
+
21
+ * build!: switch from lerna to nx and compile to esm with tsup ([c586085](https://github.com/Availity/sdk-js/commit/c5860856ca96b743a0653d335ea00f0889132f7f))
22
+
23
+
24
+ ### BREAKING CHANGES
25
+
26
+ * Drop Internet Explorer support
27
+
2
28
 
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
29
 
6
30
  ## [4.0.12](https://github.com/availity/sdk-js/compare/@availity/native-form@4.0.10...@availity/native-form@4.0.12) (2022-02-22)
7
31
 
@@ -0,0 +1,13 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ type SsoType = 'saml' | 'openid';
4
+
5
+ declare function nativeForm(
6
+ spaceId: string,
7
+ params?: Record<string, any>,
8
+ formAttributes?: Record<string, any>,
9
+ type?: SsoType,
10
+ clientId?: string
11
+ ): Promise<void>;
12
+
13
+ export { nativeForm as default };
package/dist/index.js ADDED
@@ -0,0 +1,116 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, { get: all[name], enumerable: true });
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ }
29
+ return to;
30
+ };
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // src/index.js
34
+ var src_exports = {};
35
+ __export(src_exports, {
36
+ default: () => src_default
37
+ });
38
+ module.exports = __toCommonJS(src_exports);
39
+ var import_api_axios = require("@availity/api-axios");
40
+
41
+ // src/flattenObject.js
42
+ var parseValue = (value) => value === void 0 || value === null ? value : value.toString();
43
+ var flattenObject = (ob) => Object.keys(ob).reduce((toReturn, k) => {
44
+ if (Object.prototype.toString.call(ob[k]) === "[object Date]") {
45
+ toReturn[k] = ob[k].toJSON();
46
+ } else if (ob[k] && typeof ob[k] === "object") {
47
+ const flatObject = flattenObject(ob[k]);
48
+ const isArray = Array.isArray(ob[k]);
49
+ for (const k2 of Object.keys(flatObject)) {
50
+ toReturn[`${k}${isArray ? k2.replace(/^(\d+)(\..*)?/, "[$1]$2") : `.${k2}`}`] = parseValue(flatObject[k2]);
51
+ }
52
+ } else {
53
+ toReturn[k] = parseValue(ob[k]);
54
+ }
55
+ return toReturn;
56
+ }, {});
57
+ var flattenObject_default = flattenObject;
58
+
59
+ // src/index.js
60
+ var ssoTypeQuery = `
61
+ query ssoTypeFindById($id: ID!){
62
+ configurationFindOne(id: $id){
63
+ ...on Saml{
64
+ type
65
+ }
66
+ ...on OpenId{
67
+ type
68
+ }
69
+ }
70
+ }
71
+ `;
72
+ var nativeForm = async (spaceId, params = {}, formAttributes = {}, type, clientId = "clientId") => {
73
+ var _a, _b, _c;
74
+ if (!spaceId)
75
+ throw new Error("spaceId is required and was not provided");
76
+ let typeLower = type == null ? void 0 : type.toLowerCase();
77
+ if (typeLower !== "saml" && typeLower !== "openid") {
78
+ try {
79
+ const { data } = await import_api_axios.avWebQLApi.create({
80
+ query: ssoTypeQuery,
81
+ variables: { id: spaceId },
82
+ operationName: "ssoTypeFindById"
83
+ }, { headers: { "X-Client-ID": clientId } });
84
+ typeLower = (_c = (_b = (_a = data == null ? void 0 : data.data) == null ? void 0 : _a.configurationFindOne) == null ? void 0 : _b.type) == null ? void 0 : _c.toLowerCase();
85
+ } catch (error) {
86
+ if (error.response) {
87
+ throw new Error("The server responded with an error");
88
+ } else if (error.request) {
89
+ throw new Error("No response received");
90
+ } else {
91
+ throw new Error("An error occurred while setting up request, check your configurations");
92
+ }
93
+ }
94
+ }
95
+ const mergedOptions = __spreadValues({
96
+ method: "post",
97
+ action: `/ms/api/availity/internal/spc/magneto/sso/v1/${typeLower}/${spaceId}`,
98
+ target: "_blank"
99
+ }, formAttributes);
100
+ const form = document.createElement("form");
101
+ for (const key of Object.keys(mergedOptions)) {
102
+ form.setAttribute(key, mergedOptions[key]);
103
+ }
104
+ const flat = flattenObject_default(params);
105
+ const fields = Object.keys(flat).map((key) => {
106
+ const name = key.replace(/\[\d+]/g, "[]");
107
+ const value = flat[key];
108
+ return `<input type="hidden" name="${name}" value="${value}" />`;
109
+ }).join("");
110
+ form.insertAdjacentHTML("beforeend", fields);
111
+ document.body.appendChild(form);
112
+ form.submit();
113
+ };
114
+ var src_default = nativeForm;
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {});
package/dist/index.mjs ADDED
@@ -0,0 +1,97 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+
18
+ // src/index.js
19
+ import { avWebQLApi } from "@availity/api-axios";
20
+
21
+ // src/flattenObject.js
22
+ var parseValue = (value) => value === void 0 || value === null ? value : value.toString();
23
+ var flattenObject = (ob) => Object.keys(ob).reduce((toReturn, k) => {
24
+ if (Object.prototype.toString.call(ob[k]) === "[object Date]") {
25
+ toReturn[k] = ob[k].toJSON();
26
+ } else if (ob[k] && typeof ob[k] === "object") {
27
+ const flatObject = flattenObject(ob[k]);
28
+ const isArray = Array.isArray(ob[k]);
29
+ for (const k2 of Object.keys(flatObject)) {
30
+ toReturn[`${k}${isArray ? k2.replace(/^(\d+)(\..*)?/, "[$1]$2") : `.${k2}`}`] = parseValue(flatObject[k2]);
31
+ }
32
+ } else {
33
+ toReturn[k] = parseValue(ob[k]);
34
+ }
35
+ return toReturn;
36
+ }, {});
37
+ var flattenObject_default = flattenObject;
38
+
39
+ // src/index.js
40
+ var ssoTypeQuery = `
41
+ query ssoTypeFindById($id: ID!){
42
+ configurationFindOne(id: $id){
43
+ ...on Saml{
44
+ type
45
+ }
46
+ ...on OpenId{
47
+ type
48
+ }
49
+ }
50
+ }
51
+ `;
52
+ var nativeForm = async (spaceId, params = {}, formAttributes = {}, type, clientId = "clientId") => {
53
+ var _a, _b, _c;
54
+ if (!spaceId)
55
+ throw new Error("spaceId is required and was not provided");
56
+ let typeLower = type == null ? void 0 : type.toLowerCase();
57
+ if (typeLower !== "saml" && typeLower !== "openid") {
58
+ try {
59
+ const { data } = await avWebQLApi.create({
60
+ query: ssoTypeQuery,
61
+ variables: { id: spaceId },
62
+ operationName: "ssoTypeFindById"
63
+ }, { headers: { "X-Client-ID": clientId } });
64
+ typeLower = (_c = (_b = (_a = data == null ? void 0 : data.data) == null ? void 0 : _a.configurationFindOne) == null ? void 0 : _b.type) == null ? void 0 : _c.toLowerCase();
65
+ } catch (error) {
66
+ if (error.response) {
67
+ throw new Error("The server responded with an error");
68
+ } else if (error.request) {
69
+ throw new Error("No response received");
70
+ } else {
71
+ throw new Error("An error occurred while setting up request, check your configurations");
72
+ }
73
+ }
74
+ }
75
+ const mergedOptions = __spreadValues({
76
+ method: "post",
77
+ action: `/ms/api/availity/internal/spc/magneto/sso/v1/${typeLower}/${spaceId}`,
78
+ target: "_blank"
79
+ }, formAttributes);
80
+ const form = document.createElement("form");
81
+ for (const key of Object.keys(mergedOptions)) {
82
+ form.setAttribute(key, mergedOptions[key]);
83
+ }
84
+ const flat = flattenObject_default(params);
85
+ const fields = Object.keys(flat).map((key) => {
86
+ const name = key.replace(/\[\d+]/g, "[]");
87
+ const value = flat[key];
88
+ return `<input type="hidden" name="${name}" value="${value}" />`;
89
+ }).join("");
90
+ form.insertAdjacentHTML("beforeend", fields);
91
+ document.body.appendChild(form);
92
+ form.submit();
93
+ };
94
+ var src_default = nativeForm;
95
+ export {
96
+ src_default as default
97
+ };
package/jest.config.js ADDED
@@ -0,0 +1,7 @@
1
+ const global = require('../../jest.config');
2
+
3
+ module.exports = {
4
+ ...global,
5
+ displayName: 'native-form',
6
+ coverageDirectory: '../../coverage/native-form',
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/native-form",
3
- "version": "4.0.12",
3
+ "version": "5.0.2",
4
4
  "description": "Submit JSON data via a native form, not AJAX. Useful when you need to open a new page with a POST action.",
5
5
  "keywords": [
6
6
  "availity",
@@ -19,26 +19,27 @@
19
19
  },
20
20
  "license": "MIT",
21
21
  "author": "Evan Sharp <evan.sharp@availity.com>",
22
- "main": "lib/index.js",
23
- "module": "src/index.js",
24
- "types": "src/index.d.ts",
22
+ "browser": "./dist/index.js",
23
+ "main": "./dist/index.js",
24
+ "module": "./dist/index.mjs",
25
+ "types": "./dist/index.d.ts",
25
26
  "scripts": {
26
- "build": "yarn clean && yarn transpile",
27
- "clean": "rimraf ./lib",
28
- "transpile": "babel --root-mode upward src -d lib --ignore **/*.test.js"
27
+ "build": "tsup src/index.js --format esm,cjs --dts",
28
+ "dev": "tsup src/index.js --format esm,cjs --watch --dts",
29
+ "lint": "eslint src",
30
+ "lint:fix": "eslint src --fix",
31
+ "clean": "rm -rf node_modules && rm -rf dist",
32
+ "bundlesize": "bundlesize",
33
+ "publish": "yarn npm publish --tolerate-republish --access public"
29
34
  },
30
35
  "dependencies": {
31
- "@babel/runtime": "^7.16.5",
32
- "core-js": "^3.12.1"
36
+ "@availity/api-axios": "7.0.2"
33
37
  },
34
38
  "devDependencies": {
35
- "@availity/api-axios": "^6.0.8"
36
- },
37
- "peerDependencies": {
38
- "@availity/api-axios": "^6.0.0"
39
+ "tsup": "^5.12.8",
40
+ "typescript": "^4.6.4"
39
41
  },
40
42
  "publishConfig": {
41
43
  "access": "public"
42
- },
43
- "gitHead": "67c8772142e62d31efba07ed3f880994848a8ea4"
44
- }
44
+ }
45
+ }
package/project.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "root": "packages/native-form",
3
+ "projectType": "library",
4
+ "targets": {
5
+ "test": {
6
+ "executor": "@nrwl/jest:jest",
7
+ "outputs": ["coverage/native-form"],
8
+ "options": {
9
+ "jestConfig": "packages/native-form/jest.config.js",
10
+ "passWithNoTests": true
11
+ }
12
+ },
13
+ "version": {
14
+ "executor": "@jscutlery/semver:version",
15
+ "options": {
16
+ "preset": "angular",
17
+ "commitMessageFormat": "chore(${projectName}): release version ${version} [skip ci]",
18
+ "tagPrefix": "@availity/${projectName}@",
19
+ "baseBranch": "master"
20
+ }
21
+ },
22
+ "lint": {
23
+ "executor": "@nrwl/linter:eslint",
24
+ "options": {
25
+ "eslintConfig": ".eslintrc.yaml",
26
+ "lintFilePatterns": ["packages/native-form/**/*.{js,ts}"],
27
+ "silent": false,
28
+ "fix": false,
29
+ "cache": true,
30
+ "cacheLocation": "./node_modules/.cache/native-form/.eslintcache",
31
+ "maxWarnings": -1,
32
+ "quiet": false,
33
+ "noEslintrc": false,
34
+ "hasTypeAwareRules": true,
35
+ "cacheStrategy": "metadata"
36
+ }
37
+ }
38
+ }
39
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": ["."],
4
+ "exclude": ["dist", "build", "node_modules"]
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node"],
7
+ "allowJs": true
8
+ },
9
+ "include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
10
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016-present Availity, LLC
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- require("core-js/modules/es.object.to-string");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports["default"] = void 0;
11
-
12
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
-
14
- require("core-js/modules/es.regexp.to-string.js");
15
-
16
- require("core-js/modules/esnext.async-iterator.reduce.js");
17
-
18
- require("core-js/modules/esnext.iterator.constructor.js");
19
-
20
- require("core-js/modules/esnext.iterator.reduce.js");
21
-
22
- require("core-js/modules/es.object.keys.js");
23
-
24
- require("core-js/modules/web.url.to-json.js");
25
-
26
- require("core-js/modules/es.array.concat.js");
27
-
28
- require("core-js/modules/es.regexp.exec.js");
29
-
30
- require("core-js/modules/es.string.replace.js");
31
-
32
- // Copied from https://github.com/Availity/sdk-js/blob/master/packages/native-form/flattenObject.js
33
- var parseValue = function parseValue(value) {
34
- return value === undefined || value === null ? value : value.toString();
35
- };
36
-
37
- var flattenObject = function flattenObject(ob) {
38
- return Object.keys(ob).reduce(function (toReturn, k) {
39
- if (Object.prototype.toString.call(ob[k]) === '[object Date]') {
40
- toReturn[k] = ob[k].toJSON();
41
- } else if (ob[k] && (0, _typeof2["default"])(ob[k]) === 'object') {
42
- var flatObject = flattenObject(ob[k]);
43
- var isArray = Array.isArray(ob[k]);
44
-
45
- for (var _i = 0, _Object$keys = Object.keys(flatObject); _i < _Object$keys.length; _i++) {
46
- var k2 = _Object$keys[_i];
47
- toReturn["".concat(k).concat(isArray ? k2.replace(/^(\d+)(\..*)?/, '[$1]$2') : ".".concat(k2))] = parseValue(flatObject[k2]);
48
- }
49
- } else {
50
- toReturn[k] = parseValue(ob[k]);
51
- }
52
-
53
- return toReturn;
54
- }, {});
55
- };
56
-
57
- var _default = flattenObject;
58
- exports["default"] = _default;
package/lib/index.js DELETED
@@ -1,163 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- require("core-js/modules/es.array.concat.js");
11
-
12
- require("core-js/modules/es.object.keys.js");
13
-
14
- require("core-js/modules/es.array.join.js");
15
-
16
- require("core-js/modules/es.array.map.js");
17
-
18
- require("core-js/modules/esnext.async-iterator.map.js");
19
-
20
- require("core-js/modules/esnext.iterator.map.js");
21
-
22
- require("core-js/modules/es.regexp.exec.js");
23
-
24
- require("core-js/modules/es.string.replace.js");
25
-
26
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
27
-
28
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
29
-
30
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
31
-
32
- var _apiAxios = require("@availity/api-axios");
33
-
34
- var _flattenObject = _interopRequireDefault(require("./flattenObject"));
35
-
36
- var ssoTypeQuery = "\nquery ssoTypeFindById($id: ID!){\n configurationFindOne(id: $id){\n ...on Saml{\n type\n }\n ...on OpenId{\n type\n }\n }\n}\n";
37
-
38
- var nativeForm = /*#__PURE__*/function () {
39
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(spaceId) {
40
- var params,
41
- formAttributes,
42
- type,
43
- clientId,
44
- typeLower,
45
- _data$data,
46
- _data$data$configurat,
47
- _data$data$configurat2,
48
- _yield$avWebQLApi$cre,
49
- data,
50
- mergedOptions,
51
- form,
52
- _i,
53
- _Object$keys,
54
- key,
55
- flat,
56
- fields,
57
- _args = arguments;
58
-
59
- return _regenerator["default"].wrap(function _callee$(_context) {
60
- while (1) {
61
- switch (_context.prev = _context.next) {
62
- case 0:
63
- params = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
64
- formAttributes = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
65
- type = _args.length > 3 ? _args[3] : undefined;
66
- clientId = _args.length > 4 && _args[4] !== undefined ? _args[4] : 'clientId';
67
-
68
- if (spaceId) {
69
- _context.next = 6;
70
- break;
71
- }
72
-
73
- throw new Error('spaceId is required and was not provided');
74
-
75
- case 6:
76
- typeLower = type === null || type === void 0 ? void 0 : type.toLowerCase();
77
-
78
- if (!(typeLower !== 'saml' && typeLower !== 'openid')) {
79
- _context.next = 27;
80
- break;
81
- }
82
-
83
- _context.prev = 8;
84
- _context.next = 11;
85
- return _apiAxios.avWebQLApi.create({
86
- query: ssoTypeQuery,
87
- variables: {
88
- id: spaceId
89
- },
90
- operationName: 'ssoTypeFindById'
91
- }, {
92
- headers: {
93
- 'X-Client-ID': clientId
94
- }
95
- });
96
-
97
- case 11:
98
- _yield$avWebQLApi$cre = _context.sent;
99
- data = _yield$avWebQLApi$cre.data;
100
- typeLower = data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : (_data$data$configurat = _data$data.configurationFindOne) === null || _data$data$configurat === void 0 ? void 0 : (_data$data$configurat2 = _data$data$configurat.type) === null || _data$data$configurat2 === void 0 ? void 0 : _data$data$configurat2.toLowerCase();
101
- _context.next = 27;
102
- break;
103
-
104
- case 16:
105
- _context.prev = 16;
106
- _context.t0 = _context["catch"](8);
107
-
108
- if (!_context.t0.response) {
109
- _context.next = 22;
110
- break;
111
- }
112
-
113
- throw new Error('The server responded with an error');
114
-
115
- case 22:
116
- if (!_context.t0.request) {
117
- _context.next = 26;
118
- break;
119
- }
120
-
121
- throw new Error('No response received');
122
-
123
- case 26:
124
- throw new Error('An error occurred while setting up request, check your configurations');
125
-
126
- case 27:
127
- mergedOptions = (0, _objectSpread2["default"])({
128
- method: 'post',
129
- action: "/ms/api/availity/internal/spc/magneto/sso/v1/".concat(typeLower, "/").concat(spaceId),
130
- target: '_blank'
131
- }, formAttributes);
132
- form = document.createElement('form');
133
-
134
- for (_i = 0, _Object$keys = Object.keys(mergedOptions); _i < _Object$keys.length; _i++) {
135
- key = _Object$keys[_i];
136
- form.setAttribute(key, mergedOptions[key]);
137
- }
138
-
139
- flat = (0, _flattenObject["default"])(params);
140
- fields = Object.keys(flat).map(function (key) {
141
- var name = key.replace(/\[\d+]/g, '[]');
142
- var value = flat[key];
143
- return "<input type=\"hidden\" name=\"".concat(name, "\" value=\"").concat(value, "\" />");
144
- }).join('');
145
- form.insertAdjacentHTML('beforeend', fields);
146
- document.body.appendChild(form);
147
- form.submit();
148
-
149
- case 35:
150
- case "end":
151
- return _context.stop();
152
- }
153
- }
154
- }, _callee, null, [[8, 16]]);
155
- }));
156
-
157
- return function nativeForm(_x) {
158
- return _ref.apply(this, arguments);
159
- };
160
- }();
161
-
162
- var _default = nativeForm;
163
- exports["default"] = _default;