@spacelr/sdk 0.6.0 → 0.8.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/README.md CHANGED
@@ -77,6 +77,56 @@ Notes:
77
77
  - Enabling/configuring cold-tier on a collection is an **admin** operation and
78
78
  is not part of this client SDK.
79
79
 
80
+ ## Passkey authentication (WebAuthn)
81
+
82
+ The SDK never touches `navigator.credentials` and does not depend on
83
+ `@simplewebauthn` in any way (no runtime, dev, or peer dependency). It only
84
+ performs the HTTP `begin`/`verify` round trips against the gateway. The
85
+ browser WebAuthn ceremony itself — calling `navigator.credentials.get()` /
86
+ `navigator.credentials.create()` — is the caller's responsibility, typically
87
+ via the optional `@simplewebauthn/browser` package:
88
+
89
+ ```bash
90
+ npm install @simplewebauthn/browser # optional, only needed for the ceremony
91
+ ```
92
+
93
+ ```typescript
94
+ import { startAuthentication, startRegistration } from '@simplewebauthn/browser';
95
+
96
+ // --- Login ---
97
+ const opts = await spacelr.auth.beginPasskeyLogin(email);
98
+ // The SDK vendors its own self-contained WebAuthn JSON types (see
99
+ // libs/sdk/src/types/auth.ts) so it never depends on `@simplewebauthn`.
100
+ // Because of that, an `as` cast is ALWAYS required here — `@simplewebauthn/browser`
101
+ // v13's `optionsJSON` parameter uses its own DOM literal-union/named types, which
102
+ // the vendored types don't nominally match even though they're structurally identical.
103
+ const assertion = await startAuthentication({ optionsJSON: opts as never });
104
+ await spacelr.auth.verifyPasskeyLogin(assertion); // tokens stored, 'authenticated' emitted
105
+
106
+ // --- Register (while already signed in) ---
107
+ const regOpts = await spacelr.auth.beginPasskeyRegistration();
108
+ const attestation = await startRegistration({ optionsJSON: regOpts as never }); // cast required, see above
109
+ await spacelr.auth.verifyPasskeyRegistration(attestation, 'My Laptop');
110
+
111
+ // --- Manage registered credentials ---
112
+ const creds = await spacelr.auth.listPasskeys();
113
+ await spacelr.auth.renamePasskey(creds[0].credentialId, 'Renamed');
114
+ await spacelr.auth.deletePasskey(creds[0].credentialId);
115
+ ```
116
+
117
+ Notes:
118
+ - `beginPasskeyLogin` / `verifyPasskeyLogin` complete the passkey login flow;
119
+ on success tokens are stored and the SDK emits `authenticated`, the same as
120
+ `auth.login()`.
121
+ - `beginPasskeyRegistration` / `verifyPasskeyRegistration` register a new
122
+ passkey for the current session; they don't emit auth events (the caller is
123
+ already signed in).
124
+ - `listPasskeys`, `renamePasskey`, and `deletePasskey` manage the current
125
+ user's registered credentials.
126
+ - `@simplewebauthn/browser` is entirely optional and only relevant to browser
127
+ consumers performing the ceremony — Node/server usage of the SDK never
128
+ needs it.
129
+
80
130
  ## Requirements
81
131
 
82
132
  - Node.js >= 18
package/dist/index.d.mts CHANGED
@@ -146,6 +146,120 @@ interface TwoFactorVerifyParams {
146
146
  token: string;
147
147
  code: string;
148
148
  }
