@maxceem/agw 0.15.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/agw.mjs +20 -12
  2. package/package.json +2 -1
package/dist/agw.mjs CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // <define:__AGW_MANIFEST__>
9
- var define_AGW_MANIFEST_default = { version: "0.15.1", wrangler: "4.96.0", upgradeFrom: ["0.15.1", "0.15.0", "0.14.0", "0.13.1", "0.13.0", "0.12.1", "0.12.0", "0.11.2", "0.11.1", "0.11.0", "0.10.11", "0.10.10", "0.10.9", "0.10.8", "0.10.7", "0.10.6", "0.10.5", "0.10.4", "0.10.3", "0.10.2", "0.10.1", "0.10.0", "0.9.3", "0.9.2", "0.9.1", "0.9.0", "0.8.3", "0.8.2", "0.8.1", "0.8.0", "0.7.2", "0.7.1", "0.7.0", "0.6.4", "0.6.3", "0.6.2", "0.6.1", "0.6.0", "0.5.2", "0.5.1", "0.5.0", "0.4.0"], release: { url: "https://github.com/maxceem/app-ai-gateway/releases/download/v0.15.1/gateway-0.15.1.tar.gz", sha256: "b5938517a50f09ea3ce3f966efd949dde8e9f0f2c195d47bb0dfdcbc7ec8eda0", manifest: "888f171f040d7547b37c40b41c01a53d1f284c9671e0bdc98083e9474c4ecdab" } };
9
+ var define_AGW_MANIFEST_default = { version: "0.16.0", wrangler: "4.96.0", upgradeFrom: ["0.16.0", "0.15.1", "0.15.0", "0.14.0", "0.13.1", "0.13.0", "0.12.1", "0.12.0", "0.11.2", "0.11.1", "0.11.0", "0.10.11", "0.10.10", "0.10.9", "0.10.8", "0.10.7", "0.10.6", "0.10.5", "0.10.4", "0.10.3", "0.10.2", "0.10.1", "0.10.0", "0.9.3", "0.9.2", "0.9.1", "0.9.0", "0.8.3", "0.8.2", "0.8.1", "0.8.0", "0.7.2", "0.7.1", "0.7.0", "0.6.4", "0.6.3", "0.6.2", "0.6.1", "0.6.0", "0.5.2", "0.5.1", "0.5.0", "0.4.0"], release: { url: "https://github.com/maxceem/app-ai-gateway/releases/download/v0.16.0/gateway-0.16.0.tar.gz", sha256: "222ce0c030268e5b1468c5d1755d8ea7d6da0ce86d9a0229e0adf5eb5eab4850", manifest: "1ecdc82e5705b259f5eed20bc58348fa9bcd36686f177d5040b3544ea09ba920" } };
10
10
 
11
11
  // src/main.ts
12
12
  import { Writable as Writable2 } from "node:stream";
@@ -20585,6 +20585,7 @@ var ISSUER_PROVIDERS = ["firebase", "supabase", "auth0", "clerk", "custom"];
20585
20585
  var ENTITLEMENT_CHECKS = ["revenuecat", "custom"];
20586
20586
  var APP_ATTEST_ENVIRONMENTS = ["production", "development"];
20587
20587
  var APP_ATTEST_VERIFY_ON = ["every_request", "token_exchange"];
20588
+ var MAX_APP_TRANSACTION_LENGTH = 16384;
20588
20589
  var ENDPOINT_SLUG = /^[a-z0-9-]{1,64}$/;
20589
20590
  var PROVIDER_SLUG_PATTERN = /^[a-z0-9][a-z0-9-]{0,62}$/;
20590
20591
  var HTTP_FIELD_NAME = /^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/;
@@ -20818,11 +20819,11 @@ var LimitScopeSchema = external_exports.object({
20818
20819
  }).strict(),
20819
20820
  spending: external_exports.object({ monthly_usd: NullableSpendLimit }).strict()
20820
20821
  }).strict();
