samlesa 2.12.10 → 2.12.11
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.
- package/build/src/binding-post.js +2 -2
- package/build/src/binding-post.js.map +1 -1
- package/build/src/binding-redirect.js +2 -2
- package/build/src/binding-redirect.js.map +1 -1
- package/build/src/binding-simplesign.js +2 -2
- package/build/src/binding-simplesign.js.map +1 -1
- package/build/src/entity-idp.js +17 -22
- package/build/src/entity-idp.js.map +1 -1
- package/build/src/extractor.js +1 -1
- package/build/src/extractor.js.map +1 -1
- package/build/src/libsaml.js +148 -103
- package/build/src/libsaml.js.map +1 -1
- package/build/src/validator.js.map +1 -1
- package/package.json +70 -70
- package/src/binding-post.ts +2 -2
- package/src/binding-redirect.ts +2 -2
- package/src/binding-simplesign.ts +2 -2
- package/src/entity-idp.ts +4 -4
- package/src/extractor.ts +1 -1
- package/src/libsaml.ts +271 -207
- package/src/validator.ts +2 -7
- package/types/src/binding-post.d.ts +1 -1
- package/types/src/binding-redirect.d.ts +1 -1
- package/types/src/binding-simplesign.d.ts +1 -1
- package/types/src/entity-idp.d.ts +1 -1
- package/types/src/libsaml.d.ts +56 -47
package/src/validator.ts
CHANGED
|
@@ -6,20 +6,15 @@ function verifyTime(
|
|
|
6
6
|
utcNotOnOrAfter: string | undefined,
|
|
7
7
|
drift: DriftTolerance = [0, 0]
|
|
8
8
|
): boolean {
|
|
9
|
-
|
|
10
9
|
const now = new Date();
|
|
11
|
-
|
|
12
10
|
if (!utcNotBefore && !utcNotOnOrAfter) {
|
|
13
11
|
// show warning because user intends to have time check but the document doesn't include corresponding information
|
|
14
12
|
console.warn('You intend to have time validation however the document doesn\'t include the valid range.');
|
|
15
|
-
return true;
|
|
13
|
+
return true;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
let notBeforeLocal: Date | null = null;
|
|
19
16
|
let notOnOrAfterLocal: Date | null = null;
|
|
20
|
-
|
|
21
17
|
const [notBeforeDrift, notOnOrAfterDrift] = drift;
|
|
22
|
-
|
|
23
18
|
if (utcNotBefore && !utcNotOnOrAfter) {
|
|
24
19
|
notBeforeLocal = new Date(utcNotBefore);
|
|
25
20
|
return +notBeforeLocal + notBeforeDrift <= +now;
|
|
@@ -41,4 +36,4 @@ function verifyTime(
|
|
|
41
36
|
|
|
42
37
|
export {
|
|
43
38
|
verifyTime
|
|
44
|
-
};
|
|
39
|
+
};
|
|
@@ -20,7 +20,7 @@ declare function base64LoginRequest(referenceTagXPath: string, entity: any, cust
|
|
|
20
20
|
* @param {boolean} encryptThenSign whether or not to encrypt then sign first (if signing). Defaults to sign-then-encrypt
|
|
21
21
|
* @param AttributeStatement
|
|
22
22
|
*/
|
|
23
|
-
declare function base64LoginResponse(requestInfo: any, entity: any, user?: any, customTagReplacement?: (template: string) => BindingContext, encryptThenSign?: boolean, AttributeStatement?:
|
|
23
|
+
declare function base64LoginResponse(requestInfo: any, entity: any, user?: any, customTagReplacement?: (template: string) => BindingContext, encryptThenSign?: boolean, AttributeStatement?: never[]): Promise<BindingContext>;
|
|
24
24
|
/**
|
|
25
25
|
* @desc Generate a base64 encoded logout request
|
|
26
26
|
* @param {object} user current logged user (e.g. req.user)
|
|
@@ -28,7 +28,7 @@ declare function loginRequestRedirectURL(entity: {
|
|
|
28
28
|
* @param {function} customTagReplacement used when developers have their own login response template
|
|
29
29
|
* @param AttributeStatement
|
|
30
30
|
*/
|
|
31
|
-
declare function loginResponseRedirectURL(requestInfo: any, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext, AttributeStatement?:
|
|
31
|
+
declare function loginResponseRedirectURL(requestInfo: any, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext, AttributeStatement?: never[]): BindingContext;
|
|
32
32
|
/**
|
|
33
33
|
* @desc Redirect URL for logout request
|
|
34
34
|
* @param {object} user current logged user (e.g. req.user)
|
|
@@ -32,7 +32,7 @@ declare function base64LoginRequest(entity: any, customTagReplacement?: (templat
|
|
|
32
32
|
* @param {function} customTagReplacement used when developers have their own login response template
|
|
33
33
|
* @param AttributeStatement
|
|
34
34
|
*/
|
|
35
|
-
declare function base64LoginResponse(requestInfo: any, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext, AttributeStatement?:
|
|
35
|
+
declare function base64LoginResponse(requestInfo: any, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext, AttributeStatement?: []): Promise<BindingSimpleSignContext>;
|
|
36
36
|
declare const simpleSignBinding: {
|
|
37
37
|
base64LoginRequest: typeof base64LoginRequest;
|
|
38
38
|
base64LoginResponse: typeof base64LoginResponse;
|
|
@@ -25,7 +25,7 @@ export declare class IdentityProvider extends Entity {
|
|
|
25
25
|
encryptThenSign?: boolean;
|
|
26
26
|
relayState?: string;
|
|
27
27
|
context: Record<string, any>;
|
|
28
|
-
AttributeStatement:
|
|
28
|
+
AttributeStatement: [];
|
|
29
29
|
}): Promise<any>;
|
|
30
30
|
/**
|
|
31
31
|
* Validation of the parsed URL parameters
|
package/types/src/libsaml.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { MetadataInterface } from './metadata.js';
|
|
4
|
+
/**
|
|
5
|
+
* 生成 SAML Attribute 元素(不带 XML 声明头)
|
|
6
|
+
* @param {Array} attributeData - 属性配置数据
|
|
7
|
+
* @returns {string} SAML Attribute XML 字符串
|
|
8
|
+
*/
|
|
4
9
|
export interface SignatureConstructor {
|
|
5
10
|
rawSamlMessage: string;
|
|
6
11
|
referenceTagXPath?: string;
|
|
@@ -112,48 +117,52 @@ declare const _default: {
|
|
|
112
117
|
defaultLogoutResponseTemplate: {
|
|
113
118
|
context: string;
|
|
114
119
|
};
|
|
120
|
+
defaultAttributeValueTemplate: {
|
|
121
|
+
context: string;
|
|
122
|
+
};
|
|
115
123
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
* @desc Replace the tag (e.g. {tag}) inside the raw XML
|
|
125
|
+
* @param {string} rawXML raw XML string used to do keyword replacement
|
|
126
|
+
* @param {array} tagValues tag values
|
|
127
|
+
* @return {string}
|
|
128
|
+
*/
|
|
121
129
|
replaceTagsByValue(rawXML: string, tagValues: Record<string, unknown>): string;
|
|
122
130
|
/**
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
* @desc Helper function to build the AttributeStatement tag
|
|
132
|
+
* @param {LoginResponseAttribute} attributes an array of attribute configuration
|
|
133
|
+
* @param {AttributeTemplate} attributeTemplate the attribute tag template to be used
|
|
134
|
+
* @param {AttributeStatementTemplate} attributeStatementTemplate the attributeStatement tag template to be used
|
|
135
|
+
* @return {string}
|
|
136
|
+
*/
|
|
137
|
+
/** For Test */
|
|
138
|
+
attributeStatementBuilder(attributeData: any[]): string;
|
|
130
139
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
* @desc Construct the XML signature for POST binding
|
|
141
|
+
* @param {string} rawSamlMessage request/response xml string
|
|
142
|
+
* @param {string} referenceTagXPath reference uri
|
|
143
|
+
* @param {string} privateKey declares the private key
|
|
144
|
+
* @param {string} passphrase passphrase of the private key [optional]
|
|
145
|
+
* @param {string|buffer} signingCert signing certificate
|
|
146
|
+
* @param {string} signatureAlgorithm signature algorithm
|
|
147
|
+
* @param {string[]} transformationAlgorithms canonicalization and transformation Algorithms
|
|
148
|
+
* @return {string} base64 encoded string
|
|
149
|
+
*/
|
|
141
150
|
constructSAMLSignature(opts: SignatureConstructor): string;
|
|
142
151
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
152
|
+
* @desc Verify the XML signature
|
|
153
|
+
* @param {string} xml xml
|
|
154
|
+
* @param {SignatureVerifierOptions} opts cert declares the X509 certificate
|
|
146
155
|
* @return {[boolean, string | null]} - A tuple where:
|
|
147
156
|
* - The first element is `true` if the signature is valid, `false` otherwise.
|
|
148
157
|
* - The second element is the cryptographically authenticated assertion node as a string, or `null` if not found.
|
|
149
158
|
*/
|
|
150
159
|
verifySignature(xml: string, opts: SignatureVerifierOptions): (string | boolean)[] | (boolean | null)[];
|
|
151
160
|
/**
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
* @desc Helper function to create the key section in metadata (abstraction for signing and encrypt use)
|
|
162
|
+
* @param {string} use type of certificate (e.g. signing, encrypt)
|
|
163
|
+
* @param {string} certString declares the certificate String
|
|
164
|
+
* @return {object} object used in xml module
|
|
165
|
+
*/
|
|
157
166
|
createKeySection(use: KeyUse, certString: string | Buffer): KeyComponent;
|
|
158
167
|
/**
|
|
159
168
|
* SAML 消息签名 (符合 SAML V2.0 绑定规范)
|
|
@@ -167,30 +176,30 @@ declare const _default: {
|
|
|
167
176
|
constructMessageSignature(octetString: string | Buffer, key: string | Buffer, passphrase?: string | undefined, isBase64?: boolean, signingAlgorithm?: string): string | Buffer;
|
|
168
177
|
verifyMessageSignature(metadata: any, octetString: string, signature: string | Buffer, verifyAlgorithm?: string | undefined): boolean;
|
|
169
178
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
179
|
+
* @desc Get the public key in string format
|
|
180
|
+
* @param {string} x509Certificate certificate
|
|
181
|
+
* @return {string} public key
|
|
182
|
+
*/
|
|
174
183
|
getKeyInfo(x509Certificate: string, signatureConfig?: any): {
|
|
175
184
|
getKeyInfo: () => string;
|
|
176
185
|
getKey: () => string;
|
|
177
186
|
};
|
|
178
187
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
188
|
+
* @desc Encrypt the assertion section in Response
|
|
189
|
+
* @param {Entity} sourceEntity source entity
|
|
190
|
+
* @param {Entity} targetEntity target entity
|
|
191
|
+
* @param {string} xml response in xml string format
|
|
192
|
+
* @return {Promise} a promise to resolve the finalized xml
|
|
193
|
+
*/
|
|
185
194
|
encryptAssertion(sourceEntity: any, targetEntity: any, xml?: string | undefined): Promise<string>;
|
|
186
195
|
/**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
196
|
+
* @desc Decrypt the assertion section in Response
|
|
197
|
+
* @param {string} type only accept SAMLResponse to proceed decryption
|
|
198
|
+
* @param {Entity} here this entity
|
|
199
|
+
* @param {Entity} from from the entity where the message is sent
|
|
200
|
+
* @param {string} entireXML response in xml string format
|
|
201
|
+
* @return {function} a promise to get back the entire xml with decrypted assertion
|
|
202
|
+
*/
|
|
194
203
|
decryptAssertion(here: any, entireXML: string): Promise<[string, any]>;
|
|
195
204
|
/**
|
|
196
205
|
* @desc Check if the xml string is valid and bounded
|