@rockerone/xprnkit 0.3.2 → 0.3.4

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.
Files changed (33) hide show
  1. package/README.md +141 -0
  2. package/build/components/identity/index.d.ts +2 -0
  3. package/build/components/identity/index.js +2 -0
  4. package/build/components/identity/xprn-account-list.d.ts +48 -0
  5. package/build/components/identity/xprn-account-list.js +106 -0
  6. package/build/components/identity/xprn-identity-proof-gate.d.ts +67 -0
  7. package/build/components/identity/xprn-identity-proof-gate.js +77 -0
  8. package/build/components/identity/xprn-identity.d.ts +4 -0
  9. package/build/components/identity/xprn-identity.js +5 -4
  10. package/build/components/identity/xprn-session-name.d.ts +23 -2
  11. package/build/components/identity/xprn-session-name.js +48 -3
  12. package/build/components/ui/dropdown.d.ts +3 -1
  13. package/build/components/ui/dropdown.js +4 -1
  14. package/build/components/xprn-transaction.js +3 -1
  15. package/build/global.css +118 -0
  16. package/build/providers/XPRNProvider.d.ts +60 -26
  17. package/build/providers/XPRNProvider.js +324 -267
  18. package/build/services/identity-proof/create-identity-proof.js +1 -0
  19. package/build/services/identity-proof/index.d.ts +5 -1
  20. package/build/services/identity-proof/index.js +3 -0
  21. package/build/services/identity-proof/token-utils.d.ts +48 -0
  22. package/build/services/identity-proof/token-utils.js +85 -0
  23. package/build/services/identity-proof/types.d.ts +25 -2
  24. package/build/services/identity-proof/use-identity-proof.js +5 -3
  25. package/build/services/identity-proof/validate-identity-proof.d.ts +51 -0
  26. package/build/services/identity-proof/validate-identity-proof.js +93 -0
  27. package/build/services/identity-proof/verify-identity-proof.d.ts +4 -4
  28. package/build/services/identity-proof/verify-identity-proof.js +15 -3
  29. package/build/utils/auth-storage.d.ts +126 -0
  30. package/build/utils/auth-storage.js +216 -0
  31. package/build/utils/index.d.ts +1 -0
  32. package/build/utils/index.js +1 -0
  33. package/package.json +2 -1
package/build/global.css CHANGED
@@ -558,6 +558,10 @@ body {
558
558
  font-feature-settings: "rlig" 1, "calt" 1;
559
559
  }
560
560
 
561
+ .visible {
562
+ visibility: visible;
563
+ }
564
+
561
565
  .absolute {
562
566
  position: absolute;
563
567
  }
@@ -636,6 +640,10 @@ body {
636
640
  height: 1rem;
637
641
  }
638
642
 
643
+ .h-5 {
644
+ height: 1.25rem;
645
+ }
646
+
639
647
  .h-9 {
640
648
  height: 2.25rem;
641
649
  }
@@ -668,6 +676,10 @@ body {
668
676
  width: 1rem;
669
677
  }
670
678
 
679
+ .w-5 {
680
+ width: 1.25rem;
681
+ }
682
+
671
683
  .w-auto {
672
684
  width: auto;
673
685
  }
@@ -676,6 +688,10 @@ body {
676
688
  width: 100%;
677
689
  }
678
690
 
691
+ .min-w-0 {
692
+ min-width: 0px;
693
+ }
694
+
679
695
  .min-w-\[8rem\] {
680
696
  min-width: 8rem;
681
697
  }
@@ -684,6 +700,10 @@ body {
684
700
  min-width: var(--radix-select-trigger-width);
685
701
  }
686
702
 
703
+ .flex-1 {
704
+ flex: 1 1 0%;
705
+ }
706
+
687
707
  .shrink-0 {
688
708
  flex-shrink: 0;
689
709
  }
@@ -697,6 +717,16 @@ body {
697
717
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
698
718
  }
699
719
 
