add challenges.cloudflare.com to content security policy
This commit is contained in:
parent
ecb0f0e78a
commit
f33961232b
@ -1,2 +1,2 @@
|
|||||||
/*
|
/*
|
||||||
Content-Security-Policy: default-src 'self'; manifest-src *; child-src 'none'; worker-src 'self'; frame-src youtube.com www.youtube.com https://platform.twitter.com https://embed.tidal.com https://w.soundcloud.com https://www.mixcloud.com https://open.spotify.com https://player.twitch.tv https://embed.music.apple.com https://nostrnests.com https://embed.wavlake.com; style-src 'self' 'unsafe-inline'; connect-src *; img-src * data: blob:; font-src 'self'; media-src * blob:; script-src 'self' 'wasm-unsafe-eval' https://analytics.v0l.io https://platform.twitter.com https://embed.tidal.com;
|
Content-Security-Policy: default-src 'self'; manifest-src *; child-src 'none'; worker-src 'self'; frame-src youtube.com www.youtube.com https://platform.twitter.com https://embed.tidal.com https://w.soundcloud.com https://www.mixcloud.com https://open.spotify.com https://player.twitch.tv https://embed.music.apple.com https://nostrnests.com https://embed.wavlake.com https://challenges.cloudflare.com; style-src 'self' 'unsafe-inline'; connect-src *; img-src * data: blob:; font-src 'self'; media-src * blob:; script-src 'self' 'wasm-unsafe-eval' https://analytics.v0l.io https://platform.twitter.com https://embed.tidal.com https://challenges.cloudflare.com;
|
@ -1,6 +1,6 @@
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
export default function AccountName({ name = '', link = true }) {
|
export default function AccountName({ name = "", link = true }) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -8,15 +8,14 @@ export default function AccountName({ name = '', link = true }) {
|
|||||||
Username: <b>{name}</b>
|
Username: <b>{name}</b>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Short link:{' '}
|
Short link:{" "}
|
||||||
{link ? (
|
{link ? (
|
||||||
<a
|
<a
|
||||||
href={`https://iris.to/${name}`}
|
href={`https://iris.to/${name}`}
|
||||||
onClick={(e) => {
|
onClick={e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
navigate(`/${name}`);
|
navigate(`/${name}`);
|
||||||
}}
|
}}>
|
||||||
>
|
|
||||||
iris.to/{name}
|
iris.to/{name}
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import AccountName from './AccountName';
|
import AccountName from "./AccountName";
|
||||||
import useLogin from "../../Hooks/useLogin";
|
import useLogin from "../../Hooks/useLogin";
|
||||||
import { useUserProfile } from "@snort/system-react";
|
import { useUserProfile } from "@snort/system-react";
|
||||||
import { System } from "../../index";
|
import { System } from "../../index";
|
||||||
@ -6,7 +6,7 @@ import {UserCache} from "../../Cache";
|
|||||||
import useEventPublisher from "../../Hooks/useEventPublisher";
|
import useEventPublisher from "../../Hooks/useEventPublisher";
|
||||||
import { mapEventToProfile } from "@snort/system";
|
import { mapEventToProfile } from "@snort/system";
|
||||||
|
|
||||||
export default function ActiveAccount({ name = '', setAsPrimary = () => {} }) {
|
export default function ActiveAccount({ name = "", setAsPrimary = () => {} }) {
|
||||||
const { publicKey, readonly } = useLogin(s => ({
|
const { publicKey, readonly } = useLogin(s => ({
|
||||||
publicKey: s.publicKey,
|
publicKey: s.publicKey,
|
||||||
readonly: s.readonly,
|
readonly: s.readonly,
|
||||||
@ -20,7 +20,7 @@ export default function ActiveAccount({ name = '', setAsPrimary = () => {} }) {
|
|||||||
}
|
}
|
||||||
// copy user object and delete internal fields
|
// copy user object and delete internal fields
|
||||||
const userCopy = {
|
const userCopy = {
|
||||||
...profile,
|
...(profile || {}),
|
||||||
nip05,
|
nip05,
|
||||||
} as Record<string, string | number | undefined | boolean>;
|
} as Record<string, string | number | undefined | boolean>;
|
||||||
delete userCopy["loaded"];
|
delete userCopy["loaded"];
|
||||||
@ -44,7 +44,7 @@ export default function ActiveAccount({ name = '', setAsPrimary = () => {} }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
const newNip = name + '@iris.to';
|
const newNip = name + "@iris.to";
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
saveProfile(newNip);
|
saveProfile(newNip);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
@ -64,7 +64,7 @@ export default function ActiveAccount({ name = '', setAsPrimary = () => {} }) {
|
|||||||
<AccountName name={name} />
|
<AccountName name={name} />
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<button className="btn btn-sm btn-primary" onClick={onClick}>
|
<button type="button" onClick={onClick}>
|
||||||
Set as primary Nostr address (nip05)
|
Set as primary Nostr address (nip05)
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { Component, FormEvent} from 'react';
|
import { Component, FormEvent } from "react";
|
||||||
import { LoginStore } from "Login";
|
import { LoginStore } from "Login";
|
||||||
|
|
||||||
import AccountName from './AccountName';
|
import AccountName from "./AccountName";
|
||||||
import ActiveAccount from './ActiveAccount';
|
import ActiveAccount from "./ActiveAccount";
|
||||||
import ReservedAccount from './ReservedAccount';
|
import ReservedAccount from "./ReservedAccount";
|
||||||
|
import { ProfileLoader } from "../../index";
|
||||||
//import {ProfileLoader} from "../../index";
|
//import {ProfileLoader} from "../../index";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@ -19,7 +20,7 @@ export default class IrisAccount extends Component {
|
|||||||
irisToActive: false,
|
irisToActive: false,
|
||||||
existing: null as any,
|
existing: null as any,
|
||||||
profile: null as any,
|
profile: null as any,
|
||||||
newUserName: '',
|
newUserName: "",
|
||||||
newUserNameValid: false,
|
newUserNameValid: false,
|
||||||
error: null as any,
|
error: null as any,
|
||||||
showChallenge: false,
|
showChallenge: false,
|
||||||
@ -30,14 +31,11 @@ export default class IrisAccount extends Component {
|
|||||||
let view: any;
|
let view: any;
|
||||||
|
|
||||||
if (this.state.irisToActive) {
|
if (this.state.irisToActive) {
|
||||||
const username = this.state.profile.nip05.split('@')[0];
|
const username = this.state.profile?.nip05.split("@")[0];
|
||||||
view = <AccountName name={username} />;
|
view = <AccountName name={username} />;
|
||||||
} else if (this.state.existing && this.state.existing.confirmed) {
|
} else if (this.state.existing && this.state.existing.confirmed) {
|
||||||
view = (
|
view = (
|
||||||
<ActiveAccount
|
<ActiveAccount name={this.state.existing.name} setAsPrimary={() => this.setState({ irisToActive: true })} />
|
||||||
name={this.state.existing.name}
|
|
||||||
setAsPrimary={() => this.setState({irisToActive: true})}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
} else if (this.state.existing) {
|
} else if (this.state.existing) {
|
||||||
view = (
|
view = (
|
||||||
@ -56,30 +54,27 @@ export default class IrisAccount extends Component {
|
|||||||
<div
|
<div
|
||||||
className="cf-turnstile"
|
className="cf-turnstile"
|
||||||
data-sitekey={
|
data-sitekey={
|
||||||
['iris.to', 'beta.iris.to', 'snort.social'].includes(window.location.hostname)
|
["iris.to", "beta.iris.to", "snort.social"].includes(window.location.hostname)
|
||||||
? '0x4AAAAAAACsEd8XuwpPTFwz'
|
? "0x4AAAAAAACsEd8XuwpPTFwz"
|
||||||
: '3x00000000000000000000FF'
|
: "3x00000000000000000000FF"
|
||||||
}
|
}
|
||||||
data-callback="cf_turnstile_callback"
|
data-callback="cf_turnstile_callback"></div>
|
||||||
></div>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
view = (
|
view = (
|
||||||
<div>
|
<div>
|
||||||
<p>Register an Iris username (iris.to/username)</p>
|
<p>Register an Iris username (iris.to/username)</p>
|
||||||
<form onSubmit={(e) => this.showChallenge(e)}>
|
<form onSubmit={e => this.showChallenge(e)}>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<input
|
<input
|
||||||
className="input"
|
className="input"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Username"
|
placeholder="Username"
|
||||||
value={this.state.newUserName}
|
value={this.state.newUserName}
|
||||||
onInput={(e) => this.onNewUserNameChange(e)}
|
onInput={e => this.onNewUserNameChange(e)}
|
||||||
/>
|
/>
|
||||||
<button className="btn btn-primary" type="submit">
|
<button type="submit">Register</button>
|
||||||
Register
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{this.state.newUserNameValid ? (
|
{this.state.newUserNameValid ? (
|
||||||
@ -113,7 +108,7 @@ export default class IrisAccount extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
newUserName,
|
newUserName,
|
||||||
newUserNameValid: false,
|
newUserNameValid: false,
|
||||||
invalidUsernameMessage: '',
|
invalidUsernameMessage: "",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,7 +116,7 @@ export default class IrisAccount extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
newUserName,
|
newUserName,
|
||||||
newUserNameValid: false,
|
newUserNameValid: false,
|
||||||
invalidUsernameMessage: 'Username must be between 8 and 15 characters',
|
invalidUsernameMessage: "Username must be between 8 and 15 characters",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -129,13 +124,13 @@ export default class IrisAccount extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
newUserName,
|
newUserName,
|
||||||
newUserNameValid: false,
|
newUserNameValid: false,
|
||||||
invalidUsernameMessage: 'Username must only contain lowercase letters and numbers',
|
invalidUsernameMessage: "Username must only contain lowercase letters and numbers",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
newUserName,
|
newUserName,
|
||||||
invalidUsernameMessage: '',
|
invalidUsernameMessage: "",
|
||||||
});
|
});
|
||||||
this.checkAvailabilityFromAPI(newUserName);
|
this.checkAvailabilityFromAPI(newUserName);
|
||||||
}
|
}
|
||||||
@ -158,10 +153,10 @@ export default class IrisAccount extends Component {
|
|||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
newUserNameValid: false,
|
newUserNameValid: false,
|
||||||
invalidUsernameMessage: 'Error checking username availability',
|
invalidUsernameMessage: "Error checking username availability",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
showChallenge(e: FormEvent<HTMLFormElement>) {
|
showChallenge(e: FormEvent<HTMLFormElement>) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -181,15 +176,15 @@ export default class IrisAccount extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async register(cfToken: any) {
|
async register(cfToken: any) {
|
||||||
console.log('register', cfToken);
|
console.log("register", cfToken);
|
||||||
const login = LoginStore.snapshot();
|
const login = LoginStore.snapshot();
|
||||||
const publisher = LoginStore.getPublisher(login.id)
|
const publisher = LoginStore.getPublisher(login.id);
|
||||||
const event = await publisher?.note(`iris.to/${this.state.newUserName}`);
|
const event = await publisher?.note(`iris.to/${this.state.newUserName}`);
|
||||||
// post signed event as request body to https://api.iris.to/user/confirm_user
|
// post signed event as request body to https://api.iris.to/user/confirm_user
|
||||||
const res = await fetch('https://api.iris.to/user/signup', {
|
const res = await fetch("https://api.iris.to/user/signup", {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ event, cfToken }),
|
body: JSON.stringify({ event, cfToken }),
|
||||||
});
|
});
|
||||||
@ -205,24 +200,24 @@ export default class IrisAccount extends Component {
|
|||||||
} else {
|
} else {
|
||||||
res
|
res
|
||||||
.json()
|
.json()
|
||||||
.then((json) => {
|
.then(json => {
|
||||||
this.setState({ error: json.message || 'error' });
|
this.setState({ error: json.message || "error" });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.setState({ error: 'error' });
|
this.setState({ error: "error" });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async enableReserved() {
|
async enableReserved() {
|
||||||
const login = LoginStore.snapshot();
|
const login = LoginStore.snapshot();
|
||||||
const publisher = LoginStore.getPublisher(login.id)
|
const publisher = LoginStore.getPublisher(login.id);
|
||||||
const event = await publisher?.note(`iris.to/${this.state.newUserName}`);
|
const event = await publisher?.note(`iris.to/${this.state.newUserName}`);
|
||||||
// post signed event as request body to https://api.iris.to/user/confirm_user
|
// post signed event as request body to https://api.iris.to/user/confirm_user
|
||||||
const res = await fetch('https://api.iris.to/user/confirm_user', {
|
const res = await fetch("https://api.iris.to/user/confirm_user", {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(event),
|
body: JSON.stringify(event),
|
||||||
});
|
});
|
||||||
@ -234,11 +229,11 @@ export default class IrisAccount extends Component {
|
|||||||
} else {
|
} else {
|
||||||
res
|
res
|
||||||
.json()
|
.json()
|
||||||
.then((json) => {
|
.then(json => {
|
||||||
this.setState({ error: json.message || 'error' });
|
this.setState({ error: json.message || "error" });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.setState({ error: 'error' });
|
this.setState({ error: "error" });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,13 +243,13 @@ export default class IrisAccount extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const login = LoginStore.snapshot();
|
const login = LoginStore.snapshot();
|
||||||
const publisher = LoginStore.getPublisher(login.id)
|
const publisher = LoginStore.getPublisher(login.id);
|
||||||
const event = await publisher?.note(`decline iris.to/${this.state.newUserName}`);
|
const event = await publisher?.note(`decline iris.to/${this.state.newUserName}`);
|
||||||
// post signed event as request body to https://api.iris.to/user/confirm_user
|
// post signed event as request body to https://api.iris.to/user/confirm_user
|
||||||
const res = await fetch('https://api.iris.to/user/decline_user', {
|
const res = await fetch("https://api.iris.to/user/decline_user", {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(event),
|
body: JSON.stringify(event),
|
||||||
});
|
});
|
||||||
@ -263,11 +258,11 @@ export default class IrisAccount extends Component {
|
|||||||
} else {
|
} else {
|
||||||
res
|
res
|
||||||
.json()
|
.json()
|
||||||
.then((json) => {
|
.then(json => {
|
||||||
this.setState({ error: json.message || 'error' });
|
this.setState({ error: json.message || "error" });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.setState({ error: 'error' });
|
this.setState({ error: "error" });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,22 +270,14 @@ export default class IrisAccount extends Component {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const session = LoginStore.snapshot();
|
const session = LoginStore.snapshot();
|
||||||
const myPub = session.publicKey;
|
const myPub = session.publicKey;
|
||||||
/*
|
ProfileLoader.Cache.hook(() => {
|
||||||
ProfileLoader.Cache.hook(h, myPub);
|
const profile = ProfileLoader.Cache.getFromCache(myPub);
|
||||||
SocialNetwork.getProfile(
|
const irisToActive = profile && profile.nip05 && profile.nip05.endsWith("@iris.to");
|
||||||
myPub,
|
|
||||||
(profile) => {
|
|
||||||
const irisToActive =
|
|
||||||
profile && profile.nip05 && profile.nip05valid && profile.nip05.endsWith('@iris.to');
|
|
||||||
this.setState({ profile, irisToActive });
|
this.setState({ profile, irisToActive });
|
||||||
if (profile && !irisToActive) {
|
if (profile && !irisToActive) {
|
||||||
this.checkExistingAccount(myPub);
|
this.checkExistingAccount(myPub);
|
||||||
}
|
}
|
||||||
},
|
}, myPub);
|
||||||
true,
|
|
||||||
);
|
|
||||||
|
|
||||||
*/
|
|
||||||
this.checkExistingAccount(myPub);
|
this.checkExistingAccount(myPub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import AccountName from './AccountName';
|
import AccountName from "./AccountName";
|
||||||
|
|
||||||
export default function ReservedAccount({ name = '', enableReserved = () => {}, declineReserved = () => {} }) {
|
export default function ReservedAccount({ name = "", enableReserved = () => {}, declineReserved = () => {} }) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<p className="text-iris-green">
|
<p className="text-iris-green">
|
||||||
|
@ -662,6 +662,9 @@
|
|||||||
"OLEm6z": {
|
"OLEm6z": {
|
||||||
"defaultMessage": "Unknown login error"
|
"defaultMessage": "Unknown login error"
|
||||||
},
|
},
|
||||||
|
"OQSOJF": {
|
||||||
|
"defaultMessage": "Get a free nostr address"
|
||||||
|
},
|
||||||
"OQXnew": {
|
"OQXnew": {
|
||||||
"defaultMessage": "You subscription is still active, you can't renew yet"
|
"defaultMessage": "You subscription is still active, you can't renew yet"
|
||||||
},
|
},
|
||||||
|
@ -217,6 +217,7 @@
|
|||||||
"OEW7yJ": "Zaps",
|
"OEW7yJ": "Zaps",
|
||||||
"OKhRC6": "Share",
|
"OKhRC6": "Share",
|
||||||
"OLEm6z": "Unknown login error",
|
"OLEm6z": "Unknown login error",
|
||||||
|
"OQSOJF": "Get a free nostr address",
|
||||||
"OQXnew": "You subscription is still active, you can't renew yet",
|
"OQXnew": "You subscription is still active, you can't renew yet",
|
||||||
"ORGv1Q": "Created",
|
"ORGv1Q": "Created",
|
||||||
"P61BTu": "Copy Event JSON",
|
"P61BTu": "Copy Event JSON",
|
||||||
|
Loading…
Reference in New Issue
Block a user