@andco/protocol 0.0.10 → 0.0.12
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/api-errors.d.ts +5 -128
- package/dist/api-errors.d.ts.map +1 -1
- package/dist/api-errors.js +5 -131
- package/dist/authorization-preparation.d.ts +3 -3
- package/dist/authorization-preparation.d.ts.map +1 -1
- package/dist/authorization-preparation.js +4 -0
- package/dist/authorization.js +2 -2
- package/dist/errors.d.ts +60 -16
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +60 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/intent-input.d.ts +1791 -725
- package/dist/intent-input.d.ts.map +1 -1
- package/dist/intent-input.js +325 -157
- package/dist/issues.d.ts +61 -0
- package/dist/issues.d.ts.map +1 -0
- package/dist/issues.js +61 -0
- package/dist/messages/index.d.ts +2 -2
- package/dist/messages/index.d.ts.map +1 -1
- package/dist/messages/index.js +10 -3
- package/dist/messages/set-preferences.d.ts +13 -1
- package/dist/messages/set-preferences.d.ts.map +1 -1
- package/dist/messages/set-preferences.js +31 -9
- package/dist/miniapp-manifest.d.ts +2 -2
- package/dist/miniapp-manifest.d.ts.map +1 -1
- package/dist/miniapp-manifest.js +1 -1
- package/dist/native-intent.d.ts +48 -28
- package/dist/native-intent.d.ts.map +1 -1
- package/dist/native-intent.js +76 -24
- package/dist/pagination.d.ts +37 -31
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +72 -24
- package/dist/rar/account-matchers.d.ts +47 -240
- package/dist/rar/account-matchers.d.ts.map +1 -1
- package/dist/rar/account-matchers.js +52 -131
- package/dist/rar/bank.d.ts +280 -392
- package/dist/rar/bank.d.ts.map +1 -1
- package/dist/rar/bank.js +68 -137
- package/dist/rar/catalog.d.ts +305 -288
- package/dist/rar/catalog.d.ts.map +1 -1
- package/dist/rar/catalog.js +69 -29
- package/dist/rar/detail.d.ts +15 -32
- package/dist/rar/detail.d.ts.map +1 -1
- package/dist/rar/detail.js +14 -34
- package/dist/rar/index.d.ts +2 -1
- package/dist/rar/index.d.ts.map +1 -1
- package/dist/rar/index.js +2 -1
- package/dist/rar/json-schemas.generated.d.ts +4 -0
- package/dist/rar/json-schemas.generated.d.ts.map +1 -0
- package/dist/rar/json-schemas.generated.js +3570 -0
- package/dist/rar/money.d.ts +5 -5
- package/dist/rar/money.d.ts.map +1 -1
- package/dist/rar/money.js +5 -5
- package/dist/rar/project-users.d.ts +40 -14
- package/dist/rar/project-users.d.ts.map +1 -1
- package/dist/rar/project-users.js +20 -23
- package/dist/rar/subject-data.d.ts +96 -48
- package/dist/rar/subject-data.d.ts.map +1 -1
- package/dist/rar/subject-data.js +61 -34
- package/dist/rar/subject.d.ts +18 -85
- package/dist/rar/subject.d.ts.map +1 -1
- package/dist/rar/subject.js +23 -51
- package/dist/rest/accounts.d.ts +347 -0
- package/dist/rest/accounts.d.ts.map +1 -0
- package/dist/rest/accounts.js +108 -0
- package/dist/rest/addresses.d.ts +581 -0
- package/dist/rest/addresses.d.ts.map +1 -0
- package/dist/rest/addresses.js +190 -0
- package/dist/rest/api-error.d.ts +104 -0
- package/dist/rest/api-error.d.ts.map +1 -0
- package/dist/rest/api-error.js +103 -0
- package/dist/rest/authorization.d.ts +123 -0
- package/dist/rest/authorization.d.ts.map +1 -0
- package/dist/rest/authorization.js +62 -0
- package/dist/rest/catalog.d.ts +199 -0
- package/dist/rest/catalog.d.ts.map +1 -0
- package/dist/rest/catalog.js +63 -0
- package/dist/rest/common.d.ts +637 -0
- package/dist/rest/common.d.ts.map +1 -0
- package/dist/rest/common.js +172 -0
- package/dist/rest/contract.d.ts +3480 -0
- package/dist/rest/contract.d.ts.map +1 -0
- package/dist/rest/contract.js +120 -0
- package/dist/rest/events.d.ts +145 -0
- package/dist/rest/events.d.ts.map +1 -0
- package/dist/rest/events.js +42 -0
- package/dist/rest/http.d.ts +49 -0
- package/dist/rest/http.d.ts.map +1 -0
- package/dist/rest/http.js +25 -0
- package/dist/rest/identity.d.ts +627 -0
- package/dist/rest/identity.d.ts.map +1 -0
- package/dist/rest/identity.js +128 -0
- package/dist/rest/index.d.ts +14 -0
- package/dist/rest/index.d.ts.map +1 -0
- package/dist/rest/index.js +13 -0
- package/dist/rest/intents.d.ts +4556 -0
- package/dist/rest/intents.d.ts.map +1 -0
- package/dist/rest/intents.js +551 -0
- package/dist/rest/signatures.d.ts +110 -0
- package/dist/rest/signatures.d.ts.map +1 -0
- package/dist/rest/signatures.js +113 -0
- package/dist/rest/subjects.d.ts +14 -0
- package/dist/rest/subjects.d.ts.map +1 -0
- package/dist/rest/subjects.js +22 -0
- package/dist/service-grants.d.ts +2 -2
- package/dist/service-grants.d.ts.map +1 -1
- package/dist/service-grants.js +1 -1
- package/dist/transport/generated/oauth-api.d.ts +5547 -1448
- package/dist/transport/generated/oauth-api.d.ts.map +1 -1
- package/dist/transport/intents.d.ts +9 -134
- package/dist/transport/intents.d.ts.map +1 -1
- package/dist/transport/intents.js +21 -405
- package/dist/transport/rest.d.ts +15 -5
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/userinfo.d.ts +22 -9
- package/dist/userinfo.d.ts.map +1 -1
- package/dist/userinfo.js +17 -12
- package/package.json +13 -2
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { InvalidOrigin, InvalidToken, PayloadTooLarge, ServerError, TemporarilyUnavailable, UnsupportedMediaType, UnsupportedVersion } from "./common.js";
|
|
3
|
+
/** The media type a Signed Instruction travels as: one compact JWS, as text. */
|
|
4
|
+
export declare const SIGNED_INSTRUCTION_MEDIA_TYPE = "application/jwt";
|
|
5
|
+
/**
|
|
6
|
+
* A Signed Instruction as the body of a request: the compact JWS, as text. The schema reads any
|
|
7
|
+
* string, and the pattern is only documented, because an assertion that is not a compact JWS is
|
|
8
|
+
* refused by the verification, which names why (`malformed_assertion`), not by a generic
|
|
9
|
+
* `invalid_request`. The operation serves it as `application/jwt` with {@link servedAsSignedInstruction}.
|
|
10
|
+
*
|
|
11
|
+
* @param description What the body is, for the reference.
|
|
12
|
+
* @param claims The JSON Schema of the decoded payload (`contentSchema`), when the operation names it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function signedInstructionBody(description: string, claims?: Record<string, unknown>): v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, string>, v.MetadataAction<string, Record<string, unknown>>]>;
|
|
15
|
+
/**
|
|
16
|
+
* oRPC describes a request body as `application/json`. A body that is a Signed Instruction (the string
|
|
17
|
+
* branch of the body, see {@link signedInstructionBody}) travels as `application/jwt` instead: this
|
|
18
|
+
* moves that branch to its own media type, with `contentMediaType`, and leaves the JSON branches where
|
|
19
|
+
* they are. It is the `spec` of an operation's {@link http} meta.
|
|
20
|
+
*
|
|
21
|
+
* The media type is added here rather than in the schema because oRPC reads a string schema with a
|
|
22
|
+
* `contentMediaType` as a file, and then writes the JSON branches inline instead of by reference.
|
|
23
|
+
*/
|
|
24
|
+
export declare function servedAsSignedInstruction(operation: Record<string, unknown>): Record<string, unknown>;
|
|
25
|
+
/**
|
|
26
|
+
* Why a Signed Instruction did not verify. Every refusal names one cause, so an integrator can tell a
|
|
27
|
+
* `kid` that was never registered from one that was revoked, a clock that ran out from an audience
|
|
28
|
+
* that was wrong, and any of those from a payload altered in flight.
|
|
29
|
+
*/
|
|
30
|
+
export declare const SignedInstructionRejectionReason: v.PicklistSchema<["malformed_assertion", "missing_key_id", "disallowed_algorithm", "unknown_key", "revoked_key", "unusable_key", "invalid_signature", "expired_assertion", "premature_assertion", "missing_expiration", "missing_instruction_id", "missing_claim", "wrong_audience", "wrong_issuer", "verification_failed"], undefined>;
|
|
31
|
+
/** Why a Signed Instruction did not verify. */
|
|
32
|
+
export type SignedInstructionRejectionReason = v.InferOutput<typeof SignedInstructionRejectionReason>;
|
|
33
|
+
declare const UnverifiedSignedInstruction_base: (abstract new (data: {
|
|
34
|
+
reason: "malformed_assertion" | "missing_key_id" | "disallowed_algorithm" | "unknown_key" | "revoked_key" | "unusable_key" | "invalid_signature" | "expired_assertion" | "premature_assertion" | "missing_expiration" | "missing_instruction_id" | "missing_claim" | "wrong_audience" | "wrong_issuer" | "verification_failed";
|
|
35
|
+
key_id: string | null;
|
|
36
|
+
}, message?: string, hint?: string) => {
|
|
37
|
+
readonly error: "unverified_signed_instruction";
|
|
38
|
+
readonly hint?: string;
|
|
39
|
+
readonly data: {
|
|
40
|
+
reason: "malformed_assertion" | "missing_key_id" | "disallowed_algorithm" | "unknown_key" | "revoked_key" | "unusable_key" | "invalid_signature" | "expired_assertion" | "premature_assertion" | "missing_expiration" | "missing_instruction_id" | "missing_claim" | "wrong_audience" | "wrong_issuer" | "verification_failed";
|
|
41
|
+
key_id: string | null;
|
|
42
|
+
};
|
|
43
|
+
name: string;
|
|
44
|
+
message: string;
|
|
45
|
+
stack?: string;
|
|
46
|
+
cause?: unknown;
|
|
47
|
+
}) & {
|
|
48
|
+
readonly error: "unverified_signed_instruction";
|
|
49
|
+
readonly status: 422;
|
|
50
|
+
readonly data: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
51
|
+
readonly reason: v.SchemaWithPipe<readonly [v.PicklistSchema<["malformed_assertion", "missing_key_id", "disallowed_algorithm", "unknown_key", "revoked_key", "unusable_key", "invalid_signature", "expired_assertion", "premature_assertion", "missing_expiration", "missing_instruction_id", "missing_claim", "wrong_audience", "wrong_issuer", "verification_failed"], undefined>, v.DescriptionAction<"malformed_assertion" | "missing_key_id" | "disallowed_algorithm" | "unknown_key" | "revoked_key" | "unusable_key" | "invalid_signature" | "expired_assertion" | "premature_assertion" | "missing_expiration" | "missing_instruction_id" | "missing_claim" | "wrong_audience" | "wrong_issuer" | "verification_failed", "The one cause, never a generic failure.">]>;
|
|
52
|
+
readonly key_id: v.SchemaWithPipe<readonly [v.NullableSchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string | null, "The `kid` the assertion declared, when one could be read from it.">]>;
|
|
53
|
+
}, undefined>, v.DescriptionAction<{
|
|
54
|
+
reason: "malformed_assertion" | "missing_key_id" | "disallowed_algorithm" | "unknown_key" | "revoked_key" | "unusable_key" | "invalid_signature" | "expired_assertion" | "premature_assertion" | "missing_expiration" | "missing_instruction_id" | "missing_claim" | "wrong_audience" | "wrong_issuer" | "verification_failed";
|
|
55
|
+
key_id: string | null;
|
|
56
|
+
}, "The assertion did not verify against the OAuth Client's registered Signing Keys.">]>;
|
|
57
|
+
define<const Code extends string, const Status extends number, Data extends import("./api-error.js").AndcoAPIErrorDataSchema>(error: Code, status: Status, data: Data): (abstract new (data: v.InferOutput<Data>, message?: string, hint?: string) => {
|
|
58
|
+
readonly error: Code;
|
|
59
|
+
readonly hint?: string;
|
|
60
|
+
readonly data: v.InferOutput<Data>;
|
|
61
|
+
name: string;
|
|
62
|
+
message: string;
|
|
63
|
+
stack?: string;
|
|
64
|
+
cause?: unknown;
|
|
65
|
+
}) & {
|
|
66
|
+
readonly error: Code;
|
|
67
|
+
readonly status: Status;
|
|
68
|
+
readonly data: Data;
|
|
69
|
+
define<const Code extends string, const Status extends number, Data extends import("./api-error.js").AndcoAPIErrorDataSchema>(error: Code, status: Status, data: Data): /*elided*/ any;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The Signed Instruction sent to `POST /signatures/verify` did not verify. `reason` names the one
|
|
74
|
+
* cause, `key_id` the `kid` the assertion declared, and `message` says it in a sentence. Nothing was
|
|
75
|
+
* acted on.
|
|
76
|
+
*/
|
|
77
|
+
export declare class UnverifiedSignedInstruction extends /* @__PURE__ */ UnverifiedSignedInstruction_base {
|
|
78
|
+
constructor(data: {
|
|
79
|
+
reason: SignedInstructionRejectionReason;
|
|
80
|
+
key_id: string | null;
|
|
81
|
+
}, message?: string);
|
|
82
|
+
}
|
|
83
|
+
/** The verified `kid`, algorithm and claims of a Signed Instruction. */
|
|
84
|
+
export declare const SignedInstructionVerification: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
85
|
+
readonly key_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "RFC 7638 JWK Thumbprint of the Signing Key that verified the assertion.">]>;
|
|
86
|
+
readonly algorithm: v.PicklistSchema<["RS256", "ES256"], undefined>;
|
|
87
|
+
readonly claims: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
|
|
88
|
+
}, undefined>, v.DescriptionAction<{
|
|
89
|
+
key_id: string;
|
|
90
|
+
algorithm: "ES256" | "RS256";
|
|
91
|
+
claims: {
|
|
92
|
+
[x: string]: unknown;
|
|
93
|
+
};
|
|
94
|
+
}, "The verified `kid`, algorithm and claims of a Signed Instruction that verified against the presenting OAuth Client's registered keys. `claims` is the decoded JWT payload as signed -- this operation checks only `exp` and `jti` structurally and otherwise passes every claim through untouched, so it never narrows to one Intent family's claim schema.">]>;
|
|
95
|
+
/** The verified `kid`, algorithm and claims of a Signed Instruction. */
|
|
96
|
+
export type SignedInstructionVerification = v.InferOutput<typeof SignedInstructionVerification>;
|
|
97
|
+
/** Verifies a Signed Instruction against the OAuth Client's registered keys, without acting on it. */
|
|
98
|
+
export declare const verifySignature: import("@orpc/contract").ProcedureContractBuilderWithInputOutput<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, string>, v.MetadataAction<string, Record<string, unknown>>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
99
|
+
readonly key_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "RFC 7638 JWK Thumbprint of the Signing Key that verified the assertion.">]>;
|
|
100
|
+
readonly algorithm: v.PicklistSchema<["RS256", "ES256"], undefined>;
|
|
101
|
+
readonly claims: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
|
|
102
|
+
}, undefined>, v.DescriptionAction<{
|
|
103
|
+
key_id: string;
|
|
104
|
+
algorithm: "ES256" | "RS256";
|
|
105
|
+
claims: {
|
|
106
|
+
[x: string]: unknown;
|
|
107
|
+
};
|
|
108
|
+
}, "The verified `kid`, algorithm and claims of a Signed Instruction that verified against the presenting OAuth Client's registered keys. `claims` is the decoded JWT payload as signed -- this operation checks only `exp` and `jti` structurally and otherwise passes every claim through untouched, so it never narrows to one Intent family's claim schema.">]>, import("./api-error.js").AndcoAPIErrorMap<readonly [typeof InvalidToken, typeof InvalidOrigin, typeof UnsupportedVersion, typeof ServerError, typeof PayloadTooLarge, typeof UnsupportedMediaType, typeof UnverifiedSignedInstruction, typeof TemporarilyUnavailable]>>;
|
|
109
|
+
export {};
|
|
110
|
+
//# sourceMappingURL=signatures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatures.d.ts","sourceRoot":"","sources":["../../src/rest/signatures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAGrB,gFAAgF;AAChF,eAAO,MAAM,6BAA6B,oBAAoB,CAAC;AAK/D;;;;;;;;GAQG;AAEH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kJAM1F;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsBrG;AAQD;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,yUAgB3C,CAAC;AAEH,+CAA+C;AAC/C,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gCAAgC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtG;;;;GAIG;AACH,qBAAa,2BAA4B,SAAQ,eAAe,CAAC,gCAahE;gBACa,IAAI,EAAE;QAAE,MAAM,EAAE,gCAAgC,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,MAAM;CAGxG;AAED,wEAAwE;AACxE,eAAO,MAAM,6BAA6B;;;;;;;;;;mWAYzC,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEhG,sGAAsG;AACtG,eAAO,MAAM,eAAe;;;;;;;;;;4mBAyBY,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { oc } from "@orpc/contract";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { AndcoAPIError, errors } from "./api-error.js";
|
|
4
|
+
import { InvalidOrigin, InvalidToken, PayloadTooLarge, ServerError, TemporarilyUnavailable, UnsupportedMediaType, UnsupportedVersion, } from "./common.js";
|
|
5
|
+
import { http } from "./http.js";
|
|
6
|
+
/** The media type a Signed Instruction travels as: one compact JWS, as text. */
|
|
7
|
+
export const SIGNED_INSTRUCTION_MEDIA_TYPE = "application/jwt";
|
|
8
|
+
/** What a compact JWS looks like: three base64url segments separated by dots. */
|
|
9
|
+
const COMPACT_JWS_PATTERN = "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$";
|
|
10
|
+
/**
|
|
11
|
+
* A Signed Instruction as the body of a request: the compact JWS, as text. The schema reads any
|
|
12
|
+
* string, and the pattern is only documented, because an assertion that is not a compact JWS is
|
|
13
|
+
* refused by the verification, which names why (`malformed_assertion`), not by a generic
|
|
14
|
+
* `invalid_request`. The operation serves it as `application/jwt` with {@link servedAsSignedInstruction}.
|
|
15
|
+
*
|
|
16
|
+
* @param description What the body is, for the reference.
|
|
17
|
+
* @param claims The JSON Schema of the decoded payload (`contentSchema`), when the operation names it.
|
|
18
|
+
*/
|
|
19
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
20
|
+
export function signedInstructionBody(description, claims) {
|
|
21
|
+
const documented = { pattern: COMPACT_JWS_PATTERN };
|
|
22
|
+
if (claims !== undefined) {
|
|
23
|
+
documented["contentSchema"] = claims;
|
|
24
|
+
}
|
|
25
|
+
return v.pipe(v.string(), v.description(description), v.metadata(documented));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* oRPC describes a request body as `application/json`. A body that is a Signed Instruction (the string
|
|
29
|
+
* branch of the body, see {@link signedInstructionBody}) travels as `application/jwt` instead: this
|
|
30
|
+
* moves that branch to its own media type, with `contentMediaType`, and leaves the JSON branches where
|
|
31
|
+
* they are. It is the `spec` of an operation's {@link http} meta.
|
|
32
|
+
*
|
|
33
|
+
* The media type is added here rather than in the schema because oRPC reads a string schema with a
|
|
34
|
+
* `contentMediaType` as a file, and then writes the JSON branches inline instead of by reference.
|
|
35
|
+
*/
|
|
36
|
+
export function servedAsSignedInstruction(operation) {
|
|
37
|
+
const requestBody = operation["requestBody"];
|
|
38
|
+
const schema = requestBody?.content?.["application/json"]?.schema;
|
|
39
|
+
if (requestBody?.content === undefined || schema === undefined) {
|
|
40
|
+
throw new Error("The operation has no body to serve as a Signed Instruction.");
|
|
41
|
+
}
|
|
42
|
+
const branches = schema.anyOf ?? [schema];
|
|
43
|
+
const signed = branches.filter((branch) => branch.type === "string");
|
|
44
|
+
const json = branches.filter((branch) => branch.type !== "string");
|
|
45
|
+
if (signed.length !== 1) {
|
|
46
|
+
throw new Error("The body of the operation declares no Signed Instruction.");
|
|
47
|
+
}
|
|
48
|
+
const content = {};
|
|
49
|
+
if (json.length === 1) {
|
|
50
|
+
content["application/json"] = { schema: json[0] };
|
|
51
|
+
}
|
|
52
|
+
else if (json.length > 1) {
|
|
53
|
+
content["application/json"] = { schema: { anyOf: json } };
|
|
54
|
+
}
|
|
55
|
+
content[SIGNED_INSTRUCTION_MEDIA_TYPE] = {
|
|
56
|
+
schema: { ...signed[0], contentMediaType: SIGNED_INSTRUCTION_MEDIA_TYPE },
|
|
57
|
+
};
|
|
58
|
+
return { ...operation, requestBody: { ...requestBody, content } };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Why a Signed Instruction did not verify. Every refusal names one cause, so an integrator can tell a
|
|
62
|
+
* `kid` that was never registered from one that was revoked, a clock that ran out from an audience
|
|
63
|
+
* that was wrong, and any of those from a payload altered in flight.
|
|
64
|
+
*/
|
|
65
|
+
export const SignedInstructionRejectionReason = /* @__PURE__ */ v.picklist([
|
|
66
|
+
"malformed_assertion",
|
|
67
|
+
"missing_key_id",
|
|
68
|
+
"disallowed_algorithm",
|
|
69
|
+
"unknown_key",
|
|
70
|
+
"revoked_key",
|
|
71
|
+
"unusable_key",
|
|
72
|
+
"invalid_signature",
|
|
73
|
+
"expired_assertion",
|
|
74
|
+
"premature_assertion",
|
|
75
|
+
"missing_expiration",
|
|
76
|
+
"missing_instruction_id",
|
|
77
|
+
"missing_claim",
|
|
78
|
+
"wrong_audience",
|
|
79
|
+
"wrong_issuer",
|
|
80
|
+
"verification_failed",
|
|
81
|
+
]);
|
|
82
|
+
/**
|
|
83
|
+
* The Signed Instruction sent to `POST /signatures/verify` did not verify. `reason` names the one
|
|
84
|
+
* cause, `key_id` the `kid` the assertion declared, and `message` says it in a sentence. Nothing was
|
|
85
|
+
* acted on.
|
|
86
|
+
*/
|
|
87
|
+
export class UnverifiedSignedInstruction extends /* @__PURE__ */ AndcoAPIError.define("unverified_signed_instruction", 422, v.pipe(v.object({
|
|
88
|
+
reason: v.pipe(SignedInstructionRejectionReason, v.description("The one cause, never a generic failure.")),
|
|
89
|
+
key_id: v.pipe(v.nullable(v.string()), v.description("The `kid` the assertion declared, when one could be read from it.")),
|
|
90
|
+
}), v.description("The assertion did not verify against the OAuth Client's registered Signing Keys."))) {
|
|
91
|
+
constructor(data, message) {
|
|
92
|
+
super(data, message);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** The verified `kid`, algorithm and claims of a Signed Instruction. */
|
|
96
|
+
export const SignedInstructionVerification = /* @__PURE__ */ v.pipe(v.object({
|
|
97
|
+
key_id: v.pipe(v.string(), v.description("RFC 7638 JWK Thumbprint of the Signing Key that verified the assertion.")),
|
|
98
|
+
algorithm: v.picklist(["RS256", "ES256"]),
|
|
99
|
+
claims: v.record(v.string(), v.unknown()),
|
|
100
|
+
}), v.description("The verified `kid`, algorithm and claims of a Signed Instruction that verified against the presenting OAuth Client's registered keys. `claims` is the decoded JWT payload as signed -- this operation checks only `exp` and `jti` structurally and otherwise passes every claim through untouched, so it never narrows to one Intent family's claim schema."));
|
|
101
|
+
/** Verifies a Signed Instruction against the OAuth Client's registered keys, without acting on it. */
|
|
102
|
+
export const verifySignature = /* @__PURE__ */ oc
|
|
103
|
+
.meta(http({
|
|
104
|
+
method: "POST",
|
|
105
|
+
path: "/signatures/verify",
|
|
106
|
+
summary: "Verify a Signed Instruction against the OAuth Client's registered keys, without acting on it",
|
|
107
|
+
description: "Verifies the assertion's signature, `kid`, algorithm, issuer, audience and expiration against the Signing Keys the presenting OAuth Client has registered, and returns its verified claims untouched. Acts on nothing: this is the smallest surface that exercises signing end to end, so an integrator can confirm that the key it registered, the `kid` its SDK derived and the claims it signs all line up before any of them is submitted to create, execute or approve an Intent. Requires only a valid OAuth bearer token, no scope or authorization detail.",
|
|
108
|
+
successDescription: "The assertion verified; its claims as signed",
|
|
109
|
+
spec: servedAsSignedInstruction,
|
|
110
|
+
}))
|
|
111
|
+
.errors(errors(InvalidToken, InvalidOrigin, UnsupportedVersion, ServerError, PayloadTooLarge, UnsupportedMediaType, UnverifiedSignedInstruction, TemporarilyUnavailable))
|
|
112
|
+
.input(signedInstructionBody("The Signed Instruction to verify, as a compact JWS."))
|
|
113
|
+
.output(SignedInstructionVerification);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { InsufficientAuthorization, InvalidIdentifier, InvalidOrigin, InvalidToken, NotFound, ServerError, TemporarilyUnavailable, UnsupportedVersion } from "./common.js";
|
|
3
|
+
/** The identifier of a Profile, in `/profiles/{profile_id}/…`. */
|
|
4
|
+
export declare const ProfileIdParameter: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UuidAction<string, undefined>]>, v.DescriptionAction<string, "The Profile the Grant's subject names.">]>;
|
|
5
|
+
/** The identifier of an Organization, in `/organizations/{organization_id}/…`: a positive integer of up to ten digits. */
|
|
6
|
+
export declare const OrganizationIdParameter: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, v.DescriptionAction<string, "The Organization the Grant's subject names.">]>;
|
|
7
|
+
/**
|
|
8
|
+
* The errors every route under `/profiles/{profile_id}` and `/organizations/{organization_id}`
|
|
9
|
+
* answers, whatever it does: a malformed subject, a token that is not valid or whose Grant lacks the
|
|
10
|
+
* operation's permission, a subject that is not the Grant's (`not_found`, as one that does not exist),
|
|
11
|
+
* an origin the Client is not registered for, and an outage.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SubjectErrors: readonly [typeof InvalidIdentifier, typeof InvalidToken, typeof InsufficientAuthorization, typeof NotFound, typeof InvalidOrigin, typeof UnsupportedVersion, typeof ServerError, typeof TemporarilyUnavailable];
|
|
14
|
+
//# sourceMappingURL=subjects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subjects.d.ts","sourceRoot":"","sources":["../../src/rest/subjects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,6LAG9B,CAAC;AAEF,0HAA0H;AAC1H,eAAO,MAAM,uBAAuB,mMAGnC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,iNAShB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { InsufficientAuthorization, InvalidIdentifier, InvalidOrigin, InvalidToken, NotFound, ServerError, TemporarilyUnavailable, UnsupportedVersion, } from "./common.js";
|
|
3
|
+
/** The identifier of a Profile, in `/profiles/{profile_id}/…`. */
|
|
4
|
+
export const ProfileIdParameter = /* @__PURE__ */ v.pipe(v.pipe(v.string(), v.uuid()), v.description("The Profile the Grant's subject names."));
|
|
5
|
+
/** The identifier of an Organization, in `/organizations/{organization_id}/…`: a positive integer of up to ten digits. */
|
|
6
|
+
export const OrganizationIdParameter = /* @__PURE__ */ v.pipe(v.pipe(v.string(), v.regex(/^[1-9][0-9]{0,9}$/)), v.description("The Organization the Grant's subject names."));
|
|
7
|
+
/**
|
|
8
|
+
* The errors every route under `/profiles/{profile_id}` and `/organizations/{organization_id}`
|
|
9
|
+
* answers, whatever it does: a malformed subject, a token that is not valid or whose Grant lacks the
|
|
10
|
+
* operation's permission, a subject that is not the Grant's (`not_found`, as one that does not exist),
|
|
11
|
+
* an origin the Client is not registered for, and an outage.
|
|
12
|
+
*/
|
|
13
|
+
export const SubjectErrors = [
|
|
14
|
+
InvalidIdentifier,
|
|
15
|
+
InvalidToken,
|
|
16
|
+
InsufficientAuthorization,
|
|
17
|
+
NotFound,
|
|
18
|
+
InvalidOrigin,
|
|
19
|
+
UnsupportedVersion,
|
|
20
|
+
ServerError,
|
|
21
|
+
TemporarilyUnavailable,
|
|
22
|
+
];
|
package/dist/service-grants.d.ts
CHANGED
|
@@ -15,10 +15,10 @@ export declare const ServiceGrantSchema: v.ObjectSchema<{
|
|
|
15
15
|
readonly clientId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UuidAction<string, undefined>]>;
|
|
16
16
|
readonly subject: v.StrictObjectSchema<{
|
|
17
17
|
readonly type: v.LiteralSchema<"organization", undefined>;
|
|
18
|
-
readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined
|
|
18
|
+
readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
|
|
19
19
|
}, undefined>;
|
|
20
20
|
readonly resource: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>]>;
|
|
21
|
-
readonly createdAt: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
21
|
+
readonly createdAt: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>;
|
|
22
22
|
/** `expired`: its expiry passed (ADR 0034); like `revoked`, it stays in the authorizations history. */
|
|
23
23
|
readonly status: v.PicklistSchema<["active", "revoked", "expired"], undefined>;
|
|
24
24
|
readonly version: v.StringSchema<undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-grants.d.ts","sourceRoot":"","sources":["../src/service-grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"service-grants.d.ts","sourceRoot":"","sources":["../src/service-grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;IAM7B,uGAAuG;;;;;aAKvG,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAE9D;AAUD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,iBAAiB,EAAE,UAAU,CAAC,YAAY,CAAC,CAErG;AACD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gCAAgC,CAAC,CAE1G;AACD,eAAO,MAAM,kBAAkB;;;;;aAK7B,CAAC;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAE1F"}
|
package/dist/service-grants.js
CHANGED
|
@@ -15,7 +15,7 @@ export const ServiceGrantSchema = /* @__PURE__ */ v.object({
|
|
|
15
15
|
clientId: v.pipe(v.string(), v.uuid()),
|
|
16
16
|
subject: GrantedOrganizationSubjectSchema,
|
|
17
17
|
resource: v.pipe(v.string(), v.url()),
|
|
18
|
-
createdAt: v.pipe(v.string(), v.
|
|
18
|
+
createdAt: v.pipe(v.string(), v.isoTimestamp()),
|
|
19
19
|
/** `expired`: its expiry passed (ADR 0034); like `revoked`, it stays in the authorizations history. */
|
|
20
20
|
status: v.picklist(["active", "revoked", "expired"]),
|
|
21
21
|
version: v.string(),
|