@drmhse/sso-sdk 0.3.14 → 0.5.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 +71 -3
- package/dist/index.d.mts +487 -66
- package/dist/index.d.ts +487 -66
- package/dist/index.js +268 -25
- package/dist/index.mjs +268 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -44,23 +44,38 @@ var AuthErrorCodes = /* @__PURE__ */ ((AuthErrorCodes2) => {
|
|
|
44
44
|
AuthErrorCodes2["MFA_REQUIRED"] = "MFA_REQUIRED";
|
|
45
45
|
AuthErrorCodes2["ORG_REQUIRED"] = "ORG_REQUIRED";
|
|
46
46
|
AuthErrorCodes2["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
|
|
47
|
-
AuthErrorCodes2["TOKEN_EXPIRED"] = "TOKEN_EXPIRED";
|
|
48
47
|
AuthErrorCodes2["REFRESH_TOKEN_INVALID"] = "REFRESH_TOKEN_INVALID";
|
|
48
|
+
AuthErrorCodes2["NOT_FOUND"] = "NOT_FOUND";
|
|
49
49
|
AuthErrorCodes2["UNAUTHORIZED"] = "UNAUTHORIZED";
|
|
50
50
|
AuthErrorCodes2["FORBIDDEN"] = "FORBIDDEN";
|
|
51
|
-
AuthErrorCodes2["
|
|
51
|
+
AuthErrorCodes2["TOKEN_EXPIRED"] = "TOKEN_EXPIRED";
|
|
52
52
|
AuthErrorCodes2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
53
53
|
AuthErrorCodes2["EMAIL_ALREADY_EXISTS"] = "EMAIL_ALREADY_EXISTS";
|
|
54
54
|
AuthErrorCodes2["EMAIL_NOT_VERIFIED"] = "EMAIL_NOT_VERIFIED";
|
|
55
55
|
AuthErrorCodes2["ACCOUNT_SUSPENDED"] = "ACCOUNT_SUSPENDED";
|
|
56
56
|
AuthErrorCodes2["ORG_SUSPENDED"] = "ORG_SUSPENDED";
|
|
57
|
-
AuthErrorCodes2["
|
|
58
|
-
AuthErrorCodes2["
|
|
59
|
-
AuthErrorCodes2["
|
|
57
|
+
AuthErrorCodes2["BAD_REQUEST"] = "BAD_REQUEST";
|
|
58
|
+
AuthErrorCodes2["DUPLICATE_CONSTRAINT"] = "DUPLICATE_CONSTRAINT";
|
|
59
|
+
AuthErrorCodes2["ORGANIZATION_NOT_ACTIVE"] = "ORGANIZATION_NOT_ACTIVE";
|
|
60
|
+
AuthErrorCodes2["SERVICE_LIMIT_EXCEEDED"] = "SERVICE_LIMIT_EXCEEDED";
|
|
61
|
+
AuthErrorCodes2["TEAM_LIMIT_EXCEEDED"] = "TEAM_LIMIT_EXCEEDED";
|
|
62
|
+
AuthErrorCodes2["INVITATION_EXPIRED"] = "INVITATION_EXPIRED";
|
|
60
63
|
AuthErrorCodes2["LINK_EXPIRED"] = "LINK_EXPIRED";
|
|
61
64
|
AuthErrorCodes2["DEVICE_CODE_EXPIRED"] = "DEVICE_CODE_EXPIRED";
|
|
62
65
|
AuthErrorCodes2["AUTHORIZATION_PENDING"] = "AUTHORIZATION_PENDING";
|
|
66
|
+
AuthErrorCodes2["DEVICE_CODE_PENDING"] = "DEVICE_CODE_PENDING";
|
|
67
|
+
AuthErrorCodes2["FEATURE_NOT_AVAILABLE_IN_TIER"] = "FEATURE_NOT_AVAILABLE_IN_TIER";
|
|
68
|
+
AuthErrorCodes2["RATE_LIMITED"] = "RATE_LIMITED";
|
|
69
|
+
AuthErrorCodes2["TOO_MANY_REQUESTS"] = "TOO_MANY_REQUESTS";
|
|
70
|
+
AuthErrorCodes2["WEAK_PASSWORD"] = "WEAK_PASSWORD";
|
|
71
|
+
AuthErrorCodes2["INVALID_MFA_CODE"] = "INVALID_MFA_CODE";
|
|
72
|
+
AuthErrorCodes2["JWT_ERROR"] = "JWT_ERROR";
|
|
73
|
+
AuthErrorCodes2["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
|
|
74
|
+
AuthErrorCodes2["OAUTH_ERROR"] = "OAUTH_ERROR";
|
|
63
75
|
AuthErrorCodes2["PASSKEY_ERROR"] = "PASSKEY_ERROR";
|
|
76
|
+
AuthErrorCodes2["STRIPE_ERROR"] = "STRIPE_ERROR";
|
|
77
|
+
AuthErrorCodes2["DATABASE_ERROR"] = "DATABASE_ERROR";
|
|
78
|
+
AuthErrorCodes2["GENERIC_ERROR"] = "GENERIC_ERROR";
|
|
64
79
|
return AuthErrorCodes2;
|
|
65
80
|
})(AuthErrorCodes || {});
|
|
66
81
|
var SsoApiError = class _SsoApiError extends Error {
|
|
@@ -270,10 +285,13 @@ var HttpClient = class {
|
|
|
270
285
|
/**
|
|
271
286
|
* DELETE request
|
|
272
287
|
*/
|
|
273
|
-
async delete(path, config) {
|
|
288
|
+
async delete(path, data, config) {
|
|
289
|
+
const requestConfig = data && typeof data === "object" && "headers" in data && !config ? data : config;
|
|
290
|
+
const body = requestConfig === data ? void 0 : data;
|
|
274
291
|
return this.request(path, {
|
|
275
292
|
method: "DELETE",
|
|
276
|
-
|
|
293
|
+
body,
|
|
294
|
+
headers: requestConfig?.headers
|
|
277
295
|
});
|
|
278
296
|
}
|
|
279
297
|
};
|
|
@@ -856,7 +874,7 @@ var AuthModule = class {
|
|
|
856
874
|
}
|
|
857
875
|
/**
|
|
858
876
|
* Login with email and password.
|
|
859
|
-
* Automatically persists the session
|
|
877
|
+
* Automatically persists the session once authentication is complete.
|
|
860
878
|
*
|
|
861
879
|
* @param payload Login credentials (email and password)
|
|
862
880
|
* @returns Access token, refresh token, and expiration info
|
|
@@ -867,15 +885,17 @@ var AuthModule = class {
|
|
|
867
885
|
* email: 'user@example.com',
|
|
868
886
|
* password: 'SecurePassword123!'
|
|
869
887
|
* });
|
|
870
|
-
* // Session is automatically saved
|
|
888
|
+
* // Session is automatically saved unless MFA is required
|
|
871
889
|
* ```
|
|
872
890
|
*/
|
|
873
891
|
async login(payload) {
|
|
874
892
|
const response = await this.http.post("/api/auth/login", payload);
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
893
|
+
if (response.data.refresh_token) {
|
|
894
|
+
await this.session.setSession({
|
|
895
|
+
access_token: response.data.access_token,
|
|
896
|
+
refresh_token: response.data.refresh_token
|
|
897
|
+
});
|
|
898
|
+
}
|
|
879
899
|
return response.data;
|
|
880
900
|
}
|
|
881
901
|
/**
|
|
@@ -1004,6 +1024,20 @@ var AuthModule = class {
|
|
|
1004
1024
|
});
|
|
1005
1025
|
return response.data;
|
|
1006
1026
|
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Fetch public hosted-auth context for an organization/service login.
|
|
1029
|
+
*/
|
|
1030
|
+
async getContext(params = {}) {
|
|
1031
|
+
const searchParams = new URLSearchParams();
|
|
1032
|
+
if (params.org) searchParams.append("org", params.org);
|
|
1033
|
+
if (params.service) searchParams.append("service", params.service);
|
|
1034
|
+
if (params.redirect_uri) searchParams.append("redirect_uri", params.redirect_uri);
|
|
1035
|
+
const query = searchParams.toString();
|
|
1036
|
+
const response = await this.http.get(
|
|
1037
|
+
`/api/auth/context${query ? `?${query}` : ""}`
|
|
1038
|
+
);
|
|
1039
|
+
return response.data;
|
|
1040
|
+
}
|
|
1007
1041
|
};
|
|
1008
1042
|
|
|
1009
1043
|
// src/modules/user.ts
|
|
@@ -1058,6 +1092,41 @@ var IdentitiesModule = class {
|
|
|
1058
1092
|
await this.http.delete(`/api/user/identities/${provider}`);
|
|
1059
1093
|
}
|
|
1060
1094
|
};
|
|
1095
|
+
var LinkedAccountsModule = class {
|
|
1096
|
+
constructor(http) {
|
|
1097
|
+
this.http = http;
|
|
1098
|
+
}
|
|
1099
|
+
async list() {
|
|
1100
|
+
const response = await this.http.get("/api/user/linked-accounts");
|
|
1101
|
+
return response.data;
|
|
1102
|
+
}
|
|
1103
|
+
async startLink(provider) {
|
|
1104
|
+
const response = await this.http.post(`/api/user/linked-accounts/${provider}/link`, {});
|
|
1105
|
+
return response.data;
|
|
1106
|
+
}
|
|
1107
|
+
async grant(accountId, payload) {
|
|
1108
|
+
const response = await this.http.post(`/api/user/linked-accounts/${accountId}/grants`, payload);
|
|
1109
|
+
return response.data;
|
|
1110
|
+
}
|
|
1111
|
+
async revokeGrant(accountId, serviceId) {
|
|
1112
|
+
await this.http.delete(`/api/user/linked-accounts/${accountId}/grants/${serviceId}`);
|
|
1113
|
+
}
|
|
1114
|
+
async unlink(accountId) {
|
|
1115
|
+
await this.http.delete(`/api/user/linked-accounts/${accountId}`);
|
|
1116
|
+
}
|
|
1117
|
+
async getProviderTokenRequest(state) {
|
|
1118
|
+
const response = await this.http.get(`/api/user/provider-token-requests/${state}`);
|
|
1119
|
+
return response.data;
|
|
1120
|
+
}
|
|
1121
|
+
async completeProviderTokenRequest(state, payload = {}) {
|
|
1122
|
+
const response = await this.http.post(`/api/user/provider-token-requests/${state}/complete`, payload);
|
|
1123
|
+
return response.data;
|
|
1124
|
+
}
|
|
1125
|
+
async startProviderTokenRequestLink(state) {
|
|
1126
|
+
const response = await this.http.post(`/api/user/provider-token-requests/${state}/link`, {});
|
|
1127
|
+
return response.data;
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1061
1130
|
var MfaModule = class {
|
|
1062
1131
|
constructor(http) {
|
|
1063
1132
|
this.http = http;
|
|
@@ -1259,6 +1328,7 @@ var UserModule = class {
|
|
|
1259
1328
|
constructor(http) {
|
|
1260
1329
|
this.http = http;
|
|
1261
1330
|
this.identities = new IdentitiesModule(http);
|
|
1331
|
+
this.linkedAccounts = new LinkedAccountsModule(http);
|
|
1262
1332
|
this.mfa = new MfaModule(http);
|
|
1263
1333
|
this.devices = new DevicesModule(http);
|
|
1264
1334
|
}
|
|
@@ -1629,6 +1699,76 @@ var WebhooksModule = class {
|
|
|
1629
1699
|
}
|
|
1630
1700
|
};
|
|
1631
1701
|
|
|
1702
|
+
// src/modules/organizations/upstream-providers.ts
|
|
1703
|
+
var UpstreamProvidersModule = class {
|
|
1704
|
+
constructor(http) {
|
|
1705
|
+
this.http = http;
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* List all upstream providers for an organization.
|
|
1709
|
+
*
|
|
1710
|
+
* @param orgSlug Organization slug
|
|
1711
|
+
* @returns Array of upstream providers
|
|
1712
|
+
*/
|
|
1713
|
+
async list(orgSlug) {
|
|
1714
|
+
const response = await this.http.get(
|
|
1715
|
+
`/api/organizations/${orgSlug}/upstream-providers`
|
|
1716
|
+
);
|
|
1717
|
+
return response.data;
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Get a specific upstream provider.
|
|
1721
|
+
*
|
|
1722
|
+
* @param orgSlug Organization slug
|
|
1723
|
+
* @param providerId Provider ID or connection_id
|
|
1724
|
+
* @returns Upstream provider details
|
|
1725
|
+
*/
|
|
1726
|
+
async get(orgSlug, providerId) {
|
|
1727
|
+
const response = await this.http.get(
|
|
1728
|
+
`/api/organizations/${orgSlug}/upstream-providers/${providerId}`
|
|
1729
|
+
);
|
|
1730
|
+
return response.data;
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Create a new upstream provider.
|
|
1734
|
+
*
|
|
1735
|
+
* @param orgSlug Organization slug
|
|
1736
|
+
* @param payload Provider configuration
|
|
1737
|
+
* @returns Created upstream provider
|
|
1738
|
+
*/
|
|
1739
|
+
async create(orgSlug, payload) {
|
|
1740
|
+
const response = await this.http.post(
|
|
1741
|
+
`/api/organizations/${orgSlug}/upstream-providers`,
|
|
1742
|
+
payload
|
|
1743
|
+
);
|
|
1744
|
+
return response.data;
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* Update an existing upstream provider.
|
|
1748
|
+
*
|
|
1749
|
+
* @param orgSlug Organization slug
|
|
1750
|
+
* @param providerId Provider ID or connection_id
|
|
1751
|
+
* @param payload Update payload
|
|
1752
|
+
* @returns Updated upstream provider
|
|
1753
|
+
*/
|
|
1754
|
+
async update(orgSlug, providerId, payload) {
|
|
1755
|
+
const response = await this.http.patch(
|
|
1756
|
+
`/api/organizations/${orgSlug}/upstream-providers/${providerId}`,
|
|
1757
|
+
payload
|
|
1758
|
+
);
|
|
1759
|
+
return response.data;
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Delete an upstream provider.
|
|
1763
|
+
*
|
|
1764
|
+
* @param orgSlug Organization slug
|
|
1765
|
+
* @param providerId Provider ID or connection_id
|
|
1766
|
+
*/
|
|
1767
|
+
async delete(orgSlug, providerId) {
|
|
1768
|
+
await this.http.delete(`/api/organizations/${orgSlug}/upstream-providers/${providerId}`);
|
|
1769
|
+
}
|
|
1770
|
+
};
|
|
1771
|
+
|
|
1632
1772
|
// src/modules/organizations.ts
|
|
1633
1773
|
var OrganizationsModule = class {
|
|
1634
1774
|
constructor(http) {
|
|
@@ -1708,7 +1848,9 @@ var OrganizationsModule = class {
|
|
|
1708
1848
|
payload
|
|
1709
1849
|
);
|
|
1710
1850
|
const invitation = response.data;
|
|
1711
|
-
await this.http.post(
|
|
1851
|
+
await this.http.post(
|
|
1852
|
+
`/api/organizations/${orgSlug}/invitations/${invitation.id}/accept`
|
|
1853
|
+
);
|
|
1712
1854
|
return invitation;
|
|
1713
1855
|
},
|
|
1714
1856
|
/**
|
|
@@ -1749,6 +1891,25 @@ var OrganizationsModule = class {
|
|
|
1749
1891
|
remove: async (orgSlug, userId) => {
|
|
1750
1892
|
await this.http.post(`/api/organizations/${orgSlug}/members/${userId}`);
|
|
1751
1893
|
},
|
|
1894
|
+
/**
|
|
1895
|
+
* List a member's direct per-service access grants.
|
|
1896
|
+
*/
|
|
1897
|
+
listServiceAccess: async (orgSlug, userId) => {
|
|
1898
|
+
const response = await this.http.get(
|
|
1899
|
+
`/api/organizations/${orgSlug}/members/${userId}/service-access`
|
|
1900
|
+
);
|
|
1901
|
+
return response.data;
|
|
1902
|
+
},
|
|
1903
|
+
/**
|
|
1904
|
+
* Replace a member's direct per-service access grants.
|
|
1905
|
+
*/
|
|
1906
|
+
updateServiceAccess: async (orgSlug, userId, payload) => {
|
|
1907
|
+
const response = await this.http.put(
|
|
1908
|
+
`/api/organizations/${orgSlug}/members/${userId}/service-access`,
|
|
1909
|
+
payload
|
|
1910
|
+
);
|
|
1911
|
+
return response.data;
|
|
1912
|
+
},
|
|
1752
1913
|
/**
|
|
1753
1914
|
* Transfer organization ownership to another member.
|
|
1754
1915
|
* Requires 'owner' role.
|
|
@@ -2313,6 +2474,7 @@ var OrganizationsModule = class {
|
|
|
2313
2474
|
};
|
|
2314
2475
|
this.auditLogs = new AuditLogsModule(http);
|
|
2315
2476
|
this.webhooks = new WebhooksModule(http);
|
|
2477
|
+
this.upstreamProviders = new UpstreamProvidersModule(http);
|
|
2316
2478
|
}
|
|
2317
2479
|
/**
|
|
2318
2480
|
* Create a new organization (requires authentication).
|
|
@@ -3177,13 +3339,12 @@ var ServicesModule = class {
|
|
|
3177
3339
|
*
|
|
3178
3340
|
* @param orgSlug Organization slug
|
|
3179
3341
|
* @param serviceSlug Service slug
|
|
3180
|
-
* @returns Service
|
|
3342
|
+
* @returns Service details
|
|
3181
3343
|
*
|
|
3182
3344
|
* @example
|
|
3183
3345
|
* ```typescript
|
|
3184
3346
|
* const service = await sso.services.get('acme-corp', 'main-app');
|
|
3185
|
-
* console.log(service.service.
|
|
3186
|
-
* console.log(service.plans);
|
|
3347
|
+
* console.log(service.name, service.client_id);
|
|
3187
3348
|
* ```
|
|
3188
3349
|
*/
|
|
3189
3350
|
async get(orgSlug, serviceSlug) {
|
|
@@ -3231,6 +3392,17 @@ var ServicesModule = class {
|
|
|
3231
3392
|
async delete(orgSlug, serviceSlug) {
|
|
3232
3393
|
await this.http.delete(`/api/organizations/${orgSlug}/services/${serviceSlug}`);
|
|
3233
3394
|
}
|
|
3395
|
+
/**
|
|
3396
|
+
* Rotate a service client secret.
|
|
3397
|
+
* The new secret is returned once and cannot be retrieved later.
|
|
3398
|
+
*/
|
|
3399
|
+
async rotateSecret(orgSlug, serviceSlug) {
|
|
3400
|
+
const response = await this.http.post(
|
|
3401
|
+
`/api/organizations/${orgSlug}/services/${serviceSlug}/secret/rotate`,
|
|
3402
|
+
{}
|
|
3403
|
+
);
|
|
3404
|
+
return response.data;
|
|
3405
|
+
}
|
|
3234
3406
|
};
|
|
3235
3407
|
|
|
3236
3408
|
// src/modules/invitations.ts
|
|
@@ -3326,6 +3498,14 @@ var InvitationsModule = class {
|
|
|
3326
3498
|
const payload = { token };
|
|
3327
3499
|
await this.http.post("/api/invitations/accept", payload);
|
|
3328
3500
|
}
|
|
3501
|
+
/**
|
|
3502
|
+
* Accept one of the current user's invitations by invitation ID.
|
|
3503
|
+
*
|
|
3504
|
+
* @param invitationId Invitation ID
|
|
3505
|
+
*/
|
|
3506
|
+
async acceptById(invitationId) {
|
|
3507
|
+
await this.http.post(`/api/invitations/${invitationId}/accept`);
|
|
3508
|
+
}
|
|
3329
3509
|
/**
|
|
3330
3510
|
* Decline an invitation using its token.
|
|
3331
3511
|
*
|
|
@@ -3340,6 +3520,14 @@ var InvitationsModule = class {
|
|
|
3340
3520
|
const payload = { token };
|
|
3341
3521
|
await this.http.post("/api/invitations/decline", payload);
|
|
3342
3522
|
}
|
|
3523
|
+
/**
|
|
3524
|
+
* Decline one of the current user's invitations by invitation ID.
|
|
3525
|
+
*
|
|
3526
|
+
* @param invitationId Invitation ID
|
|
3527
|
+
*/
|
|
3528
|
+
async declineById(invitationId) {
|
|
3529
|
+
await this.http.post(`/api/invitations/${invitationId}/decline`);
|
|
3530
|
+
}
|
|
3343
3531
|
};
|
|
3344
3532
|
|
|
3345
3533
|
// src/modules/platform.ts
|
|
@@ -3560,6 +3748,13 @@ var PlatformModule = class {
|
|
|
3560
3748
|
const response = await this.http.get("/api/platform/users", { params: options });
|
|
3561
3749
|
return response.data;
|
|
3562
3750
|
},
|
|
3751
|
+
/**
|
|
3752
|
+
* Get a single platform user by ID.
|
|
3753
|
+
*/
|
|
3754
|
+
get: async (userId) => {
|
|
3755
|
+
const response = await this.http.get(`/api/platform/users/${userId}`);
|
|
3756
|
+
return response.data;
|
|
3757
|
+
},
|
|
3563
3758
|
/**
|
|
3564
3759
|
* Search users by email address or user ID.
|
|
3565
3760
|
*
|
|
@@ -3818,6 +4013,13 @@ var PlatformModule = class {
|
|
|
3818
4013
|
const response = await this.http.post("/api/platform/impersonate", payload);
|
|
3819
4014
|
return response.data;
|
|
3820
4015
|
}
|
|
4016
|
+
/**
|
|
4017
|
+
* Get platform operational counters for jobs, webhooks, and SIEM delivery.
|
|
4018
|
+
*/
|
|
4019
|
+
async getOperationsStatus() {
|
|
4020
|
+
const response = await this.http.get("/api/platform/operations/status");
|
|
4021
|
+
return response.data;
|
|
4022
|
+
}
|
|
3821
4023
|
};
|
|
3822
4024
|
|
|
3823
4025
|
// src/modules/serviceApi.ts
|
|
@@ -3897,6 +4099,17 @@ var ServiceApiModule = class {
|
|
|
3897
4099
|
const response = await this.http.get("/api/service/info");
|
|
3898
4100
|
return response.data;
|
|
3899
4101
|
}
|
|
4102
|
+
/**
|
|
4103
|
+
* Request a backend-only third-party provider access token for an AuthOS user.
|
|
4104
|
+
* Requires `read:provider_tokens` or `read:provider_tokens:{provider}` on the API key.
|
|
4105
|
+
*/
|
|
4106
|
+
async requestProviderToken(request) {
|
|
4107
|
+
const response = await this.http.post("/api/service/provider-tokens", {
|
|
4108
|
+
...request,
|
|
4109
|
+
scopes: request.scopes ?? []
|
|
4110
|
+
});
|
|
4111
|
+
return response.data;
|
|
4112
|
+
}
|
|
3900
4113
|
/**
|
|
3901
4114
|
* Create a new user
|
|
3902
4115
|
* Requires 'write:users' permission on the API key
|
|
@@ -4331,6 +4544,29 @@ var PasskeysModule = class {
|
|
|
4331
4544
|
);
|
|
4332
4545
|
return response.data;
|
|
4333
4546
|
}
|
|
4547
|
+
/**
|
|
4548
|
+
* List registered passkeys for the authenticated user.
|
|
4549
|
+
*/
|
|
4550
|
+
async list() {
|
|
4551
|
+
const response = await this.http.get("/api/auth/passkeys");
|
|
4552
|
+
return response.data;
|
|
4553
|
+
}
|
|
4554
|
+
/**
|
|
4555
|
+
* Rename a passkey for the authenticated user.
|
|
4556
|
+
*/
|
|
4557
|
+
async updateName(passkeyId, name) {
|
|
4558
|
+
const response = await this.http.patch(`/api/auth/passkeys/${passkeyId}`, {
|
|
4559
|
+
name
|
|
4560
|
+
});
|
|
4561
|
+
return response.data;
|
|
4562
|
+
}
|
|
4563
|
+
/**
|
|
4564
|
+
* Delete a passkey for the authenticated user.
|
|
4565
|
+
*/
|
|
4566
|
+
async delete(passkeyId) {
|
|
4567
|
+
const response = await this.http.delete(`/api/auth/passkeys/${passkeyId}`);
|
|
4568
|
+
return response.data;
|
|
4569
|
+
}
|
|
4334
4570
|
/**
|
|
4335
4571
|
* Finish the passkey registration ceremony.
|
|
4336
4572
|
* Verifies the credential created by the browser.
|
|
@@ -4416,10 +4652,10 @@ var PasskeysModule = class {
|
|
|
4416
4652
|
* Start the passkey authentication ceremony.
|
|
4417
4653
|
* Returns the options required to get credentials from the browser.
|
|
4418
4654
|
*/
|
|
4419
|
-
async authenticateStart(email) {
|
|
4655
|
+
async authenticateStart(email, context) {
|
|
4420
4656
|
const response = await this.http.post(
|
|
4421
4657
|
"/api/auth/passkeys/authenticate/start",
|
|
4422
|
-
{ email }
|
|
4658
|
+
{ email, ...context }
|
|
4423
4659
|
);
|
|
4424
4660
|
return response.data;
|
|
4425
4661
|
}
|
|
@@ -4441,11 +4677,11 @@ var PasskeysModule = class {
|
|
|
4441
4677
|
* Authenticate with a passkey and obtain a JWT token
|
|
4442
4678
|
* ...
|
|
4443
4679
|
*/
|
|
4444
|
-
async login(email) {
|
|
4680
|
+
async login(email, context) {
|
|
4445
4681
|
if (!this.isSupported()) {
|
|
4446
4682
|
throw new Error("WebAuthn is not supported in this browser");
|
|
4447
4683
|
}
|
|
4448
|
-
const startData = await this.authenticateStart(email);
|
|
4684
|
+
const startData = await this.authenticateStart(email, context);
|
|
4449
4685
|
const getOptions = {
|
|
4450
4686
|
publicKey: {
|
|
4451
4687
|
...startData.options,
|
|
@@ -4516,7 +4752,10 @@ var MagicLinks = class {
|
|
|
4516
4752
|
* @returns Promise resolving to magic link response
|
|
4517
4753
|
*/
|
|
4518
4754
|
async request(data) {
|
|
4519
|
-
const response = await this.http.post("/api/auth/magic-link/request",
|
|
4755
|
+
const response = await this.http.post("/api/auth/magic-link/request", {
|
|
4756
|
+
...data,
|
|
4757
|
+
org_slug: data.org_slug || data.orgSlug
|
|
4758
|
+
});
|
|
4520
4759
|
return response.data;
|
|
4521
4760
|
}
|
|
4522
4761
|
/**
|
|
@@ -4548,7 +4787,8 @@ var MagicLinks = class {
|
|
|
4548
4787
|
if (redirectUri) {
|
|
4549
4788
|
params.append("redirect_uri", redirectUri);
|
|
4550
4789
|
}
|
|
4551
|
-
|
|
4790
|
+
const response = await this.http.get(`/api/auth/magic-link/verify?${params.toString()}`);
|
|
4791
|
+
return response.data;
|
|
4552
4792
|
}
|
|
4553
4793
|
/**
|
|
4554
4794
|
* Construct the complete magic link URL that would be sent via email
|
|
@@ -4605,8 +4845,11 @@ var PrivacyModule = class {
|
|
|
4605
4845
|
* // "User data has been anonymized. PII has been removed while preserving audit logs."
|
|
4606
4846
|
* ```
|
|
4607
4847
|
*/
|
|
4608
|
-
async forgetUser(userId) {
|
|
4609
|
-
const response = await this.http.delete(
|
|
4848
|
+
async forgetUser(userId, payload = {}) {
|
|
4849
|
+
const response = await this.http.delete(
|
|
4850
|
+
`/api/privacy/forget/${userId}`,
|
|
4851
|
+
payload
|
|
4852
|
+
);
|
|
4610
4853
|
return response.data;
|
|
4611
4854
|
}
|
|
4612
4855
|
};
|