samlesa 2.17.0 → 2.17.1
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/index.js +2 -1
- package/build/src/binding-artifact.js +330 -146
- package/build/src/entity-sp.js +21 -94
- package/build/src/extractor.js +32 -0
- package/build/src/flow.js +23 -112
- package/build/src/libsaml.js +325 -127
- package/build/src/libsamlSoap.js +115 -0
- package/build/src/schemaValidator.js +1 -5
- package/build/src/soap.js +123 -3
- package/package.json +77 -75
- package/types/api.d.ts +15 -0
- package/types/api.d.ts.map +1 -0
- package/types/binding-post.d.ts +48 -0
- package/types/binding-post.d.ts.map +1 -0
- package/types/binding-redirect.d.ts +54 -0
- package/types/binding-redirect.d.ts.map +1 -0
- package/types/binding-simplesign.d.ts +41 -0
- package/types/binding-simplesign.d.ts.map +1 -0
- package/types/entity-idp.d.ts +38 -0
- package/types/entity-idp.d.ts.map +1 -0
- package/types/entity-sp.d.ts +38 -0
- package/types/entity-sp.d.ts.map +1 -0
- package/types/entity.d.ts +100 -0
- package/types/entity.d.ts.map +1 -0
- package/types/extractor.d.ts +26 -0
- package/types/extractor.d.ts.map +1 -0
- package/types/flow.d.ts +7 -0
- package/types/flow.d.ts.map +1 -0
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/libsaml.d.ts +208 -0
- package/types/libsaml.d.ts.map +1 -0
- package/types/metadata-idp.d.ts +25 -0
- package/types/metadata-idp.d.ts.map +1 -0
- package/types/metadata-sp.d.ts +37 -0
- package/types/metadata-sp.d.ts.map +1 -0
- package/types/metadata.d.ts +58 -0
- package/types/metadata.d.ts.map +1 -0
- package/types/src/binding-artifact.d.ts +24 -29
- package/types/src/binding-artifact.d.ts.map +1 -1
- package/types/src/binding-post.d.ts.map +1 -1
- package/types/src/entity-sp.d.ts +13 -24
- package/types/src/entity-sp.d.ts.map +1 -1
- package/types/src/extractor.d.ts +22 -0
- package/types/src/extractor.d.ts.map +1 -1
- package/types/src/flow.d.ts +1 -0
- package/types/src/flow.d.ts.map +1 -1
- package/types/src/libsaml.d.ts +4 -3
- package/types/src/libsaml.d.ts.map +1 -1
- package/types/src/libsamlSoap.d.ts +7 -0
- package/types/src/libsamlSoap.d.ts.map +1 -0
- package/types/src/schemaValidator.d.ts.map +1 -1
- package/types/src/soap.d.ts +33 -0
- package/types/src/soap.d.ts.map +1 -1
- package/types/src/validator.d.ts.map +1 -1
- package/types/types.d.ts +128 -0
- package/types/types.d.ts.map +1 -0
- package/types/urn.d.ts +195 -0
- package/types/urn.d.ts.map +1 -0
- package/types/utility.d.ts +133 -0
- package/types/utility.d.ts.map +1 -0
- package/types/validator.d.ts +4 -0
- package/types/validator.d.ts.map +1 -0
- package/build/src/schema/XMLSchema.dtd +0 -402
- package/build/src/schema/datatypes.dtd +0 -203
|
@@ -56,10 +56,9 @@ function detectXXEIndicators(samlString) {
|
|
|
56
56
|
export const validate = async (xml, isSoap = false) => {
|
|
57
57
|
const indicators = detectXXEIndicators(xml);
|
|
58
58
|
if (indicators) {
|
|
59
|
-
console.log("----------------------绝对不会是这里---------------------");
|
|
60
59
|
throw new Error('ERR_EXCEPTION_VALIDATE_XML');
|
|
61
60
|
}
|
|
62
|
-
schemas = normal;
|
|
61
|
+
schemas = isSoap ? soapSchema : normal;
|
|
63
62
|
const schemaPath = path.resolve(__dirname, 'schema');
|
|
64
63
|
const [xmlParse, ...preload] = await Promise.all(schemas.map(async (file) => ({
|
|
65
64
|
fileName: file,
|
|
@@ -78,14 +77,11 @@ export const validate = async (xml, isSoap = false) => {
|
|
|
78
77
|
preload: [xmlParse, ...preload],
|
|
79
78
|
});
|
|
80
79
|
if (validationResult.valid) {
|
|
81
|
-
console.log("验证通过-------------------------");
|
|
82
80
|
return true;
|
|
83
81
|
}
|
|
84
82
|
throw validationResult.errors;
|
|
85
83
|
}
|
|
86
84
|
catch (error) {
|
|
87
|
-
console.log(error);
|
|
88
|
-
console.log("----------------------绝333333333333333333333333对不会是这里---------------------");
|
|
89
85
|
throw new Error('ERR_EXCEPTION_VALIDATE_XML');
|
|
90
86
|
}
|
|
91
87
|
};
|
package/build/src/soap.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import https from 'node:https';
|
|
3
|
+
import crypto from "node:crypto";
|
|
4
|
+
import { Builder } from 'xml2js';
|
|
5
|
+
import iconv from 'iconv-lite';
|
|
3
6
|
// 2. 配置 Axios 实例(处理自签名证书)
|
|
4
7
|
const axiosInstance = axios.create({
|
|
5
8
|
httpsAgent: new https.Agent({
|
|
@@ -10,16 +13,133 @@ export async function sendArtifactResolve(url, soapRequest) {
|
|
|
10
13
|
try {
|
|
11
14
|
const response = await axiosInstance.post(url, soapRequest, {
|
|
12
15
|
headers: {
|
|
13
|
-
'Content-Type': '
|
|
16
|
+
'Content-Type': 'text/xml',
|
|
14
17
|
'SOAPAction': '"ArtifactResolve"'
|
|
15
18
|
},
|
|
16
19
|
timeout: 5000 // 5秒超时
|
|
17
20
|
});
|
|
18
|
-
console.log('✅ Resolve请求成功');
|
|
19
21
|
return response.data;
|
|
20
22
|
}
|
|
21
23
|
catch (error) {
|
|
22
|
-
console.error('❌ Resolve请求失败');
|
|
23
24
|
throw error.response.data;
|
|
24
25
|
}
|
|
25
26
|
}
|
|
27
|
+
export async function sendArtifactResponse(url, soapRequest) {
|
|
28
|
+
try {
|
|
29
|
+
const response = await axiosInstance.post(url, soapRequest, {
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'text/xml',
|
|
32
|
+
'SOAPAction': '"ArtifactResponse"'
|
|
33
|
+
},
|
|
34
|
+
timeout: 5000 // 5秒超时
|
|
35
|
+
});
|
|
36
|
+
return response.data;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw error.response.data;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @desc generate Art id
|
|
44
|
+
*
|
|
45
|
+
* @param entityIDString
|
|
46
|
+
* @param endpointIndex
|
|
47
|
+
*/
|
|
48
|
+
export function createArt(entityIDString, endpointIndex = 0) {
|
|
49
|
+
// 安全获取 sourceEntityId
|
|
50
|
+
let sourceEntityId;
|
|
51
|
+
if (typeof entityIDString === "string") {
|
|
52
|
+
sourceEntityId = entityIDString;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// 确保只在非字符串类型上访问 entityMeta
|
|
56
|
+
sourceEntityId = entityIDString.entityMeta.getEntityID();
|
|
57
|
+
}
|
|
58
|
+
// 1. 固定类型代码 (0x0004 - 2字节)
|
|
59
|
+
const typeCode = Buffer.from([0x00, 0x04]);
|
|
60
|
+
// 2. 端点索引 (2字节,大端序)
|
|
61
|
+
if (endpointIndex < 0 || endpointIndex > 65535) {
|
|
62
|
+
throw new Error("Endpoint index must be between 0 and 65535");
|
|
63
|
+
}
|
|
64
|
+
const endpointBuf = Buffer.alloc(2);
|
|
65
|
+
endpointBuf.writeUInt16BE(endpointIndex);
|
|
66
|
+
// 3. Source ID - 实体ID的SHA-1哈希 (20字节)
|
|
67
|
+
const sourceId = crypto
|
|
68
|
+
.createHash("sha1")
|
|
69
|
+
.update(sourceEntityId)
|
|
70
|
+
.digest();
|
|
71
|
+
// 4. Message Handler - 20字节随机值
|
|
72
|
+
const messageHandler = crypto.randomBytes(20);
|
|
73
|
+
// 组合所有组件 (2+2+20+20 = 44字节)
|
|
74
|
+
const artifact = Buffer.concat([
|
|
75
|
+
typeCode,
|
|
76
|
+
endpointBuf,
|
|
77
|
+
sourceId,
|
|
78
|
+
messageHandler,
|
|
79
|
+
]);
|
|
80
|
+
// 返回Base64编码的Artifact
|
|
81
|
+
return {
|
|
82
|
+
artifact: artifact.toString("base64"),
|
|
83
|
+
origin: {
|
|
84
|
+
typeCode: typeCode.readUInt16BE(0), // 改为整数值
|
|
85
|
+
endpointIndex: endpointIndex, // 修复字段名并赋正确的值
|
|
86
|
+
sourceId: sourceId.toString("hex"), // 转为十六进制
|
|
87
|
+
messageHandle: messageHandler.toString("hex"), // 转为十六进制
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @desc generate Art id
|
|
93
|
+
* @param artifact
|
|
94
|
+
*/
|
|
95
|
+
export function parseArt(artifact) {
|
|
96
|
+
// 解码 Base64
|
|
97
|
+
console.log(Object.prototype.toString.call(artifact));
|
|
98
|
+
if (Object.prototype.toString.call(artifact) !== '[object String]') {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const decoded = Buffer.from(artifact, 'base64');
|
|
102
|
+
// 确保长度正确(SAML 工件固定为 44 字节)
|
|
103
|
+
if (decoded.length !== 44) {
|
|
104
|
+
throw new Error(`Invalid artifact length: ${decoded.length}, expected 44 bytes`);
|
|
105
|
+
}
|
|
106
|
+
// 读取前 4 字节(TypeCode + EndpointIndex)
|
|
107
|
+
const typeCode = decoded.readUInt16BE(0);
|
|
108
|
+
const endpointIndex = decoded.readUInt16BE(2);
|
|
109
|
+
// 使用 Buffer.from() 替代 slice()
|
|
110
|
+
const sourceId = Buffer.from(decoded.buffer, // 底层 ArrayBuffer
|
|
111
|
+
decoded.byteOffset + 4, // 起始偏移量
|
|
112
|
+
20 // 长度
|
|
113
|
+
).toString('hex');
|
|
114
|
+
const messageHandle = Buffer.from(decoded.buffer, // 底层 ArrayBuffer
|
|
115
|
+
decoded.byteOffset + 24, // 起始偏移量
|
|
116
|
+
20 // 长度
|
|
117
|
+
).toString('hex');
|
|
118
|
+
return { typeCode, endpointIndex, sourceId, messageHandle };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* 将对象转换为 ISO-8859-1 编码的 XML 字符串
|
|
122
|
+
* @param {Object} data - 要转换的数据对象
|
|
123
|
+
* @returns {Buffer} - ISO-8859-1 编码的 XML 数据 (Buffer)
|
|
124
|
+
*/
|
|
125
|
+
export function encodeXmlToIso88591(data) {
|
|
126
|
+
try {
|
|
127
|
+
// 1. 创建 XML 构建器
|
|
128
|
+
const builder = new Builder({
|
|
129
|
+
headless: false, // 包含 XML 声明
|
|
130
|
+
renderOpts: { 'pretty': false }, // 紧凑格式
|
|
131
|
+
xmldec: {
|
|
132
|
+
version: '1.0',
|
|
133
|
+
encoding: 'ISO-8859-1',
|
|
134
|
+
standalone: true
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
// 2. 构建 XML 字符串 (UTF-8 格式)
|
|
138
|
+
const utf8Xml = builder.buildObject(data);
|
|
139
|
+
// 3. 转换为 ISO-8859-1 编码的 Buffer
|
|
140
|
+
return iconv.encode(utf8Xml, 'iso-8859-1');
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
throw new Error(`XML 编码失败: ${error.message}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
package/package.json
CHANGED
|
@@ -1,75 +1,77 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "samlesa",
|
|
3
|
-
"version": "2.17.
|
|
4
|
-
"description": "High-level API for Single Sign On (SAML 2.0) baseed on samlify ",
|
|
5
|
-
"main": "build/index.js",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"nodejs",
|
|
8
|
-
"saml2",
|
|
9
|
-
"sso",
|
|
10
|
-
"slo",
|
|
11
|
-
"metadata"
|
|
12
|
-
],
|
|
13
|
-
"type": "module",
|
|
14
|
-
"typings": "types/index.d.ts",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "tsc && copyfiles -u 1 src/schema/**/* build/src",
|
|
17
|
-
"docs": "docsify serve -o docs",
|
|
18
|
-
"lint": "tslint -p .",
|
|
19
|
-
"lint:fix": "tslint -p . --fix",
|
|
20
|
-
"test": "vitest",
|
|
21
|
-
"test:watch": "vitest",
|
|
22
|
-
"test:coverage": "vitest run --coverage",
|
|
23
|
-
"hooks:postinstall": "mklink /J .git\\hooks\\pre-commit .pre-commit.sh || copy .pre-commit.sh .git\\hooks\\pre-commit"
|
|
24
|
-
},
|
|
25
|
-
"exports": {
|
|
26
|
-
".": {
|
|
27
|
-
"types": "./types/index.d.ts",
|
|
28
|
-
"import": "./build/index.js"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"files": [
|
|
32
|
-
"build",
|
|
33
|
-
"types"
|
|
34
|
-
],
|
|
35
|
-
"contributors": [
|
|
36
|
-
"Veclea <vemocle@gmail.com>"
|
|
37
|
-
],
|
|
38
|
-
"author": "Veclea",
|
|
39
|
-
"repository": {
|
|
40
|
-
"url": "https://github.com/Veclea/samlify.git",
|
|
41
|
-
"type": "git"
|
|
42
|
-
},
|
|
43
|
-
"license": "MIT",
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"@xmldom/xmldom": "^0.9.8",
|
|
46
|
-
"axios": "^1.10.0",
|
|
47
|
-
"camelcase": "^8.0.0",
|
|
48
|
-
"cross-env": "^7.0.3",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"xml
|
|
56
|
-
"xml-
|
|
57
|
-
"xml-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"@types/
|
|
65
|
-
"@types/
|
|
66
|
-
"@
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "samlesa",
|
|
3
|
+
"version": "2.17.1",
|
|
4
|
+
"description": "High-level API for Single Sign On (SAML 2.0) baseed on samlify ",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"nodejs",
|
|
8
|
+
"saml2",
|
|
9
|
+
"sso",
|
|
10
|
+
"slo",
|
|
11
|
+
"metadata"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"typings": "types/index.d.ts",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc && copyfiles -u 1 src/schema/**/* build/src",
|
|
17
|
+
"docs": "docsify serve -o docs",
|
|
18
|
+
"lint": "tslint -p .",
|
|
19
|
+
"lint:fix": "tslint -p . --fix",
|
|
20
|
+
"test": "vitest",
|
|
21
|
+
"test:watch": "vitest --watch",
|
|
22
|
+
"test:coverage": "vitest run --coverage",
|
|
23
|
+
"hooks:postinstall": "mklink /J .git\\hooks\\pre-commit .pre-commit.sh || copy .pre-commit.sh .git\\hooks\\pre-commit"
|
|
24
|
+
},
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./types/index.d.ts",
|
|
28
|
+
"import": "./build/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"build",
|
|
33
|
+
"types"
|
|
34
|
+
],
|
|
35
|
+
"contributors": [
|
|
36
|
+
"Veclea <vemocle@gmail.com>"
|
|
37
|
+
],
|
|
38
|
+
"author": "Veclea",
|
|
39
|
+
"repository": {
|
|
40
|
+
"url": "https://github.com/Veclea/samlify.git",
|
|
41
|
+
"type": "git"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@xmldom/xmldom": "^0.9.8",
|
|
46
|
+
"axios": "^1.10.0",
|
|
47
|
+
"camelcase": "^8.0.0",
|
|
48
|
+
"cross-env": "^7.0.3",
|
|
49
|
+
"iconv-lite": "^0.6.3",
|
|
50
|
+
"node-rsa": "^1.1.1",
|
|
51
|
+
"pako": "^2.1.0",
|
|
52
|
+
"ts-node": "^10.9.2",
|
|
53
|
+
"uuid": "^11.1.0",
|
|
54
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
55
|
+
"xml": "^1.0.1",
|
|
56
|
+
"xml-crypto": "^6.1.2",
|
|
57
|
+
"xml-encryption": "^3.1.0",
|
|
58
|
+
"xml-escape": "^1.1.0",
|
|
59
|
+
"xml2js": "^0.6.2",
|
|
60
|
+
"xmllint-wasm": "^5.0.0",
|
|
61
|
+
"xpath": "^0.0.32"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^24.0.13",
|
|
65
|
+
"@types/pako": "2.0.3",
|
|
66
|
+
"@types/uuid": "10.0.0",
|
|
67
|
+
"@vitest/coverage-istanbul": "^3.2.4",
|
|
68
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
69
|
+
"copyfiles": "^2.4.1",
|
|
70
|
+
"coveralls": "^3.1.1",
|
|
71
|
+
"esbuild": "^0.25.6",
|
|
72
|
+
"jsdom": "^26.1.0",
|
|
73
|
+
"timekeeper": "^2.3.1",
|
|
74
|
+
"typescript": "5.8.3",
|
|
75
|
+
"vitest": "^3.2.4"
|
|
76
|
+
}
|
|
77
|
+
}
|
package/types/api.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DOMParser as dom } from '@xmldom/xmldom';
|
|
2
|
+
import type { Options as DOMParserOptions } from '@xmldom/xmldom';
|
|
3
|
+
interface Context extends ValidatorContext, DOMParserContext {
|
|
4
|
+
}
|
|
5
|
+
interface ValidatorContext {
|
|
6
|
+
validate?: (xml: string) => Promise<any>;
|
|
7
|
+
}
|
|
8
|
+
interface DOMParserContext {
|
|
9
|
+
dom: dom;
|
|
10
|
+
}
|
|
11
|
+
export declare function getContext(): Context;
|
|
12
|
+
export declare function setSchemaValidator(params: ValidatorContext): void;
|
|
13
|
+
export declare function setDOMParserOptions(options?: DOMParserOptions): void;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElE,UAAU,OAAQ,SAAQ,gBAAgB,EAAE,gBAAgB;CAAG;AAE/D,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC1C;AAED,UAAU,gBAAgB;IACxB,GAAG,EAAE,GAAG,CAAC;CACV;AAOD,wBAAgB,UAAU,IAAG,OAAO,CAEnC;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,GAAE,IAAI,CAShE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,gBAAqB,GAAE,IAAI,CAEvE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file binding-post.ts
|
|
3
|
+
* @author tngan
|
|
4
|
+
* @desc Binding-level API, declare the functions using POST binding
|
|
5
|
+
*/
|
|
6
|
+
import type { BindingContext } from './entity.js';
|
|
7
|
+
/**
|
|
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;
|
|
14
|
+
/**
|
|
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
|
+
* @param AttributeStatement
|
|
22
|
+
*/
|
|
23
|
+
declare function base64LoginResponse(requestInfo: any | undefined, entity: any, user?: any, customTagReplacement?: (template: string) => BindingContext, encryptThenSign?: boolean, AttributeStatement?: never[]): Promise<BindingContext>;
|
|
24
|
+
/**
|
|
25
|
+
* @desc Generate a base64 encoded logout request
|
|
26
|
+
* @param {object} user current logged user (e.g. req.user)
|
|
27
|
+
* @param {string} referenceTagXPath reference uri
|
|
28
|
+
* @param {object} entity object includes both idp and sp
|
|
29
|
+
* @param {function} customTagReplacement used when developers have their own login response template
|
|
30
|
+
* @return {string} base64 encoded request
|
|
31
|
+
*/
|
|
32
|
+
declare function base64LogoutRequest(user: Record<string, unknown>, referenceTagXPath: string, entity: any, customTagReplacement?: (template: string) => BindingContext): BindingContext;
|
|
33
|
+
/**
|
|
34
|
+
* @desc Generate a base64 encoded logout response
|
|
35
|
+
* @param {object} requestInfo corresponding request, used to obtain the id
|
|
36
|
+
* @param {string} referenceTagXPath reference uri
|
|
37
|
+
* @param {object} entity object includes both idp and sp
|
|
38
|
+
* @param {function} customTagReplacement used when developers have their own login response template
|
|
39
|
+
*/
|
|
40
|
+
declare function base64LogoutResponse(requestInfo: any, entity: any, customTagReplacement: (template: string) => BindingContext): BindingContext;
|
|
41
|
+
declare const postBinding: {
|
|
42
|
+
base64LoginRequest: typeof base64LoginRequest;
|
|
43
|
+
base64LoginResponse: typeof base64LoginResponse;
|
|
44
|
+
base64LogoutRequest: typeof base64LogoutRequest;
|
|
45
|
+
base64LogoutResponse: typeof base64LogoutResponse;
|
|
46
|
+
};
|
|
47
|
+
export default postBinding;
|
|
48
|
+
//# sourceMappingURL=binding-post.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding-post.d.ts","sourceRoot":"","sources":["../src/binding-post.ts"],"names":[],"mappings":"AAAA;;;;EAIE;AAGF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD;;;;;EAKE;AACF,iBAAS,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,GAAG,cAAc,CAqD/I;AACD;;;;;;;;GAQG;AACH,iBAAe,mBAAmB,CAAC,WAAW,EAAE,GAAG,YAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,GAAE,GAAQ,EAAE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,EAAE,eAAe,GAAE,OAAe,EAAG,kBAAkB,UAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAuIrO;AACD;;;;;;;EAOE;AACF,iBAAS,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,EAAC,MAAM,EAAE,MAAM,KAAA,EAAE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,GAAG,cAAc,CAkDzK;AACD;;;;;;EAME;AACF,iBAAS,oBAAoB,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,GAAG,cAAc,CAsDvI;AAED,QAAA,MAAM,WAAW;;;;;CAKhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { BindingContext } from './entity.js';
|
|
2
|
+
import { IdentityProvider as Idp } from './entity-idp.js';
|
|
3
|
+
import { ServiceProvider as Sp } from './entity-sp.js';
|
|
4
|
+
export interface BuildRedirectConfig {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
type: string;
|
|
7
|
+
isSigned: boolean;
|
|
8
|
+
context: string;
|
|
9
|
+
entitySetting: any;
|
|
10
|
+
relayState?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
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
|
+
*/
|
|
18
|
+
declare function loginRequestRedirectURL(entity: {
|
|
19
|
+
idp: Idp;
|
|
20
|
+
sp: Sp;
|
|
21
|
+
}, customTagReplacement?: (template: string) => BindingContext): BindingContext;
|
|
22
|
+
/**
|
|
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
|
+
* @param AttributeStatement
|
|
30
|
+
*/
|
|
31
|
+
declare function loginResponseRedirectURL(requestInfo: any, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext, AttributeStatement?: never[]): BindingContext;
|
|
32
|
+
/**
|
|
33
|
+
* @desc Redirect URL for logout request
|
|
34
|
+
* @param {object} user current logged user (e.g. req.user)
|
|
35
|
+
* @param {object} entity object includes both idp and sp
|
|
36
|
+
* @param {function} customTagReplacement used when developers have their own login response template
|
|
37
|
+
* @return {string} redirect URL
|
|
38
|
+
*/
|
|
39
|
+
declare function logoutRequestRedirectURL(user: any, entity: any, relayState?: string, customTagReplacement?: (template: string, tags: object) => BindingContext): BindingContext;
|
|
40
|
+
/**
|
|
41
|
+
* @desc Redirect URL for logout response
|
|
42
|
+
* @param {object} requescorresponding request, used to obtain the id
|
|
43
|
+
* @param {object} entity object includes both idp and sp
|
|
44
|
+
* @param {function} customTagReplacement used when developers have their own login response template
|
|
45
|
+
*/
|
|
46
|
+
declare function logoutResponseRedirectURL(requestInfo: any, entity: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext): BindingContext;
|
|
47
|
+
declare const redirectBinding: {
|
|
48
|
+
loginRequestRedirectURL: typeof loginRequestRedirectURL;
|
|
49
|
+
loginResponseRedirectURL: typeof loginResponseRedirectURL;
|
|
50
|
+
logoutRequestRedirectURL: typeof logoutRequestRedirectURL;
|
|
51
|
+
logoutResponseRedirectURL: typeof logoutResponseRedirectURL;
|
|
52
|
+
};
|
|
53
|
+
export default redirectBinding;
|
|
54
|
+
//# sourceMappingURL=binding-redirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding-redirect.d.ts","sourceRoot":"","sources":["../src/binding-redirect.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,gBAAgB,IAAI,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAC,eAAe,IAAI,EAAE,EAAC,MAAM,gBAAgB,CAAC;AAOrD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,GAAG,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAgED;;;;;GAKG;AACH,iBAAS,uBAAuB,CAAC,MAAM,EAAE;IACvC,GAAG,EAAE,GAAG,CAAC;IACT,EAAE,EAAE,EAAE,CAAA;CACP,EAAE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,GAAG,cAAc,CAyC9E;AAED;;;;;;;;GAQG;AACH,iBAAS,wBAAwB,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,GAAE,GAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,EAAC,kBAAkB,UAAI,GAAG,cAAc,CAoGxM;AAED;;;;;;GAMG;AACH,iBAAS,wBAAwB,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,cAAc,GAAG,cAAc,CAwC9J;AAED;;;;;GAKG;AACH,iBAAS,yBAAyB,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,GAAG,cAAc,CAyClK;AAED,QAAA,MAAM,eAAe;;;;;CAKpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file binding-simplesign.ts
|
|
3
|
+
* @author Orange
|
|
4
|
+
* @desc Binding-level API, declare the functions using POST SimpleSign binding
|
|
5
|
+
*/
|
|
6
|
+
import type { BindingContext, SimpleSignComputedContext } from './entity.js';
|
|
7
|
+
export interface BuildSimpleSignConfig {
|
|
8
|
+
type: string;
|
|
9
|
+
context: string;
|
|
10
|
+
entitySetting: any;
|
|
11
|
+
relayState?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface BindingSimpleSignContext {
|
|
14
|
+
id: string;
|
|
15
|
+
context: string;
|
|
16
|
+
signature: any;
|
|
17
|
+
sigAlg: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
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;
|
|
26
|
+
/**
|
|
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
|
+
* @param AttributeStatement
|
|
34
|
+
*/
|
|
35
|
+
declare function base64LoginResponse(requestInfo: any | undefined, entity: any, user?: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext, AttributeStatement?: []): Promise<BindingSimpleSignContext>;
|
|
36
|
+
declare const simpleSignBinding: {
|
|
37
|
+
base64LoginRequest: typeof base64LoginRequest;
|
|
38
|
+
base64LoginResponse: typeof base64LoginResponse;
|
|
39
|
+
};
|
|
40
|
+
export default simpleSignBinding;
|
|
41
|
+
//# sourceMappingURL=binding-simplesign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding-simplesign.d.ts","sourceRoot":"","sources":["../src/binding-simplesign.ts"],"names":[],"mappings":"AAAA;;;;EAIE;AAGF,OAAQ,KAAK,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAO9E,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,GAAG,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AA6CD;;;;;EAKE;AACF,iBAAS,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,GAAG,yBAAyB,CAkD/H;AACD;;;;;;;;GAQG;AACH,iBAAe,mBAAmB,CAAC,WAAW,EAAE,GAAG,YAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,GAAE,GAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,EAAE,kBAAkB,GAAC,EAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA6FtO;AAED,QAAA,MAAM,iBAAiB;;;CAGpB,CAAC;AAEJ,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Entity, { type ESamlHttpRequest } from './entity.js';
|
|
2
|
+
import { ServiceProviderConstructor as ServiceProvider, IdentityProviderMetadata, type IdentityProviderSettings } from './types.js';
|
|
3
|
+
import { type FlowResult } from './flow.js';
|
|
4
|
+
import type { BindingContext } from './entity.js';
|
|
5
|
+
/**
|
|
6
|
+
* Identity provider can be configured using either metadata importing or idpSetting
|
|
7
|
+
*/
|
|
8
|
+
export default function (props: IdentityProviderSettings): IdentityProvider;
|
|
9
|
+
/**
|
|
10
|
+
* Identity provider can be configured using either metadata importing or idpSetting
|
|
11
|
+
*/
|
|
12
|
+
export declare class IdentityProvider extends Entity {
|
|
13
|
+
entityMeta: IdentityProviderMetadata;
|
|
14
|
+
constructor(idpSetting: IdentityProviderSettings);
|
|
15
|
+
/**
|
|
16
|
+
* @desc Generates the login response for developers to design their own method
|
|
17
|
+
* @param params
|
|
18
|
+
*/
|
|
19
|
+
createLoginResponse(params: {
|
|
20
|
+
sp: ServiceProvider;
|
|
21
|
+
requestInfo: Record<string, any>;
|
|
22
|
+
binding?: string;
|
|
23
|
+
user: Record<string, any>;
|
|
24
|
+
customTagReplacement?: (template: string) => BindingContext;
|
|
25
|
+
encryptThenSign?: boolean;
|
|
26
|
+
relayState?: string;
|
|
27
|
+
context: Record<string, any>;
|
|
28
|
+
AttributeStatement: [];
|
|
29
|
+
}): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* Validation of the parsed URL parameters
|
|
32
|
+
* @param sp ServiceProvider instance
|
|
33
|
+
* @param binding Protocol binding
|
|
34
|
+
* @param req RequesmessageSigningOrderst
|
|
35
|
+
*/
|
|
36
|
+
parseLoginRequest(sp: ServiceProvider, binding: string, req: ESamlHttpRequest): Promise<FlowResult>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=entity-idp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-idp.d.ts","sourceRoot":"","sources":["../src/entity-idp.ts"],"names":[],"mappings":"AAYA,OAAO,MAAM,EAAE,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,0BAA0B,IAAI,eAAe,EAE7C,wBAAwB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAO,WAAW,CAAC;AAEnD,OAAO,KAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,OAAO,WAAU,KAAK,EAAE,wBAAwB,oBAEtD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,MAAM;IAElC,UAAU,EAAE,wBAAwB,CAAC;gBAEjC,UAAU,EAAE,wBAAwB;IAqChD;;;OAGG;IACU,mBAAmB,CAAC,MAAM,EAAC;QACtC,EAAE,EAAE,eAAe,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACjC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1B,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,CAAC;QAC5D,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC7B,kBAAkB,EAAC,EAAE,CAAA;KACtB;IAyCD;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB;CAY9E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file entity-sp.ts
|
|
3
|
+
* @author tngan
|
|
4
|
+
* @desc Declares the actions taken by service provider
|
|
5
|
+
*/
|
|
6
|
+
import Entity from './entity.js';
|
|
7
|
+
import type { BindingContext, PostBindingContext, ESamlHttpRequest, SimpleSignBindingContext } from './entity.js';
|
|
8
|
+
import { IdentityProviderConstructor as IdentityProvider, ServiceProviderMetadata, type ServiceProviderSettings } from './types.js';
|
|
9
|
+
import { type FlowResult } from './flow.js';
|
|
10
|
+
export default function (props: ServiceProviderSettings): ServiceProvider;
|
|
11
|
+
/**
|
|
12
|
+
* @desc Service provider can be configured using either metadata importing or spSetting
|
|
13
|
+
* @param {object} spSettingimport { FlowResult } from '../types/src/flow.d';
|
|
14
|
+
|
|
15
|
+
*/
|
|
16
|
+
export declare class ServiceProvider extends Entity {
|
|
17
|
+
entityMeta: ServiceProviderMetadata;
|
|
18
|
+
/**
|
|
19
|
+
* @desc Inherited from Entity
|
|
20
|
+
* @param {object} spSetting setting of service provider
|
|
21
|
+
*/
|
|
22
|
+
constructor(spSetting: ServiceProviderSettings);
|
|
23
|
+
/**
|
|
24
|
+
* @desc Generates the login request for developers to design their own method
|
|
25
|
+
* @param {IdentityProvider} idp object of identity provider
|
|
26
|
+
* @param {string} binding protocol binding
|
|
27
|
+
* @param {function} customTagReplacement used when developers have their own login response template
|
|
28
|
+
*/
|
|
29
|
+
createLoginRequest(idp: IdentityProvider, binding?: string, customTagReplacement?: (template: string) => BindingContext): BindingContext | PostBindingContext | SimpleSignBindingContext;
|
|
30
|
+
/**
|
|
31
|
+
* @desc Validation of the parsed the URL parameters
|
|
32
|
+
* @param {IdentityProvider} idp object of identity provider
|
|
33
|
+
* @param {string} binding protocol binding
|
|
34
|
+
* @param {request} req request
|
|
35
|
+
*/
|
|
36
|
+
parseLoginResponse(idp: any, binding: any, request: ESamlHttpRequest): Promise<FlowResult>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=entity-sp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-sp.d.ts","sourceRoot":"","sources":["../src/entity-sp.ts"],"names":[],"mappings":"AAAA;;;;EAIE;AACF,OAAO,MAEN,MAAM,aAAa,CAAC;AACrB,OAAQ,KAAK,EAAG,cAAc,EAC5B,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EAAE,MAAK,aAAa,CAAC;AAC/C,OAAO,EACL,2BAA2B,IAAI,gBAAgB,EAC/C,uBAAuB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAO,WAAW,CAAC;AAKnD,MAAM,CAAC,OAAO,WAAU,KAAK,EAAE,uBAAuB,mBAErD;AAED;;;;EAIE;AACF,qBAAa,eAAgB,SAAQ,MAAM;IAChC,UAAU,EAAE,uBAAuB,CAAC;IAE7C;;;MAGE;gBACU,SAAS,EAAE,uBAAuB;IAS9C;;;;;MAKE;IACK,kBAAkB,CACvB,GAAG,EAAE,gBAAgB,EACrB,OAAO,SAAa,EACpB,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,GAC1D,cAAc,GAAG,kBAAkB,GAAE,wBAAwB;IAkChE;;;;;MAKE;IACK,kBAAkB,CAAC,GAAG,KAAA,EAAE,OAAO,KAAA,EAAE,OAAO,EAAE,gBAAgB;CAalE"}
|