149
+ /**
150
+ * Vendored WebAuthn JSON interfaces.
151
+ *
152
+ * These are SDK-owned structural interfaces (no `@simplewebauthn` import and
153
+ * no new dependency in `libs/sdk/package.json`), faithful to the W3C WebAuthn
154
+ * JSON serialization — the same shape as `@simplewebauthn/browser`'s
155
+ * `PublicKeyCredentialRequestOptionsJSON` / `AuthenticationResponseJSON` /
156
+ * `PublicKeyCredentialCreationOptionsJSON` / `RegistrationResponseJSON`.
157
+ * A browser caller passes these values into `@simplewebauthn/browser`'s
158
+ * `startAuthentication({ optionsJSON })` / `startRegistration({ optionsJSON })`.
159
+ * Because these are structurally-equivalent SDK-owned types rather than
160
+ * `@simplewebauthn`'s own types, an `as` cast at that call boundary is ALWAYS
161
+ * required — not only when the installed `@simplewebauthn` version differs.
162
+ * `@simplewebauthn/browser` v13's `optionsJSON` parameter is typed with DOM
163
+ * literal-union/named types (e.g. `PublicKeyCredentialRequestOptionsJSON`),
164
+ * which these vendored interfaces do not nominally match even when
165
+ * structurally identical, so TypeScript will not accept them without a cast.
166
+ */
167
+ /** A public key credential descriptor in its JSON wire form. */
168
+ interface PasskeyCredentialDescriptorJSON {
169
+ id: string;
170
+ type: string;
171
+ transports?: string[];
172
+ }
173
+ /** WebAuthn assertion (`navigator.credentials.get`) request options, JSON form. */
174
+ interface PasskeyAuthenticationOptionsJSON {
175
+ challenge: string;
176
+ rpId?: string;
177
+ timeout?: number;
178
+ userVerification?: string;
179
+ allowCredentials?: PasskeyCredentialDescriptorJSON[];
180
+ extensions?: Record<string, unknown>;
181
+ }
182
+ /** WebAuthn assertion (`navigator.credentials.get`) response, JSON form. */
183
+ interface PasskeyAuthenticationResponseJSON {
184
+ id: string;
185
+ rawId: string;
186
+ type: string;
187
+ response: {
188
+ clientDataJSON: string;
189
+ authenticatorData: string;
190
+ signature: string;
191
+ userHandle?: string;
192
+ };
193
+ clientExtensionResults?: Record<string, unknown>;
194
+ authenticatorAttachment?: string;
195
+ }
196
+ /** WebAuthn attestation (`navigator.credentials.create`) request options, JSON form. */
197
+ interface PasskeyRegistrationOptionsJSON {
198
+ challenge: string;
199
+ rp: {
200
+ id?: string;
201
+ name: string;
202
+ };
203
+ user: {
204
+ id: string;
205
+ name: string;
206
+ displayName: string;
207
+ };
208
+ pubKeyCredParams: Array<{
209
+ type: string;
210
+ alg: number;
211
+ }>;
212
+ timeout?: number;
213
+ excludeCredentials?: PasskeyCredentialDescriptorJSON[];
214
+ authenticatorSelection?: Record<string, unknown>;
215
+ attestation?: string;
216
+ extensions?: Record<string, unknown>;
217
+ }
218
+ /** WebAuthn attestation (`navigator.credentials.create`) response, JSON form. */
219
+ interface PasskeyRegistrationResponseJSON {
220
+ id: string;
221
+ rawId: string;
222
+ type: string;
223
+ response: {
224
+ clientDataJSON: string;
225
+ attestationObject: string;
226
+ transports?: string[];
227
+ };
228
+ clientExtensionResults?: Record<string, unknown>;
229
+ authenticatorAttachment?: string;
230
+ }
231
+ /**
232
+ * Response returned by the passkey login flow.
233
+ *
234
+ * This is intentionally a SEPARATE type from `LoginResponse`, not an alias:
235
+ * the gateway's passkey mapper drops `user.sub`/`user.username`, returning
236
+ * only `{ id, email, roles }`, so `LoginResponse` (which requires `user.sub`)
237
+ * would not structurally match.
238
+ */
239
+ interface PasskeyLoginResponse {
240
+ user: {
241
+ id: string;
242
+ email: string;
243
+ roles: string[];
244
+ };
245
+ access_token: string;
246
+ refresh_token?: string;
247
+ expires_in?: number;
248
+ }
249
+ /** Result of verifying a passkey registration attestation. */
250
+ interface PasskeyRegistrationResult {
251
+ verified: boolean;
252
+ }
253
+ /** A registered passkey credential, as returned by the credential-list endpoint. */
254
+ interface PasskeyCredential {
255
+ credentialId: string;
256
+ label?: string;
257
+ deviceType?: string;
258
+ backedUp?: boolean;
259
+ transports?: string[];
260
+ createdAt: string;
261
+ lastUsedAt?: string;
262
+ }
149
263
 
