samlesa 2.17.2 → 2.17.3

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 (44) hide show
  1. package/build/src/binding-post.js +0 -2
  2. package/build/src/metadata-idp.js +26 -24
  3. package/build/src/metadata-sp.js +19 -19
  4. package/build/src/schemaValidator.js +30 -6
  5. package/package.json +77 -78
  6. package/types/api.d.ts +15 -0
  7. package/types/api.d.ts.map +1 -0
  8. package/types/binding-post.d.ts +48 -0
  9. package/types/binding-post.d.ts.map +1 -0
  10. package/types/binding-redirect.d.ts +54 -0
  11. package/types/binding-redirect.d.ts.map +1 -0
  12. package/types/binding-simplesign.d.ts +41 -0
  13. package/types/binding-simplesign.d.ts.map +1 -0
  14. package/types/entity-idp.d.ts +38 -0
  15. package/types/entity-idp.d.ts.map +1 -0
  16. package/types/entity-sp.d.ts +38 -0
  17. package/types/entity-sp.d.ts.map +1 -0
  18. package/types/entity.d.ts +100 -0
  19. package/types/entity.d.ts.map +1 -0
  20. package/types/extractor.d.ts +26 -0
  21. package/types/extractor.d.ts.map +1 -0
  22. package/types/flow.d.ts +7 -0
  23. package/types/flow.d.ts.map +1 -0
  24. package/types/libsaml.d.ts +208 -0
  25. package/types/libsaml.d.ts.map +1 -0
  26. package/types/metadata-idp.d.ts +25 -0
  27. package/types/metadata-idp.d.ts.map +1 -0
  28. package/types/metadata-sp.d.ts +37 -0
  29. package/types/metadata-sp.d.ts.map +1 -0
  30. package/types/metadata.d.ts +58 -0
  31. package/types/metadata.d.ts.map +1 -0
  32. package/types/src/binding-post.d.ts.map +1 -1
  33. package/types/src/metadata-idp.d.ts.map +1 -1
  34. package/types/src/metadata-sp.d.ts.map +1 -1
  35. package/types/src/schemaValidator.d.ts +1 -1
  36. package/types/src/schemaValidator.d.ts.map +1 -1
  37. package/types/types.d.ts +128 -0
  38. package/types/types.d.ts.map +1 -0
  39. package/types/urn.d.ts +195 -0
  40. package/types/urn.d.ts.map +1 -0
  41. package/types/utility.d.ts +133 -0
  42. package/types/utility.d.ts.map +1 -0
  43. package/types/validator.d.ts +4 -0
  44. package/types/validator.d.ts.map +1 -0
@@ -130,8 +130,6 @@ async function base64LoginResponse(requestInfo = {}, entity, user = {}, customTa
130
130
  tvalue.InResponseTo = requestInfo?.extract?.request?.id ?? '';
131
131
  }
132
132
  rawSamlResponse = libsaml.replaceTagsByValue(libsaml.defaultLoginResponseTemplate.context, tvalue);
133
- console.log(rawSamlResponse);
134
- console.log("没有加密签名过的------------------------------------");
135
133
  }
136
134
  const { privateKey, privateKeyPass, requestSignatureAlgorithm: signatureAlgorithm } = idpSetting;
