samlify 2.9.0 → 2.10.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.
Files changed (45) hide show
  1. package/build/index.js +17 -7
  2. package/build/index.js.map +1 -1
  3. package/build/src/api.js +3 -4
  4. package/build/src/api.js.map +1 -1
  5. package/build/src/binding-post.js +25 -15
  6. package/build/src/binding-post.js.map +1 -1
  7. package/build/src/binding-redirect.js +17 -7
  8. package/build/src/binding-redirect.js.map +1 -1
  9. package/build/src/binding-simplesign.js +24 -14
  10. package/build/src/binding-simplesign.js.map +1 -1
  11. package/build/src/entity-idp.js +4 -4
  12. package/build/src/entity-idp.js.map +1 -1
  13. package/build/src/entity-sp.js +2 -2
  14. package/build/src/entity-sp.js.map +1 -1
  15. package/build/src/entity.js +17 -7
  16. package/build/src/entity.js.map +1 -1
  17. package/build/src/extractor.js +2 -2
  18. package/build/src/extractor.js.map +1 -1
  19. package/build/src/flow.js +4 -5
  20. package/build/src/flow.js.map +1 -1
  21. package/build/src/libsaml.js +162 -83
  22. package/build/src/libsaml.js.map +1 -1
  23. package/build/src/metadata-idp.js +9 -9
  24. package/build/src/metadata-idp.js.map +1 -1
  25. package/build/src/metadata-sp.js +9 -9
  26. package/build/src/metadata-sp.js.map +1 -1
  27. package/build/src/metadata.js +17 -7
  28. package/build/src/metadata.js.map +1 -1
  29. package/build/src/urn.js +4 -4
  30. package/build/src/urn.js.map +1 -1
  31. package/build/src/utility.js +12 -13
  32. package/build/src/utility.js.map +1 -1
  33. package/build/src/validator.js +1 -2
  34. package/build/src/validator.js.map +1 -1
  35. package/package.json +2 -2
  36. package/src/libsaml.ts +82 -47
  37. package/types/src/binding-post.d.ts +1 -1
  38. package/types/src/binding-simplesign.d.ts +1 -1
  39. package/types/src/entity.d.ts +1 -2
  40. package/types/src/extractor.d.ts +1 -1
  41. package/types/src/libsaml.d.ts +15 -11
  42. package/types/src/metadata.d.ts +0 -1
  43. package/types/src/types.d.ts +7 -8
  44. package/types/src/utility.d.ts +1 -2
  45. package/types/src/validator.d.ts +1 -1
