Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BFR: Big Falcon Refactoring #609

Merged
merged 98 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
bef8222
Move pricingSheet and calculate to order module (delivery and payment)
pozylon Nov 27, 2024
a4eceeb
Fix delivery and payment plugins any context
pozylon Nov 27, 2024
bbbca65
Allow to mix in unchained api to director types
pozylon Nov 27, 2024
0f4f636
Refactor pricing
pozylon Nov 27, 2024
b55ce10
Pass currency correctly
pozylon Nov 27, 2024
98d9b69
Refactor findSupported and move it to services
pozylon Nov 27, 2024
9d636fc
Refactor findSupported and move it to services (payment)
pozylon Nov 27, 2024
ee593ef
Remove unchained api
pozylon Nov 27, 2024
efa0e0b
when is a data
pozylon Nov 27, 2024
b4243cf
Fix token expiry
pozylon Nov 27, 2024
a037959
Refactor payment and delivery to be mostly core-free
pozylon Nov 28, 2024
fe63506
Simplify
pozylon Nov 28, 2024
f35a851
Move tokenizeItem und tokenMetadata
pozylon Nov 28, 2024
7a75c50
Move estimatedDispatch
pozylon Nov 28, 2024
24b7bbe
Fix estimatedStock
pozylon Nov 28, 2024
beee4c8
Fix director types
pozylon Nov 28, 2024
db1522b
Move stuff
pozylon Nov 28, 2024
76e007e
Fix currency tangling
pozylon Nov 29, 2024
f954efc
Start to simplify enrollments
pozylon Dec 3, 2024
692b879
Fix enrollments module typing
pozylon Dec 4, 2024
a243b65
Fix filters module typing
pozylon Dec 4, 2024
71685bf
Filters
pozylon Dec 4, 2024
2828380
Filter services
pozylon Dec 4, 2024
975f6a9
Fix product types
pozylon Dec 4, 2024
517f339
It get’s freezing cold down the rabbit hole 🤣
pozylon Dec 6, 2024
0223ee3
Fix parts of cart mutations to not depend on context
pozylon Dec 6, 2024
6153e02
Move away Director reference in core modules
pozylon Dec 6, 2024
2980733
Remove pricingSheet fn’s because of ambiguity
pozylon Dec 6, 2024
6de32e8
Remove pricingSheet fn’s because of ambiguity
pozylon Dec 6, 2024
70a9748
Move discounted
pozylon Dec 6, 2024
8e6c25b
Move updateScheduling to services
pozylon Dec 6, 2024
3d9a79c
Milestone: completely decoupled core usage in core modules, next up: …
pozylon Dec 6, 2024
1343873
Move DeliveryDirector to core
pozylon Dec 6, 2024
289fc35
Move EnrollmenDirector to core
pozylon Dec 6, 2024
ed24066
Move ProductDirector and FilterDirector to core
pozylon Dec 6, 2024
1d4c469
Adjust types to core
pozylon Dec 6, 2024
8b88f8c
Move order adapters to core
pozylon Dec 6, 2024
c4eef9a
Move warehousing director to core
pozylon Dec 6, 2024
8f4fd06
Fix base pricing sheet dependency of OrderDirector
pozylon Dec 6, 2024
d856b1e
Move discount handling
pozylon Dec 9, 2024
1536bdb
Move initialConfiguration to callee
pozylon Dec 9, 2024
1ede802
Move price simulation to api
pozylon Dec 9, 2024
3483779
Move enrollment processing to services
pozylon Dec 9, 2024
238cc29
Fix some checkout problems
pozylon Dec 9, 2024
425901d
Fix discounts
pozylon Dec 9, 2024
f98d5f9
Default quantity to 1 if not set
pozylon Dec 9, 2024
216b8f2
Fix quantity default
pozylon Dec 9, 2024
32341d0
Fix orderId
pozylon Dec 9, 2024
773642a
Update eslint
pozylon Dec 9, 2024
5931999
Use rust bcrypt instead of bcryptjs (50% faster)
pozylon Dec 9, 2024
51e64d1
Fix filter
pozylon Dec 9, 2024
3f3c559
Move worker director
pozylon Dec 10, 2024
9a7664d
Move worker management
pozylon Dec 10, 2024
80f1460
Fix recursion
pozylon Dec 10, 2024
94efcef
Move messaging management
pozylon Dec 10, 2024
a96dda7
Remove quotations entanglement
pozylon Dec 10, 2024
d66c33c
Adjust enrollment typing
pozylon Dec 10, 2024
eb15929
Inline product search and assortment search indirection
pozylon Dec 11, 2024
f08d1e4
Move internal filter fn to core and api
pozylon Dec 11, 2024
223b6e9
Complete unchainedAPI typing
pozylon Dec 11, 2024
0645f82
Update deps
pozylon Dec 11, 2024
fff9367
Fix optional/dev dependencies
pozylon Dec 11, 2024
0dbacff
Get rid of winston dependencies
pozylon Dec 11, 2024
95f8cf5
Move fileUrl
pozylon Dec 11, 2024
6fa5c47
Implement erc metadata for fastify
pozylon Dec 12, 2024
5d7fd57
Remove passport-strategy and enable erc metadata and bulk import hand…
pozylon Dec 12, 2024
aec227b
Enforce WebCrypto to hash
pozylon Dec 12, 2024
695cd7f
Fix chainTokenId
pozylon Dec 12, 2024
64bbc20
Fix bulk importer
pozylon Dec 12, 2024
2d1afe5
Type order templates
pozylon Dec 12, 2024
6d9309d
Lockfile
pozylon Dec 13, 2024
c49f7d6
Fix signature generation for datatrans
pozylon Dec 13, 2024
03b2abd
Fix file signatures and tests
pozylon Dec 13, 2024
2698626
Merge branch 'master' into hardcore-refactor
pozylon Dec 13, 2024
1e39e18
WIP: Add private flag option on file upload
Mikearaya Nov 25, 2024
f0fade8
Lock Media.url
Mikearaya Nov 26, 2024
bb6e4b0
Update media upload endpoint to accept private flag
Mikearaya Nov 26, 2024
66f2c97
Extend file adapter with url sign util and add signature and expirati…
Mikearaya Nov 26, 2024
ec82e04
Merge branch 'master' into hardcore-refactor
pozylon Dec 13, 2024
a3ec586
Make compatible with Bun
pozylon Dec 13, 2024
2d1519d
Add requested changes
Mikearaya Dec 14, 2024
99d5293
Move url signing responsibility to adapter
Mikearaya Dec 14, 2024
46ad40e
Lock private file download option based on user and adapter
Mikearaya Dec 15, 2024
7cd5bfc
Move url signer adapter check into file adapter base class
Mikearaya Dec 16, 2024
d8ce9a7
Move privateFileSharingMaxAge access into file adapter
Mikearaya Dec 16, 2024
384d3c1
Lock avatar upload
Mikearaya Dec 16, 2024
02e094d
Add event-bridge plugin
pozylon Dec 17, 2024
7e29b82
Update changelog
pozylon Dec 17, 2024
a1e18a7
Add media permissions integration tests
Mikearaya Dec 17, 2024
41c0675
new service architecture (wip)
pozylon Dec 17, 2024
a1be970
Add media download/access tests
Mikearaya Dec 17, 2024
6a4f18a
Add private tag in meta
Mikearaya Dec 17, 2024
1f908db
Move file access check into adapter
Mikearaya Dec 17, 2024
9517558
new service architecture (wip)
pozylon Dec 17, 2024
875bfb1
Move signing url call into getUrl
Mikearaya Dec 17, 2024
bb79ddc
Fix regression
pozylon Dec 17, 2024
15d26e1
Update changelog and packages
pozylon Dec 17, 2024
eaa7069
Merge branch 'restrict-file-access' into hardcore-refactor
pozylon Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move file access check into adapter
  • Loading branch information