150
264
  interface TokenStorage {
151
265
  getTokens(): Promise<StoredTokens | null>;
@@ -703,6 +817,45 @@ declare class AuthModule {
703
817
  * Call this after catching SpacelrTwoFactorRequiredError from login().
704
818
  */
705
819
  verifyTwoFactor(params: TwoFactorVerifyParams): Promise<LoginResponse>;
820
+ /**
821
+ * Fetch WebAuthn assertion options to start a passkey login.
822
+ * Pass `email` to scope the challenge to a known user's registered
823
+ * credentials; omit it for a discoverable-credential (usernameless) flow.
824
+ */
825
+ beginPasskeyLogin(email?: string): Promise<PasskeyAuthenticationOptionsJSON>;
826
+ /**
827
+ * Verify a WebAuthn assertion produced by `navigator.credentials.get()`
828
+ * against the options returned by `beginPasskeyLogin()`, completing login.
829
+ */
830
+ verifyPasskeyLogin(response: PasskeyAuthenticationResponseJSON): Promise<PasskeyLoginResponse>;
831
+ /**
832
+ * Fetch WebAuthn attestation options to register a new passkey for the
833
+ * currently authenticated user.
834
+ */
835
+ beginPasskeyRegistration(): Promise<PasskeyRegistrationOptionsJSON>;
836
+ /**
837
+ * Verify a WebAuthn attestation produced by `navigator.credentials.create()`
838
+ * against the options returned by `beginPasskeyRegistration()`, saving the
839
+ * new credential under the current user. This does not issue tokens or
840
+ * change auth state — the caller is already authenticated.
841
+ */
842
+ verifyPasskeyRegistration(response: PasskeyRegistrationResponseJSON, label?: string): Promise<PasskeyRegistrationResult>;
843
+ /**
844
+ * List the WebAuthn passkey credentials registered for the current user.
845
+ */
846
+ listPasskeys(): Promise<PasskeyCredential[]>;
847
+ /**
848
+ * Rename a registered passkey credential (e.g. "My Laptop").
849
+ */
850
+ renamePasskey(credentialId: string, label: string): Promise<{
851
+ renamed: true;
852
+ }>;
853
+ /**
854
+ * Delete a registered passkey credential.
855
+ */
856
+ deletePasskey(credentialId: string): Promise<{
857
+ deleted: true;
858
+ }>;
706
859
  private storeTokensFromLogin;
707
860
  private storeTokensFromRegister;
708
861
  }
@@ -1582,4 +1735,4 @@ interface SpacelrClient {
1582
1735
  }
1583
1736
  declare function createClient(config: SpacelrClientConfig): SpacelrClient;
1584
1737
 
1585
- export { type ApiResponse, type AuthLostReason, type AuthState, type AuthStateListener, type AuthorizationUrlParams, BrowserTokenStorage, CodeChallengeMethod, type ConnectionState, CursorInvalidError, type CursorStorage, type DatabaseChangeEvent, type DownloadUrlResponse, type ExchangeCodeParams, type FileInfo, type FileListResponse, FileVisibility, ForbiddenError, type FunctionInvokeOptions, type FunctionInvokeResult, type GapReason, GrantType, type InitMultipartUploadParams, type InitMultipartUploadResponse, type JWK, type JWKSResponse, type ListFilesParams, type LoginParams, type LoginResponse, MemoryTokenStorage, NotFoundError, type OpenIDConfiguration, type PKCEChallenge, type PartEtag, type PushSubscriptionInfo, type QuotaInfo, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrSearchFilterRequiredError, SpacelrTimeoutError, SpacelrTwoFactorRequiredError, type StoredTokens, type StreamGapInfo, type StreamSubscription, type SubscribeEventsHandlers, type SubscribeHandlers, type SubscribeWithSnapshotOptions, type TimelineAndFilter, TimelineError, type TimelineFieldFilter, type TimelineFilter, type TimelineLeafFilter, TimelineModule, type TimelineOrderBy, type TimelineQueryOptions, type TimelineQueryResponse, type TimelineScalar, type TimelineSourceStats, TimeoutError, type TokenResponse, type TokenStorage, type TwoFactorResponse, type TwoFactorVerifyParams, type UnshareFileParams, type UploadFileParams, type UploadLargeFileParams, type UploadProgress, type UserInfo, type UserProfile, ValidationError, type VapidKeyResponse, createClient, generatePKCEChallenge, localStorageCursorStorage, memoryCursorStorage };
1738
+ export { type ApiResponse, type AuthLostReason, type AuthState, type AuthStateListener, type AuthorizationUrlParams, BrowserTokenStorage, CodeChallengeMethod, type ConnectionState, CursorInvalidError, type CursorStorage, type DatabaseChangeEvent, type DownloadUrlResponse, type ExchangeCodeParams, type FileInfo, type FileListResponse, FileVisibility, ForbiddenError, type FunctionInvokeOptions, type FunctionInvokeResult, type GapReason, GrantType, type InitMultipartUploadParams, type InitMultipartUploadResponse, type JWK, type JWKSResponse, type ListFilesParams, type LoginParams, type LoginResponse, MemoryTokenStorage, NotFoundError, type OpenIDConfiguration, type PKCEChallenge, type PartEtag, type PasskeyAuthenticationOptionsJSON, type PasskeyAuthenticationResponseJSON, type PasskeyCredential, type PasskeyCredentialDescriptorJSON, type PasskeyLoginResponse, type PasskeyRegistrationOptionsJSON, type PasskeyRegistrationResponseJSON, type PasskeyRegistrationResult, type PushSubscriptionInfo, type QuotaInfo, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrSearchFilterRequiredError, SpacelrTimeoutError, SpacelrTwoFactorRequiredError, type StoredTokens, type StreamGapInfo, type StreamSubscription, type SubscribeEventsHandlers, type SubscribeHandlers, type SubscribeWithSnapshotOptions, type TimelineAndFilter, TimelineError, type TimelineFieldFilter, type TimelineFilter, type TimelineLeafFilter, TimelineModule, type TimelineOrderBy, type TimelineQueryOptions, type TimelineQueryResponse, type TimelineScalar, type TimelineSourceStats, TimeoutError, type TokenResponse, type TokenStorage, type TwoFactorResponse, type TwoFactorVerifyParams, type UnshareFileParams, type UploadFileParams, type UploadLargeFileParams, type UploadProgress, type UserInfo, type UserProfile, ValidationError, type VapidKeyResponse, createClient, generatePKCEChallenge, localStorageCursorStorage, memoryCursorStorage };
package/dist/index.d.ts CHANGED
@@ -146,6 +146,120 @@ interface TwoFactorVerifyParams {
146
146
  token: string;
147
147
  code: string;
148
148
  }
149
+ /**
150
+ * Vendored WebAuthn JSON interfaces.
151
+ *
152
+ * These are SDK-owned structural interfaces (no `@simplewebauthn` import and
153
+ * no new dependency in `libs/sdk/package.json`), faithful to the W3C WebAuthn
154
+ * JSON serialization — the same shape as `@simplewebauthn/browser`'s
155
+ * `PublicKeyCredentialRequestOptionsJSON` / `AuthenticationResponseJSON` /
156
+ * `PublicKeyCredentialCreationOptionsJSON` / `RegistrationResponseJSON`.
157
+ * A browser caller passes these values into `@simplewebauthn/browser`'s
158
+ * `startAuthentication({ optionsJSON })` / `startRegistration({ optionsJSON })`.
159
+ * Because these are structurally-equivalent SDK-owned types rather than
160
+ * `@simplewebauthn`'s own types, an `as` cast at that call boundary is ALWAYS
161
+ * required — not only when the installed `@simplewebauthn` version differs.
162
+ * `@simplewebauthn/browser` v13's `optionsJSON` parameter is typed with DOM
163
+ * literal-union/named types (e.g. `PublicKeyCredentialRequestOptionsJSON`),
164
+ * which these vendored interfaces do not nominally match even when
165
+ * structurally identical, so TypeScript will not accept them without a cast.
166
+ */
167
+ /** A public key credential descriptor in its JSON wire form. */
168
+ interface PasskeyCredentialDescriptorJSON {
169
+ id: string;
170
+ type: string;
171
+ transports?: string[];
172
+ }
173
+ /** WebAuthn assertion (`navigator.credentials.get`) request options, JSON form. */
174
+ interface PasskeyAuthenticationOptionsJSON {
175
+ challenge: string;
176
+ rpId?: string;
177
+ timeout?: number;
178
+ userVerification?: string;
179
+ allowCredentials?: PasskeyCredentialDescriptorJSON[];
180
+ extensions?: Record<string, unknown>;
181
+ }
182
+ /** WebAuthn assertion (`navigator.credentials.get`) response, JSON form. */
183
+ interface PasskeyAuthenticationResponseJSON {
184
+ id: string;
185
+ rawId: string;
186
+ type: string;
187
+ response: {
188
+ clientDataJSON: string;
189
+ authenticatorData: string;
190
+ signature: string;
191
+ userHandle?: string;
192
+ };
193
+ clientExtensionResults?: Record<string, unknown>;
194
+ authenticatorAttachment?: string;
195
+ }
196
+ /** WebAuthn attestation (`navigator.credentials.create`) request options, JSON form. */
197
+ interface PasskeyRegistrationOptionsJSON {
198
+ challenge: string;
199
+ rp: {
200
+ id?: string;
201
+ name: string;
202
+ };
203
+ user: {
204
+ id: string;
205
+ name: string;
206
+ displayName: string;
207
+ };
208
+ pubKeyCredParams: Array<{
209
+ type: string;
210
+ alg: number;
211
+ }>;
212
+ timeout?: number;
213
+ excludeCredentials?: PasskeyCredentialDescriptorJSON[];
214
+ authenticatorSelection?: Record<string, unknown>;
215
+ attestation?: string;
216
+ extensions?: Record<string, unknown>;
217
+ }
218
+ /** WebAuthn attestation (`navigator.credentials.create`) response, JSON form. */
219
+ interface PasskeyRegistrationResponseJSON {
220
+ id: string;
221
+ rawId: string;
222
+ type: string;
223
+ response: {
224
+ clientDataJSON: string;
225
+ attestationObject: string;
226
+ transports?: string[];
227
+ };
228
+ clientExtensionResults?: Record<string, unknown>;
229
+ authenticatorAttachment?: string;
230
+ }
231
+ /**
232
+ * Response returned by the passkey login flow.
233
+ *
234
+ * This is intentionally a SEPARATE type from `LoginResponse`, not an alias:
235
+ * the gateway's passkey mapper drops `user.sub`/`user.username`, returning
236
+ * only `{ id, email, roles }`, so `LoginResponse` (which requires `user.sub`)
237
+ * would not structurally match.
238
+ */
239
+ interface PasskeyLoginResponse {
240
+ user: {
241
+ id: string;
242
+ email: string;
243
+ roles: string[];
244
+ };
245
+ access_token: string;
246
+ refresh_token?: string;
247
+ expires_in?: number;
248
+ }
249
+ /** Result of verifying a passkey registration attestation. */
250
+ interface PasskeyRegistrationResult {
251
+ verified: boolean;
252
+ }
253
+ /** A registered passkey credential, as returned by the credential-list endpoint. */
254
+ interface PasskeyCredential {
255
+ credentialId: string;
256
+ label?: string;
257
+ deviceType?: string;
258
+ backedUp?: boolean;
259
+ transports?: string[];
260
+ createdAt: string;
261
+ lastUsedAt?: string;
262
+ }
149
263
 
150
264
  interface TokenStorage {
151
265
  getTokens(): Promise<StoredTokens | null>;
@@ -703,6 +817,45 @@ declare class AuthModule {
703
817
  * Call this after catching SpacelrTwoFactorRequiredError from login().
704
818
  */
705
819
  verifyTwoFactor(params: TwoFactorVerifyParams): Promise<LoginResponse>;
820
+ /**
821
+ * Fetch WebAuthn assertion options to start a passkey login.
822
+ * Pass `email` to scope the challenge to a known user's registered
823
+ * credentials; omit it for a discoverable-credential (usernameless) flow.
824
+ */
825
+ beginPasskeyLogin(email?: string): Promise<PasskeyAuthenticationOptionsJSON>;
826
+ /**
827
+ * Verify a WebAuthn assertion produced by `navigator.credentials.get()`
828
+ * against the options returned by `beginPasskeyLogin()`, completing login.
829
+ */
830
+ verifyPasskeyLogin(response: PasskeyAuthenticationResponseJSON): Promise<PasskeyLoginResponse>;
831
+ /**
832
+ * Fetch WebAuthn attestation options to register a new passkey for the
833
+ * currently authenticated user.
834
+ */
835
+ beginPasskeyRegistration(): Promise<PasskeyRegistrationOptionsJSON>;
836
+ /**
837
+ * Verify a WebAuthn attestation produced by `navigator.credentials.create()`
838
+ * against the options returned by `beginPasskeyRegistration()`, saving the
839
+ * new credential under the current user. This does not issue tokens or
840
+ * change auth state — the caller is already authenticated.
841
+ */
842
+ verifyPasskeyRegistration(response: PasskeyRegistrationResponseJSON, label?: string): Promise<PasskeyRegistrationResult>;
843
+ /**
844
+ * List the WebAuthn passkey credentials registered for the current user.
845
+ */
846
+ listPasskeys(): Promise<PasskeyCredential[]>;
847
+ /**
848
+ * Rename a registered passkey credential (e.g. "My Laptop").
849
+ */
850
+ renamePasskey(credentialId: string, label: string): Promise<{
851
+ renamed: true;
852
+ }>;
853
+ /**
854
+ * Delete a registered passkey credential.
855
+ */
856
+ deletePasskey(credentialId: string): Promise<{
857
+ deleted: true;
858
+ }>;
706
859
  private storeTokensFromLogin;
707
860
  private storeTokensFromRegister;
708
861
  }
@@ -1582,4 +1735,4 @@ interface SpacelrClient {
1582
1735
  }
1583
1736
  declare function createClient(config: SpacelrClientConfig): SpacelrClient;
1584
1737
 
1585
- export { type ApiResponse, type AuthLostReason, type AuthState, type AuthStateListener, type AuthorizationUrlParams, BrowserTokenStorage, CodeChallengeMethod, type ConnectionState, CursorInvalidError, type CursorStorage, type DatabaseChangeEvent, type DownloadUrlResponse, type ExchangeCodeParams, type FileInfo, type FileListResponse, FileVisibility, ForbiddenError, type FunctionInvokeOptions, type FunctionInvokeResult, type GapReason, GrantType, type InitMultipartUploadParams, type InitMultipartUploadResponse, type JWK, type JWKSResponse, type ListFilesParams, type LoginParams, type LoginResponse, MemoryTokenStorage, NotFoundError, type OpenIDConfiguration, type PKCEChallenge, type PartEtag, type PushSubscriptionInfo, type QuotaInfo, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrSearchFilterRequiredError, SpacelrTimeoutError, SpacelrTwoFactorRequiredError, type StoredTokens, type StreamGapInfo, type StreamSubscription, type SubscribeEventsHandlers, type SubscribeHandlers, type SubscribeWithSnapshotOptions, type TimelineAndFilter, TimelineError, type TimelineFieldFilter, type TimelineFilter, type TimelineLeafFilter, TimelineModule, type TimelineOrderBy, type TimelineQueryOptions, type TimelineQueryResponse, type TimelineScalar, type TimelineSourceStats, TimeoutError, type TokenResponse, type TokenStorage, type TwoFactorResponse, type TwoFactorVerifyParams, type UnshareFileParams, type UploadFileParams, type UploadLargeFileParams, type UploadProgress, type UserInfo, type UserProfile, ValidationError, type VapidKeyResponse, createClient, generatePKCEChallenge, localStorageCursorStorage, memoryCursorStorage };
1738
+ export { type ApiResponse, type AuthLostReason, type AuthState, type AuthStateListener, type AuthorizationUrlParams, BrowserTokenStorage, CodeChallengeMethod, type ConnectionState, CursorInvalidError, type CursorStorage, type DatabaseChangeEvent, type DownloadUrlResponse, type ExchangeCodeParams, type FileInfo, type FileListResponse, FileVisibility, ForbiddenError, type FunctionInvokeOptions, type FunctionInvokeResult, type GapReason, GrantType, type InitMultipartUploadParams, type InitMultipartUploadResponse, type JWK, type JWKSResponse, type ListFilesParams, type LoginParams, type LoginResponse, MemoryTokenStorage, NotFoundError, type OpenIDConfiguration, type PKCEChallenge, type PartEtag, type PasskeyAuthenticationOptionsJSON, type PasskeyAuthenticationResponseJSON, type PasskeyCredential, type PasskeyCredentialDescriptorJSON, type PasskeyLoginResponse, type PasskeyRegistrationOptionsJSON, type PasskeyRegistrationResponseJSON, type PasskeyRegistrationResult, type PushSubscriptionInfo, type QuotaInfo, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrSearchFilterRequiredError, SpacelrTimeoutError, SpacelrTwoFactorRequiredError, type StoredTokens, type StreamGapInfo, type StreamSubscription, type SubscribeEventsHandlers, type SubscribeHandlers, type SubscribeWithSnapshotOptions, type TimelineAndFilter, TimelineError, type TimelineFieldFilter, type TimelineFilter, type TimelineLeafFilter, TimelineModule, type TimelineOrderBy, type TimelineQueryOptions, type TimelineQueryResponse, type TimelineScalar, type TimelineSourceStats, TimeoutError, type TokenResponse, type TokenStorage, type TwoFactorResponse, type TwoFactorVerifyParams, type UnshareFileParams, type UploadFileParams, type UploadLargeFileParams, type UploadProgress, type UserInfo, type UserProfile, ValidationError, type VapidKeyResponse, createClient, generatePKCEChallenge, localStorageCursorStorage, memoryCursorStorage };
package/dist/index.js CHANGED
@@ -1590,6 +1590,88 @@ var AuthModule = class {
1590
1590
  await this.storeTokensFromLogin(response);
1591
1591
  return response;
1592
1592
  }
1593
+ /**
1594
+ * Fetch WebAuthn assertion options to start a passkey login.
1595
+ * Pass `email` to scope the challenge to a known user's registered
1596
+ * credentials; omit it for a discoverable-credential (usernameless) flow.
1597
+ */
1598
+ async beginPasskeyLogin(email) {
1599
+ return this.http.request({
1600
+ method: "POST",
1601
+ path: "/auth/passkey/login/options",
1602
+ body: email ? { email } : {}
1603
+ });
1604
+ }
1605
+ /**
1606
+ * Verify a WebAuthn assertion produced by `navigator.credentials.get()`
1607
+ * against the options returned by `beginPasskeyLogin()`, completing login.
1608
+ */
1609
+ async verifyPasskeyLogin(response) {
1610
+ const result = await this.http.request({
1611
+ method: "POST",
1612
+ path: "/auth/passkey/login/verify",
1613
+ body: { response }
1614
+ });
1615
+ await this.storeTokensFromLogin(result);
1616
+ return result;
1617
+ }
1618
+ /**
1619
+ * Fetch WebAuthn attestation options to register a new passkey for the
1620
+ * currently authenticated user.
1621
+ */
1622
+ async beginPasskeyRegistration() {
1623
+ return this.http.request({
1624
+ method: "POST",
1625
+ path: "/auth/passkey/register/options",
1626
+ authenticated: true,
1627
+ body: {}
1628
+ });
1629
+ }
1630
+ /**
1631
+ * Verify a WebAuthn attestation produced by `navigator.credentials.create()`
1632
+ * against the options returned by `beginPasskeyRegistration()`, saving the
1633
+ * new credential under the current user. This does not issue tokens or
1634
+ * change auth state — the caller is already authenticated.
1635
+ */
1636
+ async verifyPasskeyRegistration(response, label) {
1637
+ return this.http.request({
1638
+ method: "POST",
1639
+ path: "/auth/passkey/register/verify",
1640
+ authenticated: true,
1641
+ body: { response, label }
1642
+ });
1643
+ }
1644
+ /**
1645
+ * List the WebAuthn passkey credentials registered for the current user.
1646
+ */
1647
+ async listPasskeys() {
1648
+ return this.http.request({
1649
+ method: "GET",
1650
+ path: "/auth/passkey/credentials",
1651
+ authenticated: true
1652
+ });
1653
+ }
1654
+ /**
1655
+ * Rename a registered passkey credential (e.g. "My Laptop").
1656
+ */
1657
+ async renamePasskey(credentialId, label) {
1658
+ return this.http.request({
1659
+ method: "PATCH",
1660
+ path: `/auth/passkey/credentials/${encodeURIComponent(credentialId)}`,
1661
+ authenticated: true,
1662
+ body: { label }
1663
+ });
1664
+ }
1665
+ /**
1666
+ * Delete a registered passkey credential.
1667
+ */
1668
+ async deletePasskey(credentialId) {
1669
+ return this.http.request({
1670
+ method: "DELETE",
1671
+ path: `/auth/passkey/credentials/${encodeURIComponent(credentialId)}`,
1672
+ authenticated: true
1673
+ });
1674
+ }
1593
1675
  async storeTokensFromLogin(response) {
1594
1676
  const expiresAt = response.expires_in ? Math.floor(Date.now() / 1e3) + response.expires_in : void 0;
1595
1677
  await this.tokenManager.setTokens({