@arbidocs/sdk 0.4.71 → 0.4.72
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/{browser-Bf2QdtQY.d.cts → browser-BWUCi_v2.d.cts} +676 -10
- package/dist/{browser-Bf2QdtQY.d.ts → browser-BWUCi_v2.d.ts} +676 -10
- package/dist/browser.cjs +119 -3
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +118 -4
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +119 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +118 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -6479,6 +6479,76 @@ async function requestDeletion(arbi) {
|
|
|
6479
6479
|
return requireData(await arbi.fetch.POST("/v1/user/request-deletion"), "Failed to delete account");
|
|
6480
6480
|
}
|
|
6481
6481
|
|
|
6482
|
+
// src/operations/identity.ts
|
|
6483
|
+
var identity_exports = {};
|
|
6484
|
+
__export(identity_exports, {
|
|
6485
|
+
acceptName: () => acceptName,
|
|
6486
|
+
getStatus: () => getStatus,
|
|
6487
|
+
identityErrorCode: () => identityErrorCode,
|
|
6488
|
+
purchase: () => purchase,
|
|
6489
|
+
refresh: () => refresh,
|
|
6490
|
+
remove: () => remove,
|
|
6491
|
+
startSession: () => startSession
|
|
6492
|
+
});
|
|
6493
|
+
function refusal(apiError) {
|
|
6494
|
+
const detail = apiError?.detail;
|
|
6495
|
+
if (typeof detail === "string") return { message: detail };
|
|
6496
|
+
if (detail && typeof detail === "object" && !Array.isArray(detail)) {
|
|
6497
|
+
const { code, message } = detail;
|
|
6498
|
+
return {
|
|
6499
|
+
code: typeof code === "string" ? code : void 0,
|
|
6500
|
+
message: typeof message === "string" ? message : void 0
|
|
6501
|
+
};
|
|
6502
|
+
}
|
|
6503
|
+
return {};
|
|
6504
|
+
}
|
|
6505
|
+
function identityErrorCode(error) {
|
|
6506
|
+
return error instanceof ArbiApiError ? refusal(error.apiError).code : void 0;
|
|
6507
|
+
}
|
|
6508
|
+
function unwrap(result, fallback) {
|
|
6509
|
+
if (result.error || result.data === void 0) {
|
|
6510
|
+
throw new ArbiApiError(
|
|
6511
|
+
refusal(result.error).message ?? fallback,
|
|
6512
|
+
result.error,
|
|
6513
|
+
result.response?.status
|
|
6514
|
+
);
|
|
6515
|
+
}
|
|
6516
|
+
return result.data;
|
|
6517
|
+
}
|
|
6518
|
+
async function getStatus(arbi) {
|
|
6519
|
+
return unwrap(await arbi.fetch.GET("/v1/user/identity"), "Failed to load identity verification");
|
|
6520
|
+
}
|
|
6521
|
+
async function purchase(arbi, projectExtId) {
|
|
6522
|
+
return unwrap(
|
|
6523
|
+
await arbi.fetch.POST("/v1/user/identity/purchase", {
|
|
6524
|
+
body: projectExtId ? { project_ext_id: projectExtId } : {}
|
|
6525
|
+
}),
|
|
6526
|
+
"Payment could not be completed"
|
|
6527
|
+
);
|
|
6528
|
+
}
|
|
6529
|
+
async function startSession(arbi) {
|
|
6530
|
+
const data = unwrap(
|
|
6531
|
+
await arbi.fetch.POST("/v1/user/identity/session"),
|
|
6532
|
+
"Could not start identity verification"
|
|
6533
|
+
);
|
|
6534
|
+
return data.url;
|
|
6535
|
+
}
|
|
6536
|
+
async function refresh(arbi) {
|
|
6537
|
+
return unwrap(
|
|
6538
|
+
await arbi.fetch.POST("/v1/user/identity/refresh"),
|
|
6539
|
+
"Could not read the verification result"
|
|
6540
|
+
);
|
|
6541
|
+
}
|
|
6542
|
+
async function acceptName(arbi) {
|
|
6543
|
+
return unwrap(
|
|
6544
|
+
await arbi.fetch.POST("/v1/user/identity/accept-name"),
|
|
6545
|
+
"Could not change your name"
|
|
6546
|
+
);
|
|
6547
|
+
}
|
|
6548
|
+
async function remove(arbi) {
|
|
6549
|
+
return unwrap(await arbi.fetch.DELETE("/v1/user/identity"), "Could not remove the verification");
|
|
6550
|
+
}
|
|
6551
|
+
|
|
6482
6552
|
// src/operations/projects.ts
|
|
6483
6553
|
var projects_exports = {};
|
|
6484
6554
|
__export(projects_exports, {
|
|
@@ -6495,10 +6565,10 @@ __export(projects_exports, {
|
|
|
6495
6565
|
async function listProjects(arbi) {
|
|
6496
6566
|
return requireData(await arbi.fetch.GET("/v1/user/projects/"), "Failed to fetch projects");
|
|
6497
6567
|
}
|
|
6498
|
-
async function createProject(arbi, name) {
|
|
6568
|
+
async function createProject(arbi, name, plan = "free") {
|
|
6499
6569
|
return requireData(
|
|
6500
6570
|
await arbi.fetch.POST("/v1/user/projects/", {
|
|
6501
|
-
body: { name }
|
|
6571
|
+
body: { name, plan }
|
|
6502
6572
|
}),
|
|
6503
6573
|
"Failed to create project"
|
|
6504
6574
|
);
|
|
@@ -7024,7 +7094,8 @@ var Arbi = class {
|
|
|
7024
7094
|
...this.userProfile,
|
|
7025
7095
|
givenName: updated.given_name ?? this.userProfile.givenName,
|
|
7026
7096
|
familyName: updated.family_name ?? null,
|
|
7027
|
-
picture: updated.picture ?? null
|
|
7097
|
+
picture: updated.picture ?? null,
|
|
7098
|
+
isIdentityVerified: updated.is_identity_verified ?? false
|
|
7028
7099
|
});
|
|
7029
7100
|
}
|
|
7030
7101
|
return updated;
|
|
@@ -7069,6 +7140,49 @@ var Arbi = class {
|
|
|
7069
7140
|
return result;
|
|
7070
7141
|
}
|
|
7071
7142
|
};
|
|
7143
|
+
// ── Identity verification ─────────────────────────────────────────────
|
|
7144
|
+
identity = {
|
|
7145
|
+
/** Whether the ID check is offered (Pro plans), its price, and where the user's check stands. */
|
|
7146
|
+
status: () => getStatus(this.requireClient()),
|
|
7147
|
+
/** Charge the one-time fee to an own Pro project; `requires_action` carries a payment URL. */
|
|
7148
|
+
purchase: (projectExtId) => purchase(this.requireClient(), projectExtId),
|
|
7149
|
+
/** The Didit session URL to run the web SDK on. */
|
|
7150
|
+
startSession: () => startSession(this.requireClient()),
|
|
7151
|
+
/** Read the decision of the open check; the profile follows a granted tick. */
|
|
7152
|
+
refresh: async () => {
|
|
7153
|
+
const status = await refresh(this.requireClient());
|
|
7154
|
+
this.syncIdentity(status);
|
|
7155
|
+
return status;
|
|
7156
|
+
},
|
|
7157
|
+
/** Take the name on the document as the account name; the profile follows. */
|
|
7158
|
+
acceptName: async () => {
|
|
7159
|
+
const client = this.requireClient();
|
|
7160
|
+
const offered = await getStatus(client);
|
|
7161
|
+
const status = await acceptName(client);
|
|
7162
|
+
if (this.userProfile && offered.document_given_name) {
|
|
7163
|
+
this.setUserProfile({
|
|
7164
|
+
...this.userProfile,
|
|
7165
|
+
givenName: offered.document_given_name,
|
|
7166
|
+
familyName: offered.document_family_name ?? null,
|
|
7167
|
+
isIdentityVerified: status.verified
|
|
7168
|
+
});
|
|
7169
|
+
} else {
|
|
7170
|
+
this.syncIdentity(status);
|
|
7171
|
+
}
|
|
7172
|
+
return status;
|
|
7173
|
+
},
|
|
7174
|
+
/** Remove the tick and erase any open check. */
|
|
7175
|
+
remove: async () => {
|
|
7176
|
+
const status = await remove(this.requireClient());
|
|
7177
|
+
this.syncIdentity(status);
|
|
7178
|
+
return status;
|
|
7179
|
+
}
|
|
7180
|
+
};
|
|
7181
|
+
syncIdentity(status) {
|
|
7182
|
+
if (this.userProfile && this.userProfile.isIdentityVerified !== status.verified) {
|
|
7183
|
+
this.setUserProfile({ ...this.userProfile, isIdentityVerified: status.verified });
|
|
7184
|
+
}
|
|
7185
|
+
}
|
|
7072
7186
|
// ── Workspaces ────────────────────────────────────────────────────────
|
|
7073
7187
|
workspaces = {
|
|
7074
7188
|
list: () => listWorkspaces(this.requireClient()),
|
|
@@ -8811,6 +8925,8 @@ exports.getErrorCode = getErrorCode;
|
|
|
8811
8925
|
exports.getErrorMessage = getErrorMessage;
|
|
8812
8926
|
exports.getRawWorkspaceKey = getRawWorkspaceKey;
|
|
8813
8927
|
exports.health = health_exports;
|
|
8928
|
+
exports.identityErrorCode = identityErrorCode;
|
|
8929
|
+
exports.identityVerification = identity_exports;
|
|
8814
8930
|
exports.listen = listen_exports;
|
|
8815
8931
|
exports.mail = mail_exports;
|
|
8816
8932
|
exports.mailNode = mail_node_exports;
|