chore: rename localclient interceptor to native

This commit is contained in:
Andrew Bastin
2023-10-11 13:41:10 +05:30
parent 4587cee189
commit 20ba4bed5d
7 changed files with 23 additions and 14 deletions

View File

@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>http://localhost:3000/settings</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime/websocket</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime/sse</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime/socketio</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime/mqtt</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/profile</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/join-team</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/import</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/graphql</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/enter</loc><lastmod>2023-10-11T06:31:17.965Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url></urlset> <?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>http://localhost:3000/settings</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime/websocket</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime/sse</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime/socketio</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/realtime/mqtt</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/profile</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/join-team</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/import</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/graphql</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>http://localhost:3000/enter</loc><lastmod>2023-10-11T08:05:53.439Z</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url></urlset>

View File

@@ -34,6 +34,7 @@
"devDependencies": { "devDependencies": {
"@intlify/vite-plugin-vue-i18n": "^6.0.1", "@intlify/vite-plugin-vue-i18n": "^6.0.1",
"@rushstack/eslint-patch": "^1.1.4", "@rushstack/eslint-patch": "^1.1.4",
"@types/lodash-es": "^4.17.9",
"@types/node": "^18.7.10", "@types/node": "^18.7.10",
"@typescript-eslint/eslint-plugin": "^5.19.0", "@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0", "@typescript-eslint/parser": "^5.19.0",

View File

@@ -35,7 +35,7 @@ fn main() {
tauri_plugin_deep_link::register( tauri_plugin_deep_link::register(
"hoppscotch", "hoppscotch",
move |request| { move |request| {
println!("{:?}", request); println!("{:?}", request);
handle.emit_all("scheme-request-received", request).unwrap(); handle.emit_all("scheme-request-received", request).unwrap();
}, },
).unwrap(); ).unwrap();

View File

@@ -5,7 +5,7 @@ import { def as collectionsDef } from "./platform/collections/collections.platfo
import { def as settingsDef } from "./platform/settings/settings.platform" import { def as settingsDef } from "./platform/settings/settings.platform"
import { def as historyDef } from "./platform/history/history.platform" import { def as historyDef } from "./platform/history/history.platform"
import { def as tabStateDef } from "./platform/tabState/tabState.platform" import { def as tabStateDef } from "./platform/tabState/tabState.platform"
import { localclientInterceptor } from "./platform/std/interceptors/localclient" import { nativeInterceptor } from "./platform/interceptors/native"
import { browserInterceptor } from "@hoppscotch/common/platform/std/interceptors/browser" import { browserInterceptor } from "@hoppscotch/common/platform/std/interceptors/browser"
import { proxyInterceptor } from "@hoppscotch/common/platform/std/interceptors/proxy" import { proxyInterceptor } from "@hoppscotch/common/platform/std/interceptors/proxy"
import { ExtensionInspectorService } from "@hoppscotch/common/platform/std/inspections/extension.inspector" import { ExtensionInspectorService } from "@hoppscotch/common/platform/std/inspections/extension.inspector"
@@ -40,9 +40,9 @@ createHoppApp("#app", {
tabState: tabStateDef, tabState: tabStateDef,
}, },
interceptors: { interceptors: {
default: "localclient", default: "native",
interceptors: [ interceptors: [
{ type: "standalone", interceptor: localclientInterceptor }, { type: "standalone", interceptor: nativeInterceptor },
{ type: "standalone", interceptor: browserInterceptor }, { type: "standalone", interceptor: browserInterceptor },
{ type: "standalone", interceptor: proxyInterceptor }, { type: "standalone", interceptor: proxyInterceptor },
{ type: "service", service: ExtensionInterceptorService }, { type: "service", service: ExtensionInterceptorService },

View File

@@ -15,7 +15,6 @@ import { open } from '@tauri-apps/api/shell'
import { Body, getClient } from '@tauri-apps/api/http' import { Body, getClient } from '@tauri-apps/api/http'
import { listen } from '@tauri-apps/api/event' import { listen } from '@tauri-apps/api/event'
import { Store } from "tauri-plugin-store-api"; import { Store } from "tauri-plugin-store-api";
import { P } from "@tauri-apps/api/event-41a9edf5"
export const authEvents$ = new Subject<AuthEvent | { event: "token_refresh" }>() export const authEvents$ = new Subject<AuthEvent | { event: "token_refresh" }>()
const currentUser$ = new BehaviorSubject<HoppUser | null>(null) const currentUser$ = new BehaviorSubject<HoppUser | null>(null)
@@ -25,7 +24,7 @@ async function logout() {
let client = await getClient(); let client = await getClient();
await client.get(`${import.meta.env.VITE_BACKEND_API_URL}/auth/logout`) await client.get(`${import.meta.env.VITE_BACKEND_API_URL}/auth/logout`)
const store = new Store("/Users/vivek/.creds.dat") const store = new Store("/Users/vivek/.creds.dat")
await store.set("refresh_token", {}) await store.set("refresh_token", {})
await store.set("access_token", {}) await store.set("access_token", {})
await store.save() await store.save()
@@ -337,7 +336,7 @@ export const def: AuthPlatformDef = {
let verifyToken = getLocalConfig("verifyToken") let verifyToken = getLocalConfig("verifyToken")
const client = await getClient(); const client = await getClient();
let res = await client.post(`${import.meta.env.VITE_BACKEND_API_URL}/auth/verify`, Body.json({ let res = await client.post(`${import.meta.env.VITE_BACKEND_API_URL}/auth/verify`, Body.json({
token: verifyToken, token: verifyToken,
deviceIdentifier deviceIdentifier
})); }));

View File

@@ -3,7 +3,7 @@ import {
Interceptor, Interceptor,
InterceptorError, InterceptorError,
RequestRunResult, RequestRunResult,
} from "../../../services/interceptor.service" } from "@hoppscotch/common/services/interceptor.service"
import axios, { AxiosRequestConfig, CancelToken } from "axios" import axios, { AxiosRequestConfig, CancelToken } from "axios"
import { cloneDeep } from "lodash-es" import { cloneDeep } from "lodash-es"
import { Body, HttpVerb, ResponseType, getClient } from '@tauri-apps/api/http' import { Body, HttpVerb, ResponseType, getClient } from '@tauri-apps/api/http'
@@ -56,12 +56,12 @@ async function runRequest(
let body_data = {} let body_data = {}
for (const entry of processedReq.data.entries()) { for (const entry of processedReq.data.entries()) {
const [name, value] = entry; const [name, value] = entry;
if (value instanceof File) { if (value instanceof File) {
let file_data = await value.arrayBuffer() let file_data = await value.arrayBuffer()
body_data[name] = { body_data[name] = {
file: new Uint8Array(file_data as number[]), file: new Uint8Array(file_data),
fileName: value.name fileName: value.name
} }
} }
@@ -123,9 +123,9 @@ async function runRequest(
} }
} }
export const localclientInterceptor: Interceptor = { export const nativeInterceptor: Interceptor = {
interceptorID: "localclient", interceptorID: "native",
name: () => "localclient", name: () => "Native",
selectable: { type: "selectable" }, selectable: { type: "selectable" },
runRequest(req) { runRequest(req) {
const processedReq = preProcessRequest(req) const processedReq = preProcessRequest(req)

9
pnpm-lock.yaml generated
View File

@@ -947,6 +947,9 @@ importers:
'@rushstack/eslint-patch': '@rushstack/eslint-patch':
specifier: ^1.1.4 specifier: ^1.1.4
version: 1.3.3 version: 1.3.3
'@types/lodash-es':
specifier: ^4.17.9
version: 4.17.10
'@types/node': '@types/node':
specifier: ^18.7.10 specifier: ^18.7.10
version: 18.18.8 version: 18.18.8
@@ -10246,6 +10249,12 @@ packages:
'@types/lodash': 4.14.200 '@types/lodash': 4.14.200
dev: true dev: true
/@types/lodash-es@4.17.10:
resolution: {integrity: sha512-YJP+w/2khSBwbUSFdGsSqmDvmnN3cCKoPOL7Zjle6s30ZtemkkqhjVfFqGwPN7ASil5VyjE2GtyU/yqYY6mC0A==}
dependencies:
'@types/lodash': 4.14.199
dev: true
/@types/lodash-es@4.17.8: /@types/lodash-es@4.17.8:
resolution: {integrity: sha512-euY3XQcZmIzSy7YH5+Unb3b2X12Wtk54YWINBvvGQ5SmMvwb11JQskGsfkH/5HXK77Kr8GF0wkVDIxzAisWtog==} resolution: {integrity: sha512-euY3XQcZmIzSy7YH5+Unb3b2X12Wtk54YWINBvvGQ5SmMvwb11JQskGsfkH/5HXK77Kr8GF0wkVDIxzAisWtog==}
dependencies: dependencies: