samlesa 2.12.3 → 2.12.6

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.

Potentially problematic release.


This version of samlesa might be problematic. Click here for more details.

Files changed (66) hide show
  1. package/build/index.js +54 -64
  2. package/build/index.js.map +1 -1
  3. package/build/src/api.js +24 -23
  4. package/build/src/api.js.map +1 -1
  5. package/build/src/binding-post.js +358 -368
  6. package/build/src/binding-post.js.map +1 -1
  7. package/build/src/binding-redirect.js +333 -332
  8. package/build/src/binding-redirect.js.map +1 -1
  9. package/build/src/binding-simplesign.js +222 -232
  10. package/build/src/binding-simplesign.js.map +1 -1
  11. package/build/src/entity-idp.js +132 -130
  12. package/build/src/entity-idp.js.map +1 -1
  13. package/build/src/entity-sp.js +96 -96
  14. package/build/src/entity-sp.js.map +1 -1
  15. package/build/src/entity.js +225 -235
  16. package/build/src/entity.js.map +1 -1
  17. package/build/src/extractor.js +369 -369
  18. package/build/src/extractor.js.map +1 -1
  19. package/build/src/flow.js +320 -319
  20. package/build/src/flow.js.map +1 -1
  21. package/build/src/libsaml.js +660 -641
  22. package/build/src/libsaml.js.map +1 -1
  23. package/build/src/metadata-idp.js +127 -127
  24. package/build/src/metadata-idp.js.map +1 -1
  25. package/build/src/metadata-sp.js +231 -231
  26. package/build/src/metadata-sp.js.map +1 -1
  27. package/build/src/metadata.js +166 -176
  28. package/build/src/metadata.js.map +1 -1
  29. package/build/src/types.js +11 -11
  30. package/build/src/urn.js +212 -212
  31. package/build/src/urn.js.map +1 -1
  32. package/build/src/utility.js +292 -248
  33. package/build/src/utility.js.map +1 -1
  34. package/build/src/validator.js +27 -26
  35. package/build/src/validator.js.map +1 -1
  36. package/index.d.ts +10 -10
  37. package/index.js +18 -18
  38. package/package.json +1 -5
  39. package/qodana.yaml +29 -29
  40. package/src/binding-post.ts +1 -1
  41. package/src/binding-redirect.ts +83 -64
  42. package/src/entity-idp.ts +26 -20
  43. package/src/libsaml.ts +79 -48
  44. package/src/utility.ts +147 -76
  45. package/types/index.d.ts +10 -10
  46. package/types/src/api.d.ts +13 -13
  47. package/types/src/binding-post.d.ts +46 -46
  48. package/types/src/binding-redirect.d.ts +52 -52
  49. package/types/src/binding-simplesign.d.ts +39 -39
  50. package/types/src/entity-idp.d.ts +35 -42
  51. package/types/src/entity-sp.d.ts +36 -36
  52. package/types/src/entity.d.ts +101 -99
  53. package/types/src/extractor.d.ts +25 -25
  54. package/types/src/flow.d.ts +6 -6
  55. package/types/src/libsaml.d.ts +200 -210
  56. package/types/src/metadata-idp.d.ts +24 -24
  57. package/types/src/metadata-sp.d.ts +36 -36
  58. package/types/src/metadata.d.ts +59 -57
  59. package/types/src/types.d.ts +129 -127
  60. package/types/src/urn.d.ts +194 -194
  61. package/types/src/utility.d.ts +134 -134
  62. package/types/src/validator.d.ts +3 -3
  63. package/.idea/compiler.xml +0 -6
  64. package/.idea/deployment.xml +0 -14
  65. package/.idea/jsLibraryMappings.xml +0 -6
  66. package/build/.idea/workspace.xml +0 -58
