Skip to content

Usage license #205

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

Closed
wants to merge 2 commits into from
Closed

Usage license #205

wants to merge 2 commits into from

Conversation

kriszyp
Copy link
Member

@kriszyp kriszyp commented Jul 25, 2025

No description provided.

Comment on lines +34 to +36
* header: This is a JSON object with two properties:
* typ: should be "Harper-License"
* alg: should be "EdDSA"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how this will eventually be rendered, but maybe the properties should be code?

Suggested change
* header: This is a JSON object with two properties:
* typ: should be "Harper-License"
* alg: should be "EdDSA"
* `header`: This is a JSON object with two properties:
* `typ`: should be "Harper-License"
* `alg`: should be "EdDSA"

"realTimeBytes": 40000000000000,
"cpuTime": 108000,
"storage": 400000000000000,
"expiration":"2025-07-25T21:17:21.248Z"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"expiration":"2025-07-25T21:17:21.248Z"
"expiration": "2025-07-25T21:17:21.248Z"

The three base64 blocks are combined to form the `license` property value in the operation.

- operation _(required)_ - must always be `install_usage_license`
- license _(required)_ - This is the combination of the three blocks in the form header.payload.signature
Copy link
Contributor

Choose a reason for hiding this comment

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

Elsewhere the value is rendered as inline code.

Suggested change
- license _(required)_ - This is the combination of the three blocks in the form header.payload.signature
- license _(required)_ - This is the combination of the three blocks in the form `header.payload.signature`

"cpuTime": 108000,
"usedCpuTime": 41000,
"storage": 400000000000000,
"expiration":"2025-07-25T21:17:21.248Z"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"expiration":"2025-07-25T21:17:21.248Z"
"expiration": "2025-07-25T21:17:21.248Z"

"cpuTime": 108000,
"usedCpuTime": 0,
"storage": 400000000000000,
"expiration":"2025-09-25T21:17:21.248Z"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"expiration":"2025-09-25T21:17:21.248Z"
"expiration": "2025-09-25T21:17:21.248Z"

Comment on lines +164 to +167
]
```

---
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what's going on here. Past merge conflict?


Install a Harper license for a block of usage. Multiple usage blocks may be installed, and they will be used up sequentially, with the earliest installed blocks used first. A license is installed
by creating a string that consists of three base64 encoded blocks, separated by dots. The three blocks consist of:
* header: This is a JSON object with two properties:
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems else where in this page and on other page we are using - for lists, not *. We should be consistent.

* realTimeBytes _(required)_ - The number of allowed real-time message bytes
* cpuTime _(optional)_ - The allowed amount of CPU time consumed by application code
* storage _(optional)_ - Maximum of storage that may be used
* expiration _(required_) - The date when this block expires, as an ISO date
Copy link
Contributor

Choose a reason for hiding this comment

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

s/required_)/required)_/

* storage _(optional)_ - Maximum of storage that may be used
* expiration _(required_) - The date when this block expires, as an ISO date

This JSON object should be converted to base64 (conversion from utf-8 to base64) and is the second base64 block.
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes me wonder if we need any JSON normalization in here... Otherwise differences that a JSON parser would ignore might result in different base64 encodings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't the signing of the JSON based on the generated licenses stringification? It seems like the signer can dictate all of that itself without coordination? But if coordination is needed, maybe we can just say without any extra/unnecessary spacing? (the default for JSON.stringify).

* typ: should be "Harper-License"
* alg: should be "EdDSA"

This JSON object should be converted to base64 (conversion from utf-8 to base64) and is the first base64 block.
Copy link
Contributor

Choose a reason for hiding this comment

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

I used base64url encoding originally (mostly just because it's what JWTs use and it seemed the safer choice overall). So unless you changed that, we should specify that here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did not change the code, so yes, make it base64url if that is the behavior.


This will retrieve and return all active usage licenses, with counts of how much of the limits have been consumed.

- operation _(required)_ - must always be `install_usage_license`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be get_usage_licenses

{
"id": "license-717b-4c6c-b69d-b29014054ab7",
"level": 2,
"regionId": "us-nw-2",
Copy link
Contributor

Choose a reason for hiding this comment

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

This attribute is just called region currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Region makes sense to me because of the way we have region + latency sort of grouped together in the block pricing

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, region is fine.


* license payload: This is a JSON object with properties:
* id _(required)_ - A unique id for the license
* level _(required)_ - Usage level number
Copy link
Contributor

Choose a reason for hiding this comment

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

There was no description of this attribute in the original ticket, so the code currently expects it to be a string. I can adjust it to expect a number, but is there any more context about what this value is and any other constraints that should be placed on it?

Copy link
Member Author

Choose a reason for hiding this comment

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

This corresponds to the different levels from https://harperdb.atlassian.net/wiki/spaces/SD/pages/34209804/HarperDB+Usage+Pricing+and+Tracking. I don't think we have any functional behavior that depends on this (right now), so it is just informational. We could make this optional (and any type of if that is easier).

@cap10morgan cap10morgan mentioned this pull request Aug 11, 2025
@cap10morgan
Copy link
Contributor

Closing in favor of #220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants