@settlemint/dalp-sdk 3.1.19-main.36415955113 → 3.1.19-main.36423867720
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/auth/invite-step-up.d.ts +2 -0
- package/dist/auth.js +53 -5
- package/dist/chunk-4pmxj750.js +5 -0
- package/dist/{chunk-kj20benv.js → chunk-84vvr8vq.js} +2 -1
- package/dist/{chunk-d4amjr6g.js → chunk-cnmk4f9m.js} +1 -1
- package/dist/{chunk-h63an3a6.js → chunk-df68d26h.js} +52 -9
- package/dist/chunk-tjvz2fz6.js +5 -0
- package/dist/chunk-wp4269cm.js +121 -0
- package/dist/client/step-up-challenge.d.ts +10 -0
- package/dist/effect.js +2 -2
- package/dist/generated/api-types.d.ts +65 -64
- package/dist/index.js +4 -4
- package/dist/proxy/flat-args.d.ts +1 -0
- package/dist/proxy/step-up-challenge.d.ts +4 -0
- package/dist/proxy/transport.d.ts +10 -1
- package/dist/react-query.js +2 -2
- package/dist/routes/console.js +3 -3
- package/package.json +2 -1
- package/dist/chunk-cr1tms72.js +0 -66
- package/dist/chunk-jryqac1s.js +0 -5
- package/dist/chunk-ndcne1sq.js +0 -5
package/dist/auth.js
CHANGED
|
@@ -5,13 +5,17 @@ import {
|
|
|
5
5
|
DALP_AUTH_SURFACE_HEADER2,
|
|
6
6
|
secret2,
|
|
7
7
|
unwrapSecret,
|
|
8
|
-
normalizeDalpBaseUrl
|
|
9
|
-
|
|
8
|
+
normalizeDalpBaseUrl,
|
|
9
|
+
STEP_UP_CHALLENGE_HEADER,
|
|
10
|
+
STEP_UP_CHALLENGE_PATH,
|
|
11
|
+
carriesWalletProof,
|
|
12
|
+
stepUpChallengeRequest
|
|
13
|
+
} from "./chunk-wp4269cm.js";
|
|
10
14
|
import {
|
|
11
15
|
makeCookieStore2,
|
|
12
16
|
createCookieStoreFetch2,
|
|
13
17
|
SDK_USER_AGENT2
|
|
14
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-84vvr8vq.js";
|
|
15
19
|
|
|
16
20
|
// src/auth/live.ts
|
|
17
21
|
import { apiKeyClient } from "@better-auth/api-key/client";
|
|
@@ -144,6 +148,49 @@ async function decodeDalpAuthClientConfig(input) {
|
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
|
|
151
|
+
// src/auth/invite-step-up.ts
|
|
152
|
+
var INVITE_MEMBER_PATH = "/api/auth/organization/invite-member";
|
|
153
|
+
var INVITE_MEMBER_OPERATION = `POST ${INVITE_MEMBER_PATH}`;
|
|
154
|
+
function readChallengeId(payload) {
|
|
155
|
+
const data = payload !== null && typeof payload === "object" ? Reflect.get(payload, "data") : undefined;
|
|
156
|
+
const challengeId = data !== null && typeof data === "object" ? Reflect.get(data, "challengeId") : undefined;
|
|
157
|
+
return typeof challengeId === "string" ? challengeId : undefined;
|
|
158
|
+
}
|
|
159
|
+
function invitesWithWalletProof(input, init, baseUrl) {
|
|
160
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
161
|
+
if ((init?.method ?? "GET").toUpperCase() !== "POST" || typeof init?.body !== "string" || new URL(url).pathname !== new URL(`${baseUrl}${INVITE_MEMBER_PATH}`).pathname) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const body = JSON.parse(init.body);
|
|
165
|
+
return carriesWalletProof(body) ? body : undefined;
|
|
166
|
+
}
|
|
167
|
+
function withInviteStepUp(fetchImpl, baseUrl) {
|
|
168
|
+
return async (input, init) => {
|
|
169
|
+
const headers = new Headers(init?.headers);
|
|
170
|
+
const body = invitesWithWalletProof(input, init, baseUrl);
|
|
171
|
+
if (body === undefined || headers.has("x-api-key") || headers.has(STEP_UP_CHALLENGE_HEADER)) {
|
|
172
|
+
return fetchImpl(input, init);
|
|
173
|
+
}
|
|
174
|
+
const challengeHeaders = new Headers(headers);
|
|
175
|
+
challengeHeaders.set("Content-Type", "application/json");
|
|
176
|
+
const issued = await fetchImpl(`${baseUrl}${STEP_UP_CHALLENGE_PATH}`, {
|
|
177
|
+
method: "POST",
|
|
178
|
+
headers: challengeHeaders,
|
|
179
|
+
body: JSON.stringify(await stepUpChallengeRequest(INVITE_MEMBER_OPERATION, null, body)),
|
|
180
|
+
signal: init?.signal ?? null,
|
|
181
|
+
...init?.credentials === undefined ? {} : { credentials: init.credentials }
|
|
182
|
+
});
|
|
183
|
+
if (!issued.ok) {
|
|
184
|
+
return issued;
|
|
185
|
+
}
|
|
186
|
+
const challengeId = readChallengeId(await issued.json());
|
|
187
|
+
if (challengeId !== undefined) {
|
|
188
|
+
headers.set(STEP_UP_CHALLENGE_HEADER, challengeId);
|
|
189
|
+
}
|
|
190
|
+
return fetchImpl(input, { ...init, headers });
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
147
194
|
// src/auth/permissions.ts
|
|
148
195
|
import { createAccessControl } from "better-auth/plugins/access";
|
|
149
196
|
import { adminAc, defaultStatements as adminDefaultStatements } from "better-auth/plugins/admin/access";
|
|
@@ -315,11 +362,12 @@ function createConfiguredBetterAuthClient(config, cookieStore) {
|
|
|
315
362
|
deviceAuthorizationClient(),
|
|
316
363
|
organizationClient(organizationPluginOptions)
|
|
317
364
|
];
|
|
365
|
+
const baseUrl = normalizeDalpBaseUrl(config.url);
|
|
318
366
|
return createBetterAuthClient({
|
|
319
|
-
baseURL: `${
|
|
367
|
+
baseURL: `${baseUrl}/api/auth`,
|
|
320
368
|
fetchOptions: {
|
|
321
369
|
headers: authHeaders(config),
|
|
322
|
-
customFetchImpl: createCookieStoreFetch2(cookieStore, config.fetch),
|
|
370
|
+
customFetchImpl: withInviteStepUp(createCookieStoreFetch2(cookieStore, config.fetch), baseUrl),
|
|
323
371
|
credentials: "include"
|
|
324
372
|
},
|
|
325
373
|
plugins
|