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

Remove delegates #18

Merged
merged 8 commits into from
Dec 17, 2024
Merged

Remove delegates #18

merged 8 commits into from
Dec 17, 2024

Conversation

fpseverino
Copy link
Member

@fpseverino fpseverino commented Dec 14, 2024

  • Completely remove the delegates and move their methods to PassDataModel and OrderDataModel
  • Provide a default implementation for the model middleware of PassDataModel and OrderDataModel
  • Update DocC

⚠️ This PR removes the possibility for the user to make a serious mistake, below it is explained why:

Made data models generic parameters of services

Now PassesService and OrdersService require respectively PassDataModel and OrderDataModel as generic parameters (until now the data model protocols were basically useless).

That means that the user must create a service for each data model; the reason is explained in the next paragraph

Eliminate a possible error with signing passes/orders

PassDataModel and OrderDataModel now also require a typeIdentifier static property.

Each certificate Apple gives is related to a type identifier, and should only sign passes/orders of that type identifier.

Until now it was possible to sign passes and orders of different type identifiers with the same service (and therefore the same certificate).

Now each service has a single data model as a generic parameter, so this error is impossible

Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment

import Orders

final class OrderData: OrderDataModel, @unchecked Sendable {
static let schema = "order_data"

static let typeIdentifier = Environment.get("ORDER_TYPE_IDENTIFIER")!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this best practice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I prefer not to hard code it so as not to leak it into version control, just to be safe. It's not actually strictly secret, so you might as well hard code it.

@fpseverino fpseverino merged commit 01bd819 into vapor-community:main Dec 17, 2024
7 of 11 checks passed
@fpseverino fpseverino deleted the update branch December 17, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants