Skip to content

Commit

Permalink
Merge pull request #295 from shocknet/test
Browse files Browse the repository at this point in the history
merge from Test
  • Loading branch information
shocknet-justin authored Sep 18, 2024
2 parents db33c94 + 79177a1 commit 4884d82
Show file tree
Hide file tree
Showing 31 changed files with 3,473 additions and 1,749 deletions.
1,428 changes: 1,123 additions & 305 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@capacitor/android": "5.4.0",
"@capacitor/app": "5.0.6",
"@capacitor/browser": "^5.2.0",
"@capacitor/camera": "^5.0.7",
"@capacitor/camera": "^5.0.10",
"@capacitor/clipboard": "^5.0.6",
"@capacitor/core": "5.7.8",
"@capacitor/filesystem": "^5.1.4",
Expand All @@ -32,8 +32,8 @@
"@gandlaf21/bolt11-decode": "^3.0.6",
"@ionic-native/camera": "^5.36.0",
"@ionic/pwa-elements": "^3.2.2",
"@ionic/react": "^7.0.0",
"@ionic/react-router": "^7.0.0",
"@ionic/react": "^8.3.0",
"@ionic/react-router": "^8.3.0",
"@noble/curves": "^1.5.0",
"@noble/hashes": "^1.5.0",
"@noble/secp256k1": "^2.0.0",
Expand Down Expand Up @@ -83,7 +83,7 @@
"reactjs-qr-reader": "^1.1.0",
"sortablejs": "^1.15.1",
"styled-components": "^6.0.8",
"uuid": "^9.0.1"
"uuid": "^10.0.0"
},
"devDependencies": {
"@capacitor/assets": "^3.0.5",
Expand All @@ -94,7 +94,7 @@
"@types/deep-diff": "^1.0.5",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@types/uuid": "^9.0.7",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.3.0",
"@vitejs/plugin-legacy": "^4.0.2",
Expand All @@ -103,12 +103,13 @@
"eslint": "^8.56.0",
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-hooks": "^4.6.2",
"jsdom": "^22.1.0",
"sass": "^1.67.0",
"typescript": "^5.3.3",
"vite": "^4.3.9",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-pwa": "^0.20.5",
"vitest": "^0.32.2"
},
"description": "An Ionic project"
Expand Down
16 changes: 12 additions & 4 deletions public/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ self.addEventListener('click', event => {
});

self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request)
.then(response => response || fetch(event.request))
);
if (event.request.mode === 'navigate') {
event.respondWith(
fetch(event.request).catch(() => {
return caches.match('/index.html');
})
);
} else {
event.respondWith(
caches.match(event.request)
.then(response => response || fetch(event.request))
);
}
});

self.addEventListener('beforeinstallprompt', event => {
Expand Down
32 changes: 32 additions & 0 deletions src/Api/bridge/autogenerated/ts/http_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type ResultError = { status: 'ERROR', reason: string }
export type ClientParams = {
baseUrl: string
retrieveGuestAuth: () => Promise<string | null>
retrieveNostrAuth: () => Promise<string | null>
encryptCallback: (plain: any) => Promise<any>
decryptCallback: (encrypted: any) => Promise<any>
deviceId: string
Expand All @@ -26,6 +27,20 @@ export default (params: ClientParams) => ({
}
return { status: 'ERROR', reason: 'invalid response' }
},
GetOrCreateNofferName: async (request: Types.GetOrCreateNofferNameRequest): Promise<ResultError | ({ status: 'OK' }& Types.GetOrCreateNofferNameResponse)> => {
const auth = await params.retrieveNostrAuth()
if (auth === null) throw new Error('retrieveNostrAuth() returned null')
let finalRoute = '/api/v1/noffer/vanity'
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.GetOrCreateNofferNameResponseValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
HandleLnurlPay: async (query: Types.HandleLnurlPay_Query): Promise<ResultError | ({ status: 'OK' }& Types.HandleLnurlPayResponse)> => {
const auth = await params.retrieveGuestAuth()
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
Expand All @@ -42,6 +57,23 @@ export default (params: ClientParams) => ({
}
return { status: 'ERROR', reason: 'invalid response' }
},
HandleLnurlPayUsername: async (query: Types.HandleLnurlPayUsername_Query, routeParams: Types.HandleLnurlPayUsername_RouteParams): Promise<ResultError | ({ status: 'OK' }& Types.HandleLnurlPayResponse)> => {
const auth = await params.retrieveGuestAuth()
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
let finalRoute = '/api/lnurl_pay/:address_name'
finalRoute = finalRoute.replace(':address_name', routeParams['address_name'])
const q = (new URLSearchParams(query)).toString()
finalRoute = finalRoute + (q === '' ? '' : '?' + q)
const { data } = await axios.get(params.baseUrl + finalRoute, { headers: { 'authorization': auth } })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.HandleLnurlPayResponseValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
HandleLnurlAddress: async (routeParams: Types.HandleLnurlAddress_RouteParams): Promise<ResultError | ({ status: 'OK' }& Types.LnurlPayInfoResponse)> => {
const auth = await params.retrieveGuestAuth()
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
Expand Down
Loading

0 comments on commit 4884d82

Please sign in to comment.