@rebasepro/client 0.6.1 → 0.7.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/dist/admin.d.ts +13 -0
- package/dist/api-keys.d.ts +65 -0
- package/dist/auth.d.ts +10 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +85 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +85 -0
- package/dist/index.umd.js.map +1 -1
- package/package.json +12 -12
- package/src/admin.ts +19 -0
- package/src/api-keys.ts +109 -0
- package/src/auth.ts +30 -0
- package/src/index.ts +6 -0
- package/LICENSE +0 -21
package/dist/index.umd.js
CHANGED
|
@@ -589,6 +589,31 @@
|
|
|
589
589
|
if (!res.ok) throwApiError(res.status, body, res.statusText);
|
|
590
590
|
return body;
|
|
591
591
|
}
|
|
592
|
+
async function sendMagicLink(email) {
|
|
593
|
+
const res = await getFetch()(authUrl("/magic-link"), {
|
|
594
|
+
method: "POST",
|
|
595
|
+
headers: { "Content-Type": "application/json" },
|
|
596
|
+
body: JSON.stringify({ email })
|
|
597
|
+
});
|
|
598
|
+
const body = await res.json().catch(() => ({}));
|
|
599
|
+
if (!res.ok) throwApiError(res.status, body, res.statusText);
|
|
600
|
+
return body;
|
|
601
|
+
}
|
|
602
|
+
async function verifyMagicLink(token) {
|
|
603
|
+
const res = await getFetch()(authUrl("/magic-link/verify"), {
|
|
604
|
+
method: "POST",
|
|
605
|
+
headers: { "Content-Type": "application/json" },
|
|
606
|
+
body: JSON.stringify({ token })
|
|
607
|
+
});
|
|
608
|
+
const body = await res.json().catch(() => ({}));
|
|
609
|
+
if (!res.ok) throwApiError(res.status, body, res.statusText);
|
|
610
|
+
const session = handleAuthResponse(body, "SIGNED_IN");
|
|
611
|
+
return {
|
|
612
|
+
user: session.user,
|
|
613
|
+
accessToken: session.accessToken,
|
|
614
|
+
refreshToken: session.refreshToken
|
|
615
|
+
};
|
|
616
|
+
}
|
|
592
617
|
async function getSessions() {
|
|
593
618
|
return (await transport.request(authPath + "/sessions", { method: "GET" })).sessions;
|
|
594
619
|
}
|
|
@@ -665,6 +690,8 @@
|
|
|
665
690
|
changePassword,
|
|
666
691
|
sendVerificationEmail,
|
|
667
692
|
verifyEmail,
|
|
693
|
+
sendMagicLink,
|
|
694
|
+
verifyMagicLink,
|
|
668
695
|
getSessions,
|
|
669
696
|
revokeSession,
|
|
670
697
|
revokeAllSessions,
|
|
@@ -745,6 +772,15 @@
|
|
|
745
772
|
async function deleteUser(userId) {
|
|
746
773
|
return transport.request(adminPath + "/users/" + encodeURIComponent(userId), { method: "DELETE" });
|
|
747
774
|
}
|
|
775
|
+
async function resetPassword(userId, options) {
|
|
776
|
+
return transport.request(adminPath + "/users/" + encodeURIComponent(userId) + "/reset-password", {
|
|
777
|
+
method: "POST",
|
|
778
|
+
...options?.password ? { body: JSON.stringify({ password: options.password }) } : {}
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
async function listRoles() {
|
|
782
|
+
return transport.request(adminPath + "/roles", { method: "GET" });
|
|
783
|
+
}
|
|
748
784
|
async function bootstrap() {
|
|
749
785
|
return transport.request(adminPath + "/bootstrap", { method: "POST" });
|
|
750
786
|
}
|
|
@@ -755,6 +791,8 @@
|
|
|
755
791
|
createUser,
|
|
756
792
|
updateUser,
|
|
757
793
|
deleteUser,
|
|
794
|
+
resetPassword,
|
|
795
|
+
listRoles,
|
|
758
796
|
bootstrap
|
|
759
797
|
};
|
|
760
798
|
}
|
|
@@ -792,6 +830,50 @@
|
|
|
792
830
|
};
|
|
793
831
|
}
|
|
794
832
|
//#endregion
|
|
833
|
+
//#region src/api-keys.ts
|
|
834
|
+
/**
|
|
835
|
+
* Creates a client for managing API keys via the admin routes.
|
|
836
|
+
*
|
|
837
|
+
* @param transport - The shared HTTP transport created by `createTransport`.
|
|
838
|
+
* @param options - Optional overrides (e.g. a custom base path).
|
|
839
|
+
*/
|
|
840
|
+
function createApiKeys(transport, options) {
|
|
841
|
+
const apiKeysPath = options?.apiKeysPath || "/admin/api-keys";
|
|
842
|
+
/** List all API keys (masked). */
|
|
843
|
+
async function listKeys() {
|
|
844
|
+
return transport.request(apiKeysPath, { method: "GET" });
|
|
845
|
+
}
|
|
846
|
+
/** Get a single API key by ID (masked). */
|
|
847
|
+
async function getKey(id) {
|
|
848
|
+
return transport.request(apiKeysPath + "/" + encodeURIComponent(id), { method: "GET" });
|
|
849
|
+
}
|
|
850
|
+
/** Create a new API key. The full secret is included in the response. */
|
|
851
|
+
async function createKey(data) {
|
|
852
|
+
return transport.request(apiKeysPath, {
|
|
853
|
+
method: "POST",
|
|
854
|
+
body: JSON.stringify(data)
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
/** Update an existing API key. */
|
|
858
|
+
async function updateKey(id, data) {
|
|
859
|
+
return transport.request(apiKeysPath + "/" + encodeURIComponent(id), {
|
|
860
|
+
method: "PUT",
|
|
861
|
+
body: JSON.stringify(data)
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
/** Revoke (soft-delete) an API key. */
|
|
865
|
+
async function revokeKey(id) {
|
|
866
|
+
return transport.request(apiKeysPath + "/" + encodeURIComponent(id), { method: "DELETE" });
|
|
867
|
+
}
|
|
868
|
+
return {
|
|
869
|
+
listKeys,
|
|
870
|
+
getKey,
|
|
871
|
+
createKey,
|
|
872
|
+
updateKey,
|
|
873
|
+
revokeKey
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
//#endregion
|
|
795
877
|
//#region src/collection.ts
|
|
796
878
|
function parseWhereFilter(where) {
|
|
797
879
|
if (!where) return void 0;
|
|
@@ -2043,6 +2125,7 @@
|
|
|
2043
2125
|
const auth = createAuth(transport, options.auth);
|
|
2044
2126
|
const admin = createAdmin(transport, options.admin);
|
|
2045
2127
|
const cron = createCron(transport, options.cron);
|
|
2128
|
+
const apiKeys = createApiKeys(transport, options.apiKeys);
|
|
2046
2129
|
const storage = createStorage(transport);
|
|
2047
2130
|
const functions = createFunctionsClient(transport);
|
|
2048
2131
|
const resolvedWsUrl = options.websocketUrl ?? deriveWebSocketUrl(options.baseUrl);
|
|
@@ -2096,6 +2179,7 @@
|
|
|
2096
2179
|
auth,
|
|
2097
2180
|
admin,
|
|
2098
2181
|
cron,
|
|
2182
|
+
apiKeys,
|
|
2099
2183
|
functions,
|
|
2100
2184
|
storage,
|
|
2101
2185
|
ws,
|
|
@@ -2141,6 +2225,7 @@
|
|
|
2141
2225
|
}
|
|
2142
2226
|
});
|
|
2143
2227
|
exports.createAdmin = createAdmin;
|
|
2228
|
+
exports.createApiKeys = createApiKeys;
|
|
2144
2229
|
exports.createAuth = createAuth;
|
|
2145
2230
|
exports.createCollectionClient = createCollectionClient;
|
|
2146
2231
|
exports.createCookieStorage = createCookieStorage;
|