Actually fix standalone mode
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
3ecffaef08
commit
614168d079
8 changed files with 14 additions and 14 deletions
|
@ -133,7 +133,7 @@
|
||||||
"multiselect-react-dropdown": "^2.0.25",
|
"multiselect-react-dropdown": "^2.0.25",
|
||||||
"object-to-formdata": "^4.5.1",
|
"object-to-formdata": "^4.5.1",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"pl-api": "^0.0.8",
|
"pl-api": "^0.0.9",
|
||||||
"postcss": "^8.4.29",
|
"postcss": "^8.4.29",
|
||||||
"process": "^0.11.10",
|
"process": "^0.11.10",
|
||||||
"punycode": "^2.1.1",
|
"punycode": "^2.1.1",
|
||||||
|
|
|
@ -20,7 +20,7 @@ const createApp = (params: CreateApplicationParams, baseURL?: string) =>
|
||||||
(dispatch: React.Dispatch<AnyAction>) => {
|
(dispatch: React.Dispatch<AnyAction>) => {
|
||||||
dispatch({ type: APP_CREATE_REQUEST, params });
|
dispatch({ type: APP_CREATE_REQUEST, params });
|
||||||
|
|
||||||
const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || '', undefined, { fetchInstance: false });
|
const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || '');
|
||||||
return client.apps.createApplication(params).then((app) => {
|
return client.apps.createApplication(params).then((app) => {
|
||||||
dispatch({ type: APP_CREATE_SUCCESS, params, app });
|
dispatch({ type: APP_CREATE_SUCCESS, params, app });
|
||||||
return app as Record<string, string>;
|
return app as Record<string, string>;
|
||||||
|
|
|
@ -128,7 +128,7 @@ const otpVerify = (code: string, mfa_token: string) =>
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const app = state.auth.app;
|
const app = state.auth.app;
|
||||||
const baseUrl = parseBaseURL(state.me) || BuildConfig.BACKEND_URL;
|
const baseUrl = parseBaseURL(state.me) || BuildConfig.BACKEND_URL;
|
||||||
const client = new PlApiClient(baseUrl, undefined, { fetchInstance: false });
|
const client = new PlApiClient(baseUrl);
|
||||||
return client.oauth.mfaChallenge({
|
return client.oauth.mfaChallenge({
|
||||||
client_id: app?.client_id!,
|
client_id: app?.client_id!,
|
||||||
client_secret: app?.client_secret!,
|
client_secret: app?.client_secret!,
|
||||||
|
@ -146,7 +146,7 @@ const verifyCredentials = (token: string, accountUrl?: string) =>
|
||||||
|
|
||||||
dispatch({ type: VERIFY_CREDENTIALS_REQUEST, token });
|
dispatch({ type: VERIFY_CREDENTIALS_REQUEST, token });
|
||||||
|
|
||||||
const client = new PlApiClient(baseURL, token, { fetchInstance: false });
|
const client = new PlApiClient(baseURL, token);
|
||||||
|
|
||||||
return client.settings.verifyCredentials().then((account) => {
|
return client.settings.verifyCredentials().then((account) => {
|
||||||
dispatch(importFetchedAccount(account));
|
dispatch(importFetchedAccount(account));
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { getInstanceScopes } from 'soapbox/utils/scopes';
|
||||||
import type { AppDispatch } from 'soapbox/store';
|
import type { AppDispatch } from 'soapbox/store';
|
||||||
|
|
||||||
const fetchExternalInstance = (baseURL: string) =>
|
const fetchExternalInstance = (baseURL: string) =>
|
||||||
(new PlApiClient(baseURL, undefined, { fetchInstance: false })).instance.getInstance()
|
(new PlApiClient(baseURL)).instance.getInstance()
|
||||||
.then(instance => instance)
|
.then(instance => instance)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.response?.status === 401) {
|
if (error.response?.status === 401) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ const OAUTH_TOKEN_REVOKE_FAIL = 'OAUTH_TOKEN_REVOKE_FAIL' as const;
|
||||||
const obtainOAuthToken = (params: GetTokenParams, baseURL?: string) =>
|
const obtainOAuthToken = (params: GetTokenParams, baseURL?: string) =>
|
||||||
(dispatch: AppDispatch) => {
|
(dispatch: AppDispatch) => {
|
||||||
dispatch({ type: OAUTH_TOKEN_CREATE_REQUEST, params });
|
dispatch({ type: OAUTH_TOKEN_CREATE_REQUEST, params });
|
||||||
const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || '', undefined, { fetchInstance: false });
|
const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || '');
|
||||||
|
|
||||||
return client.oauth.getToken(params).then((token) => {
|
return client.oauth.getToken(params).then((token) => {
|
||||||
dispatch({ type: OAUTH_TOKEN_CREATE_SUCCESS, params, token });
|
dispatch({ type: OAUTH_TOKEN_CREATE_SUCCESS, params, token });
|
||||||
|
@ -39,7 +39,7 @@ const revokeOAuthToken = (params: RevokeTokenParams) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
dispatch({ type: OAUTH_TOKEN_REVOKE_REQUEST, params });
|
dispatch({ type: OAUTH_TOKEN_REVOKE_REQUEST, params });
|
||||||
const baseURL = getBaseURL(getState());
|
const baseURL = getBaseURL(getState());
|
||||||
const client = new PlApiClient(baseURL || '', undefined, { fetchInstance: false });
|
const client = new PlApiClient(baseURL || '');
|
||||||
return client.oauth.revokeToken(params).then((data) => {
|
return client.oauth.revokeToken(params).then((data) => {
|
||||||
dispatch({ type: OAUTH_TOKEN_REVOKE_SUCCESS, params, data });
|
dispatch({ type: OAUTH_TOKEN_REVOKE_SUCCESS, params, data });
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -35,7 +35,7 @@ const ReducerRecord = ImmutableRecord({
|
||||||
tokens: ImmutableMap<string, Token>(),
|
tokens: ImmutableMap<string, Token>(),
|
||||||
users: ImmutableMap<string, AuthUser>(),
|
users: ImmutableMap<string, AuthUser>(),
|
||||||
me: null as string | null,
|
me: null as string | null,
|
||||||
client: new PlApiClient(backendUrl) as any as PlApiClient,
|
client: new PlApiClient(backendUrl),
|
||||||
});
|
});
|
||||||
|
|
||||||
type AuthUser = ReturnType<typeof AuthUserRecord>;
|
type AuthUser = ReturnType<typeof AuthUserRecord>;
|
||||||
|
@ -60,7 +60,7 @@ const getLocalState = () => {
|
||||||
if (!state) return undefined;
|
if (!state) return undefined;
|
||||||
|
|
||||||
return ReducerRecord({
|
return ReducerRecord({
|
||||||
app: applicationSchema.parse(state.app),
|
app: state.app && applicationSchema.parse(state.app),
|
||||||
tokens: ImmutableMap(Object.entries(state.tokens).map(([key, value]) => [key, tokenSchema.parse(value)])),
|
tokens: ImmutableMap(Object.entries(state.tokens).map(([key, value]) => [key, tokenSchema.parse(value)])),
|
||||||
users: ImmutableMap(Object.entries(state.users).map(([key, value]) => [key, AuthUserRecord(value as any)])),
|
users: ImmutableMap(Object.entries(state.users).map(([key, value]) => [key, AuthUserRecord(value as any)])),
|
||||||
me: state.me,
|
me: state.me,
|
||||||
|
|
|
@ -13,7 +13,7 @@ const ReducerRecord = ImmutableRecord({
|
||||||
const meta = (state = ReducerRecord(), action: InstanceAction | SwAction) => {
|
const meta = (state = ReducerRecord(), action: InstanceAction | SwAction) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INSTANCE_FETCH_FAIL:
|
case INSTANCE_FETCH_FAIL:
|
||||||
if (action.error?.status === 404) {
|
if (action.error?.response?.status === 404) {
|
||||||
return state.set('instance_fetch_failed', true);
|
return state.set('instance_fetch_failed', true);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
|
|
@ -8390,10 +8390,10 @@ pkg-types@^1.0.3:
|
||||||
mlly "^1.2.0"
|
mlly "^1.2.0"
|
||||||
pathe "^1.1.0"
|
pathe "^1.1.0"
|
||||||
|
|
||||||
pl-api@^0.0.8:
|
pl-api@^0.0.9:
|
||||||
version "0.0.8"
|
version "0.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.8.tgz#8ccf422da7116fdf93e6d642b59e44e8ee7b978b"
|
resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.9.tgz#8e5c1d205e44f6e7fa332b14cafe49c67c00175e"
|
||||||
integrity sha512-OJs0S4Z8bIgXJj/2U+BKX0hCyBnOcTn2I2IwRMfVXe7a+KetiF/loO4CslXh30d+0qN/vyYKg4X2/9jzJ56sgQ==
|
integrity sha512-oJwYdkdpvuXwVPWYBWcbWbwIg2zm+vNBxeni5usfH2RI4Co+WiCkuCnhM7pxyB0YnqvgCtAnFJY4O9YUT47xRg==
|
||||||
dependencies:
|
dependencies:
|
||||||
blurhash "^2.0.5"
|
blurhash "^2.0.5"
|
||||||
http-link-header "^1.1.3"
|
http-link-header "^1.1.3"
|
||||||
|
|
Loading…
Reference in a new issue