44 * @desc An abstraction for identity provider and service provider.
55 */
66import { v4 as uuid } from 'uuid' ;
7+ import type { BindingContext , ESamlHttpRequest , PostBindingContext } from './binding' ;
78import postBinding from './binding-post' ;
89import redirectBinding from './binding-redirect' ;
910import { SamlifyError , SamlifyErrorCode } from './error' ;
1011import { flow , FlowResult } from './flow' ;
11- import type { CustomTagReplacement } from './libsaml' ;
12- import type { Metadata } from './metadata' ;
13- import type { EntitySettings , ParsedLogoutRequest , ParsedLogoutResponse } from './types' ;
14- import { algorithms , BindingNamespace , messageConfigurations , ParserType } from './urn' ;
12+ import type {
13+ CustomTagReplacement ,
14+ EncryptionAlgorithm ,
15+ KeyEncryptionAlgorithm ,
16+ LogoutResponseTemplate ,
17+ RequestSignatureAlgorithm ,
18+ SAMLDocumentTemplate ,
19+ SignatureConfig ,
20+ } from './libsaml' ;
21+ import type { Metadata , SSOService } from './metadata' ;
22+ import { algorithms , BindingNamespace , messageConfigurations , MessageSignatureOrder , ParserType } from './urn' ;
1523import { isNonEmptyArray , isString } from './utility' ;
1624
1725const dataEncryptionAlgorithm = algorithms . encryption . data ;
@@ -32,27 +40,58 @@ const defaultEntitySetting = {
3240 relayState : '' ,
3341} as const ;
3442
35- export interface ESamlHttpRequest {
36- query ?: any ;
37- body ?: any ;
38- octetString ?: string ;
39- }
43+ export interface EntitySettings {
44+ metadata ?: string | Buffer ;
45+ entityID ?: string ;
46+ singleLogoutService ?: SSOService [ ] ;
47+
48+ isAssertionEncrypted ?: boolean ;
49+
50+ /** signature algorithm */
51+ requestSignatureAlgorithm ?: RequestSignatureAlgorithm ;
52+ dataEncryptionAlgorithm ?: EncryptionAlgorithm ;
53+ keyEncryptionAlgorithm ?: KeyEncryptionAlgorithm ;
54+
55+ messageSigningOrder ?: MessageSignatureOrder ;
56+ signatureConfig ?: SignatureConfig ;
57+ transformationAlgorithms ?: string [ ] ;
58+ wantLogoutRequestSigned ?: boolean ;
59+ wantLogoutResponseSigned ?: boolean ;
60+
61+ signingCert ?: string | Buffer ;
62+ privateKey ?: string | Buffer ;
63+ privateKeyPass ?: string ;
64+
65+ encryptCert ?: string | Buffer ;
66+ encPrivateKey ?: string | Buffer ;
67+ encPrivateKeyPass ?: string ;
68+
69+ /** template of logout request */
70+ logoutRequestTemplate ?: SAMLDocumentTemplate ;
71+ /** template of logout response */
72+ logoutResponseTemplate ?: LogoutResponseTemplate ;
73+
74+ nameIDFormat ?: string [ ] ;
75+ // https://github.com/tngan/samlify/issues/337
76+ clockDrifts ?: [ number , number ] ;
77+ /** customized function used for generating request ID */
78+ generateID ?: ( ) => string ;
4079
41- export interface BindingContext {
42- context : string ;
43- id : string ;
80+ /** Declare the tag of specific xml document node. `TagPrefixKey` currently supports `encryptedAssertion` only */
81+ tagPrefix ?: { encryptedAssertion ?: string } ;
4482}
4583
46- export interface PostBindingContext extends BindingContext {
47- relayState ?: string ;
48- entityEndpoint : string ;
49- type : 'SAMLRequest' | 'SAMLResponse' ;
84+ export interface ParsedLogoutRequest {
85+ request ?: { id ?: string ; issueInstant ?: string ; destination ?: string } ;
86+ issuer ?: string ;
87+ nameID ?: string ;
88+ signature ?: string ;
5089}
5190
52- export interface ParseResult {
53- samlContent : string ;
54- extract : any ;
55- sigAlg : string ;
91+ export interface ParsedLogoutResponse {
92+ response ?: { id ?: string ; destination ?: string ; inResponseTo ?: string } ;
93+ issuer ?: string ;
94+ signature ? : string ;
5695}
5796
5897export class Entity < Settings extends EntitySettings = EntitySettings , Meta extends Metadata = Metadata > {
0 commit comments