samlesa 2.12.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.
- package/.editorconfig +19 -0
- package/.github/FUNDING.yml +1 -0
- package/.idea/compiler.xml +6 -0
- package/.idea/deployment.xml +14 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/samlify.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.pre-commit.sh +15 -0
- package/.snyk +8 -0
- package/.travis.yml +29 -0
- package/LICENSE +22 -0
- package/Makefile +25 -0
- package/README.md +84 -0
- package/build/.idea/workspace.xml +58 -0
- package/build/index.js +65 -0
- package/build/index.js.map +1 -0
- package/build/src/api.js +24 -0
- package/build/src/api.js.map +1 -0
- package/build/src/binding-post.js +369 -0
- package/build/src/binding-post.js.map +1 -0
- package/build/src/binding-redirect.js +333 -0
- package/build/src/binding-redirect.js.map +1 -0
- package/build/src/binding-simplesign.js +233 -0
- package/build/src/binding-simplesign.js.map +1 -0
- package/build/src/entity-idp.js +131 -0
- package/build/src/entity-idp.js.map +1 -0
- package/build/src/entity-sp.js +97 -0
- package/build/src/entity-sp.js.map +1 -0
- package/build/src/entity.js +236 -0
- package/build/src/entity.js.map +1 -0
- package/build/src/extractor.js +370 -0
- package/build/src/extractor.js.map +1 -0
- package/build/src/flow.js +320 -0
- package/build/src/flow.js.map +1 -0
- package/build/src/libsaml.js +642 -0
- package/build/src/libsaml.js.map +1 -0
- package/build/src/metadata-idp.js +128 -0
- package/build/src/metadata-idp.js.map +1 -0
- package/build/src/metadata-sp.js +232 -0
- package/build/src/metadata-sp.js.map +1 -0
- package/build/src/metadata.js +177 -0
- package/build/src/metadata.js.map +1 -0
- package/build/src/types.js +12 -0
- package/build/src/types.js.map +1 -0
- package/build/src/urn.js +213 -0
- package/build/src/urn.js.map +1 -0
- package/build/src/utility.js +249 -0
- package/build/src/utility.js.map +1 -0
- package/build/src/validator.js +27 -0
- package/build/src/validator.js.map +1 -0
- package/index.d.ts +10 -0
- package/index.js +19 -0
- package/index.js.map +1 -0
- package/index.ts +28 -0
- package/package.json +74 -0
- package/qodana.yaml +29 -0
- package/src/.idea/modules.xml +8 -0
- package/src/.idea/src.iml +12 -0
- package/src/.idea/vcs.xml +6 -0
- package/src/api.ts +36 -0
- package/src/binding-post.ts +338 -0
- package/src/binding-redirect.ts +331 -0
- package/src/binding-simplesign.ts +231 -0
- package/src/entity-idp.ts +145 -0
- package/src/entity-sp.ts +114 -0
- package/src/entity.ts +243 -0
- package/src/extractor.ts +392 -0
- package/src/flow.ts +467 -0
- package/src/libsaml.ts +786 -0
- package/src/metadata-idp.ts +146 -0
- package/src/metadata-sp.ts +268 -0
- package/src/metadata.ts +166 -0
- package/src/types.ts +153 -0
- package/src/urn.ts +211 -0
- package/src/utility.ts +248 -0
- package/src/validator.ts +44 -0
- package/tsconfig.json +38 -0
- package/tslint.json +35 -0
- package/types/index.d.ts +10 -0
- package/types/src/api.d.ts +13 -0
- package/types/src/binding-post.d.ts +46 -0
- package/types/src/binding-redirect.d.ts +52 -0
- package/types/src/binding-simplesign.d.ts +39 -0
- package/types/src/entity-idp.d.ts +42 -0
- package/types/src/entity-sp.d.ts +36 -0
- package/types/src/entity.d.ts +99 -0
- package/types/src/extractor.d.ts +25 -0
- package/types/src/flow.d.ts +6 -0
- package/types/src/libsaml.d.ts +210 -0
- package/types/src/metadata-idp.d.ts +24 -0
- package/types/src/metadata-sp.d.ts +36 -0
- package/types/src/metadata.d.ts +57 -0
- package/types/src/types.d.ts +127 -0
- package/types/src/urn.d.ts +194 -0
- package/types/src/utility.d.ts +134 -0
- package/types/src/validator.d.ts +3 -0
- package/types.d.ts +2 -0
package/build/src/urn.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file urn.ts
|
|
4
|
+
* @author tngan
|
|
5
|
+
* @desc Includes all keywords need in samlify
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.messageConfigurations = exports.elementsOrder = exports.wording = exports.algorithms = exports.tags = exports.namespace = exports.ParserType = exports.StatusCode = exports.MessageSignatureOrder = exports.BindingNamespace = void 0;
|
|
9
|
+
var BindingNamespace;
|
|
10
|
+
(function (BindingNamespace) {
|
|
11
|
+
BindingNamespace["Redirect"] = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect";
|
|
12
|
+
BindingNamespace["Post"] = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST";
|
|
13
|
+
BindingNamespace["SimpleSign"] = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign";
|
|
14
|
+
BindingNamespace["Artifact"] = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact";
|
|
15
|
+
})(BindingNamespace || (exports.BindingNamespace = BindingNamespace = {}));
|
|
16
|
+
var MessageSignatureOrder;
|
|
17
|
+
(function (MessageSignatureOrder) {
|
|
18
|
+
MessageSignatureOrder["STE"] = "sign-then-encrypt";
|
|
19
|
+
MessageSignatureOrder["ETS"] = "encrypt-then-sign";
|
|
20
|
+
})(MessageSignatureOrder || (exports.MessageSignatureOrder = MessageSignatureOrder = {}));
|
|
21
|
+
var StatusCode;
|
|
22
|
+
(function (StatusCode) {
|
|
23
|
+
// top-tier
|
|
24
|
+
StatusCode["Success"] = "urn:oasis:names:tc:SAML:2.0:status:Success";
|
|
25
|
+
StatusCode["Requester"] = "urn:oasis:names:tc:SAML:2.0:status:Requester";
|
|
26
|
+
StatusCode["Responder"] = "urn:oasis:names:tc:SAML:2.0:status:Responder";
|
|
27
|
+
StatusCode["VersionMismatch"] = "urn:oasis:names:tc:SAML:2.0:status:VersionMismatch";
|
|
28
|
+
// second-tier to provide more information
|
|
29
|
+
StatusCode["AuthFailed"] = "urn:oasis:names:tc:SAML:2.0:status:AuthnFailed";
|
|
30
|
+
StatusCode["InvalidAttrNameOrValue"] = "urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue";
|
|
31
|
+
StatusCode["InvalidNameIDPolicy"] = "urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy";
|
|
32
|
+
StatusCode["NoAuthnContext"] = "urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext";
|
|
33
|
+
StatusCode["NoAvailableIDP"] = "urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP";
|
|
34
|
+
StatusCode["NoPassive"] = "urn:oasis:names:tc:SAML:2.0:status:NoPassive";
|
|
35
|
+
StatusCode["NoSupportedIDP"] = "urn:oasis:names:tc:SAML:2.0:status:NoSupportedIDP";
|
|
36
|
+
StatusCode["PartialLogout"] = "urn:oasis:names:tc:SAML:2.0:status:PartialLogout";
|
|
37
|
+
StatusCode["ProxyCountExceeded"] = "urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded";
|
|
38
|
+
StatusCode["RequestDenied"] = "urn:oasis:names:tc:SAML:2.0:status:RequestDenied";
|
|
39
|
+
StatusCode["RequestUnsupported"] = "urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported";
|
|
40
|
+
StatusCode["RequestVersionDeprecated"] = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionDeprecated";
|
|
41
|
+
StatusCode["RequestVersionTooHigh"] = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh";
|
|
42
|
+
StatusCode["RequestVersionTooLow"] = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow";
|
|
43
|
+
StatusCode["ResourceNotRecognized"] = "urn:oasis:names:tc:SAML:2.0:status:ResourceNotRecognized";
|
|
44
|
+
StatusCode["TooManyResponses"] = "urn:oasis:names:tc:SAML:2.0:status:TooManyResponses";
|
|
45
|
+
StatusCode["UnknownAttrProfile"] = "urn:oasis:names:tc:SAML:2.0:status:UnknownAttrProfile";
|
|
46
|
+
StatusCode["UnknownPrincipal"] = "urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal";
|
|
47
|
+
StatusCode["UnsupportedBinding"] = "urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding";
|
|
48
|
+
})(StatusCode || (exports.StatusCode = StatusCode = {}));
|
|
49
|
+
const namespace = {
|
|
50
|
+
binding: {
|
|
51
|
+
redirect: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
|
52
|
+
post: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
|
|
53
|
+
simpleSign: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign',
|
|
54
|
+
artifact: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
|
|
55
|
+
},
|
|
56
|
+
names: {
|
|
57
|
+
protocol: 'urn:oasis:names:tc:SAML:2.0:protocol',
|
|
58
|
+
assertion: 'urn:oasis:names:tc:SAML:2.0:assertion',
|
|
59
|
+
metadata: 'urn:oasis:names:tc:SAML:2.0:metadata',
|
|
60
|
+
userLogout: 'urn:oasis:names:tc:SAML:2.0:logout:user',
|
|
61
|
+
adminLogout: 'urn:oasis:names:tc:SAML:2.0:logout:admin',
|
|
62
|
+
},
|
|
63
|
+
authnContextClassRef: {
|
|
64
|
+
password: 'urn:oasis:names:tc:SAML:2.0:ac:classes:Password',
|
|
65
|
+
passwordProtectedTransport: 'urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport',
|
|
66
|
+
},
|
|
67
|
+
format: {
|
|
68
|
+
emailAddress: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
|
|
69
|
+
persistent: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
|
|
70
|
+
transient: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
|
|
71
|
+
entity: 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity',
|
|
72
|
+
unspecified: 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified',
|
|
73
|
+
kerberos: 'urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos',
|
|
74
|
+
windowsDomainQualifiedName: 'urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName',
|
|
75
|
+
x509SubjectName: 'urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName',
|
|
76
|
+
},
|
|
77
|
+
statusCode: {
|
|
78
|
+
// permissible top-level status codes
|
|
79
|
+
success: 'urn:oasis:names:tc:SAML:2.0:status:Success',
|
|
80
|
+
requester: 'urn:oasis:names:tc:SAML:2.0:status:Requester',
|
|
81
|
+
responder: 'urn:oasis:names:tc:SAML:2.0:status:Responder',
|
|
82
|
+
versionMismatch: 'urn:oasis:names:tc:SAML:2.0:status:VersionMismatch',
|
|
83
|
+
// second-level status codes
|
|
84
|
+
authFailed: 'urn:oasis:names:tc:SAML:2.0:status:AuthnFailed',
|
|
85
|
+
invalidAttrNameOrValue: 'urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue',
|
|
86
|
+
invalidNameIDPolicy: 'urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy',
|
|
87
|
+
noAuthnContext: 'urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext',
|
|
88
|
+
noAvailableIDP: 'urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP',
|
|
89
|
+
noPassive: 'urn:oasis:names:tc:SAML:2.0:status:NoPassive',
|
|
90
|
+
noSupportedIDP: 'urn:oasis:names:tc:SAML:2.0:status:NoSupportedIDP',
|
|
91
|
+
partialLogout: 'urn:oasis:names:tc:SAML:2.0:status:PartialLogout',
|
|
92
|
+
proxyCountExceeded: 'urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded',
|
|
93
|
+
requestDenied: 'urn:oasis:names:tc:SAML:2.0:status:RequestDenied',
|
|
94
|
+
requestUnsupported: 'urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported',
|
|
95
|
+
requestVersionDeprecated: 'urn:oasis:names:tc:SAML:2.0:status:RequestVersionDeprecated',
|
|
96
|
+
requestVersionTooHigh: 'urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh',
|
|
97
|
+
requestVersionTooLow: 'urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow',
|
|
98
|
+
resourceNotRecognized: 'urn:oasis:names:tc:SAML:2.0:status:ResourceNotRecognized',
|
|
99
|
+
tooManyResponses: 'urn:oasis:names:tc:SAML:2.0:status:TooManyResponses',
|
|
100
|
+
unknownAttrProfile: 'urn:oasis:names:tc:SAML:2.0:status:UnknownAttrProfile',
|
|
101
|
+
unknownPrincipal: 'urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal',
|
|
102
|
+
unsupportedBinding: 'urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding',
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
exports.namespace = namespace;
|
|
106
|
+
const tags = {
|
|
107
|
+
request: {
|
|
108
|
+
AllowCreate: '{AllowCreate}',
|
|
109
|
+
AssertionConsumerServiceURL: '{AssertionConsumerServiceURL}',
|
|
110
|
+
AuthnContextClassRef: '{AuthnContextClassRef}',
|
|
111
|
+
AssertionID: '{AssertionID}',
|
|
112
|
+
Audience: '{Audience}',
|
|
113
|
+
AuthnStatement: '{AuthnStatement}',
|
|
114
|
+
AttributeStatement: '{AttributeStatement}',
|
|
115
|
+
ConditionsNotBefore: '{ConditionsNotBefore}',
|
|
116
|
+
ConditionsNotOnOrAfter: '{ConditionsNotOnOrAfter}',
|
|
117
|
+
Destination: '{Destination}',
|
|
118
|
+
EntityID: '{EntityID}',
|
|
119
|
+
ID: '{ID}',
|
|
120
|
+
Issuer: '{Issuer}',
|
|
121
|
+
IssueInstant: '{IssueInstant}',
|
|
122
|
+
InResponseTo: '{InResponseTo}',
|
|
123
|
+
NameID: '{NameID}',
|
|
124
|
+
NameIDFormat: '{NameIDFormat}',
|
|
125
|
+
ProtocolBinding: '{ProtocolBinding}',
|
|
126
|
+
SessionIndex: '{SessionIndex}',
|
|
127
|
+
SubjectRecipient: '{SubjectRecipient}',
|
|
128
|
+
SubjectConfirmationDataNotOnOrAfter: '{SubjectConfirmationDataNotOnOrAfter}',
|
|
129
|
+
StatusCode: '{StatusCode}',
|
|
130
|
+
},
|
|
131
|
+
xmlTag: {
|
|
132
|
+
loginRequest: 'AuthnRequest',
|
|
133
|
+
logoutRequest: 'LogoutRequest',
|
|
134
|
+
loginResponse: 'Response',
|
|
135
|
+
logoutResponse: 'LogoutResponse',
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
exports.tags = tags;
|
|
139
|
+
const messageConfigurations = {
|
|
140
|
+
signingOrder: {
|
|
141
|
+
SIGN_THEN_ENCRYPT: 'sign-then-encrypt',
|
|
142
|
+
ENCRYPT_THEN_SIGN: 'encrypt-then-sign',
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
exports.messageConfigurations = messageConfigurations;
|
|
146
|
+
const algorithms = {
|
|
147
|
+
signature: {
|
|
148
|
+
RSA_SHA1: 'http://www.w3.org/2000/09/xmldsig#rsa-sha1',
|
|
149
|
+
RSA_SHA256: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
|
|
150
|
+
RSA_SHA512: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512',
|
|
151
|
+
},
|
|
152
|
+
encryption: {
|
|
153
|
+
data: {
|
|
154
|
+
AES_128: 'http://www.w3.org/2001/04/xmlenc#aes128-cbc',
|
|
155
|
+
AES_256: 'http://www.w3.org/2001/04/xmlenc#aes256-cbc',
|
|
156
|
+
AES_256_GCM: 'http://www.w3.org/2009/xmlenc11#aes256-gcm',
|
|
157
|
+
TRI_DEC: 'http://www.w3.org/2001/04/xmlenc#tripledes-cbc',
|
|
158
|
+
AES_128_GCM: 'http://www.w3.org/2009/xmlenc11#aes128-gcm'
|
|
159
|
+
},
|
|
160
|
+
key: {
|
|
161
|
+
RSA_OAEP_MGF1P: 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p',
|
|
162
|
+
RSA_1_5: 'http://www.w3.org/2001/04/xmlenc#rsa-1_5',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
digest: {
|
|
166
|
+
'http://www.w3.org/2000/09/xmldsig#rsa-sha1': 'http://www.w3.org/2000/09/xmldsig#sha1',
|
|
167
|
+
'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256': 'http://www.w3.org/2001/04/xmlenc#sha256',
|
|
168
|
+
'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512': 'http://www.w3.org/2001/04/xmlenc#sha512', // support hashing algorithm sha512 in xml-crypto after 0.8.0
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
exports.algorithms = algorithms;
|
|
172
|
+
var ParserType;
|
|
173
|
+
(function (ParserType) {
|
|
174
|
+
ParserType["SAMLRequest"] = "SAMLRequest";
|
|
175
|
+
ParserType["SAMLResponse"] = "SAMLResponse";
|
|
176
|
+
ParserType["LogoutRequest"] = "LogoutRequest";
|
|
177
|
+
ParserType["LogoutResponse"] = "LogoutResponse";
|
|
178
|
+
})(ParserType || (exports.ParserType = ParserType = {}));
|
|
179
|
+
const wording = {
|
|
180
|
+
urlParams: {
|
|
181
|
+
samlRequest: 'SAMLRequest',
|
|
182
|
+
samlResponse: 'SAMLResponse',
|
|
183
|
+
logoutRequest: 'LogoutRequest',
|
|
184
|
+
logoutResponse: 'LogoutResponse',
|
|
185
|
+
sigAlg: 'SigAlg',
|
|
186
|
+
signature: 'Signature',
|
|
187
|
+
relayState: 'RelayState',
|
|
188
|
+
},
|
|
189
|
+
binding: {
|
|
190
|
+
redirect: 'redirect',
|
|
191
|
+
post: 'post',
|
|
192
|
+
simpleSign: 'simpleSign',
|
|
193
|
+
artifact: 'artifact',
|
|
194
|
+
},
|
|
195
|
+
certUse: {
|
|
196
|
+
signing: 'signing',
|
|
197
|
+
encrypt: 'encryption',
|
|
198
|
+
},
|
|
199
|
+
metadata: {
|
|
200
|
+
sp: 'metadata-sp',
|
|
201
|
+
idp: 'metadata-idp',
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
exports.wording = wording;
|
|
205
|
+
// https://wiki.shibboleth.net/confluence/display/CONCEPT/MetadataForSP
|
|
206
|
+
// some idps restrict the order of elements in entity descriptors
|
|
207
|
+
const elementsOrder = {
|
|
208
|
+
default: ['KeyDescriptor', 'NameIDFormat', 'SingleLogoutService', 'AssertionConsumerService', 'AttributeConsumingService'],
|
|
209
|
+
onelogin: ['KeyDescriptor', 'NameIDFormat', 'SingleLogoutService', 'AssertionConsumerService', 'AttributeConsumingService'],
|
|
210
|
+
shibboleth: ['KeyDescriptor', 'SingleLogoutService', 'NameIDFormat', 'AssertionConsumerService', 'AttributeConsumingService'],
|
|
211
|
+
};
|
|
212
|
+
exports.elementsOrder = elementsOrder;
|
|
213
|
+
//# sourceMappingURL=urn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urn.js","sourceRoot":"","sources":["../../src/urn.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;AAEF,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,mFAA+D,CAAA;IAC/D,2EAAuD,CAAA;IACvD,4FAAwE,CAAA;IACxE,mFAA+D,CAAA;AACjE,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B;AAED,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,kDAAyB,CAAA;IACzB,kDAAyB,CAAA;AAC3B,CAAC,EAHW,qBAAqB,qCAArB,qBAAqB,QAGhC;AAED,IAAY,UA0BX;AA1BD,WAAY,UAAU;IACpB,WAAW;IACX,oEAAsD,CAAA;IACtD,wEAA0D,CAAA;IAC1D,wEAA0D,CAAA;IAC1D,oFAAsE,CAAA;IACtE,0CAA0C;IAC1C,2EAA6D,CAAA;IAC7D,kGAAoF,CAAA;IACpF,4FAA8E,CAAA;IAC9E,kFAAoE,CAAA;IACpE,kFAAoE,CAAA;IACpE,wEAA0D,CAAA;IAC1D,kFAAoE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AAY;KACtB;IACD,QAAQ,EAAE;QACR,EAAE,EAAE,aAAa;QACjB,GAAG,EAAE,cAAc;KACpB;CACF,CAAC;AAUoC,0BAAO;AAR7C,uEAAuE;AACvE,iEAAiE;AACjE,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,qBAAqB,EAAE,0BAA0B,EAAC,2BAA2B,CAAC;IACzH,QAAQ,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,qBAAqB,EAAE,0BAA0B,EAAC,2BAA2B,CAAC;IAC1H,UAAU,EAAE,CAAC,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,0BAA0B,EAAE,2BAA2B,CAAC;CAC9H,CAAC;AAE6C,sCAAa"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zipObject = zipObject;
|
|
4
|
+
exports.flattenDeep = flattenDeep;
|
|
5
|
+
exports.last = last;
|
|
6
|
+
exports.uniq = uniq;
|
|
7
|
+
exports.get = get;
|
|
8
|
+
exports.isString = isString;
|
|
9
|
+
exports.base64Decode = base64Decode;
|
|
10
|
+
exports.inflateString = inflateString;
|
|
11
|
+
exports.readPrivateKey = readPrivateKey;
|
|
12
|
+
exports.isNonEmptyArray = isNonEmptyArray;
|
|
13
|
+
exports.castArrayOpt = castArrayOpt;
|
|
14
|
+
exports.notEmpty = notEmpty;
|
|
15
|
+
/**
|
|
16
|
+
* @file utility.ts
|
|
17
|
+
* @author tngan
|
|
18
|
+
* @desc Library for some common functions (e.g. de/inflation, en/decoding)
|
|
19
|
+
*/
|
|
20
|
+
const node_forge_1 = require("node-forge");
|
|
21
|
+
const pako_1 = require("pako");
|
|
22
|
+
const BASE64_STR = 'base64';
|
|
23
|
+
/**
|
|
24
|
+
* @desc Mimic lodash.zipObject
|
|
25
|
+
* @param arr1 {string[]}
|
|
26
|
+
* @param arr2 {[]}
|
|
27
|
+
*/
|
|
28
|
+
function zipObject(arr1, arr2, skipDuplicated = true) {
|
|
29
|
+
return arr1.reduce((res, l, i) => {
|
|
30
|
+
if (skipDuplicated) {
|
|
31
|
+
res[l] = arr2[i];
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
// if key exists, aggregate with array in order to get rid of duplicate key
|
|
35
|
+
if (res[l] !== undefined) {
|
|
36
|
+
res[l] = Array.isArray(res[l])
|
|
37
|
+
? res[l].concat(arr2[i])
|
|
38
|
+
: [res[l]].concat(arr2[i]);
|
|
39
|
+
return res;
|
|
40
|
+
}
|
|
41
|
+
res[l] = arr2[i];
|
|
42
|
+
return res;
|
|
43
|
+
}, {});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @desc Alternative to lodash.flattenDeep
|
|
47
|
+
* @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_flattendeep
|
|
48
|
+
* @param input {[]}
|
|
49
|
+
*/
|
|
50
|
+
function flattenDeep(input) {
|
|
51
|
+
return Array.isArray(input)
|
|
52
|
+
? input.reduce((a, b) => a.concat(flattenDeep(b)), [])
|
|
53
|
+
: [input];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @desc Alternative to lodash.last
|
|
57
|
+
* @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_last
|
|
58
|
+
* @param input {[]}
|
|
59
|
+
*/
|
|
60
|
+
function last(input) {
|
|
61
|
+
return input.slice(-1)[0];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @desc Alternative to lodash.uniq
|
|
65
|
+
* @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_uniq
|
|
66
|
+
* @param input {string[]}
|
|
67
|
+
*/
|
|
68
|
+
function uniq(input) {
|
|
69
|
+
const set = new Set(input);
|
|
70
|
+
return [...set];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @desc Alternative to lodash.get
|
|
74
|
+
* @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get
|
|
75
|
+
* @param obj
|
|
76
|
+
* @param path
|
|
77
|
+
* @param defaultValue
|
|
78
|
+
*/
|
|
79
|
+
function get(obj, path, defaultValue) {
|
|
80
|
+
return path.split('.')
|
|
81
|
+
.reduce((a, c) => (a && a[c] ? a[c] : (defaultValue || null)), obj);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @desc Check if the input is string
|
|
85
|
+
* @param {any} input
|
|
86
|
+
*/
|
|
87
|
+
function isString(input) {
|
|
88
|
+
return typeof input === 'string';
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @desc Encode string with base64 format
|
|
92
|
+
* @param {string} message plain-text message
|
|
93
|
+
* @return {string} base64 encoded string
|
|
94
|
+
*/
|
|
95
|
+
function base64Encode(message) {
|
|
96
|
+
return Buffer.from(message).toString(BASE64_STR);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @desc Decode string from base64 format
|
|
100
|
+
* @param {string} base64Message encoded string
|
|
101
|
+
* @param {boolean} isBytes determine the return value type (True: bytes False: string)
|
|
102
|
+
* @return {bytes/string} decoded bytes/string depends on isBytes, default is {string}
|
|
103
|
+
*/
|
|
104
|
+
function base64Decode(base64Message, isBytes) {
|
|
105
|
+
const bytes = Buffer.from(base64Message, BASE64_STR);
|
|
106
|
+
return Boolean(isBytes) ? bytes : bytes.toString();
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @desc Compress the string
|
|
110
|
+
* @param {string} message
|
|
111
|
+
* @return {string} compressed string
|
|
112
|
+
*/
|
|
113
|
+
function deflateString(message) {
|
|
114
|
+
const input = Array.prototype.map.call(message, char => char.charCodeAt(0));
|
|
115
|
+
return Array.from((0, pako_1.deflate)(input, { raw: true }));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @desc Decompress the compressed string
|
|
119
|
+
* @param {string} compressedString
|
|
120
|
+
* @return {string} decompressed string
|
|
121
|
+
*/
|
|
122
|
+
function inflateString(compressedString) {
|
|
123
|
+
const inputBuffer = Buffer.from(compressedString, BASE64_STR);
|
|
124
|
+
const input = Array.prototype.map.call(inputBuffer.toString('binary'), char => char.charCodeAt(0));
|
|
125
|
+
return Array.from((0, pako_1.inflate)(input, { raw: true }))
|
|
126
|
+
.map((byte) => String.fromCharCode(byte))
|
|
127
|
+
.join('');
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @desc Abstract the normalizeCerString and normalizePemString
|
|
131
|
+
* @param {buffer} File stream or string
|
|
132
|
+
* @param {string} String for header and tail
|
|
133
|
+
* @return {string} A formatted certificate string
|
|
134
|
+
*/
|
|
135
|
+
function _normalizeCerString(bin, format) {
|
|
136
|
+
return bin.toString().replace(/\n/g, '').replace(/\r/g, '').replace(`-----BEGIN ${format}-----`, '').replace(`-----END ${format}-----`, '').replace(/ /g, '').replace(/\t/g, '');
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @desc Parse the .cer to string format without line break, header and footer
|
|
140
|
+
* @param {string} certString declares the certificate contents
|
|
141
|
+
* @return {string} certificiate in string format
|
|
142
|
+
*/
|
|
143
|
+
function normalizeCerString(certString) {
|
|
144
|
+
return _normalizeCerString(certString, 'CERTIFICATE');
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @desc Normalize the string in .pem format without line break, header and footer
|
|
148
|
+
* @param {string} pemString
|
|
149
|
+
* @return {string} private key in string format
|
|
150
|
+
*/
|
|
151
|
+
function normalizePemString(pemString) {
|
|
152
|
+
return _normalizeCerString(pemString.toString(), 'RSA PRIVATE KEY');
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* @desc Return the complete URL
|
|
156
|
+
* @param {object} req HTTP request
|
|
157
|
+
* @return {string} URL
|
|
158
|
+
*/
|
|
159
|
+
function getFullURL(req) {
|
|
160
|
+
return `${req.protocol}://${req.get('host')}${req.originalUrl}`;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @desc Parse input string, return default value if it is undefined
|
|
164
|
+
* @param {string/boolean}
|
|
165
|
+
* @return {boolean}
|
|
166
|
+
*/
|
|
167
|
+
function parseString(str, defaultValue = '') {
|
|
168
|
+
return str || defaultValue;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* @desc Override the object by another object (rtl)
|
|
172
|
+
* @param {object} default object
|
|
173
|
+
* @param {object} object applied to the default object
|
|
174
|
+
* @return {object} result object
|
|
175
|
+
*/
|
|
176
|
+
function applyDefault(obj1, obj2) {
|
|
177
|
+
return Object.assign({}, obj1, obj2);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* @desc Get public key in pem format from the certificate included in the metadata
|
|
181
|
+
* @param {string} x509 certificate
|
|
182
|
+
* @return {string} public key fetched from the certificate
|
|
183
|
+
*/
|
|
184
|
+
function getPublicKeyPemFromCertificate(x509CertificateString) {
|
|
185
|
+
const certDerBytes = node_forge_1.util.decode64(x509CertificateString);
|
|
186
|
+
const obj = node_forge_1.asn1.fromDer(certDerBytes);
|
|
187
|
+
const cert = node_forge_1.pki.certificateFromAsn1(obj);
|
|
188
|
+
return node_forge_1.pki.publicKeyToPem(cert.publicKey);
|
|
189
|
+
}
|
|
190
|
+
/*function getPublicKeyPemFromCertificate(x509Certificate: string): string {
|
|
191
|
+
// 将 Base64 字符串转为 Buffer(DER 编码)
|
|
192
|
+
const derBuffer = Buffer.from(x509Certificate, 'base64');
|
|
193
|
+
|
|
194
|
+
// 解析 X.509 证书
|
|
195
|
+
const cert = new X509Certificate(derBuffer);
|
|
196
|
+
|
|
197
|
+
// 直接获取公钥的 PEM 格式
|
|
198
|
+
console.log(cert.publicKey?.toString())
|
|
199
|
+
console.log("这就是我的打印")
|
|
200
|
+
return cert.publicKey?.toString();
|
|
201
|
+
}*/
|
|
202
|
+
/**
|
|
203
|
+
* @desc Read private key from pem-formatted string
|
|
204
|
+
* @param {string | Buffer} keyString pem-formatted string
|
|
205
|
+
* @param {string} protected passphrase of the key
|
|
206
|
+
* @return {string} string in pem format
|
|
207
|
+
* If passphrase is used to protect the .pem content (recommend)
|
|
208
|
+
*/
|
|
209
|
+
function readPrivateKey(keyString, passphrase, isOutputString) {
|
|
210
|
+
return isString(passphrase) ? this.convertToString(node_forge_1.pki.privateKeyToPem(node_forge_1.pki.decryptRsaPrivateKey(String(keyString), passphrase)), isOutputString) : keyString;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @desc Inline syntax sugar
|
|
214
|
+
*/
|
|
215
|
+
function convertToString(input, isOutputString) {
|
|
216
|
+
return Boolean(isOutputString) ? String(input) : input;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @desc Check if the input is an array with non-zero size
|
|
220
|
+
*/
|
|
221
|
+
function isNonEmptyArray(a) {
|
|
222
|
+
return Array.isArray(a) && a.length > 0;
|
|
223
|
+
}
|
|
224
|
+
function castArrayOpt(a) {
|
|
225
|
+
if (a === undefined)
|
|
226
|
+
return [];
|
|
227
|
+
return Array.isArray(a) ? a : [a];
|
|
228
|
+
}
|
|
229
|
+
function notEmpty(value) {
|
|
230
|
+
return value !== null && value !== undefined;
|
|
231
|
+
}
|
|
232
|
+
const utility = {
|
|
233
|
+
isString,
|
|
234
|
+
base64Encode,
|
|
235
|
+
base64Decode,
|
|
236
|
+
deflateString,
|
|
237
|
+
inflateString,
|
|
238
|
+
normalizeCerString,
|
|
239
|
+
normalizePemString,
|
|
240
|
+
getFullURL,
|
|
241
|
+
parseString,
|
|
242
|
+
applyDefault,
|
|
243
|
+
getPublicKeyPemFromCertificate,
|
|
244
|
+
readPrivateKey,
|
|
245
|
+
convertToString,
|
|
246
|
+
isNonEmptyArray,
|
|
247
|
+
};
|
|
248
|
+
exports.default = utility;
|
|
249
|
+
//# sourceMappingURL=utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../src/utility.ts"],"names":[],"m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3
|
+
exports.verifyTime = verifyTime;
|
|
4
|
+
function verifyTime(utcNotBefore, utcNotOnOrAfter, drift = [0, 0]) {
|
|
5
|
+
const now = new Date();
|
|
6
|
+
if (!utcNotBefore && !utcNotOnOrAfter) {
|
|
7
|
+
// show warning because user intends to have time check but the document doesn't include corresponding information
|
|
8
|
+
console.warn('You intend to have time validation however the document doesn\'t include the valid range.');
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
let notBeforeLocal = null;
|
|
12
|
+
let notOnOrAfterLocal = null;
|
|
13
|
+
const [notBeforeDrift, notOnOrAfterDrift] = drift;
|
|
14
|
+
if (utcNotBefore && !utcNotOnOrAfter) {
|
|
15
|
+
notBeforeLocal = new Date(utcNotBefore);
|
|
16
|
+
return +notBeforeLocal + notBeforeDrift <= +now;
|
|
17
|
+
}
|
|
18
|
+
if (!utcNotBefore && utcNotOnOrAfter) {
|
|
19
|
+
notOnOrAfterLocal = new Date(utcNotOnOrAfter);
|
|
20
|
+
return +now < +notOnOrAfterLocal + notOnOrAfterDrift;
|
|
21
|
+
}
|
|
22
|
+
notBeforeLocal = new Date(utcNotBefore);
|
|
23
|
+
notOnOrAfterLocal = new Date(utcNotOnOrAfter);
|
|
24
|
+
return (+notBeforeLocal + notBeforeDrift <= +now &&
|
|
25
|
+
+now < +notOnOrAfterLocal + notOnOrAfterDrift);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":";;AA0CE,gCAAU;AAvCZ,SAAS,UAAU,CACjB,YAAgC,EAChC,eAAmC,EACnC,QAAwB,CAAC,CAAC,EAAE,CAAC,CAAC;IAG9B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,IAAI,CAAC,YAAY,IAAI,CAAC,eAAe,EAAE,CAAC;QACtC,kHAAkH;QAClH,OAAO,CAAC,IAAI,CAAC,2FAA2F,CAAC,CAAC;QAC1G,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,cAAc,GAAgB,IAAI,CAAC;IACvC,IAAI,iBAAiB,GAAgB,IAAI,CAAC;IAE1C,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC;IAElD,IAAI,YAAY,IAAI,CAAC,eAAe,EAAE,CAAC;QACrC,cAAc,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QACxC,OAAO,CAAC,cAAc,GAAG,cAAc,IAAI,CAAC,GAAG,CAAC;IAClD,CAAC;IACD,IAAI,CAAC,YAAY,IAAI,eAAe,EAAE,CAAC;QACrC,iBAAiB,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IACvD,CAAC;IAED,cAAc,GAAG,IAAI,IAAI,CAAC,YAAa,CAAC,CAAC;IACzC,iBAAiB,GAAG,IAAI,IAAI,CAAC,eAAgB,CAAC,CAAC;IAE/C,OAAO,CACL,CAAC,cAAc,GAAG,cAAc,IAAI,CAAC,GAAG;QACxC,CAAC,GAAG,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAC9C,CAAC;AAEJ,CAAC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import IdentityProvider, { IdentityProvider as IdentityProviderInstance } from './src/entity-idp';
|
|
2
|
+
import ServiceProvider, { ServiceProvider as ServiceProviderInstance } from './src/entity-sp';
|
|
3
|
+
export { default as IdPMetadata } from './src/metadata-idp';
|
|
4
|
+
export { default as SPMetadata } from './src/metadata-sp';
|
|
5
|
+
export { default as Utility } from './src/utility';
|
|
6
|
+
export { default as SamlLib } from './src/libsaml';
|
|
7
|
+
import * as Constants from './src/urn';
|
|
8
|
+
import * as Extractor from './src/extractor';
|
|
9
|
+
import { setSchemaValidator, setDOMParserOptions } from './src/api';
|
|
10
|
+
export { Constants, Extractor, IdentityProvider, IdentityProviderInstance, ServiceProvider, ServiceProviderInstance, setSchemaValidator, setDOMParserOptions };
|
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// version <= 1.25
|
|
2
|
+
import IdentityProvider, { IdentityProvider as IdentityProviderInstance } from './src/entity-idp';
|
|
3
|
+
import ServiceProvider, { ServiceProvider as ServiceProviderInstance } from './src/entity-sp';
|
|
4
|
+
export { default as IdPMetadata } from './src/metadata-idp';
|
|
5
|
+
export { default as SPMetadata } from './src/metadata-sp';
|
|
6
|
+
export { default as Utility } from './src/utility';
|
|
7
|
+
export { default as SamlLib } from './src/libsaml';
|
|
8
|
+
// roadmap
|
|
9
|
+
// new name convention in version >= 3.0
|
|
10
|
+
import * as Constants from './src/urn';
|
|
11
|
+
import * as Extractor from './src/extractor';
|
|
12
|
+
// exposed methods for customizing samlify
|
|
13
|
+
import { setSchemaValidator, setDOMParserOptions } from './src/api';
|
|
14
|
+
export { Constants, Extractor,
|
|
15
|
+
// temp: resolve the conflict after version >= 3.0
|
|
16
|
+
IdentityProvider, IdentityProviderInstance, ServiceProvider, ServiceProviderInstance,
|
|
17
|
+
// set context
|
|
18
|
+
setSchemaValidator, setDOMParserOptions };
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,OAAO,gBAAgB,EAAE,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,eAAe,EAAE,EAAE,eAAe,IAAI,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE9F,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AACnD,UAAU;AACV,wCAAwC;AACxC,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAE7C,0CAA0C;AAC1C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEpE,OAAO,EACL,SAAS,EACT,SAAS;AACT,kDAAkD;AAClD,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,uBAAuB;AACvB,cAAc;AACd,kBAAkB,EAClB,mBAAmB,EACpB,CAAC"}
|
package/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// version <= 1.25
|
|
2
|
+
import IdentityProvider, { IdentityProvider as IdentityProviderInstance } from './src/entity-idp.js';
|
|
3
|
+
import ServiceProvider, { ServiceProvider as ServiceProviderInstance } from './src/entity-sp.js';
|
|
4
|
+
|
|
5
|
+
export { default as IdPMetadata } from './src/metadata-idp.js';
|
|
6
|
+
export { default as SPMetadata } from './src/metadata-sp.js';
|
|
7
|
+
export { default as Utility } from './src/utility.js';
|
|
8
|
+
export { default as SamlLib } from './src/libsaml.js';
|
|
9
|
+
// roadmap
|
|
10
|
+
// new name convention in version >= 3.0
|
|
11
|
+
import * as Constants from './src/urn.js';
|
|
12
|
+
import * as Extractor from './src/extractor.js';
|
|
13
|
+
|
|
14
|
+
// exposed methods for customizing samlify
|
|
15
|
+
import { setSchemaValidator, setDOMParserOptions } from './src/api.js';
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
Constants,
|
|
19
|
+
Extractor,
|
|
20
|
+
// temp: resolve the conflict after version >= 3.0
|
|
21
|
+
IdentityProvider,
|
|
22
|
+
IdentityProviderInstance,
|
|
23
|
+
ServiceProvider,
|
|
24
|
+
ServiceProviderInstance,
|
|
25
|
+
// set context
|
|
26
|
+
setSchemaValidator,
|
|
27
|
+
setDOMParserOptions
|
|
28
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "samlesa",
|
|
3
|
+
"version": "2.12.3",
|
|
4
|
+
"description": "High-level API for Single Sign On (SAML 2.0) 维护分支:修复原项目samlify的一些问题 ",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"nodejs",
|
|
8
|
+
"saml2",
|
|
9
|
+
"sso",
|
|
10
|
+
"slo",
|
|
11
|
+
"metadata"
|
|
12
|
+
],
|
|
13
|
+
"typings": "types/index.d.ts",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"docs": "docsify serve -o docs",
|
|
17
|
+
"lint": "tslint -p .",
|
|
18
|
+
"lint:fix": "tslint -p . --fix",
|
|
19
|
+
"pretest": "make pretest",
|
|
20
|
+
"test": "NODE_ENV=test nyc ava",
|
|
21
|
+
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
|
22
|
+
"hooks:postinstall": "ln -sf $PWD/.pre-commit.sh $PWD/.git/hooks/pre-commit"
|
|
23
|
+
},
|
|
24
|
+
"contributors": [
|
|
25
|
+
"Veclea <vemocle@gmail.com>"
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
"author": "Veclea",
|
|
29
|
+
"repository": {
|
|
30
|
+
"url": "https://github.com/Veclea/samlify.git",
|
|
31
|
+
"type": "git"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"xml-encryption": "^3.0.1",
|
|
36
|
+
"@xmldom/xmldom": "^0.8.6",
|
|
37
|
+
"camelcase": "^6.2.0",
|
|
38
|
+
"node-forge": "^1.3.0",
|
|
39
|
+
"node-rsa": "^1.1.1",
|
|
40
|
+
"pako": "^1.0.10",
|
|
41
|
+
"uuid": "^10.0.0",
|
|
42
|
+
"xml": "^1.0.1",
|
|
43
|
+
"xml-crypto": "^6.1.0",
|
|
44
|
+
"xml-escape": "^1.1.0",
|
|
45
|
+
"xpath": "^0.0.32"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@ava/typescript": "^1.1.1",
|
|
49
|
+
"@types/node": "^22.15.17",
|
|
50
|
+
"@types/node-forge": "^1.0.1",
|
|
51
|
+
"@types/node-rsa": "^1.1.1",
|
|
52
|
+
"@types/pako": "^1.0.1",
|
|
53
|
+
"@types/uuid": "^10.0.0",
|
|
54
|
+
"@types/xmldom": "^0.1.31",
|
|
55
|
+
"ava": "^4.1.0",
|
|
56
|
+
"coveralls": "^3.1.1",
|
|
57
|
+
"nyc": "^17.1.0",
|
|
58
|
+
"timekeeper": "^2.2.0",
|
|
59
|
+
"ts-node": "^10.9.2",
|
|
60
|
+
"tslint": "^6.1.3",
|
|
61
|
+
"typescript": "^4.4.2"
|
|
62
|
+
},
|
|
63
|
+
"ava": {
|
|
64
|
+
"extensions": [
|
|
65
|
+
"ts"
|
|
66
|
+
],
|
|
67
|
+
"require": [
|
|
68
|
+
"ts-node/register"
|
|
69
|
+
],
|
|
70
|
+
"files": [
|
|
71
|
+
"!**/*.d.ts"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|