720
+ @keyframes pulse {
721
+ 50% {
722
+ opacity: .5;
723
+ }
724
+ }
725
+
726
+ .animate-pulse {
727
+ animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
728
+ }
729
+
700
730
  @keyframes spin {
701
731
  to {
702
732
  transform: rotate(360deg);
@@ -711,6 +741,10 @@ body {
711
741
  cursor: default;
712
742
  }
713
743
 
744
+ .cursor-pointer {
745
+ cursor: pointer;
746
+ }
747
+
714
748
  .select-none {
715
749
  -webkit-user-select: none;
716
750
  -moz-user-select: none;
@@ -761,10 +795,18 @@ body {
761
795
  justify-content: space-between;
762
796
  }
763
797
 
798
+ .gap-1 {
799
+ gap: 0.25rem;
800
+ }
801
+
764
802
  .gap-2 {
765
803
  gap: 0.5rem;
766
804
  }
767
805
 
806
+ .gap-3 {
807
+ gap: 0.75rem;
808
+ }
809
+
768
810
  .gap-4 {
769
811
  gap: 1rem;
770
812
  }
@@ -773,14 +815,28 @@ body {
773
815
  overflow: hidden;
774
816
  }
775
817
 
818
+ .truncate {
819
+ overflow: hidden;
820
+ text-overflow: ellipsis;
821
+ white-space: nowrap;
822
+ }
823
+
776
824
  .whitespace-nowrap {
777
825
  white-space: nowrap;
778
826
  }
779
827
 
828
+ .rounded {
829
+ border-radius: 0.25rem;
830
+ }
831
+
780
832
  .rounded-full {
781
833
  border-radius: 9999px;
782
834
  }
783
835
 
836
+ .rounded-lg {
837
+ border-radius: 0.5rem;
838
+ }
839
+
784
840
  .rounded-md {
785
841
  border-radius: 0.375rem;
786
842
  }
@@ -806,6 +862,16 @@ body {
806
862
  border-color: rgb(255 255 255 / var(--tw-border-opacity, 1));
807
863
  }
808
864
 
865
+ .bg-black {
866
+ --tw-bg-opacity: 1;
867
+ background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
868
+ }
869
+
870
+ .bg-gray-900 {
871
+ --tw-bg-opacity: 1;
872
+ background-color: rgb(17 24 39 / var(--tw-bg-opacity, 1));
873
+ }
874
+
809
875
  .bg-transparent {
810
876
  background-color: transparent;
811
877
  }
@@ -823,6 +889,10 @@ body {
823
889
  padding: 0.25rem;
824
890
  }
825
891
 
892
+ .p-2 {
893
+ padding: 0.5rem;
894
+ }
895
+
826
896
  .p-4 {
827
897
  padding: 1rem;
828
898
  }
@@ -909,10 +979,44 @@ body {
909
979
  color: rgb(0 0 0 / var(--tw-text-opacity, 1));
910
980
  }
911
981
 
982
+ .text-gray-300 {
983
+ --tw-text-opacity: 1;
984
+ color: rgb(209 213 219 / var(--tw-text-opacity, 1));
985
+ }
986
+
987
+ .text-gray-400 {
988
+ --tw-text-opacity: 1;
989
+ color: rgb(156 163 175 / var(--tw-text-opacity, 1));
990
+ }
991
+
992
+ .text-gray-500 {
993
+ --tw-text-opacity: 1;
994
+ color: rgb(107 114 128 / var(--tw-text-opacity, 1));
995
+ }
996
+
997
+ .text-green-500 {
998
+ --tw-text-opacity: 1;
999
+ color: rgb(34 197 94 / var(--tw-text-opacity, 1));
1000
+ }
1001
+
1002
+ .text-red-500 {
1003
+ --tw-text-opacity: 1;
1004
+ color: rgb(239 68 68 / var(--tw-text-opacity, 1));
1005
+ }
1006
+
1007
+ .text-white {
1008
+ --tw-text-opacity: 1;
1009
+ color: rgb(255 255 255 / var(--tw-text-opacity, 1));
1010
+ }
1011
+
912
1012
  .underline {
913
1013
  text-decoration-line: underline;
914
1014
  }
915
1015
 
1016
+ .opacity-25 {
1017
+ opacity: 0.25;
1018
+ }
1019
+
916
1020
  .opacity-50 {
917
1021
  opacity: 0.5;
918
1022
  }
@@ -921,6 +1025,10 @@ body {
921
1025
  opacity: 0.6;
922
1026
  }
923
1027
 
1028
+ .opacity-75 {
1029
+ opacity: 0.75;
1030
+ }
1031
+
924
1032
  .shadow-lg {
925
1033
  --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
926
1034
  --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);
@@ -1012,6 +1120,16 @@ body {
1012
1120
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
1013
1121
  }
1014
1122
 
1123
+ .hover\:bg-gray-700:hover {
1124
+ --tw-bg-opacity: 1;
1125
+ background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1));
1126
+ }
1127
+
1128
+ .hover\:bg-gray-800:hover {
1129
+ --tw-bg-opacity: 1;
1130
+ background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1));
1131
+ }
1132
+
1015
1133
  .focus\:border-0:focus {
1016
1134
  border-width: 0px;
1017
1135
  }
@@ -1,24 +1,49 @@
1
- import type { Link, LinkSession, ProtonWebLink } from "@proton/web-sdk";
1
+ import type { Link, LinkSession } from "@proton/link";
2
+ import { ProtonWebLink } from "@proton/web-sdk";
2
3
  import React from "react";
3
4
  import { JsonRpc } from "@proton/js";
5
+ import { type StoredSessionRef } from "../utils";
4
6
  import { type IdentityProofStatus } from "../services/identity-proof";