20821
- var BUDGET_SCOPES = ["install", "user"];
20822
+ var BUDGET_SCOPES = ["install", "user", "apple_account"];
20822
20823
  var PerUserLimitScopeSchema = LimitScopeSchema.extend({
20823
20824
  spending: LimitScopeSchema.shape.spending.extend({
20824
20825
  scope: external_exports.enum(BUDGET_SCOPES).optional().meta({
20825
- description: "Whose month monthly_usd is measured over: install (the default on App Attest applications) or user (the default, and the only value, on server applications). user on an App Attest application needs authentication.end_user.source issuer. Filled in on every parsed configuration."
20826
+ description: "Whose month monthly_usd is measured over: apple_account (the default on App Attest applications), install, or user (the default, and the only value, on server applications). apple_account counts every install of one Apple Account together, across devices and reinstalls; an install whose client sent no verifiable App Store transaction is counted on its own, as under install. user on an App Attest application needs authentication.end_user.source issuer. Filled in on every parsed configuration."
20826
20827
  })
20827
20828
  }).strict()
20828
20829
  }).strict();
@@ -20901,25 +20902,25 @@ var AppConfigSchema = external_exports.object({
20901
20902
  }
20902
20903
  const budgetScope = perUser?.spending.scope;
20903
20904
  if (authentication !== void 0 && budgetScope !== void 0) {
20904
- if (authentication.type === "api_key" && budgetScope === "install") {
20905
+ if (authentication.type === "api_key" && budgetScope !== "user") {
20905
20906
  context.addIssue({
20906
20907
  code: "custom",
20907
20908
  path: ["limits", "per_user", "spending", "scope"],
20908
- message: "cannot be install: server applications have no install; the budget is per user"
20909
+ message: `cannot be ${budgetScope}: server applications have no install or Apple Account; the budget is per user`
20909
20910
  });
20910
20911
  }
20911
20912
  if (authentication.type === "apple_app_attest" && budgetScope === "user" && authentication.end_user.source !== "issuer") {
20912
20913
  context.addIssue({
20913
20914
  code: "custom",
20914
20915
  path: ["limits", "per_user", "spending", "scope"],
20915
- message: "can be user only when authentication.end_user.source is issuer: under app_install every install is its own user, so use install"
20916
+ message: "can be user only when authentication.end_user.source is issuer: under app_install every install is its own user, so use apple_account to count one person's installs together, or install"
20916
20917
  });
20917
20918
  }
20918
20919
  }
20919
20920
  }).overwrite((config2) => {
20920
20921
  const spending = config2.limits.per_user.spending;
20921
20922
  if (spending.scope === void 0) {
20922
- spending.scope = config2.authentication.type === "apple_app_attest" ? "install" : "user";
20923
+ spending.scope = config2.authentication.type === "apple_app_attest" ? "apple_account" : "user";
20923
20924
  }
20924
20925
  return config2;
20925
20926
  }).meta({ id: "AppConfig" });
@@ -20961,7 +20962,10 @@ var AppAttestTokenRequestSchema = external_exports.object({
20961
20962
  issuer_token: external_exports.string().min(1).optional(),
20962
20963
  key_id: AppAttestKeyIdSchema,
20963
20964
  assertion: external_exports.string().min(1),
20964
- challenge: ChallengeSchema
20965
+ challenge: ChallengeSchema,
20966
+ app_transaction: external_exports.string().min(1).max(MAX_APP_TRANSACTION_LENGTH).optional().meta({
20967
+ description: "The App Store's signed AppTransaction (its JWS), which names the Apple Account the install belongs to. When present, the assertion signs client data that also carries app_transaction: the unpadded base64url SHA-256 of this string. One that does not verify against Apple's root names no account, and the install is counted on its own."
20968
+ })
20965
20969
  }).meta({ id: "AppAttestTokenRequest" });