137
135
  const config = {
@@ -31,23 +31,21 @@ export class IdpMetadata extends Metadata {
31
31
  for (const cert of castArrayOpt(encryptCert)) {
32
32
  IDPSSODescriptor.push(libsaml.createKeySection('encryption', cert));
33
33
  }
34
- if (isNonEmptyArray(nameIDFormat)) {
35
- nameIDFormat.forEach(f => IDPSSODescriptor.push({ NameIDFormat: f }));
36
- }
37
- if (isNonEmptyArray(singleSignOnService)) {
38
- singleSignOnService.forEach((a, indexCount) => {
39
- const attr = {
40
- Binding: a.Binding,
41
- Location: a.Location,
42
- };
43
- /* if (a.isDefault) {
44
- attr.isDefault = true;
45
- }*/
46
- IDPSSODescriptor.push({ SingleSignOnService: [{ _attr: attr }] });
34
+ if (isNonEmptyArray(artifactResolutionService)) {
35
+ let indexCounts = 0;
36
+ artifactResolutionService.forEach((a, indexCount) => {
37
+ const attr = {};
38
+ /* if (a.isDefault) {
39
+ attr.isDefault = true;
40
+ }*/
41
+ attr.index = String(indexCounts++),
42
+ attr.Binding = a.Binding;
43
+ attr.Location = a.Location;
44
+ IDPSSODescriptor.push({ ArtifactResolutionService: [{ _attr: attr }] });
47
45
  });
48
46
  }
49
47
  else {
50
- throw new Error('ERR_IDP_METADATA_MISSING_SINGLE_SIGN_ON_SERVICE');
48
+ console.warn('Construct identity provider - missing endpoint of ArtifactResolutionService');
51
49
  }
52
50
  if (isNonEmptyArray(singleLogoutService)) {
53
51
  singleLogoutService.forEach((a, indexCount) => {
@@ -63,19 +61,23 @@ export class IdpMetadata extends Metadata {
63
61
  else {
64
62
  console.warn('Construct identity provider - missing endpoint of SingleLogoutService');
65
63
  }
66
- if (isNonEmptyArray(artifactResolutionService)) {
67
- artifactResolutionService.forEach((a, indexCount) => {
68
- const attr = {};
69
- /* if (a.isDefault) {
70
- attr.isDefault = true;
71
- }*/
72
- attr.Binding = a.Binding;
73
- attr.Location = a.Location;
74
- IDPSSODescriptor.push({ ArtifactResolutionService: [{ _attr: attr }] });
64
+ if (isNonEmptyArray(nameIDFormat)) {
65
+ nameIDFormat.forEach(f => IDPSSODescriptor.push({ NameIDFormat: f }));
66
+ }
67
+ if (isNonEmptyArray(singleSignOnService)) {
68
+ singleSignOnService.forEach((a, indexCount) => {
69
+ const attr = {
70
+ Binding: a.Binding,
71
+ Location: a.Location,
72
+ };
73
+ /* if (a.isDefault) {
74
+ attr.isDefault = true;
75
+ }*/
76
+ IDPSSODescriptor.push({ SingleSignOnService: [{ _attr: attr }] });
75
77
  });
76
78
  }
77
79
  else {
78
- console.warn('Construct identity provider - missing endpoint of ArtifactResolutionService');
80
+ throw new Error('ERR_IDP_METADATA_MISSING_SINGLE_SIGN_ON_SERVICE');
79
81
  }
80
82
  // Create a new metadata by setting
81
83
  meta = xml([{
@@ -51,12 +51,19 @@ export class SpMetadata extends Metadata {
51
51
  for (const cert of castArrayOpt(encryptCert)) {
52
52
  descriptors.KeyDescriptor.push(libsaml.createKeySection('encryption', cert).KeyDescriptor);
53
53
  }
54
- if (isNonEmptyArray(nameIDFormat)) {
55
- nameIDFormat.forEach(f => descriptors.NameIDFormat.push(f));
56
- }
57
- else {
58
- // default value
59
- descriptors.NameIDFormat.push(namespace.format.emailAddress);
54
+ if (isNonEmptyArray(artifactResolutionService)) {
55
+ let indexCount = 0;
56
+ artifactResolutionService.forEach(a => {
57
+ const attr = {
58
+ index: String(indexCount++),
59
+ Binding: a.Binding,
60
+ Location: a.Location,
61
+ };
62
+ if (a.isDefault) {
63
+ attr.isDefault = true;
64
+ }
65
+ descriptors.ArtifactResolutionService.push([{ _attr: attr }]);
66
+ });
60
67
  }
61
68
  if (isNonEmptyArray(singleLogoutService)) {
62
69
  singleLogoutService.forEach(a => {
@@ -70,19 +77,12 @@ export class SpMetadata extends Metadata {
70
77
  descriptors.SingleLogoutService.push([{ _attr: attr }]);
71
78
  });
72
79
  }
73
- if (isNonEmptyArray(artifactResolutionService)) {
74
- let indexCount = 0;
75
- artifactResolutionService.forEach(a => {
76
- const attr = {
77
- index: String(indexCount++),
78
- Binding: a.Binding,
79
- Location: a.Location,
80
- };
81
- /* if (a.isDefault) {
82
- attr.isDefault = true;
83
- }*/
84
- descriptors.ArtifactResolutionService.push([{ _attr: attr }]);
85
- });
80
+ if (isNonEmptyArray(nameIDFormat)) {
81
+ nameIDFormat.forEach(f => descriptors.NameIDFormat.push(f));
82
+ }
83
+ else {
84
+ // default value
85
+ descriptors.NameIDFormat.push(namespace.format.emailAddress);
86
86
  }
87
87
  if (isNonEmptyArray(assertionConsumerService)) {
88
88
  let indexCount = 0;
@@ -2,6 +2,7 @@ import { validateXML } from 'xmllint-wasm';
2
2
  import * as fs from 'node:fs';
3
3
  import * as path from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
+ import { DOMParser } from '@xmldom/xmldom';
5
6
  const __filename = fileURLToPath(import.meta.url);
6
7
  const __dirname = path.dirname(__filename);
7
8
  let normal = [
@@ -89,12 +90,10 @@ export const validate = async (xml, isSoap = false) => {
89
90
  throw validationResult.errors;
90
91
  }
91
92
  catch (error) {
92
- console.log(error);
93
- console.log("真的错误了=================");
94
93
  throw new Error('ERR_EXCEPTION_VALIDATE_XML');
95
94
  }
96
95
  };
97
- export const validateMetadata = async (xml, isSoap = false) => {
96
+ export const validateMetadata = async (xml, isParse = false) => {
98
97
  const indicators = detectXXEIndicators(xml);
99
98
  if (indicators) {
100
99
  throw new Error('ERR_EXCEPTION_VALIDATE_XML');
@@ -118,13 +117,38 @@ export const validateMetadata = async (xml, isSoap = false) => {
118
117
  preload: [xmlParse, ...preload],
119
118
  });
120
119
  if (validationResult.valid) {
120
+ if (isParse) {
121
+ // 解析 XML 为 DOM 对象
122
+ const parser = new DOMParser();
123
+ const xmlDoc = parser.parseFromString(xml, 'text/xml');
124
+ // 检查 IdP 和 SP 描述符元素
125
+ const idpDescriptor = xmlDoc.getElementsByTagNameNS('urn:oasis:names:tc:SAML:2.0:metadata', 'IDPSSODescriptor');
126
+ const spDescriptor = xmlDoc.getElementsByTagNameNS('urn:oasis:names:tc:SAML:2.0:metadata', 'SPSSODescriptor');
127
+ // 判断元数据类型
128
+ let metadataType;
129
+ if (idpDescriptor.length > 0 && spDescriptor.length > 0) {
130
+ metadataType = 'both'; // 同时包含 IdP 和 SP
131
+ }
132
+ else if (idpDescriptor.length > 0) {
133
+ metadataType = 'IdP'; // 身份提供者
134
+ }
135
+ else if (spDescriptor.length > 0) {
136
+ metadataType = 'SP'; // 服务提供者
137
+ }
138
+ else {
139
+ metadataType = 'unknown'; // 无法确定
140
+ }
141
+ // 返回验证结果和元数据类型
142
+ return {
143
+ isValid: true,
144
+ metadataType: metadataType
145
+ };
146
+ }
121
147
  return true;
122
148
  }
123
149
  throw validationResult.errors;
124
150
  }
125
151
  catch (error) {
126
- console.log(error);
127
- console.log("真的错误了=================");
128
- throw new Error('ERR_EXCEPTION_VALIDATE_XML');
152
+ return error;
129
153
  }
130
154
  };
package/package.json CHANGED
@@ -1,78 +1,77 @@
1
- {
2
- "name": "samlesa",
3
- "version": "2.17.2",
4
-
5
- "description": "High-level API for Single Sign On (SAML 2.0) baseed on samlify ",
6
- "main": "build/index.js",
7
- "keywords": [
8
- "nodejs",
9
- "saml2",
10
- "sso",
11
- "slo",
12
- "metadata"
13
- ],
14
- "type": "module",
15
- "typings": "types/index.d.ts",
16
- "scripts": {
17
- "build": "tsc && copyfiles -u 1 src/schema/**/* build/src",
18
- "docs": "docsify serve -o docs",
19
- "lint": "tslint -p .",
20
- "lint:fix": "tslint -p . --fix",
21
- "test": "vitest",
22
- "test:watch": "vitest --watch",
23
- "test:coverage": "vitest run --coverage",
24
- "hooks:postinstall": "mklink /J .git\\hooks\\pre-commit .pre-commit.sh || copy .pre-commit.sh .git\\hooks\\pre-commit"
25
- },
26
- "exports": {
27
- ".": {
28
- "types": "./types/index.d.ts",
29
- "import": "./build/index.js"
30
- }
31
- },
32
- "files": [
33
- "build",
34
- "types"
35
- ],
36
- "contributors": [
37
- "Veclea <vemocle@gmail.com>"
38
- ],
39
- "author": "Veclea",
40
- "repository": {
41
- "url": "https://github.com/Veclea/samlify.git",
42
- "type": "git"
43
- },
44
- "license": "MIT",
45
- "dependencies": {
46
- "@xmldom/xmldom": "^0.9.8",
47
- "axios": "^1.10.0",
48
- "camelcase": "^8.0.0",
49
- "cross-env": "^7.0.3",
50
- "iconv-lite": "^0.6.3",
51
- "node-rsa": "^1.1.1",
52
- "pako": "^2.1.0",
53
- "ts-node": "^10.9.2",
54
- "uuid": "^11.1.0",
55
- "vite-tsconfig-paths": "^5.1.4",
56
- "xml": "^1.0.1",
57
- "xml-crypto": "^6.1.2",
58
- "xml-encryption": "^3.1.0",
59
- "xml-escape": "^1.1.0",
60
- "xml2js": "^0.6.2",
61
- "xmllint-wasm": "^5.0.0",
62
- "xpath": "^0.0.32"
63
- },
64
- "devDependencies": {
65
- "@types/node": "^24.0.13",
66
- "@types/pako": "2.0.3",
67
- "@types/uuid": "10.0.0",
68
- "@vitest/coverage-istanbul": "^3.2.4",
69
- "@vitest/coverage-v8": "3.2.4",
70
- "copyfiles": "^2.4.1",
71
- "coveralls": "^3.1.1",
72
- "esbuild": "^0.25.6",
73
- "jsdom": "^26.1.0",
74
- "timekeeper": "^2.3.1",
75
- "typescript": "5.8.3",
76
- "vitest": "^3.2.4"
77
- }
78
- }
1
+ {
2
+ "name": "samlesa",
3
+ "version": "2.17.3",
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"}