@webiny/auth0 0.0.0-unstable.61c048f412
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/Auth0.d.ts +14 -0
- package/Auth0.js +44 -0
- package/Auth0.js.map +1 -0
- package/LICENSE +36 -0
- package/README.md +11 -0
- package/admin/Auth0.d.ts +6 -0
- package/admin/Auth0.js +18 -0
- package/admin/Auth0.js.map +1 -0
- package/admin/Auth0LoginScreen.d.ts +9 -0
- package/admin/Auth0LoginScreen.js +36 -0
- package/admin/Auth0LoginScreen.js.map +1 -0
- package/admin/Extension.d.ts +2 -0
- package/admin/Extension.js +16 -0
- package/admin/Extension.js.map +1 -0
- package/admin/components/LoginContent.d.ts +26 -0
- package/admin/components/LoginContent.js +34 -0
- package/admin/components/LoginContent.js.map +1 -0
- package/admin/components/View.d.ts +98 -0
- package/admin/components/View.js +66 -0
- package/admin/components/View.js.map +1 -0
- package/admin/components/auth0-icon.svg +6 -0
- package/admin/components/index.d.ts +2 -0
- package/admin/components/index.js +4 -0
- package/admin/components/index.js.map +1 -0
- package/admin/features/Auth0/Auth0Presenter.d.ts +27 -0
- package/admin/features/Auth0/Auth0Presenter.js +124 -0
- package/admin/features/Auth0/Auth0Presenter.js.map +1 -0
- package/admin/features/Auth0/IdTokenProvider.d.ts +7 -0
- package/admin/features/Auth0/IdTokenProvider.js +32 -0
- package/admin/features/Auth0/IdTokenProvider.js.map +1 -0
- package/admin/features/Auth0/abstractions.d.ts +22 -0
- package/admin/features/Auth0/abstractions.js +4 -0
- package/admin/features/Auth0/abstractions.js.map +1 -0
- package/admin/features/Auth0/feature.d.ts +3 -0
- package/admin/features/Auth0/feature.js +16 -0
- package/admin/features/Auth0/feature.js.map +1 -0
- package/admin/features/Auth0/index.d.ts +1 -0
- package/admin/features/Auth0/index.js +3 -0
- package/admin/features/Auth0/index.js.map +1 -0
- package/admin/index.d.ts +102 -0
- package/admin/index.js +8 -0
- package/admin/index.js.map +1 -0
- package/api/features/Auth0Idp/Auth0IdentityProvider.d.ts +15 -0
- package/api/features/Auth0Idp/Auth0IdentityProvider.js +38 -0
- package/api/features/Auth0Idp/Auth0IdentityProvider.js.map +1 -0
- package/api/features/Auth0Idp/abstractions.d.ts +15 -0
- package/api/features/Auth0Idp/abstractions.js +4 -0
- package/api/features/Auth0Idp/abstractions.js.map +1 -0
- package/api/features/Auth0Idp/feature.d.ts +1 -0
- package/api/features/Auth0Idp/feature.js +10 -0
- package/api/features/Auth0Idp/feature.js.map +1 -0
- package/api/features/Auth0Idp/index.d.ts +1 -0
- package/api/features/Auth0Idp/index.js +3 -0
- package/api/features/Auth0Idp/index.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +4 -0
- package/index.js.map +1 -0
- package/package.json +42 -0
package/Auth0.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const Auth0: import("@webiny/project/defineExtension/defineExtension").ExtensionComponent<z.ZodObject<{
|
|
3
|
+
issuer: z.ZodString;
|
|
4
|
+
clientId: z.ZodString;
|
|
5
|
+
apiConfig: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
issuer: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
apiConfig: string;
|
|
10
|
+
}, {
|
|
11
|
+
issuer: string;
|
|
12
|
+
clientId: string;
|
|
13
|
+
apiConfig: string;
|
|
14
|
+
}>>;
|
package/Auth0.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { defineExtension } from "@webiny/project/defineExtension/index.js";
|
|
3
|
+
import { EnvVar } from "@webiny/project/extensions/index.js";
|
|
4
|
+
import { Api, Admin } from "@webiny/project-aws";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
export const Auth0 = defineExtension({
|
|
7
|
+
type: "Project/Auth0",
|
|
8
|
+
tags: {
|
|
9
|
+
runtimeContext: "project"
|
|
10
|
+
},
|
|
11
|
+
description: "Enable and configure Auth0 authentication.",
|
|
12
|
+
paramsSchema: z.object({
|
|
13
|
+
issuer: z.string().describe("Auth0 issuer URL."),
|
|
14
|
+
clientId: z.string().describe("Auth0 client ID."),
|
|
15
|
+
apiConfig: z.string().describe("Path to API configuration.")
|
|
16
|
+
}),
|
|
17
|
+
render: props => {
|
|
18
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EnvVar, {
|
|
19
|
+
varName: "AUTH0_ISSUER",
|
|
20
|
+
value: props.issuer
|
|
21
|
+
}), /*#__PURE__*/React.createElement(EnvVar, {
|
|
22
|
+
varName: "AUTH0_CLIENT_ID",
|
|
23
|
+
value: props.clientId
|
|
24
|
+
}), /*#__PURE__*/React.createElement(EnvVar, {
|
|
25
|
+
varName: "REACT_APP_IDP_TYPE",
|
|
26
|
+
value: "auth0"
|
|
27
|
+
}), /*#__PURE__*/React.createElement(EnvVar, {
|
|
28
|
+
varName: "REACT_APP_AUTH0_ISSUER",
|
|
29
|
+
value: props.issuer
|
|
30
|
+
}), /*#__PURE__*/React.createElement(EnvVar, {
|
|
31
|
+
varName: "REACT_APP_AUTH0_CLIENT_ID",
|
|
32
|
+
value: props.clientId
|
|
33
|
+
}), /*#__PURE__*/React.createElement(Api.Extension, {
|
|
34
|
+
src: import.meta.dirname + "/api/features/Auth0Idp/feature.js",
|
|
35
|
+
exportName: "Auth0IdpFeature"
|
|
36
|
+
}), /*#__PURE__*/React.createElement(Api.Extension, {
|
|
37
|
+
src: props.apiConfig
|
|
38
|
+
}), /*#__PURE__*/React.createElement(Admin.Extension, {
|
|
39
|
+
src: import.meta.dirname + "/admin/Extension.js"
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=Auth0.js.map
|
package/Auth0.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","defineExtension","EnvVar","Api","Admin","z","Auth0","type","tags","runtimeContext","description","paramsSchema","object","issuer","string","describe","clientId","apiConfig","render","props","createElement","Fragment","varName","value","Extension","src","import","meta","dirname","exportName"],"sources":["Auth0.tsx"],"sourcesContent":["import React from \"react\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { EnvVar } from \"@webiny/project/extensions/index.js\";\nimport { Api, Admin } from \"@webiny/project-aws\";\nimport { z } from \"zod\";\n\nexport const Auth0 = defineExtension({\n type: \"Project/Auth0\",\n tags: { runtimeContext: \"project\" },\n description: \"Enable and configure Auth0 authentication.\",\n paramsSchema: z.object({\n issuer: z.string().describe(\"Auth0 issuer URL.\"),\n clientId: z.string().describe(\"Auth0 client ID.\"),\n apiConfig: z.string().describe(\"Path to API configuration.\")\n }),\n render: props => {\n return (\n <>\n {/* Lambda vars */}\n <EnvVar varName={\"AUTH0_ISSUER\"} value={props.issuer} />\n <EnvVar varName={\"AUTH0_CLIENT_ID\"} value={props.clientId} />\n {/* Admin app vars */}\n <EnvVar varName={\"REACT_APP_IDP_TYPE\"} value={\"auth0\"} />\n <EnvVar varName={\"REACT_APP_AUTH0_ISSUER\"} value={props.issuer} />\n <EnvVar varName={\"REACT_APP_AUTH0_CLIENT_ID\"} value={props.clientId} />\n {/* Api extensions */}\n <Api.Extension\n src={import.meta.dirname + \"/api/features/Auth0Idp/feature.js\"}\n exportName={\"Auth0IdpFeature\"}\n />\n <Api.Extension src={props.apiConfig} />\n {/* Admin extensions */}\n <Admin.Extension src={import.meta.dirname + \"/admin/Extension.js\"} />\n </>\n );\n }\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,0CAA0C;AAC1E,SAASC,MAAM,QAAQ,qCAAqC;AAC5D,SAASC,GAAG,EAAEC,KAAK,QAAQ,qBAAqB;AAChD,SAASC,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,KAAK,GAAGL,eAAe,CAAC;EACjCM,IAAI,EAAE,eAAe;EACr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AAA,CAAAoB,aAAA,CAACjB,GAAG,CAACqB,SAAS;MAACC,GAAG,EAAEN,KAAK,CAACF;IAAU,CAAE,CAAC,eAEvCjB,KAAA,CAAAoB,aAAA,CAAChB,KAAK,CAACoB,SAAS;MAACC,GAAG,EAAEC,MAAM,CAACC,IAAI,CAACC,OAAO,GAAG;IAAsB,CAAE,CACtE,CAAC;EAEX;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
The Webiny Enterprise license (the “Enterprise License”)
|
|
2
|
+
Copyright (c) 2021 Webiny Ltd.
|
|
3
|
+
|
|
4
|
+
With regard to the Webiny Software:
|
|
5
|
+
|
|
6
|
+
This software and associated documentation files (the "Software") may only be
|
|
7
|
+
used in production, if you (and any entity that you represent) have agreed to,
|
|
8
|
+
and are in compliance with, the Webiny Subscription Terms of Service, available
|
|
9
|
+
at https://www.webiny.com/terms (the “Enterprise Terms”), or other
|
|
10
|
+
agreement governing the use of the Software, as agreed by you and Webiny,
|
|
11
|
+
and otherwise have a valid Webiny Enterprise license for the
|
|
12
|
+
correct number of user seats. Subject to the foregoing sentence, you are free to
|
|
13
|
+
modify this Software and publish patches to the Software. You agree that Webiny
|
|
14
|
+
and/or its licensors (as applicable) retain all right, title and interest in and
|
|
15
|
+
to all such modifications and/or patches, and all such modifications and/or
|
|
16
|
+
patches may only be used, copied, modified, displayed, distributed, or otherwise
|
|
17
|
+
exploited with a valid Webiny Enterprise license for the correct
|
|
18
|
+
number of user seats. Notwithstanding the foregoing, you may copy and modify
|
|
19
|
+
the Software for development and testing purposes, without requiring a
|
|
20
|
+
subscription. You agree that Webiny and/or its licensors (as applicable) retain
|
|
21
|
+
all right, title and interest in and to all such modifications. You are not
|
|
22
|
+
granted any other rights beyond what is expressly stated herein. Subject to the
|
|
23
|
+
foregoing, it is forbidden to copy, merge, publish, distribute, sublicense,
|
|
24
|
+
and/or sell the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
|
33
|
+
|
|
34
|
+
For all third party components incorporated into the Webiny Software, those
|
|
35
|
+
components are licensed under the original license provided by the owner of the
|
|
36
|
+
applicable component.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @webiny/auth0
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/admin/Auth0.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type CreateAuthenticationConfig } from "./Auth0LoginScreen.js";
|
|
3
|
+
export type Auth0Props = Pick<CreateAuthenticationConfig, "auth0"> & {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export declare const Auth0: (props: Auth0Props) => React.JSX.Element;
|
package/admin/Auth0.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { LoginScreenRenderer } from "@webiny/app-admin";
|
|
3
|
+
import { Auth0LoginScreen } from "./Auth0LoginScreen.js";
|
|
4
|
+
const createLoginScreenPlugin = params => {
|
|
5
|
+
return LoginScreenRenderer.createDecorator(() => {
|
|
6
|
+
return function Auth0({
|
|
7
|
+
children
|
|
8
|
+
}) {
|
|
9
|
+
return /*#__PURE__*/React.createElement(Auth0LoginScreen, params, children);
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export const Auth0 = props => {
|
|
14
|
+
const LoginScreenPlugin = createLoginScreenPlugin(props);
|
|
15
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(LoginScreenPlugin, null));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=Auth0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Fragment","LoginScreenRenderer","Auth0LoginScreen","createLoginScreenPlugin","params","createDecorator","Auth0","children","createElement","props","LoginScreenPlugin"],"sources":["Auth0.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport { LoginScreenRenderer } from \"@webiny/app-admin\";\nimport { Auth0LoginScreen, type CreateAuthenticationConfig } from \"./Auth0LoginScreen.js\";\n\nconst createLoginScreenPlugin = (params: Auth0Props) => {\n return LoginScreenRenderer.createDecorator(() => {\n return function Auth0({ children }) {\n return <Auth0LoginScreen {...params}>{children}</Auth0LoginScreen>;\n };\n });\n};\n\nexport type Auth0Props = Pick<CreateAuthenticationConfig, \"auth0\"> & {\n children?: React.ReactNode;\n};\n\nexport const Auth0 = (props: Auth0Props) => {\n const LoginScreenPlugin = createLoginScreenPlugin(props);\n return (\n <Fragment>\n <LoginScreenPlugin />\n </Fragment>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,gBAAgB;AAEzB,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,OAAOH,mBAAmB,CAACI,eAAe,CAAC,MAAM;IAC7C,OAAO,SAASC,KAAKA,CAAC;MAAEC;IAAS,CAAC,EAAE;MAChC,oBAAOR,KAAA,CAAAS,aAAA,CAACN,gBAAgB,EAAKE,MAAM,EAAGG,QAA2B,CAAC;IACtE,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAMD,OAAO,MAAMD,KAAK,GAAIG,KAAiB,IAAK;EACxC,MAAMC,iBAAiB,GAAGP,uBAAuB,CAACM,KAAK,CAAC;EACxD,oBACIV,KAAA,CAAAS,aAAA,CAACR,QAAQ,qBACLD,KAAA,CAAAS,aAAA,CAACE,iBAAiB,MAAE,CACd,CAAC;AAEnB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Auth0ClientOptions } from "@auth0/auth0-spa-js";
|
|
3
|
+
export interface CreateAuthenticationConfig {
|
|
4
|
+
auth0: Auth0ClientOptions;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const Auth0LoginScreen: (({ auth0, children }: CreateAuthenticationConfig) => React.JSX.Element) & {
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { useEffect, useMemo } from "react";
|
|
2
|
+
import { observer } from "mobx-react-lite";
|
|
3
|
+
import { useFeature } from "@webiny/app";
|
|
4
|
+
import { Auth0Feature } from "./features/Auth0/feature.js";
|
|
5
|
+
import { LoginContent } from "./components/index.js";
|
|
6
|
+
export const Auth0LoginScreen = observer(({
|
|
7
|
+
auth0,
|
|
8
|
+
children
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
presenter
|
|
12
|
+
} = useFeature(Auth0Feature);
|
|
13
|
+
const autoLogin = useMemo(() => {
|
|
14
|
+
const query = new URLSearchParams(window.location.search);
|
|
15
|
+
return query.get("action") !== "logout";
|
|
16
|
+
}, []);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
presenter.init({
|
|
19
|
+
issuer: auth0.domain,
|
|
20
|
+
clientId: auth0.clientId,
|
|
21
|
+
autoLogin
|
|
22
|
+
});
|
|
23
|
+
}, []);
|
|
24
|
+
const vm = presenter.vm;
|
|
25
|
+
if (vm.isAuthenticated) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/React.createElement(LoginContent, {
|
|
29
|
+
onLogin: () => presenter.authenticate(),
|
|
30
|
+
checkingSession: vm.checkingSession,
|
|
31
|
+
isLoggingIn: vm.isLoggingIn,
|
|
32
|
+
isAuthenticated: vm.isAuthenticated
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=Auth0LoginScreen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","useMemo","observer","useFeature","Auth0Feature","LoginContent","Auth0LoginScreen","auth0","children","presenter","autoLogin","query","URLSearchParams","window","location","search","get","init","issuer","domain","clientId","vm","isAuthenticated","createElement","Fragment","onLogin","authenticate","checkingSession","isLoggingIn"],"sources":["Auth0LoginScreen.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport type { Auth0ClientOptions } from \"@auth0/auth0-spa-js\";\nimport { useFeature } from \"@webiny/app\";\nimport { Auth0Feature } from \"~/admin/features/Auth0/feature.js\";\nimport { LoginContent } from \"./components/index.js\";\n\nexport interface CreateAuthenticationConfig {\n auth0: Auth0ClientOptions;\n children: React.ReactNode;\n}\n\nexport const Auth0LoginScreen = observer(({ auth0, children }: CreateAuthenticationConfig) => {\n const { presenter } = useFeature(Auth0Feature);\n\n const autoLogin = useMemo(() => {\n const query = new URLSearchParams(window.location.search);\n return query.get(\"action\") !== \"logout\";\n }, []);\n\n useEffect(() => {\n presenter.init({\n issuer: auth0.domain,\n clientId: auth0.clientId,\n autoLogin\n });\n }, []);\n\n const vm = presenter.vm;\n\n if (vm.isAuthenticated) {\n return <>{children}</>;\n }\n\n return (\n <LoginContent\n onLogin={() => presenter.authenticate()}\n checkingSession={vm.checkingSession}\n isLoggingIn={vm.isLoggingIn}\n isAuthenticated={vm.isAuthenticated}\n />\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AACjD,SAASC,QAAQ,QAAQ,iBAAiB;AAE1C,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,YAAY;AACrB,SAASC,YAAY;AAOrB,OAAO,MAAMC,gBAAgB,GAAGJ,QAAQ,CAAC,CAAC;EAAEK,KAAK;EAAEC;AAAqC,CAAC,KAAK;EAC1F,MAAM;IAAEC;EAAU,CAAC,GAAGN,UAAU,CAACC,YAAY,CAAC;EAE9C,MAAMM,SAAS,GAAGT,OAAO,CAAC,MAAM;IAC5B,MAAMU,KAAK,GAAG,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;IACzD,OAAOJ,KAAK,CAACK,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ;EAC3C,CAAC,EAAE,EAAE,CAAC;EAENhB,SAAS,CAAC,MAAM;IACZS,SAAS,CAACQ,IAAI,CAAC;MACXC,MAAM,EAAEX,KAAK,CAACY,MAAM;MACpBC,QAAQ,EAAEb,KAAK,CAACa,QAAQ;MACxBV;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMW,EAAE,GAAGZ,SAAS,CAACY,EAAE;EAEvB,IAAIA,EAAE,CAACC,eAAe,EAAE;IACpB,oBAAOvB,KAAA,CAAAwB,aAAA,CAAAxB,KAAA,CAAAyB,QAAA,QAAGhB,QAAW,CAAC;EAC1B;EAEA,oBACIT,KAAA,CAAAwB,aAAA,CAAClB,YAAY;IACToB,OAAO,EAAEA,CAAA,KAAMhB,SAAS,CAACiB,YAAY,CAAC,CAAE;IACxCC,eAAe,EAAEN,EAAE,CAACM,eAAgB;IACpCC,WAAW,EAAEP,EAAE,CAACO,WAAY;IAC5BN,eAAe,EAAED,EAAE,CAACC;EAAgB,CACvC,CAAC;AAEV,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { RegisterFeature } from "@webiny/app-admin/components/RegisterFeature.js";
|
|
3
|
+
import { Auth0 } from "./Auth0.js";
|
|
4
|
+
import { Auth0Feature } from "./features/Auth0/feature.js";
|
|
5
|
+
export const Extension = () => {
|
|
6
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RegisterFeature, {
|
|
7
|
+
feature: Auth0Feature
|
|
8
|
+
}), /*#__PURE__*/React.createElement(Auth0, {
|
|
9
|
+
auth0: {
|
|
10
|
+
domain: String(process.env.REACT_APP_AUTH0_ISSUER),
|
|
11
|
+
clientId: String(process.env.REACT_APP_AUTH0_CLIENT_ID)
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=Extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","RegisterFeature","Auth0","Auth0Feature","Extension","createElement","Fragment","feature","auth0","domain","String","process","env","REACT_APP_AUTH0_ISSUER","clientId","REACT_APP_AUTH0_CLIENT_ID"],"sources":["Extension.tsx"],"sourcesContent":["import React from \"react\";\nimport { RegisterFeature } from \"@webiny/app-admin/components/RegisterFeature.js\";\nimport { Auth0 } from \"./Auth0.js\";\nimport { Auth0Feature } from \"./features/Auth0/feature.js\";\n\nexport const Extension = () => {\n return (\n <>\n <RegisterFeature feature={Auth0Feature} />\n <Auth0\n auth0={{\n domain: String(process.env.REACT_APP_AUTH0_ISSUER),\n clientId: String(process.env.REACT_APP_AUTH0_CLIENT_ID)\n }}\n />\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,iDAAiD;AACjF,SAASC,KAAK;AACd,SAASC,YAAY;AAErB,OAAO,MAAMC,SAAS,GAAGA,CAAA,KAAM;EAC3B,oBACIJ,KAAA,CAAAK,aAAA,CAAAL,KAAA,CAAAM,QAAA,qBACIN,KAAA,CAAAK,aAAA,CAACJ,eAAe;IAACM,OAAO,EAAEJ;EAAa,CAAE,CAAC,eAC1CH,KAAA,CAAAK,aAAA,CAACH,KAAK;IACFM,KAAK,EAAE;MACHC,MAAM,EAAEC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,sBAAsB,CAAC;MAClDC,QAAQ,EAAEJ,MAAM,CAACC,OAAO,CAACC,GAAG,CAACG,yBAAyB;IAC1D;EAAE,CACL,CACH,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface LoginContentProps {
|
|
3
|
+
isAuthenticated: boolean;
|
|
4
|
+
isLoggingIn: boolean;
|
|
5
|
+
checkingSession: boolean;
|
|
6
|
+
onLogin: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const LoginContent: (({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: LoginContentProps) => React.JSX.Element) & {
|
|
9
|
+
original: ({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: LoginContentProps) => React.JSX.Element;
|
|
10
|
+
originalName: string;
|
|
11
|
+
displayName: string;
|
|
12
|
+
} & {
|
|
13
|
+
original: (({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: LoginContentProps) => React.JSX.Element) & {
|
|
14
|
+
original: ({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: LoginContentProps) => React.JSX.Element;
|
|
15
|
+
originalName: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
18
|
+
originalName: string;
|
|
19
|
+
displayName: string;
|
|
20
|
+
} & {
|
|
21
|
+
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: LoginContentProps) => React.JSX.Element) & {
|
|
22
|
+
original: ({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: LoginContentProps) => React.JSX.Element;
|
|
23
|
+
originalName: string;
|
|
24
|
+
displayName: string;
|
|
25
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
26
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { makeDecoratable } from "@webiny/app-admin";
|
|
3
|
+
import { Button, Icon, OverlayLoader } from "@webiny/admin-ui";
|
|
4
|
+
import { ReactComponent as Auth0Icon } from "./auth0-icon.svg";
|
|
5
|
+
import { View } from "./View.js";
|
|
6
|
+
export const LoginContent = makeDecoratable("LoginContent", ({
|
|
7
|
+
onLogin,
|
|
8
|
+
isLoggingIn,
|
|
9
|
+
checkingSession,
|
|
10
|
+
isAuthenticated
|
|
11
|
+
}) => {
|
|
12
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isLoggingIn ? /*#__PURE__*/React.createElement(OverlayLoader, {
|
|
13
|
+
text: "Logging in..."
|
|
14
|
+
}) : null, checkingSession ? /*#__PURE__*/React.createElement(OverlayLoader, {
|
|
15
|
+
text: "Checking user session..."
|
|
16
|
+
}) : null, !isAuthenticated && !isLoggingIn && !checkingSession ? /*#__PURE__*/React.createElement(View.Container, null, /*#__PURE__*/React.createElement(View.Content, null, /*#__PURE__*/React.createElement(View.Title, {
|
|
17
|
+
title: "Sign In",
|
|
18
|
+
description: "You will be taken to Auth0 website to complete the sign in process."
|
|
19
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: "flex w-full"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
22
|
+
variant: "primary",
|
|
23
|
+
className: "w-full",
|
|
24
|
+
containerClassName: "w-full",
|
|
25
|
+
onClick: onLogin,
|
|
26
|
+
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
27
|
+
icon: /*#__PURE__*/React.createElement(Auth0Icon, null),
|
|
28
|
+
label: "Auth0"
|
|
29
|
+
}),
|
|
30
|
+
text: "Sign in with Auth0"
|
|
31
|
+
})))) : null);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=LoginContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","makeDecoratable","Button","Icon","OverlayLoader","ReactComponent","Auth0Icon","View","LoginContent","onLogin","isLoggingIn","checkingSession","isAuthenticated","createElement","Fragment","text","Container","Content","Title","title","description","className","variant","containerClassName","onClick","icon","label"],"sources":["LoginContent.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/app-admin\";\nimport { Button, Icon, OverlayLoader } from \"@webiny/admin-ui\";\nimport { ReactComponent as Auth0Icon } from \"./auth0-icon.svg\";\nimport { View } from \"./View.js\";\n\nexport interface LoginContentProps {\n isAuthenticated: boolean;\n isLoggingIn: boolean;\n checkingSession: boolean;\n onLogin: () => void;\n}\n\nexport const LoginContent = makeDecoratable(\n \"LoginContent\",\n ({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: LoginContentProps) => {\n return (\n <>\n {isLoggingIn ? <OverlayLoader text={\"Logging in...\"} /> : null}\n {checkingSession ? <OverlayLoader text={\"Checking user session...\"} /> : null}\n {!isAuthenticated && !isLoggingIn && !checkingSession ? (\n <View.Container>\n <View.Content>\n <View.Title\n title={\"Sign In\"}\n description={\n \"You will be taken to Auth0 website to complete the sign in process.\"\n }\n />\n\n <div className={\"flex w-full\"}>\n <Button\n variant={\"primary\"}\n className={\"w-full\"}\n containerClassName={\"w-full\"}\n onClick={onLogin}\n icon={<Icon icon={<Auth0Icon />} label={\"Auth0\"} />}\n text={\"Sign in with Auth0\"}\n />\n </div>\n </View.Content>\n </View.Container>\n ) : null}\n </>\n );\n }\n);\n"],"mappings":"AAAA,OAAOA,KA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F,CAAC,GACjB,IACN,CAAC;AAEX,CACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface ContainerProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export interface ContentProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface FooterProps {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export interface TitleProps {
|
|
12
|
+
title: string;
|
|
13
|
+
description?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export interface ErrorProps {
|
|
16
|
+
title?: string;
|
|
17
|
+
description?: string | null;
|
|
18
|
+
}
|
|
19
|
+
export declare const Error: ({ title, description }: ErrorProps) => React.JSX.Element | null;
|
|
20
|
+
export declare const View: {
|
|
21
|
+
Container: (({ children }: ContainerProps) => React.JSX.Element) & {
|
|
22
|
+
original: ({ children }: ContainerProps) => React.JSX.Element;
|
|
23
|
+
originalName: string;
|
|
24
|
+
displayName: string;
|
|
25
|
+
} & {
|
|
26
|
+
original: (({ children }: ContainerProps) => React.JSX.Element) & {
|
|
27
|
+
original: ({ children }: ContainerProps) => React.JSX.Element;
|
|
28
|
+
originalName: string;
|
|
29
|
+
displayName: string;
|
|
30
|
+
};
|
|
31
|
+
originalName: string;
|
|
32
|
+
displayName: string;
|
|
33
|
+
} & {
|
|
34
|
+
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(({ children }: ContainerProps) => React.JSX.Element) & {
|
|
35
|
+
original: ({ children }: ContainerProps) => React.JSX.Element;
|
|
36
|
+
originalName: string;
|
|
37
|
+
displayName: string;
|
|
38
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
39
|
+
};
|
|
40
|
+
Content: (({ children }: ContentProps) => React.JSX.Element) & {
|
|
41
|
+
original: ({ children }: ContentProps) => React.JSX.Element;
|
|
42
|
+
originalName: string;
|
|
43
|
+
displayName: string;
|
|
44
|
+
} & {
|
|
45
|
+
original: (({ children }: ContentProps) => React.JSX.Element) & {
|
|
46
|
+
original: ({ children }: ContentProps) => React.JSX.Element;
|
|
47
|
+
originalName: string;
|
|
48
|
+
displayName: string;
|
|
49
|
+
};
|
|
50
|
+
originalName: string;
|
|
51
|
+
displayName: string;
|
|
52
|
+
} & {
|
|
53
|
+
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(({ children }: ContentProps) => React.JSX.Element) & {
|
|
54
|
+
original: ({ children }: ContentProps) => React.JSX.Element;
|
|
55
|
+
originalName: string;
|
|
56
|
+
displayName: string;
|
|
57
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
58
|
+
};
|
|
59
|
+
Title: (({ title, description }: TitleProps) => React.JSX.Element) & {
|
|
60
|
+
original: ({ title, description }: TitleProps) => React.JSX.Element;
|
|
61
|
+
originalName: string;
|
|
62
|
+
displayName: string;
|
|
63
|
+
} & {
|
|
64
|
+
original: (({ title, description }: TitleProps) => React.JSX.Element) & {
|
|
65
|
+
original: ({ title, description }: TitleProps) => React.JSX.Element;
|
|
66
|
+
originalName: string;
|
|
67
|
+
displayName: string;
|
|
68
|
+
};
|
|
69
|
+
originalName: string;
|
|
70
|
+
displayName: string;
|
|
71
|
+
} & {
|
|
72
|
+
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(({ title, description }: TitleProps) => React.JSX.Element) & {
|
|
73
|
+
original: ({ title, description }: TitleProps) => React.JSX.Element;
|
|
74
|
+
originalName: string;
|
|
75
|
+
displayName: string;
|
|
76
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
77
|
+
};
|
|
78
|
+
Footer: (({ children }: FooterProps) => React.JSX.Element) & {
|
|
79
|
+
original: ({ children }: FooterProps) => React.JSX.Element;
|
|
80
|
+
originalName: string;
|
|
81
|
+
displayName: string;
|
|
82
|
+
} & {
|
|
83
|
+
original: (({ children }: FooterProps) => React.JSX.Element) & {
|
|
84
|
+
original: ({ children }: FooterProps) => React.JSX.Element;
|
|
85
|
+
originalName: string;
|
|
86
|
+
displayName: string;
|
|
87
|
+
};
|
|
88
|
+
originalName: string;
|
|
89
|
+
displayName: string;
|
|
90
|
+
} & {
|
|
91
|
+
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(({ children }: FooterProps) => React.JSX.Element) & {
|
|
92
|
+
original: ({ children }: FooterProps) => React.JSX.Element;
|
|
93
|
+
originalName: string;
|
|
94
|
+
displayName: string;
|
|
95
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
96
|
+
};
|
|
97
|
+
Error: ({ title, description }: ErrorProps) => React.JSX.Element | null;
|
|
98
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Logo, makeDecoratable } from "@webiny/app-admin";
|
|
3
|
+
import { Alert, Grid, Heading, Text } from "@webiny/admin-ui";
|
|
4
|
+
const Container = makeDecoratable("ViewContainer", ({
|
|
5
|
+
children
|
|
6
|
+
}) => {
|
|
7
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
8
|
+
className: "w-full h-screen bg-neutral-light flex-1"
|
|
9
|
+
}, /*#__PURE__*/React.createElement("section", {
|
|
10
|
+
className: "m-auto flex flex-col justify-center min-h-screen"
|
|
11
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
className: "mx-auto"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(Logo, null)), /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: "w-full max-w-[480px] mx-auto my-lg"
|
|
15
|
+
}, children)));
|
|
16
|
+
});
|
|
17
|
+
const Content = makeDecoratable("ViewContent", ({
|
|
18
|
+
children
|
|
19
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: "relative p-lg pt-md bg-neutral-base rounded-xl"
|
|
21
|
+
}, children));
|
|
22
|
+
const Footer = makeDecoratable("ViewFooter", ({
|
|
23
|
+
children
|
|
24
|
+
}) => {
|
|
25
|
+
return /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Grid.Column, {
|
|
26
|
+
span: 12,
|
|
27
|
+
className: "text-center mt-lg"
|
|
28
|
+
}, children));
|
|
29
|
+
});
|
|
30
|
+
const Title = makeDecoratable("ViewTitle", ({
|
|
31
|
+
title,
|
|
32
|
+
description
|
|
33
|
+
}) => {
|
|
34
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "mb-md"
|
|
36
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
37
|
+
level: 4
|
|
38
|
+
}, title), description && /*#__PURE__*/React.createElement(Text, {
|
|
39
|
+
as: "div",
|
|
40
|
+
size: "sm",
|
|
41
|
+
className: "text-neutral-strong"
|
|
42
|
+
}, description));
|
|
43
|
+
});
|
|
44
|
+
export const Error = ({
|
|
45
|
+
title = "Something went wrong",
|
|
46
|
+
description
|
|
47
|
+
}) => {
|
|
48
|
+
if (!description) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: "mb-lg"
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
54
|
+
title: title,
|
|
55
|
+
type: "danger"
|
|
56
|
+
}, description));
|
|
57
|
+
};
|
|
58
|
+
export const View = {
|
|
59
|
+
Container,
|
|
60
|
+
Content,
|
|
61
|
+
Title,
|
|
62
|
+
Footer,
|
|
63
|
+
Error
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=View.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Logo","makeDecoratable","Alert","Grid","Heading","Text","Container","children","createElement","className","Content","Footer","Column","span","Title","title","description","level","as","size","Error","type","View"],"sources":["View.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Logo, makeDecoratable } from \"@webiny/app-admin\";\nimport { Alert, Grid, Heading, Text } from \"@webiny/admin-ui\";\n\nexport interface ContainerProps {\n children: React.ReactNode;\n}\n\nconst Container = makeDecoratable(\"ViewContainer\", ({ children }: ContainerProps) => {\n return (\n <div className={\"w-full h-screen bg-neutral-light flex-1\"}>\n <section className={\"m-auto flex flex-col justify-center min-h-screen\"}>\n <div className={\"mx-auto\"}>\n <Logo />\n </div>\n <div className={\"w-full max-w-[480px] mx-auto my-lg\"}>{children}</div>\n </section>\n </div>\n );\n});\n\nexport interface ContentProps {\n children: React.ReactNode;\n}\n\nconst Content = makeDecoratable(\"ViewContent\", ({ children }: ContentProps) => (\n <div className={\"relative p-lg pt-md bg-neutral-base rounded-xl\"}>{children}</div>\n));\n\nexport interface FooterProps {\n children: React.ReactNode;\n}\n\nconst Footer = makeDecoratable(\"ViewFooter\", ({ children }: FooterProps) => {\n return (\n <Grid>\n <Grid.Column span={12} className={\"text-center mt-lg\"}>\n {children}\n </Grid.Column>\n </Grid>\n );\n});\n\nexport interface TitleProps {\n title: string;\n description?: React.ReactNode;\n}\n\nconst Title = makeDecoratable(\"ViewTitle\", ({ title, description }: TitleProps) => {\n return (\n <div className={\"mb-md\"}>\n <Heading level={4}>{title}</Heading>\n {description && (\n <Text as={\"div\"} size={\"sm\"} className={\"text-neutral-strong\"}>\n {description}\n </Text>\n )}\n </div>\n );\n});\n\nexport interface ErrorProps {\n title?: string;\n description?: string | null;\n}\n\nexport const Error = ({ title = \"Something went wrong\", description }: ErrorProps) => {\n if (!description) {\n return null;\n }\n\n return (\n <div className={\"mb-lg\"}>\n <Alert title={title} type={\"danger\"}>\n {description}\n </Alert>\n </div>\n );\n};\n\nexport const View = {\n Container,\n Content,\n Title,\n Footer,\n Error\n};\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,IAAI,EAAEC,eAAe,QAAQ,mBAAmB;AACzD,SAASC,KAAK,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,QAAQ,kBAAkB;AAM7D,MAAMC,SAAS,GAAGL,eAAe,CAAC,eAAe,EAAE,CAAC;EAAEM;A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sBAAsB;EAAEC;AAAwB,CAAC,KAAK;EAClF,IAAI,CAACA,WAAW,EAAE;IACd,OAAO,IAAI;EACf;EAEA,oBACIjB,KAAA,CAAAS,aAAA;IAAKC,SAAS,EAAE;EAAQ,gBACpBV,KAAA,CAAAS,aAAA,CAACN,KAAK;IAACa,KAAK,EAAEA,KAAM;IAACM,IAAI,EAAE;EAAS,GAC/BL,WACE,CACN,CAAC;AAEd,CAAC;AAED,OAAO,MAAMM,IAAI,GAAG;EAChBhB,SAAS;EACTI,OAAO;EACPI,KAAK;EACLH,MAAM;EACNS;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1" fill="currentColor">
|
|
3
|
+
<g id="surface1">
|
|
4
|
+
<path style=" stroke:none;fill-rule:nonzero;fill-opacity:1;" d="M 18.378906 19.414062 L 15.941406 12 L 22.320312 7.417969 L 14.4375 7.417969 L 12 0 L 19.890625 0 L 22.328125 7.417969 C 23.742188 11.71875 22.285156 16.613281 18.378906 19.414062 Z M 5.621094 19.414062 L 12 24 L 18.378906 19.414062 L 12 14.832031 Z M 1.675781 7.414062 C 0.1875 11.953125 1.917969 16.757812 5.613281 19.417969 L 5.613281 19.414062 L 8.054688 12 L 1.679688 7.414062 L 9.5625 7.417969 L 12 0 L 4.113281 0 Z M 1.675781 7.414062 "/>
|
|
5
|
+
</g>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./LoginContent.js\";\nexport * from \"./View.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Auth0Presenter as Abstraction } from "./abstractions.js";
|
|
2
|
+
import { LogInUseCase } from "@webiny/app-admin/features/security/LogIn";
|
|
3
|
+
import { IdentityContext } from "@webiny/app-admin/features/security/IdentityContext/index.js";
|
|
4
|
+
declare class Auth0PresenterImpl implements Abstraction.Interface {
|
|
5
|
+
private identity;
|
|
6
|
+
private loginUseCase;
|
|
7
|
+
private auth0Client;
|
|
8
|
+
private idTokenProvider;
|
|
9
|
+
private loggingIn;
|
|
10
|
+
private checkingSession;
|
|
11
|
+
constructor(identity: IdentityContext.Interface, loginUseCase: LogInUseCase.Interface);
|
|
12
|
+
get vm(): {
|
|
13
|
+
isAuthenticated: boolean;
|
|
14
|
+
isLoggingIn: boolean;
|
|
15
|
+
checkingSession: boolean;
|
|
16
|
+
};
|
|
17
|
+
init(params: Abstraction.InitParams): Promise<void>;
|
|
18
|
+
authenticate(): void;
|
|
19
|
+
private login;
|
|
20
|
+
private checkSession;
|
|
21
|
+
private getAuth0;
|
|
22
|
+
private getIdTokenProvider;
|
|
23
|
+
}
|
|
24
|
+
export declare const Auth0Presenter: typeof Auth0PresenterImpl & {
|
|
25
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IAuth0Presenter>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { makeAutoObservable, runInAction } from "mobx";
|
|
2
|
+
import { Auth0Client } from "@auth0/auth0-spa-js";
|
|
3
|
+
import { Auth0Presenter as Abstraction } from "./abstractions.js";
|
|
4
|
+
import { LogInUseCase } from "@webiny/app-admin/features/security/LogIn";
|
|
5
|
+
import { IdentityContext } from "@webiny/app-admin/features/security/IdentityContext/index.js";
|
|
6
|
+
import { IdTokenProvider } from "./IdTokenProvider.js";
|
|
7
|
+
class Auth0PresenterImpl {
|
|
8
|
+
loggingIn = false;
|
|
9
|
+
checkingSession = false;
|
|
10
|
+
constructor(identity, loginUseCase) {
|
|
11
|
+
this.identity = identity;
|
|
12
|
+
this.loginUseCase = loginUseCase;
|
|
13
|
+
makeAutoObservable(this);
|
|
14
|
+
}
|
|
15
|
+
get vm() {
|
|
16
|
+
const identity = this.identity.getIdentity();
|
|
17
|
+
return {
|
|
18
|
+
isAuthenticated: identity.isAuthenticated,
|
|
19
|
+
isLoggingIn: this.loggingIn,
|
|
20
|
+
checkingSession: this.checkingSession
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async init(params) {
|
|
24
|
+
this.auth0Client = new Auth0Client({
|
|
25
|
+
domain: params.issuer,
|
|
26
|
+
clientId: params.clientId,
|
|
27
|
+
useRefreshTokens: true,
|
|
28
|
+
cacheLocation: "localstorage",
|
|
29
|
+
authorizationParams: {
|
|
30
|
+
redirect_uri: window.location.origin,
|
|
31
|
+
scope: "openid profile email offline_access"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Initialize IdTokenProvider
|
|
36
|
+
this.idTokenProvider = new IdTokenProvider(this.auth0Client);
|
|
37
|
+
|
|
38
|
+
// Handle redirect callback if present
|
|
39
|
+
const hasRedirectCallback = window.location.search.includes("code=") && window.location.search.includes("state=");
|
|
40
|
+
if (hasRedirectCallback) {
|
|
41
|
+
await this.auth0Client.handleRedirectCallback();
|
|
42
|
+
// Clean up URL
|
|
43
|
+
window.history.replaceState({}, document.title, window.location.pathname);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Check if already authenticated
|
|
47
|
+
const isAuthenticated = await this.checkSession();
|
|
48
|
+
if (isAuthenticated) {
|
|
49
|
+
await this.login();
|
|
50
|
+
return; // Don't check autoLogin if we're already authenticated
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Only auto-login if not authenticated and autoLogin is enabled
|
|
54
|
+
if (params.autoLogin && !hasRedirectCallback) {
|
|
55
|
+
this.authenticate();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
authenticate() {
|
|
59
|
+
this.getAuth0().loginWithRedirect({
|
|
60
|
+
appState: {
|
|
61
|
+
returnTo: window.location.pathname + window.location.search
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async login() {
|
|
66
|
+
runInAction(() => {
|
|
67
|
+
this.loggingIn = true;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Set logout callback
|
|
71
|
+
const logoutCallback = async () => {
|
|
72
|
+
this.getAuth0().logout({
|
|
73
|
+
openUrl: false
|
|
74
|
+
});
|
|
75
|
+
const url = new URL(`${window.location}`);
|
|
76
|
+
url.searchParams.set("action", "logout");
|
|
77
|
+
window.history.replaceState({}, "", url);
|
|
78
|
+
};
|
|
79
|
+
await this.loginUseCase.execute({
|
|
80
|
+
idTokenProvider: () => this.getIdTokenProvider().getIdToken(),
|
|
81
|
+
logoutCallback
|
|
82
|
+
});
|
|
83
|
+
runInAction(() => {
|
|
84
|
+
this.loggingIn = false;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async checkSession() {
|
|
88
|
+
runInAction(() => {
|
|
89
|
+
this.checkingSession = true;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// First check if tokens exist in cache (don't try to refresh)
|
|
93
|
+
const cachedToken = await this.getAuth0().getTokenSilently({
|
|
94
|
+
cacheMode: "cache-only"
|
|
95
|
+
});
|
|
96
|
+
runInAction(() => {
|
|
97
|
+
this.checkingSession = false;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// No token in cache
|
|
101
|
+
if (!cachedToken) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
getAuth0() {
|
|
107
|
+
if (!this.auth0Client) {
|
|
108
|
+
throw new Error("Auth0Client is not initialized.");
|
|
109
|
+
}
|
|
110
|
+
return this.auth0Client;
|
|
111
|
+
}
|
|
112
|
+
getIdTokenProvider() {
|
|
113
|
+
if (!this.idTokenProvider) {
|
|
114
|
+
throw new Error("IdTokenProvider is not initialized.");
|
|
115
|
+
}
|
|
116
|
+
return this.idTokenProvider;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export const Auth0Presenter = Abstraction.createImplementation({
|
|
120
|
+
implementation: Auth0PresenterImpl,
|
|
121
|
+
dependencies: [IdentityContext, LogInUseCase]
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=Auth0Presenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["makeAutoObservable","runInAction","Auth0Client","Auth0Presenter","Abstraction","LogInUseCase","IdentityContext","IdTokenProvider","Auth0PresenterImpl","loggingIn","checkingSession","constructor","identity","loginUseCase","vm","getIdentity","isAuthenticated","isLoggingIn","init","params","auth0Client","domain","issuer","clientId","useRefreshTokens","cacheLocation","authorizationParams","redirect_uri","window","location","origin","scope","idTokenProvider","hasRedirectCallback","search","includes","handleRedirectCallback","history","replaceState","document","title","pathname","checkSession","login","autoLogin","authenticate","getAuth0","loginWithRedirect","appState","returnTo","logoutCallback","logout","openUrl","url","URL","searchParams","set","execute","getIdTokenProvider","getIdToken","cachedToken","getTokenSilently","cacheMode","Error","createImplementation","implementation","dependencies"],"sources":["Auth0Presenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport { Auth0Client } from \"@auth0/auth0-spa-js\";\nimport { Auth0Presenter as Abstraction } from \"./abstractions.js\";\nimport { LogInUseCase } from \"@webiny/app-admin/features/security/LogIn\";\nimport { IdentityContext } from \"@webiny/app-admin/features/security/IdentityContext/index.js\";\nimport { IdTokenProvider } from \"./IdTokenProvider.js\";\n\nclass Auth0PresenterImpl implements Abstraction.Interface {\n private auth0Client: Auth0Client | undefined;\n private idTokenProvider: IdTokenProvider | undefined;\n private loggingIn = false;\n private checkingSession = false;\n\n constructor(\n private identity: IdentityContext.Interface,\n private loginUseCase: LogInUseCase.Interface\n ) {\n makeAutoObservable(this);\n }\n\n get vm() {\n const identity = this.identity.getIdentity();\n\n return {\n isAuthenticated: identity.isAuthenticated,\n isLoggingIn: this.loggingIn,\n checkingSession: this.checkingSession\n };\n }\n\n async init(params: Abstraction.InitParams): Promise<void> {\n this.auth0Client = new Auth0Client({\n domain: params.issuer,\n clientId: params.clientId,\n useRefreshTokens: true,\n cacheLocation: \"localstorage\",\n authorizationParams: {\n redirect_uri: window.location.origin,\n scope: \"openid profile email offline_access\"\n }\n });\n\n // Initialize IdTokenProvider\n this.idTokenProvider = new IdTokenProvider(this.auth0Client);\n\n // Handle redirect callback if present\n const hasRedirectCallback =\n window.location.search.includes(\"code=\") && window.location.search.includes(\"state=\");\n\n if (hasRedirectCallback) {\n await this.auth0Client.handleRedirectCallback();\n // Clean up URL\n window.history.replaceState({}, document.title, window.location.pathname);\n }\n\n // Check if already authenticated\n const isAuthenticated = await this.checkSession();\n\n if (isAuthenticated) {\n await this.login();\n return; // Don't check autoLogin if we're already authenticated\n }\n\n // Only auto-login if not authenticated and autoLogin is enabled\n if (params.autoLogin && !hasRedirectCallback) {\n this.authenticate();\n }\n }\n\n authenticate() {\n this.getAuth0().loginWithRedirect({\n appState: { returnTo: window.location.pathname + window.location.search }\n });\n }\n\n private async login(): Promise<void> {\n runInAction(() => {\n this.loggingIn = true;\n });\n\n // Set logout callback\n const logoutCallback = async (): Promise<void> => {\n this.getAuth0().logout({ openUrl: false });\n\n const url = new URL(`${window.location}`);\n url.searchParams.set(\"action\", \"logout\");\n window.history.replaceState({}, \"\", url);\n };\n\n await this.loginUseCase.execute({\n idTokenProvider: () => this.getIdTokenProvider().getIdToken(),\n logoutCallback\n });\n\n runInAction(() => {\n this.loggingIn = false;\n });\n }\n\n private async checkSession(): Promise<boolean> {\n runInAction(() => {\n this.checkingSession = true;\n });\n\n // First check if tokens exist in cache (don't try to refresh)\n const cachedToken = await this.getAuth0().getTokenSilently({ cacheMode: \"cache-only\" });\n\n runInAction(() => {\n this.checkingSession = false;\n });\n\n // No token in cache\n if (!cachedToken) {\n return false;\n }\n\n return true;\n }\n\n private getAuth0() {\n if (!this.auth0Client) {\n throw new Error(\"Auth0Client is not initialized.\");\n }\n return this.auth0Client;\n }\n\n private getIdTokenProvider() {\n if (!this.idTokenProvider) {\n throw new Error(\"IdTokenProvider is not initialized.\");\n }\n return this.idTokenProvider;\n }\n}\n\nexport const Auth0Presenter = Abstraction.createImplementation({\n implementation: Auth0PresenterImpl,\n dependencies: [IdentityContext, LogInUseCase]\n});\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,WAAW,QAAQ,MAAM;AACtD,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,cAAc,IAAIC,WAAW;AACtC,SAASC,YAAY,QAAQ,2CAA2C;AACxE,SAASC,eAAe,QAAQ,8DAA8D;AAC9F,SAASC,eAAe;AAExB,MAAMC,kBAAkB,CAAkC;EAG9CC,SAAS,GAAG,KAAK;EACjBC,eAAe,GAAG,KAAK;EAE/BC,WAAWA,CACCC,QAAmC,EACnCC,YAAoC,EAC9C;IAAA,KAFUD,QAAmC,GAAnCA,QAAmC;IAAA,KACnCC,YAAoC,GAApCA,YAAoC;IAE5Cb,kBAAkB,CAAC,IAAI,CAAC;EAC5B;EAEA,IAAIc,EAAEA,CAAA,EAAG;IACL,MAAMF,QAAQ,GAAG,IAAI,CAACA,QAAQ,CAACG,WAAW,CAAC,CAAC;IAE5C,OAAO;MACHC,eAAe,EAAEJ,QAAQ,CAACI,eAAe;MACzCC,WAAW,EAAE,IAAI,CAACR,SAAS;MAC3BC,eAAe,EAAE,IAAI,CAACA;IAC1B,CAAC;EACL;EAEA,MAAMQ,IAAIA,CAACC,MAA8B,EAAiB;IACtD,IAAI,CAACC,WAAW,GAAG,IAAIlB,WAAW,CAAC;MAC/BmB,MAAM,EAAEF,MAAM,CAACG,MAAM;MACrBC,QAAQ,EAAEJ,MAAM,CAACI,QAAQ;MACzBC,gBAAgB,EAAE,IAAI;MACtBC,aAAa,EAAE,cAAc;MAC7BC,mBAAmB,EAAE;QACjBC,YAAY,EAAEC,MAAM,CAACC,QAAQ,CAACC,MAAM;QACpCC,KAAK,EAAE;MACX;IACJ,CAAC,CA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,OAAO,IAAI,CAAC/B,eAAe;EAC/B;AACJ;AAEA,OAAO,MAAM7B,cAAc,GAAGC,WAAW,CAAC4D,oBAAoB,CAAC;EAC3DC,cAAc,EAAEzD,kBAAkB;EAClC0D,YAAY,EAAE,CAAC5D,eAAe,EAAED,YAAY;AAChD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const EXPIRATION_BUFFER = 10;
|
|
2
|
+
export class IdTokenProvider {
|
|
3
|
+
constructor(auth0Client) {
|
|
4
|
+
this.auth0Client = auth0Client;
|
|
5
|
+
}
|
|
6
|
+
async getIdToken() {
|
|
7
|
+
// Check if token is expired
|
|
8
|
+
const isExpired = await this.isTokenExpired();
|
|
9
|
+
|
|
10
|
+
// Use the appropriate cache mode based on expiration
|
|
11
|
+
const cacheMode = isExpired ? "off" : undefined;
|
|
12
|
+
const response = await this.auth0Client.getTokenSilently({
|
|
13
|
+
cacheMode,
|
|
14
|
+
detailedResponse: true
|
|
15
|
+
});
|
|
16
|
+
return response.id_token || "";
|
|
17
|
+
}
|
|
18
|
+
async isTokenExpired() {
|
|
19
|
+
try {
|
|
20
|
+
const claims = await this.auth0Client.getIdTokenClaims();
|
|
21
|
+
if (!claims || !claims.exp) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
const now = Math.floor(Date.now() / 1000);
|
|
25
|
+
return claims.exp < now + EXPIRATION_BUFFER;
|
|
26
|
+
} catch {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=IdTokenProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EXPIRATION_BUFFER","IdTokenProvider","constructor","auth0Client","getIdToken","isExpired","isTokenExpired","cacheMode","undefined","response","getTokenSilently","detailedResponse","id_token","claims","getIdTokenClaims","exp","now","Math","floor","Date"],"sources":["IdTokenProvider.ts"],"sourcesContent":["import type { Auth0Client } from \"@auth0/auth0-spa-js\";\n\nconst EXPIRATION_BUFFER = 10;\n\nexport class IdTokenProvider {\n constructor(private auth0Client: Auth0Client) {}\n\n async getIdToken(): Promise<string> {\n // Check if token is expired\n const isExpired = await this.isTokenExpired();\n\n // Use the appropriate cache mode based on expiration\n const cacheMode = isExpired ? \"off\" : undefined;\n\n const response = await this.auth0Client.getTokenSilently({\n cacheMode,\n detailedResponse: true\n });\n\n return response.id_token || \"\";\n }\n\n private async isTokenExpired(): Promise<boolean> {\n try {\n const claims = await this.auth0Client.getIdTokenClaims();\n if (!claims || !claims.exp) {\n return true;\n }\n\n const now = Math.floor(Date.now() / 1000);\n\n return claims.exp < now + EXPIRATION_BUFFER;\n } catch {\n return true;\n }\n }\n}\n"],"mappings":"AAEA,MAAMA,iBAAiB,GAAG,EAAE;AAE5B,OAAO,MAAMC,eAAe,CAAC;EACzBC,WAAWA,CAASC,WAAwB,EAAE;IAAA,KAA1BA,WAAwB,GAAxBA,WAAwB;EAAG;EAE/C,MAAMC,UAAUA,CAAA,EAAoB;IAChC;IACA,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACC,cAAc,CAAC,CAAC;;IAE7C;IACA,MAAMC,SAAS,GAAGF,SAAS,GAAG,KAAK,GAAGG,SAAS;IAE/C,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACN,WAAW,CAACO,gBAAgB,CAAC;MACrDH,SAAS;MACTI,gBAAgB,EAAE;IACtB,CAAC,CAAC;IAEF,OAAOF,QAAQ,CAACG,QAAQ,IAAI,EAAE;EAClC;EAEA,MAAcN,cAAcA,CAAA,EAAqB;IAC7C,IAAI;MACA,MAAMO,MAAM,GAAG,MAAM,IAAI,CAACV,WAAW,CAACW,gBAAgB,CAAC,CAAC;MACxD,IAAI,CAACD,MAAM,IAAI,CAACA,MAAM,CAACE,GAAG,EAAE;QACxB,OAAO,IAAI;MACf;MAEA,MAAMC,GAAG,GAAGC,IAAI,CAACC,KAAK,CAACC,IAAI,CAACH,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;MAEzC,OAAOH,MAAM,CAACE,GAAG,GAAGC,GAAG,GAAGhB,iBAAiB;IAC/C,CAAC,CAAC,MAAM;MACJ,OAAO,IAAI;IACf;EACJ;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Auth0Client } from "@auth0/auth0-spa-js";
|
|
2
|
+
export type IOnLogin = (auth0: Auth0Client) => void;
|
|
3
|
+
export interface IAuth0Presenter {
|
|
4
|
+
vm: {
|
|
5
|
+
isAuthenticated: boolean;
|
|
6
|
+
isLoggingIn: boolean;
|
|
7
|
+
checkingSession: boolean;
|
|
8
|
+
};
|
|
9
|
+
init(params: IAuth0InitParams): Promise<void>;
|
|
10
|
+
authenticate(): void;
|
|
11
|
+
}
|
|
12
|
+
export interface IAuth0InitParams {
|
|
13
|
+
issuer: string;
|
|
14
|
+
clientId: string;
|
|
15
|
+
autoLogin: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const Auth0Presenter: import("@webiny/di").Abstraction<IAuth0Presenter>;
|
|
18
|
+
export declare namespace Auth0Presenter {
|
|
19
|
+
type Interface = IAuth0Presenter;
|
|
20
|
+
type InitParams = IAuth0InitParams;
|
|
21
|
+
type OnLogin = IOnLogin;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","Auth0Presenter"],"sources":["abstractions.ts"],"sourcesContent":["import { Auth0Client } from \"@auth0/auth0-spa-js\";\nimport { createAbstraction } from \"@webiny/feature/admin\";\n\nexport type IOnLogin = (auth0: Auth0Client) => void;\n\nexport interface IAuth0Presenter {\n vm: {\n isAuthenticated: boolean;\n isLoggingIn: boolean;\n checkingSession: boolean;\n };\n init(params: IAuth0InitParams): Promise<void>;\n authenticate(): void;\n}\n\nexport interface IAuth0InitParams {\n issuer: string;\n clientId: string;\n autoLogin: boolean;\n}\n\nexport const Auth0Presenter = createAbstraction<IAuth0Presenter>(\"Auth0Presenter\");\n\nexport namespace Auth0Presenter {\n export type Interface = IAuth0Presenter;\n export type InitParams = IAuth0InitParams;\n export type OnLogin = IOnLogin;\n}\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,uBAAuB;AAoBzD,OAAO,MAAMC,cAAc,GAAGD,iBAAiB,CAAkB,gBAAgB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
+
import { Auth0Presenter } from "./Auth0Presenter.js";
|
|
3
|
+
import { Auth0Presenter as Presenter } from "./abstractions.js";
|
|
4
|
+
export const Auth0Feature = createFeature({
|
|
5
|
+
name: "Auth0",
|
|
6
|
+
register(container) {
|
|
7
|
+
container.register(Auth0Presenter);
|
|
8
|
+
},
|
|
9
|
+
resolve(container) {
|
|
10
|
+
return {
|
|
11
|
+
presenter: container.resolve(Presenter)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","Auth0Presenter","Presenter","Auth0Feature","name","register","container","resolve","presenter"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { Auth0Presenter } from \"./Auth0Presenter.js\";\nimport { Auth0Presenter as Presenter } from \"./abstractions.js\";\n\nexport const Auth0Feature = createFeature({\n name: \"Auth0\",\n register(container) {\n container.register(Auth0Presenter);\n },\n resolve(container) {\n return {\n presenter: container.resolve(Presenter)\n };\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,cAAc;AACvB,SAASA,cAAc,IAAIC,SAAS;AAEpC,OAAO,MAAMC,YAAY,GAAGH,aAAa,CAAC;EACtCI,IAAI,EAAE,OAAO;EACbC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACJ,cAAc,CAAC;EACtC,CAAC;EACDM,OAAOA,CAACD,SAAS,EAAE;IACf,OAAO;MACHE,SAAS,EAAEF,SAAS,CAACC,OAAO,CAACL,SAAS;IAC1C,CAAC;EACL;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Auth0Presenter } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Auth0Presenter"],"sources":["index.ts"],"sourcesContent":["export { Auth0Presenter } from \"./abstractions.js\";\n"],"mappings":"AAAA,SAASA,cAAc","ignoreList":[]}
|
package/admin/index.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export { Auth0 } from "./Auth0.js";
|
|
2
|
+
export type { Auth0Props } from "./Auth0.js";
|
|
3
|
+
export declare const Components: {
|
|
4
|
+
LoginContent: (({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: import("./components/LoginContent.js").LoginContentProps) => import("react").JSX.Element) & {
|
|
5
|
+
original: ({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: import("./components/LoginContent.js").LoginContentProps) => import("react").JSX.Element;
|
|
6
|
+
originalName: string;
|
|
7
|
+
displayName: string;
|
|
8
|
+
} & {
|
|
9
|
+
original: (({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: import("./components/LoginContent.js").LoginContentProps) => import("react").JSX.Element) & {
|
|
10
|
+
original: ({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: import("./components/LoginContent.js").LoginContentProps) => import("react").JSX.Element;
|
|
11
|
+
originalName: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
originalName: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
} & {
|
|
17
|
+
createDecorator: (decorator: import("@webiny/app/index.js").ComponentDecorator<(({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: import("./components/LoginContent.js").LoginContentProps) => import("react").JSX.Element) & {
|
|
18
|
+
original: ({ onLogin, isLoggingIn, checkingSession, isAuthenticated }: import("./components/LoginContent.js").LoginContentProps) => import("react").JSX.Element;
|
|
19
|
+
originalName: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
22
|
+
};
|
|
23
|
+
View: {
|
|
24
|
+
Container: (({ children }: import("./components/View.js").ContainerProps) => import("react").JSX.Element) & {
|
|
25
|
+
original: ({ children }: import("./components/View.js").ContainerProps) => import("react").JSX.Element;
|
|
26
|
+
originalName: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
} & {
|
|
29
|
+
original: (({ children }: import("./components/View.js").ContainerProps) => import("react").JSX.Element) & {
|
|
30
|
+
original: ({ children }: import("./components/View.js").ContainerProps) => import("react").JSX.Element;
|
|
31
|
+
originalName: string;
|
|
32
|
+
displayName: string;
|
|
33
|
+
};
|
|
34
|
+
originalName: string;
|
|
35
|
+
displayName: string;
|
|
36
|
+
} & {
|
|
37
|
+
createDecorator: (decorator: import("@webiny/app/index.js").ComponentDecorator<(({ children }: import("./components/View.js").ContainerProps) => import("react").JSX.Element) & {
|
|
38
|
+
original: ({ children }: import("./components/View.js").ContainerProps) => import("react").JSX.Element;
|
|
39
|
+
originalName: string;
|
|
40
|
+
displayName: string;
|
|
41
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
42
|
+
};
|
|
43
|
+
Content: (({ children }: import("./components/View.js").ContentProps) => import("react").JSX.Element) & {
|
|
44
|
+
original: ({ children }: import("./components/View.js").ContentProps) => import("react").JSX.Element;
|
|
45
|
+
originalName: string;
|
|
46
|
+
displayName: string;
|
|
47
|
+
} & {
|
|
48
|
+
original: (({ children }: import("./components/View.js").ContentProps) => import("react").JSX.Element) & {
|
|
49
|
+
original: ({ children }: import("./components/View.js").ContentProps) => import("react").JSX.Element;
|
|
50
|
+
originalName: string;
|
|
51
|
+
displayName: string;
|
|
52
|
+
};
|
|
53
|
+
originalName: string;
|
|
54
|
+
displayName: string;
|
|
55
|
+
} & {
|
|
56
|
+
createDecorator: (decorator: import("@webiny/app/index.js").ComponentDecorator<(({ children }: import("./components/View.js").ContentProps) => import("react").JSX.Element) & {
|
|
57
|
+
original: ({ children }: import("./components/View.js").ContentProps) => import("react").JSX.Element;
|
|
58
|
+
originalName: string;
|
|
59
|
+
displayName: string;
|
|
60
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
61
|
+
};
|
|
62
|
+
Title: (({ title, description }: import("./components/View.js").TitleProps) => import("react").JSX.Element) & {
|
|
63
|
+
original: ({ title, description }: import("./components/View.js").TitleProps) => import("react").JSX.Element;
|
|
64
|
+
originalName: string;
|
|
65
|
+
displayName: string;
|
|
66
|
+
} & {
|
|
67
|
+
original: (({ title, description }: import("./components/View.js").TitleProps) => import("react").JSX.Element) & {
|
|
68
|
+
original: ({ title, description }: import("./components/View.js").TitleProps) => import("react").JSX.Element;
|
|
69
|
+
originalName: string;
|
|
70
|
+
displayName: string;
|
|
71
|
+
};
|
|
72
|
+
originalName: string;
|
|
73
|
+
displayName: string;
|
|
74
|
+
} & {
|
|
75
|
+
createDecorator: (decorator: import("@webiny/app/index.js").ComponentDecorator<(({ title, description }: import("./components/View.js").TitleProps) => import("react").JSX.Element) & {
|
|
76
|
+
original: ({ title, description }: import("./components/View.js").TitleProps) => import("react").JSX.Element;
|
|
77
|
+
originalName: string;
|
|
78
|
+
displayName: string;
|
|
79
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
80
|
+
};
|
|
81
|
+
Footer: (({ children }: import("./components/View.js").FooterProps) => import("react").JSX.Element) & {
|
|
82
|
+
original: ({ children }: import("./components/View.js").FooterProps) => import("react").JSX.Element;
|
|
83
|
+
originalName: string;
|
|
84
|
+
displayName: string;
|
|
85
|
+
} & {
|
|
86
|
+
original: (({ children }: import("./components/View.js").FooterProps) => import("react").JSX.Element) & {
|
|
87
|
+
original: ({ children }: import("./components/View.js").FooterProps) => import("react").JSX.Element;
|
|
88
|
+
originalName: string;
|
|
89
|
+
displayName: string;
|
|
90
|
+
};
|
|
91
|
+
originalName: string;
|
|
92
|
+
displayName: string;
|
|
93
|
+
} & {
|
|
94
|
+
createDecorator: (decorator: import("@webiny/app/index.js").ComponentDecorator<(({ children }: import("./components/View.js").FooterProps) => import("react").JSX.Element) & {
|
|
95
|
+
original: ({ children }: import("./components/View.js").FooterProps) => import("react").JSX.Element;
|
|
96
|
+
originalName: string;
|
|
97
|
+
displayName: string;
|
|
98
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
99
|
+
};
|
|
100
|
+
Error: ({ title, description }: import("./components/View.js").ErrorProps) => import("react").JSX.Element | null;
|
|
101
|
+
};
|
|
102
|
+
};
|
package/admin/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Auth0","LoginContent","View","Components"],"sources":["index.ts"],"sourcesContent":["export { Auth0 } from \"./Auth0.js\";\nexport type { Auth0Props } from \"./Auth0.js\";\nimport { LoginContent, View } from \"./components/index.js\";\n\nexport const Components = {\n LoginContent,\n View\n};\n"],"mappings":"AAAA,SAASA,KAAK;AAEd,SAASC,YAAY,EAAEC,IAAI;AAE3B,OAAO,MAAMC,UAAU,GAAG;EACtBF,YAAY;EACZC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OidcIdentityProvider } from "@webiny/api-core/idp";
|
|
2
|
+
import { Auth0IdpConfig } from "./abstractions.js";
|
|
3
|
+
declare class Auth0IdentityProviderImpl implements OidcIdentityProvider.Interface {
|
|
4
|
+
private config;
|
|
5
|
+
issuer: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
constructor(config: Auth0IdpConfig.Interface);
|
|
8
|
+
isApplicable(token: OidcIdentityProvider.JwtPayload): boolean;
|
|
9
|
+
getIdentity(jwt: OidcIdentityProvider.JwtPayload): Promise<OidcIdentityProvider.IdentityData>;
|
|
10
|
+
verifyTokenClaims(token: OidcIdentityProvider.JwtPayload): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare const Auth0IdentityProvider: typeof Auth0IdentityProviderImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/idp/abstractions.js").IOidcIdentityProvider>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { OidcIdentityProvider } from "@webiny/api-core/idp";
|
|
2
|
+
import { Auth0IdpConfig } from "./abstractions.js";
|
|
3
|
+
class Auth0IdentityProviderImpl {
|
|
4
|
+
issuer = String(process.env.AUTH0_ISSUER);
|
|
5
|
+
clientId = String(process.env.AUTH0_CLIENT_ID);
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
isApplicable(token) {
|
|
10
|
+
const issuer = token.iss;
|
|
11
|
+
if (!issuer) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return new URL(issuer).hostname.endsWith(".auth0.com") ?? false;
|
|
15
|
+
}
|
|
16
|
+
async getIdentity(jwt) {
|
|
17
|
+
const identity = await this.config.getIdentity(jwt);
|
|
18
|
+
return {
|
|
19
|
+
...identity,
|
|
20
|
+
type: "admin",
|
|
21
|
+
profile: {
|
|
22
|
+
...identity.profile,
|
|
23
|
+
external: true
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async verifyTokenClaims(token) {
|
|
28
|
+
if (this.config.verifyTokenClaims) {
|
|
29
|
+
await this.config.verifyTokenClaims(token);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export const Auth0IdentityProvider = OidcIdentityProvider.createImplementation({
|
|
34
|
+
implementation: Auth0IdentityProviderImpl,
|
|
35
|
+
dependencies: [Auth0IdpConfig]
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=Auth0IdentityProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OidcIdentityProvider","Auth0IdpConfig","Auth0IdentityProviderImpl","issuer","String","process","env","AUTH0_ISSUER","clientId","AUTH0_CLIENT_ID","constructor","config","isApplicable","token","iss","URL","hostname","endsWith","getIdentity","jwt","identity","type","profile","external","verifyTokenClaims","Auth0IdentityProvider","createImplementation","implementation","dependencies"],"sources":["Auth0IdentityProvider.ts"],"sourcesContent":["import { OidcIdentityProvider } from \"@webiny/api-core/idp\";\nimport { Auth0IdpConfig } from \"./abstractions.js\";\n\nclass Auth0IdentityProviderImpl implements OidcIdentityProvider.Interface {\n public issuer = String(process.env.AUTH0_ISSUER);\n public clientId = String(process.env.AUTH0_CLIENT_ID);\n\n constructor(private config: Auth0IdpConfig.Interface) {}\n\n isApplicable(token: OidcIdentityProvider.JwtPayload) {\n const issuer = token.iss as string;\n if (!issuer) {\n return false;\n }\n\n return new URL(issuer).hostname.endsWith(\".auth0.com\") ?? false;\n }\n\n async getIdentity(\n jwt: OidcIdentityProvider.JwtPayload\n ): Promise<OidcIdentityProvider.IdentityData> {\n const identity = await this.config.getIdentity(jwt);\n\n return {\n ...identity,\n type: \"admin\",\n profile: {\n ...identity.profile,\n external: true\n }\n };\n }\n\n async verifyTokenClaims(token: OidcIdentityProvider.JwtPayload): Promise<void> {\n if (this.config.verifyTokenClaims) {\n await this.config.verifyTokenClaims(token);\n }\n }\n}\n\nexport const Auth0IdentityProvider = OidcIdentityProvider.createImplementation({\n implementation: Auth0IdentityProviderImpl,\n dependencies: [Auth0IdpConfig]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,sBAAsB;AAC3D,SAASC,cAAc;AAEvB,MAAMC,yBAAyB,CAA2C;EAC/DC,MAAM,GAAGC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,YAAY,CAAC;EACzCC,QAAQ,GAAGJ,MAAM,CAACC,OAAO,CAACC,GAAG,CAACG,eAAe,CAAC;EAErDC,WAAWA,CAASC,MAAgC,EAAE;IAAA,KAAlCA,MAAgC,GAAhCA,MAAgC;EAAG;EAEvDC,YAAYA,CAACC,KAAsC,EAAE;IACjD,MAAMV,MAAM,GAAGU,KAAK,CAACC,GAAa;IAClC,IAAI,CAACX,MAAM,EAAE;MACT,OAAO,KAAK;IAChB;IAEA,OAAO,IAAIY,GAAG,CAACZ,MAAM,CAAC,CAACa,QAAQ,CAACC,QAAQ,CAAC,YAAY,CAAC,IAAI,KAAK;EACnE;EAEA,MAAMC,WAAWA,CACbC,GAAoC,EACM;IAC1C,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACT,MAAM,CAACO,WAAW,CAACC,GAAG,CAAC;IAEnD,OAAO;MACH,GAAGC,QAAQ;MACXC,IAAI,EAAE,OAAO;MACbC,OAAO,EAAE;QACL,GAAGF,QAAQ,CAACE,OAAO;QACnBC,QAAQ,EAAE;MACd;IACJ,CAAC;EACL;EAEA,MAAMC,iBAAiBA,CAACX,KAAsC,EAAiB;IAC3E,IAAI,IAAI,CAACF,MAAM,CAACa,iBAAiB,EAAE;MAC/B,MAAM,IAAI,CAACb,MAAM,CAACa,iBAAiB,CAACX,KAAK,CAAC;IAC9C;EACJ;AACJ;AAEA,OAAO,MAAMY,qBAAqB,GAAGzB,oBAAoB,CAAC0B,oBAAoB,CAAC;EAC3EC,cAAc,EAAEzB,yBAAyB;EACzC0B,YAAY,EAAE,CAAC3B,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type jwt from "jsonwebtoken";
|
|
2
|
+
import type { IdentityData } from "@webiny/api-core/idp";
|
|
3
|
+
export type Auth0Identity = Omit<IdentityData, "type"> & {
|
|
4
|
+
profile: Omit<IdentityData["profile"], "external">;
|
|
5
|
+
};
|
|
6
|
+
export interface IAuth0IdpConfig {
|
|
7
|
+
getIdentity(token: jwt.JwtPayload): Promise<Auth0Identity> | Auth0Identity;
|
|
8
|
+
verifyTokenClaims?(token: jwt.JwtPayload): Promise<void> | void;
|
|
9
|
+
}
|
|
10
|
+
export declare const Auth0IdpConfig: import("@webiny/di").Abstraction<IAuth0IdpConfig>;
|
|
11
|
+
export declare namespace Auth0IdpConfig {
|
|
12
|
+
type Interface = IAuth0IdpConfig;
|
|
13
|
+
type IdentityData = Auth0Identity;
|
|
14
|
+
type JwtPayload = jwt.JwtPayload;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","Auth0IdpConfig"],"sources":["abstractions.ts"],"sourcesContent":["import type jwt from \"jsonwebtoken\";\nimport type { IdentityData } from \"@webiny/api-core/idp\";\nimport { createAbstraction } from \"@webiny/feature/api\";\n\nexport type Auth0Identity = Omit<IdentityData, \"type\"> & {\n profile: Omit<IdentityData[\"profile\"], \"external\">;\n};\n\nexport interface IAuth0IdpConfig {\n getIdentity(token: jwt.JwtPayload): Promise<Auth0Identity> | Auth0Identity;\n verifyTokenClaims?(token: jwt.JwtPayload): Promise<void> | void;\n}\n\nexport const Auth0IdpConfig = createAbstraction<IAuth0IdpConfig>(\"Auth0IdpConfig\");\n\nexport namespace Auth0IdpConfig {\n export type Interface = IAuth0IdpConfig;\n export type IdentityData = Auth0Identity;\n export type JwtPayload = jwt.JwtPayload;\n}\n"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,qBAAqB;AAWvD,OAAO,MAAMC,cAAc,GAAGD,iBAAiB,CAAkB,gBAAgB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Auth0IdpFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { Auth0IdentityProvider } from "./Auth0IdentityProvider.js";
|
|
3
|
+
export const Auth0IdpFeature = createFeature({
|
|
4
|
+
name: "Auth0Idp",
|
|
5
|
+
register(container) {
|
|
6
|
+
container.register(Auth0IdentityProvider).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","Auth0IdentityProvider","Auth0IdpFeature","name","register","container","inSingletonScope"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Auth0IdentityProvider } from \"./Auth0IdentityProvider.js\";\n\nexport const Auth0IdpFeature = createFeature({\n name: \"Auth0Idp\",\n register(container) {\n container.register(Auth0IdentityProvider).inSingletonScope();\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,eAAe,GAAGF,aAAa,CAAC;EACzCG,IAAI,EAAE,UAAU;EAChBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,qBAAqB,CAAC,CAACK,gBAAgB,CAAC,CAAC;EAChE;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Auth0IdpConfig } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Auth0IdpConfig"],"sources":["index.ts"],"sourcesContent":["export { Auth0IdpConfig } from \"./abstractions.js\";\n"],"mappings":"AAAA,SAASA,cAAc","ignoreList":[]}
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Auth0IdpConfig","Auth0"],"sources":["index.ts"],"sourcesContent":["export { Auth0IdpConfig } from \"./api/features/Auth0Idp/abstractions.js\";\nexport { Auth0 } from \"./Auth0.js\";\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,KAAK","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/auth0",
|
|
3
|
+
"version": "0.0.0-unstable.61c048f412",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
10
|
+
},
|
|
11
|
+
"description": "Security plugins for Auth0",
|
|
12
|
+
"author": "Webiny Ltd.",
|
|
13
|
+
"license": "Webiny Enterprise",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@auth0/auth0-spa-js": "2.13.1",
|
|
16
|
+
"@webiny/admin-ui": "0.0.0-unstable.61c048f412",
|
|
17
|
+
"@webiny/api-core": "0.0.0-unstable.61c048f412",
|
|
18
|
+
"@webiny/app": "0.0.0-unstable.61c048f412",
|
|
19
|
+
"@webiny/app-admin": "0.0.0-unstable.61c048f412",
|
|
20
|
+
"@webiny/feature": "0.0.0-unstable.61c048f412",
|
|
21
|
+
"@webiny/project": "0.0.0-unstable.61c048f412",
|
|
22
|
+
"@webiny/project-aws": "0.0.0-unstable.61c048f412",
|
|
23
|
+
"jsonwebtoken": "9.0.3",
|
|
24
|
+
"mobx": "6.15.0",
|
|
25
|
+
"mobx-react-lite": "3.4.3",
|
|
26
|
+
"react": "18.2.0",
|
|
27
|
+
"react-dom": "18.2.0",
|
|
28
|
+
"zod": "3.25.76"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/jsonwebtoken": "9.0.10",
|
|
32
|
+
"@types/jwk-to-pem": "2.0.3",
|
|
33
|
+
"@webiny/build-tools": "0.0.0-unstable.61c048f412",
|
|
34
|
+
"rimraf": "6.1.2",
|
|
35
|
+
"typescript": "5.9.3"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"directory": "dist"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "61c048f412d6b4aa70c1d105aab21e3fa69730f3"
|
|
42
|
+
}
|