samlesa 2.12.3

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.
Files changed (99) hide show
  1. package/.editorconfig +19 -0
  2. package/.github/FUNDING.yml +1 -0
  3. package/.idea/compiler.xml +6 -0
  4. package/.idea/deployment.xml +14 -0
  5. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  6. package/.idea/jsLibraryMappings.xml +6 -0
  7. package/.idea/modules.xml +8 -0
  8. package/.idea/samlify.iml +12 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/.pre-commit.sh +15 -0
  11. package/.snyk +8 -0
  12. package/.travis.yml +29 -0
  13. package/LICENSE +22 -0
  14. package/Makefile +25 -0
  15. package/README.md +84 -0
  16. package/build/.idea/workspace.xml +58 -0
  17. package/build/index.js +65 -0
  18. package/build/index.js.map +1 -0
  19. package/build/src/api.js +24 -0
  20. package/build/src/api.js.map +1 -0
  21. package/build/src/binding-post.js +369 -0
  22. package/build/src/binding-post.js.map +1 -0
  23. package/build/src/binding-redirect.js +333 -0
  24. package/build/src/binding-redirect.js.map +1 -0
  25. package/build/src/binding-simplesign.js +233 -0
  26. package/build/src/binding-simplesign.js.map +1 -0
  27. package/build/src/entity-idp.js +131 -0
  28. package/build/src/entity-idp.js.map +1 -0
  29. package/build/src/entity-sp.js +97 -0
  30. package/build/src/entity-sp.js.map +1 -0
  31. package/build/src/entity.js +236 -0
  32. package/build/src/entity.js.map +1 -0
  33. package/build/src/extractor.js +370 -0
  34. package/build/src/extractor.js.map +1 -0
  35. package/build/src/flow.js +320 -0
  36. package/build/src/flow.js.map +1 -0
  37. package/build/src/libsaml.js +642 -0
  38. package/build/src/libsaml.js.map +1 -0
  39. package/build/src/metadata-idp.js +128 -0
  40. package/build/src/metadata-idp.js.map +1 -0
  41. package/build/src/metadata-sp.js +232 -0
  42. package/build/src/metadata-sp.js.map +1 -0
  43. package/build/src/metadata.js +177 -0
  44. package/build/src/metadata.js.map +1 -0
  45. package/build/src/types.js +12 -0
  46. package/build/src/types.js.map +1 -0
  47. package/build/src/urn.js +213 -0
  48. package/build/src/urn.js.map +1 -0
  49. package/build/src/utility.js +249 -0
  50. package/build/src/utility.js.map +1 -0
  51. package/build/src/validator.js +27 -0
  52. package/build/src/validator.js.map +1 -0
  53. package/index.d.ts +10 -0
  54. package/index.js +19 -0
  55. package/index.js.map +1 -0
  56. package/index.ts +28 -0
  57. package/package.json +74 -0
  58. package/qodana.yaml +29 -0
  59. package/src/.idea/modules.xml +8 -0
  60. package/src/.idea/src.iml +12 -0
  61. package/src/.idea/vcs.xml +6 -0
  62. package/src/api.ts +36 -0
  63. package/src/binding-post.ts +338 -0
  64. package/src/binding-redirect.ts +331 -0
  65. package/src/binding-simplesign.ts +231 -0
  66. package/src/entity-idp.ts +145 -0
  67. package/src/entity-sp.ts +114 -0
  68. package/src/entity.ts +243 -0
  69. package/src/extractor.ts +392 -0
  70. package/src/flow.ts +467 -0
  71. package/src/libsaml.ts +786 -0
  72. package/src/metadata-idp.ts +146 -0
  73. package/src/metadata-sp.ts +268 -0
  74. package/src/metadata.ts +166 -0
  75. package/src/types.ts +153 -0
  76. package/src/urn.ts +211 -0
  77. package/src/utility.ts +248 -0
  78. package/src/validator.ts +44 -0
  79. package/tsconfig.json +38 -0
  80. package/tslint.json +35 -0
  81. package/types/index.d.ts +10 -0
  82. package/types/src/api.d.ts +13 -0
  83. package/types/src/binding-post.d.ts +46 -0
  84. package/types/src/binding-redirect.d.ts +52 -0
  85. package/types/src/binding-simplesign.d.ts +39 -0
  86. package/types/src/entity-idp.d.ts +42 -0
  87. package/types/src/entity-sp.d.ts +36 -0
  88. package/types/src/entity.d.ts +99 -0
  89. package/types/src/extractor.d.ts +25 -0
  90. package/types/src/flow.d.ts +6 -0
  91. package/types/src/libsaml.d.ts +210 -0
  92. package/types/src/metadata-idp.d.ts +24 -0
  93. package/types/src/metadata-sp.d.ts +36 -0
  94. package/types/src/metadata.d.ts +57 -0
  95. package/types/src/types.d.ts +127 -0
  96. package/types/src/urn.d.ts +194 -0
  97. package/types/src/utility.d.ts +134 -0
  98. package/types/src/validator.d.ts +3 -0
  99. package/types.d.ts +2 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @file metadata-sp.ts
