@zitadel/sdk-qwik 0.1.0-alpha.11
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/LICENSE +21 -0
- package/README.md +58 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.qwik.mjs +83 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ZITADEL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @zitadel/sdk-qwik
|
|
2
|
+
|
|
3
|
+
Qwik components for the Zitadel auth UI, for client-side SPAs (Vite, etc.).
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
TypeScript ≥ 5.0 — the published type definitions re-export with `export type *`, which TypeScript introduced in 5.0.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { component$ } from '@builder.io/qwik';
|
|
13
|
+
import { ZitadelLogin, configureZitadel } from '@zitadel/sdk-qwik';
|
|
14
|
+
|
|
15
|
+
export default component$(() => {
|
|
16
|
+
const project = configureZitadel({
|
|
17
|
+
projectId: import.meta.env.VITE_ZITADEL_PROJECT_ID,
|
|
18
|
+
proxyPath: '/__nextgen',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return <ZitadelLogin project={project} purpose="login" postSignInUrl="/" />;
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`<ZitadelLogout project={project} postSignOutUrl="/login" />` works the same way.
|
|
26
|
+
|
|
27
|
+
The widget's flow events are surfaced as optional QRL callbacks:
|
|
28
|
+
`onFlowStep$`, `onFlowInput$`, `onFlowComplete$`, and `onFlowError$`.
|
|
29
|
+
|
|
30
|
+
> The SDK binds `project` (and the discrete `projectId` / `proxyPath`) to the
|
|
31
|
+
> element as DOM properties, the same as the other framework SDKs.
|
|
32
|
+
|
|
33
|
+
## Proxying to the backend (deployment)
|
|
34
|
+
|
|
35
|
+
The widgets call `${proxyPath}/…` same-origin (default `/__nextgen`). A SPA has no
|
|
36
|
+
server, so on Vercel use `@zitadel/edge-proxy` to forward those calls:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
// api/__nextgen/[...path].ts (Vercel Edge Function)
|
|
40
|
+
import { handleProxy, resolveConfig } from '@zitadel/edge-proxy';
|
|
41
|
+
export const config = { runtime: 'edge' };
|
|
42
|
+
const proxyConfig = resolveConfig({
|
|
43
|
+
apiUrl: process.env.NEXTGEN_API_URL ?? '',
|
|
44
|
+
});
|
|
45
|
+
export default (req: Request) => handleProxy(req, proxyConfig);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
// vercel.json
|
|
50
|
+
{
|
|
51
|
+
"rewrites": [
|
|
52
|
+
{ "source": "/__nextgen/(.*)", "destination": "/api/__nextgen/$1" }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
For local development you can skip the proxy and point `proxyPath` straight at the
|
|
58
|
+
backend (cross-origin), e.g. `proxyPath: "http://localhost:4000"`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ZitadelLogin as ZitadelLoginElement, ZitadelLogout as ZitadelLogoutElement } from '@zitadel/components';
|
|
2
|
+
import { ZitadelLoginConfig, ZitadelLoginHandlers, ZitadelLogoutConfig, ZitadelLogoutHandlers } from '@zitadel/sdk-core/types';
|
|
3
|
+
import { QRL, Signal } from '@builder.io/qwik';
|
|
4
|
+
import { configureZitadel, getApi, getZitadelConfig, ZitadelConfig, ZitadelProject } from '@zitadel/api/config';
|
|
5
|
+
export { configureZitadel, getApi, getZitadelConfig };
|
|
6
|
+
export type { ZitadelConfig, ZitadelProject };
|
|
7
|
+
export * from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Wraps each plain-callback handler from the shared SPA contract in a Qwik
|
|
10
|
+
* {@link QRL} and suffixes the prop name with `$`, so the Qwik prop set is
|
|
11
|
+
* derived from `@zitadel/sdk-core` and can never drift from the events the
|
|
12
|
+
* widget emits. Adding a contract event surfaces a new `on…$` QRL prop here.
|
|
13
|
+
*/
|
|
14
|
+
type Qrlify<H> = {
|
|
15
|
+
readonly [K in keyof H as `${K & string}$`]?: H[K] extends ((detail: infer D) => void) | undefined ? QRL<(detail: D) => void> : never;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Props for {@link ZitadelLogin}. Supply the SDK handle via {@link project}, or
|
|
19
|
+
* the discrete `projectId` / `proxyPath` the widget reads as properties — the
|
|
20
|
+
* widget uses whichever is present. The `on…$` QRL callbacks are derived from
|
|
21
|
+
* the shared {@link ZitadelLoginHandlers} contract. Pass an optional {@link ref}
|
|
22
|
+
* signal to obtain the underlying `<zitadel-login>` element imperatively.
|
|
23
|
+
*/
|
|
24
|
+
export type ZitadelLoginProps = ZitadelLoginConfig & Qrlify<ZitadelLoginHandlers> & {
|
|
25
|
+
/**
|
|
26
|
+
* Optional signal populated with the underlying `<zitadel-login>` element
|
|
27
|
+
* once it mounts, mirroring React's `forwardRef`. Wired alongside the
|
|
28
|
+
* component's internal host signal, so event forwarding stays intact.
|
|
29
|
+
*/
|
|
30
|
+
readonly ref?: Signal<ZitadelLoginElement | undefined>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Qwik component wrapping the `<zitadel-login>` web component. Binds the
|
|
34
|
+
* {@link ZitadelProject} handle as a DOM property (or the discrete project id /
|
|
35
|
+
* proxy path) and forwards the widget's `zitadel-*` events as optional
|
|
36
|
+
* callbacks. `useVisibleTask$` (eager `document-ready`, so listeners attach on
|
|
37
|
+
* load rather than on first visibility) wires the native listeners; Qwik's
|
|
38
|
+
* declarative `useOn` does not catch these programmatic custom events.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ZitadelLogin: import('@builder.io/qwik').Component<ZitadelLoginProps>;
|
|
41
|
+
/**
|
|
42
|
+
* Props for {@link ZitadelLogout}. Supply the SDK handle via {@link project}, or
|
|
43
|
+
* the discrete `projectId` / `proxyPath` the widget reads as properties — the
|
|
44
|
+
* widget uses whichever is present. The `on…$` QRL callbacks are derived from
|
|
45
|
+
* the shared {@link ZitadelLogoutHandlers} contract. Pass an optional {@link ref}
|
|
46
|
+
* signal to obtain the underlying `<zitadel-logout>` element imperatively.
|
|
47
|
+
*/
|
|
48
|
+
export type ZitadelLogoutProps = ZitadelLogoutConfig & Qrlify<ZitadelLogoutHandlers> & {
|
|
49
|
+
/**
|
|
50
|
+
* Optional signal populated with the underlying `<zitadel-logout>` element
|
|
51
|
+
* once it mounts, mirroring React's `forwardRef`. Wired alongside the
|
|
52
|
+
* component's internal host signal, so event forwarding stays intact.
|
|
53
|
+
*/
|
|
54
|
+
readonly ref?: Signal<ZitadelLogoutElement | undefined>;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Qwik component wrapping the `<zitadel-logout>` web component. Binds the
|
|
58
|
+
* {@link ZitadelProject} handle as a DOM property (or the discrete project id /
|
|
59
|
+
* proxy path) and forwards the widget's `zitadel-signout` event as an optional
|
|
60
|
+
* callback.
|
|
61
|
+
*/
|
|
62
|
+
export declare const ZitadelLogout: import('@builder.io/qwik').Component<ZitadelLogoutProps>;
|
|
63
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,IAAI,mBAAmB,EACnC,aAAa,IAAI,oBAAoB,EACtC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAA0C,KAAK,GAAG,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EACL,gBAAgB,EAChB,MAAM,EACN,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAC9C,cAAc,SAAS,CAAC;AAoBxB;;;;;GAKG;AACH,KAAK,MAAM,CAAC,CAAC,IAAI;IACf,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,GAC9F,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC,GACxB,KAAK;CACV,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAChD,MAAM,CAAC,oBAAoB,CAAC,GAAG;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;CACxD,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,yDAuCvB,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAClD,MAAM,CAAC,qBAAqB,CAAC,GAAG;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAC;CACzD,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,aAAa,0DA6BxB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx } from "@builder.io/qwik/jsx-runtime";
|
|
2
|
+
import "@zitadel/components";
|
|
3
|
+
import { component$, useSignal, useVisibleTask$ } from "@builder.io/qwik";
|
|
4
|
+
import { configureZitadel, getApi, getZitadelConfig } from "@zitadel/api/config";
|
|
5
|
+
function projectProp(project, projectId, proxyPath) {
|
|
6
|
+
return {
|
|
7
|
+
project,
|
|
8
|
+
projectId,
|
|
9
|
+
proxyPath
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function eventDetail(event) {
|
|
13
|
+
return event.detail;
|
|
14
|
+
}
|
|
15
|
+
const ZitadelLogin = component$((props) => {
|
|
16
|
+
const host = useSignal();
|
|
17
|
+
useVisibleTask$(({ track, cleanup }) => {
|
|
18
|
+
const el = track(() => host.value);
|
|
19
|
+
if (!el) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const onStep = (event) => void props.onFlowStep$?.(eventDetail(event));
|
|
23
|
+
const onInput = (event) => void props.onFlowInput$?.(eventDetail(event));
|
|
24
|
+
const onComplete = (event) => void props.onFlowComplete$?.(eventDetail(event));
|
|
25
|
+
const onError = (event) => void props.onFlowError$?.(eventDetail(event));
|
|
26
|
+
el.addEventListener("zitadel-flow-step", onStep);
|
|
27
|
+
el.addEventListener("zitadel-flow-input", onInput);
|
|
28
|
+
el.addEventListener("zitadel-flow-complete", onComplete);
|
|
29
|
+
el.addEventListener("zitadel-flow-error", onError);
|
|
30
|
+
cleanup(() => {
|
|
31
|
+
el.removeEventListener("zitadel-flow-step", onStep);
|
|
32
|
+
el.removeEventListener("zitadel-flow-input", onInput);
|
|
33
|
+
el.removeEventListener("zitadel-flow-complete", onComplete);
|
|
34
|
+
el.removeEventListener("zitadel-flow-error", onError);
|
|
35
|
+
});
|
|
36
|
+
}, {
|
|
37
|
+
strategy: "document-ready"
|
|
38
|
+
});
|
|
39
|
+
return /* @__PURE__ */ jsx("zitadel-login", {
|
|
40
|
+
ref: (el) => {
|
|
41
|
+
host.value = el;
|
|
42
|
+
if (props.ref) {
|
|
43
|
+
props.ref.value = el;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
...projectProp(props.project, props.projectId, props.proxyPath),
|
|
47
|
+
purpose: props.purpose ?? "login",
|
|
48
|
+
"post-sign-in-url": props.postSignInUrl
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
const ZitadelLogout = component$((props) => {
|
|
52
|
+
const host = useSignal();
|
|
53
|
+
useVisibleTask$(({ track, cleanup }) => {
|
|
54
|
+
const el = track(() => host.value);
|
|
55
|
+
if (!el) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const onSignout = (event) => void props.onSignout$?.(eventDetail(event));
|
|
59
|
+
el.addEventListener("zitadel-signout", onSignout);
|
|
60
|
+
cleanup(() => {
|
|
61
|
+
el.removeEventListener("zitadel-signout", onSignout);
|
|
62
|
+
});
|
|
63
|
+
}, {
|
|
64
|
+
strategy: "document-ready"
|
|
65
|
+
});
|
|
66
|
+
return /* @__PURE__ */ jsx("zitadel-logout", {
|
|
67
|
+
ref: (el) => {
|
|
68
|
+
host.value = el;
|
|
69
|
+
if (props.ref) {
|
|
70
|
+
props.ref.value = el;
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
...projectProp(props.project, props.projectId, props.proxyPath),
|
|
74
|
+
"post-sign-out-url": props.postSignOutUrl
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
export {
|
|
78
|
+
ZitadelLogin,
|
|
79
|
+
ZitadelLogout,
|
|
80
|
+
configureZitadel,
|
|
81
|
+
getApi,
|
|
82
|
+
getZitadelConfig
|
|
83
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zitadel/sdk-qwik",
|
|
3
|
+
"version": "0.1.0-alpha.11",
|
|
4
|
+
"description": "Qwik components for the Zitadel auth UI (client-side SPA).",
|
|
5
|
+
"homepage": "https://github.com/zitadel/nextgen/tree/main/packages/sdk-qwik#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/zitadel/nextgen/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/zitadel/nextgen.git",
|
|
12
|
+
"directory": "packages/sdk-qwik"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/index.qwik.mjs",
|
|
20
|
+
"qwik": "./dist/index.qwik.mjs",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.qwik.mjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@zitadel/api": "0.1.0-alpha.11",
|
|
33
|
+
"@zitadel/components": "0.1.0-alpha.11",
|
|
34
|
+
"@zitadel/sdk-core": "0.1.0-alpha.11"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@builder.io/qwik": "^1.5.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@builder.io/qwik": "^1.19.0",
|
|
41
|
+
"@eslint/js": "^9.0.0",
|
|
42
|
+
"@eslint/json": "^0.11.0",
|
|
43
|
+
"@eslint/markdown": "^6.0.0",
|
|
44
|
+
"eslint": "^9.0.0",
|
|
45
|
+
"eslint-config-prettier": "^10.0.0",
|
|
46
|
+
"eslint-import-resolver-typescript": "^3.7.0",
|
|
47
|
+
"eslint-plugin-import": "^2.31.0",
|
|
48
|
+
"eslint-plugin-perfectionist": "^4.0.0",
|
|
49
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
50
|
+
"eslint-plugin-qwik": "^1.19.0",
|
|
51
|
+
"jsdom": "^29.0.2",
|
|
52
|
+
"prettier": "^3.0.0",
|
|
53
|
+
"typescript": "^6.0.3",
|
|
54
|
+
"typescript-eslint": "^8.0.0",
|
|
55
|
+
"vite": "^7.3.5",
|
|
56
|
+
"vite-plugin-dts": "^4.5.0",
|
|
57
|
+
"vitest": "^3.0.0"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "vite build --mode lib",
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
62
|
+
"test": "vitest run",
|
|
63
|
+
"lint": "eslint ."
|
|
64
|
+
}
|
|
65
|
+
}
|