@novasamatech/host-papp-ui 0.5.0-8 → 0.5.0-9
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as e, jsxs as n, Fragment as
|
|
2
|
-
import { memo as
|
|
3
|
-
import {
|
|
1
|
+
import { jsx as e, jsxs as n, Fragment as d } from "react/jsx-runtime";
|
|
2
|
+
import { memo as p, useMemo as u } from "react";
|
|
3
|
+
import { useIdentity as m } from "../hooks/identity.js";
|
|
4
4
|
import { useAuthenticateFlow as f } from "../providers/AuthProvider.js";
|
|
5
5
|
import { Modal as g } from "../ui/Modal.js";
|
|
6
6
|
import { QrCode as h } from "../ui/QrCode.js";
|
|
7
|
-
const i = ({ children: t }) => /* @__PURE__ */ e("span", { style: { fontSize: "16px", textAlign: "center", flexShrink: 0, color: "white", fontFamily: "sans-serif" }, children: t }), w =
|
|
8
|
-
const t = f(), s = t.status.step !== "none", o = (
|
|
9
|
-
|
|
10
|
-
}, r =
|
|
7
|
+
const i = ({ children: t }) => /* @__PURE__ */ e("span", { style: { fontSize: "16px", textAlign: "center", flexShrink: 0, color: "white", fontFamily: "sans-serif" }, children: t }), w = p(() => {
|
|
8
|
+
const t = f(), s = t.status.step !== "none", o = (c) => {
|
|
9
|
+
c || t.abortAuthentication();
|
|
10
|
+
}, r = u(() => t.status.step === "finished" ? t.status.session : null, [t.status.step]), [a, l] = m(r?.remoteAccount.accountId ?? null);
|
|
11
11
|
return /* @__PURE__ */ e(g, { isOpen: s, onOpenChange: o, width: 300, children: /* @__PURE__ */ n(
|
|
12
12
|
"div",
|
|
13
13
|
{
|
|
@@ -22,7 +22,7 @@ const i = ({ children: t }) => /* @__PURE__ */ e("span", { style: { fontSize: "1
|
|
|
22
22
|
children: [
|
|
23
23
|
/* @__PURE__ */ e(i, { children: "Sign in Polkadot app" }),
|
|
24
24
|
t.status.step === "pairing" && /* @__PURE__ */ e(h, { value: t.status.payload, size: 270 }),
|
|
25
|
-
t.status.step === "finished" && /* @__PURE__ */ e(
|
|
25
|
+
t.status.step === "finished" && /* @__PURE__ */ e(d, { children: /* @__PURE__ */ n(i, { children: [
|
|
26
26
|
"Welcome back, ",
|
|
27
27
|
a?.liteUsername ?? (l ? "..." : "user"),
|
|
28
28
|
"!"
|
package/dist/hooks/identity.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Identity, UserSession } from '../../../host-papp';
|
|
2
|
-
|
|
2
|
+
import { AccountId } from '../../../statement-store';
|
|
3
|
+
export declare function useIdentity(accountId: AccountId | null): readonly [Identity | null, boolean];
|
|
3
4
|
export declare function useSessionIdentity(session: UserSession | null): readonly [Identity | null, boolean];
|
package/dist/hooks/identity.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { toHex as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { usePapp as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
return
|
|
7
|
-
if (!
|
|
8
|
-
|
|
1
|
+
import { toHex as c } from "@polkadot-api/utils";
|
|
2
|
+
import { useState as o, useEffect as a } from "react";
|
|
3
|
+
import { usePapp as d } from "../flow/PappProvider.js";
|
|
4
|
+
function p(t) {
|
|
5
|
+
const r = d(), [f, e] = o(!1), [s, i] = o(null), n = t ? c(t) : null;
|
|
6
|
+
return a(() => {
|
|
7
|
+
if (!n) {
|
|
8
|
+
e(!1);
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
let
|
|
12
|
-
return
|
|
11
|
+
let u = !0;
|
|
12
|
+
return e(!0), r.identity.getIdentity(n).match(
|
|
13
13
|
(l) => {
|
|
14
|
-
|
|
14
|
+
u && (i(l), e(!1));
|
|
15
15
|
},
|
|
16
16
|
() => {
|
|
17
|
-
|
|
17
|
+
u && (i(null), e(!1));
|
|
18
18
|
}
|
|
19
19
|
), () => {
|
|
20
|
-
|
|
20
|
+
e(!1), u = !1;
|
|
21
21
|
};
|
|
22
|
-
}, [
|
|
22
|
+
}, [n]), [s, f];
|
|
23
23
|
}
|
|
24
|
-
function g(
|
|
25
|
-
return
|
|
24
|
+
function g(t) {
|
|
25
|
+
return p(t ? t.remoteAccount.accountId : null);
|
|
26
26
|
}
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
p as useIdentity,
|
|
29
29
|
g as useSessionIdentity
|
|
30
30
|
};
|
|
@@ -3,7 +3,7 @@ import { PropsWithChildren } from 'react';
|
|
|
3
3
|
type State = {
|
|
4
4
|
status: AuthentificationStatus;
|
|
5
5
|
pending: boolean;
|
|
6
|
-
authenticate(): Promise<
|
|
6
|
+
authenticate(): Promise<void>;
|
|
7
7
|
abortAuthentication(): void;
|
|
8
8
|
disconnect(session: UserSession): Promise<void>;
|
|
9
9
|
};
|
|
@@ -4,7 +4,7 @@ import { usePapp as u } from "../flow/PappProvider.js";
|
|
|
4
4
|
const c = f({
|
|
5
5
|
status: { step: "none" },
|
|
6
6
|
pending: !1,
|
|
7
|
-
authenticate: () => Promise.resolve(
|
|
7
|
+
authenticate: () => Promise.resolve(),
|
|
8
8
|
abortAuthentication() {
|
|
9
9
|
},
|
|
10
10
|
async disconnect() {
|
|
@@ -13,19 +13,19 @@ const c = f({
|
|
|
13
13
|
const e = u(), s = v(e.sso.status.subscribe, e.sso.status.read);
|
|
14
14
|
return x(`Polkadot app authentification status: ${s.step}`), s;
|
|
15
15
|
}, k = ({ children: e }) => {
|
|
16
|
-
const [s, n] = b(!1), t = u(), i = A(),
|
|
17
|
-
t.sso.authenticate().andTee(() => n(!1)).orTee(() => n(!1)).match(o, a);
|
|
18
|
-
})), [t]),
|
|
19
|
-
(o) => new Promise((a,
|
|
16
|
+
const [s, n] = b(!1), t = u(), i = A(), p = r(() => (n(!0), new Promise((o, a) => {
|
|
17
|
+
t.sso.authenticate().andTee(() => n(!1)).orTee(() => n(!1)).match(() => o(), a);
|
|
18
|
+
})), [t]), d = r(
|
|
19
|
+
(o) => new Promise((a, l) => t.sessions.disconnect(o).match(a, l)),
|
|
20
20
|
[t]
|
|
21
|
-
),
|
|
21
|
+
), h = {
|
|
22
22
|
pending: s,
|
|
23
23
|
status: i,
|
|
24
|
-
authenticate:
|
|
24
|
+
authenticate: p,
|
|
25
25
|
abortAuthentication: t.sso.abortAuthentication,
|
|
26
|
-
disconnect:
|
|
26
|
+
disconnect: d
|
|
27
27
|
};
|
|
28
|
-
return /* @__PURE__ */ m(c.Provider, { value:
|
|
28
|
+
return /* @__PURE__ */ m(c.Provider, { value: h, children: e });
|
|
29
29
|
};
|
|
30
30
|
export {
|
|
31
31
|
k as AuthProvider,
|
|
@@ -8,18 +8,18 @@ const t = i(null), v = () => {
|
|
|
8
8
|
return s;
|
|
9
9
|
}, x = ({ children: s }) => {
|
|
10
10
|
const o = {
|
|
11
|
-
session:
|
|
11
|
+
session: a()
|
|
12
12
|
};
|
|
13
13
|
return /* @__PURE__ */ r(t.Provider, { value: o, children: s });
|
|
14
|
-
},
|
|
14
|
+
}, S = () => {
|
|
15
15
|
const s = d(), [e, o] = c([]);
|
|
16
16
|
return l(() => s.sessions.sessions.subscribe(o), [s]), n(`Sessions: ${e.length}`), e;
|
|
17
|
-
},
|
|
18
|
-
const e =
|
|
19
|
-
return n(`Selected user: ${e?.
|
|
17
|
+
}, a = () => {
|
|
18
|
+
const e = S().at(0) ?? null;
|
|
19
|
+
return n(`Selected user: ${e?.remoteAccount.accountId.toString() ?? "None"}`), e;
|
|
20
20
|
};
|
|
21
21
|
export {
|
|
22
22
|
x as SessionsProvider,
|
|
23
23
|
v as useSession,
|
|
24
|
-
|
|
24
|
+
a as useUserSession
|
|
25
25
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-papp-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.0-
|
|
4
|
+
"version": "0.5.0-9",
|
|
5
5
|
"description": "Polkadot app UI Flow",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"qr-code-styling": "1.9.2",
|
|
33
|
-
"@polkadot-api/utils": "0.2.0"
|
|
33
|
+
"@polkadot-api/utils": "^0.2.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/react": "19.2.7",
|