@aperture-browser/api-client 0.0.0-init.0 → 0.0.0-nightly.101.c63f90ec6164

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.
@@ -0,0 +1,54 @@
1
+ import { t as AuthApi } from "./service-riqZPQHq.js";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Schema from "effect/Schema";
4
+ import { startAuthentication, startRegistration } from "@simplewebauthn/browser";
5
+ //#region src/passkeys.ts
6
+ const PasskeyCeremony = Schema.Literals(["authentication", "registration"]);
7
+ /**
8
+ * The browser did not complete the WebAuthn ceremony. `cancelled` covers the user
9
+ * dismissing the prompt or letting it time out; anything else is `failed`.
10
+ */
11
+ var PasskeyCeremonyError = class extends Schema.TaggedError()("PasskeyCeremonyError", {
12
+ ceremony: PasskeyCeremony,
13
+ reason: Schema.Literals(["cancelled", "failed"]),
14
+ message: Schema.String,
15
+ cause: Schema.Defect()
16
+ }) {};
17
+ const ceremonyLabels = {
18
+ authentication: "Passkey sign-in",
19
+ registration: "Passkey registration"
20
+ };
21
+ const toCeremonyError = (ceremony) => (cause) => {
22
+ const cancelled = cause instanceof Error && (cause.name === "NotAllowedError" || cause.name === "AbortError");
23
+ const label = ceremonyLabels[ceremony];
24
+ return new PasskeyCeremonyError({
25
+ ceremony,
26
+ reason: cancelled ? "cancelled" : "failed",
27
+ message: cancelled ? `${label} was cancelled` : `${label} failed`,
28
+ cause
29
+ });
30
+ };
31
+ /** Signs the browser in with a passkey, establishing the web session. */
32
+ const loginWithPasskey = Effect.fn("loginWithPasskey")(function* () {
33
+ const auth = yield* AuthApi;
34
+ const options = yield* auth.beginPasskeyLogin();
35
+ const credential = yield* Effect.tryPromise({
36
+ try: () => startAuthentication({ optionsJSON: options.publicKey }),
37
+ catch: toCeremonyError("authentication")
38
+ });
39
+ yield* auth.finishPasskeyLogin(credential);
40
+ });
41
+ /** Creates a passkey on this device and registers it for the signed-in user. */
42
+ const registerPasskey = Effect.fn("registerPasskey")(function* (name) {
43
+ const auth = yield* AuthApi;
44
+ const options = yield* auth.beginPasskeyRegistration(name);
45
+ const credential = yield* Effect.tryPromise({
46
+ try: () => startRegistration({ optionsJSON: options.publicKey }),
47
+ catch: toCeremonyError("registration")
48
+ });
49
+ return yield* auth.finishPasskeyRegistration(credential);
50
+ });
51
+ //#endregion
52
+ export { PasskeyCeremonyError, loginWithPasskey, registerPasskey };
53
+
54
+ //# sourceMappingURL=passkeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkeys.js","names":[],"sources":["../src/passkeys.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport { startAuthentication, startRegistration } from \"@simplewebauthn/browser\";\nimport { AuthApi } from \"./auth/service.ts\";\n\nconst PasskeyCeremony = Schema.Literals([\"authentication\", \"registration\"]);\ntype PasskeyCeremony = typeof PasskeyCeremony.Type;\n\n/**\n * The browser did not complete the WebAuthn ceremony. `cancelled` covers the user\n * dismissing the prompt or letting it time out; anything else is `failed`.\n */\nexport class PasskeyCeremonyError extends Schema.TaggedError<PasskeyCeremonyError>()(\n \"PasskeyCeremonyError\",\n {\n ceremony: PasskeyCeremony,\n reason: Schema.Literals([\"cancelled\", \"failed\"]),\n message: Schema.String,\n cause: Schema.Defect(),\n },\n) {}\n\nconst ceremonyLabels = {\n authentication: \"Passkey sign-in\",\n registration: \"Passkey registration\",\n} satisfies Record<PasskeyCeremony, string>;\n\n// Browsers report a dismissed or timed-out prompt as NotAllowedError, and an aborted one as\n// AbortError; @simplewebauthn/browser keeps that name on the WebAuthnError it rethrows.\nconst toCeremonyError = (ceremony: PasskeyCeremony) => (cause: unknown) => {\n const cancelled =\n cause instanceof Error && (cause.name === \"NotAllowedError\" || cause.name === \"AbortError\");\n const label = ceremonyLabels[ceremony];\n return new PasskeyCeremonyError({\n ceremony,\n reason: cancelled ? \"cancelled\" : \"failed\",\n message: cancelled ? `${label} was cancelled` : `${label} failed`,\n cause,\n });\n};\n\n/** Signs the browser in with a passkey, establishing the web session. */\nexport const loginWithPasskey = Effect.fn(\"loginWithPasskey\")(function* () {\n const auth = yield* AuthApi;\n const options = yield* auth.beginPasskeyLogin();\n const credential = yield* Effect.tryPromise({\n try: () => startAuthentication({ optionsJSON: options.publicKey }),\n catch: toCeremonyError(\"authentication\"),\n });\n yield* auth.finishPasskeyLogin(credential);\n});\n\n/** Creates a passkey on this device and registers it for the signed-in user. */\nexport const registerPasskey = Effect.fn(\"registerPasskey\")(function* (name: string) {\n const auth = yield* AuthApi;\n const options = yield* auth.beginPasskeyRegistration(name);\n const credential = yield* Effect.tryPromise({\n try: () => startRegistration({ optionsJSON: options.publicKey }),\n catch: toCeremonyError(\"registration\"),\n });\n return yield* auth.finishPasskeyRegistration(credential);\n});\n"],"mappings":";;;;;AAKA,MAAM,kBAAkB,OAAO,SAAS,CAAC,kBAAkB,cAAc,CAAC;;;;;AAO1E,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,UAAU;CACV,QAAQ,OAAO,SAAS,CAAC,aAAa,QAAQ,CAAC;CAC/C,SAAS,OAAO;CAChB,OAAO,OAAO,OAAO;AACvB,CACF,CAAC,CAAC,CAAC;AAEH,MAAM,iBAAiB;CACrB,gBAAgB;CAChB,cAAc;AAChB;AAIA,MAAM,mBAAmB,cAA+B,UAAmB;CACzE,MAAM,YACJ,iBAAiB,UAAU,MAAM,SAAS,qBAAqB,MAAM,SAAS;CAChF,MAAM,QAAQ,eAAe;CAC7B,OAAO,IAAI,qBAAqB;EAC9B;EACA,QAAQ,YAAY,cAAc;EAClC,SAAS,YAAY,GAAG,MAAM,kBAAkB,GAAG,MAAM;EACzD;CACF,CAAC;AACH;;AAGA,MAAa,mBAAmB,OAAO,GAAG,kBAAkB,CAAC,CAAC,aAAa;CACzE,MAAM,OAAO,OAAO;CACpB,MAAM,UAAU,OAAO,KAAK,kBAAkB;CAC9C,MAAM,aAAa,OAAO,OAAO,WAAW;EAC1C,WAAW,oBAAoB,EAAE,aAAa,QAAQ,UAAU,CAAC;EACjE,OAAO,gBAAgB,gBAAgB;CACzC,CAAC;CACD,OAAO,KAAK,mBAAmB,UAAU;AAC3C,CAAC;;AAGD,MAAa,kBAAkB,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,MAAc;CACnF,MAAM,OAAO,OAAO;CACpB,MAAM,UAAU,OAAO,KAAK,yBAAyB,IAAI;CACzD,MAAM,aAAa,OAAO,OAAO,WAAW;EAC1C,WAAW,kBAAkB,EAAE,aAAa,QAAQ,UAAU,CAAC;EAC/D,OAAO,gBAAgB,cAAc;CACvC,CAAC;CACD,OAAO,OAAO,KAAK,0BAA0B,UAAU;AACzD,CAAC"}
@@ -0,0 +1,406 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Api from "@aperture-browser/api-schema";
3
+ import * as Context from "effect/Context";
4
+ import * as Schema from "effect/Schema";
5
+ import * as Redacted from "effect/Redacted";
6
+ import * as Stream from "effect/Stream";
7
+ import * as HttpClientError from "effect/http/HttpClientError";
8
+
9
+ //#region src/errors.d.ts
10
+ declare const ApiErrorBody: Schema.Struct<{
11
+ readonly error: Schema.Struct<{
12
+ readonly code: Schema.String;
13
+ readonly message: Schema.String;
14
+ }>;
15
+ }>;
16
+ type ApiErrorBody = typeof ApiErrorBody.Type;
17
+ /**
18
+ * The error body of a live-session route that failed inside the running session. It carries
19
+ * no stable code, so the resulting ApiRequestError uses `live_session_error` and callers
20
+ * branch on its status.
21
+ */
22
+ declare const LiveSessionErrorBody: Schema.Struct<{
23
+ readonly error: Schema.String;
24
+ }>;
25
+ type LiveSessionErrorBody = typeof LiveSessionErrorBody.Type;
26
+ declare const ApiRequestError_base: Schema.Class<ApiRequestError, Schema.TaggedStruct<"ApiRequestError", {
27
+ readonly code: Schema.String;
28
+ readonly message: Schema.String;
29
+ readonly status: Schema.Number;
30
+ readonly cause: Schema.optional<Schema.Union<readonly [Schema.instanceOf<HttpClientError.HttpClientError, unknown>, Schema.instanceOf<Schema.SchemaError, unknown>]>>;
31
+ }>, import("effect/Cause").YieldableError>;
32
+ /**
33
+ * A failed API request. `code` and `message` come from the server's error body when it
34
+ * sent one; `status` is 0 when no HTTP status applies. `cause` is the underlying HTTP or
35
+ * decoding failure when the server's error body alone does not explain it.
36
+ */
37
+ declare class ApiRequestError extends ApiRequestError_base {}
38
+ /**
39
+ * Maps HTTP and decoding failures to ApiRequestError. Error responses keep the code and
40
+ * message of the server's error body.
41
+ */
42
+ declare const toApiRequestError: <A, R>(self: Effect.Effect<A, HttpClientError.HttpClientError | Schema.SchemaError, R>) => Effect.Effect<A, ApiRequestError, R>;
43
+ //#endregion
44
+ //#region src/authorization/service.d.ts
45
+ declare const TENANT_HEADER = "X-Aperture-Tenant-Id";
46
+ interface CredentialContext {
47
+ authorityType: "system_admin" | "tenant" | null;
48
+ tenantId: string | null;
49
+ selectedTenantId: string | null;
50
+ }
51
+ type ApiCredentials = (CredentialContext & {
52
+ kind: "bearer";
53
+ token: Redacted.Redacted<string>;
54
+ }) | (CredentialContext & {
55
+ kind: "session";
56
+ });
57
+ /** The browser's own login session, sent as a cookie. */
58
+ declare const webSessionCredentials: ApiCredentials;
59
+ type TenantHeaderMode = "none" | "optional" | "tenant-scoped";
60
+ /** Which tenant, if any, a request acts for under the given credentials. */
61
+ declare function resolveTenantHeader(credentials: ApiCredentials, mode: TenantHeaderMode): string | undefined;
62
+ /** How a request authenticates, and which tenant it acts for. */
63
+ interface Authorization {
64
+ readonly credentials?: ApiCredentials;
65
+ readonly bearerToken?: Redacted.Redacted<string>;
66
+ readonly tenantHeader?: TenantHeaderMode;
67
+ }
68
+ declare const Authorization: {
69
+ anonymous: Authorization;
70
+ webSession: Authorization;
71
+ of: (credentials: ApiCredentials) => Authorization;
72
+ tenantScoped: (credentials: ApiCredentials) => Authorization;
73
+ };
74
+ declare const ApiAuthorization_base: Context.ServiceClass<ApiAuthorization, "@aperture-browser/api-client/ApiAuthorization", {
75
+ /** Runs a call with the given authorization and maps its failures to ApiRequestError. */readonly authorize: (authorization: Authorization) => <A, R>(self: Effect.Effect<A, HttpClientError.HttpClientError | Schema.SchemaError, R>) => Effect.Effect<A, ApiRequestError, R>; /** Emits whenever the web session is found to be missing, expired or revoked. */
76
+ readonly sessionAuthenticationFailures: Stream.Stream<void>;
77
+ }>;
78
+ /**
79
+ * Authenticates API calls. Inside `authorize`, every request sent through the HttpClient
80
+ * that `authorizedHttpClientLayer` provides carries that call's credentials and tenant, so
81
+ * callers never touch headers.
82
+ */
83
+ declare class ApiAuthorization extends ApiAuthorization_base {}
84
+ //#endregion
85
+ //#region src/auth/schemas.d.ts
86
+ declare const LoginMethods: Schema.Struct<{
87
+ readonly methods: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
88
+ readonly type: Schema.Literal<"password">;
89
+ }>, Schema.Struct<{
90
+ readonly type: Schema.Literal<"api_token">;
91
+ }>, Schema.Struct<{
92
+ readonly type: Schema.Literal<"passkey">;
93
+ }>, Schema.Struct<{
94
+ readonly type: Schema.Literal<"oidc">;
95
+ readonly id: Schema.String;
96
+ readonly name: Schema.String;
97
+ readonly loginUrl: Schema.String;
98
+ }>]>>;
99
+ }>;
100
+ declare const PasskeyLoginOptions: Schema.Struct<{
101
+ readonly publicKey: Schema.Struct<{
102
+ readonly challenge: Schema.String;
103
+ readonly timeout: Schema.optionalKey<Schema.Number>;
104
+ readonly rpId: Schema.optionalKey<Schema.String>;
105
+ readonly allowCredentials: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Struct<{
106
+ readonly id: Schema.String;
107
+ readonly type: Schema.Literal<"public-key">;
108
+ readonly transports: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["ble", "cable", "hybrid", "internal", "nfc", "smart-card", "usb"]>>>>;
109
+ }>>>>;
110
+ readonly userVerification: Schema.optionalKey<Schema.Literals<readonly ["discouraged", "preferred", "required"]>>;
111
+ readonly hints: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["hybrid", "security-key", "client-device"]>>>>;
112
+ readonly extensions: Schema.optionalKey<Schema.Struct<{
113
+ readonly appid: Schema.optionalKey<Schema.String>;
114
+ readonly credProps: Schema.optionalKey<Schema.Boolean>;
115
+ readonly hmacCreateSecret: Schema.optionalKey<Schema.Boolean>;
116
+ readonly minPinLength: Schema.optionalKey<Schema.Boolean>;
117
+ }>>;
118
+ }>;
119
+ }>;
120
+ declare const PasskeyRegistrationOptions: Schema.Struct<{
121
+ readonly publicKey: Schema.Struct<{
122
+ readonly rp: Schema.Struct<{
123
+ readonly id: Schema.optionalKey<Schema.String>;
124
+ readonly name: Schema.String;
125
+ }>;
126
+ readonly user: Schema.Struct<{
127
+ readonly id: Schema.String;
128
+ readonly name: Schema.String;
129
+ readonly displayName: Schema.String;
130
+ }>;
131
+ readonly challenge: Schema.String;
132
+ readonly pubKeyCredParams: Schema.mutable<Schema.$Array<Schema.Struct<{
133
+ readonly alg: Schema.Literals<readonly [-7, -8, -35, -36, -37, -38, -39, -257, -258, -259]>;
134
+ readonly type: Schema.Literal<"public-key">;
135
+ }>>>;
136
+ readonly timeout: Schema.optionalKey<Schema.Number>;
137
+ readonly excludeCredentials: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Struct<{
138
+ readonly id: Schema.String;
139
+ readonly type: Schema.Literal<"public-key">;
140
+ readonly transports: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["ble", "cable", "hybrid", "internal", "nfc", "smart-card", "usb"]>>>>;
141
+ }>>>>;
142
+ readonly authenticatorSelection: Schema.optionalKey<Schema.Struct<{
143
+ readonly authenticatorAttachment: Schema.optionalKey<Schema.Literals<readonly ["platform", "cross-platform"]>>;
144
+ readonly requireResidentKey: Schema.optionalKey<Schema.Boolean>;
145
+ readonly residentKey: Schema.optionalKey<Schema.Literals<readonly ["discouraged", "preferred", "required"]>>;
146
+ readonly userVerification: Schema.optionalKey<Schema.Literals<readonly ["discouraged", "preferred", "required"]>>;
147
+ }>>;
148
+ readonly hints: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["hybrid", "security-key", "client-device"]>>>>;
149
+ readonly attestation: Schema.optionalKey<Schema.Literals<readonly ["direct", "enterprise", "indirect", "none"]>>;
150
+ readonly attestationFormats: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["fido-u2f", "packed", "android-safetynet", "android-key", "tpm", "apple", "none"]>>>>;
151
+ readonly extensions: Schema.optionalKey<Schema.Struct<{
152
+ readonly appid: Schema.optionalKey<Schema.String>;
153
+ readonly credProps: Schema.optionalKey<Schema.Boolean>;
154
+ readonly hmacCreateSecret: Schema.optionalKey<Schema.Boolean>;
155
+ readonly minPinLength: Schema.optionalKey<Schema.Boolean>;
156
+ }>>;
157
+ }>;
158
+ }>;
159
+ declare const Passkey: Schema.Struct<{
160
+ readonly id: Schema.String;
161
+ readonly name: Schema.String;
162
+ readonly createdAt: Schema.String;
163
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
164
+ }>;
165
+ declare const Passkeys: Schema.Struct<{
166
+ readonly passkeys: Schema.$Array<Schema.Struct<{
167
+ readonly id: Schema.String;
168
+ readonly name: Schema.String;
169
+ readonly createdAt: Schema.String;
170
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
171
+ }>>;
172
+ }>;
173
+ declare const PasskeyMutation: Schema.Struct<{
174
+ readonly passkey: Schema.Struct<{
175
+ readonly id: Schema.String;
176
+ readonly name: Schema.String;
177
+ readonly createdAt: Schema.String;
178
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
179
+ }>;
180
+ }>;
181
+ declare const PasswordLoginResponse: Schema.Struct<{
182
+ readonly mfaRequired: Schema.Boolean;
183
+ }>;
184
+ declare const SecurityStatus: Schema.Struct<{
185
+ readonly hasPassword: Schema.Boolean;
186
+ readonly totpEnabled: Schema.Boolean;
187
+ readonly recoveryCodesRemaining: Schema.Number;
188
+ }>;
189
+ declare const TOTPEnrollment: Schema.Struct<{
190
+ readonly secret: Schema.String;
191
+ readonly otpauthUrl: Schema.String;
192
+ readonly qrCodeDataUrl: Schema.String;
193
+ }>;
194
+ declare const RecoveryCodes: Schema.Struct<{
195
+ readonly recoveryCodes: Schema.$Array<Schema.String>;
196
+ }>;
197
+ declare const OAuthClient: Schema.Struct<{
198
+ readonly id: Schema.String;
199
+ readonly name: Schema.String;
200
+ readonly uri: Schema.NullOr<Schema.String>;
201
+ readonly logoUri: Schema.NullOr<Schema.String>;
202
+ readonly kind: Schema.Literals<readonly ["registered", "metadata_document"]>;
203
+ }>;
204
+ /** A pending OAuth authorization request, as the consent page presents it. */
205
+ declare const OAuthAuthorizationRequest: Schema.Struct<{
206
+ readonly client: Schema.Struct<{
207
+ readonly id: Schema.String;
208
+ readonly name: Schema.String;
209
+ readonly uri: Schema.NullOr<Schema.String>;
210
+ readonly logoUri: Schema.NullOr<Schema.String>;
211
+ readonly kind: Schema.Literals<readonly ["registered", "metadata_document"]>;
212
+ }>;
213
+ readonly redirectUri: Schema.String;
214
+ readonly requestedScopes: Schema.$Array<Schema.String>;
215
+ readonly user: Schema.Struct<{
216
+ readonly id: Schema.String;
217
+ readonly displayName: Schema.String;
218
+ readonly isSystemAdmin: Schema.Boolean;
219
+ }>;
220
+ readonly tenants: Schema.$Array<Schema.Struct<{
221
+ readonly id: Schema.String;
222
+ readonly displayName: Schema.String;
223
+ readonly scopes: Schema.$Array<Schema.Literals<readonly ["sessions:read", "sessions:write", "snapshots:read", "snapshots:write", "tenant:write"]>>;
224
+ }>>;
225
+ readonly availableScopes: Schema.$Array<Schema.Literals<readonly ["sessions:read", "sessions:write", "snapshots:read", "snapshots:write", "tenant:write"]>>;
226
+ readonly canGrantSystemAdmin: Schema.Boolean;
227
+ }>;
228
+ /** Where the browser goes after the user approves or denies an authorization request. */
229
+ declare const OAuthRedirect: Schema.Struct<{
230
+ readonly redirectUrl: Schema.String;
231
+ }>;
232
+ declare const OAuthGrant: Schema.Struct<{
233
+ readonly id: Schema.String;
234
+ readonly client: Schema.Struct<{
235
+ readonly id: Schema.String;
236
+ readonly name: Schema.String;
237
+ readonly uri: Schema.NullOr<Schema.String>;
238
+ readonly logoUri: Schema.NullOr<Schema.String>;
239
+ readonly kind: Schema.Literals<readonly ["registered", "metadata_document"]>;
240
+ }>;
241
+ readonly authorityType: Schema.Literals<readonly ["system_admin", "tenant"]>;
242
+ readonly tenants: Schema.$Array<Schema.Struct<{
243
+ readonly id: Schema.String;
244
+ readonly displayName: Schema.String;
245
+ }>>;
246
+ readonly scopes: Schema.$Array<Schema.String>;
247
+ readonly resourceMode: Schema.Literals<readonly ["all", "allowlist"]>;
248
+ readonly resourceGrants: Schema.$Array<Schema.Struct<{
249
+ readonly resourceType: Schema.Literals<readonly ["session", "snapshot"]>;
250
+ readonly resourceId: Schema.String;
251
+ }>>;
252
+ readonly createdAt: Schema.String;
253
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
254
+ }>;
255
+ declare const OAuthGrants: Schema.Struct<{
256
+ readonly grants: Schema.$Array<Schema.Struct<{
257
+ readonly id: Schema.String;
258
+ readonly client: Schema.Struct<{
259
+ readonly id: Schema.String;
260
+ readonly name: Schema.String;
261
+ readonly uri: Schema.NullOr<Schema.String>;
262
+ readonly logoUri: Schema.NullOr<Schema.String>;
263
+ readonly kind: Schema.Literals<readonly ["registered", "metadata_document"]>;
264
+ }>;
265
+ readonly authorityType: Schema.Literals<readonly ["system_admin", "tenant"]>;
266
+ readonly tenants: Schema.$Array<Schema.Struct<{
267
+ readonly id: Schema.String;
268
+ readonly displayName: Schema.String;
269
+ }>>;
270
+ readonly scopes: Schema.$Array<Schema.String>;
271
+ readonly resourceMode: Schema.Literals<readonly ["all", "allowlist"]>;
272
+ readonly resourceGrants: Schema.$Array<Schema.Struct<{
273
+ readonly resourceType: Schema.Literals<readonly ["session", "snapshot"]>;
274
+ readonly resourceId: Schema.String;
275
+ }>>;
276
+ readonly createdAt: Schema.String;
277
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
278
+ }>>;
279
+ }>;
280
+ /**
281
+ * The user's answer to an authorization request. `query` is the authorize query string
282
+ * without its leading `?`. With `systemAdmin`, the tenant, scope and resource fields are
283
+ * ignored.
284
+ */
285
+ interface OAuthApproval {
286
+ readonly query: string;
287
+ readonly systemAdmin: boolean;
288
+ readonly tenantIds: ReadonlyArray<string>;
289
+ readonly scopes: ReadonlyArray<Api.TenantScope>;
290
+ readonly resourceMode: Api.ResourceMode;
291
+ readonly resourceGrants: ReadonlyArray<Api.ResourceGrant>;
292
+ }
293
+ type LoginMethods = typeof LoginMethods.Type;
294
+ type PasskeyLoginOptions = typeof PasskeyLoginOptions.Type;
295
+ type PasskeyRegistrationOptions = typeof PasskeyRegistrationOptions.Type;
296
+ type Passkey = typeof Passkey.Type;
297
+ type Passkeys = typeof Passkeys.Type;
298
+ type PasskeyMutation = typeof PasskeyMutation.Type;
299
+ type PasswordLoginResponse = typeof PasswordLoginResponse.Type;
300
+ type RecoveryCodes = typeof RecoveryCodes.Type;
301
+ type SecurityStatus = typeof SecurityStatus.Type;
302
+ type TOTPEnrollment = typeof TOTPEnrollment.Type;
303
+ type OAuthClient = typeof OAuthClient.Type;
304
+ type OAuthAuthorizationRequest = typeof OAuthAuthorizationRequest.Type;
305
+ type OAuthRedirect = typeof OAuthRedirect.Type;
306
+ type OAuthGrant = typeof OAuthGrant.Type;
307
+ type OAuthGrants = typeof OAuthGrants.Type;
308
+ //#endregion
309
+ //#region src/schemas.d.ts
310
+ type PageMeta = Api.PageMeta;
311
+ type Tenant = Api.Tenant;
312
+ type User = Api.User;
313
+ type UserInvitation = Api.UserInvitation;
314
+ type TenantMembership = Api.TenantMembership;
315
+ type AuthMeResponse = Api.AuthMe;
316
+ type AuthMePrincipal = Api.Principal;
317
+ type AuthMeTenant = Api.Tenant;
318
+ type ResourceMode = Api.ResourceMode;
319
+ type ResourceGrant = Api.ResourceGrant;
320
+ type Scope = Api.Scope;
321
+ type TenantScope = Api.TenantScope;
322
+ type Session = Api.Session;
323
+ type SessionMedia = Api.SessionMedia;
324
+ type SessionProxy = Api.SessionProxy;
325
+ type ProxyConfig = Api.ProxyConfig;
326
+ type UpdateProxyConfig = Api.UpdateProxyConfig;
327
+ type ProxyUpstream = Api.ProxyUpstream;
328
+ type ProxyRule = Api.ProxyRule;
329
+ type CursorVisibility = Api.CursorVisibility;
330
+ type SessionRecording = Api.Recording;
331
+ type SessionFile = Api.SessionFile;
332
+ type SessionRecordingEditError = Api.RecordingEditError;
333
+ type SessionDirectory = Api.SessionDirectory;
334
+ type SessionFileEntry = Api.SessionFileEntry;
335
+ type SessionFileDownloadURL = Api.SessionFileDownloadURL;
336
+ type SetViewportInput = Api.SetViewportInput;
337
+ type TargetViewport = Api.TargetViewport;
338
+ type Health = Api.Health;
339
+ type AuditEvent = Api.AuditEvent;
340
+ type AuditEventsPage = Api.AuditEventPage;
341
+ type IceServer = Api.IceServer;
342
+ declare const SessionStatus: import("effect/Schema").Literals<readonly ["creating", "running", "suspended", "deleted", "expired", "failed"]>;
343
+ type SessionStatus = Api.SessionStatus;
344
+ type Snapshot = Api.Snapshot;
345
+ type ApiToken = Api.Token;
346
+ type TenantsPage = Api.TenantPage;
347
+ type UsersPage = Api.UserPage;
348
+ type SessionsPage = Api.SessionPage;
349
+ type SessionsBulkResponse = Api.SessionBulkResponse;
350
+ type SnapshotsPage = Api.SnapshotPage;
351
+ type TokensPage = Api.TokenPage;
352
+ type BrowserChannel = Api.BrowserChannel;
353
+ type BrowserChannelsResponse = Api.BrowserChannels;
354
+ type ResourceEvent = Api.Event;
355
+ type EventsPage = Api.EventPage;
356
+ type CreateSessionResponse = Api.CreateSessionResult;
357
+ type SessionMutationResponse = Api.SessionMutation;
358
+ type SnapshotMutationResponse = Api.SnapshotMutation;
359
+ type PromoteSessionResponse = Api.SnapshotMutation;
360
+ type CreateTokenResponse = Api.CreateTokenResponse;
361
+ //#endregion
362
+ //#region src/auth/service.d.ts
363
+ type Call<A> = Effect.Effect<A, ApiRequestError>;
364
+ /**
365
+ * A WebAuthn credential serialized to JSON by the browser ceremony, as
366
+ * `@aperture-browser/api-client/passkeys` produces it. The server verifies its contents.
367
+ */
368
+ interface PasskeyCredentialJSON {
369
+ readonly id: string;
370
+ readonly rawId: string;
371
+ readonly type: "public-key";
372
+ readonly response: object;
373
+ readonly clientExtensionResults: object;
374
+ }
375
+ declare const AuthApi_base: Context.ServiceClass<AuthApi, "@aperture-browser/api-client/AuthApi", {
376
+ readonly listLoginMethods: () => Call<LoginMethods>;
377
+ readonly loginWithPassword: (email: string, password: string) => Call<PasswordLoginResponse>;
378
+ readonly completePasswordMFA: (code: string) => Call<void>;
379
+ readonly loginWithAPIToken: (token: string) => Call<void>;
380
+ readonly beginPasskeyLogin: () => Call<PasskeyLoginOptions>;
381
+ readonly finishPasskeyLogin: (credential: PasskeyCredentialJSON) => Call<void>;
382
+ readonly acceptUserInvitation: (token: string, password: string) => Call<void>;
383
+ readonly logoutWebSession: () => Call<void>;
384
+ readonly getAuthMe: (selectedTenantId?: string | null, credentials?: ApiCredentials) => Call<AuthMeResponse>;
385
+ readonly getSecurityStatus: () => Call<SecurityStatus>;
386
+ readonly setPassword: (currentPassword: string, newPassword: string) => Call<void>;
387
+ readonly listPasskeys: () => Call<Passkeys>;
388
+ readonly beginPasskeyRegistration: (name: string) => Call<PasskeyRegistrationOptions>;
389
+ readonly finishPasskeyRegistration: (credential: PasskeyCredentialJSON) => Call<PasskeyMutation>;
390
+ readonly renamePasskey: (passkeyId: string, name: string) => Call<PasskeyMutation>;
391
+ readonly deletePasskey: (passkeyId: string) => Call<void>;
392
+ readonly beginTOTPEnrollment: () => Call<TOTPEnrollment>;
393
+ readonly completeTOTPEnrollment: (code: string) => Call<RecoveryCodes>;
394
+ readonly regenerateRecoveryCodes: (code: string) => Call<RecoveryCodes>;
395
+ readonly disableTOTP: (code: string) => Call<void>; /** `query` is the OAuth authorize query string, without its leading `?`. */
396
+ readonly getOAuthAuthorization: (query: string) => Call<OAuthAuthorizationRequest>;
397
+ readonly approveOAuthAuthorization: (approval: OAuthApproval) => Call<OAuthRedirect>;
398
+ readonly denyOAuthAuthorization: (query: string) => Call<OAuthRedirect>;
399
+ readonly listOAuthGrants: () => Call<OAuthGrants>;
400
+ readonly revokeOAuthGrant: (grantId: string) => Call<void>;
401
+ }>;
402
+ /** Browser login, account security, and the current principal. */
403
+ declare class AuthApi extends AuthApi_base {}
404
+ //#endregion
405
+ export { LoginMethods as $, SessionFileEntry as A, Snapshot as B, ResourceGrant as C, ApiRequestError as Ct, SessionDirectory as D, Session as E, SessionRecordingEditError as F, TenantMembership as G, SnapshotsPage as H, SessionStatus as I, TokensPage as J, TenantScope as K, SessionsBulkResponse as L, SessionMutationResponse as M, SessionProxy as N, SessionFile as O, SessionRecording as P, UsersPage as Q, SessionsPage as R, ResourceEvent as S, ApiErrorBody as St, Scope as T, toApiRequestError as Tt, TargetViewport as U, SnapshotMutationResponse as V, Tenant as W, User as X, UpdateProxyConfig as Y, UserInvitation as Z, PageMeta as _, Authorization as _t, AuditEventsPage as a, OAuthRedirect as at, ProxyRule as b, resolveTenantHeader as bt, AuthMeTenant as c, PasskeyMutation as ct, CreateSessionResponse as d, PasswordLoginResponse as dt, OAuthApproval as et, CreateTokenResponse as f, RecoveryCodes as ft, IceServer as g, ApiCredentials as gt, Health as h, ApiAuthorization as ht, AuditEvent as i, OAuthGrants as it, SessionMedia as j, SessionFileDownloadURL as k, BrowserChannel as l, PasskeyRegistrationOptions as lt, EventsPage as m, TOTPEnrollment as mt, PasskeyCredentialJSON as n, OAuthClient as nt, AuthMePrincipal as o, Passkey as ot, CursorVisibility as p, SecurityStatus as pt, TenantsPage as q, ApiToken as r, OAuthGrant as rt, AuthMeResponse as s, PasskeyLoginOptions as st, AuthApi as t, OAuthAuthorizationRequest as tt, BrowserChannelsResponse as u, Passkeys as ut, PromoteSessionResponse as v, TENANT_HEADER as vt, ResourceMode as w, LiveSessionErrorBody as wt, ProxyUpstream as x, webSessionCredentials as xt, ProxyConfig as y, TenantHeaderMode as yt, SetViewportInput as z };
406
+ //# sourceMappingURL=service-DbyEmdKS.d.ts.map
@@ -0,0 +1,8 @@
1
+ import * as Context from "effect/Context";
2
+ //#region src/auth/service.ts
3
+ /** Browser login, account security, and the current principal. */
4
+ var AuthApi = class extends Context.Service()("@aperture-browser/api-client/AuthApi") {};
5
+ //#endregion
6
+ export { AuthApi as t };
7
+
8
+ //# sourceMappingURL=service-riqZPQHq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-riqZPQHq.js","names":[],"sources":["../src/auth/service.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport type * as Effect from \"effect/Effect\";\nimport type { ApiCredentials } from \"../authorization/service.ts\";\nimport type { ApiRequestError } from \"../errors.ts\";\nimport type { AuthMeResponse } from \"../schemas.ts\";\nimport type * as S from \"./schemas.ts\";\n\ntype Call<A> = Effect.Effect<A, ApiRequestError>;\n\n/**\n * A WebAuthn credential serialized to JSON by the browser ceremony, as\n * `@aperture-browser/api-client/passkeys` produces it. The server verifies its contents.\n */\nexport interface PasskeyCredentialJSON {\n readonly id: string;\n readonly rawId: string;\n readonly type: \"public-key\";\n readonly response: object;\n readonly clientExtensionResults: object;\n}\n\n/** Browser login, account security, and the current principal. */\nexport class AuthApi extends Context.Service<\n AuthApi,\n {\n readonly listLoginMethods: () => Call<S.LoginMethods>;\n readonly loginWithPassword: (email: string, password: string) => Call<S.PasswordLoginResponse>;\n readonly completePasswordMFA: (code: string) => Call<void>;\n readonly loginWithAPIToken: (token: string) => Call<void>;\n readonly beginPasskeyLogin: () => Call<S.PasskeyLoginOptions>;\n readonly finishPasskeyLogin: (credential: PasskeyCredentialJSON) => Call<void>;\n readonly acceptUserInvitation: (token: string, password: string) => Call<void>;\n readonly logoutWebSession: () => Call<void>;\n\n readonly getAuthMe: (\n selectedTenantId?: string | null,\n credentials?: ApiCredentials,\n ) => Call<AuthMeResponse>;\n\n readonly getSecurityStatus: () => Call<S.SecurityStatus>;\n readonly setPassword: (currentPassword: string, newPassword: string) => Call<void>;\n readonly listPasskeys: () => Call<S.Passkeys>;\n readonly beginPasskeyRegistration: (name: string) => Call<S.PasskeyRegistrationOptions>;\n readonly finishPasskeyRegistration: (\n credential: PasskeyCredentialJSON,\n ) => Call<S.PasskeyMutation>;\n readonly renamePasskey: (passkeyId: string, name: string) => Call<S.PasskeyMutation>;\n readonly deletePasskey: (passkeyId: string) => Call<void>;\n readonly beginTOTPEnrollment: () => Call<S.TOTPEnrollment>;\n readonly completeTOTPEnrollment: (code: string) => Call<S.RecoveryCodes>;\n readonly regenerateRecoveryCodes: (code: string) => Call<S.RecoveryCodes>;\n readonly disableTOTP: (code: string) => Call<void>;\n\n /** `query` is the OAuth authorize query string, without its leading `?`. */\n readonly getOAuthAuthorization: (query: string) => Call<S.OAuthAuthorizationRequest>;\n readonly approveOAuthAuthorization: (approval: S.OAuthApproval) => Call<S.OAuthRedirect>;\n readonly denyOAuthAuthorization: (query: string) => Call<S.OAuthRedirect>;\n readonly listOAuthGrants: () => Call<S.OAuthGrants>;\n readonly revokeOAuthGrant: (grantId: string) => Call<void>;\n }\n>()(\"@aperture-browser/api-client/AuthApi\") {}\n"],"mappings":";;;AAsBA,IAAa,UAAb,cAA6B,QAAQ,QAsCnC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aperture-browser/api-client",
3
- "version": "0.0.0-init.0",
3
+ "version": "0.0.0-nightly.101.c63f90ec6164",
4
4
  "description": "Effect services for the Aperture API: sessions, snapshots, tenants, users, tokens, events and authentication.",
