@tsed/oidc-provider-plugin-wildcard-redirect-uri 8.0.0-alpha.4 → 8.0.0-alpha.6
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/package.json +11 -12
- package/lib/cjs/OidcWildcardRedirectUriModule.js +0 -82
- package/lib/cjs/OidcWildcardRedirectUriModule.js.map +0 -1
- package/lib/cjs/index.js +0 -9
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/utils/wildcardRedirectUriAllowed.js +0 -22
- package/lib/cjs/utils/wildcardRedirectUriAllowed.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/OidcWildcardRedirectUriModule.d.ts +0 -21
- package/lib/types-esm/index.d.ts +0 -5
- package/lib/types-esm/utils/wildcardRedirectUriAllowed.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/oidc-provider-plugin-wildcard-redirect-uri",
|
|
3
3
|
"description": "A plugin to support wildcard in the redirect uri whitelist",
|
|
4
|
-
"type": "
|
|
5
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "8.0.0-alpha.6",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
|
-
"main": "./lib/
|
|
7
|
+
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
9
9
|
"typings": "./lib/types/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./lib/types/index.d.ts",
|
|
13
13
|
"import": "./lib/esm/index.js",
|
|
14
|
-
"require": "./lib/cjs/index.js",
|
|
15
14
|
"default": "./lib/cjs/index.js"
|
|
16
15
|
}
|
|
17
16
|
},
|
|
@@ -28,11 +27,11 @@
|
|
|
28
27
|
"wildcard": "2.0.0"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
|
-
"@tsed/barrels": "8.0.0-alpha.
|
|
32
|
-
"@tsed/core": "8.0.0-alpha.
|
|
33
|
-
"@tsed/di": "8.0.0-alpha.
|
|
34
|
-
"@tsed/oidc-provider": "8.0.0-alpha.
|
|
35
|
-
"@tsed/typescript": "8.0.0-alpha.
|
|
30
|
+
"@tsed/barrels": "8.0.0-alpha.6",
|
|
31
|
+
"@tsed/core": "8.0.0-alpha.6",
|
|
32
|
+
"@tsed/di": "8.0.0-alpha.6",
|
|
33
|
+
"@tsed/oidc-provider": "8.0.0-alpha.6",
|
|
34
|
+
"@tsed/typescript": "8.0.0-alpha.6",
|
|
36
35
|
"@types/psl": "^1.1.3",
|
|
37
36
|
"@types/uuid": "9.0.8",
|
|
38
37
|
"eslint": "^8.57.0",
|
|
@@ -40,10 +39,10 @@
|
|
|
40
39
|
"vitest": "2.0.4"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
|
-
"@tsed/core": "8.0.0-alpha.
|
|
44
|
-
"@tsed/di": "8.0.0-alpha.
|
|
42
|
+
"@tsed/core": "8.0.0-alpha.6",
|
|
43
|
+
"@tsed/di": "8.0.0-alpha.6",
|
|
45
44
|
"@tsed/logger": ">=6.7.5",
|
|
46
|
-
"@tsed/oidc-provider": "8.0.0-alpha.
|
|
45
|
+
"@tsed/oidc-provider": "8.0.0-alpha.6",
|
|
47
46
|
"oidc-provider": ">=8.0.0"
|
|
48
47
|
},
|
|
49
48
|
"peerDependenciesMeta": {
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OidcWildcardRedirectUriModule = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const di_1 = require("@tsed/di");
|
|
6
|
-
const logger_1 = require("@tsed/logger");
|
|
7
|
-
const oidc_provider_1 = require("@tsed/oidc-provider");
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
const psl_1 = tslib_1.__importDefault(require("psl"));
|
|
10
|
-
const wildcardRedirectUriAllowed_js_1 = require("./utils/wildcardRedirectUriAllowed.js");
|
|
11
|
-
let OidcWildcardRedirectUriModule = class OidcWildcardRedirectUriModule {
|
|
12
|
-
constructor(module) {
|
|
13
|
-
this.module = module;
|
|
14
|
-
}
|
|
15
|
-
$onCreateOIDC(provider) {
|
|
16
|
-
if (this.enabled) {
|
|
17
|
-
const { redirectUriAllowed, postLogoutRedirectUriAllowed } = provider.Client.prototype;
|
|
18
|
-
provider.Client.prototype.redirectUriAllowed = (0, wildcardRedirectUriAllowed_js_1.wildcardRedirectUriAllowed)(redirectUriAllowed, "redirectUris");
|
|
19
|
-
provider.Client.prototype.postLogoutRedirectUriAllowed = (0, wildcardRedirectUriAllowed_js_1.wildcardRedirectUriAllowed)(postLogoutRedirectUriAllowed, "postLogoutRedirectUris");
|
|
20
|
-
this.logger.warn("⚠️⚠️⚠️ OIDC Wildcard Uris plugin is ENABLED ⚠️⚠️⚠️");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
$alterOidcConfiguration(config) {
|
|
24
|
-
if (this.enabled) {
|
|
25
|
-
const actualProperties = config?.extraClientMetadata?.properties || [];
|
|
26
|
-
config.extraClientMetadata = {
|
|
27
|
-
properties: [...actualProperties, "redirect_uris", "post_logout_redirect_uris"],
|
|
28
|
-
validator: this.validator.bind(this)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return Promise.resolve(config);
|
|
32
|
-
}
|
|
33
|
-
validator(ctx, key, value) {
|
|
34
|
-
if (key === "redirect_uris") {
|
|
35
|
-
for (const redirectUri of value) {
|
|
36
|
-
if (redirectUri.includes("*")) {
|
|
37
|
-
const { hostname, href } = new URL(redirectUri);
|
|
38
|
-
if (href.split("*").length !== 2) {
|
|
39
|
-
throw new this.module.errors.InvalidClientMetadata("redirect_uris with a wildcard may only contain a single one");
|
|
40
|
-
}
|
|
41
|
-
if (!hostname.includes("*")) {
|
|
42
|
-
throw new this.module.errors.InvalidClientMetadata("redirect_uris may only have a wildcard in the hostname");
|
|
43
|
-
}
|
|
44
|
-
if (!psl_1.default.get(hostname.split("*.")[1])) {
|
|
45
|
-
throw new this.module.errors.InvalidClientMetadata("redirect_uris with a wildcard must not match an eTLD+1 of a known public suffix domain");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else if (key === "post_logout_redirect_uris") {
|
|
51
|
-
for (const postLogoutRedirectUri of value) {
|
|
52
|
-
if (postLogoutRedirectUri.includes("*")) {
|
|
53
|
-
const { hostname, href } = new URL(postLogoutRedirectUri);
|
|
54
|
-
if (href.split("*").length !== 2) {
|
|
55
|
-
throw new this.module.errors.InvalidClientMetadata("post_logout_redirect_uris with a wildcard may only contain a single one");
|
|
56
|
-
}
|
|
57
|
-
if (!hostname.includes("*")) {
|
|
58
|
-
throw new this.module.errors.InvalidClientMetadata("post_logout_redirect_uris may only have a wildcard in the hostname");
|
|
59
|
-
}
|
|
60
|
-
if (!psl_1.default.get(hostname.split("*.")[1])) {
|
|
61
|
-
throw new this.module.errors.InvalidClientMetadata("post_logout_redirect_uris with a wildcard must not match an eTLD+1 of a known public suffix domain");
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
tslib_1.__decorate([
|
|
69
|
-
(0, di_1.Constant)("oidc.plugins.wildcard.enabled", false),
|
|
70
|
-
tslib_1.__metadata("design:type", Boolean)
|
|
71
|
-
], OidcWildcardRedirectUriModule.prototype, "enabled", void 0);
|
|
72
|
-
tslib_1.__decorate([
|
|
73
|
-
(0, di_1.Inject)(logger_1.Logger),
|
|
74
|
-
tslib_1.__metadata("design:type", logger_1.Logger)
|
|
75
|
-
], OidcWildcardRedirectUriModule.prototype, "logger", void 0);
|
|
76
|
-
OidcWildcardRedirectUriModule = tslib_1.__decorate([
|
|
77
|
-
(0, di_1.Module)(),
|
|
78
|
-
tslib_1.__param(0, (0, di_1.Inject)(oidc_provider_1.OIDC_PROVIDER_NODE_MODULE)),
|
|
79
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
80
|
-
], OidcWildcardRedirectUriModule);
|
|
81
|
-
exports.OidcWildcardRedirectUriModule = OidcWildcardRedirectUriModule;
|
|
82
|
-
//# sourceMappingURL=OidcWildcardRedirectUriModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OidcWildcardRedirectUriModule.js","sourceRoot":"","sources":["../../src/OidcWildcardRedirectUriModule.ts"],"names":[],"mappings":";;;;AAAA,iCAAkD;AAClD,yCAAoC;AACpC,uDAA4E;AAG5E,aAAa;AACb,sDAAsB;AACtB,yFAAiF;AAa1E,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAOxC,YAAyD,MAAiC;QAAjC,WAAM,GAAN,MAAM,CAA2B;IAAG,CAAC;IAE9F,aAAa,CAAC,QAAkB;QAC9B,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,EAAC,kBAAkB,EAAE,4BAA4B,EAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;YACrF,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,GAAG,IAAA,0DAA0B,EAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;YAC9G,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,4BAA4B,GAAG,IAAA,0DAA0B,EACjF,4BAA4B,EAC5B,wBAAwB,CACzB,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;SACxE;IACH,CAAC;IAED,uBAAuB,CAAC,MAAoB;QAC1C,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,EAAE,mBAAmB,EAAE,UAAU,IAAI,EAAE,CAAC;YAEvE,MAAM,CAAC,mBAAmB,GAAG;gBAC3B,UAAU,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GAAG,IAAI,GAAG,CAAC,qBAAqB,CAAC,CAAC;oBAExD,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;wBAChC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,yEAAyE,CAAC,CAAC;qBAC/H;oBAED,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;wBAC3B,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,oEAAoE,CAAC,CAAC;qBAC1H;oBAED,IAAI,CAAC,aAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;wBACrC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAChD,oGAAoG,CACrG,CAAC;qBACH;iBACF;aACF;SACF;IACH,CAAC;CACF,CAAA;AA7EC;IAAC,IAAA,aAAQ,EAAC,+BAA+B,EAAE,KAAK,CAAC;;8DACvB;AAE1B;IAAC,IAAA,WAAM,EAAC,eAAM,CAAC;sCACG,eAAM;6DAAC;AALd,6BAA6B;IADzC,IAAA,WAAM,GAAE;IAQM,mBAAA,IAAA,WAAM,EAAC,yCAAyB,CAAC,CAAA;;GAPnC,6BAA6B,CA8EzC;AA9EY,sEAA6B"}
|
package/lib/cjs/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
/**
|
|
5
|
-
* @file Automatically generated by @tsed/barrels.
|
|
6
|
-
*/
|
|
7
|
-
tslib_1.__exportStar(require("./OidcWildcardRedirectUriModule.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./utils/wildcardRedirectUriAllowed.js"), exports);
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,6EAAmD;AACnD,gFAAsD"}
|
package/lib/cjs/package.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wildcardRedirectUriAllowed = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const wildcard_1 = tslib_1.__importDefault(require("wildcard"));
|
|
7
|
-
const hasWildcardHost = (redirectUri) => {
|
|
8
|
-
const { hostname } = new URL(redirectUri);
|
|
9
|
-
return hostname.includes("*");
|
|
10
|
-
};
|
|
11
|
-
const wildcardMatches = (redirectUri, wildcardUri) => !!(0, wildcard_1.default)(wildcardUri, redirectUri);
|
|
12
|
-
function wildcardRedirectUriAllowed(originalRedirectUriAllowed, redirectUriOrPostLogoutRedirectUri) {
|
|
13
|
-
return function (redirectUri) {
|
|
14
|
-
if (this[redirectUriOrPostLogoutRedirectUri].some(hasWildcardHost)) {
|
|
15
|
-
const wildcardUris = this[redirectUriOrPostLogoutRedirectUri].filter(hasWildcardHost);
|
|
16
|
-
return wildcardUris.some(wildcardMatches.bind(undefined, redirectUri)) || originalRedirectUriAllowed.call(this, redirectUri);
|
|
17
|
-
}
|
|
18
|
-
return originalRedirectUriAllowed.call(this, redirectUri);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
exports.wildcardRedirectUriAllowed = wildcardRedirectUriAllowed;
|
|
22
|
-
//# sourceMappingURL=wildcardRedirectUriAllowed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wildcardRedirectUriAllowed.js","sourceRoot":"","sources":["../../../src/utils/wildcardRedirectUriAllowed.ts"],"names":[],"mappings":";;;;AAAA,aAAa;AACb,gEAAgC;AAEhC,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC9C,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,WAAmB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAA,kBAAQ,EAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAE3G,SAAgB,0BAA0B,CAAC,0BAA+B,EAAE,kCAA6E;IACvJ,OAAO,UAAU,WAAmB;QAClC,IAAI,IAAI,CAAC,kCAAkC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;YAClE,MAAM,YAAY,GAAG,IAAI,CAAC,kCAAkC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YACtF,OAAO,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SAC9H;QACD,OAAO,0BAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC;AARD,gEAQC"}
|
package/lib/esm/package.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Logger } from "@tsed/logger";
|
|
2
|
-
import { OIDC_PROVIDER_NODE_MODULE, OidcSettings } from "@tsed/oidc-provider";
|
|
3
|
-
import type { default as Provider, KoaContextWithOIDC } from "oidc-provider";
|
|
4
|
-
declare global {
|
|
5
|
-
namespace TsED {
|
|
6
|
-
interface OIDCPluginSettings {
|
|
7
|
-
wildcard: {
|
|
8
|
-
enabled?: boolean;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export declare class OidcWildcardRedirectUriModule {
|
|
14
|
-
protected module: OIDC_PROVIDER_NODE_MODULE;
|
|
15
|
-
readonly enabled: boolean;
|
|
16
|
-
protected logger: Logger;
|
|
17
|
-
constructor(module: OIDC_PROVIDER_NODE_MODULE);
|
|
18
|
-
$onCreateOIDC(provider: Provider): void;
|
|
19
|
-
$alterOidcConfiguration(config: OidcSettings): Promise<OidcSettings>;
|
|
20
|
-
validator(ctx: KoaContextWithOIDC, key: string, value: any): void;
|
|
21
|
-
}
|
package/lib/types-esm/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function wildcardRedirectUriAllowed(originalRedirectUriAllowed: any, redirectUriOrPostLogoutRedirectUri: "redirectUris" | "postLogoutRedirectUris"): (redirectUri: string) => any;
|