@@ -1,194 +1,194 @@
1
- /**
2
- * @file urn.ts
3
- * @author tngan
4
- * @desc Includes all keywords need in samlify
5
- */
6
- export declare enum BindingNamespace {
7
- Redirect = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
8
- Post = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
9
- SimpleSign = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign",
10
- Artifact = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact"
11
- }
12
- export declare enum MessageSignatureOrder {
13
- STE = "sign-then-encrypt",
14
- ETS = "encrypt-then-sign"
15
- }
16
- export declare enum StatusCode {
17
- Success = "urn:oasis:names:tc:SAML:2.0:status:Success",
18
- Requester = "urn:oasis:names:tc:SAML:2.0:status:Requester",
19
- Responder = "urn:oasis:names:tc:SAML:2.0:status:Responder",
20
- VersionMismatch = "urn:oasis:names:tc:SAML:2.0:status:VersionMismatch",
21
- AuthFailed = "urn:oasis:names:tc:SAML:2.0:status:AuthnFailed",
22
- InvalidAttrNameOrValue = "urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue",
23
- InvalidNameIDPolicy = "urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy",
24
- NoAuthnContext = "urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext",
25
- NoAvailableIDP = "urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP",
26
- NoPassive = "urn:oasis:names:tc:SAML:2.0:status:NoPassive",
27
- NoSupportedIDP = "urn:oasis:names:tc:SAML:2.0:status:NoSupportedIDP",
28
- PartialLogout = "urn:oasis:names:tc:SAML:2.0:status:PartialLogout",
29
- ProxyCountExceeded = "urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded",
30
- RequestDenied = "urn:oasis:names:tc:SAML:2.0:status:RequestDenied",
31
- RequestUnsupported = "urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported",
32
- RequestVersionDeprecated = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionDeprecated",
33
- RequestVersionTooHigh = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh",
34
- RequestVersionTooLow = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow",
35
- ResourceNotRecognized = "urn:oasis:names:tc:SAML:2.0:status:ResourceNotRecognized",
36
- TooManyResponses = "urn:oasis:names:tc:SAML:2.0:status:TooManyResponses",
37
- UnknownAttrProfile = "urn:oasis:names:tc:SAML:2.0:status:UnknownAttrProfile",
38
- UnknownPrincipal = "urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal",
39
- UnsupportedBinding = "urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding"
40
- }
41
- declare const namespace: {
42
- binding: {
43
- redirect: string;
44
- post: string;
45
- simpleSign: string;
46
- artifact: string;
47
- };
48
- names: {
49
- protocol: string;
50
- assertion: string;
51
- metadata: string;
52
- userLogout: string;
53
- adminLogout: string;
54
- };
55
- authnContextClassRef: {
56
- password: string;
57
- passwordProtectedTransport: string;
58
- };
59
- format: {
60
- emailAddress: string;
61
- persistent: string;
62
- transient: string;
63
- entity: string;
64
- unspecified: string;
65
- kerberos: string;
66
- windowsDomainQualifiedName: string;
67
- x509SubjectName: string;
68
- };
69
- statusCode: {
70
- success: string;
71
- requester: string;
72
- responder: string;
73
- versionMismatch: string;
74
- authFailed: string;
75
- invalidAttrNameOrValue: string;
76
- invalidNameIDPolicy: string;
77
- noAuthnContext: string;
78
- noAvailableIDP: string;
79
- noPassive: string;
80
- noSupportedIDP: string;
81
- partialLogout: string;
82
- proxyCountExceeded: string;
83
- requestDenied: string;
84
- requestUnsupported: string;
85
- requestVersionDeprecated: string;
86
- requestVersionTooHigh: string;
87
- requestVersionTooLow: string;
88
- resourceNotRecognized: string;
89
- tooManyResponses: string;
90
- unknownAttrProfile: string;
91
- unknownPrincipal: string;
92
- unsupportedBinding: string;
93
- };
94
- };
95
- declare const tags: {
96
- request: {
97
- AllowCreate: string;
98
- AssertionConsumerServiceURL: string;
99
- AuthnContextClassRef: string;
100
- AssertionID: string;
101
- Audience: string;
102
- AuthnStatement: string;
103
- AttributeStatement: string;
104
- ConditionsNotBefore: string;
105
- ConditionsNotOnOrAfter: string;
106
- Destination: string;
107
- EntityID: string;
108
- ID: string;
109
- Issuer: string;
110
- IssueInstant: string;
111
- InResponseTo: string;
112
- NameID: string;
113
- NameIDFormat: string;
114
- ProtocolBinding: string;
115
- SessionIndex: string;
116
- SubjectRecipient: string;
117
- SubjectConfirmationDataNotOnOrAfter: string;
118
- StatusCode: string;
119
- };
120
- xmlTag: {
121
- loginRequest: string;
122
- logoutRequest: string;
123
- loginResponse: string;
124
- logoutResponse: string;
125
- };
126
- };
127
- declare const messageConfigurations: {
128
- signingOrder: {
129
- SIGN_THEN_ENCRYPT: string;
130
- ENCRYPT_THEN_SIGN: string;
131
- };
132
- };
133
- declare const algorithms: {
134
- signature: {
135
- RSA_SHA1: string;
136
- RSA_SHA256: string;
137
- RSA_SHA512: string;
138
- };
139
- encryption: {
140
- data: {
141
- AES_128: string;
142
- AES_256: string;
143
- AES_256_GCM: string;
144
- TRI_DEC: string;
145
- AES_128_GCM: string;
146
- };
147
- key: {
148
- RSA_OAEP_MGF1P: string;
149
- RSA_1_5: string;
150
- };
151
- };
152
- digest: {
153
- 'http://www.w3.org/2000/09/xmldsig#rsa-sha1': string;
154
- 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256': string;
155
- 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512': string;
156
- };
157
- };
158
- export declare enum ParserType {
159
- SAMLRequest = "SAMLRequest",
160
- SAMLResponse = "SAMLResponse",
161
- LogoutRequest = "LogoutRequest",
162
- LogoutResponse = "LogoutResponse"
163
- }
164
- declare const wording: {
165
- urlParams: {
166
- samlRequest: string;
167
- samlResponse: string;
168
- logoutRequest: string;
169
- logoutResponse: string;
170
- sigAlg: string;
171
- signature: string;
172
- relayState: string;
173
- };
174
- binding: {
175
- redirect: string;
176
- post: string;
177
- simpleSign: string;
178
- artifact: string;
179
- };
180
- certUse: {
181
- signing: string;
182
- encrypt: string;
183
- };
184
- metadata: {
185
- sp: string;
186
- idp: string;
187
- };
188
- };
189
- declare const elementsOrder: {
190
- default: string[];
191
- onelogin: string[];
192
- shibboleth: string[];
193
- };
194
- export { namespace, tags, algorithms, wording, elementsOrder, messageConfigurations };
1
+ /**
2
+ * @file urn.ts
3
+ * @author tngan
4
+ * @desc Includes all keywords need in samlify
5
+ */
6
+ export declare enum BindingNamespace {
7
+ Redirect = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
8
+ Post = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
9
+ SimpleSign = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign",
10
+ Artifact = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact"
11
+ }
12
+ export declare enum MessageSignatureOrder {
13
+ STE = "sign-then-encrypt",
14
+ ETS = "encrypt-then-sign"
15
+ }
16
+ export declare enum StatusCode {
17
+ Success = "urn:oasis:names:tc:SAML:2.0:status:Success",
18
+ Requester = "urn:oasis:names:tc:SAML:2.0:status:Requester",
19
+ Responder = "urn:oasis:names:tc:SAML:2.0:status:Responder",
20
+ VersionMismatch = "urn:oasis:names:tc:SAML:2.0:status:VersionMismatch",
21
+ AuthFailed = "urn:oasis:names:tc:SAML:2.0:status:AuthnFailed",
22
+ InvalidAttrNameOrValue = "urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue",
23
+ InvalidNameIDPolicy = "urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy",
24
+ NoAuthnContext = "urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext",
25
+ NoAvailableIDP = "urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP",
26
+ NoPassive = "urn:oasis:names:tc:SAML:2.0:status:NoPassive",
27
+ NoSupportedIDP = "urn:oasis:names:tc:SAML:2.0:status:NoSupportedIDP",
28
+ PartialLogout = "urn:oasis:names:tc:SAML:2.0:status:PartialLogout",
29
+ ProxyCountExceeded = "urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded",
30
+ RequestDenied = "urn:oasis:names:tc:SAML:2.0:status:RequestDenied",
31
+ RequestUnsupported = "urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported",
32
+ RequestVersionDeprecated = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionDeprecated",
33
+ RequestVersionTooHigh = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh",
34
+ RequestVersionTooLow = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow",
35
+ ResourceNotRecognized = "urn:oasis:names:tc:SAML:2.0:status:ResourceNotRecognized",
36
+ TooManyResponses = "urn:oasis:names:tc:SAML:2.0:status:TooManyResponses",
37
+ UnknownAttrProfile = "urn:oasis:names:tc:SAML:2.0:status:UnknownAttrProfile",
38
+ UnknownPrincipal = "urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal",
39
+ UnsupportedBinding = "urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding"
40
+ }
41
+ declare const namespace: {
42
+ binding: {
43
+ redirect: string;
44
+ post: string;
45
+ simpleSign: string;
46
+ artifact: string;
47
+ };
48
+ names: {
49
+ protocol: string;
50
+ assertion: string;
51
+ metadata: string;
52
+ userLogout: string;
53
+ adminLogout: string;
54
+ };
55
+ authnContextClassRef: {
56
+ password: string;
57
+ passwordProtectedTransport: string;
58
+ };
59
+ format: {
60
+ emailAddress: string;
61
+ persistent: string;
62
+ transient: string;
63
+ entity: string;
64
+ unspecified: string;
65
+ kerberos: string;
66
+ windowsDomainQualifiedName: string;
67
+ x509SubjectName: string;
68
+ };
69
+ statusCode: {
70
+ success: string;
71
+ requester: string;
72
+ responder: string;
73
+ versionMismatch: string;
74
+ authFailed: string;
75
+ invalidAttrNameOrValue: string;
76
+ invalidNameIDPolicy: string;
77
+ noAuthnContext: string;
78
+ noAvailableIDP: string;
79
+ noPassive: string;
80
+ noSupportedIDP: string;
81
+ partialLogout: string;
82
+ proxyCountExceeded: string;
83
+ requestDenied: string;
84
+ requestUnsupported: string;
85
+ requestVersionDeprecated: string;
86
+ requestVersionTooHigh: string;
87
+ requestVersionTooLow: string;
88
+ resourceNotRecognized: string;
89
+ tooManyResponses: string;
90
+ unknownAttrProfile: string;
91
+ unknownPrincipal: string;
92
+ unsupportedBinding: string;
93
+ };
94
+ };
95
+ declare const tags: {
96
+ request: {
97
+ AllowCreate: string;
98
+ AssertionConsumerServiceURL: string;
99
+ AuthnContextClassRef: string;
100
+ AssertionID: string;
101
+ Audience: string;
102
+ AuthnStatement: string;
103
+ AttributeStatement: string;
104
+ ConditionsNotBefore: string;
105
+ ConditionsNotOnOrAfter: string;
106
+ Destination: string;
107
+ EntityID: string;
108
+ ID: string;
109
+ Issuer: string;
110
+ IssueInstant: string;
111
+ InResponseTo: string;
112
+ NameID: string;
113
+ NameIDFormat: string;
114
+ ProtocolBinding: string;
115
+ SessionIndex: string;
116
+ SubjectRecipient: string;
117
+ SubjectConfirmationDataNotOnOrAfter: string;
118
+ StatusCode: string;
119
+ };
120
+ xmlTag: {
121
+ loginRequest: string;
122
+ logoutRequest: string;
123
+ loginResponse: string;
124
+ logoutResponse: string;
125
+ };
126
+ };
127
+ declare const messageConfigurations: {
128
+ signingOrder: {
129
+ SIGN_THEN_ENCRYPT: string;
130
+ ENCRYPT_THEN_SIGN: string;
131
+ };
132
+ };
133
+ declare const algorithms: {
134
+ signature: {
135
+ RSA_SHA1: string;
136
+ RSA_SHA256: string;
137
+ RSA_SHA512: string;
138
+ };
139
+ encryption: {
140
+ data: {
141
+ AES_128: string;
142
+ AES_256: string;
143
+ AES_256_GCM: string;
144
+ TRI_DEC: string;
145
+ AES_128_GCM: string;
146
+ };
147
+ key: {
148
+ RSA_OAEP_MGF1P: string;
149
+ RSA_1_5: string;
150
+ };
151
+ };
152
+ digest: {
153
+ 'http://www.w3.org/2000/09/xmldsig#rsa-sha1': string;
154
+ 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256': string;
155
+ 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512': string;
156
+ };
157
+ };
158
+ export declare enum ParserType {
159
+ SAMLRequest = "SAMLRequest",
160
+ SAMLResponse = "SAMLResponse",
161
+ LogoutRequest = "LogoutRequest",
162
+ LogoutResponse = "LogoutResponse"
163
+ }
164
+ declare const wording: {
165
+ urlParams: {
166
+ samlRequest: string;
167
+ samlResponse: string;
168
+ logoutRequest: string;
169
+ logoutResponse: string;
170
+ sigAlg: string;
171
+ signature: string;
172
+ relayState: string;
173
+ };
174
+ binding: {
175
+ redirect: string;
176
+ post: string;
177
+ simpleSign: string;
178
+ artifact: string;
179
+ };
180
+ certUse: {
181
+ signing: string;
182
+ encrypt: string;
183
+ };
184
+ metadata: {
185
+ sp: string;
186
+ idp: string;
187
+ };
188
+ };
189
+ declare const elementsOrder: {
190
+ default: string[];
191
+ onelogin: string[];
192
+ shibboleth: string[];
193
+ };
194
+ export { namespace, tags, algorithms, wording, elementsOrder, messageConfigurations };
@@ -1,134 +1,134 @@
1
- /**
2
- * @desc Mimic lodash.zipObject
3
- * @param arr1 {string[]}
4
- * @param arr2 {[]}
5
- */
6
- export declare function zipObject(arr1: string[], arr2: any[], skipDuplicated?: boolean): {};
7
- /**
8
- * @desc Alternative to lodash.flattenDeep
9
- * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_flattendeep
10
- * @param input {[]}
11
- */
12
- export declare function flattenDeep(input: any[]): any;
13
- /**
14
- * @desc Alternative to lodash.last
15
- * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_last
16
- * @param input {[]}
17
- */
18
- export declare function last(input: any[]): any;
19
- /**
20
- * @desc Alternative to lodash.uniq
21
- * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_uniq
22
- * @param input {string[]}
23
- */
24
- export declare function uniq(input: string[]): string[];
25
- /**
26
- * @desc Alternative to lodash.get
27
- * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get
28
- * @param obj
29
- * @param path
30
- * @param defaultValue
31
- */
32
- export declare function get(obj: any, path: any, defaultValue: any): any;
33
- /**
34
- * @desc Check if the input is string
35
- * @param {any} input
36
- */
37
- export declare function isString(input: any): input is string;
38
- /**
39
- * @desc Encode string with base64 format
40
- * @param {string} message plain-text message
41
- * @return {string} base64 encoded string
42
- */
43
- declare function base64Encode(message: string | number[]): string;
44
- /**
45
- * @desc Decode string from base64 format
46
- * @param {string} base64Message encoded string
47
- * @param {boolean} isBytes determine the return value type (True: bytes False: string)
48
- * @return {bytes/string} decoded bytes/string depends on isBytes, default is {string}
49
- */
50
- export declare function base64Decode(base64Message: string, isBytes?: boolean): string | Buffer;
51
- /**
52
- * @desc Compress the string
53
- * @param {string} message
54
- * @return {string} compressed string
55
- */
56
- declare function deflateString(message: string): number[];
57
- /**
58
- * @desc Decompress the compressed string
59
- * @param {string} compressedString
60
- * @return {string} decompressed string
61
- */
62
- export declare function inflateString(compressedString: string): string;
63
- /**
64
- * @desc Parse the .cer to string format without line break, header and footer
65
- * @param {string} certString declares the certificate contents
66
- * @return {string} certificiate in string format
67
- */
68
- declare function normalizeCerString(certString: string | Buffer): string;
69
- /**
70
- * @desc Normalize the string in .pem format without line break, header and footer
71
- * @param {string} pemString
72
- * @return {string} private key in string format
73
- */
74
- declare function normalizePemString(pemString: string | Buffer): string;
75
- /**
76
- * @desc Return the complete URL
77
- * @param {object} req HTTP request
78
- * @return {string} URL
79
- */
80
- declare function getFullURL(req: any): string;
81
- /**
82
- * @desc Parse input string, return default value if it is undefined
83
- * @param {string/boolean}
84
- * @return {boolean}
85
- */
86
- declare function parseString(str: any, defaultValue?: string): any;
87
- /**
88
- * @desc Override the object by another object (rtl)
89
- * @param {object} default object
90
- * @param {object} object applied to the default object
91
- * @return {object} result object
92
- */
93
- declare function applyDefault(obj1: any, obj2: any): any;
94
- /**
95
- * @desc Get public key in pem format from the certificate included in the metadata
96
- * @param {string} x509 certificate
97
- * @return {string} public key fetched from the certificate
98
- */
99
- declare function getPublicKeyPemFromCertificate(x509CertificateString: string): string;
100
- /**
101
- * @desc Read private key from pem-formatted string
102
- * @param {string | Buffer} keyString pem-formatted string
103
- * @param {string} protected passphrase of the key
104
- * @return {string} string in pem format
105
- * If passphrase is used to protect the .pem content (recommend)
106
- */
107
- export declare function readPrivateKey(keyString: string | Buffer, passphrase: string | undefined, isOutputString?: boolean): any;
108
- /**
109
- * @desc Inline syntax sugar
110
- */
111
- declare function convertToString(input: any, isOutputString: any): any;
112
- /**
113
- * @desc Check if the input is an array with non-zero size
114
- */
115
- export declare function isNonEmptyArray(a: any): boolean;
116
- export declare function castArrayOpt<T>(a?: T | T[]): T[];
117
- export declare function notEmpty<TValue>(value: TValue | null | undefined): value is TValue;
118
- declare const utility: {
119
- isString: typeof isString;
120
- base64Encode: typeof base64Encode;
121
- base64Decode: typeof base64Decode;
122
- deflateString: typeof deflateString;
123
- inflateString: typeof inflateString;
124
- normalizeCerString: typeof normalizeCerString;
125
- normalizePemString: typeof normalizePemString;
126
- getFullURL: typeof getFullURL;
127
- parseString: typeof parseString;
128
- applyDefault: typeof applyDefault;
129
- getPublicKeyPemFromCertificate: typeof getPublicKeyPemFromCertificate;
130
- readPrivateKey: typeof readPrivateKey;
131
- convertToString: typeof convertToString;
132
- isNonEmptyArray: typeof isNonEmptyArray;
133
- };
134
- export default utility;
1
+ /**
2
+ * @file utility.ts
3
+ * @author tngan
4
+ * @desc Library for some common functions (e.g. de/inflation, en/decoding)
5
+ */
6
+ /// <reference types="node" />
7
+ /// <reference types="node" />
8
+ /**
9
+ * @desc Mimic lodash.zipObject
10
+ * @param arr1 {string[]}
11
+ * @param arr2 {[]}
12
+ */
13
+ export declare function zipObject(arr1: string[], arr2: any[], skipDuplicated?: boolean): {};
14
+ /**
15
+ * @desc Alternative to lodash.flattenDeep
16
+ * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_flattendeep
17
+ * @param input {[]}
18
+ */
19
+ export declare function flattenDeep(input: any[]): any;
20
+ /**
21
+ * @desc Alternative to lodash.last
22
+ * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_last
23
+ * @param input {[]}
24
+ */
25
+ export declare function last(input: any[]): any;
26
+ /**
27
+ * @desc Alternative to lodash.uniq
28
+ * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_uniq
29
+ * @param input {string[]}
30
+ */
31
+ export declare function uniq(input: string[]): string[];
32
+ /**
33
+ * @desc Alternative to lodash.get
34
+ * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get
35
+ * @param obj
36
+ * @param path
37
+ * @param defaultValue
38
+ */
39
+ export declare function get(obj: any, path: any, defaultValue: any): any;
40
+ /**
41
+ * @desc Check if the input is string
42
+ * @param {any} input
43
+ */
44
+ export declare function isString(input: any): boolean;
45
+ /**
46
+ * @desc Encode string with base64 format
47
+ * @param {string} message plain-text message
48
+ * @return {string} base64 encoded string
49
+ */
50
+ declare function base64Encode(message: string | number[]): string;
51
+ /**
52
+ * @desc Decode string from base64 format
53
+ * @param {string} base64Message encoded string
54
+ * @param {boolean} isBytes determine the return value type (True: bytes False: string)
55
+ * @return {bytes/string} decoded bytes/string depends on isBytes, default is {string}
56
+ */
57
+ export declare function base64Decode(base64Message: string, isBytes?: boolean): string | Buffer;
58
+ /**
59
+ * @desc Compress the string
60
+ * @param {string} message
61
+ * @return {string} compressed string
62
+ */
63
+ declare function deflateString(message: string): number[];
64
+ /**
65
+ * @desc Decompress the compressed string
66
+ * @param {string} compressedString
67
+ * @return {string} decompressed string
68
+ */
69
+ export declare function inflateString(compressedString: string): string;
70
+ /**
71
+ * @desc Parse the .cer to string format without line break, header and footer
72
+ * @param {string} certString declares the certificate contents
73
+ * @return {string} certificiate in string format
74
+ */
75
+ declare function normalizeCerString(certString: string | Buffer): string;
76
+ /**
77
+ * @desc Normalize the string in .pem format without line break, header and footer
78
+ * @param {string} pemString
79
+ * @return {string} private key in string format
80
+ */
81
+ declare function normalizePemString(pemString: string | Buffer): string;
82
+ /**
83
+ * @desc Return the complete URL
84
+ * @param {object} req HTTP request
85
+ * @return {string} URL
86
+ */
87
+ declare function getFullURL(req: any): string;
88
+ /**
89
+ * @desc Parse input string, return default value if it is undefined
90
+ * @param {string/boolean}
91
+ * @return {boolean}
92
+ */
93
+ declare function parseString(str: any, defaultValue?: string): any;
94
+ /**
95
+ * @desc Override the object by another object (rtl)
96
+ * @param {object} default object
97
+ * @param {object} object applied to the default object
98
+ * @return {object} result object
99
+ */
100
+ declare function applyDefault(obj1: any, obj2: any): any;
101
+ /**
102
+ * @desc Get public key in pem format from the certificate included in the metadata
103
+ * @param {string} x509 certificate
104
+ * @return {string} public key fetched from the certificate
105
+ */
106
+ declare function getPublicKeyPemFromCertificate(x509CertificateString: string): string | Buffer;
107
+ export declare function readPrivateKey(keyString: string | Buffer, passphrase?: string, isOutputString?: boolean): string | Buffer;
108
+ /**
109
+ * @desc Inline syntax sugar
110
+ */
111
+ declare function convertToString(input: any, isOutputString: any): any;
112
+ /**
113
+ * @desc Check if the input is an array with non-zero size
114
+ */
115
+ export declare function isNonEmptyArray(a: any): boolean;
116
+ export declare function castArrayOpt<T>(a?: T | T[]): T[];
117
+ export declare function notEmpty<TValue>(value: TValue | null | undefined): value is TValue;
118
+ declare const utility: {
119
+ isString: typeof isString;
120
+ base64Encode: typeof base64Encode;
121
+ base64Decode: typeof base64Decode;
122
+ deflateString: typeof deflateString;
123
+ inflateString: typeof inflateString;
124
+ normalizeCerString: typeof normalizeCerString;
125
+ normalizePemString: typeof normalizePemString;
126
+ getFullURL: typeof getFullURL;
127
+ parseString: typeof parseString;
128
+ applyDefault: typeof applyDefault;
129
+ getPublicKeyPemFromCertificate: typeof getPublicKeyPemFromCertificate;
130
+ readPrivateKey: typeof readPrivateKey;
131
+ convertToString: typeof convertToString;
132
+ isNonEmptyArray: typeof isNonEmptyArray;
133
+ };
134
+ export default utility;