Skip to content

Commit 8a8dd59

Browse files
rickyrombodylanjeffersraymondjacobsonCopilotgithub-actions[bot]
authored
Simplify OAuth refreshToken middleware by using OAuth service in the middleware (#13805)
Removes the deps on usersApi by removing the `isWriteAccessGranted` method (which is redundant to the devApps APIs) and the `verifyToken` method (which is redundant with the usersApi) and calling fetch manually internally. Then, this allows the OAuth service to be initialized before other APIs so that it can be used in the config for middlewares to all other APIs. --------- Co-authored-by: Dylan Jeffers <dylan@audius.co> Co-authored-by: Ray Jacobson <ray@audius.co> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 4cea1ec commit 8a8dd59

88 files changed

Lines changed: 1232 additions & 575 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/afraid-mayflies-hunt.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/chilled-bobcats-sit.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/four-peas-impress.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

.changeset/plenty-starfishes-walk.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/purple-experts-allow.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

package-lock.json

Lines changed: 7 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/common/src/adapters/collection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export const playlistMetadataForCreateWithSDK = (
190190
parentalWarningType: input.parental_warning_type ?? undefined,
191191
...('cover_art_sizes' in input
192192
? {
193-
coverArtCid: input.cover_art_sizes ?? '',
193+
playlistImageSizesMultihash: input.cover_art_sizes ?? '',
194194
isImageAutogenerated: input.is_image_autogenerated ?? false
195195
}
196196
: {})
@@ -211,7 +211,7 @@ export const playlistMetadataForUpdateWithSDK = (
211211
: undefined,
212212
playlistName: input.playlist_name ?? '',
213213
description: input.description ?? '',
214-
coverArtCid: input.cover_art_sizes ?? '',
214+
playlistImageSizesMultihash: input.cover_art_sizes ?? '',
215215
isPrivate: input.is_private ?? false
216216
}
217217
}

packages/common/src/api/tan-query/upload/usePublishCollection.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) =>
103103
const metadata = albumMetadataForCreateWithSDK(
104104
params.collectionMetadata
105105
)
106-
metadata.playlistContents = publishedTracks.map((t) => ({
107-
timestamp: Math.round(Date.now() / 1000),
108-
trackId: Id.parse(t.trackId),
109-
metadataTimestamp: Math.round(Date.now() / 1000)
110-
}))
106+
metadata.playlistContents = publishedTracks
107+
.filter((t) => !!t.trackId)
108+
.map((t) => ({
109+
timestamp: Math.round(Date.now() / 1000),
110+
trackId: t.trackId!,
111+
metadataTimestamp: Math.round(Date.now() / 1000)
112+
}))
111113
return await sdk.albums.createAlbum({
112114
userId: Id.parse(userId),
113115
imageFile: coverArtFile,
@@ -117,11 +119,13 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) =>
117119
const metadata = playlistMetadataForCreateWithSDK(
118120
params.collectionMetadata
119121
)
120-
metadata.playlistContents = publishedTracks.map((t) => ({
121-
timestamp: Math.round(Date.now() / 1000),
122-
trackId: Id.parse(t.trackId),
123-
metadataTimestamp: Math.round(Date.now() / 1000)
124-
}))
122+
metadata.playlistContents = publishedTracks
123+
.filter((t) => !!t.trackId)
124+
.map((t) => ({
125+
timestamp: Math.round(Date.now() / 1000),
126+
trackId: t.trackId!,
127+
metadataTimestamp: Math.round(Date.now() / 1000)
128+
}))
125129
return await sdk.playlists.createPlaylist({
126130
userId: Id.parse(userId),
127131
imageFile: coverArtFile,

packages/common/src/store/account/sagas.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,16 @@ function* fetchLocalAccountAsync() {
362362
users: [cachedAccountUser],
363363
queryClient
364364
})
365+
// Set walletAddresses so useCurrentAccount/useWalletAddresses work correctly.
366+
// Without this, components that depend on currentUserWallet stay disabled.
367+
const web3WalletAddress = wallet
368+
yield* put(
369+
setWalletAddresses({ currentUser: wallet, web3User: web3WalletAddress })
370+
)
371+
queryClient.setQueryData(getWalletAddressesQueryKey(), {
372+
currentUser: wallet,
373+
web3User: web3WalletAddress
374+
})
365375
queryClient.setQueryData(getAccountStatusQueryKey(), Status.SUCCESS)
366376
yield* put(fetchAccountSucceeded(cachedAccount))
367377
}

packages/create-audius-app/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env node
22
import { cyan, green, red, bold } from 'picocolors'
3-
import Commander from 'commander'
3+
import { Command } from 'commander'
44
import path from 'path'
55
import prompts from 'prompts'
66
import { createApp } from './create-app'
7+
import type { ExampleType } from './helpers/examples'
78
import { validateNpmName } from './helpers/validate-pkg'
89
import packageJson from './package.json'
910
import { isFolderEmpty } from './helpers/is-folder-empty'
@@ -16,12 +17,12 @@ const handleSigTerm = () => process.exit(0)
1617
process.on('SIGINT', handleSigTerm)
1718
process.on('SIGTERM', handleSigTerm)
1819

19-
const program = new Commander.Command(packageJson.name)
20+
const program = new Command(packageJson.name)
2021
.version(packageJson.version)
21-
.arguments('<project-directory>')
22+
.arguments('[project-directory]')
2223
.usage(`${green('<project-directory>')} [options]`)
2324
.action((name) => {
24-
projectPath = name
25+
projectPath = name ?? ''
2526
})
2627
.option(
2728
'-e, --example [name]',
@@ -89,7 +90,8 @@ async function run() {
8990
process.exit(1)
9091
}
9192

92-
if (program.example === true) {
93+
const exampleOption = program.opts().example
94+
if (exampleOption === true) {
9395
console.error(
9496
'Please provide an example name, otherwise remove the example option.'
9597
)
@@ -107,7 +109,7 @@ async function run() {
107109
process.exit(1)
108110
}
109111

110-
const example = program.example.trim()
112+
const example = (typeof exampleOption === 'string' ? exampleOption : 'react-hono').trim() as ExampleType
111113

112114
await createApp({
113115
appPath: resolvedProjectPath,

0 commit comments

Comments
 (0)