@oneblink/sdk-core 0.2.5 → 0.3.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/conditionalLogicService.d.ts +19 -19
- package/dist/conditionalLogicService.js +138 -138
- package/dist/formElementsService.d.ts +6 -6
- package/dist/formElementsService.js +81 -81
- package/dist/index.d.ts +6 -6
- package/dist/index.js +29 -29
- package/dist/replaceCustomValues.d.ts +25 -25
- package/dist/replaceCustomValues.js +181 -169
- package/dist/replaceCustomValues.js.map +1 -1
- package/dist/typeCastService.d.ts +18 -18
- package/dist/typeCastService.js +152 -150
- package/dist/typeCastService.js.map +1 -1
- package/dist/userService.d.ts +3 -3
- package/dist/userService.js +77 -77
- package/package.json +1 -1
package/dist/typeCastService.js
CHANGED
|
@@ -1,151 +1,153 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.submissionEvents = exports.formElements = void 0;
|
|
4
|
-
const toOptionsElement = (e) => {
|
|
5
|
-
switch (e.type) {
|
|
6
|
-
case 'select':
|
|
7
|
-
case 'compliance':
|
|
8
|
-
case 'radio':
|
|
9
|
-
case 'autocomplete':
|
|
10
|
-
case 'checkboxes': {
|
|
11
|
-
return e;
|
|
12
|
-
}
|
|
13
|
-
default: {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const toFormElementWithForm = (e) => {
|
|
19
|
-
switch (e.type) {
|
|
20
|
-
case 'form':
|
|
21
|
-
case 'infoPage': {
|
|
22
|
-
return e;
|
|
23
|
-
}
|
|
24
|
-
default: {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const toFormElementWithoutForm = (e) => {
|
|
30
|
-
switch (e.type) {
|
|
31
|
-
case 'form':
|
|
32
|
-
case 'infoPage': {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
default: {
|
|
36
|
-
return e;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const toLookupElement = (e) => {
|
|
41
|
-
switch (e.type) {
|
|
42
|
-
case 'boolean':
|
|
43
|
-
case 'checkboxes':
|
|
44
|
-
case 'date':
|
|
45
|
-
case 'datetime':
|
|
46
|
-
case '
|
|
47
|
-
case '
|
|
48
|
-
case '
|
|
49
|
-
case '
|
|
50
|
-
case '
|
|
51
|
-
case '
|
|
52
|
-
case '
|
|
53
|
-
case '
|
|
54
|
-
case '
|
|
55
|
-
case '
|
|
56
|
-
case '
|
|
57
|
-
case '
|
|
58
|
-
case '
|
|
59
|
-
case '
|
|
60
|
-
case '
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case '
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
case '
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
case '
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submissionEvents = exports.formElements = void 0;
|
|
4
|
+
const toOptionsElement = (e) => {
|
|
5
|
+
switch (e.type) {
|
|
6
|
+
case 'select':
|
|
7
|
+
case 'compliance':
|
|
8
|
+
case 'radio':
|
|
9
|
+
case 'autocomplete':
|
|
10
|
+
case 'checkboxes': {
|
|
11
|
+
return e;
|
|
12
|
+
}
|
|
13
|
+
default: {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const toFormElementWithForm = (e) => {
|
|
19
|
+
switch (e.type) {
|
|
20
|
+
case 'form':
|
|
21
|
+
case 'infoPage': {
|
|
22
|
+
return e;
|
|
23
|
+
}
|
|
24
|
+
default: {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const toFormElementWithoutForm = (e) => {
|
|
30
|
+
switch (e.type) {
|
|
31
|
+
case 'form':
|
|
32
|
+
case 'infoPage': {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
default: {
|
|
36
|
+
return e;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const toLookupElement = (e) => {
|
|
41
|
+
switch (e.type) {
|
|
42
|
+
case 'boolean':
|
|
43
|
+
case 'checkboxes':
|
|
44
|
+
case 'date':
|
|
45
|
+
case 'datetime':
|
|
46
|
+
case 'files':
|
|
47
|
+
case 'location':
|
|
48
|
+
case 'number':
|
|
49
|
+
case 'compliance':
|
|
50
|
+
case 'radio':
|
|
51
|
+
case 'select':
|
|
52
|
+
case 'text':
|
|
53
|
+
case 'textarea':
|
|
54
|
+
case 'time':
|
|
55
|
+
case 'barcodeScanner':
|
|
56
|
+
case 'email':
|
|
57
|
+
case 'telephone':
|
|
58
|
+
case 'pointAddress':
|
|
59
|
+
case 'geoscapeAddress':
|
|
60
|
+
case 'civicaStreetName':
|
|
61
|
+
case 'bsb':
|
|
62
|
+
case 'autocomplete': {
|
|
63
|
+
return e;
|
|
64
|
+
}
|
|
65
|
+
default: {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const toNestedElementsElement = (e) => {
|
|
71
|
+
switch (e.type) {
|
|
72
|
+
case 'repeatableSet':
|
|
73
|
+
case 'section':
|
|
74
|
+
case 'page': {
|
|
75
|
+
return e;
|
|
76
|
+
}
|
|
77
|
+
default: {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const toNamelessElement = (e) => {
|
|
83
|
+
switch (e.type) {
|
|
84
|
+
case 'section':
|
|
85
|
+
case 'page': {
|
|
86
|
+
return e;
|
|
87
|
+
}
|
|
88
|
+
default: {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const toNonNestedElementsElement = (e) => {
|
|
94
|
+
switch (e.type) {
|
|
95
|
+
case 'repeatableSet':
|
|
96
|
+
case 'section':
|
|
97
|
+
case 'page': {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
default: {
|
|
101
|
+
return e;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const toPageElement = (e) => {
|
|
106
|
+
switch (e.type) {
|
|
107
|
+
case 'page': {
|
|
108
|
+
return e;
|
|
109
|
+
}
|
|
110
|
+
default: {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const toRepeatableSetElement = (e) => {
|
|
116
|
+
switch (e.type) {
|
|
117
|
+
case 'repeatableSet': {
|
|
118
|
+
return e;
|
|
119
|
+
}
|
|
120
|
+
default: {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const formElements = {
|
|
126
|
+
toOptionsElement,
|
|
127
|
+
toFormElementWithForm,
|
|
128
|
+
toFormElementWithoutForm,
|
|
129
|
+
toLookupElement,
|
|
130
|
+
toNestedElementsElement,
|
|
131
|
+
toNamelessElement,
|
|
132
|
+
toNonNestedElementsElement,
|
|
133
|
+
toPageElement,
|
|
134
|
+
toRepeatableSetElement,
|
|
135
|
+
};
|
|
136
|
+
exports.formElements = formElements;
|
|
137
|
+
const toPaymentSubmissionEvent = (e) => {
|
|
138
|
+
switch (e.type) {
|
|
139
|
+
case 'BPOINT':
|
|
140
|
+
case 'CP_PAY':
|
|
141
|
+
case 'WESTPAC_QUICK_WEB': {
|
|
142
|
+
return e;
|
|
143
|
+
}
|
|
144
|
+
default: {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const submissionEvents = {
|
|
150
|
+
toPaymentSubmissionEvent,
|
|
151
|
+
};
|
|
152
|
+
exports.submissionEvents = submissionEvents;
|
|
151
153
|
//# sourceMappingURL=typeCastService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeCastService.js","sourceRoot":"","sources":["../src/typeCastService.ts"],"names":[],"mappings":";;;AAEA,MAAM,gBAAgB,GAAG,CACvB,CAAwB,EACsB,EAAE;IAChD,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,YAAY,CAAC;QAClB,KAAK,OAAO,CAAC;QACb,KA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,uBAAuB;IACvB,iBAAiB;IACjB,0BAA0B;IAC1B,aAAa;IACb,sBAAsB;CACvB,CAAA;AAqBQ,oCAAY;AAnBrB,MAAM,wBAAwB,GAAG,CAC/B,CAA2C,EACc,EAAE;IAC3D,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,mBAAmB,CAAC,CAAC;YACxB,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG;IACvB,wBAAwB;CACzB,CAAA;AAEsB,4CAAgB","sourcesContent":["import { FormTypes, SubmissionEventTypes } from '@oneblink/types'\n\nconst toOptionsElement = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithOptions | undefined => {\n switch (e.type) {\n case 'select':\n case 'compliance':\n case 'radio':\n case 'autocomplete':\n case 'checkboxes': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toFormElementWithForm = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithForm | undefined => {\n switch (e.type) {\n case 'form':\n case 'infoPage': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toFormElementWithoutForm = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithoutForm | undefined => {\n switch (e.type) {\n case 'form':\n case 'infoPage': {\n return\n }\n default: {\n return e\n }\n }\n}\n\nconst toLookupElement = (\n e: FormTypes.FormElement,\n): FormTypes.LookupFormElement | undefined => {\n switch (e.type) {\n case 'boolean':\n case 'checkboxes':\n case 'date':\n case 'datetime':\n case 'location':\n case 'number':\n case 'compliance':\n case 'radio':\n case 'select':\n case 'text':\n case 'textarea':\n case 'time':\n case 'barcodeScanner':\n case 'email':\n case 'telephone':\n case 'pointAddress':\n case 'geoscapeAddress':\n case 'civicaStreetName':\n case 'autocomplete': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toNestedElementsElement = (\n e: FormTypes.FormElement,\n): FormTypes.NestedElementsElement | undefined => {\n switch (e.type) {\n case 'repeatableSet':\n case 'section':\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\ntype NamelessElement = FormTypes.PageElement | FormTypes.SectionElement\nconst toNamelessElement = (\n e: FormTypes.FormElement,\n): NamelessElement | undefined => {\n switch (e.type) {\n case 'section':\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\ntype NonNestedElementsFormElement =\n | FormTypes.NonNestedElementsElement\n | FormTypes.FormElementWithForm\nconst toNonNestedElementsElement = (\n e: FormTypes.FormElement,\n): NonNestedElementsFormElement | undefined => {\n switch (e.type) {\n case 'repeatableSet':\n case 'section':\n case 'page': {\n return\n }\n default: {\n return e\n }\n }\n}\n\nconst toPageElement = (\n e: FormTypes.FormElement,\n): FormTypes.PageElement | undefined => {\n switch (e.type) {\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toRepeatableSetElement = (\n e: FormTypes.FormElement,\n): FormTypes.RepeatableSetElement | undefined => {\n switch (e.type) {\n case 'repeatableSet': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst formElements = {\n toOptionsElement,\n toFormElementWithForm,\n toFormElementWithoutForm,\n toLookupElement,\n toNestedElementsElement,\n toNamelessElement,\n toNonNestedElementsElement,\n toPageElement,\n toRepeatableSetElement,\n}\n\nconst toPaymentSubmissionEvent = (\n e: SubmissionEventTypes.FormSubmissionEvent,\n): SubmissionEventTypes.PaymentSubmissionEvent | undefined => {\n switch (e.type) {\n case 'BPOINT':\n case 'CP_PAY':\n case 'WESTPAC_QUICK_WEB': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst submissionEvents = {\n toPaymentSubmissionEvent,\n}\n\nexport { formElements, submissionEvents }\n"]}
|
|
1
|
+
{"version":3,"file":"typeCastService.js","sourceRoot":"","sources":["../src/typeCastService.ts"],"names":[],"mappings":";;;AAEA,MAAM,gBAAgB,GAAG,CACvB,CAAwB,EACsB,EAAE;I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,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,YAAY,GAAG;IACnB,gBAAgB;IAChB,qBAAqB;IACrB,wBAAwB;IACxB,eAAe;IACf,uBAAuB;IACvB,iBAAiB;IACjB,0BAA0B;IAC1B,aAAa;IACb,sBAAsB;CACvB,CAAA;AAqBQ,oCAAY;AAnBrB,MAAM,wBAAwB,GAAG,CAC/B,CAA2C,EACc,EAAE;IAC3D,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,mBAAmB,CAAC,CAAC;YACxB,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG;IACvB,wBAAwB;CACzB,CAAA;AAEsB,4CAAgB","sourcesContent":["import { FormTypes, SubmissionEventTypes } from '@oneblink/types'\n\nconst toOptionsElement = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithOptions | undefined => {\n switch (e.type) {\n case 'select':\n case 'compliance':\n case 'radio':\n case 'autocomplete':\n case 'checkboxes': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toFormElementWithForm = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithForm | undefined => {\n switch (e.type) {\n case 'form':\n case 'infoPage': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toFormElementWithoutForm = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithoutForm | undefined => {\n switch (e.type) {\n case 'form':\n case 'infoPage': {\n return\n }\n default: {\n return e\n }\n }\n}\n\nconst toLookupElement = (\n e: FormTypes.FormElement,\n): FormTypes.LookupFormElement | undefined => {\n switch (e.type) {\n case 'boolean':\n case 'checkboxes':\n case 'date':\n case 'datetime':\n case 'files':\n case 'location':\n case 'number':\n case 'compliance':\n case 'radio':\n case 'select':\n case 'text':\n case 'textarea':\n case 'time':\n case 'barcodeScanner':\n case 'email':\n case 'telephone':\n case 'pointAddress':\n case 'geoscapeAddress':\n case 'civicaStreetName':\n case 'bsb':\n case 'autocomplete': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toNestedElementsElement = (\n e: FormTypes.FormElement,\n): FormTypes.NestedElementsElement | undefined => {\n switch (e.type) {\n case 'repeatableSet':\n case 'section':\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\ntype NamelessElement = FormTypes.PageElement | FormTypes.SectionElement\nconst toNamelessElement = (\n e: FormTypes.FormElement,\n): NamelessElement | undefined => {\n switch (e.type) {\n case 'section':\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\ntype NonNestedElementsFormElement =\n | FormTypes.NonNestedElementsElement\n | FormTypes.FormElementWithForm\nconst toNonNestedElementsElement = (\n e: FormTypes.FormElement,\n): NonNestedElementsFormElement | undefined => {\n switch (e.type) {\n case 'repeatableSet':\n case 'section':\n case 'page': {\n return\n }\n default: {\n return e\n }\n }\n}\n\nconst toPageElement = (\n e: FormTypes.FormElement,\n): FormTypes.PageElement | undefined => {\n switch (e.type) {\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toRepeatableSetElement = (\n e: FormTypes.FormElement,\n): FormTypes.RepeatableSetElement | undefined => {\n switch (e.type) {\n case 'repeatableSet': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst formElements = {\n toOptionsElement,\n toFormElementWithForm,\n toFormElementWithoutForm,\n toLookupElement,\n toNestedElementsElement,\n toNamelessElement,\n toNonNestedElementsElement,\n toPageElement,\n toRepeatableSetElement,\n}\n\nconst toPaymentSubmissionEvent = (\n e: SubmissionEventTypes.FormSubmissionEvent,\n): SubmissionEventTypes.PaymentSubmissionEvent | undefined => {\n switch (e.type) {\n case 'BPOINT':\n case 'CP_PAY':\n case 'WESTPAC_QUICK_WEB': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst submissionEvents = {\n toPaymentSubmissionEvent,\n}\n\nexport { formElements, submissionEvents }\n"]}
|
package/dist/userService.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { MiscTypes } from '@oneblink/types';
|
|
2
|
-
export declare function parseUserProfile(data: unknown): MiscTypes.UserProfile | undefined;
|
|
3
|
-
export declare function getUserFriendlyName(userProfile: MiscTypes.UserProfile): string;
|
|
1
|
+
import { MiscTypes } from '@oneblink/types';
|
|
2
|
+
export declare function parseUserProfile(data: unknown): MiscTypes.UserProfile | undefined;
|
|
3
|
+
export declare function getUserFriendlyName(userProfile: MiscTypes.UserProfile): string;
|
package/dist/userService.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUserFriendlyName = exports.parseUserProfile = void 0;
|
|
4
|
-
function parseUserProfile(data) {
|
|
5
|
-
var _a, _b, _c;
|
|
6
|
-
if (typeof data !== 'object' || !data) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const jwtPayload = data;
|
|
10
|
-
if (typeof jwtPayload.sub !== 'string') {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const userProfile = {
|
|
14
|
-
isSAMLUser: false,
|
|
15
|
-
providerType: 'Cognito',
|
|
16
|
-
providerUserId: jwtPayload.sub,
|
|
17
|
-
userId: jwtPayload.sub,
|
|
18
|
-
email: typeof jwtPayload.email === 'string' ? jwtPayload.email : undefined,
|
|
19
|
-
firstName: typeof jwtPayload.given_name === 'string'
|
|
20
|
-
? jwtPayload.given_name
|
|
21
|
-
: undefined,
|
|
22
|
-
lastName: typeof jwtPayload.family_name === 'string'
|
|
23
|
-
? jwtPayload.family_name
|
|
24
|
-
: undefined,
|
|
25
|
-
fullName: typeof jwtPayload.name === 'string' ? jwtPayload.name : undefined,
|
|
26
|
-
picture: typeof jwtPayload.picture === 'string' ? jwtPayload.picture : undefined,
|
|
27
|
-
role: typeof jwtPayload['custom:role'] === 'string'
|
|
28
|
-
? jwtPayload['custom:role']
|
|
29
|
-
: undefined,
|
|
30
|
-
username: typeof jwtPayload.email === 'string' ? jwtPayload.email : jwtPayload.sub,
|
|
31
|
-
supervisor: {
|
|
32
|
-
fullName: typeof jwtPayload['custom:supervisor_name'] === 'string'
|
|
33
|
-
? jwtPayload['custom:supervisor_name']
|
|
34
|
-
: undefined,
|
|
35
|
-
email: typeof jwtPayload['custom:supervisor_email'] === 'string'
|
|
36
|
-
? jwtPayload['custom:supervisor_email']
|
|
37
|
-
: undefined,
|
|
38
|
-
providerUserId: typeof jwtPayload['custom:supervisor_user_id'] === 'string'
|
|
39
|
-
? jwtPayload['custom:supervisor_user_id']
|
|
40
|
-
: undefined,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
if (!((_a = userProfile.supervisor) === null || _a === void 0 ? void 0 : _a.fullName) &&
|
|
44
|
-
!((_b = userProfile.supervisor) === null || _b === void 0 ? void 0 : _b.email) &&
|
|
45
|
-
!((_c = userProfile.supervisor) === null || _c === void 0 ? void 0 : _c.providerUserId)) {
|
|
46
|
-
userProfile.supervisor = undefined;
|
|
47
|
-
}
|
|
48
|
-
if (jwtPayload.identities &&
|
|
49
|
-
Array.isArray(jwtPayload.identities) &&
|
|
50
|
-
jwtPayload.identities.length) {
|
|
51
|
-
const { providerType, userId } = jwtPayload.identities[0];
|
|
52
|
-
userProfile.providerType = providerType;
|
|
53
|
-
userProfile.providerUserId = userId;
|
|
54
|
-
userProfile.isSAMLUser = providerType === 'SAML';
|
|
55
|
-
if (userProfile.isSAMLUser) {
|
|
56
|
-
userProfile.username = jwtPayload.preferred_username || userId;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return userProfile;
|
|
60
|
-
}
|
|
61
|
-
exports.parseUserProfile = parseUserProfile;
|
|
62
|
-
function getUserFriendlyName(userProfile) {
|
|
63
|
-
if (userProfile.fullName) {
|
|
64
|
-
return userProfile.fullName;
|
|
65
|
-
}
|
|
66
|
-
if (userProfile.firstName || userProfile.lastName) {
|
|
67
|
-
return [userProfile.firstName, userProfile.lastName].join(' ').trim();
|
|
68
|
-
}
|
|
69
|
-
if (userProfile.email) {
|
|
70
|
-
return userProfile.email;
|
|
71
|
-
}
|
|
72
|
-
if (userProfile.username) {
|
|
73
|
-
return userProfile.username;
|
|
74
|
-
}
|
|
75
|
-
return userProfile.userId;
|
|
76
|
-
}
|
|
77
|
-
exports.getUserFriendlyName = getUserFriendlyName;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserFriendlyName = exports.parseUserProfile = void 0;
|
|
4
|
+
function parseUserProfile(data) {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
if (typeof data !== 'object' || !data) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const jwtPayload = data;
|
|
10
|
+
if (typeof jwtPayload.sub !== 'string') {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const userProfile = {
|
|
14
|
+
isSAMLUser: false,
|
|
15
|
+
providerType: 'Cognito',
|
|
16
|
+
providerUserId: jwtPayload.sub,
|
|
17
|
+
userId: jwtPayload.sub,
|
|
18
|
+
email: typeof jwtPayload.email === 'string' ? jwtPayload.email : undefined,
|
|
19
|
+
firstName: typeof jwtPayload.given_name === 'string'
|
|
20
|
+
? jwtPayload.given_name
|
|
21
|
+
: undefined,
|
|
22
|
+
lastName: typeof jwtPayload.family_name === 'string'
|
|
23
|
+
? jwtPayload.family_name
|
|
24
|
+
: undefined,
|
|
25
|
+
fullName: typeof jwtPayload.name === 'string' ? jwtPayload.name : undefined,
|
|
26
|
+
picture: typeof jwtPayload.picture === 'string' ? jwtPayload.picture : undefined,
|
|
27
|
+
role: typeof jwtPayload['custom:role'] === 'string'
|
|
28
|
+
? jwtPayload['custom:role']
|
|
29
|
+
: undefined,
|
|
30
|
+
username: typeof jwtPayload.email === 'string' ? jwtPayload.email : jwtPayload.sub,
|
|
31
|
+
supervisor: {
|
|
32
|
+
fullName: typeof jwtPayload['custom:supervisor_name'] === 'string'
|
|
33
|
+
? jwtPayload['custom:supervisor_name']
|
|
34
|
+
: undefined,
|
|
35
|
+
email: typeof jwtPayload['custom:supervisor_email'] === 'string'
|
|
36
|
+
? jwtPayload['custom:supervisor_email']
|
|
37
|
+
: undefined,
|
|
38
|
+
providerUserId: typeof jwtPayload['custom:supervisor_user_id'] === 'string'
|
|
39
|
+
? jwtPayload['custom:supervisor_user_id']
|
|
40
|
+
: undefined,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
if (!((_a = userProfile.supervisor) === null || _a === void 0 ? void 0 : _a.fullName) &&
|
|
44
|
+
!((_b = userProfile.supervisor) === null || _b === void 0 ? void 0 : _b.email) &&
|
|
45
|
+
!((_c = userProfile.supervisor) === null || _c === void 0 ? void 0 : _c.providerUserId)) {
|
|
46
|
+
userProfile.supervisor = undefined;
|
|
47
|
+
}
|
|
48
|
+
if (jwtPayload.identities &&
|
|
49
|
+
Array.isArray(jwtPayload.identities) &&
|
|
50
|
+
jwtPayload.identities.length) {
|
|
51
|
+
const { providerType, userId } = jwtPayload.identities[0];
|
|
52
|
+
userProfile.providerType = providerType;
|
|
53
|
+
userProfile.providerUserId = userId;
|
|
54
|
+
userProfile.isSAMLUser = providerType === 'SAML';
|
|
55
|
+
if (userProfile.isSAMLUser) {
|
|
56
|
+
userProfile.username = jwtPayload.preferred_username || userId;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return userProfile;
|
|
60
|
+
}
|
|
61
|
+
exports.parseUserProfile = parseUserProfile;
|
|
62
|
+
function getUserFriendlyName(userProfile) {
|
|
63
|
+
if (userProfile.fullName) {
|
|
64
|
+
return userProfile.fullName;
|
|
65
|
+
}
|
|
66
|
+
if (userProfile.firstName || userProfile.lastName) {
|
|
67
|
+
return [userProfile.firstName, userProfile.lastName].join(' ').trim();
|
|
68
|
+
}
|
|
69
|
+
if (userProfile.email) {
|
|
70
|
+
return userProfile.email;
|
|
71
|
+
}
|
|
72
|
+
if (userProfile.username) {
|
|
73
|
+
return userProfile.username;
|
|
74
|
+
}
|
|
75
|
+
return userProfile.userId;
|
|
76
|
+
}
|
|
77
|
+
exports.getUserFriendlyName = getUserFriendlyName;
|
|
78
78
|
//# sourceMappingURL=userService.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneblink/sdk-core",
|
|
3
3
|
"description": "OneBlink SDK for JavaScript (works in Browsers and NodeJS)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/oneblink/sdk-core-js/issues"
|