@oxy.so/contracts 5.8.0 → 6.0.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.
- package/dist/cjs/accountAccess.js +6 -5
- package/dist/cjs/accountEmail.js +13 -5
- package/dist/cjs/accountGraph.js +10 -9
- package/dist/cjs/accountName.js +3 -2
- package/dist/cjs/agency.js +91 -34
- package/dist/cjs/agentKeys.js +21 -17
- package/dist/cjs/appAssertions.js +14 -13
- package/dist/cjs/applicationRoles.js +19 -12
- package/dist/cjs/civic.js +10 -9
- package/dist/cjs/client/check.js +61 -53
- package/dist/cjs/consoleOnboarding.js +9 -4
- package/dist/cjs/contentClaims.js +23 -14
- package/dist/cjs/deviceDirectory.js +11 -9
- package/dist/cjs/deviceSession.js +27 -25
- package/dist/cjs/email/messages.js +20 -18
- package/dist/cjs/emailAgentContext.js +11 -9
- package/dist/cjs/externalIdentity.js +15 -11
- package/dist/cjs/federationInstanceFetch.js +12 -7
- package/dist/cjs/identity.js +19 -17
- package/dist/cjs/identityLink.js +6 -4
- package/dist/cjs/identityProof.js +6 -4
- package/dist/cjs/inboxPush.js +5 -4
- package/dist/cjs/index.js +15 -6
- package/dist/cjs/inference/accountBilling.js +35 -33
- package/dist/cjs/inference/aliaModelRelease.js +9 -7
- package/dist/cjs/inference/attribution.js +14 -12
- package/dist/cjs/inference/catalogue.js +35 -29
- package/dist/cjs/inference/economics.js +24 -19
- package/dist/cjs/inference/embeddings.js +9 -7
- package/dist/cjs/inference/entitlement.js +17 -15
- package/dist/cjs/inference/errors.js +15 -8
- package/dist/cjs/inference/identifiers.js +33 -21
- package/dist/cjs/inference/inbox.js +37 -35
- package/dist/cjs/inference/modelDocumentation.js +16 -14
- package/dist/cjs/inference/money.js +5 -4
- package/dist/cjs/inference/priceVersion.js +10 -5
- package/dist/cjs/inference/providerConnection.js +21 -14
- package/dist/cjs/inference/realtime.js +88 -47
- package/dist/cjs/inference/request.js +27 -25
- package/dist/cjs/inference/routingPolicy.js +12 -10
- package/dist/cjs/inference/streamEvents.js +22 -16
- package/dist/cjs/inference/usage.js +32 -15
- package/dist/cjs/keyRecovery.js +8 -6
- package/dist/cjs/keyRotation.js +5 -4
- package/dist/cjs/linkedAccounts.js +22 -18
- package/dist/cjs/moderationReputation.js +29 -27
- package/dist/cjs/notifications.js +25 -9
- package/dist/cjs/numberChecks.js +45 -0
- package/dist/cjs/oauth.js +14 -12
- package/dist/cjs/organizations.js +23 -21
- package/dist/cjs/products/access.js +10 -8
- package/dist/cjs/products/billing.js +10 -8
- package/dist/cjs/products/checkout.js +22 -10
- package/dist/cjs/products/plans.js +15 -10
- package/dist/cjs/protocol.js +6 -5
- package/dist/cjs/recommendations.js +27 -19
- package/dist/cjs/reputation.js +15 -13
- package/dist/cjs/safety.js +43 -27
- package/dist/cjs/serviceToken.js +81 -2
- package/dist/cjs/sessionRevocation.js +8 -6
- package/dist/cjs/signIn.js +42 -24
- package/dist/cjs/stickers.js +19 -15
- package/dist/cjs/stringChecks.js +70 -0
- package/dist/cjs/transparency.js +14 -12
- package/dist/cjs/updates.js +24 -22
- package/dist/cjs/userInvalidation.js +7 -5
- package/dist/cjs/userResponse.js +8 -7
- package/dist/cjs/username.js +7 -6
- package/dist/esm/accountAccess.js +4 -3
- package/dist/esm/accountEmail.js +13 -5
- package/dist/esm/accountGraph.js +8 -7
- package/dist/esm/accountName.js +3 -2
- package/dist/esm/agency.js +90 -33
- package/dist/esm/agentKeys.js +21 -17
- package/dist/esm/appAssertions.js +11 -10
- package/dist/esm/applicationRoles.js +16 -9
- package/dist/esm/civic.js +8 -7
- package/dist/esm/client/check.js +61 -53
- package/dist/esm/consoleOnboarding.js +7 -2
- package/dist/esm/contentClaims.js +23 -14
- package/dist/esm/deviceDirectory.js +11 -9
- package/dist/esm/deviceSession.js +27 -25
- package/dist/esm/email/messages.js +18 -16
- package/dist/esm/emailAgentContext.js +11 -9
- package/dist/esm/externalIdentity.js +15 -11
- package/dist/esm/federationInstanceFetch.js +10 -5
- package/dist/esm/identity.js +17 -15
- package/dist/esm/identityLink.js +6 -4
- package/dist/esm/identityProof.js +6 -4
- package/dist/esm/inboxPush.js +3 -2
- package/dist/esm/index.js +4 -2
- package/dist/esm/inference/accountBilling.js +33 -31
- package/dist/esm/inference/aliaModelRelease.js +7 -5
- package/dist/esm/inference/attribution.js +14 -12
- package/dist/esm/inference/catalogue.js +33 -27
- package/dist/esm/inference/economics.js +22 -17
- package/dist/esm/inference/embeddings.js +9 -7
- package/dist/esm/inference/entitlement.js +15 -13
- package/dist/esm/inference/errors.js +13 -6
- package/dist/esm/inference/identifiers.js +31 -19
- package/dist/esm/inference/inbox.js +37 -35
- package/dist/esm/inference/modelDocumentation.js +14 -12
- package/dist/esm/inference/money.js +3 -2
- package/dist/esm/inference/priceVersion.js +8 -3
- package/dist/esm/inference/providerConnection.js +19 -12
- package/dist/esm/inference/realtime.js +85 -44
- package/dist/esm/inference/request.js +25 -23
- package/dist/esm/inference/routingPolicy.js +9 -7
- package/dist/esm/inference/streamEvents.js +20 -14
- package/dist/esm/inference/usage.js +30 -13
- package/dist/esm/keyRecovery.js +8 -6
- package/dist/esm/keyRotation.js +5 -4
- package/dist/esm/linkedAccounts.js +20 -16
- package/dist/esm/moderationReputation.js +27 -25
- package/dist/esm/notifications.js +23 -7
- package/dist/esm/numberChecks.js +41 -0
- package/dist/esm/oauth.js +14 -12
- package/dist/esm/organizations.js +23 -21
- package/dist/esm/products/access.js +10 -8
- package/dist/esm/products/billing.js +10 -8
- package/dist/esm/products/checkout.js +22 -10
- package/dist/esm/products/plans.js +15 -10
- package/dist/esm/protocol.js +4 -3
- package/dist/esm/recommendations.js +25 -17
- package/dist/esm/reputation.js +13 -11
- package/dist/esm/safety.js +43 -27
- package/dist/esm/serviceToken.js +80 -1
- package/dist/esm/sessionRevocation.js +6 -4
- package/dist/esm/signIn.js +42 -24
- package/dist/esm/stickers.js +17 -13
- package/dist/esm/stringChecks.js +63 -0
- package/dist/esm/transparency.js +14 -12
- package/dist/esm/updates.js +22 -20
- package/dist/esm/userInvalidation.js +4 -2
- package/dist/esm/userResponse.js +4 -3
- package/dist/esm/username.js +3 -2
- package/dist/types/accountAccess.d.ts +29 -70
- package/dist/types/accountEmail.d.ts +2 -14
- package/dist/types/accountGraph.d.ts +179 -171
- package/dist/types/accountName.d.ts +1 -1
- package/dist/types/accountSubject.d.ts +20 -93
- package/dist/types/agency.d.ts +528 -2924
- package/dist/types/agentKeys.d.ts +48 -421
- package/dist/types/appAssertions.d.ts +56 -210
- package/dist/types/applicationRoles.d.ts +30 -276
- package/dist/types/avatarCharacter.d.ts +1 -1
- package/dist/types/civic.d.ts +1 -13
- package/dist/types/client/agentKeys.d.ts +18 -18
- package/dist/types/client/appAssertions.d.ts +3 -3
- package/dist/types/client/check.d.ts +13 -13
- package/dist/types/client/deviceDirectory.d.ts +51 -51
- package/dist/types/client/deviceSession.d.ts +14 -14
- package/dist/types/client/organizations.d.ts +25 -25
- package/dist/types/client/products.d.ts +33 -33
- package/dist/types/client/recommendations.d.ts +2 -2
- package/dist/types/client/safety.d.ts +45 -45
- package/dist/types/client/sessionStatus.d.ts +4 -4
- package/dist/types/client/signIn.d.ts +1 -1
- package/dist/types/commonsSignIn.d.ts +4 -1
- package/dist/types/consoleOnboarding.d.ts +24 -44
- package/dist/types/contentClaims.d.ts +24 -180
- package/dist/types/deviceDirectory.d.ts +109 -1040
- package/dist/types/deviceSession.d.ts +36 -298
- package/dist/types/email/messages.d.ts +212 -1793
- package/dist/types/emailAgentContext.d.ts +10 -194
- package/dist/types/externalIdentity.d.ts +121 -615
- package/dist/types/federationInstanceFetch.d.ts +3 -32
- package/dist/types/identity.d.ts +15 -92
- package/dist/types/identityLink.d.ts +6 -84
- package/dist/types/identityProof.d.ts +5 -17
- package/dist/types/inboxPush.d.ts +1 -9
- package/dist/types/index.d.ts +5 -3
- package/dist/types/inference/accountBilling.d.ts +151 -488
- package/dist/types/inference/aliaModelRelease.d.ts +42 -439
- package/dist/types/inference/attribution.d.ts +75 -104
- package/dist/types/inference/catalogue.d.ts +417 -1599
- package/dist/types/inference/economics.d.ts +69 -276
- package/dist/types/inference/embeddings.d.ts +110 -406
- package/dist/types/inference/entitlement.d.ts +80 -335
- package/dist/types/inference/errors.d.ts +90 -102
- package/dist/types/inference/identifiers.d.ts +12 -4
- package/dist/types/inference/inbox.d.ts +105 -420
- package/dist/types/inference/modelDocumentation.d.ts +201 -1390
- package/dist/types/inference/money.d.ts +65 -32
- package/dist/types/inference/priceVersion.d.ts +53 -120
- package/dist/types/inference/providerConnection.d.ts +253 -710
- package/dist/types/inference/realtime.d.ts +954 -6825
- package/dist/types/inference/request.d.ts +300 -2572
- package/dist/types/inference/routingPolicy.d.ts +95 -503
- package/dist/types/inference/streamEvents.d.ts +253 -721
- package/dist/types/inference/usage.d.ts +317 -950
- package/dist/types/keyRecovery.d.ts +3 -51
- package/dist/types/keyRotation.d.ts +3 -38
- package/dist/types/linkedAccounts.d.ts +50 -236
- package/dist/types/moderationReputation.d.ts +81 -14
- package/dist/types/notifications.d.ts +19 -51
- package/dist/types/numberChecks.d.ts +9 -0
- package/dist/types/oauth.d.ts +101 -809
- package/dist/types/organizations.d.ts +268 -921
- package/dist/types/oxyRecordTypes.d.ts +11 -1
- package/dist/types/products/access.d.ts +125 -775
- package/dist/types/products/billing.d.ts +67 -503
- package/dist/types/products/checkout.d.ts +16 -69
- package/dist/types/products/plans.d.ts +33 -366
- package/dist/types/recommendations.d.ts +76 -389
- package/dist/types/reputation.d.ts +37 -5
- package/dist/types/safety.d.ts +408 -2048
- package/dist/types/serviceToken.d.ts +247 -7
- package/dist/types/sessionRevocation.d.ts +2 -17
- package/dist/types/sessionStatus.d.ts +27 -115
- package/dist/types/signIn.d.ts +53 -553
- package/dist/types/stickers.d.ts +67 -819
- package/dist/types/stringChecks.d.ts +16 -0
- package/dist/types/transparency.d.ts +14 -302
- package/dist/types/updates.d.ts +60 -316
- package/dist/types/userInvalidation.d.ts +4 -13
- package/dist/types/userResponse.d.ts +302 -2400
- package/dist/types/username.d.ts +3 -3
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { utf16MinLength } from './stringChecks.js';
|
|
1
2
|
/**
|
|
2
3
|
* Wire contract for `GET /internal/accounts/:accountId/access/:userId`: Oxy
|
|
3
4
|
* answers a trusted first-party service's question "may this person act FOR
|
|
@@ -49,15 +50,15 @@ export const accountAccessSourceSchema = z.enum(ACCOUNT_ACCESS_SOURCES);
|
|
|
49
50
|
* revokes), never on `role`.
|
|
50
51
|
*/
|
|
51
52
|
export const accountAccessGrantSchema = z.object({
|
|
52
|
-
role: z.string().
|
|
53
|
-
permissions: z.array(z.string().
|
|
53
|
+
role: z.string().check(utf16MinLength(1)),
|
|
54
|
+
permissions: z.array(z.string().check(utf16MinLength(1))),
|
|
54
55
|
/** Only an active membership grants access, so this is the one value. */
|
|
55
56
|
status: z.literal('active'),
|
|
56
57
|
source: accountAccessSourceSchema,
|
|
57
58
|
});
|
|
58
59
|
export const accountAccessVerdictSchema = z
|
|
59
60
|
.object({
|
|
60
|
-
accountId: z.string().
|
|
61
|
+
accountId: z.string().check(utf16MinLength(1)),
|
|
61
62
|
/** `null` when no such account exists. */
|
|
62
63
|
kind: accountKindSchema.nullable(),
|
|
63
64
|
/** `null` means: this person may not act for this account. */
|
package/dist/esm/accountEmail.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integerCheck } from './numberChecks.js';
|
|
2
|
+
import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
|
|
1
3
|
/**
|
|
2
4
|
* Email codes and tickets (ADR 0030).
|
|
3
5
|
*
|
|
@@ -18,7 +20,13 @@ import { z } from 'zod';
|
|
|
18
20
|
import { EMAIL_CODE_LENGTH } from './client/accountEmail.js';
|
|
19
21
|
export { EMAIL_VERIFICATION_PURPOSES, EMAIL_CODE_LENGTH, EMAIL_CODE_TTL_MS, EMAIL_CODE_MAX_ATTEMPTS, EMAIL_TICKET_TTL_MS, EMAIL_VERIFICATION_ERROR_CODES, } from './client/accountEmail.js';
|
|
20
22
|
/** An email address as the API stores it: trimmed and lowercase. */
|
|
21
|
-
export const emailAddressSchema = z
|
|
23
|
+
export const emailAddressSchema = z
|
|
24
|
+
.string()
|
|
25
|
+
.trim()
|
|
26
|
+
.toLowerCase()
|
|
27
|
+
.check(utf16MinLength(3))
|
|
28
|
+
.check(utf16MaxLength(254))
|
|
29
|
+
.email();
|
|
22
30
|
/** An opaque one-use ticket (32 random bytes, base64url). */
|
|
23
31
|
export const emailTicketSchema = z
|
|
24
32
|
.string()
|
|
@@ -29,13 +37,13 @@ export const emailVerificationStartRequestSchema = z
|
|
|
29
37
|
.object({ purpose: z.literal('signup'), email: emailAddressSchema })
|
|
30
38
|
.strict();
|
|
31
39
|
export const emailVerificationStartResponseSchema = z.object({
|
|
32
|
-
verificationId: z.string().
|
|
33
|
-
expiresAt: z.number().
|
|
40
|
+
verificationId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
41
|
+
expiresAt: z.number().check(integerCheck()).positive(),
|
|
34
42
|
});
|
|
35
43
|
/** `POST /auth/email/verify/confirm` */
|
|
36
44
|
export const emailVerificationConfirmRequestSchema = z
|
|
37
45
|
.object({
|
|
38
|
-
verificationId: z.string().trim().
|
|
46
|
+
verificationId: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
39
47
|
code: z
|
|
40
48
|
.string()
|
|
41
49
|
.trim()
|
|
@@ -44,5 +52,5 @@ export const emailVerificationConfirmRequestSchema = z
|
|
|
44
52
|
.strict();
|
|
45
53
|
export const emailVerificationConfirmResponseSchema = z.object({
|
|
46
54
|
ticket: emailTicketSchema,
|
|
47
|
-
expiresAt: z.number().
|
|
55
|
+
expiresAt: z.number().check(integerCheck()).positive(),
|
|
48
56
|
});
|
package/dist/esm/accountGraph.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
|
|
1
2
|
/**
|
|
2
3
|
* Account graph wire contracts — the account-kind vocabulary, the account
|
|
3
4
|
* category taxonomy, and the create-account input.
|
|
@@ -69,9 +70,9 @@ export const accountCategoriesSchema = z
|
|
|
69
70
|
*/
|
|
70
71
|
export const accountNameSchema = z
|
|
71
72
|
.object({
|
|
72
|
-
first: z.string().trim().
|
|
73
|
-
last: z.string().trim().
|
|
74
|
-
displayName: z.string().trim().
|
|
73
|
+
first: z.string().trim().check(utf16MaxLength(100)).optional(),
|
|
74
|
+
last: z.string().trim().check(utf16MaxLength(100)).optional(),
|
|
75
|
+
displayName: z.string().trim().check(utf16MaxLength(ACCOUNT_TITLE_MAX_LENGTH)).optional(),
|
|
75
76
|
})
|
|
76
77
|
.optional();
|
|
77
78
|
/**
|
|
@@ -87,7 +88,7 @@ export const accountNameSchema = z
|
|
|
87
88
|
*/
|
|
88
89
|
export const createAccountRequestSchema = z
|
|
89
90
|
.object({
|
|
90
|
-
parentAccountId: z.string().trim().
|
|
91
|
+
parentAccountId: z.string().trim().check(utf16MinLength(1)).optional(),
|
|
91
92
|
kind: childAccountKindSchema,
|
|
92
93
|
/**
|
|
93
94
|
* The SAME policy a person's handle is held to. `users.username` is one unique
|
|
@@ -102,9 +103,9 @@ export const createAccountRequestSchema = z
|
|
|
102
103
|
*/
|
|
103
104
|
username: usernameSchema,
|
|
104
105
|
name: accountNameSchema,
|
|
105
|
-
bio: z.string().trim().
|
|
106
|
+
bio: z.string().trim().check(utf16MaxLength(500)).optional(),
|
|
106
107
|
avatar: z.string().optional(),
|
|
107
|
-
description: z.string().trim().
|
|
108
|
+
description: z.string().trim().check(utf16MaxLength(1000)).optional(),
|
|
108
109
|
/**
|
|
109
110
|
* A named color preset KEY (`"blue"`, `"mint"`, …), never a hex value.
|
|
110
111
|
*
|
|
@@ -121,7 +122,7 @@ export const createAccountRequestSchema = z
|
|
|
121
122
|
* would drift apart silently. What this shape does is keep an over-long or
|
|
122
123
|
* non-string value from reaching the service at all.
|
|
123
124
|
*/
|
|
124
|
-
color: z.string().trim().
|
|
125
|
+
color: z.string().trim().check(utf16MaxLength(32)).optional(),
|
|
125
126
|
/** Ordered, PRIMARY FIRST — see rule 2 above {@link ACCOUNT_CATEGORY_IDS}. */
|
|
126
127
|
accountCategories: accountCategoriesSchema.optional(),
|
|
127
128
|
organizationType: z.enum(ORGANIZATION_TYPES).optional(),
|
package/dist/esm/accountName.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
// The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
|
|
3
4
|
// it is re-exported here so the root entry carries the whole policy.
|
|
@@ -7,6 +8,6 @@ export { ACCOUNT_NAME_POLICY_BY_KIND, ACCOUNT_TITLE_DISALLOWED_SOURCE, ACCOUNT_T
|
|
|
7
8
|
export const accountTitleSchema = z
|
|
8
9
|
.string()
|
|
9
10
|
.trim()
|
|
10
|
-
.
|
|
11
|
-
.
|
|
11
|
+
.check(utf16MinLength(1))
|
|
12
|
+
.check(utf16MaxLength(ACCOUNT_TITLE_MAX_LENGTH))
|
|
12
13
|
.refine(isPlainTextTitle, 'Name must be plain text');
|
package/dist/esm/agency.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { integerCheck } from './numberChecks.js';
|
|
2
|
+
import { isoDateTime, urlCheck, utf16MaxLength, utf16MinLength } from './stringChecks.js';
|
|
1
3
|
import { z } from 'zod';
|
|
2
4
|
import { catalogInvocationPathParameters, findOverlappingCatalogInvocations, } from './capabilityInvocation.js';
|
|
3
|
-
const nonEmptyStringSchema = z.string().trim().
|
|
4
|
-
const identifierSchema = z.string().trim().
|
|
5
|
+
const nonEmptyStringSchema = z.string().trim().check(utf16MinLength(1));
|
|
6
|
+
const identifierSchema = z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(255));
|
|
5
7
|
const limitKeySchema = z
|
|
6
8
|
.string()
|
|
7
9
|
.regex(/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/, 'limit keys must be dot-separated input property names')
|
|
8
|
-
.
|
|
10
|
+
.check(utf16MaxLength(255));
|
|
9
11
|
const auditCodeSchema = z.string().regex(/^[A-Za-z0-9_.:-]{1,128}$/);
|
|
10
12
|
const sha256HexSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
11
13
|
const invocationPathSchema = z
|
|
@@ -57,7 +59,7 @@ export const foregroundExecutionAuthorizationInputSchema = z
|
|
|
57
59
|
.strict(),
|
|
58
60
|
runId: identifierSchema,
|
|
59
61
|
stepId: identifierSchema.optional(),
|
|
60
|
-
expiresAt: z.string().
|
|
62
|
+
expiresAt: z.string().check(isoDateTime()),
|
|
61
63
|
})
|
|
62
64
|
.strict();
|
|
63
65
|
export const resourceRefSchema = z
|
|
@@ -68,6 +70,50 @@ export const resourceRefSchema = z
|
|
|
68
70
|
resourceId: identifierSchema,
|
|
69
71
|
})
|
|
70
72
|
.strict();
|
|
73
|
+
export const firstPartyTaskInputSchema = z
|
|
74
|
+
.object({
|
|
75
|
+
origin: z
|
|
76
|
+
.object({ kind: z.enum(['request', 'goal', 'automation']), id: identifierSchema })
|
|
77
|
+
.strict(),
|
|
78
|
+
actor: executionActorRefSchema,
|
|
79
|
+
effectiveAccountId: identifierSchema,
|
|
80
|
+
expiresAt: z.string().check(isoDateTime()),
|
|
81
|
+
})
|
|
82
|
+
.strict();
|
|
83
|
+
/** Oxy-owned tools use the authenticated requester's task, never per-app grants. */
|
|
84
|
+
export const firstPartyExecutionAuthorizationInputSchema = z
|
|
85
|
+
.object({
|
|
86
|
+
authority: z.literal('first_party'),
|
|
87
|
+
kind: z.enum(['direct_request', 'automation']).default('direct_request'),
|
|
88
|
+
actor: executionActorRefSchema,
|
|
89
|
+
resource: resourceRefSchema,
|
|
90
|
+
tool: identifierSchema,
|
|
91
|
+
expectedCatalog: foregroundExecutionAuthorizationInputSchema.shape.expectedCatalog,
|
|
92
|
+
runId: identifierSchema.optional(),
|
|
93
|
+
stepId: identifierSchema.optional(),
|
|
94
|
+
automationId: identifierSchema.optional(),
|
|
95
|
+
limits: z
|
|
96
|
+
.array(z
|
|
97
|
+
.object({
|
|
98
|
+
tool: identifierSchema,
|
|
99
|
+
key: limitKeySchema,
|
|
100
|
+
value: z.union([z.number().finite(), z.boolean()]),
|
|
101
|
+
})
|
|
102
|
+
.strict())
|
|
103
|
+
.default([]),
|
|
104
|
+
expiresAt: z.string().check(isoDateTime()),
|
|
105
|
+
})
|
|
106
|
+
.strict()
|
|
107
|
+
.superRefine((input, context) => {
|
|
108
|
+
if (input.kind === 'direct_request'
|
|
109
|
+
? !input.runId || input.automationId !== undefined
|
|
110
|
+
: !input.automationId || input.runId !== undefined || input.stepId !== undefined) {
|
|
111
|
+
context.addIssue({
|
|
112
|
+
code: z.ZodIssueCode.custom,
|
|
113
|
+
message: 'Bind either a direct run or an automation identity.',
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
71
117
|
export const toolGrantOverrideSchema = z
|
|
72
118
|
.object({
|
|
73
119
|
tool: identifierSchema,
|
|
@@ -115,9 +161,9 @@ export const capabilityCoordinatorSchema = z
|
|
|
115
161
|
/** Opt-in catalogue pin; legacy issuance omits expectedCatalog and its claim. */
|
|
116
162
|
export const capabilityTicketRequestSchema = z
|
|
117
163
|
.object({
|
|
118
|
-
executionAuthorizationId: z.string().
|
|
119
|
-
runId: z.string().
|
|
120
|
-
stepId: z.string().
|
|
164
|
+
executionAuthorizationId: z.string().check(utf16MinLength(1)),
|
|
165
|
+
runId: z.string().check(utf16MinLength(1)).optional(),
|
|
166
|
+
stepId: z.string().check(utf16MinLength(1)).optional(),
|
|
121
167
|
expectedCatalog: capabilityCatalogBindingSchema.optional(),
|
|
122
168
|
})
|
|
123
169
|
.strict();
|
|
@@ -134,10 +180,10 @@ export const delegationGrantSchema = z
|
|
|
134
180
|
limits: z.array(grantLimitSchema).default([]),
|
|
135
181
|
maximumAutonomy: autonomyLevelSchema,
|
|
136
182
|
canRedelegate: z.boolean().default(false),
|
|
137
|
-
expiresAt: z.string().
|
|
138
|
-
revokedAt: z.string().
|
|
139
|
-
createdAt: z.string().
|
|
140
|
-
updatedAt: z.string().
|
|
183
|
+
expiresAt: z.string().check(isoDateTime()).nullable(),
|
|
184
|
+
revokedAt: z.string().check(isoDateTime()).nullable().default(null),
|
|
185
|
+
createdAt: z.string().check(isoDateTime()),
|
|
186
|
+
updatedAt: z.string().check(isoDateTime()),
|
|
141
187
|
})
|
|
142
188
|
.strict();
|
|
143
189
|
/**
|
|
@@ -163,10 +209,10 @@ export const agentRequesterCeilingSchema = agentRequesterCeilingWriteSchema
|
|
|
163
209
|
agentAccountId: identifierSchema,
|
|
164
210
|
appId: identifierSchema,
|
|
165
211
|
catalog: capabilityCatalogBindingSchema,
|
|
166
|
-
version: z.number().
|
|
167
|
-
revokedAt: z.string().
|
|
168
|
-
createdAt: z.string().
|
|
169
|
-
updatedAt: z.string().
|
|
212
|
+
version: z.number().check(integerCheck()).positive(),
|
|
213
|
+
revokedAt: z.string().check(isoDateTime()).nullable(),
|
|
214
|
+
createdAt: z.string().check(isoDateTime()),
|
|
215
|
+
updatedAt: z.string().check(isoDateTime()),
|
|
170
216
|
})
|
|
171
217
|
.strict();
|
|
172
218
|
/**
|
|
@@ -186,8 +232,8 @@ export const applicationAgentSchema = applicationAgentWriteSchema
|
|
|
186
232
|
applicationId: identifierSchema,
|
|
187
233
|
agentAccountId: identifierSchema,
|
|
188
234
|
createdByUserId: identifierSchema.nullable(),
|
|
189
|
-
createdAt: z.string().
|
|
190
|
-
updatedAt: z.string().
|
|
235
|
+
createdAt: z.string().check(isoDateTime()),
|
|
236
|
+
updatedAt: z.string().check(isoDateTime()),
|
|
191
237
|
})
|
|
192
238
|
.strict();
|
|
193
239
|
/**
|
|
@@ -236,14 +282,14 @@ export const automationDefinitionSchema = z
|
|
|
236
282
|
objective: nonEmptyStringSchema,
|
|
237
283
|
trigger: automationTriggerSchema,
|
|
238
284
|
actorSelection: automationActorSelectionSchema,
|
|
239
|
-
inputs: z.record(z.unknown()),
|
|
285
|
+
inputs: z.record(z.string(), z.unknown()),
|
|
240
286
|
resources: z.array(resourceRefSchema),
|
|
241
287
|
dataFlow: automationDataFlowSchema,
|
|
242
288
|
maximumAutonomy: autonomyLevelSchema,
|
|
243
289
|
limits: z.array(grantLimitSchema).default([]),
|
|
244
290
|
enabled: z.boolean(),
|
|
245
|
-
createdAt: z.string().
|
|
246
|
-
updatedAt: z.string().
|
|
291
|
+
createdAt: z.string().check(isoDateTime()),
|
|
292
|
+
updatedAt: z.string().check(isoDateTime()),
|
|
247
293
|
})
|
|
248
294
|
.strict();
|
|
249
295
|
export const capabilityTicketClaimsSchema = z
|
|
@@ -252,12 +298,14 @@ export const capabilityTicketClaimsSchema = z
|
|
|
252
298
|
aud: identifierSchema,
|
|
253
299
|
sub: identifierSchema,
|
|
254
300
|
jti: identifierSchema,
|
|
255
|
-
iat: z.number().
|
|
256
|
-
exp: z.number().
|
|
301
|
+
iat: z.number().check(integerCheck()).nonnegative(),
|
|
302
|
+
exp: z.number().check(integerCheck()).positive(),
|
|
257
303
|
runId: identifierSchema,
|
|
258
304
|
stepId: identifierSchema.optional(),
|
|
259
305
|
automationId: identifierSchema.optional(),
|
|
260
306
|
executionAuthorization: executionAuthorizationRefSchema,
|
|
307
|
+
authority: z.enum(['first_party', 'external']).optional(),
|
|
308
|
+
taskId: identifierSchema.optional(),
|
|
261
309
|
coordinator: capabilityCoordinatorSchema,
|
|
262
310
|
/** Signed only for callers that explicitly requested a pinned catalogue. */
|
|
263
311
|
catalog: capabilityCatalogBindingSchema.optional(),
|
|
@@ -291,6 +339,7 @@ export const capabilityTicketClaimsSchema = z
|
|
|
291
339
|
});
|
|
292
340
|
}
|
|
293
341
|
if (claims.actor.type === 'requester' &&
|
|
342
|
+
claims.authority !== 'first_party' &&
|
|
294
343
|
(claims.actor.accountId !== claims.requesterAccountId ||
|
|
295
344
|
claims.executionAuthorization.kind !== 'direct_request' ||
|
|
296
345
|
claims.autonomy !== 'read_only' ||
|
|
@@ -302,6 +351,14 @@ export const capabilityTicketClaimsSchema = z
|
|
|
302
351
|
message: 'requester actors require their exact principal and direct read-only authority without standing grants',
|
|
303
352
|
});
|
|
304
353
|
}
|
|
354
|
+
if (claims.authority === 'first_party' &&
|
|
355
|
+
(claims.grantId !== undefined || claims.ceilingId !== undefined)) {
|
|
356
|
+
context.addIssue({
|
|
357
|
+
code: z.ZodIssueCode.custom,
|
|
358
|
+
message: 'Own tool tasks cannot carry external grants or ceilings',
|
|
359
|
+
path: ['authority'],
|
|
360
|
+
});
|
|
361
|
+
}
|
|
305
362
|
if (claims.ceilingId !== undefined) {
|
|
306
363
|
if (claims.grantId !== undefined) {
|
|
307
364
|
context.addIssue({
|
|
@@ -363,7 +420,7 @@ export const invocationPrincipalSchema = z.discriminatedUnion('kind', [
|
|
|
363
420
|
originAccountId: identifierSchema,
|
|
364
421
|
activeAccountId: identifierSchema,
|
|
365
422
|
scopes: z.array(identifierSchema),
|
|
366
|
-
resource: z.string().
|
|
423
|
+
resource: z.string().check(urlCheck()),
|
|
367
424
|
})
|
|
368
425
|
.strict(),
|
|
369
426
|
z
|
|
@@ -393,7 +450,7 @@ export const auditResultSchema = z
|
|
|
393
450
|
export const auditEventSchema = z
|
|
394
451
|
.object({
|
|
395
452
|
eventId: identifierSchema,
|
|
396
|
-
occurredAt: z.string().
|
|
453
|
+
occurredAt: z.string().check(isoDateTime()),
|
|
397
454
|
requesterAccountId: identifierSchema,
|
|
398
455
|
coordinator: capabilityCoordinatorSchema,
|
|
399
456
|
executor: executionActorRefSchema,
|
|
@@ -440,8 +497,8 @@ export const catalogToolSchema = z
|
|
|
440
497
|
name: identifierSchema,
|
|
441
498
|
version: identifierSchema,
|
|
442
499
|
description: nonEmptyStringSchema,
|
|
443
|
-
inputSchema: z.record(z.unknown()),
|
|
444
|
-
outputSchema: z.record(z.unknown()).optional(),
|
|
500
|
+
inputSchema: z.record(z.string(), z.unknown()),
|
|
501
|
+
outputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
445
502
|
capabilityPackage: capabilityPackageSchema,
|
|
446
503
|
requiredCapabilities: z.array(identifierSchema).min(1),
|
|
447
504
|
resourceTypes: z.array(identifierSchema).min(1),
|
|
@@ -618,7 +675,7 @@ export const catalogEventSchema = z
|
|
|
618
675
|
type: identifierSchema,
|
|
619
676
|
version: identifierSchema,
|
|
620
677
|
description: nonEmptyStringSchema,
|
|
621
|
-
dataSchema: z.record(z.unknown()),
|
|
678
|
+
dataSchema: z.record(z.string(), z.unknown()),
|
|
622
679
|
resourceTypes: z.array(identifierSchema).min(1),
|
|
623
680
|
})
|
|
624
681
|
.strict();
|
|
@@ -632,7 +689,7 @@ export const catalogFeatureSchema = z
|
|
|
632
689
|
key: z
|
|
633
690
|
.string()
|
|
634
691
|
.regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)*$/, 'feature keys are dot-separated slugs')
|
|
635
|
-
.
|
|
692
|
+
.check(utf16MaxLength(128)),
|
|
636
693
|
description: nonEmptyStringSchema,
|
|
637
694
|
checkTool: identifierSchema,
|
|
638
695
|
consumeTool: identifierSchema.optional(),
|
|
@@ -649,7 +706,7 @@ export const appCapabilityCatalogSchema = z
|
|
|
649
706
|
/** HTTPS origin that serves the catalog's internal invocation paths. */
|
|
650
707
|
internalBaseUrl: z
|
|
651
708
|
.string()
|
|
652
|
-
.
|
|
709
|
+
.check(urlCheck())
|
|
653
710
|
.superRefine((value, context) => {
|
|
654
711
|
const url = new URL(value);
|
|
655
712
|
const localDevelopment = url.hostname === 'localhost' || url.hostname === '127.0.0.1';
|
|
@@ -673,7 +730,7 @@ export const appCapabilityCatalogSchema = z
|
|
|
673
730
|
.object({
|
|
674
731
|
resource: z
|
|
675
732
|
.string()
|
|
676
|
-
.
|
|
733
|
+
.check(urlCheck())
|
|
677
734
|
.superRefine((value, context) => {
|
|
678
735
|
const url = new URL(value);
|
|
679
736
|
const localDevelopment = url.hostname === 'localhost' ||
|
|
@@ -783,7 +840,7 @@ export const catalogRegistrationSchema = z
|
|
|
783
840
|
catalog: appCapabilityCatalogSchema,
|
|
784
841
|
digest: z.string().regex(/^[a-f0-9]{64}$/),
|
|
785
842
|
signature: nonEmptyStringSchema,
|
|
786
|
-
deployedAt: z.string().
|
|
843
|
+
deployedAt: z.string().check(isoDateTime()),
|
|
787
844
|
})
|
|
788
845
|
.strict();
|
|
789
846
|
export const normalizedAppEventSchema = z
|
|
@@ -793,8 +850,8 @@ export const normalizedAppEventSchema = z
|
|
|
793
850
|
accountId: identifierSchema,
|
|
794
851
|
resource: resourceRefSchema,
|
|
795
852
|
type: identifierSchema,
|
|
796
|
-
occurredAt: z.string().
|
|
797
|
-
data: z.record(z.unknown()),
|
|
853
|
+
occurredAt: z.string().check(isoDateTime()),
|
|
854
|
+
data: z.record(z.string(), z.unknown()),
|
|
798
855
|
})
|
|
799
856
|
.strict();
|
|
800
857
|
/** The actor types that may execute `tool`: the one reading of an absent `actors`. */
|
package/dist/esm/agentKeys.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integerCheck } from './numberChecks.js';
|
|
2
|
+
import { isoDateTime, utf16MaxLength, utf16MinLength } from './stringChecks.js';
|
|
1
3
|
/** Autonomous runtime proof. No private key crosses this contract. */
|
|
2
4
|
import { z } from 'zod';
|
|
3
5
|
import { reauthProofSchema } from './signIn.js';
|
|
@@ -11,13 +13,13 @@ export const agentProofClaimsSchema = z
|
|
|
11
13
|
version: z.literal(1),
|
|
12
14
|
audience: z.literal(AGENT_PROOF_AUDIENCE),
|
|
13
15
|
action: z.enum(AGENT_PROOF_ACTIONS),
|
|
14
|
-
accountId: z.string().
|
|
15
|
-
actorId: z.string().
|
|
16
|
+
accountId: z.string().check(utf16MinLength(1)),
|
|
17
|
+
actorId: z.string().check(utf16MinLength(1)),
|
|
16
18
|
authMethodId: z.string().nullable(),
|
|
17
|
-
publicKey: z.string().
|
|
19
|
+
publicKey: z.string().check(utf16MinLength(1)),
|
|
18
20
|
payloadDigest: z.string().regex(/^[0-9a-f]{64}$/),
|
|
19
21
|
challenge: z.string().regex(/^[0-9a-f]{64}$/),
|
|
20
|
-
expiresAt: z.number().
|
|
22
|
+
expiresAt: z.number().check(integerCheck()).positive(),
|
|
21
23
|
})
|
|
22
24
|
.strict();
|
|
23
25
|
/** Different proof roles cannot substitute for one another on the same operation. */
|
|
@@ -35,19 +37,19 @@ export const agentSignatureSchema = z
|
|
|
35
37
|
signature: z
|
|
36
38
|
.string()
|
|
37
39
|
.regex(/^[0-9a-f]+$/i)
|
|
38
|
-
.
|
|
39
|
-
timestamp: z.number().
|
|
40
|
+
.check(utf16MaxLength(160)),
|
|
41
|
+
timestamp: z.number().check(integerCheck()).positive(),
|
|
40
42
|
})
|
|
41
43
|
.strict();
|
|
42
44
|
export const agentChallengeRequestSchema = z
|
|
43
|
-
.object({ publicKey: z.string().trim().
|
|
45
|
+
.object({ publicKey: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(130)) })
|
|
44
46
|
.strict();
|
|
45
47
|
export const agentVerifyRequestSchema = agentSignatureSchema
|
|
46
|
-
.extend({ publicKey: z.string().trim().
|
|
48
|
+
.extend({ publicKey: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(130)) })
|
|
47
49
|
.strict();
|
|
48
50
|
const newKey = {
|
|
49
|
-
publicKey: z.string().trim().
|
|
50
|
-
label: z.string().trim().
|
|
51
|
+
publicKey: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(130)),
|
|
52
|
+
label: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(120)),
|
|
51
53
|
};
|
|
52
54
|
export const agentKeyOperationSchema = z.discriminatedUnion('operation', [
|
|
53
55
|
z.object({ operation: z.literal('enroll'), ...newKey }).strict(),
|
|
@@ -55,21 +57,23 @@ export const agentKeyOperationSchema = z.discriminatedUnion('operation', [
|
|
|
55
57
|
z
|
|
56
58
|
.object({ operation: z.literal('rotate'), ...newKey, retireCurrent: z.boolean().optional() })
|
|
57
59
|
.strict(),
|
|
58
|
-
z
|
|
60
|
+
z
|
|
61
|
+
.object({ operation: z.literal('revoke'), methodId: z.string().check(utf16MinLength(1)) })
|
|
62
|
+
.strict(),
|
|
59
63
|
]);
|
|
60
64
|
export const agentKeyOperationProofSchema = z
|
|
61
65
|
.object({
|
|
62
66
|
challenge: z.string().regex(/^[0-9a-f]{64}$/),
|
|
63
|
-
timestamp: z.number().
|
|
67
|
+
timestamp: z.number().check(integerCheck()).positive(),
|
|
64
68
|
keySignature: z
|
|
65
69
|
.string()
|
|
66
70
|
.regex(/^[0-9a-f]+$/i)
|
|
67
|
-
.
|
|
71
|
+
.check(utf16MaxLength(160))
|
|
68
72
|
.optional(),
|
|
69
73
|
governorSignature: z
|
|
70
74
|
.string()
|
|
71
75
|
.regex(/^[0-9a-f]+$/i)
|
|
72
|
-
.
|
|
76
|
+
.check(utf16MaxLength(160))
|
|
73
77
|
.optional(),
|
|
74
78
|
reauth: reauthProofSchema.optional(),
|
|
75
79
|
})
|
|
@@ -102,9 +106,9 @@ export const agentKeyListResponseSchema = z
|
|
|
102
106
|
label: z.string(),
|
|
103
107
|
enrolledByUserId: z.string().nullable(),
|
|
104
108
|
enrollmentMethod: z.enum(['governor', 'rotation', 'recovery']),
|
|
105
|
-
linkedAt: z.string().
|
|
106
|
-
lastUsedAt: z.string().
|
|
107
|
-
revokedAt: z.string().
|
|
109
|
+
linkedAt: z.string().check(isoDateTime()),
|
|
110
|
+
lastUsedAt: z.string().check(isoDateTime()).nullable(),
|
|
111
|
+
revokedAt: z.string().check(isoDateTime()).nullable(),
|
|
108
112
|
})
|
|
109
113
|
.strict()),
|
|
110
114
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isoDateTime, utf16MaxLength, utf16MinLength } from './stringChecks.js';
|
|
1
2
|
/**
|
|
2
3
|
* App assertions (ADR 0045): how an Oxy app proves which app it is.
|
|
3
4
|
*
|
|
@@ -25,12 +26,12 @@
|
|
|
25
26
|
import { z } from 'zod';
|
|
26
27
|
import { APP_ASSERTION_CHALLENGE_PURPOSES, APP_ASSERTION_ERROR_CODES, APP_ASSERTION_PLATFORMS, OXY_APP_ASSERTION_AUDIENCE, OXY_APP_ASSERTION_HEADER, OXY_APP_ASSERTION_TTL_SECONDS, OXY_APP_ASSERTION_TYPE, } from './client/appAssertions.js';
|
|
27
28
|
export { APP_ASSERTION_CHALLENGE_PURPOSES, APP_ASSERTION_ERROR_CODES, APP_ASSERTION_PLATFORMS, OXY_APP_ASSERTION_AUDIENCE, OXY_APP_ASSERTION_HEADER, OXY_APP_ASSERTION_TTL_SECONDS, OXY_APP_ASSERTION_TYPE, };
|
|
28
|
-
const applicationIdSchema = z.string().trim().
|
|
29
|
+
const applicationIdSchema = z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(255));
|
|
29
30
|
const base64Url32Schema = z.string().regex(/^[A-Za-z0-9_-]{43}$/);
|
|
30
31
|
const base64Schema = (max) => z
|
|
31
32
|
.string()
|
|
32
|
-
.
|
|
33
|
-
.
|
|
33
|
+
.check(utf16MinLength(4))
|
|
34
|
+
.check(utf16MaxLength(max))
|
|
34
35
|
.regex(/^[A-Za-z0-9+/]+={0,2}$/);
|
|
35
36
|
export const appAssertionPlatformSchema = z.enum(APP_ASSERTION_PLATFORMS);
|
|
36
37
|
export const appAssertionErrorCodeSchema = z.enum(APP_ASSERTION_ERROR_CODES);
|
|
@@ -50,12 +51,12 @@ export function isExactHttpsOrigin(value) {
|
|
|
50
51
|
/** An exact `https://` origin, in the form a browser sends in `Origin` (`https://mention.earth`). */
|
|
51
52
|
export const applicationWebOriginSchema = z
|
|
52
53
|
.string()
|
|
53
|
-
.
|
|
54
|
+
.check(utf16MaxLength(255))
|
|
54
55
|
.refine(isExactHttpsOrigin, 'Must be an exact https origin, as a browser sends it');
|
|
55
56
|
/** A Java-style Android application id, at least two segments. */
|
|
56
57
|
export const androidPackageNameSchema = z
|
|
57
58
|
.string()
|
|
58
|
-
.
|
|
59
|
+
.check(utf16MaxLength(255))
|
|
59
60
|
.regex(/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)+$/, 'Must be an Android package name');
|
|
60
61
|
/** A signing certificate's SHA-256, 64 lowercase hex characters (keytool's digest without colons). */
|
|
61
62
|
export const signingCertSha256Schema = z
|
|
@@ -66,7 +67,7 @@ export const appleTeamIdSchema = z.string().regex(/^[A-Z0-9]{10}$/, 'Must be an
|
|
|
66
67
|
/** An Apple bundle id. */
|
|
67
68
|
export const appleBundleIdSchema = z
|
|
68
69
|
.string()
|
|
69
|
-
.
|
|
70
|
+
.check(utf16MaxLength(255))
|
|
70
71
|
.regex(/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/, 'Must be an Apple bundle id');
|
|
71
72
|
const unique = (values) => new Set(values).size === values.length;
|
|
72
73
|
export const applicationAndroidRecognitionSchema = z
|
|
@@ -100,7 +101,7 @@ export const applicationRecognitionWriteSchema = z
|
|
|
100
101
|
export const applicationRecognitionSchema = applicationRecognitionWriteSchema
|
|
101
102
|
.extend({
|
|
102
103
|
applicationId: applicationIdSchema,
|
|
103
|
-
updatedAt: z.string().
|
|
104
|
+
updatedAt: z.string().check(isoDateTime()).nullable(),
|
|
104
105
|
})
|
|
105
106
|
.strict();
|
|
106
107
|
// ---------------------------------------------------------------------------
|
|
@@ -127,7 +128,7 @@ export const appAssertionChallengeResponseSchema = z
|
|
|
127
128
|
.object({
|
|
128
129
|
challenge: base64Url32Schema,
|
|
129
130
|
requestHash: base64Url32Schema,
|
|
130
|
-
expiresAt: z.string().
|
|
131
|
+
expiresAt: z.string().check(isoDateTime()),
|
|
131
132
|
cloudProjectNumber: z
|
|
132
133
|
.string()
|
|
133
134
|
.regex(/^[0-9]{1,20}$/)
|
|
@@ -161,7 +162,7 @@ export const appAssertionRequestSchema = z.discriminatedUnion('platform', [
|
|
|
161
162
|
proof: z
|
|
162
163
|
.object({
|
|
163
164
|
challenge: base64Url32Schema,
|
|
164
|
-
integrityToken: z.string().
|
|
165
|
+
integrityToken: z.string().check(utf16MinLength(1)).check(utf16MaxLength(16384)),
|
|
165
166
|
})
|
|
166
167
|
.strict(),
|
|
167
168
|
})
|
|
@@ -186,6 +187,6 @@ export const appAssertionResponseSchema = z
|
|
|
186
187
|
assertion: z.string().regex(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/),
|
|
187
188
|
applicationId: z.string().regex(/^\S{1,255}$/),
|
|
188
189
|
platform: appAssertionPlatformSchema,
|
|
189
|
-
expiresAt: z.string().
|
|
190
|
+
expiresAt: z.string().check(isoDateTime()),
|
|
190
191
|
})
|
|
191
192
|
.strict();
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integerCheck } from './numberChecks.js';
|
|
2
|
+
import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
|
|
1
3
|
/**
|
|
2
4
|
* Application roles — the wire contract for permissions an APPLICATION declares
|
|
3
5
|
* about its own users, and for the grants that give them to Oxy users.
|
|
@@ -68,22 +70,22 @@ export function isApplicationPermissionKey(value) {
|
|
|
68
70
|
}
|
|
69
71
|
export const applicationPermissionKeySchema = z
|
|
70
72
|
.string()
|
|
71
|
-
.
|
|
73
|
+
.check(utf16MaxLength(APPLICATION_PERMISSION_KEY_MAX_LENGTH))
|
|
72
74
|
.regex(APPLICATION_PERMISSION_KEY_PATTERN, 'A permission key is 2-4 dot-separated lowercase segments, e.g. payments.operate');
|
|
73
75
|
/** Plain text: no control characters other than a newline or a tab. */
|
|
74
76
|
function plainText(max) {
|
|
75
77
|
return z
|
|
76
78
|
.string()
|
|
77
79
|
.trim()
|
|
78
|
-
.
|
|
79
|
-
.
|
|
80
|
+
.check(utf16MinLength(1))
|
|
81
|
+
.check(utf16MaxLength(max))
|
|
80
82
|
.refine((value) => Array.from(value).every((character) => {
|
|
81
83
|
const code = character.charCodeAt(0);
|
|
82
84
|
return (code >= 32 && code !== 127) || character === '\n' || character === '\t';
|
|
83
85
|
}), 'Must be plain text');
|
|
84
86
|
}
|
|
85
|
-
const id = z.string().
|
|
86
|
-
const isoTimestamp = z.string().
|
|
87
|
+
const id = z.string().check(utf16MinLength(1)).check(utf16MaxLength(128));
|
|
88
|
+
const isoTimestamp = z.string().check(utf16MinLength(1));
|
|
87
89
|
const reasonSchema = plainText(APPLICATION_ROLE_REASON_MAX_LENGTH);
|
|
88
90
|
/** One key as the application's owners declare it. */
|
|
89
91
|
export const applicationPermissionDeclarationSchema = z
|
|
@@ -140,7 +142,7 @@ export const declareApplicationPermissionsResponseSchema = applicationPermission
|
|
|
140
142
|
/** Live keys whose description changed. */
|
|
141
143
|
described: z.array(applicationPermissionKeySchema),
|
|
142
144
|
/** Live grants revoked because their key was retired. */
|
|
143
|
-
revokedGrants: z.number().
|
|
145
|
+
revokedGrants: z.number().check(integerCheck()).nonnegative(),
|
|
144
146
|
});
|
|
145
147
|
/** One grant of one key to one Oxy user. Revocation is a stamp, never a delete. */
|
|
146
148
|
export const applicationRoleGrantSchema = z.object({
|
|
@@ -166,7 +168,7 @@ export const applicationRoleGrantListSchema = z.object({
|
|
|
166
168
|
export const createApplicationRoleGrantRequestSchema = z
|
|
167
169
|
.object({
|
|
168
170
|
userId: id.optional(),
|
|
169
|
-
username: z.string().trim().
|
|
171
|
+
username: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(64)).optional(),
|
|
170
172
|
permission: applicationPermissionKeySchema,
|
|
171
173
|
reason: reasonSchema.optional(),
|
|
172
174
|
})
|
|
@@ -190,8 +192,13 @@ export const listApplicationRoleGrantsQuerySchema = z
|
|
|
190
192
|
.enum(['true', 'false'])
|
|
191
193
|
.transform((value) => value === 'true')
|
|
192
194
|
.optional(),
|
|
193
|
-
limit: z.coerce
|
|
194
|
-
|
|
195
|
+
limit: z.coerce
|
|
196
|
+
.number()
|
|
197
|
+
.check(integerCheck())
|
|
198
|
+
.min(1)
|
|
199
|
+
.max(APPLICATION_ROLE_GRANTS_PAGE_MAX)
|
|
200
|
+
.optional(),
|
|
201
|
+
cursor: z.string().check(utf16MinLength(1)).check(utf16MaxLength(512)).optional(),
|
|
195
202
|
})
|
|
196
203
|
.strict();
|
|
197
204
|
/**
|