@blazedpath/commons 0.0.4
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/README.md +3 -0
- package/blz-base/health/index.js +215 -0
- package/blz-base/index.js +1466 -0
- package/blz-cache/LruCache.js +44 -0
- package/blz-cache/index.js +29 -0
- package/blz-config/index.js +434 -0
- package/blz-core/index.js +364 -0
- package/blz-cryptography/index.js +54 -0
- package/blz-datetimes/index.js +356 -0
- package/blz-file/example.dat +2545 -0
- package/blz-file/fileService.js +205 -0
- package/blz-file/index.js +94 -0
- package/blz-file/index.test.js +31 -0
- package/blz-file/lab.js +33 -0
- package/blz-hazelcast/index.js +189 -0
- package/blz-hazelcast/lib/credentials.js +25 -0
- package/blz-hazelcast/lib/credentialsFactory.js +12 -0
- package/blz-hazelcast/lib/hazelcastCache.js +234 -0
- package/blz-iterable/index.js +446 -0
- package/blz-json-schema/index.js +11 -0
- package/blz-jwt/index.js +121 -0
- package/blz-kafka/index.js +522 -0
- package/blz-math/index.js +131 -0
- package/blz-mongodb/index.js +326 -0
- package/blz-rds/__test__/scape.test.js +58 -0
- package/blz-rds/blz-rds-executor.js +578 -0
- package/blz-rds/blz-rds-helper.js +310 -0
- package/blz-rds/commands/core/add.js +13 -0
- package/blz-rds/commands/core/and.js +18 -0
- package/blz-rds/commands/core/asc.js +10 -0
- package/blz-rds/commands/core/avg.js +10 -0
- package/blz-rds/commands/core/column-ref.js +8 -0
- package/blz-rds/commands/core/count-distinct.js +10 -0
- package/blz-rds/commands/core/count.js +10 -0
- package/blz-rds/commands/core/decimal.js +8 -0
- package/blz-rds/commands/core/desc.js +10 -0
- package/blz-rds/commands/core/distinct.js +10 -0
- package/blz-rds/commands/core/divide.js +11 -0
- package/blz-rds/commands/core/embedded-exists.js +17 -0
- package/blz-rds/commands/core/embedded-select.js +17 -0
- package/blz-rds/commands/core/equals.js +9 -0
- package/blz-rds/commands/core/false.js +8 -0
- package/blz-rds/commands/core/greater-or-equal.js +9 -0
- package/blz-rds/commands/core/greater.js +9 -0
- package/blz-rds/commands/core/in.js +9 -0
- package/blz-rds/commands/core/integer.js +8 -0
- package/blz-rds/commands/core/is-not-null.js +11 -0
- package/blz-rds/commands/core/is-null-or-value.js +10 -0
- package/blz-rds/commands/core/is-null.js +11 -0
- package/blz-rds/commands/core/less-or-equal.js +9 -0
- package/blz-rds/commands/core/less-unary.js +12 -0
- package/blz-rds/commands/core/less.js +9 -0
- package/blz-rds/commands/core/like.js +12 -0
- package/blz-rds/commands/core/max.js +10 -0
- package/blz-rds/commands/core/min.js +10 -0
- package/blz-rds/commands/core/multiply.js +13 -0
- package/blz-rds/commands/core/not-equals.js +9 -0
- package/blz-rds/commands/core/not-in.js +9 -0
- package/blz-rds/commands/core/not.js +13 -0
- package/blz-rds/commands/core/null.js +8 -0
- package/blz-rds/commands/core/nvl.js +11 -0
- package/blz-rds/commands/core/or.js +13 -0
- package/blz-rds/commands/core/parameter.js +34 -0
- package/blz-rds/commands/core/remainder.js +16 -0
- package/blz-rds/commands/core/string.js +8 -0
- package/blz-rds/commands/core/subtract.js +13 -0
- package/blz-rds/commands/core/sum.js +10 -0
- package/blz-rds/commands/core/true.js +8 -0
- package/blz-rds/commands/core/tuple.js +13 -0
- package/blz-rds/commands/datetimes/add-days.js +11 -0
- package/blz-rds/commands/datetimes/add-hours.js +11 -0
- package/blz-rds/commands/datetimes/add-milliseconds.js +11 -0
- package/blz-rds/commands/datetimes/add-minutes.js +11 -0
- package/blz-rds/commands/datetimes/add-months.js +11 -0
- package/blz-rds/commands/datetimes/add-seconds.js +11 -0
- package/blz-rds/commands/datetimes/add-years.js +11 -0
- package/blz-rds/commands/datetimes/date-diff.js +11 -0
- package/blz-rds/commands/datetimes/date.js +12 -0
- package/blz-rds/commands/datetimes/datetime-diff.js +11 -0
- package/blz-rds/commands/datetimes/datetime.js +15 -0
- package/blz-rds/commands/datetimes/day.js +10 -0
- package/blz-rds/commands/datetimes/hour.js +10 -0
- package/blz-rds/commands/datetimes/millisecond.js +10 -0
- package/blz-rds/commands/datetimes/minute.js +10 -0
- package/blz-rds/commands/datetimes/month-text.js +10 -0
- package/blz-rds/commands/datetimes/month.js +10 -0
- package/blz-rds/commands/datetimes/now.js +9 -0
- package/blz-rds/commands/datetimes/second.js +10 -0
- package/blz-rds/commands/datetimes/subtract-days.js +11 -0
- package/blz-rds/commands/datetimes/subtract-hours.js +11 -0
- package/blz-rds/commands/datetimes/subtract-milliseconds.js +11 -0
- package/blz-rds/commands/datetimes/subtract-minutes.js +11 -0
- package/blz-rds/commands/datetimes/subtract-seconds.js +11 -0
- package/blz-rds/commands/datetimes/time-diff.js +11 -0
- package/blz-rds/commands/datetimes/time.js +13 -0
- package/blz-rds/commands/datetimes/today.js +9 -0
- package/blz-rds/commands/datetimes/week-day-text.js +10 -0
- package/blz-rds/commands/datetimes/week-day.js +10 -0
- package/blz-rds/commands/datetimes/week.js +10 -0
- package/blz-rds/commands/datetimes/year.js +10 -0
- package/blz-rds/commands/math/abs.js +10 -0
- package/blz-rds/commands/math/acos.js +10 -0
- package/blz-rds/commands/math/asin.js +10 -0
- package/blz-rds/commands/math/atan.js +10 -0
- package/blz-rds/commands/math/atan2.js +11 -0
- package/blz-rds/commands/math/ceil.js +10 -0
- package/blz-rds/commands/math/cos.js +10 -0
- package/blz-rds/commands/math/cosh.js +10 -0
- package/blz-rds/commands/math/exp.js +10 -0
- package/blz-rds/commands/math/floor.js +10 -0
- package/blz-rds/commands/math/log.js +18 -0
- package/blz-rds/commands/math/log10.js +10 -0
- package/blz-rds/commands/math/pow.js +11 -0
- package/blz-rds/commands/math/random.js +9 -0
- package/blz-rds/commands/math/round.js +18 -0
- package/blz-rds/commands/math/sign.js +10 -0
- package/blz-rds/commands/math/sin.js +10 -0
- package/blz-rds/commands/math/sinh.js +10 -0
- package/blz-rds/commands/math/sqrt.js +10 -0
- package/blz-rds/commands/math/tan.js +10 -0
- package/blz-rds/commands/math/tanh.js +10 -0
- package/blz-rds/commands/math/trunc.js +18 -0
- package/blz-rds/commands/strings/concat.js +20 -0
- package/blz-rds/commands/strings/contains.js +12 -0
- package/blz-rds/commands/strings/ends-with.js +12 -0
- package/blz-rds/commands/strings/index-of.js +11 -0
- package/blz-rds/commands/strings/is-null-or-empty.js +11 -0
- package/blz-rds/commands/strings/is-null-or-white-space.js +11 -0
- package/blz-rds/commands/strings/join.js +22 -0
- package/blz-rds/commands/strings/last-index-of.js +11 -0
- package/blz-rds/commands/strings/length.js +10 -0
- package/blz-rds/commands/strings/pad-left.js +20 -0
- package/blz-rds/commands/strings/pad-right.js +20 -0
- package/blz-rds/commands/strings/replace.js +12 -0
- package/blz-rds/commands/strings/starts-with.js +12 -0
- package/blz-rds/commands/strings/substring.js +12 -0
- package/blz-rds/commands/strings/to-lower.js +10 -0
- package/blz-rds/commands/strings/to-upper.js +10 -0
- package/blz-rds/commands/strings/trim-end.js +10 -0
- package/blz-rds/commands/strings/trim-start.js +10 -0
- package/blz-rds/commands/strings/trim.js +10 -0
- package/blz-rds/index.js +744 -0
- package/blz-rds-mysql/base.js +857 -0
- package/blz-rds-mysql/connection-manager.js +129 -0
- package/blz-rds-mysql/execute-bulk-insert.js +35 -0
- package/blz-rds-mysql/execute-bulk-merge.js +45 -0
- package/blz-rds-mysql/execute-non-query.js +34 -0
- package/blz-rds-mysql/execute-query.js +50 -0
- package/blz-rds-mysql/index.js +41 -0
- package/blz-rds-mysql/stored-procedure.js +207 -0
- package/blz-rds-mysql/syntaxis.json +114 -0
- package/blz-rds-mysqlx/base.js +846 -0
- package/blz-rds-mysqlx/connection-manager.js +141 -0
- package/blz-rds-mysqlx/execute-bulk-insert.js +35 -0
- package/blz-rds-mysqlx/execute-bulk-merge.js +45 -0
- package/blz-rds-mysqlx/execute-non-query.js +29 -0
- package/blz-rds-mysqlx/execute-query.js +39 -0
- package/blz-rds-mysqlx/index.js +41 -0
- package/blz-rds-mysqlx/stored-procedure.js +179 -0
- package/blz-rds-mysqlx/syntaxis.json +105 -0
- package/blz-rds-oracle/index.js +540 -0
- package/blz-rds-oracle/syntaxis.json +112 -0
- package/blz-rds-postgres/base.js +861 -0
- package/blz-rds-postgres/connection-manager.js +225 -0
- package/blz-rds-postgres/execute-bulk-insert.js +81 -0
- package/blz-rds-postgres/execute-bulk-merge.js +93 -0
- package/blz-rds-postgres/execute-non-query.js +23 -0
- package/blz-rds-postgres/execute-query.js +37 -0
- package/blz-rds-postgres/index.js +41 -0
- package/blz-rds-postgres/result-set.js +51 -0
- package/blz-rds-postgres/stored-procedure.js +116 -0
- package/blz-rds-postgres/syntaxis.json +114 -0
- package/blz-redis/index.js +217 -0
- package/blz-redis/lib/redisCache.js +265 -0
- package/blz-regex/index.js +25 -0
- package/blz-security/.eslintrc.js +15 -0
- package/blz-security/__test__/AuthorizationKpn.yaml +1043 -0
- package/blz-security/__test__/FinancingSetting.yaml +177 -0
- package/blz-security/__test__/KpnConfigPortal.yaml +330 -0
- package/blz-security/__test__/OrderManagement.yaml +5190 -0
- package/blz-security/__test__/Security.yaml +128 -0
- package/blz-security/__test__/autorization.test.js +105 -0
- package/blz-security/__test__/orderManagement.test.js +26 -0
- package/blz-security/__test__/secureUrl.test.js +79 -0
- package/blz-security/__test__/solveMergeRule.test.js +109 -0
- package/blz-security/__test__/sqlInjectionGuard.test.js +203 -0
- package/blz-security/__test__/xssGuard.test.js +204 -0
- package/blz-security/authorizationService.js +536 -0
- package/blz-security/config/global.js +8 -0
- package/blz-security/config/welcome +8 -0
- package/blz-security/doc/README.md +75 -0
- package/blz-security/filescanner/index.js +46 -0
- package/blz-security/helpers/consts.js +229 -0
- package/blz-security/helpers/utils.js +267 -0
- package/blz-security/implementations/cache.js +90 -0
- package/blz-security/implementations/oidc.js +404 -0
- package/blz-security/implementations/pkceCacheStore.js +23 -0
- package/blz-security/implementations/saml.js +10 -0
- package/blz-security/implementations/uma.js +63 -0
- package/blz-security/implementations/webAuthn.js +9 -0
- package/blz-security/implementations/wstg.js +72 -0
- package/blz-security/index.js +77 -0
- package/blz-security/lab/index.js +27 -0
- package/blz-security/middleware/HapiServerAzureAd.js +641 -0
- package/blz-security/middleware/HapiServerKeycloak.js +840 -0
- package/blz-security/middleware/HapiServerSimToken.js +247 -0
- package/blz-security/middleware/hapi.js +515 -0
- package/blz-security/middleware/hapiServer.js +974 -0
- package/blz-security/navigationMemoryRepository.js +15 -0
- package/blz-security/navigationMongoDbRepository.js +73 -0
- package/blz-security/secureUrlService.js +47 -0
- package/blz-security/securityService.js +409 -0
- package/blz-security/sqlInjectionGuard.js +162 -0
- package/blz-security/templates/forbidden.html +0 -0
- package/blz-security/templates/session-iframe-azure-ad.html +7 -0
- package/blz-security/templates/session-iframe.html +73 -0
- package/blz-security/templates/unauthorized.html +1 -0
- package/blz-security/xssGuard.js +87 -0
- package/blz-strings/index.js +167 -0
- package/blz-uuid/index.js +7 -0
- package/blz-yaml/index.js +19 -0
- package/index.js +84 -0
- package/package.json +97 -0
- package/process-managers/index.js +422 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://openid.net/specs/openid-connect-core-1_0.html
|
|
3
|
+
* @description OpenID Connect Core
|
|
4
|
+
* @version 1.0
|
|
5
|
+
* @param OP OpenId Provider
|
|
6
|
+
* @param RP Relying Party (Client)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig
|
|
11
|
+
* @description OP configuration document.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
const OIDC_DISCOVERY = '/.well-known/openid-configuration'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @description Encrypt with AES the word "BLAZEDPATH" with the same secret key in md5 and the output to be base64.
|
|
18
|
+
* @argument md5 E6F712AA790EE519C2E39177576CD0F0
|
|
19
|
+
* @argument output base64
|
|
20
|
+
*/
|
|
21
|
+
const SIGNATURE = 'LSL/e9tVTTK5VovRt9qQgg=='
|
|
22
|
+
/**
|
|
23
|
+
* @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
|
|
24
|
+
* @description Document listing OP endpoint URLs.
|
|
25
|
+
*/
|
|
26
|
+
const METADATA = [
|
|
27
|
+
{
|
|
28
|
+
name: 'issuer',
|
|
29
|
+
description: 'URL using the https scheme with no query or fragment component that the OP asserts as its Issuer Identifier.',
|
|
30
|
+
type: 'REQUIRED'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'authorization_endpoint',
|
|
34
|
+
description: 'URL of the OP OAuth 2.0 Authorization Endpoint.',
|
|
35
|
+
type: 'REQUIRED'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'token_endpoint',
|
|
39
|
+
description: 'URL of the OP OAuth 2.0 Token Endpoint.',
|
|
40
|
+
type: 'REQUIRED'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'userinfo_endpoint',
|
|
44
|
+
description: 'URL of the OP UserInfo Endpoint.',
|
|
45
|
+
type: 'RECOMMENDED'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'jwks_uri',
|
|
49
|
+
description: 'URL of the OP JSON Web Key Set [JWK] document.',
|
|
50
|
+
type: 'REQUIRED'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'registration_endpoint',
|
|
54
|
+
description: 'URL of the OP Dynamic Client Registration Endpoint.',
|
|
55
|
+
type: 'RECOMMENDED'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'scopes_supported',
|
|
59
|
+
description: 'JSON array containing a list of the OAuth 2.0 [RFC6749] scope values that this server supports.',
|
|
60
|
+
type: 'RECOMMENDED'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'response_types_supported',
|
|
64
|
+
description: 'JSON array containing a list of the OAuth 2.0 response_type values that this OP supports.',
|
|
65
|
+
type: 'REQUIRED'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'response_modes_supported',
|
|
69
|
+
description: 'JSON array containing a list of the OAuth 2.0 response_mode values that this OP supports',
|
|
70
|
+
type: 'OPTIONAL'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'grant_types_supported',
|
|
74
|
+
description: 'JSON array containing a list of the OAuth 2.0 Grant Type values that this OP supports.',
|
|
75
|
+
type: 'OPTIONAL'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'acr_values_supported',
|
|
79
|
+
description: 'JSON array containing a list of the Authentication Context Class References that this OP supports.',
|
|
80
|
+
type: 'OPTIONAL'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'subject_types_supported',
|
|
84
|
+
description: 'JSON array containing a list of the Subject Identifier types that this OP supports.',
|
|
85
|
+
type: 'REQUIRED'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'id_token_signing_alg_values_supported',
|
|
89
|
+
description: 'JSON array containing a list of the JWS signing algorithms supported by the OP for the ID Token to encode the Claims in a JWT.',
|
|
90
|
+
type: 'REQUIRED'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'id_token_encryption_alg_values_supported',
|
|
94
|
+
description: 'JSON array containing a list of the JWE encryption algorithms supported by the OP for the ID Token to encode the Claims in a JWT.',
|
|
95
|
+
type: 'OPTIONAL'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'id_token_encryption_enc_values_supported',
|
|
99
|
+
description: 'JSON array containing a list of the JWE encryption algorithms supported by the OP for the ID Token to encode the Claims in a JWT.',
|
|
100
|
+
type: 'OPTIONAL'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'userinfo_signing_alg_values_supported',
|
|
104
|
+
description: 'JSON array containing a list of the JWS [JWS] signing algorithms [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT.',
|
|
105
|
+
type: 'OPTIONAL'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'userinfo_encryption_alg_values_supported',
|
|
109
|
+
description: 'JSON array containing a list of the JWE [JWE] encryption algorithms [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT ',
|
|
110
|
+
type: 'OPTIONAL'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'userinfo_encryption_enc_values_supported',
|
|
114
|
+
description: 'JSON array containing a list of the JWE encryption algorithms [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT.',
|
|
115
|
+
type: 'OPTIONAL'
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'request_object_signing_alg_values_supported',
|
|
119
|
+
description: 'JSON array containing a list of the JWS signing algorithms supported by the OP for Request Objects.',
|
|
120
|
+
type: 'OPTIONAL'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'request_object_encryption_alg_values_supported',
|
|
124
|
+
description: 'JSON array containing a list of the JWE encryption algorithms supported by the OP for Request Objects.',
|
|
125
|
+
type: 'OPTIONAL'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'request_object_encryption_enc_values_supported',
|
|
129
|
+
description: 'JSON array containing a list of the JWE encryption algorithms supported by the OP for Request Objects',
|
|
130
|
+
type: 'OPTIONAL'
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'token_endpoint_auth_methods_supported',
|
|
134
|
+
description: 'JSON array containing a list of Client Authentication methods supported by this Token Endpoint.',
|
|
135
|
+
type: 'OPTIONAL'
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'token_endpoint_auth_signing_alg_values_supported',
|
|
139
|
+
description: 'JSON array containing a list of the JWS signing algorithms supported by the Token Endpoint for the signature on the JWT.',
|
|
140
|
+
type: 'OPTIONAL'
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'display_values_supported',
|
|
144
|
+
description: 'JSON array containing a list of the display parameter values that the OP supports',
|
|
145
|
+
type: 'OPTIONAL'
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'claim_types_supported',
|
|
149
|
+
description: 'JSON array containing a list of the Claim Types that the OP supports.',
|
|
150
|
+
type: 'OPTIONAL'
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'claims_supported',
|
|
154
|
+
description: 'JSON array containing a list of the Claim Names of the Claims that the OP may be able to supply values for.',
|
|
155
|
+
type: 'RECOMMENDED'
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'service_documentation',
|
|
159
|
+
description: 'URL of a page containing human-readable information that developers might want or need to know when using the OP.',
|
|
160
|
+
type: 'OPTIONAL'
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'claims_locales_supported',
|
|
164
|
+
description: 'Languages and scripts supported for values in Claims being returned.',
|
|
165
|
+
type: 'OPTIONAL'
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'ui_locales_supported',
|
|
169
|
+
description: 'Languages and scripts supported for the user interface.',
|
|
170
|
+
type: 'OPTIONAL'
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'claims_parameter_supported',
|
|
174
|
+
description: 'Boolean value specifying whether the OP supports use of the claims parameter.',
|
|
175
|
+
type: 'OPTIONAL'
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'request_parameter_supported',
|
|
179
|
+
description: 'Boolean value specifying whether the OP supports use of the request parameter.',
|
|
180
|
+
type: 'OPTIONAL'
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'request_uri_parameter_supported',
|
|
184
|
+
description: 'Boolean value specifying whether the OP supports use of the request_uri parameter.',
|
|
185
|
+
type: 'OPTIONAL'
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'require_request_uri_registration',
|
|
189
|
+
description: 'Boolean value specifying whether the OP requires any request_uri values used to be pre-registered using the request_uris registration parameter.',
|
|
190
|
+
type: 'OPTIONAL'
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'op_policy_uri',
|
|
194
|
+
description: 'URL that the OP provides to the person registering the Client to read about the OP requirements on how the Relying Party can use the data provided by the OP.',
|
|
195
|
+
type: 'OPTIONAL'
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'op_tos_uri',
|
|
199
|
+
description: 'URL that the OP provides to the person registering the Client to read about OP terms of service',
|
|
200
|
+
type: 'OPTIONAL'
|
|
201
|
+
},
|
|
202
|
+
// @see https://openid.net/specs/openid-connect-session-1_0.html
|
|
203
|
+
{
|
|
204
|
+
name: 'check_session_iframe',
|
|
205
|
+
description: 'URL of an OP iframe that supports cross-origin communications for session state information with the RP Client',
|
|
206
|
+
type: 'OPTIONAL'
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'end_session_endpoint',
|
|
210
|
+
description: 'OAuth logout URI that the client can use to initiate logout on the server.',
|
|
211
|
+
type: 'OPTIONAL'
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'backchannel_logout_supported',
|
|
215
|
+
description: 'Boolean value specifying whether the OP supports back-channel logout.',
|
|
216
|
+
type: 'OPTIONAL'
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: 'backchannel_logout_session_supported',
|
|
220
|
+
description: 'Boolean value specifying whether the OP can pass a sid (session ID) Claim in the Logout Token to identify the RP session with the OP.',
|
|
221
|
+
type: 'OPTIONAL'
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
|
|
225
|
+
module.exports = {
|
|
226
|
+
METADATA,
|
|
227
|
+
OIDC_DISCOVERY,
|
|
228
|
+
SIGNATURE
|
|
229
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
// const Boxen = require('boxen')
|
|
2
|
+
const Fs = require('fs')
|
|
3
|
+
const Handlebars = require('handlebars')
|
|
4
|
+
const Path = require('path')
|
|
5
|
+
const jsonpath = require('jsonpath')
|
|
6
|
+
// const { startupBoxOptions } = require('../config/global')
|
|
7
|
+
const BlzConfig = require('../../blz-config/index')
|
|
8
|
+
|
|
9
|
+
const hasTracing = process.env.TRACING || false
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @name Template
|
|
13
|
+
* @description Function to get the template through the key and context data.
|
|
14
|
+
* @api private
|
|
15
|
+
* @param {String} key
|
|
16
|
+
* @param {*} data Context data
|
|
17
|
+
* @returns {String} Template with html structure.
|
|
18
|
+
*/
|
|
19
|
+
const getTemplate = (key, data) => {
|
|
20
|
+
let file = Path.join(Path.dirname(__dirname), 'templates', `${key}.html`)
|
|
21
|
+
if (!Fs.existsSync(file)) {
|
|
22
|
+
throw new Exception(`The template doesn't exist with the key ${key}`, 'TemplateError', 404)
|
|
23
|
+
}
|
|
24
|
+
file = Fs.readFileSync(file, 'utf-8')
|
|
25
|
+
return Handlebars.compile(file)(data)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @name log
|
|
30
|
+
* @api private
|
|
31
|
+
* @Description Event logging function
|
|
32
|
+
* @param {*} Object with unstructured properties.
|
|
33
|
+
*/
|
|
34
|
+
function log ({ inBox, color, message, withDateTime = false }) {
|
|
35
|
+
const _time = withDateTime ? `[${new Date().toLocaleString()}]` : ''
|
|
36
|
+
message = `${_time} ${message}`
|
|
37
|
+
console.log(message)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @name filePathList
|
|
42
|
+
* @api private
|
|
43
|
+
* @description Get list of files with path and folder name recursively.
|
|
44
|
+
* @param {String} path Absolute path of the folder to be analyzed.
|
|
45
|
+
* @param {String} folderName Name of the folder to compare recursively to get the files.
|
|
46
|
+
* @param {[]} listFiles List of files to be added after the recursive search criteria are met.
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
const filePathList = (path, folderName, listFiles = []) => {
|
|
50
|
+
if (Fs.existsSync(path)) {
|
|
51
|
+
if (!Fs.lstatSync(path).isDirectory()) {
|
|
52
|
+
listFiles.push(path)
|
|
53
|
+
} else {
|
|
54
|
+
const folderList = Fs.readdirSync(path).filter((file) => Fs.statSync(Path.join(path, file)).isDirectory())
|
|
55
|
+
if (folderList && folderList.length > 0) {
|
|
56
|
+
for (const p in folderList) {
|
|
57
|
+
const folder = folderList[p]
|
|
58
|
+
if (folder === folderName) {
|
|
59
|
+
const files = Fs.readdirSync(Path.join(path, folder)).filter((file) => Fs.statSync(Path.join(path, folder, file)).isFile())
|
|
60
|
+
files.map((file) => listFiles.push(Path.join(path, folder, file)))
|
|
61
|
+
}
|
|
62
|
+
filePathList(Path.join(path, folder), folderName, listFiles)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return listFiles
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @name getFullUrl
|
|
72
|
+
* @api private
|
|
73
|
+
* @description Get full URL
|
|
74
|
+
* @param {*} request
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
const getFullUrl = (request) => {
|
|
78
|
+
return `${getProtocol(request)}://${getHost(request)}${getPathname(request)}`
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @name getHost
|
|
83
|
+
* @api private
|
|
84
|
+
* @description Get host URL
|
|
85
|
+
* @param {*} request
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
const getHost = (request) => {
|
|
89
|
+
// Use the host from the request's raw info (never trust x-forwarded headers here)
|
|
90
|
+
return request.info.host;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @name getPathname
|
|
95
|
+
* @api private
|
|
96
|
+
* @description Get pathname URL
|
|
97
|
+
* @param {*} request
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
const getPathname = (request) => {
|
|
101
|
+
const { pathname } = request.url
|
|
102
|
+
return pathname
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @name getProtocol
|
|
107
|
+
* @api private
|
|
108
|
+
* @description Get protocol URL
|
|
109
|
+
* @param {*} request
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
const getProtocol = (request) => {
|
|
113
|
+
return request.server.info.protocol; // usually "http" or "https"
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Event tracing
|
|
118
|
+
* @param {string} logLevel INFO, ERROR or WARN
|
|
119
|
+
* @param {string} message Log message
|
|
120
|
+
*/
|
|
121
|
+
const trace = (logLevel, message) => {
|
|
122
|
+
if (process.env.TRACING || hasTracing) {
|
|
123
|
+
let color = null
|
|
124
|
+
switch (logLevel) {
|
|
125
|
+
case 'ERROR': {
|
|
126
|
+
color = 'red'
|
|
127
|
+
break
|
|
128
|
+
}
|
|
129
|
+
case 'WARN': {
|
|
130
|
+
color = 'yellow'
|
|
131
|
+
break
|
|
132
|
+
}
|
|
133
|
+
default: {
|
|
134
|
+
color = 'green'
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (typeof message === 'object') {
|
|
138
|
+
Object.entries(message).map((entry) => {
|
|
139
|
+
if (entry && entry[0] && entry[1]) {
|
|
140
|
+
log({ message: `${entry[0]}: ${entry[1]}`, withDateTime: true, color })
|
|
141
|
+
}
|
|
142
|
+
return entry
|
|
143
|
+
})
|
|
144
|
+
} else {
|
|
145
|
+
log({ message, withDateTime: true, color })
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const getMappingValues = (data, mappings) => {
|
|
151
|
+
const values = {}
|
|
152
|
+
for (const i in mappings) {
|
|
153
|
+
const mapping = mappings[i]
|
|
154
|
+
try {
|
|
155
|
+
let value = jsonpath.query(data, mapping.path)
|
|
156
|
+
if (mapping.pathIndex !== undefined) {
|
|
157
|
+
value = value[mapping.pathIndex]
|
|
158
|
+
}
|
|
159
|
+
if (mapping.regex) {
|
|
160
|
+
const regex = new RegExp(mapping.regex)
|
|
161
|
+
value = regex.exec(value)
|
|
162
|
+
if (mapping.regexGroup !== undefined) {
|
|
163
|
+
value = value[mapping.regexGroup]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (mapping.split) {
|
|
167
|
+
value = value.split(mapping.split)
|
|
168
|
+
}
|
|
169
|
+
if (mapping.replaceRules) {
|
|
170
|
+
const replacement = []
|
|
171
|
+
for (const v in value) {
|
|
172
|
+
const oldValue = value[v]
|
|
173
|
+
const rule = mapping.replaceRules.find(x => x.oldValue === oldValue)
|
|
174
|
+
if (rule) {
|
|
175
|
+
replacement.push(rule.newValue)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
value = replacement
|
|
179
|
+
}
|
|
180
|
+
values[mapping.itemKey] = value
|
|
181
|
+
} catch (error) {
|
|
182
|
+
throw new Error(`User info mapping ${JSON.stringify(mapping)} error: ${error}`)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return values
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Handling exceptions
|
|
190
|
+
* @param {string} message
|
|
191
|
+
* @param {string} name
|
|
192
|
+
* @param {integer} code
|
|
193
|
+
*/
|
|
194
|
+
class Exception {
|
|
195
|
+
constructor(message, name, code) {
|
|
196
|
+
this.message = message
|
|
197
|
+
this.name = name
|
|
198
|
+
this.code = code
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const getTokenTolerance = function (defaultValue = 30) {
|
|
203
|
+
return parseNumber(process.env.TOKEN_TOLERANCE, defaultValue)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const getRefreshTokenTolerance = function (defaultValue = 0) {
|
|
207
|
+
return parseNumber(process.env.REFRESH_TOKEN_TOLERANCE, defaultValue)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const parseNumber = function (valueToParse, defaultValueIfNaN) {
|
|
211
|
+
return valueToParse && !isNaN(valueToParse)
|
|
212
|
+
? Number(valueToParse)
|
|
213
|
+
: defaultValueIfNaN
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const getCookieName = function (cookieName = '') {
|
|
217
|
+
const config = BlzConfig.getConfig() || {}
|
|
218
|
+
const prefix = (config.authServer && config.authServer.sessionCookiesPrefix) || ''
|
|
219
|
+
return prefix + cookieName
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const errorResponse = function (h, err, defaultCode = 500) {
|
|
223
|
+
const { code, name, message } = err
|
|
224
|
+
if (process.env.NODE_ENV === 'production') {
|
|
225
|
+
trace('ERROR', { name, message })
|
|
226
|
+
return h.response({ name }).code(parseInt(code) || defaultCode).takeover()
|
|
227
|
+
} else {
|
|
228
|
+
return h.response({ name, message }).code(parseInt(code) || defaultCode).takeover()
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const isBase64 = function(str) {
|
|
233
|
+
if (typeof str !== 'string') return false;
|
|
234
|
+
|
|
235
|
+
// Verificás si tiene la forma típica de Base64 (múltiplo de 4, solo caracteres válidos)
|
|
236
|
+
const base64Regex = /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/;
|
|
237
|
+
|
|
238
|
+
if (!base64Regex.test(str)) return false;
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
// Intentás decodificarla
|
|
242
|
+
const decoded = Buffer.from(str, 'base64').toString('utf8');
|
|
243
|
+
|
|
244
|
+
// Verificás que al re-codificar vuelva a ser igual (esto filtra algunas falsos positivos)
|
|
245
|
+
return Buffer.from(decoded, 'utf8').toString('base64') === str.replace(/=*$/, '');
|
|
246
|
+
} catch (err) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
module.exports = {
|
|
252
|
+
Exception,
|
|
253
|
+
filePathList,
|
|
254
|
+
getCookieName,
|
|
255
|
+
getFullUrl,
|
|
256
|
+
getHost,
|
|
257
|
+
getMappingValues,
|
|
258
|
+
getPathname,
|
|
259
|
+
getProtocol,
|
|
260
|
+
getRefreshTokenTolerance,
|
|
261
|
+
getTemplate,
|
|
262
|
+
getTokenTolerance,
|
|
263
|
+
log,
|
|
264
|
+
trace,
|
|
265
|
+
errorResponse,
|
|
266
|
+
isBase64
|
|
267
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const { LRUCache } = require('lru-cache')
|
|
2
|
+
const IoRedis = require('ioredis')
|
|
3
|
+
|
|
4
|
+
class LruCache {
|
|
5
|
+
constructor () {
|
|
6
|
+
this._cache = new LRUCache({ max: 500, maxSize: 5000, ttl: 1000 * 60 * 60 * 3, sizeCalculation: (value, key) => { return 1 } })
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @name set
|
|
11
|
+
* @api private
|
|
12
|
+
* @description Maximum age in ms.
|
|
13
|
+
* @param {*} key key to be cached.
|
|
14
|
+
* @param {*} value value to be cached.
|
|
15
|
+
* @param {*} maxAge Maximum age in ms.
|
|
16
|
+
*/
|
|
17
|
+
async set (key, value, maxAge) {
|
|
18
|
+
this._cache.set(key, value, maxAge)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @name get
|
|
23
|
+
* @api private
|
|
24
|
+
* @description Get the value that was cached.
|
|
25
|
+
* @param {*} key
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
async get (key) {
|
|
29
|
+
return this._cache.get(key)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @name del
|
|
34
|
+
* @api private
|
|
35
|
+
* @description It was removing the value that was in the cache.
|
|
36
|
+
* @param {*} key
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
async del (key) {
|
|
40
|
+
this._cache.delete(key)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class RedisCache {
|
|
45
|
+
constructor (cnx) {
|
|
46
|
+
this._cache = new IoRedis(cnx)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @name set
|
|
51
|
+
* @api private
|
|
52
|
+
* @description Maximum age in ms.
|
|
53
|
+
* @param {*} key key to be cached.
|
|
54
|
+
* @param {*} value value to be cached.
|
|
55
|
+
* @param {*} maxAge Maximum age in ms.
|
|
56
|
+
*/
|
|
57
|
+
async set (key, value, maxAge) {
|
|
58
|
+
// https://stackoverflow.com/questions/41237001/nodejs-ioredis-how-to-set-expire-time-for-a-key
|
|
59
|
+
const _value = JSON.stringify(value)
|
|
60
|
+
await this._cache.set(key, _value, 'EX', maxAge / 1000)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @name get
|
|
65
|
+
* @api private
|
|
66
|
+
* @description Get the value that was cached.
|
|
67
|
+
* @param {*} key
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
async get (key) {
|
|
71
|
+
const _value = await this._cache.get(key)
|
|
72
|
+
return _value ? JSON.parse(_value) : _value
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @name del
|
|
77
|
+
* @api private
|
|
78
|
+
* @description It was removing the value that was in the cache.
|
|
79
|
+
* @param {*} key
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
async del (key) {
|
|
83
|
+
await this._cache.del(key)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
RedisCache,
|
|
89
|
+
LruCache
|
|
90
|
+
}
|