@aperture-browser/api-client 0.0.0-init.0 → 0.0.0-nightly.82.2e4f6368108f

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,296 @@
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 Stream from "effect/Stream";
6
+ import * as HttpClientError from "effect/unstable/http/HttpClientError";
7
+
8
+ //#region src/errors.d.ts
9
+ declare const ApiErrorBody: Schema.Struct<{
10
+ readonly error: Schema.Struct<{
11
+ readonly code: Schema.String;
12
+ readonly message: Schema.String;
13
+ }>;
14
+ }>;
15
+ type ApiErrorBody = typeof ApiErrorBody.Type;
16
+ /**
17
+ * The error body of a live-session route that failed inside the running session. It carries
18
+ * no stable code, so the resulting ApiRequestError uses `live_session_error` and callers
19
+ * branch on its status.
20
+ */
21
+ declare const LiveSessionErrorBody: Schema.Struct<{
22
+ readonly error: Schema.String;
23
+ }>;
24
+ type LiveSessionErrorBody = typeof LiveSessionErrorBody.Type;
25
+ declare const ApiRequestError_base: Schema.Class<ApiRequestError, Schema.TaggedStruct<"ApiRequestError", {
26
+ readonly code: Schema.String;
27
+ readonly message: Schema.String;
28
+ readonly status: Schema.Number;
29
+ }>, import("effect/Cause").YieldableError>;
30
+ /**
31
+ * A failed API request. `code` and `message` come from the server's error body when it
32
+ * sent one; `status` is 0 when no HTTP status applies.
33
+ */
34
+ declare class ApiRequestError extends ApiRequestError_base {}
35
+ /**
36
+ * Maps HTTP and decoding failures to ApiRequestError. Error responses keep the code and
37
+ * message of the server's error body.
38
+ */
39
+ declare const toApiRequestError: <A, R>(self: Effect.Effect<A, HttpClientError.HttpClientError | Schema.SchemaError, R>) => Effect.Effect<A, ApiRequestError, R>;
40
+ //#endregion
41
+ //#region src/authorization/service.d.ts
42
+ declare const TENANT_HEADER = "X-Aperture-Tenant-Id";
43
+ interface CredentialContext {
44
+ authorityType: "system_admin" | "tenant" | null;
45
+ tenantId: string | null;
46
+ selectedTenantId: string | null;
47
+ }
48
+ type ApiCredentials = (CredentialContext & {
49
+ kind: "bearer";
50
+ token: string;
51
+ }) | (CredentialContext & {
52
+ kind: "session";
53
+ });
54
+ /** The browser's own login session, sent as a cookie. */
55
+ declare const webSessionCredentials: ApiCredentials;
56
+ type TenantHeaderMode = "none" | "optional" | "tenant-scoped";
57
+ /** Which tenant, if any, a request acts for under the given credentials. */
58
+ declare function resolveTenantHeader(credentials: ApiCredentials, mode: TenantHeaderMode): string | undefined;
59
+ /** How a request authenticates, and which tenant it acts for. */
60
+ interface Authorization {
61
+ readonly credentials?: ApiCredentials;
62
+ readonly bearerToken?: string;
63
+ readonly tenantHeader?: TenantHeaderMode;
64
+ }
65
+ declare const Authorization: {
66
+ anonymous: Authorization;
67
+ webSession: Authorization;
68
+ of: (credentials: ApiCredentials) => Authorization;
69
+ tenantScoped: (credentials: ApiCredentials) => Authorization;
70
+ };
71
+ declare const ApiAuthorization_base: Context.ServiceClass<ApiAuthorization, "@aperture-browser/api-client/ApiAuthorization", {
72
+ /** 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. */
73
+ readonly sessionAuthenticationFailures: Stream.Stream<void>;
74
+ }>;
75
+ /**
76
+ * Authenticates API calls. Inside `authorize`, every request sent through the HttpClient
77
+ * that `authorizedHttpClientLayer` provides carries that call's credentials and tenant, so
78
+ * callers never touch headers.
79
+ */
80
+ declare class ApiAuthorization extends ApiAuthorization_base {}
81
+ //#endregion
82
+ //#region src/schemas.d.ts
83
+ type PageMeta = Api.PageMeta;
84
+ type Tenant = Api.Tenant;
85
+ type User = Api.User;
86
+ type UserInvitation = Api.UserInvitation;
87
+ type TenantMembership = Api.TenantMembership;
88
+ type AuthMeResponse = Api.AuthMe;
89
+ type AuthMePrincipal = Api.Principal;
90
+ type AuthMeTenant = Api.Tenant;
91
+ type ResourceMode = Api.ResourceMode;
92
+ type ResourceGrant = Api.ResourceGrant;
93
+ type Scope = Api.Scope;
94
+ type TenantScope = Api.TenantScope;
95
+ type Session = Api.Session;
96
+ type SessionMedia = Api.SessionMedia;
97
+ type SessionProxy = Api.SessionProxy;
98
+ type ProxyConfig = Api.ProxyConfig;
99
+ type UpdateProxyConfig = Api.UpdateProxyConfig;
100
+ type ProxyUpstream = Api.ProxyUpstream;
101
+ type ProxyRule = Api.ProxyRule;
102
+ type CursorVisibility = Api.CursorVisibility;
103
+ type SessionRecording = Api.Recording;
104
+ type SessionFile = Api.SessionFile;
105
+ type SessionDirectory = Api.SessionDirectory;
106
+ type SessionFileEntry = Api.SessionFileEntry;
107
+ type SessionFileDownloadURL = Api.SessionFileDownloadURL;
108
+ type SetViewportInput = Api.SetViewportInput;
109
+ type TargetViewport = Api.TargetViewport;
110
+ type Health = Api.Health;
111
+ type AuditEvent = Api.AuditEvent;
112
+ type AuditEventsPage = Api.AuditEventPage;
113
+ type IceServer = Api.IceServer;
114
+ declare const SessionStatus: import("effect/Schema").Literals<readonly ["creating", "running", "suspended", "deleted", "expired", "failed"]>;
115
+ type SessionStatus = Api.SessionStatus;
116
+ type Snapshot = Api.Snapshot;
117
+ type ApiToken = Api.Token;
118
+ type TenantsPage = Api.TenantPage;
119
+ type UsersPage = Api.UserPage;
120
+ type SessionsPage = Api.SessionPage;
121
+ type SessionsBulkResponse = Api.SessionBulkResponse;
122
+ type SnapshotsPage = Api.SnapshotPage;
123
+ type TokensPage = Api.TokenPage;
124
+ type BrowserChannel = Api.BrowserChannel;
125
+ type BrowserChannelsResponse = Api.BrowserChannels;
126
+ type ResourceEvent = Api.Event;
127
+ type EventsPage = Api.EventPage;
128
+ type CreateSessionResponse = Api.CreateSessionResult;
129
+ type SessionMutationResponse = Api.SessionMutation;
130
+ type SnapshotMutationResponse = Api.SnapshotMutation;
131
+ type PromoteSessionResponse = Api.SnapshotMutation;
132
+ type CreateTokenResponse = Api.CreateTokenResponse;
133
+ //#endregion
134
+ //#region src/auth/schemas.d.ts
135
+ declare const LoginMethods: Schema.Struct<{
136
+ readonly methods: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
137
+ readonly type: Schema.Literal<"password">;
138
+ }>, Schema.Struct<{
139
+ readonly type: Schema.Literal<"api_token">;
140
+ }>, Schema.Struct<{
141
+ readonly type: Schema.Literal<"passkey">;
142
+ }>, Schema.Struct<{
143
+ readonly type: Schema.Literal<"oidc">;
144
+ readonly id: Schema.String;
145
+ readonly name: Schema.String;
146
+ readonly loginUrl: Schema.String;
147
+ }>]>>;
148
+ }>;
149
+ declare const PasskeyLoginOptions: Schema.Struct<{
150
+ readonly publicKey: Schema.Struct<{
151
+ readonly challenge: Schema.String;
152
+ readonly timeout: Schema.optionalKey<Schema.Number>;
153
+ readonly rpId: Schema.optionalKey<Schema.String>;
154
+ readonly allowCredentials: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Struct<{
155
+ readonly id: Schema.String;
156
+ readonly type: Schema.Literal<"public-key">;
157
+ readonly transports: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["ble", "cable", "hybrid", "internal", "nfc", "smart-card", "usb"]>>>>;
158
+ }>>>>;
159
+ readonly userVerification: Schema.optionalKey<Schema.Literals<readonly ["discouraged", "preferred", "required"]>>;
160
+ readonly hints: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["hybrid", "security-key", "client-device"]>>>>;
161
+ readonly extensions: Schema.optionalKey<Schema.Struct<{
162
+ readonly appid: Schema.optionalKey<Schema.String>;
163
+ readonly credProps: Schema.optionalKey<Schema.Boolean>;
164
+ readonly hmacCreateSecret: Schema.optionalKey<Schema.Boolean>;
165
+ readonly minPinLength: Schema.optionalKey<Schema.Boolean>;
166
+ }>>;
167
+ }>;
168
+ }>;
169
+ declare const PasskeyRegistrationOptions: Schema.Struct<{
170
+ readonly publicKey: Schema.Struct<{
171
+ readonly rp: Schema.Struct<{
172
+ readonly id: Schema.optionalKey<Schema.String>;
173
+ readonly name: Schema.String;
174
+ }>;
175
+ readonly user: Schema.Struct<{
176
+ readonly id: Schema.String;
177
+ readonly name: Schema.String;
178
+ readonly displayName: Schema.String;
179
+ }>;
180
+ readonly challenge: Schema.String;
181
+ readonly pubKeyCredParams: Schema.mutable<Schema.$Array<Schema.Struct<{
182
+ readonly alg: Schema.Literals<readonly [-7, -8, -35, -36, -37, -38, -39, -257, -258, -259]>;
183
+ readonly type: Schema.Literal<"public-key">;
184
+ }>>>;
185
+ readonly timeout: Schema.optionalKey<Schema.Number>;
186
+ readonly excludeCredentials: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Struct<{
187
+ readonly id: Schema.String;
188
+ readonly type: Schema.Literal<"public-key">;
189
+ readonly transports: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["ble", "cable", "hybrid", "internal", "nfc", "smart-card", "usb"]>>>>;
190
+ }>>>>;
191
+ readonly authenticatorSelection: Schema.optionalKey<Schema.Struct<{
192
+ readonly authenticatorAttachment: Schema.optionalKey<Schema.Literals<readonly ["platform", "cross-platform"]>>;
193
+ readonly requireResidentKey: Schema.optionalKey<Schema.Boolean>;
194
+ readonly residentKey: Schema.optionalKey<Schema.Literals<readonly ["discouraged", "preferred", "required"]>>;
195
+ readonly userVerification: Schema.optionalKey<Schema.Literals<readonly ["discouraged", "preferred", "required"]>>;
196
+ }>>;
197
+ readonly hints: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["hybrid", "security-key", "client-device"]>>>>;
198
+ readonly attestation: Schema.optionalKey<Schema.Literals<readonly ["direct", "enterprise", "indirect", "none"]>>;
199
+ readonly attestationFormats: Schema.optionalKey<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["fido-u2f", "packed", "android-safetynet", "android-key", "tpm", "apple", "none"]>>>>;
200
+ readonly extensions: Schema.optionalKey<Schema.Struct<{
201
+ readonly appid: Schema.optionalKey<Schema.String>;
202
+ readonly credProps: Schema.optionalKey<Schema.Boolean>;
203
+ readonly hmacCreateSecret: Schema.optionalKey<Schema.Boolean>;
204
+ readonly minPinLength: Schema.optionalKey<Schema.Boolean>;
205
+ }>>;
206
+ }>;
207
+ }>;
208
+ declare const Passkey: Schema.Struct<{
209
+ readonly id: Schema.String;
210
+ readonly name: Schema.String;
211
+ readonly createdAt: Schema.String;
212
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
213
+ }>;
214
+ declare const Passkeys: Schema.Struct<{
215
+ readonly passkeys: Schema.$Array<Schema.Struct<{
216
+ readonly id: Schema.String;
217
+ readonly name: Schema.String;
218
+ readonly createdAt: Schema.String;
219
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
220
+ }>>;
221
+ }>;
222
+ declare const PasskeyMutation: Schema.Struct<{
223
+ readonly passkey: Schema.Struct<{
224
+ readonly id: Schema.String;
225
+ readonly name: Schema.String;
226
+ readonly createdAt: Schema.String;
227
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
228
+ }>;
229
+ }>;
230
+ declare const PasswordLoginResponse: Schema.Struct<{
231
+ readonly mfaRequired: Schema.Boolean;
232
+ }>;
233
+ declare const SecurityStatus: Schema.Struct<{
234
+ readonly hasPassword: Schema.Boolean;
235
+ readonly totpEnabled: Schema.Boolean;
236
+ readonly recoveryCodesRemaining: Schema.Number;
237
+ }>;
238
+ declare const TOTPEnrollment: Schema.Struct<{
239
+ readonly secret: Schema.String;
240
+ readonly otpauthUrl: Schema.String;
241
+ readonly qrCodeDataUrl: Schema.String;
242
+ }>;
243
+ declare const RecoveryCodes: Schema.Struct<{
244
+ readonly recoveryCodes: Schema.$Array<Schema.String>;
245
+ }>;
246
+ type LoginMethods = typeof LoginMethods.Type;
247
+ type PasskeyLoginOptions = typeof PasskeyLoginOptions.Type;
248
+ type PasskeyRegistrationOptions = typeof PasskeyRegistrationOptions.Type;
249
+ type Passkey = typeof Passkey.Type;
250
+ type Passkeys = typeof Passkeys.Type;
251
+ type PasskeyMutation = typeof PasskeyMutation.Type;
252
+ type PasswordLoginResponse = typeof PasswordLoginResponse.Type;
253
+ type RecoveryCodes = typeof RecoveryCodes.Type;
254
+ type SecurityStatus = typeof SecurityStatus.Type;
255
+ type TOTPEnrollment = typeof TOTPEnrollment.Type;
256
+ //#endregion
257
+ //#region src/auth/service.d.ts
258
+ type Call<A> = Effect.Effect<A, ApiRequestError>;
259
+ /**
260
+ * A WebAuthn credential serialized to JSON by the browser ceremony, as
261
+ * `@aperture-browser/api-client/passkeys` produces it. The server verifies its contents.
262
+ */
263
+ interface PasskeyCredentialJSON {
264
+ readonly id: string;
265
+ readonly rawId: string;
266
+ readonly type: "public-key";
267
+ readonly response: object;
268
+ readonly clientExtensionResults: object;
269
+ }
270
+ declare const AuthApi_base: Context.ServiceClass<AuthApi, "@aperture-browser/api-client/AuthApi", {
271
+ readonly listLoginMethods: () => Call<LoginMethods>;
272
+ readonly loginWithPassword: (email: string, password: string) => Call<PasswordLoginResponse>;
273
+ readonly completePasswordMFA: (code: string) => Call<void>;
274
+ readonly loginWithAPIToken: (token: string) => Call<void>;
275
+ readonly beginPasskeyLogin: () => Call<PasskeyLoginOptions>;
276
+ readonly finishPasskeyLogin: (credential: PasskeyCredentialJSON) => Call<void>;
277
+ readonly acceptUserInvitation: (token: string, password: string) => Call<void>;
278
+ readonly logoutWebSession: () => Call<void>;
279
+ readonly getAuthMe: (selectedTenantId?: string | null, credentials?: ApiCredentials) => Call<AuthMeResponse>;
280
+ readonly getSecurityStatus: () => Call<SecurityStatus>;
281
+ readonly setPassword: (currentPassword: string, newPassword: string) => Call<void>;
282
+ readonly listPasskeys: () => Call<Passkeys>;
283
+ readonly beginPasskeyRegistration: (name: string) => Call<PasskeyRegistrationOptions>;
284
+ readonly finishPasskeyRegistration: (credential: PasskeyCredentialJSON) => Call<PasskeyMutation>;
285
+ readonly renamePasskey: (passkeyId: string, name: string) => Call<PasskeyMutation>;
286
+ readonly deletePasskey: (passkeyId: string) => Call<void>;
287
+ readonly beginTOTPEnrollment: () => Call<TOTPEnrollment>;
288
+ readonly completeTOTPEnrollment: (code: string) => Call<RecoveryCodes>;
289
+ readonly regenerateRecoveryCodes: (code: string) => Call<RecoveryCodes>;
290
+ readonly disableTOTP: (code: string) => Call<void>;
291
+ }>;
292
+ /** Browser login, account security, and the current principal. */
293
+ declare class AuthApi extends AuthApi_base {}
294
+ //#endregion
295
+ export { Tenant as $, ProxyRule as A, SessionFileEntry as B, CursorVisibility as C, PageMeta as D, IceServer as E, Scope as F, SessionStatus as G, SessionMutationResponse as H, Session as I, SetViewportInput as J, SessionsBulkResponse as K, SessionDirectory as L, ResourceEvent as M, ResourceGrant as N, PromoteSessionResponse as O, ResourceMode as P, TargetViewport as Q, SessionFile as R, CreateTokenResponse as S, Health as T, SessionProxy as U, SessionMedia as V, SessionRecording as W, SnapshotMutationResponse as X, Snapshot as Y, SnapshotsPage as Z, AuthMeResponse as _, LiveSessionErrorBody as _t, PasskeyLoginOptions as a, User as at, BrowserChannelsResponse as b, Passkeys as c, ApiAuthorization as ct, SecurityStatus as d, TENANT_HEADER as dt, TenantMembership as et, TOTPEnrollment as f, TenantHeaderMode as ft, AuthMePrincipal as g, ApiRequestError as gt, AuditEventsPage as h, ApiErrorBody as ht, Passkey as i, UpdateProxyConfig as it, ProxyUpstream as j, ProxyConfig as k, PasswordLoginResponse as l, ApiCredentials as lt, AuditEvent as m, webSessionCredentials as mt, PasskeyCredentialJSON as n, TenantsPage as nt, PasskeyMutation as o, UserInvitation as ot, ApiToken as p, resolveTenantHeader as pt, SessionsPage as q, LoginMethods as r, TokensPage as rt, PasskeyRegistrationOptions as s, UsersPage as st, AuthApi as t, TenantScope as tt, RecoveryCodes as u, Authorization as ut, AuthMeTenant as v, toApiRequestError as vt, EventsPage as w, CreateSessionResponse as x, BrowserChannel as y, SessionFileDownloadURL as z };
296
+ //# sourceMappingURL=service-DhkerN7u.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>()(\"@aperture-browser/api-client/AuthApi\") {}\n"],"mappings":";;;AAsBA,IAAa,UAAb,cAA6B,QAAQ,QA+BnC,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.82.2e4f6368108f",
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,22 +19,32 @@
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.82.2e4f6368108f"
30
33
  },
31
34
  "devDependencies": {
35
+ "@simplewebauthn/browser": "13.3.0",
32
36
  "effect": "4.0.0-rc.117",
33
37
  "vite-plus": "0.2.4"
34
38
  },
35
39
  "peerDependencies": {
40
+ "@simplewebauthn/browser": "^13.3.0",
36
41
  "effect": "^4.0.0-rc.117"
37
42
  },
43
+ "peerDependenciesMeta": {
44
+ "@simplewebauthn/browser": {
45
+ "optional": true
46
+ }
47
+ },
38
48
  "scripts": {
39
49
  "build": "vp pack",
40
50
  "typecheck": "tsgo --noEmit"