@sylphx/sdk 0.28.0 → 0.31.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/LICENSE +21 -0
- package/README.md +42 -114
- package/dist/access.d.ts +670 -0
- package/dist/access.js +640 -0
- package/dist/access.js.map +1 -0
- package/dist/ai.d.ts +176 -0
- package/dist/ai.js +112 -0
- package/dist/ai.js.map +1 -0
- package/dist/artifacts.d.ts +165 -0
- package/dist/artifacts.js +129 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/auth/verify.d.ts +57 -0
- package/dist/auth/verify.js +157 -0
- package/dist/auth/verify.js.map +1 -0
- package/dist/auth.d.ts +896 -0
- package/dist/auth.js +828 -0
- package/dist/auth.js.map +1 -0
- package/dist/billing.d.ts +854 -0
- package/dist/billing.js +593 -0
- package/dist/billing.js.map +1 -0
- package/dist/broker.d.ts +226 -0
- package/dist/broker.js +187 -0
- package/dist/broker.js.map +1 -0
- package/dist/build.d.ts +313 -0
- package/dist/build.js +271 -0
- package/dist/build.js.map +1 -0
- package/dist/common.d.ts +162 -0
- package/dist/common.js +41 -0
- package/dist/common.js.map +1 -0
- package/dist/config.d.ts +198 -0
- package/dist/config.js +168 -0
- package/dist/config.js.map +1 -0
- package/dist/connections.d.ts +354 -0
- package/dist/connections.js +313 -0
- package/dist/connections.js.map +1 -0
- package/dist/data.d.ts +1141 -0
- package/dist/data.js +1082 -0
- package/dist/data.js.map +1 -0
- package/dist/entitlement.d.ts +179 -0
- package/dist/entitlement.js +117 -0
- package/dist/entitlement.js.map +1 -0
- package/dist/events.d.ts +1324 -0
- package/dist/events.js +1227 -0
- package/dist/events.js.map +1 -0
- package/dist/hosting.d.ts +709 -0
- package/dist/hosting.js +611 -0
- package/dist/hosting.js.map +1 -0
- package/dist/index.d.ts +79 -33656
- package/dist/index.js +113 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +438 -0
- package/dist/keys.js +406 -0
- package/dist/keys.js.map +1 -0
- package/dist/methods.d.ts +2 -0
- package/dist/methods.js +4200 -0
- package/dist/methods.js.map +1 -0
- package/dist/network.d.ts +733 -0
- package/dist/network.js +711 -0
- package/dist/network.js.map +1 -0
- package/dist/notify.d.ts +1753 -0
- package/dist/notify.js +1551 -0
- package/dist/notify.js.map +1 -0
- package/dist/observability.d.ts +509 -0
- package/dist/observability.js +437 -0
- package/dist/observability.js.map +1 -0
- package/dist/release.d.ts +303 -0
- package/dist/release.js +214 -0
- package/dist/release.js.map +1 -0
- package/dist/runners.d.ts +262 -0
- package/dist/runners.js +238 -0
- package/dist/runners.js.map +1 -0
- package/dist/runtime.d.ts +121 -0
- package/dist/runtime.js +305 -0
- package/dist/runtime.js.map +1 -0
- package/dist/sandboxes.d.ts +1705 -0
- package/dist/sandboxes.js +1226 -0
- package/dist/sandboxes.js.map +1 -0
- package/dist/secrets.d.ts +508 -0
- package/dist/secrets.js +474 -0
- package/dist/secrets.js.map +1 -0
- package/dist/workflows.d.ts +678 -0
- package/dist/workflows.js +595 -0
- package/dist/workflows.js.map +1 -0
- package/package.json +33 -112
- package/dist/connect.d.ts +0 -2838
- package/dist/connect.mjs +0 -220
- package/dist/connect.mjs.map +0 -1
- package/dist/health/index.d.ts +0 -1394
- package/dist/health/index.mjs +0 -1394
- package/dist/health/index.mjs.map +0 -1
- package/dist/index.mjs +0 -38429
- package/dist/index.mjs.map +0 -1
- package/dist/nextjs/index.d.ts +0 -724
- package/dist/nextjs/index.mjs +0 -3332
- package/dist/nextjs/index.mjs.map +0 -1
- package/dist/react/index.d.ts +0 -13066
- package/dist/react/index.mjs +0 -35329
- package/dist/react/index.mjs.map +0 -1
- package/dist/server/index.d.ts +0 -2000
- package/dist/server/index.mjs +0 -3446
- package/dist/server/index.mjs.map +0 -1
- package/dist/web-analytics.d.ts +0 -90
- package/dist/web-analytics.mjs +0 -225
- package/dist/web-analytics.mjs.map +0 -1
package/dist/ai.d.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import * as runtime from './runtime.js';
|
|
2
|
+
import './common.js';
|
|
3
|
+
import type * as common from './common.js';
|
|
4
|
+
/**
|
|
5
|
+
* An AI Model is one admitted entry of the Sylphx AI catalog: a model id a
|
|
6
|
+
* caller may name on the inference surface, with its sell prices, limits, and
|
|
7
|
+
* data policy. Only admitted models list (AI-CATALOG-ADMISSION); no
|
|
8
|
+
* capability, contract, connector, or upstream price appears on an entry
|
|
9
|
+
* (AI-CATALOG-NO-LEAK). The id is the canonical model id with `/` and `.`
|
|
10
|
+
* written as `-`, for example `anthropic-claude-opus-5`; `model` carries the
|
|
11
|
+
* canonical id itself.
|
|
12
|
+
*
|
|
13
|
+
* The catalog is platform-wide and written only by `sylphx-platform`;
|
|
14
|
+
* customers read it.
|
|
15
|
+
*/
|
|
16
|
+
export interface AiModel {
|
|
17
|
+
/** `ai_models/{ai_model}`. */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** `aim_<cell><ulid>`; never reused. */
|
|
20
|
+
readonly uid?: string;
|
|
21
|
+
/** Resource metadata. */
|
|
22
|
+
meta?: common.ResourceMeta;
|
|
23
|
+
/**
|
|
24
|
+
* The canonical model id, `brand/model`, for example
|
|
25
|
+
* `anthropic/claude-opus-5`.
|
|
26
|
+
*/
|
|
27
|
+
readonly model?: string;
|
|
28
|
+
/** The brand, for example `anthropic`. */
|
|
29
|
+
readonly brand?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Bare spellings that resolve to this model when unique, for example
|
|
32
|
+
* `claude-opus-5`.
|
|
33
|
+
*/
|
|
34
|
+
readonly aliases?: string[];
|
|
35
|
+
/** What the model produces. */
|
|
36
|
+
readonly modality?: ModelModality;
|
|
37
|
+
/** Accepted input modalities, for example text and image. */
|
|
38
|
+
readonly inputModalities?: InputModality[];
|
|
39
|
+
/** Inference encodings the model answers on. */
|
|
40
|
+
readonly apiSurfaces?: ApiSurface[];
|
|
41
|
+
/** Context window in tokens. */
|
|
42
|
+
readonly contextWindowTokens?: string;
|
|
43
|
+
/** Most output tokens per response. */
|
|
44
|
+
readonly maxOutputTokens?: string;
|
|
45
|
+
/** The upstream release date. */
|
|
46
|
+
readonly releaseTime?: string;
|
|
47
|
+
/** Whether the model is a preview. */
|
|
48
|
+
readonly preview?: boolean;
|
|
49
|
+
/** Sell prices per meter and class; the only prices on an entry. */
|
|
50
|
+
readonly prices?: ModelPrice[];
|
|
51
|
+
/** The price identity usage events carry, for example `spv3-...`. */
|
|
52
|
+
readonly priceIdentity?: string;
|
|
53
|
+
/** How request and response data are retained and used. */
|
|
54
|
+
readonly dataPolicy?: DataPolicy;
|
|
55
|
+
/**
|
|
56
|
+
* How long a prompt-cache prefix stays warm on this model, and the longest
|
|
57
|
+
* retention a request may ask for; unset when no serving lane declares it.
|
|
58
|
+
*/
|
|
59
|
+
readonly caching?: ModelCaching;
|
|
60
|
+
}
|
|
61
|
+
/** How a model's request and response data are handled. */
|
|
62
|
+
export interface DataPolicy {
|
|
63
|
+
/** Whether Sylphx or the upstream retains prompts beyond the request. */
|
|
64
|
+
readonly retainsPrompts?: boolean;
|
|
65
|
+
/** Whether the upstream may train on prompts. */
|
|
66
|
+
readonly trainsOnPrompts?: boolean;
|
|
67
|
+
/** Stored responses expire after this long (7 days). */
|
|
68
|
+
readonly responseRetention?: string;
|
|
69
|
+
}
|
|
70
|
+
/** The request of GetAiModel. */
|
|
71
|
+
export interface GetAiModelRequest {
|
|
72
|
+
/** The name of the AI model to get. */
|
|
73
|
+
name: string;
|
|
74
|
+
}
|
|
75
|
+
/** The request of ListAiModels. */
|
|
76
|
+
export interface ListAiModelsRequest {
|
|
77
|
+
/** At most this many; default 50, clamped to 1000. */
|
|
78
|
+
pageSize?: number;
|
|
79
|
+
/** `next_page_token` of the previous page. */
|
|
80
|
+
pageToken?: string;
|
|
81
|
+
/** AIP-160 filter over labels and filterable fields. */
|
|
82
|
+
filter?: string;
|
|
83
|
+
/** AIP-132 ordering over filterable fields. */
|
|
84
|
+
orderBy?: string;
|
|
85
|
+
}
|
|
86
|
+
/** The response of ListAiModels. */
|
|
87
|
+
export interface ListAiModelsResponse {
|
|
88
|
+
/** The page. */
|
|
89
|
+
aiModels?: AiModel[];
|
|
90
|
+
/** The token of the next page; empty on the last page. */
|
|
91
|
+
nextPageToken?: string;
|
|
92
|
+
}
|
|
93
|
+
/** A model's prompt-cache retention, from its serving lanes' declarations. */
|
|
94
|
+
export interface ModelCaching {
|
|
95
|
+
/**
|
|
96
|
+
* How long a cached prefix stays warm after its last use with the default
|
|
97
|
+
* retention, for example 300 seconds.
|
|
98
|
+
*/
|
|
99
|
+
readonly ttl?: string;
|
|
100
|
+
/**
|
|
101
|
+
* The longest retention a request may ask for with
|
|
102
|
+
* `prompt_cache_retention: "24h"`, for example one hour on a lane whose
|
|
103
|
+
* longest native breakpoint is one hour; zero when no longer retention
|
|
104
|
+
* exists. A prefix written at this retention bills at the `cache_write_1h`
|
|
105
|
+
* price.
|
|
106
|
+
*/
|
|
107
|
+
readonly extendedTtl?: string;
|
|
108
|
+
}
|
|
109
|
+
/** One sell price of a model. */
|
|
110
|
+
export interface ModelPrice {
|
|
111
|
+
/** The meter, for example `ai.tokens`. */
|
|
112
|
+
readonly meter?: string;
|
|
113
|
+
/**
|
|
114
|
+
* The meter dimension class, for example `input`, `cached_input`, `output`,
|
|
115
|
+
* `reasoning`, `cache_write` (writing a prompt-cache prefix at the default
|
|
116
|
+
* retention), or `cache_write_1h` (writing it at the extended retention).
|
|
117
|
+
*/
|
|
118
|
+
readonly priceClass?: string;
|
|
119
|
+
/** The unit the price is per, for example `1M tokens` or `image`. */
|
|
120
|
+
readonly unit?: string;
|
|
121
|
+
/** ISO 4217 currency. */
|
|
122
|
+
readonly currencyCode?: string;
|
|
123
|
+
/** The price as a decimal string, for example `1.2`; never a float. */
|
|
124
|
+
readonly unitPrice?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* An inference encoding of the compatibility surface (ai-inference-surface.md
|
|
128
|
+
* §5).
|
|
129
|
+
*/
|
|
130
|
+
export type ApiSurface = 'responses' | 'messages' | 'chat_completions' | 'embeddings' | 'images' | 'speech' | 'transcription' | (string & {});
|
|
131
|
+
/** An input a model accepts. */
|
|
132
|
+
export type InputModality = 'text' | 'image' | 'audio' | 'file' | 'video' | (string & {});
|
|
133
|
+
/** What a model produces. */
|
|
134
|
+
export type ModelModality = 'chat' | 'embedding' | 'image' | 'speech' | 'transcription' | 'video' | 'decision' | (string & {});
|
|
135
|
+
/**
|
|
136
|
+
* AiService is the Resource side of Sylphx AI: the model catalog
|
|
137
|
+
* (docs/services/ai/capabilities.md AI-CATALOG).
|
|
138
|
+
*
|
|
139
|
+
* Inference is not here. The OpenAI- and Anthropic-compatible routes
|
|
140
|
+
* (`/v1/responses`, `/v1/chat/completions`, `/v1/messages`, `/v1/embeddings`,
|
|
141
|
+
* `/v1/images/*`, `/v1/audio/*`, `/v1/models`, `/v1/files`) keep their
|
|
142
|
+
* industry wire and stay outside the Resource grammar (ai-inference-surface.md
|
|
143
|
+
* §4, resource-api-and-clients.md §4.6); their contract is imported OpenAPI,
|
|
144
|
+
* not proto. Usage is not here either: AI keeps no usage or spend table
|
|
145
|
+
* (AI-USAGE-SPEND); its meters are read from Kernel Billing.
|
|
146
|
+
*
|
|
147
|
+
* Namespace of Sylphx AI on `Sylphx`.
|
|
148
|
+
*/
|
|
149
|
+
export declare class AiApi {
|
|
150
|
+
/** The `ai_models` collection. */
|
|
151
|
+
readonly aiModels: AiModelsCollection;
|
|
152
|
+
constructor(client: runtime.Client);
|
|
153
|
+
}
|
|
154
|
+
/** `ai_models` of Sylphx AI: Resource type `ai.sylphx.com/AiModel`. */
|
|
155
|
+
export declare class AiModelsCollection {
|
|
156
|
+
private readonly client;
|
|
157
|
+
constructor(client: runtime.Client);
|
|
158
|
+
/**
|
|
159
|
+
* Gets an AI model.
|
|
160
|
+
*
|
|
161
|
+
* `GET /v1/{name=ai_models/*}` · permission `ai:read` · effect `read`
|
|
162
|
+
*
|
|
163
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
|
|
164
|
+
*/
|
|
165
|
+
get(request: GetAiModelRequest): Promise<AiModel>;
|
|
166
|
+
/**
|
|
167
|
+
* Lists the admitted catalog; filter by `brand`, `modality`, or `model`.
|
|
168
|
+
*
|
|
169
|
+
* `GET /v1/ai_models` · permission `ai:read` · effect `read`
|
|
170
|
+
*
|
|
171
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
|
|
172
|
+
*/
|
|
173
|
+
list(request: ListAiModelsRequest): Promise<ListAiModelsResponse>;
|
|
174
|
+
/** Every item of every page of `list`. */
|
|
175
|
+
listAll(request: ListAiModelsRequest): AsyncGenerator<AiModel>;
|
|
176
|
+
}
|
package/dist/ai.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// @generated by sylphx-gen 0.1.0 from contracts@446ceb843d4ff88057b0db68e2e54e4aea52d8143b72d66016122995b878de20. Do not edit.
|
|
2
|
+
// `sylphx.ai.v1`.
|
|
3
|
+
import * as runtime from './runtime.js';
|
|
4
|
+
import './common.js';
|
|
5
|
+
runtime.registerSchemas({
|
|
6
|
+
'sylphx.ai.v1.AiModel': [
|
|
7
|
+
['meta', 'meta', 'sylphx.common.v1.ResourceMeta'],
|
|
8
|
+
['inputModalities', 'input_modalities'],
|
|
9
|
+
['apiSurfaces', 'api_surfaces'],
|
|
10
|
+
['contextWindowTokens', 'context_window_tokens'],
|
|
11
|
+
['maxOutputTokens', 'max_output_tokens'],
|
|
12
|
+
['releaseTime', 'release_time'],
|
|
13
|
+
['prices', 'prices', 'sylphx.ai.v1.ModelPrice'],
|
|
14
|
+
['priceIdentity', 'price_identity'],
|
|
15
|
+
['dataPolicy', 'data_policy', 'sylphx.ai.v1.DataPolicy'],
|
|
16
|
+
['caching', 'caching', 'sylphx.ai.v1.ModelCaching'],
|
|
17
|
+
],
|
|
18
|
+
'sylphx.ai.v1.DataPolicy': [
|
|
19
|
+
['retainsPrompts', 'retains_prompts'],
|
|
20
|
+
['trainsOnPrompts', 'trains_on_prompts'],
|
|
21
|
+
['responseRetention', 'response_retention'],
|
|
22
|
+
],
|
|
23
|
+
'sylphx.ai.v1.GetAiModelRequest': [],
|
|
24
|
+
'sylphx.ai.v1.ListAiModelsRequest': [
|
|
25
|
+
['pageSize', 'page_size'],
|
|
26
|
+
['pageToken', 'page_token'],
|
|
27
|
+
['orderBy', 'order_by'],
|
|
28
|
+
],
|
|
29
|
+
'sylphx.ai.v1.ListAiModelsResponse': [
|
|
30
|
+
['aiModels', 'ai_models', 'sylphx.ai.v1.AiModel'],
|
|
31
|
+
['nextPageToken', 'next_page_token'],
|
|
32
|
+
],
|
|
33
|
+
'sylphx.ai.v1.ModelCaching': [
|
|
34
|
+
['extendedTtl', 'extended_ttl'],
|
|
35
|
+
],
|
|
36
|
+
'sylphx.ai.v1.ModelPrice': [
|
|
37
|
+
['priceClass', 'price_class'],
|
|
38
|
+
['currencyCode', 'currency_code'],
|
|
39
|
+
['unitPrice', 'unit_price'],
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* AiService is the Resource side of Sylphx AI: the model catalog
|
|
44
|
+
* (docs/services/ai/capabilities.md AI-CATALOG).
|
|
45
|
+
*
|
|
46
|
+
* Inference is not here. The OpenAI- and Anthropic-compatible routes
|
|
47
|
+
* (`/v1/responses`, `/v1/chat/completions`, `/v1/messages`, `/v1/embeddings`,
|
|
48
|
+
* `/v1/images/*`, `/v1/audio/*`, `/v1/models`, `/v1/files`) keep their
|
|
49
|
+
* industry wire and stay outside the Resource grammar (ai-inference-surface.md
|
|
50
|
+
* §4, resource-api-and-clients.md §4.6); their contract is imported OpenAPI,
|
|
51
|
+
* not proto. Usage is not here either: AI keeps no usage or spend table
|
|
52
|
+
* (AI-USAGE-SPEND); its meters are read from Kernel Billing.
|
|
53
|
+
*
|
|
54
|
+
* Namespace of Sylphx AI on `Sylphx`.
|
|
55
|
+
*/
|
|
56
|
+
export class AiApi {
|
|
57
|
+
/** The `ai_models` collection. */
|
|
58
|
+
aiModels;
|
|
59
|
+
constructor(client) {
|
|
60
|
+
this.aiModels = new AiModelsCollection(client);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** `ai_models` of Sylphx AI: Resource type `ai.sylphx.com/AiModel`. */
|
|
64
|
+
export class AiModelsCollection {
|
|
65
|
+
client;
|
|
66
|
+
constructor(client) {
|
|
67
|
+
this.client = client;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Gets an AI model.
|
|
71
|
+
*
|
|
72
|
+
* `GET /v1/{name=ai_models/*}` · permission `ai:read` · effect `read`
|
|
73
|
+
*
|
|
74
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
|
|
75
|
+
*/
|
|
76
|
+
async get(request) {
|
|
77
|
+
return this.client.call({
|
|
78
|
+
method: 'GET',
|
|
79
|
+
path: `/v1/${runtime.pathParam(request.name, 'ai_models/*', 'name')}`,
|
|
80
|
+
responseType: 'sylphx.ai.v1.AiModel',
|
|
81
|
+
mutation: false,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Lists the admitted catalog; filter by `brand`, `modality`, or `model`.
|
|
86
|
+
*
|
|
87
|
+
* `GET /v1/ai_models` · permission `ai:read` · effect `read`
|
|
88
|
+
*
|
|
89
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
|
|
90
|
+
*/
|
|
91
|
+
async list(request) {
|
|
92
|
+
return this.client.call({
|
|
93
|
+
method: 'GET',
|
|
94
|
+
path: `/v1/ai_models`,
|
|
95
|
+
query: { page_size: request.pageSize, page_token: request.pageToken, filter: request.filter, order_by: request.orderBy },
|
|
96
|
+
responseType: 'sylphx.ai.v1.ListAiModelsResponse',
|
|
97
|
+
mutation: false,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/** Every item of every page of `list`. */
|
|
101
|
+
async *listAll(request) {
|
|
102
|
+
let next = request;
|
|
103
|
+
for (;;) {
|
|
104
|
+
const page = await this.list(next);
|
|
105
|
+
yield* page.aiModels ?? [];
|
|
106
|
+
if (page.nextPageToken === undefined || page.nextPageToken === '')
|
|
107
|
+
return;
|
|
108
|
+
next = { ...request, pageToken: page.nextPageToken };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=ai.js.map
|
package/dist/ai.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAC/H,kBAAkB;AAElB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,aAAa,CAAA;AAgJpB,OAAO,CAAC,eAAe,CAAC;IACvB,sBAAsB,EAAE;QACvB,CAAC,MAAM,EAAE,MAAM,EAAE,+BAA+B,CAAC;QACjD,CAAC,iBAAiB,EAAE,kBAAkB,CAAC;QACvC,CAAC,aAAa,EAAE,cAAc,CAAC;QAC/B,CAAC,qBAAqB,EAAE,uBAAuB,CAAC;QAChD,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;QACxC,CAAC,aAAa,EAAE,cAAc,CAAC;QAC/B,CAAC,QAAQ,EAAE,QAAQ,EAAE,yBAAyB,CAAC;QAC/C,CAAC,eAAe,EAAE,gBAAgB,CAAC;QACnC,CAAC,YAAY,EAAE,aAAa,EAAE,yBAAyB,CAAC;QACxD,CAAC,SAAS,EAAE,SAAS,EAAE,2BAA2B,CAAC;KACnD;IACD,yBAAyB,EAAE;QAC1B,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;QACrC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;QACxC,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;K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AC7C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE;YACxH,YAAY,EAAE,mCAAmC;YACjD,QAAQ,EAAE,KAAK;SACf,CAAC,CAAA;IACH,CAAC;IAED,0CAA0C;IAC1C,KAAK,CAAC,CAAC,OAAO,CAAC,OAA4B;QAC1C,IAAI,IAAI,GAAwB,OAAO,CAAA;QACvC,SAAS,CAAC;YACT,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAClC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;YAC1B,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,aAAa,KAAK,EAAE;gBAAE,OAAM;YACzE,IAAI,GAAG,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,CAAA;QACrD,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as runtime from './runtime.js';
|
|
2
|
+
import './common.js';
|
|
3
|
+
import type * as common from './common.js';
|
|
4
|
+
/**
|
|
5
|
+
* An Artifact is one immutable content object addressed by digest: an
|
|
6
|
+
* image, or evidence about one (an SBOM, a provenance attestation, a
|
|
7
|
+
* signature) that names it as its subject.
|
|
8
|
+
*/
|
|
9
|
+
export interface Artifact {
|
|
10
|
+
/**
|
|
11
|
+
* `orgs/{org}/projects/{project}/artifacts/{artifact}`, where `{artifact}`
|
|
12
|
+
* is the digest with `-` for `:`, for example `sha256-4f1c…`.
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
/** `art_<cell><ulid>`. */
|
|
16
|
+
readonly uid?: string;
|
|
17
|
+
/** Resource metadata. */
|
|
18
|
+
meta?: common.ResourceMeta;
|
|
19
|
+
/**
|
|
20
|
+
* The algorithm-qualified digest of the stored bytes, for example
|
|
21
|
+
* `sha256:4f1c…`.
|
|
22
|
+
*/
|
|
23
|
+
digest?: string;
|
|
24
|
+
/** What the Artifact is. */
|
|
25
|
+
kind?: ArtifactKind;
|
|
26
|
+
/**
|
|
27
|
+
* The media type, for example
|
|
28
|
+
* `application/vnd.oci.image.manifest.v1+json`.
|
|
29
|
+
*/
|
|
30
|
+
mediaType?: string;
|
|
31
|
+
/** The size of the stored bytes. */
|
|
32
|
+
sizeBytes?: string;
|
|
33
|
+
/** The Artifact this one describes, for an SBOM, provenance, or signature. */
|
|
34
|
+
subject?: string;
|
|
35
|
+
/** Digests of the sources and inputs that produced it. */
|
|
36
|
+
sourceDigests?: string[];
|
|
37
|
+
/** The builder identity (a SPIFFE id) that produced it. */
|
|
38
|
+
readonly builder?: string;
|
|
39
|
+
/** The newest SBOM whose subject is this Artifact. */
|
|
40
|
+
readonly sbom?: string;
|
|
41
|
+
/** The newest provenance attestation whose subject is this Artifact. */
|
|
42
|
+
readonly provenance?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the signature and provenance verified. Evidence, never
|
|
45
|
+
* identity: a failure does not change the digest.
|
|
46
|
+
*/
|
|
47
|
+
readonly verificationState?: VerificationState;
|
|
48
|
+
/** When verification last ran. */
|
|
49
|
+
readonly verifyTime?: string;
|
|
50
|
+
/** How long the Artifact is kept. */
|
|
51
|
+
retention?: RetentionClass;
|
|
52
|
+
/** A legal hold is active; Delete fails. */
|
|
53
|
+
readonly legalHold?: boolean;
|
|
54
|
+
/** The regions the bytes are replicated to. */
|
|
55
|
+
readonly regions?: string[];
|
|
56
|
+
/**
|
|
57
|
+
* The OCI reference by digest to pull, for example
|
|
58
|
+
* `registry.sylphx.com/<project>@sha256:4f1c…`.
|
|
59
|
+
*/
|
|
60
|
+
readonly reference?: string;
|
|
61
|
+
}
|
|
62
|
+
/** The request of CreateArtifact. */
|
|
63
|
+
export interface CreateArtifactRequest {
|
|
64
|
+
/** The project to create in. */
|
|
65
|
+
parent: string;
|
|
66
|
+
/** The artifact to create; only spec and caller-writable metadata are read. */
|
|
67
|
+
artifact: Artifact;
|
|
68
|
+
/**
|
|
69
|
+
* The id of the new artifact, the digest with `-` for `:`; the server derives it from `digest` when empty; the server assigns one when
|
|
70
|
+
* empty.
|
|
71
|
+
*/
|
|
72
|
+
artifactId?: string;
|
|
73
|
+
/** Validate and return the result without writing anything. */
|
|
74
|
+
validateOnly?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** The request of DeleteArtifact. */
|
|
77
|
+
export interface DeleteArtifactRequest {
|
|
78
|
+
/** The name of the artifact to delete. */
|
|
79
|
+
name: string;
|
|
80
|
+
/** Delete only if the current etag matches. */
|
|
81
|
+
etag?: string;
|
|
82
|
+
/** Validate without deleting anything. */
|
|
83
|
+
validateOnly?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/** The request of GetArtifact. */
|
|
86
|
+
export interface GetArtifactRequest {
|
|
87
|
+
/** The name of the artifact to get. */
|
|
88
|
+
name: string;
|
|
89
|
+
}
|
|
90
|
+
/** The request of ListArtifacts. */
|
|
91
|
+
export interface ListArtifactsRequest {
|
|
92
|
+
/** The project to list in. */
|
|
93
|
+
parent: string;
|
|
94
|
+
/** At most this many; default 50, clamped to 1000. */
|
|
95
|
+
pageSize?: number;
|
|
96
|
+
/** `next_page_token` of the previous page. */
|
|
97
|
+
pageToken?: string;
|
|
98
|
+
/** AIP-160 filter over labels and filterable fields. */
|
|
99
|
+
filter?: string;
|
|
100
|
+
/** AIP-132 ordering over filterable fields. */
|
|
101
|
+
orderBy?: string;
|
|
102
|
+
}
|
|
103
|
+
/** The response of ListArtifacts. */
|
|
104
|
+
export interface ListArtifactsResponse {
|
|
105
|
+
/** The page. */
|
|
106
|
+
artifacts?: Artifact[];
|
|
107
|
+
/** The token of the next page; empty on the last page. */
|
|
108
|
+
nextPageToken?: string;
|
|
109
|
+
}
|
|
110
|
+
/** ArtifactKind is what an Artifact is. */
|
|
111
|
+
export type ArtifactKind = 'image' | 'sbom' | 'provenance' | 'signature' | 'bundle' | (string & {});
|
|
112
|
+
/** RetentionClass is how long an Artifact is kept. */
|
|
113
|
+
export type RetentionClass = 'standard' | 'referenced' | (string & {});
|
|
114
|
+
/** VerificationState is the result of verifying an Artifact. */
|
|
115
|
+
export type VerificationState = 'unverified' | 'pending' | 'verified' | 'failed' | (string & {});
|
|
116
|
+
/**
|
|
117
|
+
* ArtifactsService is Kernel Artifacts: immutable content by digest, with
|
|
118
|
+
* its SBOM and provenance. Sylphx Build writes them; Release reads them.
|
|
119
|
+
*
|
|
120
|
+
* Namespace of Sylphx Artifacts on `Sylphx`.
|
|
121
|
+
*/
|
|
122
|
+
export declare class ArtifactsApi {
|
|
123
|
+
/** The `artifacts` collection. */
|
|
124
|
+
readonly artifacts: ArtifactsCollection;
|
|
125
|
+
constructor(client: runtime.Client);
|
|
126
|
+
}
|
|
127
|
+
/** `artifacts` of Sylphx Artifacts: Resource type `artifacts.sylphx.com/Artifact`. */
|
|
128
|
+
export declare class ArtifactsCollection {
|
|
129
|
+
private readonly client;
|
|
130
|
+
constructor(client: runtime.Client);
|
|
131
|
+
/**
|
|
132
|
+
* Gets an artifact.
|
|
133
|
+
*
|
|
134
|
+
* `GET /v1/{name=orgs/*\/projects/*\/artifacts/*}` · permission `artifacts:read` · effect `read`
|
|
135
|
+
*
|
|
136
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
|
|
137
|
+
*/
|
|
138
|
+
get(request: GetArtifactRequest): Promise<Artifact>;
|
|
139
|
+
/**
|
|
140
|
+
* Lists a project's artifacts; filter by `digest`, `kind`, or `subject`.
|
|
141
|
+
*
|
|
142
|
+
* `GET /v1/{parent=orgs/*\/projects/*}/artifacts` · permission `artifacts:read` · effect `read`
|
|
143
|
+
*
|
|
144
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
|
|
145
|
+
*/
|
|
146
|
+
list(request: ListArtifactsRequest): Promise<ListArtifactsResponse>;
|
|
147
|
+
/** Every item of every page of `list`. */
|
|
148
|
+
listAll(request: ListArtifactsRequest): AsyncGenerator<Artifact>;
|
|
149
|
+
/**
|
|
150
|
+
* Registers an artifact whose bytes were pushed by digest; verification runs after.
|
|
151
|
+
*
|
|
152
|
+
* `POST /v1/{parent=orgs/*\/projects/*}/artifacts` · permission `artifacts:write` · effect `write`
|
|
153
|
+
*
|
|
154
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `RESOURCE_ALREADY_EXISTS`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `PLAN_LIMIT_REACHED`.
|
|
155
|
+
*/
|
|
156
|
+
create(request: CreateArtifactRequest): Promise<Artifact>;
|
|
157
|
+
/**
|
|
158
|
+
* Deletes an artifact; fails while a Release references it or a legal hold is active.
|
|
159
|
+
*
|
|
160
|
+
* `DELETE /v1/{name=orgs/*\/projects/*\/artifacts/*}` · permission `artifacts:write` · effect `destructive`
|
|
161
|
+
*
|
|
162
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
|
|
163
|
+
*/
|
|
164
|
+
delete(request: DeleteArtifactRequest): Promise<Record<string, never>>;
|
|
165
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// @generated by sylphx-gen 0.1.0 from contracts@446ceb843d4ff88057b0db68e2e54e4aea52d8143b72d66016122995b878de20. Do not edit.
|
|
2
|
+
// `sylphx.artifacts.v1`.
|
|
3
|
+
import * as runtime from './runtime.js';
|
|
4
|
+
import './common.js';
|
|
5
|
+
runtime.registerSchemas({
|
|
6
|
+
'sylphx.artifacts.v1.Artifact': [
|
|
7
|
+
['meta', 'meta', 'sylphx.common.v1.ResourceMeta'],
|
|
8
|
+
['mediaType', 'media_type'],
|
|
9
|
+
['sizeBytes', 'size_bytes'],
|
|
10
|
+
['sourceDigests', 'source_digests'],
|
|
11
|
+
['verificationState', 'verification_state'],
|
|
12
|
+
['verifyTime', 'verify_time'],
|
|
13
|
+
['legalHold', 'legal_hold'],
|
|
14
|
+
],
|
|
15
|
+
'sylphx.artifacts.v1.CreateArtifactRequest': [
|
|
16
|
+
['artifact', 'artifact', 'sylphx.artifacts.v1.Artifact'],
|
|
17
|
+
['artifactId', 'artifact_id'],
|
|
18
|
+
['validateOnly', 'validate_only'],
|
|
19
|
+
],
|
|
20
|
+
'sylphx.artifacts.v1.DeleteArtifactRequest': [
|
|
21
|
+
['validateOnly', 'validate_only'],
|
|
22
|
+
],
|
|
23
|
+
'sylphx.artifacts.v1.GetArtifactRequest': [],
|
|
24
|
+
'sylphx.artifacts.v1.ListArtifactsRequest': [
|
|
25
|
+
['pageSize', 'page_size'],
|
|
26
|
+
['pageToken', 'page_token'],
|
|
27
|
+
['orderBy', 'order_by'],
|
|
28
|
+
],
|
|
29
|
+
'sylphx.artifacts.v1.ListArtifactsResponse': [
|
|
30
|
+
['artifacts', 'artifacts', 'sylphx.artifacts.v1.Artifact'],
|
|
31
|
+
['nextPageToken', 'next_page_token'],
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* ArtifactsService is Kernel Artifacts: immutable content by digest, with
|
|
36
|
+
* its SBOM and provenance. Sylphx Build writes them; Release reads them.
|
|
37
|
+
*
|
|
38
|
+
* Namespace of Sylphx Artifacts on `Sylphx`.
|
|
39
|
+
*/
|
|
40
|
+
export class ArtifactsApi {
|
|
41
|
+
/** The `artifacts` collection. */
|
|
42
|
+
artifacts;
|
|
43
|
+
constructor(client) {
|
|
44
|
+
this.artifacts = new ArtifactsCollection(client);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** `artifacts` of Sylphx Artifacts: Resource type `artifacts.sylphx.com/Artifact`. */
|
|
48
|
+
export class ArtifactsCollection {
|
|
49
|
+
client;
|
|
50
|
+
constructor(client) {
|
|
51
|
+
this.client = client;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets an artifact.
|
|
55
|
+
*
|
|
56
|
+
* `GET /v1/{name=orgs/*\/projects/*\/artifacts/*}` · permission `artifacts:read` · effect `read`
|
|
57
|
+
*
|
|
58
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
|
|
59
|
+
*/
|
|
60
|
+
async get(request) {
|
|
61
|
+
return this.client.call({
|
|
62
|
+
method: 'GET',
|
|
63
|
+
path: `/v1/${runtime.pathParam(request.name, 'orgs/*/projects/*/artifacts/*', 'name')}`,
|
|
64
|
+
responseType: 'sylphx.artifacts.v1.Artifact',
|
|
65
|
+
mutation: false,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Lists a project's artifacts; filter by `digest`, `kind`, or `subject`.
|
|
70
|
+
*
|
|
71
|
+
* `GET /v1/{parent=orgs/*\/projects/*}/artifacts` · permission `artifacts:read` · effect `read`
|
|
72
|
+
*
|
|
73
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
|
|
74
|
+
*/
|
|
75
|
+
async list(request) {
|
|
76
|
+
return this.client.call({
|
|
77
|
+
method: 'GET',
|
|
78
|
+
path: `/v1/${runtime.pathParam(request.parent, 'orgs/*/projects/*', 'parent')}/artifacts`,
|
|
79
|
+
query: { page_size: request.pageSize, page_token: request.pageToken, filter: request.filter, order_by: request.orderBy },
|
|
80
|
+
responseType: 'sylphx.artifacts.v1.ListArtifactsResponse',
|
|
81
|
+
mutation: false,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** Every item of every page of `list`. */
|
|
85
|
+
async *listAll(request) {
|
|
86
|
+
let next = request;
|
|
87
|
+
for (;;) {
|
|
88
|
+
const page = await this.list(next);
|
|
89
|
+
yield* page.artifacts ?? [];
|
|
90
|
+
if (page.nextPageToken === undefined || page.nextPageToken === '')
|
|
91
|
+
return;
|
|
92
|
+
next = { ...request, pageToken: page.nextPageToken };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Registers an artifact whose bytes were pushed by digest; verification runs after.
|
|
97
|
+
*
|
|
98
|
+
* `POST /v1/{parent=orgs/*\/projects/*}/artifacts` · permission `artifacts:write` · effect `write`
|
|
99
|
+
*
|
|
100
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `RESOURCE_ALREADY_EXISTS`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `PLAN_LIMIT_REACHED`.
|
|
101
|
+
*/
|
|
102
|
+
async create(request) {
|
|
103
|
+
return this.client.call({
|
|
104
|
+
method: 'POST',
|
|
105
|
+
path: `/v1/${runtime.pathParam(request.parent, 'orgs/*/projects/*', 'parent')}/artifacts`,
|
|
106
|
+
query: { artifact_id: request.artifactId, validate_only: request.validateOnly },
|
|
107
|
+
body: request.artifact ?? {},
|
|
108
|
+
bodyType: 'sylphx.artifacts.v1.Artifact',
|
|
109
|
+
responseType: 'sylphx.artifacts.v1.Artifact',
|
|
110
|
+
mutation: true,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Deletes an artifact; fails while a Release references it or a legal hold is active.
|
|
115
|
+
*
|
|
116
|
+
* `DELETE /v1/{name=orgs/*\/projects/*\/artifacts/*}` · permission `artifacts:write` · effect `destructive`
|
|
117
|
+
*
|
|
118
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
|
|
119
|
+
*/
|
|
120
|
+
async delete(request) {
|
|
121
|
+
return this.client.call({
|
|
122
|
+
method: 'DELETE',
|
|
123
|
+
path: `/v1/${runtime.pathParam(request.name, 'orgs/*/projects/*/artifacts/*', 'name')}`,
|
|
124
|
+
query: { etag: request.etag, validate_only: request.validateOnly },
|
|
125
|
+
mutation: true,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAC/H,yBAAyB;AAEzB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,aAAa,CAAA;AA4HpB,OAAO,CAAC,eAAe,CAAC;IACvB,8BAA8B,EAAE;QAC/B,CAAC,MAAM,EAAE,MAAM,EAAE,+BAA+B,CAAC;QACjD,CAAC,WAAW,EAAE,YAAY,CAAC;QAC3B,CAAC,WAAW,EAAE,YAAY,CAAC;QAC3B,CAAC,eAAe,EAAE,gBAAgB,CAAC;QACnC,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;QAC3C,CAAC,YAAY,EAAE,aAAa,CAAC;QAC7B,CAAC,WAAW,EAAE,YAAY,CAAC;KAC3B;IACD,2CAA2C,EAAE;QAC5C,CAAC,UAAU,EAAE,UAAU,EAAE,8BAA8B,CAAC;QACxD,CAAC,YAAY,EAAE,aAAa,CAAC;QAC7B,CAAC,cAAc,EAAE,eAAe,CAAC;KACjC;IACD,2CAA2C,EAAE;QAC5C,CAAC,cAAc,EAAE,eAAe,CAAC;KACjC;IACD,wCAAwC,EAAE,EAAE;IAC5C,0CAA0C,EAAE;QAC3C,CAAC,UAAU,EAAE,WAAW,CAAC;Q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MAAM,CAAC,EAAE;YACvF,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,YAAY,EAAE;YAClE,QAAQ,EAAE,IAAI;SACd,CAAC,CAAA;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offline verification of tokens Sylphx signs: Auth session tokens and
|
|
3
|
+
* service-to-service invocation tokens. A token is a compact JWS (ES256 or
|
|
4
|
+
* EdDSA) whose key is published in the issuer's JWKS; verification needs no
|
|
5
|
+
* call to Sylphx once the key set is cached. WebCrypto only (Node 20+,
|
|
6
|
+
* browsers, workers); no dependencies.
|
|
7
|
+
*
|
|
8
|
+
* import { createVerifier } from '@sylphx/sdk/auth/verify'
|
|
9
|
+
* const verify = createVerifier({ issuer: 'https://api.sylphx.com', audience: 'my-app' })
|
|
10
|
+
* const claims = await verify(token) // throws VerifyError
|
|
11
|
+
*
|
|
12
|
+
* `verifyWithKeys` is the pure core (caller-supplied keys and time).
|
|
13
|
+
*/
|
|
14
|
+
export type VerifyErrorCode = 'malformed' | 'algorithm' | 'unknown_key' | 'signature' | 'expired' | 'issuer' | 'audience' | 'keys';
|
|
15
|
+
/** Why a token was refused. Every code means "do not trust this token". */
|
|
16
|
+
export declare class VerifyError extends Error {
|
|
17
|
+
readonly code: VerifyErrorCode;
|
|
18
|
+
constructor(code: VerifyErrorCode, message: string);
|
|
19
|
+
}
|
|
20
|
+
export interface Expect {
|
|
21
|
+
issuer: string;
|
|
22
|
+
/** Accepted audiences; the token must name at least one. Empty accepts any. */
|
|
23
|
+
audience?: string | string[];
|
|
24
|
+
/** Clock skew tolerated on exp, nbf, and iat, in seconds. Default 60. */
|
|
25
|
+
leewaySeconds?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface Jwk {
|
|
28
|
+
kid?: string;
|
|
29
|
+
kty: string;
|
|
30
|
+
crv?: string;
|
|
31
|
+
x?: string;
|
|
32
|
+
y?: string;
|
|
33
|
+
alg?: string;
|
|
34
|
+
use?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface Jwks {
|
|
37
|
+
keys: Jwk[];
|
|
38
|
+
}
|
|
39
|
+
export type Claims = Record<string, unknown> & {
|
|
40
|
+
sub?: string;
|
|
41
|
+
exp?: number;
|
|
42
|
+
};
|
|
43
|
+
/** The token's `kid`, without verifying anything. */
|
|
44
|
+
export declare function keyId(token: string): string;
|
|
45
|
+
/** Verifies `token` against `keys` at `now` (Unix seconds). */
|
|
46
|
+
export declare function verifyWithKeys(token: string, keys: Jwks, expect: Expect, now: number): Promise<Claims>;
|
|
47
|
+
export interface VerifierOptions extends Expect {
|
|
48
|
+
/** Default `{issuer}/v1/oauth/jwks.json`. */
|
|
49
|
+
jwksUrl?: string;
|
|
50
|
+
fetch?: typeof fetch;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Keys are kept 10 minutes. An unknown `kid` refetches the set at once, but at
|
|
54
|
+
* most once every 30 s, so rotation is picked up and bad `kid`s cannot hammer
|
|
55
|
+
* the issuer.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createVerifier(options: VerifierOptions): (token: string) => Promise<Claims>;
|