3
+ * @author tngan
4
+ * @desc Metadata of service provider
5
+ */
6
+ import Metadata, { MetadataInterface } from './metadata.js';
7
+ import { MetadataSpConstructor } from './types.js';
8
+ export interface SpMetadataInterface extends MetadataInterface {
9
+ }
10
+ export default function (meta: MetadataSpConstructor): SpMetadata;
11
+ /**
12
+ * @desc SP Metadata is for creating Service Provider, provides a set of API to manage the actions in SP.
13
+ */
14
+ export declare class SpMetadata extends Metadata {
15
+ /**
16
+ * @param {object/string} meta (either xml string or configuration in object)
17
+ * @return {object} prototypes including public functions
18
+ */
19
+ constructor(meta: MetadataSpConstructor);
20
+ /**
21
+ * @desc Get the preference whether it wants a signed assertion response
22
+ * @return {boolean} Wantassertionssigned
23
+ */
24
+ isWantAssertionsSigned(): boolean;
25
+ /**
26
+ * @desc Get the preference whether it signs request
27
+ * @return {boolean} Authnrequestssigned
28
+ */
29
+ isAuthnRequestSigned(): boolean;
30
+ /**
31
+ * @desc Get the entity endpoint for assertion consumer service
32
+ * @param {string} binding protocol binding (e.g. redirect, post)
33
+ * @return {string/[string]} URL of endpoint(s)
34
+ */
35
+ getAssertionConsumerService(binding: string): string | string[];
36
+ }
@@ -0,0 +1,57 @@
1
+ export interface MetadataInterface {
2
+ xmlString: string;
3
+ getMetadata: () => string;
4
+ exportMetadata: (exportFile: string) => void;
5
+ getEntityID: () => string;
6
+ getX509Certificate: (certType: string) => string | string[];
7
+ getNameIDFormat: () => any[];
8
+ getSingleLogoutService: (binding: string | undefined) => string | object;
9
+ getSupportBindings: (services: string[]) => string[];
10
+ }
11
+ export default class Metadata implements MetadataInterface {
12
+ xmlString: string;
13
+ meta: any;
14
+ /**
15
+ * @param {string | Buffer} xml
16
+ * @param {object} extraParse for custom metadata extractor
17
+ */
18
+ constructor(xml: string | Buffer, extraParse?: any);
19
+ /**
20
+ * @desc Get the metadata in xml format
21
+ * @return {string} metadata in xml format
22
+ */
23
+ getMetadata(): string;
24
+ /**
25
+ * @desc Export the metadata to specific file
26
+ * @param {string} exportFile is the output file path
27
+ */
28
+ exportMetadata(exportFile: string): void;
29
+ /**
30
+ * @desc Get the entityID in metadata
31
+ * @return {string} entityID
32
+ */
33
+ getEntityID(): string;
34
+ /**
35
+ * @desc Get the x509 certificate declared in entity metadata
36
+ * @param {string} use declares the type of certificate
37
+ * @return {string} certificate in string format
38
+ */
39
+ getX509Certificate(use: string): any;
40
+ /**
41
+ * @desc Get the support NameID format declared in entity metadata
42
+ * @return {array} support NameID format
43
+ */
44
+ getNameIDFormat(): any;
45
+ /**
46
+ * @desc Get the entity endpoint for single logout service
47
+ * @param {string} binding e.g. redirect, post
48
+ * @return {string/object} location
49
+ */
50
+ getSingleLogoutService(binding: string | undefined): string | object;
51
+ /**
52
+ * @desc Get the support bindings
53
+ * @param {[string]} services
54
+ * @return {[string]} support bindings
55
+ */
56
+ getSupportBindings(services: string[]): string[];
57
+ }
@@ -0,0 +1,127 @@
1
+ import { LoginResponseTemplate } from './libsaml.js';
2
+ export { IdentityProvider as IdentityProviderConstructor } from './entity-idp.js';
3
+ export { IdpMetadata as IdentityProviderMetadata } from './metadata-idp.js';
4
+ export { ServiceProvider as ServiceProviderConstructor } from './entity-sp.js';
5
+ export { SpMetadata as ServiceProviderMetadata } from './metadata-sp.js';
6
+ export type MetadataFile = string | Buffer;
7
+ type SSOService = {
8
+ isDefault?: boolean;
9
+ Binding: string;
10
+ Location: string;
11
+ };
12
+ export type ServiceName = {
13
+ value: string;
14
+ /** @description 语言标识符(如 en/zh-CN) */
15
+ lang?: string;
16
+ };
17
+ export type RequestedAttribute = {
18
+ name: string;
19
+ friendlyName?: string;
20
+ isRequired?: boolean;
21
+ nameFormat?: string;
22
+ attributeValue?: string[];
23
+ };
24
+ export type AttributeConsumingService = {
25
+ isDefault: boolean;
26
+ serviceName: ServiceName[];
27
+ serviceDescription: ServiceName[];
28
+ requestedAttributes: RequestedAttribute[];
29
+ };
30
+ export type AttrService = AttributeConsumingService[];
31
+ export interface MetadataIdpOptions {
32
+ entityID?: string;
33
+ signingCert?: string | Buffer | (string | Buffer)[];
34
+ encryptCert?: string | Buffer | (string | Buffer)[];
35
+ wantAuthnRequestsSigned?: boolean;
36
+ nameIDFormat?: string[];
37
+ singleSignOnService?: SSOService[];
38
+ singleLogoutService?: SSOService[];
39
+ requestSignatureAlgorithm?: string;
40
+ }
41
+ export type MetadataIdpConstructor = MetadataIdpOptions | MetadataFile;
42
+ export interface MetadataSpOptions {
43
+ entityID?: string;
44
+ signingCert?: string | Buffer | (string | Buffer)[];
45
+ encryptCert?: string | Buffer | (string | Buffer)[];
46
+ authnRequestsSigned?: boolean;
47
+ wantAssertionsSigned?: boolean;
48
+ wantMessageSigned?: boolean;
49
+ signatureConfig?: {
50
+ [key: string]: any;
51
+ };
52
+ nameIDFormat?: string[];
53
+ singleSignOnService?: SSOService[];
54
+ singleLogoutService?: SSOService[];
55
+ assertionConsumerService?: SSOService[];
56
+ attributeConsumingService?: AttributeConsumingService[];
57
+ elementsOrder?: string[];
58
+ }
59
+ export type MetadataSpConstructor = MetadataSpOptions | MetadataFile;
60
+ export type EntitySetting = ServiceProviderSettings & IdentityProviderSettings;
61
+ export interface SignatureConfig {
62
+ prefix?: string;
63
+ location?: {
64
+ reference?: string;
65
+ action?: 'append' | 'prepend' | 'before' | 'after';
66
+ };
67
+ }
68
+ export interface SAMLDocumentTemplate {
69
+ context?: string;
70
+ }
71
+ export type ServiceProviderSettings = {
72
+ metadata?: string | Buffer;
73
+ entityID?: string;
74
+ authnRequestsSigned?: boolean;
75
+ wantAssertionsSigned?: boolean;
76
+ wantMessageSigned?: boolean;
77
+ wantLogoutResponseSigned?: boolean;
78
+ wantLogoutRequestSigned?: boolean;
79
+ privateKey?: string | Buffer;
80
+ privateKeyPass?: string;
81
+ isAssertionEncrypted?: boolean;
82
+ requestSignatureAlgorithm?: string;
83
+ encPrivateKey?: string | Buffer;
84
+ encPrivateKeyPass?: string | Buffer;
85
+ assertionConsumerService?: SSOService[];
86
+ singleLogoutService?: SSOService[];
87
+ signatureConfig?: SignatureConfig;
88
+ loginRequestTemplate?: SAMLDocumentTemplate;
89
+ logoutRequestTemplate?: SAMLDocumentTemplate;
90
+ signingCert?: string | Buffer | (string | Buffer)[];
91
+ encryptCert?: string | Buffer | (string | Buffer)[];
92
+ transformationAlgorithms?: string[];
93
+ nameIDFormat?: string[];
94
+ allowCreate?: boolean;
95
+ relayState?: string;
96
+ clockDrifts?: [number, number];
97
+ };
98
+ export type IdentityProviderSettings = {
99
+ metadata?: string | Buffer;
100
+ /** signature algorithm */
101
+ requestSignatureAlgorithm?: string;
102
+ /** template of login response */
103
+ loginResponseTemplate?: LoginResponseTemplate;
104
+ /** template of logout request */
105
+ logoutRequestTemplate?: SAMLDocumentTemplate;
106
+ /** customized function used for generating request ID */
107
+ generateID?: () => string;
108
+ entityID?: string;
109
+ privateKey?: string | Buffer;
110
+ privateKeyPass?: string;
111
+ signingCert?: string | Buffer | (string | Buffer)[];
112
+ encryptCert?: string | Buffer | (string | Buffer)[];
113
+ nameIDFormat?: string[];
114
+ singleSignOnService?: SSOService[];
115
+ singleLogoutService?: SSOService[];
116
+ isAssertionEncrypted?: boolean;
117
+ encPrivateKey?: string | Buffer;
118
+ encPrivateKeyPass?: string;
119
+ messageSigningOrder?: string;
120
+ wantLogoutRequestSigned?: boolean;
121
+ wantLogoutResponseSigned?: boolean;
122
+ wantAuthnRequestsSigned?: boolean;
123
+ wantLogoutRequestSignedResponseSigned?: boolean;
124
+ tagPrefix?: {
125
+ [key: string]: string;
126
+ };
127
+ };
@@ -0,0 +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 };
@@ -0,0 +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;
@@ -0,0 +1,3 @@
1
+ type DriftTolerance = [number, number];
2
+ declare function verifyTime(utcNotBefore: string | undefined, utcNotOnOrAfter: string | undefined, drift?: DriftTolerance): boolean;
3
+ export { verifyTime };
package/types.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './index'
2
+ export * from './src/types'