5
5
  "homepage": "https://github.com/tarik02/aperture#readme",
6
6
  "bugs": "https://github.com/tarik02/aperture/issues",
@@ -19,21 +19,31 @@
19
19
  ".": {
20
20
  "types": "./dist/index.d.ts",
21
21
  "default": "./dist/index.js"
22
+ },
23
+ "./passkeys": {
24
+ "types": "./dist/passkeys.d.ts",
25
+ "default": "./dist/passkeys.js"
22
26
  }
23
27
  },
24
28
  "publishConfig": {
25
29
  "access": "public"
26
30
  },
27
31
  "dependencies": {
28
- "@aperture-browser/api-schema": "0.0.0-init.0",
29
- "@simplewebauthn/browser": "13.3.0"
32
+ "@aperture-browser/api-schema": "0.0.0-nightly.101.c63f90ec6164"
30
33
  },
31
34
  "devDependencies": {
32
- "effect": "4.0.0-rc.117",
35
+ "@simplewebauthn/browser": "13.3.0",
36
+ "effect": "4.0.0",
33
37
  "vite-plus": "0.2.4"
34
38
  },
35
39
  "peerDependencies": {
36
- "effect": "^4.0.0-rc.117"
40
+ "@simplewebauthn/browser": "^13.3.0",
41
+ "effect": "^4.0.0"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "@simplewebauthn/browser": {
45
+ "optional": true
46
+ }
37
47
  },
38
48
  "scripts": {
39
49
  "build": "vp pack",