From 7182395e0bb3ea635c68fc9651e011773eb0c957 Mon Sep 17 00:00:00 2001 From: nikita Date: Thu, 19 Mar 2026 13:16:23 -0500 Subject: [PATCH 1/3] fix cargo toml and revert the auth openapi spec split --- resources/auth-api.yaml | 154 ++++++++++++++++++++++--------------- resources/auth-common.yaml | 34 -------- rust/Cargo.lock | 2 +- 3 files changed, 91 insertions(+), 99 deletions(-) delete mode 100644 resources/auth-common.yaml diff --git a/resources/auth-api.yaml b/resources/auth-api.yaml index d481ae86..4fa0ba8f 100644 --- a/resources/auth-api.yaml +++ b/resources/auth-api.yaml @@ -1,4 +1,4 @@ -openapi: '3.0.3' +openapi: "3.0.3" info: title: Bluefin Auth API version: 1.0.0 @@ -16,6 +16,13 @@ servers: - sui-prod components: + responses: + DefaultError: + description: Unexpected error + content: + application/json: + schema: + $ref: "./common.yaml#/components/schemas/Error" schemas: JwksResponse: type: object @@ -75,6 +82,26 @@ components: - accountAddress - signedAtMillis - audience + LoginResponse: + type: object + required: + - accessToken + - accessTokenValidForSeconds + - refreshToken + - refreshTokenValidForSeconds + properties: + accessToken: + type: string + accessTokenValidForSeconds: + type: integer + format: int64 + x-go-type: int64 + refreshToken: + type: string + refreshTokenValidForSeconds: + type: integer + format: int64 + x-go-type: int64 RefreshTokenRequest: type: object required: @@ -123,7 +150,7 @@ components: - ephemeralPublicKey - maxEpoch - randomness - + ProofPoints: type: object properties: @@ -168,9 +195,9 @@ components: type: object properties: proofPoints: - $ref: '#/components/schemas/ProofPoints' + $ref: "#/components/schemas/ProofPoints" issBase64Details: - $ref: '#/components/schemas/IssBase64Details' + $ref: "#/components/schemas/IssBase64Details" headerBase64: type: string description: Base64 encoded header information. @@ -234,18 +261,18 @@ paths: get: tags: - Auth - summary: /.well-known/openid-configuration - description: OpenID Connect Discovery endpoint + summary: /.well-known/openid-configuration + description: OpenID Connect Discovery endpoint operationId: GetWellKnownOpenidConfiguration responses: - '200': + "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/OpenIDConfigurationResponse' + $ref: "#/components/schemas/OpenIDConfigurationResponse" default: - $ref: './auth-common.yaml#/components/responses/DefaultError' + $ref: "#/components/responses/DefaultError" /auth/zklogin: get: tags: @@ -261,31 +288,30 @@ paths: schema: type: string responses: - '200': + "200": description: Successful response with zkLogin user details content: application/json: schema: - $ref: '#/components/schemas/ZKLoginUserDetailsResponse' - '400': + $ref: "#/components/schemas/ZKLoginUserDetailsResponse" + "400": description: "Bad Request" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '500': + "500": description: internal server error content: application/json: schema: - $ref: "./common.yaml#/components/schemas/Error" - + $ref: "./common.yaml#/components/schemas/Error" /auth/zklogin/zkp: post: tags: - Auth - summary: /auth/zklogin/zkp + summary: /auth/zklogin/zkp operationId: PostZkLoginZkp parameters: - in: header @@ -299,45 +325,45 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ZKLoginZKPRequest' + $ref: "#/components/schemas/ZKLoginZKPRequest" responses: - '200': + "200": description: Successful response with ZK proof result content: application/json: schema: - $ref: '#/components/schemas/ZKLoginZKPResponse' - '400': + $ref: "#/components/schemas/ZKLoginZKPResponse" + "400": description: "Bad Request" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '500': + "500": description: Internal Server Error content: application/json: schema: - $ref: "./common.yaml#/components/schemas/Error" + $ref: "./common.yaml#/components/schemas/Error" /auth/jwks: get: tags: - Auth responses: - '200': + "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/JwksResponse' + $ref: "#/components/schemas/JwksResponse" default: - $ref: './auth-common.yaml#/components/responses/DefaultError' + $ref: "#/components/responses/DefaultError" /auth/token: post: tags: - Auth - description: 'login with token' + description: "login with token" parameters: - name: payloadSignature in: header @@ -364,52 +390,52 @@ paths: in: query required: false schema: - $ref: './common.yaml#/components/schemas/ClientType' + $ref: "./common.yaml#/components/schemas/ClientType" description: "The client application originating the request (WEB or VERA). Defaults to WEB if not supplied." requestBody: required: true content: - '*/*': + "*/*": schema: - $ref: '#/components/schemas/LoginRequest' + $ref: "#/components/schemas/LoginRequest" responses: - '200': + "200": description: OK content: application/json: schema: - $ref: './auth-common.yaml#/components/schemas/LoginResponse' - '400': + $ref: "#/components/schemas/LoginResponse" + "400": description: "bad signature" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '401': + "401": description: "invalid signature" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '403': + "403": description: "invalid audience" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '500': + "500": description: internal server error content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" default: - $ref: './auth-common.yaml#/components/responses/DefaultError' + $ref: "#/components/responses/DefaultError" /auth/v2/token: post: tags: - Auth - description: 'login compatible with BCS payload with intent bytes' + description: "login compatible with BCS payload with intent bytes" parameters: - name: payloadSignature in: header @@ -436,47 +462,47 @@ paths: in: query required: false schema: - $ref: './common.yaml#/components/schemas/ClientType' + $ref: "./common.yaml#/components/schemas/ClientType" description: "The client application originating the request (WEB or VERA). Defaults to WEB if not supplied." requestBody: required: true content: - '*/*': + "*/*": schema: - $ref: '#/components/schemas/LoginRequest' + $ref: "#/components/schemas/LoginRequest" responses: - '200': + "200": description: OK content: application/json: schema: - $ref: './auth-common.yaml#/components/schemas/LoginResponse' - '400': + $ref: "#/components/schemas/LoginResponse" + "400": description: "bad signature" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '401': + "401": description: "invalid signature" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '403': + "403": description: "invalid audience" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '500': + "500": description: internal server error content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" default: - $ref: './auth-common.yaml#/components/responses/DefaultError' + $ref: "#/components/responses/DefaultError" /auth/token/refresh: put: tags: @@ -487,71 +513,71 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/RefreshTokenRequest' + $ref: "#/components/schemas/RefreshTokenRequest" responses: - '200': + "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/RefreshTokenResponse' - '401': + $ref: "#/components/schemas/RefreshTokenResponse" + "401": description: "invalid signature" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '400': + "400": description: "missing refresh token in request" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '500': + "500": description: internal server error content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" default: - $ref: './auth-common.yaml#/components/responses/DefaultError' - + $ref: "#/components/responses/DefaultError" + /auth/client-credentials: post: tags: - Auth - summary: /auth/client-credentials - description: 'OAuth2 client_credentials grant for service accounts' + summary: /auth/client-credentials + description: "OAuth2 client_credentials grant for service accounts" operationId: PostAuthClientCredentials requestBody: required: true content: application/json: schema: - $ref: '#/components/schemas/ClientCredentialsRequest' + $ref: "#/components/schemas/ClientCredentialsRequest" application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/ClientCredentialsRequest' + $ref: "#/components/schemas/ClientCredentialsRequest" responses: - '200': + "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/ClientCredentialsResponse' - '400': + $ref: "#/components/schemas/ClientCredentialsResponse" + "400": description: "invalid request" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '401': + "401": description: "invalid or unconfigured credentials" content: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" - '500': + "500": description: internal server error content: application/json: diff --git a/resources/auth-common.yaml b/resources/auth-common.yaml deleted file mode 100644 index c2284cda..00000000 --- a/resources/auth-common.yaml +++ /dev/null @@ -1,34 +0,0 @@ -openapi: 3.0.3 -info: - title: Auth Common Schemas - version: v1 - description: Shared authentication schemas. -components: - responses: - DefaultError: - description: Unexpected error - content: - application/json: - schema: - $ref: "./common.yaml#/components/schemas/Error" - schemas: - LoginResponse: - type: object - required: - - accessToken - - accessTokenValidForSeconds - - refreshToken - - refreshTokenValidForSeconds - properties: - accessToken: - type: string - accessTokenValidForSeconds: - type: integer - format: int64 - x-go-type: int64 - refreshToken: - type: string - refreshTokenValidForSeconds: - type: integer - format: int64 - x-go-type: int64 diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 01f08399..5c4499b0 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -146,7 +146,7 @@ dependencies = [ [[package]] name = "bluefin_api" -version = "1.15.0" +version = "1.16.0" dependencies = [ "reqwest", "serde", From c739e264e9e620e05c59ebc2ecd815400f45c7f4 Mon Sep 17 00:00:00 2001 From: nikita Date: Thu, 19 Mar 2026 13:20:26 -0500 Subject: [PATCH 2/3] fix rust cargo package discrepancy --- .apigen-state | 9 ++++----- rust/Cargo.lock | 2 +- rust/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.apigen-state b/.apigen-state index 9b4f8430..89d97ea6 100644 --- a/.apigen-state +++ b/.apigen-state @@ -1,11 +1,10 @@ { "version": "1", "algorithm": "sha256", - "generated_at": "2026-03-18T22:53:13.035771Z", + "generated_at": "2026-03-19T18:17:33.330033Z", "spec_files": { "resources/account-data-api.yaml": "2d366acf63b1412c3b49583b22aea07829f297332ebd1b0680954d0d248f2998", - "resources/auth-api.yaml": "7fa07edd6586d00e8fd1e23fc81c83698800aa9cbfd3fa107072952d96bbf99a", - "resources/auth-common.yaml": "dbc5d97472a5051fe79a4fef919bc3e4c4d5d2e4751d0aab65c051be56174e1f", + "resources/auth-api.yaml": "01e54ca1a13d2d6307e0d3a9ea38f816902521e7c85998f0f21a1353cc54fb76", "resources/bluefin-api.yaml": "b81cebbb70822b4806a9c56e819d6dd1b52453f4b37d63a95a14dae7cf0edb9c", "resources/common.yaml": "71dc565fccebcc9e71b49b48448d2583903aec7e2d16ef1d69972b50f2e4250f", "resources/exchange-api.yaml": "a309b3a5c29fb71dcc26d6f8018883ec51b42db43c29fee7b7ed4f0997146f77", @@ -14,5 +13,5 @@ "resources/vera-api.yaml": "f4c51b5f6614dd4e3b9f5f1f01f945e06d9090849530ecb916ad4ae18d8f61a0", "resources/websocket-api.yaml": "c2c51ceea701bff0b7e911e9afdb0addeb4d7f173b2a25b996d13f5462cb535b" }, - "combined_hash": "752605421bfad83cb0424a9a943d7430a3b34bf812412955da279ac70e7df15e" -} + "combined_hash": "629cbc1a47ac5c37e7b184e23f3b077cd1a0337fa6827632b3b0c6dab582f88e" +} \ No newline at end of file diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 5c4499b0..04eb21e1 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "bluefin-pro" -version = "1.15.0" +version = "1.16.0" dependencies = [ "base64", "bcs", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d2eb0b71..09b53afb 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -93,7 +93,7 @@ keywords = [ license = "Unlicense" name = "bluefin-pro" repository = "https://github.com/fireflyprotocol/pro-sdk" -version = "1.15.0" +version = "1.16.0" [workspace] members = [ From a6033f51f986fc0fda849026afc3247a25b2588e Mon Sep 17 00:00:00 2001 From: nikita Date: Thu, 19 Mar 2026 13:30:13 -0500 Subject: [PATCH 3/3] run apigen --- Makefile | 7 +- rust/gen/bluefin_api/.openapi-generator/FILES | 1 - scripts/version_bump.py | 218 ------------------ 3 files changed, 2 insertions(+), 224 deletions(-) delete mode 100644 scripts/version_bump.py diff --git a/Makefile b/Makefile index 5913c16f..da6afb5e 100644 --- a/Makefile +++ b/Makefile @@ -6,14 +6,11 @@ SPEC := resources/bluefin-api.yaml DOCKER_RUN := docker run --rm -v $(CURDIR):/work -w /work $(OPENAPI_GEN_IMAGE) generate \ --input-spec /work/$(SPEC) -.PHONY: generate generate-ts generate-py generate-rs version-bump help +.PHONY: generate generate-ts generate-py generate-rs help # --- Code Generation --- -version-bump: ## Detect spec changes and bump SDK versions - python3 scripts/version_bump.py - -generate: generate-ts generate-py generate-rs version-bump ## Generate all SDK clients +generate: generate-ts generate-py generate-rs ## Generate all SDK clients generate-ts: ## Generate TypeScript client $(DOCKER_RUN) \ diff --git a/rust/gen/bluefin_api/.openapi-generator/FILES b/rust/gen/bluefin_api/.openapi-generator/FILES index d05adada..9f5fda1d 100644 --- a/rust/gen/bluefin_api/.openapi-generator/FILES +++ b/rust/gen/bluefin_api/.openapi-generator/FILES @@ -1,5 +1,4 @@ .gitignore -.openapi-generator-ignore .travis.yml Cargo.toml README.md diff --git a/scripts/version_bump.py b/scripts/version_bump.py deleted file mode 100644 index 368a05d2..00000000 --- a/scripts/version_bump.py +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/env python3 -""" -Version bump script for pro-sdk. - -Detects OpenAPI spec changes via SHA-256 hashing and bumps SDK versions -in the generator config files. - -Usage: - python3 scripts/version_bump.py [--no-bump] [--major] -""" - -from __future__ import annotations - -import hashlib -import json -import os -import re -import sys -from datetime import datetime, timezone -from pathlib import Path -from typing import Any - -STATE_FILE = ".apigen-state" -RESOURCES_DIR = "resources" - -# --- Hashing --- - - -def hash_file(path: Path) -> str: - return hashlib.sha256(path.read_bytes()).hexdigest() - - -def hash_spec_bundle(resources_dir: Path) -> tuple[dict[str, str], str]: - spec_files = sorted(resources_dir.glob("*.yaml")) - if not spec_files: - return {}, "" - - file_hashes: dict[str, str] = {} - for f in spec_files: - file_hashes[str(f)] = hash_file(f) - - combined = "".join(file_hashes[k] for k in sorted(file_hashes)) - combined_hash = hashlib.sha256(combined.encode()).hexdigest() - return file_hashes, combined_hash - - -# --- State --- - - -def load_state(path: Path) -> dict[str, Any] | None: - if not path.exists(): - return None - state: dict[str, Any] = json.loads(path.read_text()) - return state - - -def save_state(path: Path, file_hashes: dict[str, str], combined_hash: str) -> None: - state: dict[str, Any] = { - "version": "1", - "algorithm": "sha256", - "generated_at": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"), - "spec_files": file_hashes, - "combined_hash": combined_hash, - } - path.write_text(json.dumps(state, indent=2) + "\n") - - -# --- Version bumping --- - - -def bump_major(version: str) -> str: - major, _minor, _patch = version.split(".") - return f"{int(major) + 1}.0.0" - - -def bump_minor(version: str) -> str: - major, minor, _patch = version.split(".") - return f"{major}.{int(minor) + 1}.0" - - -def read_yaml_version(path: Path) -> str: - """Read packageVersion from a YAML config.""" - for line in path.read_text().splitlines(): - m = re.match(r"\s*packageVersion:\s*['\"]?([0-9.]+)['\"]?", line) - if m: - return m.group(1) - raise ValueError(f"packageVersion not found in {path}") - - -def write_yaml_version(path: Path, new_version: str) -> None: - """Write packageVersion in a YAML config.""" - text = path.read_text() - text = re.sub( - r"(packageVersion:\s*)['\"]?[0-9.]+['\"]?", - rf"\g<1>{new_version}", - text, - ) - path.write_text(text) - - -def write_json_version(path: Path, new_version: str) -> None: - """Write version fields in a JSON generator config.""" - data: dict[str, Any] = json.loads(path.read_text()) - props = data.get("additionalProperties") - if isinstance(props, dict): - props["npmVersion"] = new_version - if "packageVersion" in props: - props["packageVersion"] = new_version - path.write_text(json.dumps(data, indent=2) + "\n") - - -def write_toml_version(path: Path, new_version: str) -> None: - """Write version in a TOML file (pyproject.toml or Cargo.toml).""" - text = path.read_text() - text = re.sub( - r'(version\s*=\s*")[0-9.]+"', - rf'\g<1>{new_version}"', - text, - count=1, - ) - path.write_text(text) - - -def write_package_json_version(path: Path, new_version: str) -> None: - """Write version in a package.json file.""" - data: dict[str, Any] = json.loads(path.read_text()) - data["version"] = new_version - path.write_text(json.dumps(data, indent=2) + "\n") - - -def print_changes(file_hashes: dict[str, str], previous: dict[str, Any]) -> None: - prev_files: dict[str, str] = previous.get("spec_files", {}) - print("Changed files:") - for path, current_hash in file_hashes.items(): - prev_hash = prev_files.get(path) - if prev_hash is None: - print(f" {path} (new)") - elif current_hash != prev_hash: - print(f" {path} (modified)") - for path in prev_files: - if path not in file_hashes: - print(f" {path} (deleted)") - - -# --- Main --- - - -def main() -> None: - skip_bump = "--no-bump" in sys.argv - major_bump = "--major" in sys.argv - - # cd to repo root - repo_root = Path(__file__).resolve().parent.parent - os.chdir(repo_root) - - resources = Path(RESOURCES_DIR) - if not resources.is_dir(): - print(f"Error: {RESOURCES_DIR}/ not found") - sys.exit(1) - - file_hashes, combined_hash = hash_spec_bundle(resources) - if not file_hashes: - print(f"No spec files found in {RESOURCES_DIR}/") - sys.exit(0) - - state_path = Path(STATE_FILE) - previous = load_state(state_path) - - if previous is None: - print("First run — establishing baseline (no version bump)") - for path, h in file_hashes.items(): - print(f" {path}: {h[:16]}...") - save_state(state_path, file_hashes, combined_hash) - print(f"State saved to {STATE_FILE}") - sys.exit(0) - - if combined_hash == previous.get("combined_hash"): - print("No spec changes detected") - sys.exit(0) - - print_changes(file_hashes, previous) - - if skip_bump: - print("Version bump skipped (--no-bump)") - else: - current_version = read_yaml_version(Path("python/sdk/config.yaml")) - new_version = bump_major(current_version) if major_bump else bump_minor(current_version) - bump_type = "major (breaking)" if major_bump else "minor" - print(f"Bumping versions ({bump_type}): {current_version} -> {new_version}") - - # Generator configs - write_yaml_version(Path("python/sdk/config.yaml"), new_version) - print(f" python/sdk/config.yaml -> {new_version}") - - write_yaml_version(Path("rust/gen/config.yaml"), new_version) - print(f" rust/gen/config.yaml -> {new_version}") - - write_json_version(Path("ts/sdk/openapitools.json"), new_version) - print(f" ts/sdk/openapitools.json -> {new_version}") - - # Package manifests - manifests: list[tuple[str, Any]] = [ - ("python/sdk/pyproject.toml", write_toml_version), - ("rust/Cargo.toml", write_toml_version), - ("ts/sdk/package.json", write_package_json_version), - ] - for rel_path, writer in manifests: - p = Path(rel_path) - if p.exists(): - writer(p, new_version) - print(f" {rel_path} -> {new_version}") - - save_state(state_path, file_hashes, combined_hash) - print(f"State saved to {STATE_FILE}") - - -if __name__ == "__main__": - main()