@arbidocs/client 0.5.20 → 0.5.21
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/dist/index.cjs +41 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1763,6 +1763,45 @@ async function changePassword(params, deps) {
|
|
|
1763
1763
|
return { wrappedIdentityKey: request.wrapped_identity_key };
|
|
1764
1764
|
}
|
|
1765
1765
|
|
|
1766
|
+
// src/auth/disconnect-sso.ts
|
|
1767
|
+
var endpointClient = (client) => client;
|
|
1768
|
+
async function requestSsoDisconnectCode(newEmail, deps) {
|
|
1769
|
+
const response = await endpointClient(deps.fetchClient).POST("/v1/user/sso-disconnect-code", {
|
|
1770
|
+
body: { new_email: newEmail.trim().toLowerCase() }
|
|
1771
|
+
});
|
|
1772
|
+
if (response.error) throw new Error(passwordChangeErrorMessage(response.error));
|
|
1773
|
+
}
|
|
1774
|
+
async function disconnectSso(params, deps) {
|
|
1775
|
+
const email = params.newEmail.trim().toLowerCase();
|
|
1776
|
+
const identity = await unlockIdentityWithPassword(
|
|
1777
|
+
params.email,
|
|
1778
|
+
params.password,
|
|
1779
|
+
deps.deploymentDomain
|
|
1780
|
+
);
|
|
1781
|
+
const current = await generateUserKeypairs(params.email, params.password, deps.deploymentDomain);
|
|
1782
|
+
const replacement = await generateUserKeypairs(email, params.password, deps.deploymentDomain);
|
|
1783
|
+
const timestamp = Math.floor(Date.now() / 1e3);
|
|
1784
|
+
const newLoginKey = bytesToBase64(replacement.signingKeyPair.publicKey);
|
|
1785
|
+
const wrappedIdentityKey = wrapIdentityKey(identity, replacement.signingKeyPair.secretKey);
|
|
1786
|
+
const signature = signMessage(
|
|
1787
|
+
`disconnect-sso|${params.userExtId}|${email}|${timestamp}|${newLoginKey}|${wrappedIdentityKey}`,
|
|
1788
|
+
current.signingKeyPair.secretKey
|
|
1789
|
+
);
|
|
1790
|
+
const response = await endpointClient(deps.fetchClient).POST("/v1/user/disconnect-sso", {
|
|
1791
|
+
body: {
|
|
1792
|
+
new_email: email,
|
|
1793
|
+
verification_code: params.code || void 0,
|
|
1794
|
+
timestamp,
|
|
1795
|
+
signature,
|
|
1796
|
+
new_login_key: newLoginKey,
|
|
1797
|
+
wrapped_identity_key: wrappedIdentityKey
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
if (response.error) throw new Error(passwordChangeErrorMessage(response.error));
|
|
1801
|
+
await updateWrappedIdentityKey(wrappedIdentityKey);
|
|
1802
|
+
return { email };
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1766
1805
|
// src/client.ts
|
|
1767
1806
|
var API_PREFIX = "/v1";
|
|
1768
1807
|
var RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
@@ -2229,6 +2268,7 @@ exports.decryptWithChatKey = decryptWithChatKey;
|
|
|
2229
2268
|
exports.deriveDirectChatKey = deriveDirectChatKey;
|
|
2230
2269
|
exports.deriveEncryptionKeypairFromSigning = deriveEncryptionKeypairFromSigning;
|
|
2231
2270
|
exports.derivePublicKey = derivePublicKey;
|
|
2271
|
+
exports.disconnectSso = disconnectSso;
|
|
2232
2272
|
exports.encodeCallKey = encodeCallKey;
|
|
2233
2273
|
exports.encryptCallTitle = encryptCallTitle;
|
|
2234
2274
|
exports.encryptFile = encryptFile;
|
|
@@ -2266,6 +2306,7 @@ exports.parseServerMessage = parseServerMessage;
|
|
|
2266
2306
|
exports.passwordChangeErrorMessage = passwordChangeErrorMessage;
|
|
2267
2307
|
exports.prewarmKeyPairs = prewarmKeyPairs;
|
|
2268
2308
|
exports.readSessionClaims = readSessionClaims;
|
|
2309
|
+
exports.requestSsoDisconnectCode = requestSsoDisconnectCode;
|
|
2269
2310
|
exports.saveSession = saveSession;
|
|
2270
2311
|
exports.sealCallKey = sealCallKey;
|
|
2271
2312
|
exports.sealCallKeyForPeers = sealCallKeyForPeers;
|