@solarpunkltd/swarm-id 0.8.2 → 0.9.0
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 +17 -7
- package/dist/chunks/{chat-binding-DgECjSWW.js → chat-binding-BirKsDU3.js} +9 -9
- package/dist/chunks/{chat-binding-DgECjSWW.js.map → chat-binding-BirKsDU3.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.esm.js +1 -1
- package/dist/internal.esm.js.map +1 -1
- package/dist/swarm-id-button-frame.d.ts +77 -0
- package/dist/swarm-id-client.d.ts +64 -69
- package/dist/swarm-id-proxy.d.ts +18 -49
- package/dist/swarm-id.esm.js +1 -1
- package/dist/swarm-id.esm.js.map +1 -1
- package/dist/types.d.ts +330 -59
- package/dist/utils/button-view.d.ts +16 -0
- package/dist/utils/storage-probe.d.ts +20 -10
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -665,52 +665,357 @@ export declare const AppMetadataSchema: z.ZodObject<{
|
|
|
665
665
|
icon: z.ZodOptional<z.ZodString>;
|
|
666
666
|
}, z.core.$strip>;
|
|
667
667
|
export type AppMetadata = z.infer<typeof AppMetadataSchema>;
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
668
|
+
/**
|
|
669
|
+
* What a mounted Swarm ID button does. Both open the connect window: signed
|
|
670
|
+
* out it signs the person in, signed in it is where they change the stamp the
|
|
671
|
+
* site uses, which the window asks for on every connect.
|
|
672
|
+
*/
|
|
673
|
+
export declare const ButtonActionSchema: z.ZodEnum<{
|
|
674
|
+
"sign-in": "sign-in";
|
|
675
|
+
"change-stamp": "change-stamp";
|
|
676
|
+
}>;
|
|
677
|
+
export type ButtonAction = z.infer<typeof ButtonActionSchema>;
|
|
678
|
+
/**
|
|
679
|
+
* A font file's URL: https, or http on a loopback host for local work, with
|
|
680
|
+
* no user name or password in it. The button frame takes loopback http only
|
|
681
|
+
* in a development build.
|
|
682
|
+
*/
|
|
683
|
+
export declare function isButtonFontUrl(value: string): boolean;
|
|
684
|
+
export declare const ButtonFontFaceSchema: z.ZodObject<{
|
|
685
|
+
family: z.ZodString;
|
|
686
|
+
url: z.ZodString;
|
|
687
|
+
weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
688
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
689
|
+
normal: "normal";
|
|
690
|
+
italic: "italic";
|
|
691
|
+
oblique: "oblique";
|
|
692
|
+
}>>;
|
|
693
|
+
}, z.core.$strip>;
|
|
694
|
+
/**
|
|
695
|
+
* A font file the button frame loads itself, so the label can use a family
|
|
696
|
+
* the site serves. It is fetched cross-origin from Swarm ID's frame, so the
|
|
697
|
+
* site serves it with an `Access-Control-Allow-Origin` that names Swarm ID's
|
|
698
|
+
* origin. Name `family` in `fontFamily` too, ahead of a fallback.
|
|
699
|
+
*/
|
|
700
|
+
export type ButtonFontFace = z.infer<typeof ButtonFontFaceSchema>;
|
|
701
|
+
export declare const ButtonConfigSchema: z.ZodObject<{
|
|
702
|
+
text: z.ZodOptional<z.ZodString>;
|
|
703
|
+
busyText: z.ZodOptional<z.ZodString>;
|
|
704
|
+
ariaLabel: z.ZodOptional<z.ZodString>;
|
|
705
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
706
|
+
busy: z.ZodOptional<z.ZodBoolean>;
|
|
672
707
|
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
673
708
|
color: z.ZodOptional<z.ZodString>;
|
|
674
709
|
borderRadius: z.ZodOptional<z.ZodString>;
|
|
710
|
+
borderColor: z.ZodOptional<z.ZodString>;
|
|
711
|
+
borderWidth: z.ZodOptional<z.ZodString>;
|
|
712
|
+
borderStyle: z.ZodOptional<z.ZodEnum<{
|
|
713
|
+
solid: "solid";
|
|
714
|
+
dashed: "dashed";
|
|
715
|
+
dotted: "dotted";
|
|
716
|
+
double: "double";
|
|
717
|
+
}>>;
|
|
675
718
|
fontFamily: z.ZodOptional<z.ZodString>;
|
|
676
719
|
fontSize: z.ZodOptional<z.ZodString>;
|
|
677
720
|
fontWeight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
678
|
-
|
|
721
|
+
fontFaces: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
722
|
+
family: z.ZodString;
|
|
723
|
+
url: z.ZodString;
|
|
724
|
+
weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
725
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
726
|
+
normal: "normal";
|
|
727
|
+
italic: "italic";
|
|
728
|
+
oblique: "oblique";
|
|
729
|
+
}>>;
|
|
730
|
+
}, z.core.$strip>>>;
|
|
731
|
+
}, z.core.$strip>;
|
|
732
|
+
/**
|
|
733
|
+
* How a mounted Swarm ID button looks and reads. It is painted inside Swarm
|
|
734
|
+
* ID's own frame, where the site's CSS cannot reach, so everything the site
|
|
735
|
+
* wants it to match is said here. The button fills the frame, which fills the
|
|
736
|
+
* site's container, and text that does not fit ends in an ellipsis.
|
|
737
|
+
*/
|
|
679
738
|
export interface ButtonConfig {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
739
|
+
/** The label. Default: "Sign in with Swarm ID", or "Change stamp in Swarm ID" */
|
|
740
|
+
text?: string;
|
|
741
|
+
/** The label while the connect window is open or `busy` is set. Default: "Waiting for Swarm ID" */
|
|
742
|
+
busyText?: string;
|
|
743
|
+
/** The accessible name, where the label alone does not say what the button does. Default: the label */
|
|
744
|
+
ariaLabel?: string;
|
|
745
|
+
/** Shown but not clickable */
|
|
746
|
+
disabled?: boolean;
|
|
747
|
+
/** Shown as working and not clickable, for a step of the site's own, such as signing out */
|
|
748
|
+
busy?: boolean;
|
|
749
|
+
/** CSS colour. Default: "#dd7200" */
|
|
683
750
|
backgroundColor?: string;
|
|
751
|
+
/** CSS colour of the label. Default: "white" */
|
|
684
752
|
color?: string;
|
|
753
|
+
/** CSS border-radius of the button and its frame. Default: "0" */
|
|
685
754
|
borderRadius?: string;
|
|
755
|
+
/**
|
|
756
|
+
* CSS colour of a border, for a secondary style. Naming this or
|
|
757
|
+
* `borderWidth` draws one, kept in the busy and disabled looks. Default: the
|
|
758
|
+
* label's colour
|
|
759
|
+
*/
|
|
760
|
+
borderColor?: string;
|
|
761
|
+
/** CSS width of the border. Default: "1px" once a border is drawn */
|
|
762
|
+
borderWidth?: string;
|
|
763
|
+
/** Default: "solid" */
|
|
764
|
+
borderStyle?: "solid" | "dashed" | "dotted" | "double";
|
|
765
|
+
/** CSS font-family. A stack falls back to the first family the frame has, not the page. Default: the frame's own */
|
|
686
766
|
fontFamily?: string;
|
|
767
|
+
/** CSS font-size. Default: "14px" */
|
|
687
768
|
fontSize?: string;
|
|
769
|
+
/** CSS font-weight, a keyword or a number. Default: "600" */
|
|
688
770
|
fontWeight?: string | number;
|
|
771
|
+
/**
|
|
772
|
+
* Font files the frame loads for the label, at most 8. A file that does not
|
|
773
|
+
* load leaves the label in the next family of `fontFamily`, and the frame
|
|
774
|
+
* says so once in the console
|
|
775
|
+
*/
|
|
776
|
+
fontFaces?: ButtonFontFace[];
|
|
689
777
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
778
|
+
/** Where a mounted button's connect window is. `blocked`: the browser refused to open it */
|
|
779
|
+
export declare const ButtonWindowStateSchema: z.ZodEnum<{
|
|
780
|
+
open: "open";
|
|
781
|
+
closed: "closed";
|
|
782
|
+
blocked: "blocked";
|
|
783
|
+
}>;
|
|
784
|
+
export type ButtonWindowState = z.infer<typeof ButtonWindowStateSchema>;
|
|
785
|
+
/** What `SwarmIdClient.mountButton` takes */
|
|
786
|
+
export interface MountButtonOptions {
|
|
787
|
+
action: ButtonAction;
|
|
788
|
+
config?: ButtonConfig;
|
|
789
|
+
/**
|
|
790
|
+
* Called when the button's connect window opens, closes or is blocked, for
|
|
791
|
+
* example to say that the browser blocked it.
|
|
792
|
+
*/
|
|
793
|
+
onWindowChange?: (state: ButtonWindowState) => void;
|
|
794
|
+
}
|
|
795
|
+
/** A mounted Swarm ID button */
|
|
796
|
+
export interface MountedButton {
|
|
797
|
+
/**
|
|
798
|
+
* Resolves once the button is shown. Rejects with `init-failed` when Swarm
|
|
799
|
+
* ID refuses the site or the frame does not answer in time.
|
|
800
|
+
*/
|
|
801
|
+
ready: Promise<void>;
|
|
802
|
+
/** Change what the button does or how it looks, in place. Does nothing once unmounted */
|
|
803
|
+
update(options: {
|
|
804
|
+
action?: ButtonAction;
|
|
805
|
+
config?: ButtonConfig;
|
|
806
|
+
}): void;
|
|
807
|
+
/** Remove the button. The session stays as it is, and `onWindowChange` is not called again */
|
|
808
|
+
unmount(): void;
|
|
809
|
+
}
|
|
810
|
+
export declare const ButtonIdentifyMessageSchema: z.ZodObject<{
|
|
811
|
+
type: z.ZodLiteral<"buttonIdentify">;
|
|
812
|
+
action: z.ZodEnum<{
|
|
813
|
+
"sign-in": "sign-in";
|
|
814
|
+
"change-stamp": "change-stamp";
|
|
815
|
+
}>;
|
|
816
|
+
config: z.ZodOptional<z.ZodObject<{
|
|
817
|
+
text: z.ZodOptional<z.ZodString>;
|
|
818
|
+
busyText: z.ZodOptional<z.ZodString>;
|
|
819
|
+
ariaLabel: z.ZodOptional<z.ZodString>;
|
|
820
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
821
|
+
busy: z.ZodOptional<z.ZodBoolean>;
|
|
822
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
823
|
+
color: z.ZodOptional<z.ZodString>;
|
|
824
|
+
borderRadius: z.ZodOptional<z.ZodString>;
|
|
825
|
+
borderColor: z.ZodOptional<z.ZodString>;
|
|
826
|
+
borderWidth: z.ZodOptional<z.ZodString>;
|
|
827
|
+
borderStyle: z.ZodOptional<z.ZodEnum<{
|
|
828
|
+
solid: "solid";
|
|
829
|
+
dashed: "dashed";
|
|
830
|
+
dotted: "dotted";
|
|
831
|
+
double: "double";
|
|
832
|
+
}>>;
|
|
833
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
834
|
+
fontSize: z.ZodOptional<z.ZodString>;
|
|
835
|
+
fontWeight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
836
|
+
fontFaces: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
837
|
+
family: z.ZodString;
|
|
838
|
+
url: z.ZodString;
|
|
839
|
+
weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
840
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
841
|
+
normal: "normal";
|
|
842
|
+
italic: "italic";
|
|
843
|
+
oblique: "oblique";
|
|
844
|
+
}>>;
|
|
845
|
+
}, z.core.$strip>>>;
|
|
846
|
+
}, z.core.$strip>>;
|
|
847
|
+
metadata: z.ZodObject<{
|
|
848
|
+
name: z.ZodString;
|
|
849
|
+
description: z.ZodOptional<z.ZodString>;
|
|
850
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
851
|
+
}, z.core.$strip>;
|
|
694
852
|
popupMode: z.ZodOptional<z.ZodEnum<{
|
|
695
853
|
popup: "popup";
|
|
696
854
|
window: "window";
|
|
697
855
|
}>>;
|
|
856
|
+
}, z.core.$strip>;
|
|
857
|
+
export declare const ButtonUpdateMessageSchema: z.ZodObject<{
|
|
858
|
+
type: z.ZodLiteral<"buttonUpdate">;
|
|
859
|
+
action: z.ZodEnum<{
|
|
860
|
+
"sign-in": "sign-in";
|
|
861
|
+
"change-stamp": "change-stamp";
|
|
862
|
+
}>;
|
|
863
|
+
config: z.ZodOptional<z.ZodObject<{
|
|
864
|
+
text: z.ZodOptional<z.ZodString>;
|
|
865
|
+
busyText: z.ZodOptional<z.ZodString>;
|
|
866
|
+
ariaLabel: z.ZodOptional<z.ZodString>;
|
|
867
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
868
|
+
busy: z.ZodOptional<z.ZodBoolean>;
|
|
869
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
870
|
+
color: z.ZodOptional<z.ZodString>;
|
|
871
|
+
borderRadius: z.ZodOptional<z.ZodString>;
|
|
872
|
+
borderColor: z.ZodOptional<z.ZodString>;
|
|
873
|
+
borderWidth: z.ZodOptional<z.ZodString>;
|
|
874
|
+
borderStyle: z.ZodOptional<z.ZodEnum<{
|
|
875
|
+
solid: "solid";
|
|
876
|
+
dashed: "dashed";
|
|
877
|
+
dotted: "dotted";
|
|
878
|
+
double: "double";
|
|
879
|
+
}>>;
|
|
880
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
881
|
+
fontSize: z.ZodOptional<z.ZodString>;
|
|
882
|
+
fontWeight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
883
|
+
fontFaces: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
884
|
+
family: z.ZodString;
|
|
885
|
+
url: z.ZodString;
|
|
886
|
+
weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
887
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
888
|
+
normal: "normal";
|
|
889
|
+
italic: "italic";
|
|
890
|
+
oblique: "oblique";
|
|
891
|
+
}>>;
|
|
892
|
+
}, z.core.$strip>>>;
|
|
893
|
+
}, z.core.$strip>>;
|
|
894
|
+
}, z.core.$strip>;
|
|
895
|
+
export declare const ParentToButtonMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
896
|
+
type: z.ZodLiteral<"buttonIdentify">;
|
|
897
|
+
action: z.ZodEnum<{
|
|
898
|
+
"sign-in": "sign-in";
|
|
899
|
+
"change-stamp": "change-stamp";
|
|
900
|
+
}>;
|
|
901
|
+
config: z.ZodOptional<z.ZodObject<{
|
|
902
|
+
text: z.ZodOptional<z.ZodString>;
|
|
903
|
+
busyText: z.ZodOptional<z.ZodString>;
|
|
904
|
+
ariaLabel: z.ZodOptional<z.ZodString>;
|
|
905
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
906
|
+
busy: z.ZodOptional<z.ZodBoolean>;
|
|
907
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
908
|
+
color: z.ZodOptional<z.ZodString>;
|
|
909
|
+
borderRadius: z.ZodOptional<z.ZodString>;
|
|
910
|
+
borderColor: z.ZodOptional<z.ZodString>;
|
|
911
|
+
borderWidth: z.ZodOptional<z.ZodString>;
|
|
912
|
+
borderStyle: z.ZodOptional<z.ZodEnum<{
|
|
913
|
+
solid: "solid";
|
|
914
|
+
dashed: "dashed";
|
|
915
|
+
dotted: "dotted";
|
|
916
|
+
double: "double";
|
|
917
|
+
}>>;
|
|
918
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
919
|
+
fontSize: z.ZodOptional<z.ZodString>;
|
|
920
|
+
fontWeight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
921
|
+
fontFaces: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
922
|
+
family: z.ZodString;
|
|
923
|
+
url: z.ZodString;
|
|
924
|
+
weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
925
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
926
|
+
normal: "normal";
|
|
927
|
+
italic: "italic";
|
|
928
|
+
oblique: "oblique";
|
|
929
|
+
}>>;
|
|
930
|
+
}, z.core.$strip>>>;
|
|
931
|
+
}, z.core.$strip>>;
|
|
698
932
|
metadata: z.ZodObject<{
|
|
699
933
|
name: z.ZodString;
|
|
700
934
|
description: z.ZodOptional<z.ZodString>;
|
|
701
935
|
icon: z.ZodOptional<z.ZodString>;
|
|
702
936
|
}, z.core.$strip>;
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
937
|
+
popupMode: z.ZodOptional<z.ZodEnum<{
|
|
938
|
+
popup: "popup";
|
|
939
|
+
window: "window";
|
|
940
|
+
}>>;
|
|
941
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
942
|
+
type: z.ZodLiteral<"buttonUpdate">;
|
|
943
|
+
action: z.ZodEnum<{
|
|
944
|
+
"sign-in": "sign-in";
|
|
945
|
+
"change-stamp": "change-stamp";
|
|
946
|
+
}>;
|
|
947
|
+
config: z.ZodOptional<z.ZodObject<{
|
|
948
|
+
text: z.ZodOptional<z.ZodString>;
|
|
949
|
+
busyText: z.ZodOptional<z.ZodString>;
|
|
950
|
+
ariaLabel: z.ZodOptional<z.ZodString>;
|
|
951
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
952
|
+
busy: z.ZodOptional<z.ZodBoolean>;
|
|
707
953
|
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
708
954
|
color: z.ZodOptional<z.ZodString>;
|
|
709
955
|
borderRadius: z.ZodOptional<z.ZodString>;
|
|
956
|
+
borderColor: z.ZodOptional<z.ZodString>;
|
|
957
|
+
borderWidth: z.ZodOptional<z.ZodString>;
|
|
958
|
+
borderStyle: z.ZodOptional<z.ZodEnum<{
|
|
959
|
+
solid: "solid";
|
|
960
|
+
dashed: "dashed";
|
|
961
|
+
dotted: "dotted";
|
|
962
|
+
double: "double";
|
|
963
|
+
}>>;
|
|
710
964
|
fontFamily: z.ZodOptional<z.ZodString>;
|
|
711
965
|
fontSize: z.ZodOptional<z.ZodString>;
|
|
712
966
|
fontWeight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
967
|
+
fontFaces: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
968
|
+
family: z.ZodString;
|
|
969
|
+
url: z.ZodString;
|
|
970
|
+
weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
971
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
972
|
+
normal: "normal";
|
|
973
|
+
italic: "italic";
|
|
974
|
+
oblique: "oblique";
|
|
975
|
+
}>>;
|
|
976
|
+
}, z.core.$strip>>>;
|
|
713
977
|
}, z.core.$strip>>;
|
|
978
|
+
}, z.core.$strip>], "type">;
|
|
979
|
+
export type ParentToButtonMessage = z.infer<typeof ParentToButtonMessageSchema>;
|
|
980
|
+
export declare const ButtonToParentMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
981
|
+
type: z.ZodLiteral<"buttonReady">;
|
|
982
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
983
|
+
type: z.ZodLiteral<"buttonInitError">;
|
|
984
|
+
error: z.ZodString;
|
|
985
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
986
|
+
type: z.ZodLiteral<"buttonWindowChanged">;
|
|
987
|
+
state: z.ZodEnum<{
|
|
988
|
+
open: "open";
|
|
989
|
+
closed: "closed";
|
|
990
|
+
blocked: "blocked";
|
|
991
|
+
}>;
|
|
992
|
+
}, z.core.$strip>], "type">;
|
|
993
|
+
export type ButtonToParentMessage = z.infer<typeof ButtonToParentMessageSchema>;
|
|
994
|
+
/**
|
|
995
|
+
* The button frame telling the session frames beside it that it opened a
|
|
996
|
+
* connect window under this challenge, so the handover that comes back under
|
|
997
|
+
* it is theirs to take.
|
|
998
|
+
*/
|
|
999
|
+
export declare const ConnectWindowOpenedMessageSchema: z.ZodObject<{
|
|
1000
|
+
type: z.ZodLiteral<"connectWindowOpened">;
|
|
1001
|
+
challenge: z.ZodString;
|
|
1002
|
+
}, z.core.$strip>;
|
|
1003
|
+
export type ConnectWindowOpenedMessage = z.infer<typeof ConnectWindowOpenedMessageSchema>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Sent by the button frame on a wildcard origin the moment it loads, before
|
|
1006
|
+
* the parent has identified itself, so outside the unions above, as
|
|
1007
|
+
* `proxyInitialized` is.
|
|
1008
|
+
*/
|
|
1009
|
+
export declare const BUTTON_FRAME_LOADED = "buttonFrameLoaded";
|
|
1010
|
+
export declare const ParentIdentifyMessageSchema: z.ZodObject<{
|
|
1011
|
+
type: z.ZodLiteral<"parentIdentify">;
|
|
1012
|
+
requestId: z.ZodString;
|
|
1013
|
+
beeApiUrl: z.ZodOptional<z.ZodString>;
|
|
1014
|
+
metadata: z.ZodObject<{
|
|
1015
|
+
name: z.ZodString;
|
|
1016
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1017
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
1018
|
+
}, z.core.$strip>;
|
|
714
1019
|
subsidisedGatewayUrl: z.ZodOptional<z.ZodString>;
|
|
715
1020
|
}, z.core.$strip>;
|
|
716
1021
|
export declare const CheckAuthMessageSchema: z.ZodObject<{
|
|
@@ -1295,38 +1600,15 @@ export declare const GetPostageBatchMessageSchema: z.ZodObject<{
|
|
|
1295
1600
|
type: z.ZodLiteral<"getPostageBatch">;
|
|
1296
1601
|
requestId: z.ZodString;
|
|
1297
1602
|
}, z.core.$strip>;
|
|
1298
|
-
export declare const ConnectMessageSchema: z.ZodObject<{
|
|
1299
|
-
type: z.ZodLiteral<"connect">;
|
|
1300
|
-
requestId: z.ZodString;
|
|
1301
|
-
popupMode: z.ZodOptional<z.ZodEnum<{
|
|
1302
|
-
popup: "popup";
|
|
1303
|
-
window: "window";
|
|
1304
|
-
}>>;
|
|
1305
|
-
}, z.core.$strip>;
|
|
1306
1603
|
export declare const ParentToIframeMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1307
1604
|
type: z.ZodLiteral<"parentIdentify">;
|
|
1308
1605
|
requestId: z.ZodString;
|
|
1309
1606
|
beeApiUrl: z.ZodOptional<z.ZodString>;
|
|
1310
|
-
popupMode: z.ZodOptional<z.ZodEnum<{
|
|
1311
|
-
popup: "popup";
|
|
1312
|
-
window: "window";
|
|
1313
|
-
}>>;
|
|
1314
1607
|
metadata: z.ZodObject<{
|
|
1315
1608
|
name: z.ZodString;
|
|
1316
1609
|
description: z.ZodOptional<z.ZodString>;
|
|
1317
1610
|
icon: z.ZodOptional<z.ZodString>;
|
|
1318
1611
|
}, z.core.$strip>;
|
|
1319
|
-
buttonConfig: z.ZodOptional<z.ZodObject<{
|
|
1320
|
-
connectText: z.ZodOptional<z.ZodString>;
|
|
1321
|
-
disconnectText: z.ZodOptional<z.ZodString>;
|
|
1322
|
-
loadingText: z.ZodOptional<z.ZodString>;
|
|
1323
|
-
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
1324
|
-
color: z.ZodOptional<z.ZodString>;
|
|
1325
|
-
borderRadius: z.ZodOptional<z.ZodString>;
|
|
1326
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
1327
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
1328
|
-
fontWeight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
1329
|
-
}, z.core.$strip>>;
|
|
1330
1612
|
subsidisedGatewayUrl: z.ZodOptional<z.ZodString>;
|
|
1331
1613
|
}, z.core.$strip>, z.ZodObject<{
|
|
1332
1614
|
type: z.ZodLiteral<"checkAuth">;
|
|
@@ -1835,13 +2117,6 @@ export declare const ParentToIframeMessageSchema: z.ZodDiscriminatedUnion<[z.Zod
|
|
|
1835
2117
|
}, z.core.$strip>, z.ZodObject<{
|
|
1836
2118
|
type: z.ZodLiteral<"getPostageBatch">;
|
|
1837
2119
|
requestId: z.ZodString;
|
|
1838
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1839
|
-
type: z.ZodLiteral<"connect">;
|
|
1840
|
-
requestId: z.ZodString;
|
|
1841
|
-
popupMode: z.ZodOptional<z.ZodEnum<{
|
|
1842
|
-
popup: "popup";
|
|
1843
|
-
window: "window";
|
|
1844
|
-
}>>;
|
|
1845
2120
|
}, z.core.$strip>], "type">;
|
|
1846
2121
|
export type ParentIdentifyMessage = z.infer<typeof ParentIdentifyMessageSchema>;
|
|
1847
2122
|
export type CheckAuthMessage = z.infer<typeof CheckAuthMessageSchema>;
|
|
@@ -1886,7 +2161,6 @@ export type ActAddGranteesMessage = z.infer<typeof ActAddGranteesMessageSchema>;
|
|
|
1886
2161
|
export type ActRevokeGranteesMessage = z.infer<typeof ActRevokeGranteesMessageSchema>;
|
|
1887
2162
|
export type ActGetGranteesMessage = z.infer<typeof ActGetGranteesMessageSchema>;
|
|
1888
2163
|
export type GetPostageBatchMessage = z.infer<typeof GetPostageBatchMessageSchema>;
|
|
1889
|
-
export type ConnectMessage = z.infer<typeof ConnectMessageSchema>;
|
|
1890
2164
|
export type ParentToIframeMessage = z.infer<typeof ParentToIframeMessageSchema>;
|
|
1891
2165
|
export declare const ProxyReadyMessageSchema: z.ZodObject<{
|
|
1892
2166
|
type: z.ZodLiteral<"proxyReady">;
|
|
@@ -2030,6 +2304,7 @@ export declare const SwarmIdErrorCodeSchema: z.ZodEnum<{
|
|
|
2030
2304
|
"invalid-state": "invalid-state";
|
|
2031
2305
|
"init-failed": "init-failed";
|
|
2032
2306
|
"popup-blocked": "popup-blocked";
|
|
2307
|
+
"button-required": "button-required";
|
|
2033
2308
|
internal: "internal";
|
|
2034
2309
|
}>;
|
|
2035
2310
|
export type SwarmIdErrorCode = z.infer<typeof SwarmIdErrorCodeSchema>;
|
|
@@ -2048,6 +2323,7 @@ export declare const WireErrorSchema: z.ZodObject<{
|
|
|
2048
2323
|
"invalid-state": "invalid-state";
|
|
2049
2324
|
"init-failed": "init-failed";
|
|
2050
2325
|
"popup-blocked": "popup-blocked";
|
|
2326
|
+
"button-required": "button-required";
|
|
2051
2327
|
internal: "internal";
|
|
2052
2328
|
}>>;
|
|
2053
2329
|
reason: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
|
|
@@ -2081,6 +2357,7 @@ export declare const ErrorMessageSchema: z.ZodObject<{
|
|
|
2081
2357
|
"invalid-state": "invalid-state";
|
|
2082
2358
|
"init-failed": "init-failed";
|
|
2083
2359
|
"popup-blocked": "popup-blocked";
|
|
2360
|
+
"button-required": "button-required";
|
|
2084
2361
|
internal: "internal";
|
|
2085
2362
|
}>>;
|
|
2086
2363
|
reason: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
|
|
@@ -2148,11 +2425,6 @@ export declare const ConnectionInfoChangedMessageSchema: z.ZodObject<{
|
|
|
2148
2425
|
beeApiUrl: z.ZodOptional<z.ZodString>;
|
|
2149
2426
|
postageBatchId: z.ZodOptional<z.ZodString>;
|
|
2150
2427
|
}, z.core.$strip>;
|
|
2151
|
-
export declare const ConnectResponseMessageSchema: z.ZodObject<{
|
|
2152
|
-
type: z.ZodLiteral<"connectResponse">;
|
|
2153
|
-
requestId: z.ZodString;
|
|
2154
|
-
success: z.ZodBoolean;
|
|
2155
|
-
}, z.core.$strip>;
|
|
2156
2428
|
export declare const IsConnectedResponseMessageSchema: z.ZodObject<{
|
|
2157
2429
|
type: z.ZodLiteral<"isConnectedResponse">;
|
|
2158
2430
|
requestId: z.ZodString;
|
|
@@ -2451,6 +2723,7 @@ export declare const IframeToParentMessageSchema: z.ZodDiscriminatedUnion<[z.Zod
|
|
|
2451
2723
|
"invalid-state": "invalid-state";
|
|
2452
2724
|
"init-failed": "init-failed";
|
|
2453
2725
|
"popup-blocked": "popup-blocked";
|
|
2726
|
+
"button-required": "button-required";
|
|
2454
2727
|
internal: "internal";
|
|
2455
2728
|
}>>;
|
|
2456
2729
|
reason: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
|
|
@@ -2516,10 +2789,6 @@ export declare const IframeToParentMessageSchema: z.ZodDiscriminatedUnion<[z.Zod
|
|
|
2516
2789
|
}, z.core.$strip>>;
|
|
2517
2790
|
beeApiUrl: z.ZodOptional<z.ZodString>;
|
|
2518
2791
|
postageBatchId: z.ZodOptional<z.ZodString>;
|
|
2519
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
2520
|
-
type: z.ZodLiteral<"connectResponse">;
|
|
2521
|
-
requestId: z.ZodString;
|
|
2522
|
-
success: z.ZodBoolean;
|
|
2523
2792
|
}, z.core.$strip>, z.ZodObject<{
|
|
2524
2793
|
type: z.ZodLiteral<"isConnectedResponse">;
|
|
2525
2794
|
requestId: z.ZodString;
|
|
@@ -2714,7 +2983,6 @@ export type DownloadChunkResponseMessage = z.infer<typeof DownloadChunkResponseM
|
|
|
2714
2983
|
export type UploadProgressMessage = z.infer<typeof UploadProgressMessageSchema>;
|
|
2715
2984
|
export type ErrorMessage = z.infer<typeof ErrorMessageSchema>;
|
|
2716
2985
|
export type ConnectionInfoChangedMessage = z.infer<typeof ConnectionInfoChangedMessageSchema>;
|
|
2717
|
-
export type ConnectResponseMessage = z.infer<typeof ConnectResponseMessageSchema>;
|
|
2718
2986
|
export type IsConnectedResponseMessage = z.infer<typeof IsConnectedResponseMessageSchema>;
|
|
2719
2987
|
export type GetNodeInfoResponseMessage = z.infer<typeof GetNodeInfoResponseMessageSchema>;
|
|
2720
2988
|
export type GsocMineResponseMessage = z.infer<typeof GsocMineResponseMessageSchema>;
|
|
@@ -2930,6 +3198,11 @@ export declare const SetSecretMessageSchema: z.ZodObject<{
|
|
|
2930
3198
|
stampPending: z.ZodOptional<z.ZodLiteral<true>>;
|
|
2931
3199
|
}, z.core.$strip>;
|
|
2932
3200
|
}, z.core.$strip>;
|
|
3201
|
+
/**
|
|
3202
|
+
* What the connect popup posts to the session frame. The popup was opened by
|
|
3203
|
+
* the button frame, and posts to the Swarm ID frames beside its opener
|
|
3204
|
+
* (`ui/src/lib/handover-targets.ts`).
|
|
3205
|
+
*/
|
|
2933
3206
|
export declare const PopupToIframeMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2934
3207
|
type: z.ZodLiteral<"setSecret">;
|
|
2935
3208
|
appOrigin: z.ZodString;
|
|
@@ -3024,8 +3297,6 @@ export interface ClientOptions {
|
|
|
3024
3297
|
onConnectionChange?: (info: ConnectionInfo) => void;
|
|
3025
3298
|
popupMode?: "popup" | "window";
|
|
3026
3299
|
metadata: AppMetadata;
|
|
3027
|
-
buttonConfig?: ButtonConfig;
|
|
3028
|
-
containerId?: string;
|
|
3029
3300
|
/** URL of a subsidised gateway for users without postage stamps. Gateway handles stamping server-side. */
|
|
3030
3301
|
subsidisedGatewayUrl?: string;
|
|
3031
3302
|
/**
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ButtonAction, ButtonConfig } from "../types";
|
|
2
|
+
/** What the button frame paints, worked out from what the site asked for */
|
|
3
|
+
export interface ButtonView {
|
|
4
|
+
text: string;
|
|
5
|
+
/** Set only when the site gave one, so the label is the name otherwise */
|
|
6
|
+
ariaLabel: string | undefined;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
busy: boolean;
|
|
9
|
+
style: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The button for `action` as `config` asks, busy while its connect window is
|
|
13
|
+
* open or the site says so. A busy button stays focusable and ignores clicks,
|
|
14
|
+
* a disabled one is out of the tab order.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buttonView(action: ButtonAction, config: ButtonConfig, windowOpen: boolean): ButtonView;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Whether
|
|
2
|
+
* Whether a Swarm ID frame can read the trusted domain's first-party store,
|
|
3
3
|
* asked BEFORE authentication, because it decides which transport the auth
|
|
4
|
-
* popup has to take (#613).
|
|
4
|
+
* popup has to take (#613). Both frames a site embeds read it: the session
|
|
5
|
+
* frame, to tell the client whether `connect()` can work, and the button
|
|
6
|
+
* frame, to decide whether to leave the popup's challenge in storage.
|
|
5
7
|
*
|
|
6
8
|
* The mirror image of the probe the connect popup already runs: there, the
|
|
7
|
-
*
|
|
8
|
-
* first-party (`ui/src/lib/stores/connect.svelte.ts`). That answer
|
|
9
|
-
* too late to choose a transport, so the same question is asked
|
|
10
|
-
* round
|
|
9
|
+
* button frame writes a challenge and the popup checks whether it can read it
|
|
10
|
+
* back first-party (`ui/src/lib/stores/connect.svelte.ts`). That answer
|
|
11
|
+
* arrives far too late to choose a transport, so the same question is asked
|
|
12
|
+
* the other way round: the first-party app leaves a marker, and the frames
|
|
13
|
+
* read it back.
|
|
11
14
|
*
|
|
12
15
|
* Deliberately NOT any of these:
|
|
13
16
|
*
|
|
@@ -24,7 +27,14 @@
|
|
|
24
27
|
* The marker only ever answers YES with certainty. Absent means "not proven
|
|
25
28
|
* shared" — a partitioned iframe, or a browser that has never had the SwarmID
|
|
26
29
|
* site open at the top level — and the caller treats that as partitioned,
|
|
27
|
-
* which is the safe direction: the
|
|
30
|
+
* which is the safe direction: the handover through the Swarm ID button works
|
|
31
|
+
* in both modes.
|
|
32
|
+
*
|
|
33
|
+
* The marker is sealed, because the keys in that store are: a frame that sees
|
|
34
|
+
* the store but not the IndexedDB key that opens it sees no session in it.
|
|
35
|
+
* Playwright's WebKit gives a cross-site frame exactly that, one
|
|
36
|
+
* `localStorage` and its own IndexedDB (measured 2026-10-15), and a plain
|
|
37
|
+
* marker had it wait for a storage write it could never read.
|
|
28
38
|
*/
|
|
29
39
|
export declare const STORAGE_SHARED_KEY = "swarm-id-first-party";
|
|
30
40
|
/**
|
|
@@ -35,6 +45,6 @@ export declare const STORAGE_SHARED_KEY = "swarm-id-first-party";
|
|
|
35
45
|
* bucket and make the iframe report itself shared — the one wrong answer this
|
|
36
46
|
* must never give.
|
|
37
47
|
*/
|
|
38
|
-
export declare function markFirstPartyStorage(): void
|
|
39
|
-
/** Whether this context can see the marker a first-party page left. */
|
|
40
|
-
export declare function isStorageShared(): boolean
|
|
48
|
+
export declare function markFirstPartyStorage(): Promise<void>;
|
|
49
|
+
/** Whether this context can see, and open, the marker a first-party page left. */
|
|
50
|
+
export declare function isStorageShared(): Promise<boolean>;
|