samlify 2.11.0 → 2.13.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 (83) hide show
  1. package/README.md +1 -1
  2. package/build/src/api.js +52 -3
  3. package/build/src/api.js.map +1 -1
  4. package/build/src/binding-post.js +236 -182
  5. package/build/src/binding-post.js.map +1 -1
  6. package/build/src/binding-redirect.js +303 -215
  7. package/build/src/binding-redirect.js.map +1 -1
  8. package/build/src/binding-simplesign.js +285 -137
  9. package/build/src/binding-simplesign.js.map +1 -1
  10. package/build/src/entity-idp.js +130 -47
  11. package/build/src/entity-idp.js.map +1 -1
  12. package/build/src/entity-sp.js +81 -39
  13. package/build/src/entity-sp.js.map +1 -1
  14. package/build/src/entity.js +100 -62
  15. package/build/src/entity.js.map +1 -1
  16. package/build/src/extractor.js +119 -155
  17. package/build/src/extractor.js.map +1 -1
  18. package/build/src/flow.js +100 -96
  19. package/build/src/flow.js.map +1 -1
  20. package/build/src/libsaml.js +318 -261
  21. package/build/src/libsaml.js.map +1 -1
  22. package/build/src/metadata-idp.js +60 -30
  23. package/build/src/metadata-idp.js.map +1 -1
  24. package/build/src/metadata-sp.js +51 -41
  25. package/build/src/metadata-sp.js.map +1 -1
  26. package/build/src/metadata.js +47 -43
  27. package/build/src/metadata.js.map +1 -1
  28. package/build/src/options.js +73 -0
  29. package/build/src/options.js.map +1 -0
  30. package/build/src/urn.js +28 -1
  31. package/build/src/urn.js.map +1 -1
  32. package/build/src/utility.js +165 -83
  33. package/build/src/utility.js.map +1 -1
  34. package/build/src/validator.js +27 -10
  35. package/build/src/validator.js.map +1 -1
  36. package/package.json +17 -7
  37. package/types/src/api.d.ts +33 -3
  38. package/types/src/binding-post.d.ts +67 -34
  39. package/types/src/binding-redirect.d.ts +58 -31
  40. package/types/src/binding-simplesign.d.ts +77 -21
  41. package/types/src/entity-idp.d.ts +40 -31
  42. package/types/src/entity-sp.d.ts +37 -27
  43. package/types/src/entity.d.ts +71 -77
  44. package/types/src/extractor.d.ts +31 -22
  45. package/types/src/flow.d.ts +24 -2
  46. package/types/src/libsaml.d.ts +172 -118
  47. package/types/src/metadata-idp.d.ts +27 -11
  48. package/types/src/metadata-sp.d.ts +29 -19
  49. package/types/src/metadata.d.ts +59 -34
  50. package/types/src/options.d.ts +37 -0
  51. package/types/src/types.d.ts +250 -24
  52. package/types/src/urn.d.ts +7 -0
  53. package/types/src/utility.d.ts +144 -89
  54. package/types/src/validator.d.ts +21 -0
  55. package/.circleci/config.yml +0 -98
  56. package/.editorconfig +0 -19
  57. package/.github/FUNDING.yml +0 -1
  58. package/.github/workflows/deploy-docs.yml +0 -56
  59. package/.pre-commit.sh +0 -15
  60. package/.snyk +0 -4
  61. package/Makefile +0 -25
  62. package/index.ts +0 -28
  63. package/src/api.ts +0 -36
  64. package/src/binding-post.ts +0 -336
  65. package/src/binding-redirect.ts +0 -335
  66. package/src/binding-simplesign.ts +0 -231
  67. package/src/entity-idp.ts +0 -145
  68. package/src/entity-sp.ts +0 -114
  69. package/src/entity.ts +0 -243
  70. package/src/extractor.ts +0 -399
  71. package/src/flow.ts +0 -469
  72. package/src/libsaml.ts +0 -777
  73. package/src/metadata-idp.ts +0 -146
  74. package/src/metadata-sp.ts +0 -203
  75. package/src/metadata.ts +0 -166
  76. package/src/types.ts +0 -127
  77. package/src/urn.ts +0 -210
  78. package/src/utility.ts +0 -231
  79. package/src/validator.ts +0 -44
  80. package/tsconfig.json +0 -41
  81. package/tslint.json +0 -35
  82. package/types.d.ts +0 -2
  83. package/vitest.config.ts +0 -12