5
- export type XPRNAuthentication = {
7
+ /**
8
+ * Identity proof data returned from authentication
9
+ */
10
+ export type XPRNIdentityProof = {
6
11
  actor: string;
7
12
  publicKey: string;
13
+ /** JWT token from the identity proof verification */
14
+ token?: string;
15
+ /** Additional data from the verification response */
8
16
  data?: any;
9
17
  };
18
+ /**
19
+ * @deprecated Use XPRNIdentityProof instead
20
+ */
21
+ export type XPRNAuthentication = XPRNIdentityProof;
10
22
  export type XPRNProfile = {
11
23
  displayName: string;
12
24
  avatar?: string;
13
- authentication?: XPRNAuthentication;
14
25
  isKyc: boolean;
15
26
  };
16
- export type XPRNSession = {
17
- actor: string;
18
- session: LinkSession;
19
- link: ProtonWebLink | Link;
20
- profile: XPRNProfile | null;
21
- authentication: XPRNAuthentication | null;
27
+ /**
28
+ * Identity proof configuration (optional feature)
29
+ */
30
+ export type XPRNIdentityProofConfig = {
31
+ /** URL for creating identity proof (sign + verify) */
32
+ createUrl: string;
33
+ /** URL for validating existing tokens (optional) */
34
+ validationUrl?: string;
35
+ /** Time in seconds before expiration to trigger validation (default: 300) */
36
+ validationBuffer?: number;
37
+ /** Automatically authenticate on connect (default: false) */
38
+ enforceOnConnect?: boolean;
39
+ /** Automatically re-authenticate when token expires (default: false) */
40
+ autoReauthenticate?: boolean;
41
+ /** Require identity proof for the app (default: false) */
42
+ required?: boolean;
43
+ /** Additional headers for identity proof requests */
44
+ headers?: Record<string, string>;
45
+ /** Request timeout in milliseconds */
46
+ timeout?: number;
22
47
  };
23
48
  export type XPRProviderConfig = {
24
49
  chainId: string;
@@ -26,36 +51,45 @@ export type XPRProviderConfig = {
26
51
  dAppName: string;
27
52
  requesterAccount: string;
28
53
  requesterLogo?: string;
29
- authenticationUrl?: string;
30
- enforceAuthentication?: boolean;
31
54
  apiMode: "testnet" | "mainnet";
32
55
  restoreSession?: boolean;
56
+ /** Identity proof configuration (optional - if not provided, identity proof is disabled) */
57
+ identityProof?: XPRNIdentityProofConfig;
58
+ /** @deprecated Use identityProof.createUrl instead */
59
+ authenticationUrl?: string;
60
+ /** @deprecated Use identityProof.enforceOnConnect instead */
61
+ enforceAuthentication?: boolean;
33
62
  };
34
63
  type XPRNProviderProps = {
35
64
  children: React.ReactNode | React.ReactNode[];
36
65
  config: XPRProviderConfig;
37
66
  };
38
67
  type XPRNProviderContext = {
68
+ config: XPRProviderConfig | null;
39
69
  session: LinkSession | null;
40
- link: ProtonWebLink | null;
70
+ link: ProtonWebLink | Link | null;
41
71
  profile: XPRNProfile | null;
42
72
  rpc: JsonRpc | null;
43
- txErrorsStack: null;
44
- authentication: XPRNAuthentication | null;
45
- authenticate: (success: (res: any) => void, fail: (e: any) => void, actor?: string) => void;
73
+ identityProof: XPRNIdentityProof | null;
74
+ identityProofStatus: IdentityProofStatus;
75
+ /** True if identity proof is configured but not yet obtained for current session */
76
+ needsIdentityProof: boolean;
77
+ /** True if identity proof is configured with required=true */
78
+ isIdentityProofRequired: boolean;
79
+ /** True if identity proof is enabled (config.identityProof is defined) */
80
+ isIdentityProofEnabled: boolean;
81
+ connect: (restore?: boolean, onSession?: (session: LinkSession, link: ProtonWebLink | Link) => void, onProfile?: (profile: XPRNProfile) => void) => void;
82
+ disconnect: () => Promise<void>;
83
+ requestIdentityProof: (success: (res: XPRNIdentityProof) => void, fail: (e: any) => void) => void;
84
+ listStoredSessions: () => StoredSessionRef[];
85
+ switchToSession: (auth: string, chainId: string) => Promise<void>;
46
86
  addTransactionError: (rawMessage: string) => void;
47
- connect: (restore?: boolean, onSession?: (session: LinkSession) => void, onProfile?: (profile: XPRNProfile) => void) => void;
48
- disconnect: (actor?: string) => void;
49
- getActiveSession: () => XPRNSession | null;
50
- listSessions: () => XPRNSession[];
51
- setActiveSession: (actor: string) => void;
52
- removeSession: (actor: string) => Promise<void>;
53
- getAllProfiles: () => XPRNProfile[];
54
- switchSession: (actor: string) => void;
55
- getSessionById: (actor: string) => XPRNSession | null;
56
- getSessionByActor: (actor: string) => XPRNSession | null;
87
+ /** @deprecated Use identityProof instead */
88
+ authentication: XPRNIdentityProof | null;
89
+ /** @deprecated Use identityProofStatus instead */
57
90
  authStatus: IdentityProofStatus;
58
- getAuthStatus: (actor?: string) => IdentityProofStatus;
91
+ /** @deprecated Use requestIdentityProof instead */
92
+ authenticate: (success: (res: any) => void, fail: (e: any) => void) => void;
59
93
  };
60
94
  export declare const XPRNProvider: React.FunctionComponent<XPRNProviderProps>;
61
95
  export declare function useXPRN(): XPRNProviderContext;