@zitadel/sdk-react 0.1.0-alpha.9 → 1.0.0-alpha.21
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 +18 -26
- package/dist/index.d.ts +37 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -17
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/types.d.ts +10 -1
- package/dist/types.d.ts.map +1 -0
- package/package.json +21 -20
- package/dist/chunk-6F4PWJZI.js +0 -0
- package/dist/chunk-QJALWXNY.js +0 -22
- package/dist/react.d.ts +0 -32
- package/dist/react.js +0 -8
- package/dist/types.js +0 -1
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
React components for the Zitadel auth UI, for client-side SPAs.
|
|
4
4
|
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
TypeScript ≥ 5.0 — the published type definitions re-export with `export type *`, which TypeScript introduced in 5.0.
|
|
8
|
+
|
|
5
9
|
## Usage
|
|
6
10
|
|
|
7
11
|
```tsx
|
|
@@ -27,31 +31,19 @@ export function ProfilePage() {
|
|
|
27
31
|
}
|
|
28
32
|
```
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
The widgets call `${proxyPath}/…` same-origin (default `/__nextgen`). A SPA has no
|
|
33
|
-
server, so on Vercel (and Cloudflare/Netlify) use `@zitadel/edge-proxy` to forward
|
|
34
|
-
those calls to your Zitadel backend:
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
// api/__nextgen/[...path].ts (Vercel Edge Function)
|
|
38
|
-
import { handleProxy, resolveConfig } from '@zitadel/edge-proxy';
|
|
34
|
+
The signed-in session card is `<ZitadelSession project={project} />` (exported
|
|
35
|
+
as `ZitadelSession`).
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
const proxyConfig = resolveConfig({
|
|
42
|
-
apiUrl: process.env.NEXTGEN_API_URL ?? '',
|
|
43
|
-
});
|
|
44
|
-
export default (req: Request) => handleProxy(req, proxyConfig);
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
```json
|
|
48
|
-
// vercel.json
|
|
49
|
-
{
|
|
50
|
-
"rewrites": [
|
|
51
|
-
{ "source": "/__nextgen/(.*)", "destination": "/api/__nextgen/$1" }
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
```
|
|
37
|
+
## Proxying to the backend (deployment)
|
|
55
38
|
|
|
56
|
-
|
|
57
|
-
|
|
39
|
+
The widgets call `${proxyPath}/…` same-origin (default `/__nextgen`). In
|
|
40
|
+
production the same-origin path must come from your hosting platform — until
|
|
41
|
+
the CLI can scaffold those configs, **production SPA deployment is not yet
|
|
42
|
+
supported**; see
|
|
43
|
+
[ADR 036](https://github.com/zitadel/nextgen/blob/main/docs/adrs/036-api-credential-planes.md)
|
|
44
|
+
and [zitadel/nextgen#560](https://github.com/zitadel/nextgen/issues/560). The
|
|
45
|
+
CLI dev proxy covers local development.
|
|
46
|
+
|
|
47
|
+
For local development you can also skip the proxy and point `proxyPath`
|
|
48
|
+
straight at the backend (cross-origin), e.g. `proxyPath: "http://localhost:8080"`
|
|
49
|
+
(the `zitadel start` local runtime default port).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { configureZitadel, getApi, getZitadelConfig, ZitadelConfig, ZitadelProject } from '@zitadel/api/config';
|
|
2
|
+
import { ZitadelLogin as ZitadelLoginElement, ZitadelLogout as ZitadelLogoutElement, ZitadelSession as ZitadelSessionElement } from '@zitadel/components';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export { configureZitadel, getApi, getZitadelConfig };
|
|
5
|
+
export type { ZitadelConfig, ZitadelProject };
|
|
6
|
+
export * from './types';
|
|
7
|
+
export { businessLocales } from '@zitadel/components';
|
|
8
|
+
/**
|
|
9
|
+
* React component wrapping the `<zitadel-login>` web component. Binds the
|
|
10
|
+
* `ZitadelProject` handle as a DOM property (or the discrete project id /
|
|
11
|
+
* proxy path as attributes) and forwards the widget's `zitadel-*` events as
|
|
12
|
+
* optional callbacks.
|
|
13
|
+
*
|
|
14
|
+
* A forwarded `ref` resolves to the underlying `<zitadel-login>` DOM element,
|
|
15
|
+
* so consumers can imperatively access the upgraded web component.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ZitadelLogin: React.ForwardRefExoticComponent<import('@zitadel/sdk-core/types').ZitadelLoginConfig & import('@zitadel/sdk-core/types').ZitadelLoginHandlers & React.RefAttributes<ZitadelLoginElement>>;
|
|
18
|
+
/**
|
|
19
|
+
* React component wrapping the `<zitadel-logout>` web component. Binds the
|
|
20
|
+
* `ZitadelProject` handle as a DOM property (or the discrete project id /
|
|
21
|
+
* proxy path as attributes) and forwards the widget's `zitadel-signout` event
|
|
22
|
+
* as an optional callback.
|
|
23
|
+
*
|
|
24
|
+
* A forwarded `ref` resolves to the underlying `<zitadel-logout>` DOM element,
|
|
25
|
+
* so consumers can imperatively access the upgraded web component.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ZitadelLogout: React.ForwardRefExoticComponent<import('@zitadel/sdk-core/types').ZitadelLogoutConfig & import('@zitadel/sdk-core/types').ZitadelLogoutHandlers & React.RefAttributes<ZitadelLogoutElement>>;
|
|
28
|
+
/**
|
|
29
|
+
* React component wrapping the `<zitadel-session>` web component — the
|
|
30
|
+
* post-sign-in "signed in as" card. Binds the `ZitadelProject` handle as a DOM
|
|
31
|
+
* property (or the discrete project id / proxy path as attributes) and forwards
|
|
32
|
+
* the widget's `zitadel-signout` event as an optional callback.
|
|
33
|
+
*
|
|
34
|
+
* A forwarded `ref` resolves to the underlying `<zitadel-session>` DOM element.
|
|
35
|
+
*/
|
|
36
|
+
export declare const ZitadelSession: React.ForwardRefExoticComponent<import('@zitadel/sdk-core/types').ZitadelSessionConfig & import('@zitadel/sdk-core/types').ZitadelSessionHandlers & React.RefAttributes<ZitadelSessionElement>>;
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,MAAM,EACN,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,aAAa,IAAI,oBAAoB,EACrC,cAAc,IAAI,qBAAqB,EACxC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAC9C,cAAc,SAAS,CAAC;AAIxB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA0DtD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,2LAiBxB,CAAC;AAIF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,8LAUzB,CAAC;AAIF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,iMAU1B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "
|
|
5
|
-
import "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { createComponent as d } from "@lit/react";
|
|
3
|
+
import { configureZitadel as F, getApi as v, getZitadelConfig as y } from "@zitadel/api/config";
|
|
4
|
+
import { ZitadelLogin as m, ZitadelLogout as u, ZitadelSession as f } from "@zitadel/components";
|
|
5
|
+
import { businessLocales as b } from "@zitadel/components";
|
|
6
|
+
import * as l from "react";
|
|
7
|
+
const c = d({
|
|
8
|
+
react: l,
|
|
9
|
+
tagName: "zitadel-login",
|
|
10
|
+
elementClass: m,
|
|
11
|
+
events: {
|
|
12
|
+
onZitadelFlowStep: "zitadel-flow-step",
|
|
13
|
+
onZitadelFlowInput: "zitadel-flow-input",
|
|
14
|
+
onZitadelFlowComplete: "zitadel-flow-complete",
|
|
15
|
+
onZitadelFlowError: "zitadel-flow-error"
|
|
16
|
+
}
|
|
17
|
+
}), p = d({
|
|
18
|
+
react: l,
|
|
19
|
+
tagName: "zitadel-logout",
|
|
20
|
+
elementClass: u,
|
|
21
|
+
events: {
|
|
22
|
+
onZitadelSignout: "zitadel-signout"
|
|
23
|
+
}
|
|
24
|
+
}), L = d({
|
|
25
|
+
react: l,
|
|
26
|
+
tagName: "zitadel-session",
|
|
27
|
+
elementClass: f,
|
|
28
|
+
events: {
|
|
29
|
+
onZitadelSignout: "zitadel-signout"
|
|
30
|
+
}
|
|
31
|
+
}), w = l.forwardRef(
|
|
32
|
+
function({ purpose: e, onFlowStep: o, onFlowInput: i, onFlowComplete: a, onFlowError: r, ...Z }, g) {
|
|
33
|
+
return /* @__PURE__ */ n(
|
|
34
|
+
c,
|
|
35
|
+
{
|
|
36
|
+
...Z,
|
|
37
|
+
ref: g,
|
|
38
|
+
purpose: e ?? "login",
|
|
39
|
+
onZitadelFlowStep: o && ((t) => o(t.detail)),
|
|
40
|
+
onZitadelFlowInput: i && ((t) => i(t.detail)),
|
|
41
|
+
onZitadelFlowComplete: a && ((t) => a(t.detail)),
|
|
42
|
+
onZitadelFlowError: r && ((t) => r(t.detail))
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
w.displayName = "ZitadelLogin";
|
|
48
|
+
const z = l.forwardRef(
|
|
49
|
+
function({ onSignout: e, ...o }, i) {
|
|
50
|
+
return /* @__PURE__ */ n(
|
|
51
|
+
p,
|
|
52
|
+
{
|
|
53
|
+
...o,
|
|
54
|
+
ref: i,
|
|
55
|
+
onZitadelSignout: e && ((a) => e(a.detail))
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
z.displayName = "ZitadelLogout";
|
|
61
|
+
const S = l.forwardRef(
|
|
62
|
+
function({ onSignout: e, ...o }, i) {
|
|
63
|
+
return /* @__PURE__ */ n(
|
|
64
|
+
L,
|
|
65
|
+
{
|
|
66
|
+
...o,
|
|
67
|
+
ref: i,
|
|
68
|
+
onZitadelSignout: e && ((a) => e(a.detail))
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
S.displayName = "ZitadelSession";
|
|
13
74
|
export {
|
|
14
|
-
ZitadelLogin,
|
|
15
|
-
ZitadelLogout,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
75
|
+
w as ZitadelLogin,
|
|
76
|
+
z as ZitadelLogout,
|
|
77
|
+
S as ZitadelSession,
|
|
78
|
+
b as businessLocales,
|
|
79
|
+
F as configureZitadel,
|
|
80
|
+
v as getApi,
|
|
81
|
+
y as getZitadelConfig
|
|
19
82
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports the shared SPA widget types from `@zitadel/sdk-core`.
|
|
3
|
+
*
|
|
4
|
+
* `export type *` keeps this surface in lockstep with the core SPA contract: a
|
|
5
|
+
* type added there is re-exported here automatically, and none can be dropped by
|
|
6
|
+
* hand. The server-middleware types live in a separate core module and stay out
|
|
7
|
+
* of the browser SDK surface.
|
|
8
|
+
*/
|
|
9
|
+
export type * from '@zitadel/sdk-core/types';
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,mBAAmB,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zitadel/sdk-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-alpha.21",
|
|
4
4
|
"description": "React components for the Zitadel auth UI (client-side SPA).",
|
|
5
5
|
"homepage": "https://github.com/zitadel/nextgen/tree/main/packages/sdk-react#readme",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/zitadel/nextgen/issues"
|
|
8
8
|
},
|
|
9
|
-
"license": "MIT",
|
|
10
9
|
"repository": {
|
|
11
10
|
"type": "git",
|
|
12
11
|
"url": "git+https://github.com/zitadel/nextgen.git",
|
|
13
12
|
"directory": "packages/sdk-react"
|
|
14
13
|
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
15
16
|
"files": [
|
|
16
17
|
"dist"
|
|
17
18
|
],
|
|
18
|
-
"type": "module",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@lit/react": "^1.0.8",
|
|
30
|
-
"@zitadel/api": "
|
|
31
|
-
"@zitadel/
|
|
32
|
-
"@zitadel/
|
|
30
|
+
"@zitadel/api": "1.0.0-alpha.21",
|
|
31
|
+
"@zitadel/sdk-core": "1.0.0-alpha.21",
|
|
32
|
+
"@zitadel/components": "1.0.0-alpha.21"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=18",
|
|
@@ -37,33 +37,34 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@eslint/js": "^9.0.0",
|
|
40
|
+
"@eslint/json": "^0.11.0",
|
|
41
|
+
"@eslint/markdown": "^6.0.0",
|
|
40
42
|
"@testing-library/react": "^16.3.2",
|
|
41
43
|
"@types/react": "^19.2.14",
|
|
42
44
|
"eslint": "^9.0.0",
|
|
43
|
-
"jsdom": "^29.0.2",
|
|
44
|
-
"react": "^19.2.5",
|
|
45
|
-
"react-dom": "^19.2.5",
|
|
46
|
-
"tsup": "^8.3.5",
|
|
47
|
-
"typescript": "^5.7.3",
|
|
48
|
-
"vitest": "^3.0.0",
|
|
49
|
-
"@eslint/json": "^0.11.0",
|
|
50
|
-
"@eslint/markdown": "^6.0.0",
|
|
51
45
|
"eslint-config-prettier": "^10.0.0",
|
|
52
46
|
"eslint-import-resolver-typescript": "^3.7.0",
|
|
53
47
|
"eslint-plugin-import": "^2.31.0",
|
|
48
|
+
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
54
49
|
"eslint-plugin-perfectionist": "^4.0.0",
|
|
55
50
|
"eslint-plugin-prettier": "^5.0.0",
|
|
56
|
-
"prettier": "^3.0.0",
|
|
57
|
-
"typescript-eslint": "^8.0.0",
|
|
58
|
-
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
59
51
|
"eslint-plugin-react": "^7.37.0",
|
|
60
52
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
61
|
-
"eslint-plugin-testing-library": "^7.0.0"
|
|
53
|
+
"eslint-plugin-testing-library": "^7.0.0",
|
|
54
|
+
"jsdom": "^29.0.2",
|
|
55
|
+
"prettier": "^3.0.0",
|
|
56
|
+
"react": "^19.2.8",
|
|
57
|
+
"react-dom": "^19.2.8",
|
|
58
|
+
"typescript": "^6.0.3",
|
|
59
|
+
"typescript-eslint": "^8.0.0",
|
|
60
|
+
"vite": "^7.3.5",
|
|
61
|
+
"vite-plugin-dts": "^4.5.0",
|
|
62
|
+
"vitest": "^3.0.0"
|
|
62
63
|
},
|
|
63
64
|
"scripts": {
|
|
64
|
-
"build": "
|
|
65
|
+
"build": "vite build",
|
|
65
66
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
66
|
-
"test": "vitest run
|
|
67
|
+
"test": "vitest run",
|
|
67
68
|
"lint": "eslint ."
|
|
68
69
|
}
|
|
69
70
|
}
|
package/dist/chunk-6F4PWJZI.js
DELETED
|
File without changes
|
package/dist/chunk-QJALWXNY.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/react.tsx
|
|
2
|
-
import { createComponent } from "@lit/react";
|
|
3
|
-
import {
|
|
4
|
-
ZitadelLogin as ZitadelLoginElement,
|
|
5
|
-
ZitadelLogout as ZitadelLogoutElement
|
|
6
|
-
} from "@zitadel/components";
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
var ZitadelLogin = createComponent({
|
|
9
|
-
react: React,
|
|
10
|
-
tagName: "zitadel-login",
|
|
11
|
-
elementClass: ZitadelLoginElement
|
|
12
|
-
});
|
|
13
|
-
var ZitadelLogout = createComponent({
|
|
14
|
-
react: React,
|
|
15
|
-
tagName: "zitadel-logout",
|
|
16
|
-
elementClass: ZitadelLogoutElement
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
ZitadelLogin,
|
|
21
|
-
ZitadelLogout
|
|
22
|
-
};
|
package/dist/react.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as _lit_react from '@lit/react';
|
|
2
|
-
import { ZitadelLogin as ZitadelLogin$1, ZitadelLogout as ZitadelLogout$1 } from '@zitadel/components';
|
|
3
|
-
import '@zitadel/api/config';
|
|
4
|
-
import '@zitadel/sdk-core/types';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* React components for the Zitadel auth widgets.
|
|
8
|
-
*
|
|
9
|
-
* These wrap the framework-agnostic Lit web components from
|
|
10
|
-
* `@zitadel/components` with `@lit/react`'s `createComponent`, so they are real
|
|
11
|
-
* React components: typed props, refs, and events, with the SDK `project`
|
|
12
|
-
* handle bound as a DOM *property* (not an attribute) — which is what the
|
|
13
|
-
* elements read at startup.
|
|
14
|
-
*
|
|
15
|
-
* In a client-side SPA, build the handle with `configureZitadel(...)` and pass
|
|
16
|
-
* it as the `project` prop. Because the SPA renders after configuration, the
|
|
17
|
-
* prop is present when the element upgrades:
|
|
18
|
-
*
|
|
19
|
-
* ```tsx
|
|
20
|
-
* import { ZitadelLogin, configureZitadel } from "@zitadel/sdk-react";
|
|
21
|
-
*
|
|
22
|
-
* const project = configureZitadel({ projectId: "…", proxyPath: "/__nextgen" });
|
|
23
|
-
*
|
|
24
|
-
* export function LoginPage() {
|
|
25
|
-
* return <ZitadelLogin project={project} purpose="login" postSignInUrl="/" />;
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
declare const ZitadelLogin: _lit_react.ReactWebComponent<ZitadelLogin$1, {}>;
|
|
30
|
-
declare const ZitadelLogout: _lit_react.ReactWebComponent<ZitadelLogout$1, {}>;
|
|
31
|
-
|
|
32
|
-
export { ZitadelLogin, ZitadelLogout };
|
package/dist/react.js
DELETED
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./chunk-6F4PWJZI.js";
|