@sylphx/sdk 0.31.0 → 0.32.1
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/README.md +131 -4
- package/dist/access.d.ts +146 -17
- package/dist/access.js +114 -8
- package/dist/access.js.map +1 -1
- package/dist/agents.d.ts +1564 -0
- package/dist/agents.js +1096 -0
- package/dist/agents.js.map +1 -0
- package/dist/ai.d.ts +1 -2
- package/dist/ai.js +2 -3
- package/dist/ai.js.map +1 -1
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +2 -2
- package/dist/assets.d.ts +447 -0
- package/dist/assets.js +266 -0
- package/dist/assets.js.map +1 -0
- package/dist/auth/client.d.ts +239 -0
- package/dist/auth/client.js +337 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/end-user-keys-mock.d.ts +83 -0
- package/dist/auth/end-user-keys-mock.js +427 -0
- package/dist/auth/end-user-keys-mock.js.map +1 -0
- package/dist/auth/end-user-keys.d.ts +219 -0
- package/dist/auth/end-user-keys.js +240 -0
- package/dist/auth/end-user-keys.js.map +1 -0
- package/dist/auth/verify.d.ts +38 -3
- package/dist/auth/verify.js +58 -8
- package/dist/auth/verify.js.map +1 -1
- package/dist/auth.d.ts +656 -9
- package/dist/auth.js +563 -6
- package/dist/auth.js.map +1 -1
- package/dist/billing.d.ts +99 -21
- package/dist/billing.js +43 -5
- package/dist/billing.js.map +1 -1
- package/dist/broker.d.ts +5 -4
- package/dist/broker.js +3 -3
- package/dist/broker.js.map +1 -1
- package/dist/build.d.ts +362 -29
- package/dist/build.js +302 -10
- package/dist/build.js.map +1 -1
- package/dist/common.d.ts +1 -1
- package/dist/common.js +1 -1
- package/dist/config/flags.d.ts +140 -0
- package/dist/config/flags.js +462 -0
- package/dist/config/flags.js.map +1 -0
- package/dist/config.d.ts +380 -15
- package/dist/config.js +283 -5
- package/dist/config.js.map +1 -1
- package/dist/connections.d.ts +6 -6
- package/dist/connections.js +3 -3
- package/dist/data.d.ts +612 -7
- package/dist/data.js +566 -4
- package/dist/data.js.map +1 -1
- package/dist/entitlement.d.ts +10 -8
- package/dist/entitlement.js +3 -4
- package/dist/entitlement.js.map +1 -1
- package/dist/events/realtime.d.ts +69 -0
- package/dist/events/realtime.js +107 -0
- package/dist/events/realtime.js.map +1 -0
- package/dist/events/webhooks.d.ts +40 -0
- package/dist/events/webhooks.js +110 -0
- package/dist/events/webhooks.js.map +1 -0
- package/dist/events.d.ts +369 -22
- package/dist/events.js +311 -8
- package/dist/events.js.map +1 -1
- package/dist/flags.d.ts +18 -0
- package/dist/flags.js +44 -0
- package/dist/flags.js.map +1 -0
- package/dist/hosting.d.ts +13 -14
- package/dist/hosting.js +3 -4
- package/dist/hosting.js.map +1 -1
- package/dist/ids.d.ts +987 -0
- package/dist/ids.js +317 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +25 -1
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/dist/keys.d.ts +2 -2
- package/dist/keys.js +3 -3
- package/dist/knowledge.d.ts +1192 -0
- package/dist/knowledge.js +1002 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/localization.d.ts +663 -0
- package/dist/localization.js +491 -0
- package/dist/localization.js.map +1 -0
- package/dist/methods.js +3251 -133
- package/dist/methods.js.map +1 -1
- package/dist/money.d.ts +3086 -0
- package/dist/money.js +2358 -0
- package/dist/money.js.map +1 -0
- package/dist/network.d.ts +4 -5
- package/dist/network.js +3 -4
- package/dist/network.js.map +1 -1
- package/dist/notify.d.ts +667 -125
- package/dist/notify.js +471 -73
- package/dist/notify.js.map +1 -1
- package/dist/observability.d.ts +322 -7
- package/dist/observability.js +244 -8
- package/dist/observability.js.map +1 -1
- package/dist/realtime.d.ts +404 -0
- package/dist/realtime.js +312 -0
- package/dist/realtime.js.map +1 -0
- package/dist/release.d.ts +14 -15
- package/dist/release.js +3 -4
- package/dist/release.js.map +1 -1
- package/dist/runners.d.ts +2 -3
- package/dist/runners.js +3 -4
- package/dist/runners.js.map +1 -1
- package/dist/runtime.d.ts +5 -1
- package/dist/runtime.js +7 -3
- package/dist/runtime.js.map +1 -1
- package/dist/sandboxes.d.ts +64 -20
- package/dist/sandboxes.js +9 -4
- package/dist/sandboxes.js.map +1 -1
- package/dist/secrets.d.ts +342 -6
- package/dist/secrets.js +271 -4
- package/dist/secrets.js.map +1 -1
- package/dist/workflows.d.ts +969 -15
- package/dist/workflows.js +815 -6
- package/dist/workflows.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
// @generated by sylphx-gen 0.1.0 from contracts@c8a7361c53e572321b0ec9fb014fd1e8279b007b62562423038e0d0e5b9d767a. Do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* A browser client for Sylphx Auth's client API (`/v1/client/*`). It holds a
|
|
4
|
+
* publishable key (public by design), never a secret, and the session is a
|
|
5
|
+
* bearer token (`session_mode: "browser"`). There is no cookie mode: apps that
|
|
6
|
+
* want an HttpOnly cookie redeem the sign-in ticket on their own backend with
|
|
7
|
+
* the secret key. Zero dependencies (`fetch` only).
|
|
8
|
+
*
|
|
9
|
+
* import { createAuthClient } from '@sylphx/sdk/auth/client'
|
|
10
|
+
* const auth = createAuthClient({ publishableKey: 'sylphx_pk_live_...' })
|
|
11
|
+
* const { session, user } = await auth.signInWithPassword({ email, password })
|
|
12
|
+
*
|
|
13
|
+
* Every call carries the key (`publishable_key`, or `instance`) in its query
|
|
14
|
+
* string: a browser preflight has no `Authorization`, so the query is the only
|
|
15
|
+
* place the service can learn the environment before it answers CORS. The two
|
|
16
|
+
* privacy GET routes are the exception: the service rejects unknown query
|
|
17
|
+
* fields there and resolves the environment from the session bearer alone, so
|
|
18
|
+
* they carry only `organization_id` (and `include_export`).
|
|
19
|
+
*
|
|
20
|
+
* Errors: every failure is an `AuthClientError` (match on `code`, or
|
|
21
|
+
* `instanceof`) with the HTTP `status`. The code is the service's `code`
|
|
22
|
+
* (`invalid_request`, `unauthorized`, `mfa_required`, `forbidden`, `not_found`,
|
|
23
|
+
* `conflict`, `locked_out`, `rate_limited`, `internal`, `store_unavailable`);
|
|
24
|
+
* a body that is not JSON (or has no `code`) yields `http_<status>`. A
|
|
25
|
+
* transport failure is `AuthNetworkError`.
|
|
26
|
+
*
|
|
27
|
+
* TODO(auth/client-api-contract): this client is hand-written from the Auth
|
|
28
|
+
* service source. When Identity's official contract and served OpenAPI list
|
|
29
|
+
* every `/v1/client` route (branch `auth/client-api-contract`; source
|
|
30
|
+
* identity.proto -> identity-contract-build ->
|
|
31
|
+
* services/auth/generated/product-contract.bundle.json, the client-API
|
|
32
|
+
* OpenAPI, and docs/services/auth/client-api*.md; due 2026-10-10), add a
|
|
33
|
+
* drift test that fails when a route, field or error code here differs from
|
|
34
|
+
* it, then delete /scratch/web-lead/auth-client-contract.md.
|
|
35
|
+
*/
|
|
36
|
+
/** Base of every error the client raises. Match on `code`, or `instanceof`. */
|
|
37
|
+
export class AuthClientError extends Error {
|
|
38
|
+
code;
|
|
39
|
+
status;
|
|
40
|
+
authority;
|
|
41
|
+
/** Seconds from `Retry-After`, on `locked_out` and `rate_limited`. */
|
|
42
|
+
retryAfterSeconds;
|
|
43
|
+
constructor(code, status, message, authority, retryAfterSeconds) {
|
|
44
|
+
super(message);
|
|
45
|
+
this.name = new.target.name;
|
|
46
|
+
this.code = code;
|
|
47
|
+
this.status = status;
|
|
48
|
+
this.authority = authority;
|
|
49
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
50
|
+
}
|
|
51
|
+
get retryable() {
|
|
52
|
+
return this.status === 429 || this.status === 503;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class AuthInvalidRequestError extends AuthClientError {
|
|
56
|
+
}
|
|
57
|
+
export class AuthUnauthorizedError extends AuthClientError {
|
|
58
|
+
}
|
|
59
|
+
export class AuthMfaRequiredError extends AuthClientError {
|
|
60
|
+
}
|
|
61
|
+
export class AuthForbiddenError extends AuthClientError {
|
|
62
|
+
}
|
|
63
|
+
export class AuthNotFoundError extends AuthClientError {
|
|
64
|
+
}
|
|
65
|
+
export class AuthConflictError extends AuthClientError {
|
|
66
|
+
}
|
|
67
|
+
export class AuthLockedOutError extends AuthClientError {
|
|
68
|
+
}
|
|
69
|
+
export class AuthRateLimitedError extends AuthClientError {
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The key in the query names a different environment than the session bearer;
|
|
73
|
+
* the session wins and the call is refused. The service has no dedicated code
|
|
74
|
+
* for this yet, so both spellings are matched and any other refusal keeps
|
|
75
|
+
* its own class (`forbidden` / `unauthorized`).
|
|
76
|
+
*/
|
|
77
|
+
export class AuthEnvironmentMismatchError extends AuthClientError {
|
|
78
|
+
}
|
|
79
|
+
export class AuthInternalError extends AuthClientError {
|
|
80
|
+
}
|
|
81
|
+
export class AuthUnavailableError extends AuthClientError {
|
|
82
|
+
}
|
|
83
|
+
/** The request never got an answer: offline, DNS, or a CORS refusal. */
|
|
84
|
+
export class AuthNetworkError extends AuthClientError {
|
|
85
|
+
cause;
|
|
86
|
+
constructor(message, cause) {
|
|
87
|
+
super('network_error', 0, message);
|
|
88
|
+
this.cause = cause;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const ERROR_CLASSES = {
|
|
92
|
+
invalid_request: AuthInvalidRequestError,
|
|
93
|
+
unauthorized: AuthUnauthorizedError,
|
|
94
|
+
mfa_required: AuthMfaRequiredError,
|
|
95
|
+
forbidden: AuthForbiddenError,
|
|
96
|
+
not_found: AuthNotFoundError,
|
|
97
|
+
conflict: AuthConflictError,
|
|
98
|
+
locked_out: AuthLockedOutError,
|
|
99
|
+
rate_limited: AuthRateLimitedError,
|
|
100
|
+
environment_mismatch: AuthEnvironmentMismatchError,
|
|
101
|
+
instance_mismatch: AuthEnvironmentMismatchError,
|
|
102
|
+
internal: AuthInternalError,
|
|
103
|
+
store_unavailable: AuthUnavailableError,
|
|
104
|
+
};
|
|
105
|
+
const PUBLISHABLE_PREFIX = 'sylphx_pk_';
|
|
106
|
+
const DEFAULT_BASE_URL = 'https://api.sylphx.com';
|
|
107
|
+
/** Throws unless `key` is a publishable key. Secret keys never reach a browser. */
|
|
108
|
+
export function assertPublishableKey(key) {
|
|
109
|
+
if (typeof key !== 'string' || !key.startsWith(PUBLISHABLE_PREFIX)) {
|
|
110
|
+
const secret = typeof key === 'string' && (key.startsWith('sylphx_sk_') || key.startsWith('identity_org_key_'));
|
|
111
|
+
throw new TypeError(secret
|
|
112
|
+
? 'a secret key must never be given to the browser auth client; use a publishable key (sylphx_pk_...)'
|
|
113
|
+
: 'publishableKey must start with sylphx_pk_');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Sets the environment reference on a URL: one `publishable_key` (or
|
|
118
|
+
* `instance`) parameter, replacing any the URL already had, all other query
|
|
119
|
+
* kept. Pure; exported for tests and custom transports.
|
|
120
|
+
*/
|
|
121
|
+
export function withEnvironment(url, name, value) {
|
|
122
|
+
const hash = url.indexOf('#');
|
|
123
|
+
const fragment = hash >= 0 ? url.slice(hash) : '';
|
|
124
|
+
const rest = hash >= 0 ? url.slice(0, hash) : url;
|
|
125
|
+
const q = rest.indexOf('?');
|
|
126
|
+
const path = q >= 0 ? rest.slice(0, q) : rest;
|
|
127
|
+
const params = new URLSearchParams(q >= 0 ? rest.slice(q + 1) : '');
|
|
128
|
+
params.delete(name);
|
|
129
|
+
params.append(name, value);
|
|
130
|
+
return `${path}?${params.toString()}${fragment}`;
|
|
131
|
+
}
|
|
132
|
+
const user = (w) => ({
|
|
133
|
+
id: w.id,
|
|
134
|
+
email: w.email,
|
|
135
|
+
name: w.name,
|
|
136
|
+
emailVerified: w.email_verified,
|
|
137
|
+
});
|
|
138
|
+
const signIn = (w) => ({
|
|
139
|
+
session: { id: w.session.id, token: w.session.token, expiresAt: w.session.expires_at },
|
|
140
|
+
user: user(w.user),
|
|
141
|
+
});
|
|
142
|
+
const privacy = (w) => ({
|
|
143
|
+
requestId: w.request_id,
|
|
144
|
+
state: w.state,
|
|
145
|
+
organizationId: w.organization_id,
|
|
146
|
+
principalId: w.principal_id,
|
|
147
|
+
requestType: w.request_type,
|
|
148
|
+
requestedAtUnixSeconds: w.requested_at_unix_seconds,
|
|
149
|
+
completedAtUnixSeconds: w.completed_at_unix_seconds,
|
|
150
|
+
storeRows: w.store_rows ?? [],
|
|
151
|
+
exemptStores: w.exempt_stores ?? [],
|
|
152
|
+
exportExpiresAtUnixSeconds: w.export_expires_at_unix_seconds,
|
|
153
|
+
attempts: w.attempts,
|
|
154
|
+
lastError: w.last_error,
|
|
155
|
+
});
|
|
156
|
+
export function createAuthClient(options) {
|
|
157
|
+
const { publishableKey, instance } = options;
|
|
158
|
+
if ((publishableKey === undefined) === (instance === undefined)) {
|
|
159
|
+
throw new TypeError('give exactly one of publishableKey or instance');
|
|
160
|
+
}
|
|
161
|
+
if (publishableKey !== undefined)
|
|
162
|
+
assertPublishableKey(publishableKey);
|
|
163
|
+
const base = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
164
|
+
const doFetch = options.fetch ?? ((input, init) => fetch(input, init));
|
|
165
|
+
const credentials = options.credentials ?? 'omit';
|
|
166
|
+
const reference = publishableKey !== undefined ? ['publishable_key', publishableKey] : ['instance', instance];
|
|
167
|
+
let token = options.sessionToken;
|
|
168
|
+
function url(path, query = {}, environment = true) {
|
|
169
|
+
const params = new URLSearchParams();
|
|
170
|
+
for (const [k, v] of Object.entries(query))
|
|
171
|
+
if (v !== undefined)
|
|
172
|
+
params.append(k, String(v));
|
|
173
|
+
const qs = params.toString();
|
|
174
|
+
const target = `${base}${path}${qs === '' ? '' : `?${qs}`}`;
|
|
175
|
+
return environment ? withEnvironment(target, reference[0], reference[1]) : target;
|
|
176
|
+
}
|
|
177
|
+
async function fail(res) {
|
|
178
|
+
let body = {};
|
|
179
|
+
try {
|
|
180
|
+
body = await res.json();
|
|
181
|
+
}
|
|
182
|
+
catch { }
|
|
183
|
+
const code = typeof body.code === 'string' ? body.code : `http_${res.status}`;
|
|
184
|
+
const raw = res.headers.get('retry-after');
|
|
185
|
+
const retry = raw !== null && /^\d+$/.test(raw.trim()) ? Number(raw) : undefined;
|
|
186
|
+
const Cls = ERROR_CLASSES[code] ?? AuthClientError;
|
|
187
|
+
throw new Cls(code, res.status, typeof body.error === 'string' ? body.error : res.statusText, body.authority, retry);
|
|
188
|
+
}
|
|
189
|
+
async function send(method, target, opts = {}) {
|
|
190
|
+
const headers = {};
|
|
191
|
+
if (opts.body !== undefined)
|
|
192
|
+
headers['content-type'] = 'application/json';
|
|
193
|
+
if (opts.session) {
|
|
194
|
+
if (token === undefined)
|
|
195
|
+
throw new AuthUnauthorizedError('unauthorized', 401, 'not signed in');
|
|
196
|
+
headers.authorization = `Bearer ${token}`;
|
|
197
|
+
}
|
|
198
|
+
let res;
|
|
199
|
+
try {
|
|
200
|
+
res = await doFetch(target, {
|
|
201
|
+
method,
|
|
202
|
+
headers,
|
|
203
|
+
credentials,
|
|
204
|
+
body: opts.body === undefined ? undefined : JSON.stringify(opts.body),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
catch (cause) {
|
|
208
|
+
throw new AuthNetworkError(cause instanceof Error ? cause.message : 'network error', cause);
|
|
209
|
+
}
|
|
210
|
+
if (!res.ok)
|
|
211
|
+
await fail(res);
|
|
212
|
+
return res;
|
|
213
|
+
}
|
|
214
|
+
const json = async (res) => (await res.json());
|
|
215
|
+
function remember(result) {
|
|
216
|
+
token = result.session.token;
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
/** GET /v1/client/config: methods, social providers, branding. */
|
|
221
|
+
async config() {
|
|
222
|
+
const w = await json(await send('GET', url('/v1/client/config')));
|
|
223
|
+
return {
|
|
224
|
+
instance: w.instance,
|
|
225
|
+
methods: w.methods,
|
|
226
|
+
social: (w.social ?? []).map((s) => ({
|
|
227
|
+
provider: s.provider,
|
|
228
|
+
name: s.name,
|
|
229
|
+
credentials: s.credentials,
|
|
230
|
+
startUrl: s.start_url,
|
|
231
|
+
})),
|
|
232
|
+
branding: { name: w.branding.name, logoUrl: w.branding.logo_url, primaryColor: w.branding.primary_color },
|
|
233
|
+
localization: { defaultLocale: w.localization.default_locale, locales: w.localization.locales },
|
|
234
|
+
apiOrigin: w.api_origin,
|
|
235
|
+
ticketParam: w.ticket_param,
|
|
236
|
+
errorParam: w.error_param,
|
|
237
|
+
};
|
|
238
|
+
},
|
|
239
|
+
/** POST /v1/client/sign-in/password with `session_mode: "browser"`. Throws `AuthMfaRequiredError` for MFA users; retry with `factorProofs`. */
|
|
240
|
+
async signInWithPassword(input) {
|
|
241
|
+
const res = await send('POST', url('/v1/client/sign-in/password'), {
|
|
242
|
+
body: {
|
|
243
|
+
email: input.email,
|
|
244
|
+
password: input.password,
|
|
245
|
+
factor_proofs: (input.factorProofs ?? []).map((p) => ({
|
|
246
|
+
factor_type: p.factorType,
|
|
247
|
+
factor_id: p.factorId,
|
|
248
|
+
response: p.response,
|
|
249
|
+
})),
|
|
250
|
+
captcha_token: input.captchaToken ?? '',
|
|
251
|
+
session_mode: 'browser',
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
return remember(signIn(await json(res)));
|
|
255
|
+
},
|
|
256
|
+
/** POST /v1/client/sign-up (202). The answer never says whether the email had an account. */
|
|
257
|
+
async signUp(input) {
|
|
258
|
+
await send('POST', url('/v1/client/sign-up'), {
|
|
259
|
+
body: {
|
|
260
|
+
email: input.email,
|
|
261
|
+
password: input.password,
|
|
262
|
+
name: input.name ?? '',
|
|
263
|
+
redirect_url: input.redirectUrl ?? '',
|
|
264
|
+
captcha_token: input.captchaToken ?? '',
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
return { accepted: true };
|
|
268
|
+
},
|
|
269
|
+
/**
|
|
270
|
+
* The URL to navigate to (`location.assign`) to start a social sign-in.
|
|
271
|
+
* It is a redirect, not a fetch. The callback appends `auth_ticket`
|
|
272
|
+
* (redeem it with `redeemTicket`) or `auth_error` to `redirectUrl`.
|
|
273
|
+
*/
|
|
274
|
+
oauthStartUrl(provider, input) {
|
|
275
|
+
return url(`/v1/client/oauth/${encodeURIComponent(provider)}/start`, {
|
|
276
|
+
redirect_url: input.redirectUrl,
|
|
277
|
+
session_mode: 'browser',
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
/** POST /v1/client/tickets:redeem: a browser-mode ticket becomes a session. */
|
|
281
|
+
async redeemTicket(ticket) {
|
|
282
|
+
return remember(signIn(await json(await send('POST', url('/v1/client/tickets:redeem'), { body: { ticket } }))));
|
|
283
|
+
},
|
|
284
|
+
/** GET /v1/client/session. */
|
|
285
|
+
async getSession() {
|
|
286
|
+
const w = await json(await send('GET', url('/v1/client/session'), { session: true }));
|
|
287
|
+
return {
|
|
288
|
+
session: { id: w.session.id, expiresAt: w.session.expires_at, instanceId: w.session.instance_id },
|
|
289
|
+
user: user(w.user),
|
|
290
|
+
};
|
|
291
|
+
},
|
|
292
|
+
/** POST /v1/client/sign-out (204, idempotent). Forgets the token. */
|
|
293
|
+
async signOut() {
|
|
294
|
+
if (token === undefined)
|
|
295
|
+
return;
|
|
296
|
+
await send('POST', url('/v1/client/sign-out'), { session: true });
|
|
297
|
+
token = undefined;
|
|
298
|
+
},
|
|
299
|
+
/** The held session token, if any. */
|
|
300
|
+
get sessionToken() {
|
|
301
|
+
return token;
|
|
302
|
+
},
|
|
303
|
+
setSessionToken(next) {
|
|
304
|
+
token = next;
|
|
305
|
+
},
|
|
306
|
+
privacyRequests: {
|
|
307
|
+
/** POST /v1/client/privacy-requests (202). `requestType` is `delete` or `export`. */
|
|
308
|
+
async create(input) {
|
|
309
|
+
const w = await json(await send('POST', url('/v1/client/privacy-requests'), {
|
|
310
|
+
session: true,
|
|
311
|
+
body: {
|
|
312
|
+
idempotency_key: input.idempotencyKey,
|
|
313
|
+
principal_id: input.principalId,
|
|
314
|
+
request_type: input.requestType,
|
|
315
|
+
organization_id: input.organizationId,
|
|
316
|
+
},
|
|
317
|
+
}));
|
|
318
|
+
return privacy(w.privacy_request);
|
|
319
|
+
},
|
|
320
|
+
/** GET /v1/client/privacy-requests/{id}. */
|
|
321
|
+
async get(requestId, input) {
|
|
322
|
+
const w = await json(await send('GET', url(`/v1/client/privacy-requests/${encodeURIComponent(requestId)}`, {
|
|
323
|
+
organization_id: input.organizationId,
|
|
324
|
+
include_export: input.includeExport === true ? true : undefined,
|
|
325
|
+
}, false), { session: true }));
|
|
326
|
+
return { privacyRequest: privacy(w.privacy_request), exportJson: w.export_json };
|
|
327
|
+
},
|
|
328
|
+
/** GET /v1/client/privacy-requests/{id}/export: the export document. */
|
|
329
|
+
async export(requestId, input) {
|
|
330
|
+
return json(await send('GET', url(`/v1/client/privacy-requests/${encodeURIComponent(requestId)}/export`, {
|
|
331
|
+
organization_id: input.organizationId,
|
|
332
|
+
}, false), { session: true }));
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/auth/client.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAC/H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAeH,+EAA+E;AAC/E,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAChC,IAAI,CAAqB;IACzB,MAAM,CAAQ;IACd,SAAS,CAAoB;IACtC,sEAAsE;IAC7D,iBAAiB,CAAoB;IAE9C,YACC,IAAyB,EACzB,MAAc,EACd,OAAe,EACf,SAAkB,EAClB,iBAA0B;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,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th end-user key methods, for apps
|
|
3
|
+
* that build against the contract before (or without) the service:
|
|
4
|
+
*
|
|
5
|
+
* import { MockEndUserKeys } from '@sylphx/sdk/auth/end-user-keys-mock'
|
|
6
|
+
* const keys = new MockEndUserKeys()
|
|
7
|
+
* keys.addEnvironment(parent, 'production')
|
|
8
|
+
* keys.setPolicy(parent, { prefix: 'kk', scopes: ['read'] })
|
|
9
|
+
* const { secret } = keys.create(parent, { subject: { end_user }, display_name: 'ci' })
|
|
10
|
+
* keys.verify(parent, { key: secret }).code // 'VALID'
|
|
11
|
+
*
|
|
12
|
+
* It follows `docs/services/contracts/end-user-keys.md` and passes the same
|
|
13
|
+
* contract test and golden vectors (`contracts/fixtures/end-user-keys.json`)
|
|
14
|
+
* as the service. Calls are synchronous and raise `EndUserKeyError`; the SDK
|
|
15
|
+
* methods answer the same shapes over HTTP. Not for production: it stores
|
|
16
|
+
* nothing durably and enforces no limits (limits are stored and returned).
|
|
17
|
+
*/
|
|
18
|
+
import { type ApiKeysPolicy, type CreateEndUserKeyRequest, type CreateEndUserKeyResponse, type EndUserKey, type EndUserKeyErrorCode, type ImportEndUserKeysResponse, type ImportKeyRow, type LifecycleEvent, type ListEndUserKeysRequest, type ListEndUserKeysResponse, type RollEndUserKeyRequest, type UpdateEndUserKeyRequest, type VerifyRequest, type VerifyResult } from './end-user-keys.js';
|
|
19
|
+
export declare class EndUserKeyError extends Error {
|
|
20
|
+
readonly code: EndUserKeyErrorCode;
|
|
21
|
+
constructor(code: EndUserKeyErrorCode, message: string);
|
|
22
|
+
}
|
|
23
|
+
/** Who made a lifecycle call; recorded on its event row. */
|
|
24
|
+
export interface CallContext {
|
|
25
|
+
actor?: string;
|
|
26
|
+
request_id?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface MockOptions {
|
|
29
|
+
/** Epoch milliseconds; inject a fake clock in tests. */
|
|
30
|
+
now?: () => number;
|
|
31
|
+
}
|
|
32
|
+
export declare class MockEndUserKeys {
|
|
33
|
+
/** Number of digest lookups verify made; a token of another prefix makes none. */
|
|
34
|
+
lookupCount: number;
|
|
35
|
+
private readonly now;
|
|
36
|
+
private readonly envs;
|
|
37
|
+
constructor(opts?: MockOptions);
|
|
38
|
+
/** Register an environment; `production` mints `live` keys, anything else `test`. */
|
|
39
|
+
addEnvironment(parent: string, kind: 'production' | 'preview' | string): void;
|
|
40
|
+
/** Set `AuthConfig.spec.api_keys` for an environment. */
|
|
41
|
+
setPolicy(parent: string, policy: ApiKeysPolicy): void;
|
|
42
|
+
create(parent: string, req: CreateEndUserKeyRequest, ctx?: CallContext): CreateEndUserKeyResponse;
|
|
43
|
+
get(parent: string, uid: string): EndUserKey;
|
|
44
|
+
list(parent: string, req?: ListEndUserKeysRequest): ListEndUserKeysResponse;
|
|
45
|
+
update(parent: string, uid: string, patch: UpdateEndUserKeyRequest, ctx?: CallContext): EndUserKey;
|
|
46
|
+
/** Revoke; revoking a revoked key changes nothing. */
|
|
47
|
+
revoke(parent: string, uid: string, reason: string, ctx?: CallContext): EndUserKey;
|
|
48
|
+
/** Mint a new secret (returned once); the old one stays valid for the overlap. */
|
|
49
|
+
roll(parent: string, uid: string, req?: RollEndUserKeyRequest, ctx?: CallContext): CreateEndUserKeyResponse;
|
|
50
|
+
/** Hash-only import: at most 500 rows, idempotent on the digest, atomic on bad input. */
|
|
51
|
+
import(parent: string, rows: ImportKeyRow[], ctx?: CallContext): ImportEndUserKeysResponse;
|
|
52
|
+
/** Always answers; the token is looked up by digest in this environment only. */
|
|
53
|
+
verify(parent: string, req: VerifyRequest): VerifyResult;
|
|
54
|
+
/** The lifecycle rows of one key (ids and field names only). */
|
|
55
|
+
listEvents(parent: string, uid: string): LifecycleEvent[];
|
|
56
|
+
/** Erasure of an end user: its keys and secrets go; lifecycle rows keep only ids. Returns the number erased. */
|
|
57
|
+
eraseEndUser(parent: string, endUser: string): number;
|
|
58
|
+
/** Erasure of a customer organization. */
|
|
59
|
+
eraseCustomerOrganization(parent: string, organization: string): number;
|
|
60
|
+
private eraseWhere;
|
|
61
|
+
private checkFields;
|
|
62
|
+
private insert;
|
|
63
|
+
private stateOf;
|
|
64
|
+
private view;
|
|
65
|
+
private record;
|
|
66
|
+
private iso;
|
|
67
|
+
private env;
|
|
68
|
+
private row;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A stand-in for the Resource API's bearer check, to prove the boundary: only
|
|
72
|
+
* Access credentials (`sylphx_sk_...`) authenticate; an end-user key never does.
|
|
73
|
+
*/
|
|
74
|
+
export declare class MockResourceApi {
|
|
75
|
+
private readonly valid;
|
|
76
|
+
constructor(accessKeys: string[]);
|
|
77
|
+
authenticate(bearer: string): {
|
|
78
|
+
ok: true;
|
|
79
|
+
} | {
|
|
80
|
+
ok: false;
|
|
81
|
+
code: 'UNAUTHENTICATED';
|
|
82
|
+
};
|
|
83
|
+
}
|