@@ -1,42 +1,75 @@
1
1
  /**
2
- * @file binding-post.ts
3
- * @author tngan
4
- * @desc Binding-level API, declare the functions using POST binding
5
- */
6
- import { BindingContext } from './entity';
2
+ * @file binding-post.ts
3
+ * @author tngan
4
+ * @desc Binding-level API for SAML HTTP-POST. Builds base64 login/logout
5
+ * request and response payloads that callers embed in an auto-submitting
6
+ * HTML form.
7
+ */
8
+ import type { BindingContext, RequestInfo, SAMLUser } from './types';
9
+ import type { IdentityProvider as Idp } from './entity-idp';
10
+ import type { ServiceProvider as Sp } from './entity-sp';
11
+ import type Entity from './entity';
12
+ /** Shape passed to builder functions that need both IdP and SP handles. */
13
+ interface PostIdpSpPair {
14
+ idp: Idp;
15
+ sp: Sp;
16
+ }
17
+ /** Shape passed to builder functions for logout (initiator + target). */
18
+ interface PostInitTargetPair {
19
+ init: Entity;
20
+ target: Entity;
21
+ }
7
22
  /**
8
- * @desc Generate a base64 encoded login request
9
- * @param {string} referenceTagXPath reference uri
10
- * @param {object} entity object includes both idp and sp
11
- * @param {function} customTagReplacement used when developers have their own login response template
12
- */
13
- declare function base64LoginRequest(referenceTagXPath: string, entity: any, customTagReplacement?: (template: string) => BindingContext): BindingContext;
23
+ * Generate a base64-encoded AuthnRequest for the HTTP-POST binding.
24
+ *
25
+ * @param referenceTagXPath XPath used when signing the request
26
+ * @param entity `{ idp, sp }` handles
27
+ * @param customTagReplacement optional custom template transformer
28
+ * @param forceAuthn per-request `ForceAuthn` flag (saml-core §3.4.1)
29
+ * @param assertionConsumerServiceIndex per-request ACS index (saml-core §3.4.1).
30
+ * Mutually exclusive with `AssertionConsumerServiceURL` / `ProtocolBinding`;
31
+ * when supplied, both of those attributes are dropped from the rendered XML.
32
+ * @returns id / base64-XML pair
33
+ */
34
+ declare function base64LoginRequest(referenceTagXPath: string, entity: PostIdpSpPair, customTagReplacement?: (template: string) => BindingContext, forceAuthn?: boolean, assertionConsumerServiceIndex?: number): BindingContext;
14
35
  /**
15
- * @desc Generate a base64 encoded login response
16
- * @param {object} requestInfo corresponding request, used to obtain the id
17
- * @param {object} entity object includes both idp and sp
18
- * @param {object} user current logged user (e.g. req.user)
19
- * @param {function} customTagReplacement used when developers have their own login response template
20
- * @param {boolean} encryptThenSign whether or not to encrypt then sign first (if signing). Defaults to sign-then-encrypt
21
- */
22
- declare function base64LoginResponse(requestInfo: any | undefined, entity: any, user?: any, customTagReplacement?: (template: string) => BindingContext, encryptThenSign?: boolean): Promise<BindingContext>;
36
+ * Generate a base64-encoded login response for the HTTP-POST binding.
37
+ * Supports the sign-then-encrypt and encrypt-then-sign pipelines based on
38
+ * `encryptThenSign`.
39
+ *
40
+ * @param requestInfo parsed login request used to link `InResponseTo`
41
+ * @param entity `{ idp, sp }` handles
42
+ * @param user authenticated user
43
+ * @param customTagReplacement optional custom template transformer
44
+ * @param encryptThenSign when true, encrypt the assertion first then sign
45
+ * @returns id / base64-XML pair
46
+ */
47
+ declare function base64LoginResponse(requestInfo: (RequestInfo | {
48
+ extract?: {
49
+ request?: {
50
+ id?: string;
51
+ };
52
+ };
53
+ }) | undefined, entity: PostIdpSpPair, user?: SAMLUser, customTagReplacement?: (template: string) => BindingContext, encryptThenSign?: boolean): Promise<BindingContext>;
23
54
  /**
24
- * @desc Generate a base64 encoded logout request
25
- * @param {object} user current logged user (e.g. req.user)
26
- * @param {string} referenceTagXPath reference uri
27
- * @param {object} entity object includes both idp and sp
28
- * @param {function} customTagReplacement used when developers have their own login response template
29
- * @return {string} base64 encoded request
30
- */
31
- declare function base64LogoutRequest(user: any, referenceTagXPath: any, entity: any, customTagReplacement?: (template: string) => BindingContext): BindingContext;
55
+ * Generate a base64-encoded LogoutRequest for the HTTP-POST binding.
56
+ *
57
+ * @param user currently authenticated user
58
+ * @param referenceTagXPath XPath used when signing the request
59
+ * @param entity `{ init, target }` handles
60
+ * @param customTagReplacement optional custom template transformer
61
+ * @returns id / base64-XML pair
62
+ */
63
+ declare function base64LogoutRequest(user: SAMLUser, referenceTagXPath: string, entity: PostInitTargetPair, customTagReplacement?: (template: string) => BindingContext): BindingContext;
32
64
  /**
33
- * @desc Generate a base64 encoded logout response
34
- * @param {object} requestInfo corresponding request, used to obtain the id
35
- * @param {string} referenceTagXPath reference uri
36
- * @param {object} entity object includes both idp and sp
37
- * @param {function} customTagReplacement used when developers have their own login response template
38
- */
39
- declare function base64LogoutResponse(requestInfo: any, entity: any, customTagReplacement: (template: string) => BindingContext): BindingContext;
65
+ * Generate a base64-encoded LogoutResponse for the HTTP-POST binding.
66
+ *
67
+ * @param requestInfo parsed request used to link `InResponseTo`
68
+ * @param entity `{ init, target }` handles
69
+ * @param customTagReplacement optional custom template transformer
70
+ * @returns id / base64-XML pair
71
+ */
72
+ declare function base64LogoutResponse(requestInfo: RequestInfo, entity: PostInitTargetPair, customTagReplacement?: (template: string) => BindingContext): BindingContext;
40
73
  declare const postBinding: {
41
74
  base64LoginRequest: typeof base64LoginRequest;
42
75
  base64LoginResponse: typeof base64LoginResponse;
@@ -1,48 +1,75 @@
1
- import { BindingContext } from './entity';
2
- import { IdentityProvider as Idp } from './entity-idp';
3
- import { ServiceProvider as Sp } from './entity-sp';
1
+ import type { BindingContext, RequestInfo, SAMLUser } from './types';
2
+ import type { IdentityProvider as Idp } from './entity-idp';
3
+ import type { ServiceProvider as Sp } from './entity-sp';
4
+ import type Entity from './entity';
5
+ /** Options consumed by {@link buildRedirectURL}. */
4
6
  export interface BuildRedirectConfig {
5
7
  baseUrl: string;
6
8
  type: string;
7
9
  isSigned: boolean;
8
10
  context: string;
9
- entitySetting: any;
11
+ entitySetting: {
12
+ requestSignatureAlgorithm?: string;
13
+ privateKey?: string | Buffer;
14
+ privateKeyPass?: string;
15
+ };
10
16
  relayState?: string;
11
17
  }
18
+ /** Initiator/target entity pair used for logout redirects. */
19
+ interface RedirectInitTargetPair {
20
+ init: Entity;
21
+ target: Entity;
22
+ }
12
23
  /**
13
- * @desc Redirect URL for login request
14
- * @param {object} entity object includes both idp and sp
15
- * @param {function} customTagReplacement used when developers have their own login response template
16
- * @return {string} redirect URL
17
- */
24
+ * Build a redirect URL carrying a SAML AuthnRequest.
25
+ *
26
+ * @param entity `{ idp, sp }` handles
27
+ * @param customTagReplacement optional custom template transformer
28
+ * @param relayState per-request RelayState; falls back to `entitySetting.relayState`
29
+ * @param forceAuthn per-request `ForceAuthn` flag (saml-core §3.4.1)
30
+ * @param assertionConsumerServiceIndex per-request ACS index (saml-core §3.4.1).
31
+ * Mutually exclusive with `AssertionConsumerServiceURL` / `ProtocolBinding`;
32
+ * when supplied, both of those attributes are dropped from the rendered XML.
33
+ * @returns id + redirect URL wrapped in a {@link BindingContext}
34
+ */
18
35
  declare function loginRequestRedirectURL(entity: {
19
36
  idp: Idp;
20
37
  sp: Sp;
21
- }, customTagReplacement?: (template: string) => BindingContext): BindingContext;
38
+ }, customTagReplacement?: (template: string) => BindingContext, relayState?: string, forceAuthn?: boolean, assertionConsumerServiceIndex?: number): BindingContext;
22
39
  /**
23
- * @desc Redirect URL for login response
24
- * @param {object} requestInfo corresponding request, used to obtain the id
25
- * @param {object} entity object includes both idp and sp
26
- * @param {object} user current logged user (e.g. req.user)
27
- * @param {String} relayState the relaystate sent by sp corresponding request
28
- * @param {function} customTagReplacement used when developers have their own login response template
29
- */
30
- declare function loginResponseRedirectURL(requestInfo: any, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext): BindingContext;
40
+ * Build a redirect URL carrying a SAML login Response.
41
+ *
42
+ * @param requestInfo parsed request used to link `InResponseTo`
43
+ * @param entity `{ idp, sp }` handles
44
+ * @param user authenticated user
45
+ * @param relayState caller-supplied redirect URL
46
+ * @param customTagReplacement optional custom template transformer
47
+ * @returns id + redirect URL wrapped in a {@link BindingContext}
48
+ */
49
+ declare function loginResponseRedirectURL(requestInfo: RequestInfo, entity: {
50
+ idp: Idp;
51
+ sp: Sp;
52
+ }, user?: SAMLUser, relayState?: string, customTagReplacement?: (template: string) => BindingContext): BindingContext;
31
53
  /**
32
- * @desc Redirect URL for logout request
33
- * @param {object} user current logged user (e.g. req.user)
34
- * @param {object} entity object includes both idp and sp
35
- * @param {function} customTagReplacement used when developers have their own login response template
36
- * @return {string} redirect URL
37
- */
38
- declare function logoutRequestRedirectURL(user: any, entity: any, relayState?: string, customTagReplacement?: (template: string, tags: object) => BindingContext): BindingContext;
54
+ * Build a redirect URL carrying a SAML LogoutRequest.
55
+ *
56
+ * @param user currently authenticated user
57
+ * @param entity `{ init, target }` handles
58
+ * @param relayState caller-supplied redirect URL
59
+ * @param customTagReplacement optional custom template transformer
60
+ * @returns id + redirect URL wrapped in a {@link BindingContext}
61
+ */
62
+ declare function logoutRequestRedirectURL(user: SAMLUser, entity: RedirectInitTargetPair, relayState?: string, customTagReplacement?: (template: string, tags: object) => BindingContext): BindingContext;
39
63
  /**
40
- * @desc Redirect URL for logout response
41
- * @param {object} requescorresponding request, used to obtain the id
42
- * @param {object} entity object includes both idp and sp
43
- * @param {function} customTagReplacement used when developers have their own login response template
44
- */
45
- declare function logoutResponseRedirectURL(requestInfo: any, entity: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext): BindingContext;
64
+ * Build a redirect URL carrying a SAML LogoutResponse.
65
+ *
66
+ * @param requestInfo parsed request used to link `InResponseTo`
67
+ * @param entity `{ init, target }` handles
68
+ * @param relayState caller-supplied redirect URL
69
+ * @param customTagReplacement optional custom template transformer
70
+ * @returns id + redirect URL wrapped in a {@link BindingContext}
71
+ */
72
+ declare function logoutResponseRedirectURL(requestInfo: RequestInfo, entity: RedirectInitTargetPair, relayState?: string, customTagReplacement?: (template: string) => BindingContext): BindingContext;
46
73
  declare const redirectBinding: {
47
74
  loginRequestRedirectURL: typeof loginRequestRedirectURL;
48
75
  loginResponseRedirectURL: typeof loginResponseRedirectURL;
@@ -1,39 +1,95 @@
1
1
  /**
2
- * @file binding-simplesign.ts
3
- * @author Orange
4
- * @desc Binding-level API, declare the functions using POST SimpleSign binding
5
- */
6
- import { BindingContext, SimpleSignComputedContext } from './entity';
2
+ * @file binding-simplesign.ts
3
+ * @author Orange
4
+ * @desc Binding-level API for SAML HTTP-POST-SimpleSign. Produces base64
5
+ * payloads alongside a detached signature over the canonical octet string.
6
+ */
7
+ import type { BindingContext, SimpleSignComputedContext, RequestInfo, SAMLUser } from './types';
8
+ import type { IdentityProvider as Idp } from './entity-idp';
9
+ import type { ServiceProvider as Sp } from './entity-sp';
10
+ import type Entity from './entity';
11
+ /** Options consumed by {@link buildSimpleSignature}. */
7
12
  export interface BuildSimpleSignConfig {
8
13
  type: string;
9
14
  context: string;
10
- entitySetting: any;
15
+ entitySetting: {
16
+ requestSignatureAlgorithm?: string;
17
+ privateKey?: string | Buffer;
18
+ privateKeyPass?: string;
19
+ };
11
20
  relayState?: string;
12
21
  }
22
+ /** Return value for login-response building with simple signatures. */
13
23
  export interface BindingSimpleSignContext {
14
24
  id: string;
15
25
  context: string;
16
- signature: any;
26
+ signature: string | Buffer;
17
27
  sigAlg: string;
18
28
  }
29
+ /** `{ idp, sp }` handle used by simple-sign builders. */
30
+ interface SimpleSignIdpSpPair {
31
+ idp: Idp;
32
+ sp: Sp;
33
+ }
34
+ /** `{ init, target }` handle used by simple-sign logout builders. */
35
+ interface SimpleSignInitTargetPair {
36
+ init: Entity;
37
+ target: Entity;
38
+ }
39
+ /**
40
+ * Generate a base64-encoded AuthnRequest together with a detached simple
41
+ * signature when the IdP advertises `WantAuthnRequestsSigned`.
42
+ *
43
+ * @param entity `{ idp, sp }` handles
44
+ * @param customTagReplacement optional custom template transformer
45
+ * @param relayState per-request RelayState; falls back to `entitySetting.relayState`
46
+ * @param forceAuthn per-request `ForceAuthn` flag (saml-core §3.4.1)
47
+ * @param assertionConsumerServiceIndex per-request ACS index (saml-core §3.4.1).
48
+ * Mutually exclusive with `AssertionConsumerServiceURL` / `ProtocolBinding`;
49
+ * when supplied, both of those attributes are dropped from the rendered XML.
50
+ */
51
+ declare function base64LoginRequest(entity: SimpleSignIdpSpPair, customTagReplacement?: (template: string) => BindingContext, relayState?: string, forceAuthn?: boolean, assertionConsumerServiceIndex?: number): SimpleSignComputedContext;
52
+ /**
53
+ * Generate a base64-encoded login response together with a detached simple
54
+ * signature. Login responses are always signed under this binding.
55
+ *
56
+ * @param requestInfo parsed request used to link `InResponseTo`
57
+ * @param entity `{ idp, sp }` handles
58
+ * @param user authenticated user
59
+ * @param relayState caller-supplied redirect URL
60
+ * @param customTagReplacement optional custom template transformer
61
+ */
62
+ declare function base64LoginResponse(requestInfo: (RequestInfo | {
63
+ extract?: {
64
+ request?: {
65
+ id?: string;
66
+ };
67
+ };
68
+ }) | undefined, entity: SimpleSignIdpSpPair, user?: SAMLUser, relayState?: string, customTagReplacement?: (template: string) => BindingContext): Promise<BindingSimpleSignContext>;
19
69
  /**
20
- * @desc Generate a base64 encoded login request
21
- * @param {string} referenceTagXPath reference uri
22
- * @param {object} entity object includes both idp and sp
23
- * @param {function} customTagReplacement used when developers have their own login response template
24
- */
25
- declare function base64LoginRequest(entity: any, customTagReplacement?: (template: string) => BindingContext): SimpleSignComputedContext;
70
+ * Generate a base64-encoded LogoutRequest together with a detached simple
71
+ * signature when the receiving entity requires signed logout requests.
72
+ *
73
+ * @param user currently authenticated user
74
+ * @param entity `{ init, target }` handles
75
+ * @param relayState caller-supplied redirect URL
76
+ * @param customTagReplacement optional custom template transformer
77
+ */
78
+ declare function base64LogoutRequest(user: SAMLUser, entity: SimpleSignInitTargetPair, relayState?: string, customTagReplacement?: (template: string) => BindingContext): SimpleSignComputedContext;
26
79
  /**
27
- * @desc Generate a base64 encoded login response
28
- * @param {object} requestInfo corresponding request, used to obtain the id
29
- * @param {object} entity object includes both idp and sp
30
- * @param {object} user current logged user (e.g. req.user)
31
- * @param {string} relayState the relay state
32
- * @param {function} customTagReplacement used when developers have their own login response template
33
- */
34
- declare function base64LoginResponse(requestInfo: any | undefined, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext): Promise<BindingSimpleSignContext>;
80
+ * Generate a base64-encoded LogoutResponse together with a detached simple
81
+ * signature when the receiving entity requires signed logout responses.
82
+ *
83
+ * @param requestInfo parsed request used to link `InResponseTo`
84
+ * @param entity `{ init, target }` handles
85
+ * @param relayState caller-supplied redirect URL
86
+ * @param customTagReplacement optional custom template transformer
87
+ */
88
+ declare function base64LogoutResponse(requestInfo: RequestInfo, entity: SimpleSignInitTargetPair, relayState?: string, customTagReplacement?: (template: string) => BindingContext): SimpleSignComputedContext;
35
89
  declare const simpleSignBinding: {
36
90
  base64LoginRequest: typeof base64LoginRequest;
37
91
  base64LoginResponse: typeof base64LoginResponse;
92
+ base64LogoutRequest: typeof base64LogoutRequest;
93
+ base64LogoutResponse: typeof base64LogoutResponse;
38
94
  };
39
95
  export default simpleSignBinding;
@@ -1,42 +1,51 @@
1
1
  /**
2
- * @file entity-idp.ts
3
- * @author tngan
4
- * @desc Declares the actions taken by identity provider
5
- */
6
- import Entity, { ESamlHttpRequest } from './entity';
7
- import { ServiceProviderConstructor as ServiceProvider, IdentityProviderMetadata, IdentityProviderSettings } from './types';
8
- import { FlowResult } from './flow';
9
- import { BindingContext } from './entity';
10
- /**
11
- * Identity provider can be configured using either metadata importing or idpSetting
2
+ * @file entity-idp.ts
3
+ * @author tngan
4
+ * @desc Identity provider: builds login responses and parses inbound
5
+ * login requests coming from a service provider.
12
6
  */
13
- export default function (props: IdentityProviderSettings): IdentityProvider;
7
+ import Entity from './entity';
8
+ import type { BindingContext, ESamlHttpRequest, PostBindingContext, SimpleSignBindingContext, RequestInfo, SAMLUser, IdentityProviderSettings, IdentityProviderMetadata, ServiceProviderConstructor as ServiceProvider, CreateLoginResponseOptions, CustomTagReplacement } from './types';
14
9
  /**
15
- * Identity provider can be configured using either metadata importing or idpSetting
10
+ * Factory returning a new {@link IdentityProvider}. An IdP can be built
11
+ * from an XML metadata document or from a programmatic settings object.
12
+ *
13
+ * @param props IdP settings
16
14
  */
15
+ export default function (props: IdentityProviderSettings): IdentityProvider;
16
+ /** Identity-provider entity. */
17
17
  export declare class IdentityProvider extends Entity {
18
18
  entityMeta: IdentityProviderMetadata;
19
+ /**
20
+ * Build an IdP, expanding `loginResponseTemplate.attributes` into a
21
+ * pre-baked AttributeStatement template when supplied.
22
+ */
19
23
  constructor(idpSetting: IdentityProviderSettings);
20
24
  /**
21
- * @desc Generates the login response for developers to design their own method
22
- * @param sp object of service provider
23
- * @param requestInfo corresponding request, used to obtain the id
24
- * @param binding protocol binding
25
- * @param user current logged user (e.g. req.user)
26
- * @param customTagReplacement used when developers have their own login response template
27
- * @param encryptThenSign whether or not to encrypt then sign first (if signing)
28
- * @param relayState the relayState from corresponding request
29
- */
30
- createLoginResponse(sp: ServiceProvider, requestInfo: {
31
- [key: string]: any;
32
- }, binding: string, user: {
33
- [key: string]: any;
34
- }, customTagReplacement?: (template: string) => BindingContext, encryptThenSign?: boolean, relayState?: string): Promise<any>;
25
+ * Build a login response for delivery to the supplied service provider.
26
+ *
27
+ * The fifth parameter accepts either a callback (legacy positional shape)
28
+ * or an options bag `{ relayState?, customTagReplacement?, encryptThenSign? }`.
29
+ * When the legacy shape is used, the trailing `legacyEncryptThenSign` and
30
+ * `legacyRelayState` positional arguments are honoured. Per
31
+ * `saml-bindings §3.4.3 / §3.5.3`, RelayState is request-scoped pass it
32
+ * via the options bag instead of `entitySetting.relayState`.
33
+ *
34
+ * @param sp target service provider
35
+ * @param requestInfo parsed request used to set `InResponseTo`
36
+ * @param binding `post`, `simpleSign`, or `redirect`
37
+ * @param user authenticated user
38
+ * @param optionsOrCallback per-request options or legacy custom-template callback
39
+ * @param legacyEncryptThenSign legacy positional `encryptThenSign`; ignored when options bag is used
40
+ * @param legacyRelayState legacy positional `relayState`; ignored when options bag is used
41
+ */
42
+ createLoginResponse(sp: ServiceProvider, requestInfo: RequestInfo, binding: string, user: SAMLUser, optionsOrCallback?: CreateLoginResponseOptions | CustomTagReplacement, legacyEncryptThenSign?: boolean, legacyRelayState?: string): Promise<BindingContext | PostBindingContext | SimpleSignBindingContext>;
35
43
  /**
36
- * Validation of the parsed URL parameters
37
- * @param sp ServiceProvider instance
38
- * @param binding Protocol binding
39
- * @param req RequesmessageSigningOrderst
44
+ * Parse, validate and verify an inbound login request.
45
+ *
46
+ * @param sp service provider that produced the request
47
+ * @param binding `redirect`, `post`, or `simpleSign`
48
+ * @param req HTTP request envelope
40
49
  */
41
- parseLoginRequest(sp: ServiceProvider, binding: string, req: ESamlHttpRequest): Promise<FlowResult>;
50
+ parseLoginRequest(sp: ServiceProvider, binding: string, req: ESamlHttpRequest): Promise<import("./flow").FlowResult>;
42
51
  }
@@ -1,36 +1,46 @@
1
1
  /**
2
- * @file entity-sp.ts
3
- * @author tngan
4
- * @desc Declares the actions taken by service provider
5
- */
6
- import Entity, { BindingContext, PostBindingContext, ESamlHttpRequest, SimpleSignBindingContext } from './entity';
7
- import { IdentityProviderConstructor as IdentityProvider, ServiceProviderMetadata, ServiceProviderSettings } from './types';
8
- import { FlowResult } from './flow';
9
- export default function (props: ServiceProviderSettings): ServiceProvider;
2
+ * @file entity-sp.ts
3
+ * @author tngan
4
+ * @desc Service provider: builds login requests and parses inbound login
5
+ * responses coming from an identity provider.
6
+ */
7
+ import Entity from './entity';
8
+ import type { BindingContext, PostBindingContext, ESamlHttpRequest, SimpleSignBindingContext, IdentityProviderConstructor as IdentityProvider, ServiceProviderMetadata, ServiceProviderSettings, CreateLoginRequestOptions, CustomTagReplacement } from './types';
10
9
  /**
11
- * @desc Service provider can be configured using either metadata importing or spSetting
12
- * @param {object} spSettingimport { FlowResult } from '../types/src/flow.d';
13
-
14
- */
10
+ * Factory returning a new {@link ServiceProvider}. An SP can be built from
11
+ * an XML metadata document or from a programmatic settings object.
12
+ *
13
+ * @param props SP settings
14
+ */
15
+ export default function (props: ServiceProviderSettings): ServiceProvider;
16
+ /** Service-provider entity. */
15
17
  export declare class ServiceProvider extends Entity {
16
18
  entityMeta: ServiceProviderMetadata;
17
19
  /**
18
- * @desc Inherited from Entity
19
- * @param {object} spSetting setting of service provider
20
- */
20
+ * Build an SP with sensible defaults for signing flags.
21
+ *
22
+ * @param spSetting SP settings object
23
+ */
21
24
  constructor(spSetting: ServiceProviderSettings);
22
25
  /**
23
- * @desc Generates the login request for developers to design their own method
24
- * @param {IdentityProvider} idp object of identity provider
25
- * @param {string} binding protocol binding
26
- * @param {function} customTagReplacement used when developers have their own login response template
27
- */
28
- createLoginRequest(idp: IdentityProvider, binding?: string, customTagReplacement?: (template: string) => BindingContext): BindingContext | PostBindingContext | SimpleSignBindingContext;
26
+ * Build a login request targeting the supplied identity provider.
27
+ *
28
+ * The third parameter accepts either a callback (legacy shape) or an
29
+ * options bag `{ relayState?, customTagReplacement? }`. Per
30
+ * `saml-bindings §3.4.3 / §3.5.3`, RelayState is request-scoped — pass
31
+ * it via the options bag instead of `entitySetting.relayState`.
32
+ *
33
+ * @param idp target identity provider
34
+ * @param binding `redirect` (default), `post`, or `simpleSign`
35
+ * @param optionsOrCallback per-request options or a custom-template callback
36
+ */
37
+ createLoginRequest(idp: IdentityProvider, binding?: string, optionsOrCallback?: CreateLoginRequestOptions | CustomTagReplacement): BindingContext | PostBindingContext | SimpleSignBindingContext;
29
38
  /**
30
- * @desc Validation of the parsed the URL parameters
31
- * @param {IdentityProvider} idp object of identity provider
32
- * @param {string} binding protocol binding
33
- * @param {request} req request
34
- */
35
- parseLoginResponse(idp: any, binding: any, request: ESamlHttpRequest): Promise<FlowResult>;
39
+ * Parse, validate and verify an inbound login response.
40
+ *
41
+ * @param idp identity provider that produced the response
42
+ * @param binding `redirect`, `post`, or `simpleSign`
43
+ * @param request HTTP request envelope
44
+ */
45
+ parseLoginResponse(idp: IdentityProvider, binding: string, request: ESamlHttpRequest): Promise<import("./flow").FlowResult>;
36
46
  }