@@ -31,7 +31,7 @@ declare function base64LoginRequest(entity: any, customTagReplacement?: (templat
31
31
  * @param {string} relayState the relay state
32
32
  * @param {function} customTagReplacement used when developers have their own login response template
33
33
  */
34
- declare function base64LoginResponse(requestInfo: any, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext): Promise<BindingSimpleSignContext>;
34
+ declare function base64LoginResponse(requestInfo: any | undefined, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext): Promise<BindingSimpleSignContext>;
35
35
  declare const simpleSignBinding: {
36
36
  base64LoginRequest: typeof base64LoginRequest;
37
37
  base64LoginResponse: typeof base64LoginResponse;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { IdpMetadata as IdpMetadataConstructor } from './metadata-idp';
3
2
  import { SpMetadata as SpMetadataConstructor } from './metadata-sp';
4
3
  import { MetadataIdpConstructor, MetadataSpConstructor, EntitySetting } from './types';
@@ -31,7 +30,7 @@ export interface ParseResult {
31
30
  extract: any;
32
31
  sigAlg: string;
33
32
  }
34
- export declare type EntityConstructor = (MetadataIdpConstructor | MetadataSpConstructor) & {
33
+ export type EntityConstructor = (MetadataIdpConstructor | MetadataSpConstructor) & {
35
34
  metadata?: string | Buffer;
36
35
  };
37
36
  export default class Entity {
@@ -6,7 +6,7 @@ interface ExtractorField {
6
6
  attributePath?: string[];
7
7
  context?: boolean;
8
8
  }
9
- export declare type ExtractorFields = ExtractorField[];
9
+ export type ExtractorFields = ExtractorField[];
10
10
  export declare const loginRequestFields: ExtractorFields;
11
11
  export declare const loginResponseStatusFields: {
12
12
  key: string;
@@ -3,7 +3,6 @@
3
3
  * @author tngan
4
4
  * @desc A simple library including some common functions
5
5
  */
6
- /// <reference types="node" />
7
6
  import { MetadataInterface } from './metadata';
8
7
  export interface SignatureConstructor {
9
8
  rawSamlMessage: string;
@@ -58,7 +57,7 @@ export interface LogoutRequestTemplate extends BaseSamlTemplate {
58
57
  }
59
58
  export interface LogoutResponseTemplate extends BaseSamlTemplate {
60
59
  }
61
- export declare type KeyUse = 'signing' | 'encryption';
60
+ export type KeyUse = 'signing' | 'encryption';
62
61
  export interface KeyComponent {
63
62
  [key: string]: any;
64
63
  }
@@ -86,7 +85,7 @@ export interface LibSamlInterface {
86
85
  defaultLogoutResponseTemplate: LogoutResponseTemplate;
87
86
  }
88
87
  declare const _default: {
89
- createXPath: (local: any, isExtractAll?: boolean | undefined) => string;
88
+ createXPath: (local: any, isExtractAll?: boolean) => string;
90
89
  getQueryParamByType: (type: string) => "SAMLRequest" | "SAMLResponse";
91
90
  defaultLoginRequestTemplate: {
92
91
  context: string;
@@ -121,7 +120,7 @@ declare const _default: {
121
120
  * @param {array} tagValues tag values
122
121
  * @return {string}
123
122
  */
124
- replaceTagsByValue(rawXML: string, tagValues: any): string;
123
+ replaceTagsByValue(rawXML: string, tagValues: Record<string, unknown>): string;
125
124
  /**
126
125
  * @desc Helper function to build the AttributeStatement tag
127
126
  * @param {LoginResponseAttribute} attributes an array of attribute configuration
@@ -146,9 +145,11 @@ declare const _default: {
146
145
  * @desc Verify the XML signature
147
146
  * @param {string} xml xml
148
147
  * @param {SignatureVerifierOptions} opts cert declares the X509 certificate
149
- * @return {boolean} verification result
150
- */
151
- verifySignature(xml: string, opts: SignatureVerifierOptions): (string | boolean | null)[];
148
+ * @return {[boolean, string | null]} - A tuple where:
149
+ * - The first element is `true` if the signature is valid, `false` otherwise.
150
+ * - The second element is the cryptographically authenticated assertion node as a string, or `null` if not found.
151
+ */
152
+ verifySignature(xml: string, opts: SignatureVerifierOptions): (string | boolean)[] | (boolean | null)[];
152
153
  /**
153
154
  * @desc Helper function to create the key section in metadata (abstraction for signing and encrypt use)
154
155
  * @param {string} use type of certificate (e.g. signing, encrypt)
@@ -164,7 +165,7 @@ declare const _default: {
164
165
  * @param {string} signingAlgorithm signing algorithm
165
166
  * @return {string} message signature
166
167
  */
167
- constructMessageSignature(octetString: string, key: string, passphrase?: string | undefined, isBase64?: boolean | undefined, signingAlgorithm?: string | undefined): string | Buffer;
168
+ constructMessageSignature(octetString: string, key: string, passphrase?: string, isBase64?: boolean, signingAlgorithm?: string): string | Buffer;
168
169
  /**
169
170
  * @desc Verifies message signature
170
171
  * @param {Metadata} metadata metadata object of identity provider or service provider
@@ -173,13 +174,16 @@ declare const _default: {
173
174
  * @param {string} verifyAlgorithm algorithm used to verify
174
175
  * @return {boolean} verification result
175
176
  */
176
- verifyMessageSignature(metadata: any, octetString: string, signature: string | Buffer, verifyAlgorithm?: string | undefined): boolean;
177
+ verifyMessageSignature(metadata: any, octetString: string, signature: string | Buffer, verifyAlgorithm?: string): boolean;
177
178
  /**
178
179
  * @desc Get the public key in string format
179
180
  * @param {string} x509Certificate certificate
180
181
  * @return {string} public key
181
182
  */
182
- getKeyInfo(x509Certificate: string, signatureConfig?: any): void;
183
+ getKeyInfo(x509Certificate: string, signatureConfig?: any): {
184
+ getKeyInfo: () => string;
185
+ getKey: () => string;
186
+ };
183
187
  /**
184
188
  * @desc Encrypt the assertion section in Response
185
189
  * @param {Entity} sourceEntity source entity
@@ -187,7 +191,7 @@ declare const _default: {
187
191
  * @param {string} xml response in xml string format
188
192
  * @return {Promise} a promise to resolve the finalized xml
189
193
  */
190
- encryptAssertion(sourceEntity: any, targetEntity: any, xml?: string | undefined): Promise<string>;
194
+ encryptAssertion(sourceEntity: any, targetEntity: any, xml?: string): Promise<string>;
191
195
  /**
192
196
  * @desc Decrypt the assertion section in Response
193
197
  * @param {string} type only accept SAMLResponse to proceed decryption
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export interface MetadataInterface {
3
2
  xmlString: string;
4
3
  getMetadata: () => string;
@@ -1,11 +1,10 @@
1
- /// <reference types="node" />
2
1
  import { LoginResponseTemplate } from './libsaml';
3
2
  export { IdentityProvider as IdentityProviderConstructor } from './entity-idp';
4
3
  export { IdpMetadata as IdentityProviderMetadata } from './metadata-idp';
5
4
  export { ServiceProvider as ServiceProviderConstructor } from './entity-sp';
6
5
  export { SpMetadata as ServiceProviderMetadata } from './metadata-sp';
7
- export declare type MetadataFile = string | Buffer;
8
- declare type SSOService = {
6
+ export type MetadataFile = string | Buffer;
7
+ type SSOService = {
9
8
  isDefault?: boolean;
10
9
  Binding: string;
11
10
  Location: string;
@@ -20,7 +19,7 @@ export interface MetadataIdpOptions {
20
19
  singleLogoutService?: SSOService[];
21
20
  requestSignatureAlgorithm?: string;
22
21
  }
23
- export declare type MetadataIdpConstructor = MetadataIdpOptions | MetadataFile;
22
+ export type MetadataIdpConstructor = MetadataIdpOptions | MetadataFile;
24
23
  export interface MetadataSpOptions {
25
24
  entityID?: string;
26
25
  signingCert?: string | Buffer | (string | Buffer)[];
@@ -37,8 +36,8 @@ export interface MetadataSpOptions {
37
36
  assertionConsumerService?: SSOService[];
38
37
  elementsOrder?: string[];
39
38
  }
40
- export declare type MetadataSpConstructor = MetadataSpOptions | MetadataFile;
41
- export declare type EntitySetting = ServiceProviderSettings & IdentityProviderSettings;
39
+ export type MetadataSpConstructor = MetadataSpOptions | MetadataFile;
40
+ export type EntitySetting = ServiceProviderSettings & IdentityProviderSettings;
42
41
  export interface SignatureConfig {
43
42
  prefix?: string;
44
43
  location?: {
@@ -49,7 +48,7 @@ export interface SignatureConfig {
49
48
  export interface SAMLDocumentTemplate {
50
49
  context?: string;
51
50
  }
52
- export declare type ServiceProviderSettings = {
51
+ export type ServiceProviderSettings = {
53
52
  metadata?: string | Buffer;
54
53
  entityID?: string;
55
54
  authnRequestsSigned?: boolean;
@@ -76,7 +75,7 @@ export declare type ServiceProviderSettings = {
76
75
  relayState?: string;
77
76
  clockDrifts?: [number, number];
78
77
  };
79
- export declare type IdentityProviderSettings = {
78
+ export type IdentityProviderSettings = {
80
79
  metadata?: string | Buffer;
81
80
  /** signature algorithm */
82
81
  requestSignatureAlgorithm?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * @desc Mimic lodash.zipObject
4
3
  * @param arr1 {string[]}
@@ -35,7 +34,7 @@ export declare function get(obj: any, path: any, defaultValue: any): any;
35
34
  * @desc Check if the input is string
36
35
  * @param {any} input
37
36
  */
38
- export declare function isString(input: any): boolean;
37
+ export declare function isString(input: any): input is string;
39
38
  /**
40
39
  * @desc Encode string with base64 format
41
40
  * @param {string} message plain-text message
@@ -1,3 +1,3 @@
1
- declare type DriftTolerance = [number, number];
1
+ type DriftTolerance = [number, number];
2
2
  declare function verifyTime(utcNotBefore: string | undefined, utcNotOnOrAfter: string | undefined, drift?: DriftTolerance): boolean;
3
3
  export { verifyTime };