@betterportal/auth-default 10.6.20 → 10.6.22
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 +140 -10
- package/bsb-plugin.json +1 -1
- package/lib/account.d.ts +16 -0
- package/lib/account.d.ts.map +1 -0
- package/lib/account.js +274 -0
- package/lib/account.js.map +1 -0
- package/lib/accountUI.d.ts +5 -0
- package/lib/accountUI.d.ts.map +1 -0
- package/lib/accountUI.js +68 -0
- package/lib/accountUI.js.map +1 -0
- package/lib/bp-contracts/org.betterportal.auth.default.json +2031 -707
- package/lib/clientAddress.d.ts +10 -0
- package/lib/clientAddress.d.ts.map +1 -0
- package/lib/clientAddress.js +35 -0
- package/lib/clientAddress.js.map +1 -0
- package/lib/config.d.ts +3 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +28 -0
- package/lib/config.js.map +1 -0
- package/lib/defaultAuthManifest.d.ts +7 -0
- package/lib/defaultAuthManifest.d.ts.map +1 -1
- package/lib/factors.d.ts +18 -0
- package/lib/factors.d.ts.map +1 -0
- package/lib/factors.js +95 -0
- package/lib/factors.js.map +1 -0
- package/lib/identity.d.ts +106 -0
- package/lib/identity.d.ts.map +1 -0
- package/lib/identity.js +315 -0
- package/lib/identity.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/mail.d.ts +19 -0
- package/lib/mail.d.ts.map +1 -0
- package/lib/mail.js +102 -0
- package/lib/mail.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/.bp-generated/registry.d.ts +435 -11
- package/lib/plugins/service-betterportal-auth-default/.bp-generated/registry.d.ts.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/.bp-generated/registry.js +85 -0
- package/lib/plugins/service-betterportal-auth-default/.bp-generated/registry.js.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/GET.d.ts +34 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/GET.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/GET.js +25 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/GET.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/POST.d.ts +42 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/POST.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/POST.js +27 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/POST.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/_renderer.bootstrap5/GET.d.ts +2 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/_renderer.bootstrap5/GET.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/_renderer.bootstrap5/GET.js +2 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/_renderer.bootstrap5/GET.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/_renderer.bootstrap5/POST.d.ts +2 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/_renderer.bootstrap5/POST.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/_renderer.bootstrap5/POST.js +2 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/_renderer.bootstrap5/POST.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/index.d.ts +3 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/index.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/index.js +3 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/account/index.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/login/_renderer.bootstrap5/GET.d.ts.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/bp-routes/login/_renderer.bootstrap5/GET.js +11 -8
- package/lib/plugins/service-betterportal-auth-default/bp-routes/login/_renderer.bootstrap5/GET.js.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/bp-routes/refresh/POST.d.ts +3 -1
- package/lib/plugins/service-betterportal-auth-default/bp-routes/refresh/POST.d.ts.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/bp-routes/refresh/POST.js +10 -23
- package/lib/plugins/service-betterportal-auth-default/bp-routes/refresh/POST.js.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/bp-routes/register/_renderer.bootstrap5/GET.d.ts.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/bp-routes/register/_renderer.bootstrap5/GET.js +2 -2
- package/lib/plugins/service-betterportal-auth-default/bp-routes/register/_renderer.bootstrap5/GET.js.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/GET.d.ts +34 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/GET.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/GET.js +26 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/GET.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/POST.d.ts +31 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/POST.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/POST.js +23 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/POST.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/_renderer.bootstrap5/GET.d.ts +3 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/_renderer.bootstrap5/GET.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/_renderer.bootstrap5/GET.js +36 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/_renderer.bootstrap5/GET.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/index.d.ts +3 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/index.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/index.js +3 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/social/index.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/GET.d.ts +32 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/GET.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/GET.js +39 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/GET.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/POST.d.ts +41 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/POST.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/POST.js +103 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/POST.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/_renderer.bootstrap5/GET.d.ts +3 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/_renderer.bootstrap5/GET.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/_renderer.bootstrap5/GET.js +19 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/_renderer.bootstrap5/GET.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/index.d.ts +3 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/index.d.ts.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/index.js +3 -0
- package/lib/plugins/service-betterportal-auth-default/bp-routes/users/index.js.map +1 -0
- package/lib/plugins/service-betterportal-auth-default/index.d.ts +41 -4
- package/lib/plugins/service-betterportal-auth-default/index.d.ts.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/index.js +205 -9
- package/lib/plugins/service-betterportal-auth-default/index.js.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/loginFlow.d.ts +17 -2
- package/lib/plugins/service-betterportal-auth-default/loginFlow.d.ts.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/loginFlow.js +83 -62
- package/lib/plugins/service-betterportal-auth-default/loginFlow.js.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/logoutFlow.js +1 -1
- package/lib/plugins/service-betterportal-auth-default/logoutFlow.js.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/registrationFlow.d.ts +4 -2
- package/lib/plugins/service-betterportal-auth-default/registrationFlow.d.ts.map +1 -1
- package/lib/plugins/service-betterportal-auth-default/registrationFlow.js +15 -17
- package/lib/plugins/service-betterportal-auth-default/registrationFlow.js.map +1 -1
- package/lib/schemas/service-betterportal-auth-default.json +26 -2
- package/lib/schemas/service-betterportal-auth-default.plugin.json +27 -3
- package/lib/social.d.ts +40 -0
- package/lib/social.d.ts.map +1 -0
- package/lib/social.js +178 -0
- package/lib/social.js.map +1 -0
- package/lib/storage.d.ts +72 -0
- package/lib/storage.d.ts.map +1 -0
- package/lib/storage.js +427 -0
- package/lib/storage.js.map +1 -0
- package/package.json +14 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GET.js","sourceRoot":"","sources":["../../../../../../src/plugins/service-betterportal-auth-default/bp-routes/register/_renderer.bootstrap5/GET.tsx"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAI9B,qFAAqF;AACrF,SAAS,UAAU,CAAC,GAAuB,EAAE,QAAgB;IAC3D,IAAI,CAAC,GAAG;QAAE,OAAO,QAAQ,CAAC;IAC1B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,SAAS,cAAc;IACrB,2EAA2E;IAC3E,2DAA2D;IAC3D,OAAO,EAAE,CAAC;;;;;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QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,2BAA2B,CAAC,CAAC;QACvG,CAAC;QACD,OAAO,CACL,cAAK,KAAK,EAAC,gBAAgB,EAAC,KAAK,EAAC,mBAAmB,YACnD,eAAK,KAAK,EAAC,uBAAuB,yCAAyB,YAAG,IAAI,EAAC,QAAQ,wBAAY,iBAAe,GAClG,CACP,CAAC;IACJ,CAAC;IAED,0CAA0C;IAC1C,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { title, description } from "./index.js";
|
|
2
|
+
import * as av from "anyvali";
|
|
3
|
+
import { type JsonObject } from "@betterportal/framework";
|
|
4
|
+
export declare const operationId = "auth.social.view";
|
|
5
|
+
export declare const auth: {
|
|
6
|
+
required: boolean;
|
|
7
|
+
permissions: never[];
|
|
8
|
+
};
|
|
9
|
+
export declare const cacheHints: {
|
|
10
|
+
ttlSeconds: number;
|
|
11
|
+
varyBy: never[];
|
|
12
|
+
};
|
|
13
|
+
export declare const dependencies: readonly [{
|
|
14
|
+
readonly operationId: "auth.social";
|
|
15
|
+
readonly method: "POST";
|
|
16
|
+
}, {
|
|
17
|
+
readonly operationId: "auth.account";
|
|
18
|
+
readonly method: "POST";
|
|
19
|
+
}];
|
|
20
|
+
export declare const QuerySchema: av.ObjectSchema<{
|
|
21
|
+
code: av.OptionalSchema<av.StringSchema>;
|
|
22
|
+
state: av.OptionalSchema<av.StringSchema>;
|
|
23
|
+
error: av.OptionalSchema<av.StringSchema>;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const ResponseSchema: av.BaseSchema<unknown, JsonObject>;
|
|
26
|
+
declare const _default: import("@betterportal/framework").RouteHandler<Record<string, string>, {
|
|
27
|
+
code?: string | undefined;
|
|
28
|
+
state?: string | undefined;
|
|
29
|
+
error?: string | undefined;
|
|
30
|
+
}, Record<string, string>, Record<string, unknown>, JsonObject, import("../../index.js").PluginFeature, {
|
|
31
|
+
[x: string]: unknown;
|
|
32
|
+
}>;
|
|
33
|
+
export default _default;
|
|
34
|
+
//# sourceMappingURL=GET.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GET.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/social/GET.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAI5E,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAC9C,eAAO,MAAM,IAAI;;;CAAuC,CAAC;AACzD,eAAO,MAAM,UAAU;;;CAAgC,CAAC;AACxD,eAAO,MAAM,YAAY;;;;;;EAA6G,CAAC;AACvI,eAAO,MAAM,WAAW;;;;EAAkH,CAAC;AAC3I,eAAO,MAAM,cAAc,oCAAmB,CAAC;;;;;;;;AAC/C,wBASG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { title, description } from "./index.js";
|
|
2
|
+
import * as av from "anyvali";
|
|
3
|
+
import { JsonObjectSchema } from "@betterportal/framework";
|
|
4
|
+
import { createHandler } from "../../.bp-generated/route-runtime.js";
|
|
5
|
+
import { socialConnections } from "../../../../social.js";
|
|
6
|
+
import { AuthError } from "../../../../identity.js";
|
|
7
|
+
export const operationId = "auth.social.view";
|
|
8
|
+
export const auth = { required: false, permissions: [] };
|
|
9
|
+
export const cacheHints = { ttlSeconds: 0, varyBy: [] };
|
|
10
|
+
export const dependencies = [{ operationId: "auth.social", method: "POST" }, { operationId: "auth.account", method: "POST" }];
|
|
11
|
+
export const QuerySchema = av.object({ code: av.optional(av.string()), state: av.optional(av.string()), error: av.optional(av.string()) });
|
|
12
|
+
export const ResponseSchema = JsonObjectSchema;
|
|
13
|
+
export default createHandler({ response: ResponseSchema, query: QuerySchema }, (ctx) => {
|
|
14
|
+
ctx.responseHeaders?.set("Cache-Control", "no-store");
|
|
15
|
+
ctx.responseHeaders?.set("Referrer-Policy", "no-referrer");
|
|
16
|
+
try {
|
|
17
|
+
return { status: "ok", endpoint: ctx.routeUrl?.("social.index", { absolute: true }) ?? "/social", signedIn: !!ctx.user, code: String(ctx.query.code ?? ""), state: String(ctx.query.state ?? ""), error: String(ctx.query.error ?? ""), connections: socialConnections(ctx.plugin.runtime, { tenantId: ctx.tenant.id, appId: ctx.app.id }).map(c => ({ id: c.id, title: c.kind })) };
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (!(error instanceof AuthError))
|
|
21
|
+
throw error;
|
|
22
|
+
ctx.setStatus?.(error.status);
|
|
23
|
+
return { status: "error", message: error.message, connections: [] };
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=GET.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GET.js","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/social/GET.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAmB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAC9C,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,UAAU,EAAE,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AAK,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IACvX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC;YAAE,MAAM,KAAK,CAAC;QAC/C,GAAG,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACtE,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { title, description } from "./index.js";
|
|
2
|
+
import * as av from "anyvali";
|
|
3
|
+
import { type JsonObject } from "@betterportal/framework";
|
|
4
|
+
export declare const operationId = "auth.social";
|
|
5
|
+
export declare const auth: {
|
|
6
|
+
required: boolean;
|
|
7
|
+
permissions: never[];
|
|
8
|
+
};
|
|
9
|
+
export declare const cacheHints: {
|
|
10
|
+
ttlSeconds: number;
|
|
11
|
+
varyBy: never[];
|
|
12
|
+
};
|
|
13
|
+
export declare const RequestSchema: av.ObjectSchema<{
|
|
14
|
+
action: av.StringSchema;
|
|
15
|
+
connection: av.OptionalSchema<av.StringSchema>;
|
|
16
|
+
id: av.OptionalSchema<av.StringSchema>;
|
|
17
|
+
secret: av.OptionalSchema<av.StringSchema>;
|
|
18
|
+
code: av.OptionalSchema<av.StringSchema>;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const ResponseSchema: av.BaseSchema<unknown, JsonObject>;
|
|
21
|
+
declare const _default: import("@betterportal/framework").RouteHandler<Record<string, string>, Record<string, unknown>, Record<string, string>, {
|
|
22
|
+
action: string;
|
|
23
|
+
connection?: string | undefined;
|
|
24
|
+
id?: string | undefined;
|
|
25
|
+
secret?: string | undefined;
|
|
26
|
+
code?: string | undefined;
|
|
27
|
+
}, JsonObject, import("../../index.js").PluginFeature, {
|
|
28
|
+
[x: string]: unknown;
|
|
29
|
+
}>;
|
|
30
|
+
export default _default;
|
|
31
|
+
//# sourceMappingURL=POST.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"POST.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/social/POST.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAI5E,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,IAAI;;;CAAuC,CAAC;AACzD,eAAO,MAAM,UAAU;;;CAAgC,CAAC;AACxD,eAAO,MAAM,aAAa;;;;;;EAA2K,CAAC;AACtM,eAAO,MAAM,cAAc,oCAAmB,CAAC;;;;;;;;;;AAC/C,wBAEG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { title, description } from "./index.js";
|
|
2
|
+
import * as av from "anyvali";
|
|
3
|
+
import { JsonObjectSchema } from "@betterportal/framework";
|
|
4
|
+
import { createHandler } from "../../.bp-generated/route-runtime.js";
|
|
5
|
+
import { socialPost } from "../../../../social.js";
|
|
6
|
+
import { AuthError } from "../../../../identity.js";
|
|
7
|
+
export const operationId = "auth.social";
|
|
8
|
+
export const auth = { required: false, permissions: [] };
|
|
9
|
+
export const cacheHints = { ttlSeconds: 0, varyBy: [] };
|
|
10
|
+
export const RequestSchema = av.object({ action: av.string(), connection: av.optional(av.string()), id: av.optional(av.string()), secret: av.optional(av.string()), code: av.optional(av.string()) });
|
|
11
|
+
export const ResponseSchema = JsonObjectSchema;
|
|
12
|
+
export default createHandler({ response: ResponseSchema, request: RequestSchema }, async (ctx) => {
|
|
13
|
+
try {
|
|
14
|
+
return await socialPost(ctx);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (!(error instanceof AuthError))
|
|
18
|
+
throw error;
|
|
19
|
+
ctx.setStatus?.(error.status);
|
|
20
|
+
return { status: "error", message: error.message };
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=POST.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"POST.js","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/social/POST.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAmB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AACtM,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC/C,eAAe,aAAa,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,EAAuB,EAAE;IACpH,IAAI,CAAC;QAAC,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IAAC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAAC,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC;YAAE,MAAM,KAAK,CAAC;QAAC,GAAG,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAAC,CAAC;AAC5L,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GET.d.ts","sourceRoot":"","sources":["../../../../../../src/plugins/service-betterportal-auth-default/bp-routes/social/_renderer.bootstrap5/GET.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,CAmChE"}
|
package/lib/plugins/service-betterportal-auth-default/bp-routes/social/_renderer.bootstrap5/GET.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "jsx-htmx/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource jsx-htmx */
|
|
3
|
+
import { js } from "jsx-htmx";
|
|
4
|
+
export function render(data) {
|
|
5
|
+
return _jsxs("section", { id: "bp-social-ui", class: "container py-4", style: "max-width:540px", "data-endpoint": data.endpoint, "data-code": data.code, "data-state": data.state, children: [_jsx("h2", { children: data.signedIn ? "Link a sign-in provider" : "Sign in" }), _jsx("p", { role: "status", children: data.message ?? (data.error ? "The provider declined sign-in. Try again." : "") }), data.connections.map((c) => _jsxs("button", { class: "btn btn-outline-primary m-2", "data-connection": c.id, "data-action": data.signedIn ? "link" : "start", children: ["Continue with ", c.title] })), _jsx("script", { children: js(`(() => {
|
|
6
|
+
const root = document.getElementById("bp-social-ui"); if (!root) return;
|
|
7
|
+
const status = root.querySelector('[role="status"]');
|
|
8
|
+
const api = window.BetterPortalAuth;
|
|
9
|
+
const send = async (body, endpoint = root.dataset.endpoint) => {
|
|
10
|
+
if (!api) throw new Error("Open sign-in inside your app.");
|
|
11
|
+
const response = await api.fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, body: JSON.stringify(body) });
|
|
12
|
+
const result = await response.json(); if (!response.ok) throw new Error(result.message || "Sign-in failed."); return result;
|
|
13
|
+
};
|
|
14
|
+
root.querySelectorAll("[data-connection]").forEach(button => button.addEventListener("click", async () => {
|
|
15
|
+
button.disabled = true;
|
|
16
|
+
try { const result = await send({ action: button.dataset.action, connection: button.dataset.connection }); sessionStorage.setItem("bp.oauth." + result.id, result.secret); location.assign(result.authorizationUrl); }
|
|
17
|
+
catch (error) { status.textContent = error.message; button.disabled = false; }
|
|
18
|
+
}));
|
|
19
|
+
if (root.dataset.code && root.dataset.state) void (async () => {
|
|
20
|
+
const id = root.dataset.state; const secret = sessionStorage.getItem("bp.oauth." + id); sessionStorage.removeItem("bp.oauth." + id);
|
|
21
|
+
history.replaceState(null, "", location.pathname);
|
|
22
|
+
if (!secret) { status.textContent = "Sign-in was started in a different app or browser. Start again."; return; }
|
|
23
|
+
try {
|
|
24
|
+
let result = await send({ action: "complete", id, secret, code: root.dataset.code });
|
|
25
|
+
if (result.challenge) {
|
|
26
|
+
const factor = await api.factor(result.challenge); if (!factor) { status.textContent = "Sign-in cancelled."; return; }
|
|
27
|
+
result = await send({ action: "login.complete", id: result.challenge.id, secret: result.challenge.secret, ...factor }, result.accountUrl);
|
|
28
|
+
}
|
|
29
|
+
status.textContent = result.message || "Signed in.";
|
|
30
|
+
if (result.recoveryCodes?.length) { const pre = document.createElement("pre"); pre.textContent = "Save your recovery codes:\\n" + result.recoveryCodes.join("\\n"); status.append(pre); }
|
|
31
|
+
if (result.next) { const link = document.createElement("a"); link.href = result.next; link.textContent = "Continue"; link.className = "btn btn-primary d-block"; status.append(link); }
|
|
32
|
+
} catch (error) { status.textContent = error.message; }
|
|
33
|
+
})();
|
|
34
|
+
})()`) })] });
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=GET.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GET.js","sourceRoot":"","sources":["../../../../../../src/plugins/service-betterportal-auth-default/bp-routes/social/_renderer.bootstrap5/GET.tsx"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAE9B,MAAM,UAAU,MAAM,CAAC,IAAyB;IAC9C,OAAO,mBAAS,EAAE,EAAC,cAAc,EAAC,KAAK,EAAC,gBAAgB,EAAC,KAAK,EAAC,iBAAiB,mBAAgB,IAAI,CAAC,QAAQ,eAAa,IAAI,CAAC,IAAI,gBAAc,IAAI,CAAC,KAAK,aACzJ,uBAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,SAAS,GAAM,EAAA,YAAG,IAAI,EAAC,QAAQ,YAAE,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,2CAA2C,CAAC,CAAC,CAAC,EAAE,CAAC,GAAK,EACrK,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,kBAAQ,KAAK,EAAC,6BAA6B,qBAAkB,CAAC,CAAC,EAAE,iBAAe,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,+BAAiB,CAAC,CAAC,KAAK,IAAU,CAAC,EACrL,2BAAS,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA6BP,CAAC,GAAU,IACR,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/social/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,mBAAmB,CAAC;AACtC,eAAO,MAAM,WAAW,kFAAkF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/social/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,gBAAgB,CAAC;AACtC,MAAM,CAAC,MAAM,WAAW,GAAG,+EAA+E,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { title, description } from "./index.js";
|
|
2
|
+
import * as av from "anyvali";
|
|
3
|
+
export declare const operationId = "auth.users.view";
|
|
4
|
+
export declare const auth: {
|
|
5
|
+
required: boolean;
|
|
6
|
+
permissions: {
|
|
7
|
+
serviceId: string;
|
|
8
|
+
viewId: string;
|
|
9
|
+
permissions: "read"[];
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
export declare const cacheHints: {
|
|
13
|
+
ttlSeconds: number;
|
|
14
|
+
varyBy: never[];
|
|
15
|
+
};
|
|
16
|
+
export declare const dependencies: readonly [{
|
|
17
|
+
readonly operationId: "auth.users.manage";
|
|
18
|
+
readonly method: "POST";
|
|
19
|
+
}];
|
|
20
|
+
export declare const ResponseSchema: av.BaseSchema<unknown, import("@betterportal/framework").JsonObject>;
|
|
21
|
+
export declare const QuerySchema: av.ObjectSchema<{
|
|
22
|
+
after: av.OptionalSchema<av.StringSchema>;
|
|
23
|
+
mailAfter: av.OptionalSchema<av.StringSchema>;
|
|
24
|
+
}>;
|
|
25
|
+
declare const _default: import("@betterportal/framework").RouteHandler<Record<string, string>, {
|
|
26
|
+
after?: string | undefined;
|
|
27
|
+
mailAfter?: string | undefined;
|
|
28
|
+
}, Record<string, string>, Record<string, unknown>, import("@betterportal/framework").JsonObject, import("../../index.js").PluginFeature, {
|
|
29
|
+
[x: string]: unknown;
|
|
30
|
+
}>;
|
|
31
|
+
export default _default;
|
|
32
|
+
//# sourceMappingURL=GET.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GET.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/users/GET.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAI9B,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAC7C,eAAO,MAAM,IAAI;;;;;;;CAA2I,CAAC;AAC7J,eAAO,MAAM,UAAU;;;CAAgC,CAAC;AACxD,eAAO,MAAM,YAAY;;;EAAkE,CAAC;AAC5F,eAAO,MAAM,cAAc,sEAAmB,CAAC;AAC/C,eAAO,MAAM,WAAW;;;EAAsF,CAAC;;;;;;;AAC/G,wBAyBG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export { title, description } from "./index.js";
|
|
2
|
+
import * as av from "anyvali";
|
|
3
|
+
import { JsonObjectSchema } from "@betterportal/framework";
|
|
4
|
+
import { createHandler } from "../../.bp-generated/route-runtime.js";
|
|
5
|
+
export const operationId = "auth.users.view";
|
|
6
|
+
export const auth = { required: true, permissions: [{ serviceId: "org.betterportal.auth.default", viewId: "users.index", permissions: ["read"] }] };
|
|
7
|
+
export const cacheHints = { ttlSeconds: 0, varyBy: [] };
|
|
8
|
+
export const dependencies = [{ operationId: "auth.users.manage", method: "POST" }];
|
|
9
|
+
export const ResponseSchema = JsonObjectSchema;
|
|
10
|
+
export const QuerySchema = av.object({ after: av.optional(av.string()), mailAfter: av.optional(av.string()) });
|
|
11
|
+
export default createHandler({ response: ResponseSchema, query: QuerySchema }, async (ctx) => {
|
|
12
|
+
const runtime = ctx.plugin.runtime;
|
|
13
|
+
const scope = { tenantId: ctx.tenant.id, appId: ctx.app.id };
|
|
14
|
+
const policy = await runtime.policy(scope);
|
|
15
|
+
const dir = { tenantId: scope.tenantId, appId: policy.isolation === "app" ? scope.appId : "" };
|
|
16
|
+
ctx.responseHeaders?.set("Cache-Control", "no-store");
|
|
17
|
+
return runtime.identity.storage.transaction(scope, async (tx) => {
|
|
18
|
+
const query = ctx.query;
|
|
19
|
+
const mailPage = await tx.failedMail(scope, { after: query?.mailAfter, limit: 101 });
|
|
20
|
+
const page = await tx.page("user", dir, { after: query?.after, limit: 101 });
|
|
21
|
+
const users = page.slice(0, 100);
|
|
22
|
+
const groups = await tx.list("group", dir);
|
|
23
|
+
return {
|
|
24
|
+
nextUrl: page.length > 100 ? ctx.routeUrl?.("users.index", { absolute: true, query: { after: users.at(-1).id, ...(query?.mailAfter ? { mailAfter: query.mailAfter } : {}) } }) ?? "" : "",
|
|
25
|
+
mailNextUrl: mailPage.length > 100 ? ctx.routeUrl?.("users.index", { absolute: true, query: { mailAfter: mailPage[99].id, ...(query?.after ? { after: query.after } : {}) } }) ?? "" : "",
|
|
26
|
+
status: "ok", endpoint: ctx.routeUrl?.("users.index", { absolute: true }) ?? "/users", isolation: policy.isolation, mode: runtime.identity.storage.mode, roleIds: policy.allowedRoleIds, canManageDirectory: policy.isolation === "app" || policy.canManageDirectory === true,
|
|
27
|
+
users: await Promise.all(users.map(async (u) => {
|
|
28
|
+
const roles = (await tx.get("roles", u.id, scope))?.roles ?? [];
|
|
29
|
+
const groupRoles = groups.filter(g => g.members.includes(u.id)).flatMap(g => g.appRoles[scope.appId] ?? []);
|
|
30
|
+
return { id: u.id, username: u.username, email: u.email ?? "", name: u.name ?? "", enabled: u.enabled, emailVerified: u.emailVerified, roles, effectiveRoles: [...new Set([...roles, ...groupRoles])].filter(id => policy.allowedRoleIds.includes(id) || id === "*") };
|
|
31
|
+
})),
|
|
32
|
+
invitations: (await tx.list("challenge", scope)).filter(c => c.purpose === "invite" && Number(c.expiresAt) > Date.now()).map(c => ({ id: c.id, email: String(c.data.email), expiresAt: Number(c.expiresAt) })),
|
|
33
|
+
groups: groups.map(g => ({ id: g.id, name: String(g.name), members: g.members, roles: g.appRoles[scope.appId] ?? [] })),
|
|
34
|
+
mail: mailPage.slice(0, 100).map(m => ({ id: m.id, state: String(m.state), attempts: Number(m.attempts) })),
|
|
35
|
+
audit: (await tx.page("audit", scope, { limit: 100, descending: true })).map(a => ({ id: a.id, actor: String(a.actor), event: String(a.event), at: Number(a.at) }))
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=GET.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GET.js","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/users/GET.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAi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,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC3G,KAAK,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACpK,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export { title, description } from "./index.js";
|
|
2
|
+
import * as av from "anyvali";
|
|
3
|
+
export declare const operationId = "auth.users.manage";
|
|
4
|
+
export declare const auth: {
|
|
5
|
+
required: boolean;
|
|
6
|
+
elevation: {
|
|
7
|
+
minimum: "mfa";
|
|
8
|
+
};
|
|
9
|
+
permissions: {
|
|
10
|
+
serviceId: string;
|
|
11
|
+
viewId: string;
|
|
12
|
+
permissions: "update"[];
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
export declare const cacheHints: {
|
|
16
|
+
ttlSeconds: number;
|
|
17
|
+
varyBy: never[];
|
|
18
|
+
};
|
|
19
|
+
export declare const RequestSchema: av.ObjectSchema<{
|
|
20
|
+
action: av.StringSchema;
|
|
21
|
+
id: av.OptionalSchema<av.StringSchema>;
|
|
22
|
+
email: av.OptionalSchema<av.StringSchema>;
|
|
23
|
+
name: av.OptionalSchema<av.StringSchema>;
|
|
24
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
25
|
+
roles: av.OptionalSchema<av.ArraySchema<av.StringSchema>>;
|
|
26
|
+
members: av.OptionalSchema<av.ArraySchema<av.StringSchema>>;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const ResponseSchema: av.BaseSchema<unknown, import("@betterportal/framework").JsonObject>;
|
|
29
|
+
declare const _default: import("@betterportal/framework").RouteHandler<Record<string, string>, Record<string, unknown>, Record<string, string>, {
|
|
30
|
+
action: string;
|
|
31
|
+
id?: string | undefined;
|
|
32
|
+
email?: string | undefined;
|
|
33
|
+
name?: string | undefined;
|
|
34
|
+
enabled?: boolean | undefined;
|
|
35
|
+
roles?: string[] | undefined;
|
|
36
|
+
members?: string[] | undefined;
|
|
37
|
+
}, import("@betterportal/framework").JsonObject, import("../../index.js").PluginFeature, {
|
|
38
|
+
[x: string]: unknown;
|
|
39
|
+
}>;
|
|
40
|
+
export default _default;
|
|
41
|
+
//# sourceMappingURL=POST.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"POST.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/users/POST.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAK9B,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAC/C,eAAO,MAAM,IAAI;;;;;;;;;;CAAqL,CAAC;AACvM,eAAO,MAAM,UAAU;;;CAAgC,CAAC;AACxD,eAAO,MAAM,aAAa;;;;;;;;EAA6P,CAAC;AACxR,eAAO,MAAM,cAAc,sEAAmB,CAAC;;;;;;;;;;;;AAC/C,wBAoDG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export { title, description } from "./index.js";
|
|
2
|
+
import * as av from "anyvali";
|
|
3
|
+
import { JsonObjectSchema, uuidv7 } from "@betterportal/framework";
|
|
4
|
+
import { createHandler } from "../../.bp-generated/route-runtime.js";
|
|
5
|
+
import { accountLink } from "../../../../account.js";
|
|
6
|
+
import { AuthError, isValidEmail } from "../../../../identity.js";
|
|
7
|
+
export const operationId = "auth.users.manage";
|
|
8
|
+
export const auth = { required: true, elevation: { minimum: "mfa" }, permissions: [{ serviceId: "org.betterportal.auth.default", viewId: "users.index", permissions: ["update"] }] };
|
|
9
|
+
export const cacheHints = { ttlSeconds: 0, varyBy: [] };
|
|
10
|
+
export const RequestSchema = av.object({ action: av.string(), id: av.optional(av.string()), email: av.optional(av.string()), name: av.optional(av.string()), enabled: av.optional(av.bool()), roles: av.optional(av.array(av.string())), members: av.optional(av.array(av.string())) });
|
|
11
|
+
export const ResponseSchema = JsonObjectSchema;
|
|
12
|
+
export default createHandler({ response: ResponseSchema, request: RequestSchema }, async (ctx) => {
|
|
13
|
+
const runtime = ctx.plugin.runtime;
|
|
14
|
+
const identity = runtime.identity;
|
|
15
|
+
const scope = { tenantId: ctx.tenant.id, appId: ctx.app.id };
|
|
16
|
+
const policy = await runtime.policy(scope);
|
|
17
|
+
const dir = { tenantId: scope.tenantId, appId: policy.isolation === "app" ? scope.appId : "" };
|
|
18
|
+
const body = ctx.request;
|
|
19
|
+
try {
|
|
20
|
+
if (policy.isolation === "tenant" && !policy.canManageDirectory && ["disable", "sessions.revoke", "group.save", "group.delete"].includes(body.action))
|
|
21
|
+
throw new AuthError("Use the tenant's designated directory administration app to manage shared accounts and groups.", 403);
|
|
22
|
+
const roles = [...new Set(body.roles ?? [])];
|
|
23
|
+
if (roles.some(id => id === "*" || !policy.allowedRoleIds.includes(id)))
|
|
24
|
+
throw new AuthError("Choose existing app roles. Root cannot be provisioned here.");
|
|
25
|
+
await identity.storage.transaction(scope, async (tx) => {
|
|
26
|
+
const actor = await tx.get("user", ctx.user.sub, dir);
|
|
27
|
+
if (!actor?.enabled)
|
|
28
|
+
throw new AuthError("Account unavailable.", 401);
|
|
29
|
+
await identity.assertActiveSession(tx, scope, ctx.user, actor);
|
|
30
|
+
if (body.action === "invite") {
|
|
31
|
+
if (policy.registration === "closed")
|
|
32
|
+
throw new AuthError("Registration is closed.");
|
|
33
|
+
const email = (body.email ?? "").trim().toLowerCase();
|
|
34
|
+
if (!isValidEmail(email))
|
|
35
|
+
throw new AuthError("Enter a valid email.");
|
|
36
|
+
const ticket = await identity.challengeInTransaction(tx, scope, "invite", { email, roles }, undefined, 86400);
|
|
37
|
+
const link = accountLink(ctx, "invite.accept", ticket);
|
|
38
|
+
if (!link)
|
|
39
|
+
throw new AuthError("Mount the account page before inviting users.");
|
|
40
|
+
await runtime.mail.enqueue(tx, scope, email, `Invitation to ${ctx.app.title}`, `Accept your invitation: ${link}\nThis invitation expires in 24 hours.`);
|
|
41
|
+
}
|
|
42
|
+
else if (body.action === "invite.revoke") {
|
|
43
|
+
const challenge = await tx.get("challenge", body.id ?? "", scope);
|
|
44
|
+
if (!challenge || challenge.purpose !== "invite")
|
|
45
|
+
throw new AuthError("Invitation unavailable.", 404);
|
|
46
|
+
await tx.remove("challenge", challenge.id, scope);
|
|
47
|
+
}
|
|
48
|
+
else if (body.action === "roles" || body.action === "disable" || body.action === "sessions.revoke") {
|
|
49
|
+
const user = await tx.get("user", body.id ?? "", dir);
|
|
50
|
+
if (!user)
|
|
51
|
+
throw new AuthError("User unavailable.", 404);
|
|
52
|
+
const current = await tx.get("roles", user.id, scope);
|
|
53
|
+
if (user.bootstrapAdmin || current?.roles?.includes("*"))
|
|
54
|
+
throw new AuthError("The bootstrap administrator cannot be modified through this interface.", 403);
|
|
55
|
+
if (body.action === "roles")
|
|
56
|
+
await tx.put("roles", scope, { id: user.id, roles, initialized: true });
|
|
57
|
+
else {
|
|
58
|
+
if (body.action === "disable")
|
|
59
|
+
user.enabled = body.enabled === true;
|
|
60
|
+
user.refreshVersion++;
|
|
61
|
+
await tx.put("user", dir, user);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (body.action === "group.save") {
|
|
65
|
+
const id = body.id || uuidv7();
|
|
66
|
+
if (body.id && !await tx.get("group", id, dir))
|
|
67
|
+
throw new AuthError("Group unavailable.", 404);
|
|
68
|
+
const members = [...new Set(body.members ?? [])];
|
|
69
|
+
for (const member of members)
|
|
70
|
+
if (!await tx.get("user", member, dir))
|
|
71
|
+
throw new AuthError("Group member belongs to a different directory.");
|
|
72
|
+
const existing = await tx.get("group", id, dir);
|
|
73
|
+
await tx.put("group", dir, { id, name: (body.name ?? "Group").slice(0, 200), members, appRoles: { ...(existing?.appRoles ?? {}), [scope.appId]: roles } });
|
|
74
|
+
}
|
|
75
|
+
else if (body.action === "group.roles") {
|
|
76
|
+
const group = await tx.get("group", body.id ?? "", dir);
|
|
77
|
+
if (!group)
|
|
78
|
+
throw new AuthError("Group unavailable.", 404);
|
|
79
|
+
await tx.put("group", dir, { ...group, appRoles: { ...group.appRoles, [scope.appId]: roles } });
|
|
80
|
+
}
|
|
81
|
+
else if (body.action === "group.delete") {
|
|
82
|
+
await tx.remove("group", body.id ?? "", dir);
|
|
83
|
+
}
|
|
84
|
+
else if (body.action === "mail.retry") {
|
|
85
|
+
const mail = await tx.get("mail", body.id ?? "", scope);
|
|
86
|
+
if (!mail || mail.state !== "failed")
|
|
87
|
+
throw new AuthError("Failed delivery unavailable.");
|
|
88
|
+
await tx.put("mail", scope, { ...mail, attempts: 0, nextAttempt: Date.now(), state: "pending" });
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
throw new AuthError("Unknown admin action.");
|
|
92
|
+
await identity.audit(tx, scope, ctx.user.sub, `admin.${body.action}`, { id: body.id ?? "", roles });
|
|
93
|
+
});
|
|
94
|
+
return { status: "ok", message: "Saved." };
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (!(error instanceof AuthError))
|
|
98
|
+
throw error;
|
|
99
|
+
ctx.setStatus?.(error.status);
|
|
100
|
+
return { status: "error", message: error.message };
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=POST.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"POST.js","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/users/POST.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAa,MAAM,yBAAyB,CAAC;AAC7E,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAC/C,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAc,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,SAAS,EAAE,+BAA+B,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,QAAiB,CAAC,EAAE,CAAC,EAAE,CAAC;AACvM,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,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names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,CA4BhE"}
|
package/lib/plugins/service-betterportal-auth-default/bp-routes/users/_renderer.bootstrap5/GET.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "jsx-htmx/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource jsx-htmx */
|
|
3
|
+
import { js } from "jsx-htmx";
|
|
4
|
+
export function render(data) {
|
|
5
|
+
return _jsxs("section", { id: "bp-users-ui", class: "container py-4", "data-endpoint": data.endpoint ?? "/users", children: [_jsx("h2", { children: "Users and groups" }), _jsxs("p", { children: [data.mode, " mode \u00B7 ", data.isolation === "tenant" ? "Accounts shared within this tenant" : "Accounts isolated to this app"] }), _jsx("p", { role: "status", "aria-live": "polite" }), _jsxs("p", { children: ["Available role IDs: ", (data.roleIds ?? []).join(", ") || "None configured"] }), _jsxs("form", { class: "border p-3 mb-3", "data-bp-no-route": "", children: [_jsx("h3", { children: "Invite user" }), _jsx("input", { type: "hidden", name: "action", value: "invite" }), _jsxs("label", { class: "form-label", children: ["Email", _jsx("input", { class: "form-control", type: "email", name: "email", required: true })] }), _jsxs("label", { class: "form-label ms-2", children: ["Role IDs (comma separated)", _jsx("input", { class: "form-control", name: "roles" })] }), _jsx("button", { class: "btn btn-primary ms-2", type: "submit", children: "Send invitation" })] }), _jsx("div", { class: "table-responsive", children: _jsxs("table", { class: "table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "User" }), _jsx("th", { children: "Roles" }), _jsx("th", { children: "Account" })] }) }), _jsx("tbody", { children: (data.users ?? []).map((u) => _jsxs("tr", { children: [_jsxs("td", { children: [u.email || u.username, _jsx("small", { class: "d-block", children: u.id })] }), _jsx("td", { children: _jsxs("form", { "data-bp-no-route": "", children: [_jsx("input", { type: "hidden", name: "action", value: "roles" }), _jsx("input", { type: "hidden", name: "id", value: u.id }), _jsx("input", { "aria-label": "Role IDs", class: "form-control", name: "roles", value: u.roles.join(",") }), _jsx("button", { class: "btn btn-sm btn-primary", type: "submit", children: "Save roles" })] }) }), _jsx("td", { children: data.canManageDirectory ? _jsxs("form", { "data-bp-no-route": "", children: [_jsx("input", { type: "hidden", name: "action", value: "disable" }), _jsx("input", { type: "hidden", name: "id", value: u.id }), _jsx("input", { type: "hidden", name: "enabled", value: String(!u.enabled) }), _jsx("button", { class: "btn btn-sm btn-outline-danger", type: "submit", children: u.enabled ? "Disable" : "Enable" })] }) : (u.enabled ? "Enabled" : "Disabled") })] })) })] }) }), data.nextUrl ? _jsx("a", { class: "btn btn-outline-secondary mb-3", href: data.nextUrl, "hx-get": data.nextUrl, "hx-target": "#bp-main", children: "Next users" }) : null, _jsx("h3", { children: "Pending invitations" }), (data.invitations ?? []).map((invite) => _jsxs("form", { "data-bp-no-route": "", children: [_jsx("input", { type: "hidden", name: "action", value: "invite.revoke" }), _jsx("input", { type: "hidden", name: "id", value: invite.id }), _jsxs("span", { children: [invite.email, " "] }), _jsx("button", { class: "btn btn-sm btn-outline-danger", type: "submit", children: "Revoke invitation" })] })), _jsx("h3", { children: "Groups" }), data.canManageDirectory ? [...(data.groups ?? []), { id: "", name: "", members: [], roles: [] }].map((g) => _jsxs("form", { class: "border p-3 mb-3", "data-bp-no-route": "", children: [_jsx("input", { type: "hidden", name: "action", value: "group.save" }), _jsx("input", { type: "hidden", name: "id", value: g.id }), _jsxs("label", { class: "form-label d-block", children: ["Name", _jsx("input", { class: "form-control", name: "name", value: g.name, required: true })] }), _jsxs("label", { class: "form-label d-block", children: ["Member user IDs (comma separated)", _jsx("input", { class: "form-control", name: "members", value: g.members.join(",") })] }), _jsxs("label", { class: "form-label d-block", children: ["App role IDs (comma separated)", _jsx("input", { class: "form-control", name: "roles", value: g.roles.join(",") })] }), _jsx("button", { class: "btn btn-primary", type: "submit", children: "Save group" })] })) : _jsx("p", { children: "Manage shared groups in the tenant\u2019s directory administration app." }), data.canManageDirectory ? (data.groups ?? []).map((g) => _jsxs("form", { "data-bp-no-route": "", children: [_jsx("input", { type: "hidden", name: "action", value: "group.delete" }), _jsx("input", { type: "hidden", name: "id", value: g.id }), _jsxs("span", { children: [g.name, " "] }), _jsx("button", { class: "btn btn-sm btn-outline-danger", type: "submit", children: "Delete group" })] })) : null, !data.canManageDirectory ? (data.groups ?? []).map((g) => _jsxs("form", { class: "border p-3 mb-3", "data-bp-no-route": "", children: [_jsx("input", { type: "hidden", name: "action", value: "group.roles" }), _jsx("input", { type: "hidden", name: "id", value: g.id }), _jsxs("label", { class: "form-label", children: [g.name, ": role IDs in this app", _jsx("input", { class: "form-control", name: "roles", value: g.roles.join(",") })] }), _jsx("button", { class: "btn btn-sm btn-primary", type: "submit", children: "Save app mapping" })] })) : null, _jsx("h3", { children: "Failed email deliveries" }), (data.mail ?? []).map((m) => _jsxs("form", { "data-bp-no-route": "", children: [_jsx("input", { type: "hidden", name: "action", value: "mail.retry" }), _jsx("input", { type: "hidden", name: "id", value: m.id }), _jsxs("span", { children: [m.id, " \u00B7 ", m.attempts, " attempts "] }), _jsx("button", { class: "btn btn-sm btn-secondary", type: "submit", children: "Retry" })] })), data.mailNextUrl ? _jsx("a", { class: "btn btn-outline-secondary my-3", href: data.mailNextUrl, "hx-get": data.mailNextUrl, "hx-target": "#bp-main", children: "More failed deliveries" }) : null, _jsx("h3", { class: "mt-3", children: "Recent account events" }), _jsx("ul", { children: (data.audit ?? []).map((a) => _jsxs("li", { children: [new Date(a.at).toISOString(), " \u00B7 ", a.event, " \u00B7 ", a.actor] })) }), _jsx("script", { children: js(`(() => {
|
|
6
|
+
const root = document.getElementById("bp-users-ui"); if (!root) return;
|
|
7
|
+
root.querySelectorAll("form").forEach(form => form.addEventListener("submit", async event => {
|
|
8
|
+
event.preventDefault(); event.stopPropagation(); const button = form.querySelector("button"); button.disabled = true;
|
|
9
|
+
try {
|
|
10
|
+
const data = Object.fromEntries(new FormData(form)); for (const key of ["roles", "members"]) if (key in data) data[key] = data[key].split(",").map(s => s.trim()).filter(Boolean);
|
|
11
|
+
if ("enabled" in data) data.enabled = data.enabled === "true";
|
|
12
|
+
const endpoint = new URL(root.dataset.endpoint, location.href).href;
|
|
13
|
+
const result = await window.BetterPortalAuth.fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, body: JSON.stringify(data) });
|
|
14
|
+
const body = await result.json(); root.querySelector('[role="status"]').textContent = body.message || (result.ok ? "Saved. Reload this page to see changes." : "Request failed.");
|
|
15
|
+
} catch (error) { root.querySelector('[role="status"]').textContent = error.message; } finally { button.disabled = false; }
|
|
16
|
+
}));
|
|
17
|
+
})()`) })] });
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=GET.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GET.js","sourceRoot":"","sources":["../../../../../../src/plugins/service-betterportal-auth-default/bp-routes/users/_renderer.bootstrap5/GET.tsx"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAE9B,MAAM,UAAU,MAAM,CAAC,IAAyB;IAC9C,OAAO,mBAAS,EAAE,EAAC,aAAa,EAAC,KAAK,EAAC,gBAAgB,mBAAgB,IAAI,CAAC,QAAQ,IAAI,QAAQ,aAC9F,4CAAyB,EAAA,wBAAI,IAAI,CAAC,IAAI,mBAAU,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,+BAA+B,IAAK,EACzJ,YAAG,IAAI,EAAC,QAAQ,eAAW,QAAQ,GAAG,EAAA,gDAAwB,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,iBAAiB,IAAK,EACvH,gBAAM,KAAK,EAAC,i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AAQ,EAAC,KAAK,EAAC,YAAY,GAAG,EAAA,gBAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,IAAI,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAI,EAAA,2BAAO,CAAC,CAAC,EAAE,cAAK,CAAC,CAAC,QAAQ,kBAAkB,EAAA,iBAAQ,KAAK,EAAC,0BAA0B,EAAC,IAAI,EAAC,QAAQ,sBAAe,IAAO,CAAC,EAC3T,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,YAAG,KAAK,EAAC,gCAAgC,EAAC,IAAI,EAAE,IAAI,CAAC,WAAW,YAAU,IAAI,CAAC,WAAW,eAAY,UAAU,uCAA2B,CAAC,CAAC,CAAC,IAAI,EACtK,aAAI,KAAK,EAAC,MAAM,sCAA2B,EAAA,uBAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,yBAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,cAAK,CAAC,CAAC,KAAK,cAAK,CAAC,CAAC,KAAK,IAAM,CAAC,GAAM,EACzJ,2BAAS,EAAE,CAAC;;;;;;;;;;;;SAYP,CAAC,GAAU,IACR,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/users/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,qBAAqB,CAAC;AACxC,eAAO,MAAM,WAAW,+DAA+D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/plugins/service-betterportal-auth-default/bp-routes/users/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,kBAAkB,CAAC;AACxC,MAAM,CAAC,MAAM,WAAW,GAAG,4DAA4D,CAAC"}
|