20966
20970
  var ApiKeyTokenRequestSchema = external_exports.object({
20967
20971
  issuer_token: external_exports.string().min(1),
@@ -22823,7 +22827,7 @@ var REJECTION_REASONS = [
22823
22827
  /** An App Attest assertion whose counter the install had already used. */
22824
22828
  "blocked_replay"
22825
22829
  ];
22826
- var REJECTION_SCOPES = ["user", "install", "app", "account"];
22830
+ var REJECTION_SCOPES = ["user", "install", "apple_account", "app", "account"];
22827
22831
 
22828
22832
  // ../src/contracts/billing.ts
22829
22833
  var BillingSubscriptionStatusSchema = external_exports.enum([
@@ -23044,7 +23048,10 @@ var GoogleSignInResponseSchema = external_exports.object({
23044
23048
  });
23045
23049
  var AppAttestChallengeResponseSchema = external_exports.object({
23046
23050
  challenge: external_exports.string(),
23047
- expires_in: external_exports.number()
23051
+ expires_in: external_exports.number(),
23052
+ accepts_app_transaction: external_exports.boolean().optional().meta({
23053
+ description: "True when the token exchange accepts app_transaction, the App Store's signed AppTransaction. A client sends one, and signs over its hash, only when this says so: a gateway that predates it would ignore the field and then refuse the assertion."
23054
+ })
23048
23055
  });
23049
23056
  var AppAttestRegisterResponseSchema = external_exports.object({ user_id: external_exports.string() });
23050
23057
  var GatewayTokenResponseSchema = external_exports.object({
@@ -23064,8 +23071,9 @@ var CurrentUserResponseSchema = external_exports.object({
23064
23071
  requests_remaining: external_exports.number().int().nullable().meta({ description: "What is left of requests_per_day. Null when no daily limit is set." }),
23065
23072
  requests_per_minute: external_exports.number().nullable().meta({ description: "The per-minute limit this app sets on each install (App Attest) or user (server). Null means unlimited." }),
23066
23073
  requests_per_day: external_exports.number().nullable().meta({ description: "The per-day limit this app sets on each install (App Attest) or user (server). Null means unlimited." }),
23067
- monthly_cost_usd: external_exports.number().meta({ description: "What has been spent so far in the current UTC calendar month against the budget below: by this install, or by this user when the budget's scope is user." }),
23068
- monthly_budget_usd: external_exports.number().nullable().meta({ description: "The monthly spending budget this app sets on each install or user, per limits.per_user.spending.scope. Null means unlimited." }),
23074
+ monthly_cost_usd: external_exports.number().meta({ description: "What has been spent so far in the current UTC calendar month against the budget below, by whoever budget_scope names." }),
23075
+ monthly_budget_usd: external_exports.number().nullable().meta({ description: "The monthly spending budget this app sets on each Apple Account, install or user, per limits.per_user.spending.scope. Null means unlimited." }),
23076
+ budget_scope: external_exports.enum(BUDGET_SCOPES).meta({ description: "Whose month monthly_cost_usd is: apple_account (every install of this person's Apple Account together), install (this install alone), or user (this signed-in or backend-named user). Usually the app's limits.per_user.spending.scope; install where that is apple_account but this install's client sent no verifiable App Store transaction." }),
23069
23077
  blocked: external_exports.boolean().meta({ description: "Whether this user has been blocked in the console." })
23070
23078
  }).meta({
23071
23079
  description: "The limits the app sets on this user, and where the user stands against them. The account's request allowance is not reported here: it is shared by all apps, and is reported on the rejection that spends it."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxceem/agw",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "type": "module",
5
5
  "description": "Manage App AI Gateway from a terminal or coding agent: providers, iOS and server apps, usage, and self-hosted deployment on Cloudflare",
6
6
  "keywords": [
@@ -26,6 +26,7 @@
26
26
  },
27
27
  "bugs": "https://github.com/maxceem/app-ai-gateway/issues",
28
28
  "upgradeFrom": [
29
+ "0.15.1",
29
30
  "0.15.0",
30
31
  "0.14.0",
31
32
  "0.13.1",