@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 +50 -0
- package/dist/index.d.mts +154 -1
- package/dist/index.d.ts +154 -1
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1547,6 +1547,88 @@ var AuthModule = class {
|
|
|
1547
1547
|
await this.storeTokensFromLogin(response);
|
|
1548
1548
|
return response;
|
|
1549
1549
|
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Fetch WebAuthn assertion options to start a passkey login.
|
|
1552
|
+
* Pass `email` to scope the challenge to a known user's registered
|
|
1553
|
+
* credentials; omit it for a discoverable-credential (usernameless) flow.
|
|
1554
|
+
*/
|
|
1555
|
+
async beginPasskeyLogin(email) {
|
|
1556
|
+
return this.http.request({
|
|
1557
|
+
method: "POST",
|
|
1558
|
+
path: "/auth/passkey/login/options",
|
|
1559
|
+
body: email ? { email } : {}
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Verify a WebAuthn assertion produced by `navigator.credentials.get()`
|
|
1564
|
+
* against the options returned by `beginPasskeyLogin()`, completing login.
|
|
1565
|
+
*/
|
|
1566
|
+
async verifyPasskeyLogin(response) {
|
|
1567
|
+
const result = await this.http.request({
|
|
1568
|
+
method: "POST",
|
|
1569
|
+
path: "/auth/passkey/login/verify",
|
|
1570
|
+
body: { response }
|
|
1571
|
+
});
|
|
1572
|
+
await this.storeTokensFromLogin(result);
|
|
1573
|
+
return result;
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Fetch WebAuthn attestation options to register a new passkey for the
|
|
1577
|
+
* currently authenticated user.
|
|
1578
|
+
*/
|
|
1579
|
+
async beginPasskeyRegistration() {
|
|
1580
|
+
return this.http.request({
|
|
1581
|
+
method: "POST",
|
|
1582
|
+
path: "/auth/passkey/register/options",
|
|
1583
|
+
authenticated: true,
|
|
1584
|
+
body: {}
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Verify a WebAuthn attestation produced by `navigator.credentials.create()`
|
|
1589
|
+
* against the options returned by `beginPasskeyRegistration()`, saving the
|
|
1590
|
+
* new credential under the current user. This does not issue tokens or
|
|
1591
|
+
* change auth state — the caller is already authenticated.
|
|
1592
|
+
*/
|
|
1593
|
+
async verifyPasskeyRegistration(response, label) {
|
|
1594
|
+
return this.http.request({
|
|
1595
|
+
method: "POST",
|
|
1596
|
+
path: "/auth/passkey/register/verify",
|
|
1597
|
+
authenticated: true,
|
|
1598
|
+
body: { response, label }
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
/**
|
|
1602
|
+
* List the WebAuthn passkey credentials registered for the current user.
|
|
1603
|
+
*/
|
|
1604
|
+
async listPasskeys() {
|
|
1605
|
+
return this.http.request({
|
|
1606
|
+
method: "GET",
|
|
1607
|
+
path: "/auth/passkey/credentials",
|
|
1608
|
+
authenticated: true
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* Rename a registered passkey credential (e.g. "My Laptop").
|
|
1613
|
+
*/
|
|
1614
|
+
async renamePasskey(credentialId, label) {
|
|
1615
|
+
return this.http.request({
|
|
1616
|
+
method: "PATCH",
|
|
1617
|
+
path: `/auth/passkey/credentials/${encodeURIComponent(credentialId)}`,
|
|
1618
|
+
authenticated: true,
|
|
1619
|
+
body: { label }
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Delete a registered passkey credential.
|
|
1624
|
+
*/
|
|
1625
|
+
async deletePasskey(credentialId) {
|
|
1626
|
+
return this.http.request({
|
|
1627
|
+
method: "DELETE",
|
|
1628
|
+
path: `/auth/passkey/credentials/${encodeURIComponent(credentialId)}`,
|
|
1629
|
+
authenticated: true
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1550
1632
|
async storeTokensFromLogin(response) {
|
|
1551
1633
|
const expiresAt = response.expires_in ? Math.floor(Date.now() / 1e3) + response.expires_in : void 0;
|
|
1552
1634
|
await this.tokenManager.setTokens({
|