Mikearaya committed Dec 17, 2024
commit 1f908dbd53c915130da5cd0c7e385a639c9b7da2
6 changes: 1 addition & 5 deletions packages/api/src/resolvers/type/media-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ export const Media: MediaHelperTypes = {
await checkAction(context, actions.downloadFile, [file, params]);
const fileUploadAdapter = getFileAdapter();
const mediaUrl = modules.files.getUrl(file, params);
if (file?.meta?.isPrivate) {
return fileUploadAdapter.createDownloadURL(mediaUrl, file._id);
} else {
return mediaUrl;
}
return fileUploadAdapter.createDownloadURL(mediaUrl, file);
} catch (e) {
console.error(e);
return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/file-upload/src/director/FileAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IBaseAdapter } from '@unchainedshop/utils';
import { UploadedFile, UploadFileData } from '../types.js';

export interface IFileAdapter<Context = unknown> extends IBaseAdapter {
createDownloadURL: (fileUrl: string, mediaId: string, expiry?: number) => Promise<string | null>;
createDownloadURL: (fileUrl: string, file: any, expiry?: number) => Promise<string | null>;
createSignedURL: (
directoryName: string,
fileName: string,
Expand Down
9 changes: 5 additions & 4 deletions packages/plugins/src/files/gridfs/gridfs-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@ export const GridFSAdapter: IFileAdapter = {
version: '1.0.0',

...FileAdapter,
async createDownloadURL(fileUrl: string, mediaId: string, expiry?: number) {
async createDownloadURL(mediaUrl: string, file: any, expiry?: number) {
const secretKey = process.env.UNCHAINED_SECRET;
if (!secretKey) {
throw new Error('UNCHAINED_SECRET is not set in environment variables');
}

if (!file?._id || !mediaUrl) return null;
if (!file.meta?.isPrivate) return mediaUrl;
const expiryTimestamp = new Date(
new Date().getTime() + (filesSettings?.privateFileSharingMaxAge || 0),
).getTime();

const normalizedTimestamp = expiry || expiryTimestamp;
const data = `${mediaId}:${normalizedTimestamp}`;
const data = `${file._id}:${normalizedTimestamp}`;

const signature = crypto.createHmac('sha256', secretKey).update(data).digest('hex');
return `${fileUrl}?s=${signature}&e=${normalizedTimestamp}`;
return `${mediaUrl}?s=${signature}&e=${normalizedTimestamp}`;
},
async createSignedURL(directoryName, fileName) {
const expiryDate = resolveExpirationDate();
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/files/gridfs/gridfs-webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const gridfsHandler = async (
const urlWithoutQuery = url.origin + url.pathname;
const signedUrl = await fileAdapter.createDownloadURL(
urlWithoutQuery,
fileId,
fileDocument,
parseInt(expiryTimestamp || 0),
);
if (
Expand Down
Loading