@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/browser.cjs
CHANGED
|
@@ -5915,6 +5915,76 @@ async function requestDeletion(arbi) {
|
|
|
5915
5915
|
return requireData(await arbi.fetch.POST("/v1/user/request-deletion"), "Failed to delete account");
|
|
5916
5916
|
}
|
|
5917
5917
|
|
|
5918
|
+
// src/operations/identity.ts
|
|
5919
|
+
var identity_exports = {};
|
|
5920
|
+
__export(identity_exports, {
|
|
5921
|
+
acceptName: () => acceptName,
|
|
5922
|
+
getStatus: () => getStatus,
|
|
5923
|
+
identityErrorCode: () => identityErrorCode,
|
|
5924
|
+
purchase: () => purchase,
|
|
5925
|
+
refresh: () => refresh,
|
|
5926
|
+
remove: () => remove,
|
|
5927
|
+
startSession: () => startSession
|
|
5928
|
+
});
|
|
5929
|
+
function refusal(apiError) {
|
|
5930
|
+
const detail = apiError?.detail;
|
|
5931
|
+
if (typeof detail === "string") return { message: detail };
|
|
5932
|
+
if (detail && typeof detail === "object" && !Array.isArray(detail)) {
|
|
5933
|
+
const { code, message } = detail;
|
|
5934
|
+
return {
|
|
5935
|
+
code: typeof code === "string" ? code : void 0,
|
|
5936
|
+
message: typeof message === "string" ? message : void 0
|
|
5937
|
+
};
|
|
5938
|
+
}
|
|
5939
|
+
return {};
|
|
5940
|
+
}
|
|
5941
|
+
function identityErrorCode(error) {
|
|
5942
|
+
return error instanceof ArbiApiError ? refusal(error.apiError).code : void 0;
|
|
5943
|
+
}
|
|
5944
|
+
function unwrap(result, fallback) {
|
|
5945
|
+
if (result.error || result.data === void 0) {
|
|
5946
|
+
throw new ArbiApiError(
|
|
5947
|
+
refusal(result.error).message ?? fallback,
|
|
5948
|
+
result.error,
|
|
5949
|
+
result.response?.status
|
|
5950
|
+
);
|
|
5951
|
+
}
|
|
5952
|
+
return result.data;
|
|
5953
|
+
}
|
|
5954
|
+
async function getStatus(arbi) {
|
|
5955
|
+
return unwrap(await arbi.fetch.GET("/v1/user/identity"), "Failed to load identity verification");
|
|
5956
|
+
}
|
|
5957
|
+
async function purchase(arbi, projectExtId) {
|
|
5958
|
+
return unwrap(
|
|
5959
|
+
await arbi.fetch.POST("/v1/user/identity/purchase", {
|
|
5960
|
+
body: projectExtId ? { project_ext_id: projectExtId } : {}
|
|
5961
|
+
}),
|
|
5962
|
+
"Payment could not be completed"
|
|
5963
|
+
);
|
|
5964
|
+
}
|
|
5965
|
+
async function startSession(arbi) {
|
|
5966
|
+
const data = unwrap(
|
|
5967
|
+
await arbi.fetch.POST("/v1/user/identity/session"),
|
|
5968
|
+
"Could not start identity verification"
|
|
5969
|
+
);
|
|
5970
|
+
return data.url;
|
|
5971
|
+
}
|
|
5972
|
+
async function refresh(arbi) {
|
|
5973
|
+
return unwrap(
|
|
5974
|
+
await arbi.fetch.POST("/v1/user/identity/refresh"),
|
|
5975
|
+
"Could not read the verification result"
|
|
5976
|
+
);
|
|
5977
|
+
}
|
|
5978
|
+
async function acceptName(arbi) {
|
|
5979
|
+
return unwrap(
|
|
5980
|
+
await arbi.fetch.POST("/v1/user/identity/accept-name"),
|
|
5981
|
+
"Could not change your name"
|
|
5982
|
+
);
|
|
5983
|
+
}
|
|
5984
|
+
async function remove(arbi) {
|
|
5985
|
+
return unwrap(await arbi.fetch.DELETE("/v1/user/identity"), "Could not remove the verification");
|
|
5986
|
+
}
|
|
5987
|
+
|
|
5918
5988
|
// src/operations/projects.ts
|
|
5919
5989
|
var projects_exports = {};
|
|
5920
5990
|
__export(projects_exports, {
|
|
@@ -5931,10 +6001,10 @@ __export(projects_exports, {
|
|
|
5931
6001
|
async function listProjects(arbi) {
|
|
5932
6002
|
return requireData(await arbi.fetch.GET("/v1/user/projects/"), "Failed to fetch projects");
|
|
5933
6003
|
}
|
|
5934
|
-
async function createProject(arbi, name) {
|
|
6004
|
+
async function createProject(arbi, name, plan = "free") {
|
|
5935
6005
|
return requireData(
|
|
5936
6006
|
await arbi.fetch.POST("/v1/user/projects/", {
|
|
5937
|
-
body: { name }
|
|
6007
|
+
body: { name, plan }
|
|
5938
6008
|
}),
|
|
5939
6009
|
"Failed to create project"
|
|
5940
6010
|
);
|
|
@@ -6460,7 +6530,8 @@ var Arbi = class {
|
|
|
6460
6530
|
...this.userProfile,
|
|
6461
6531
|
givenName: updated.given_name ?? this.userProfile.givenName,
|
|
6462
6532
|
familyName: updated.family_name ?? null,
|
|
6463
|
-
picture: updated.picture ?? null
|
|
6533
|
+
picture: updated.picture ?? null,
|
|
6534
|
+
isIdentityVerified: updated.is_identity_verified ?? false
|
|
6464
6535
|
});
|
|
6465
6536
|
}
|
|
6466
6537
|
return updated;
|
|
@@ -6505,6 +6576,49 @@ var Arbi = class {
|
|
|
6505
6576
|
return result;
|
|
6506
6577
|
}
|
|
6507
6578
|
};
|
|
6579
|
+
// ── Identity verification ─────────────────────────────────────────────
|
|
6580
|
+
identity = {
|
|
6581
|
+
/** Whether the ID check is offered (Pro plans), its price, and where the user's check stands. */
|
|
6582
|
+
status: () => getStatus(this.requireClient()),
|
|
6583
|
+
/** Charge the one-time fee to an own Pro project; `requires_action` carries a payment URL. */
|
|
6584
|
+
purchase: (projectExtId) => purchase(this.requireClient(), projectExtId),
|
|
6585
|
+
/** The Didit session URL to run the web SDK on. */
|
|
6586
|
+
startSession: () => startSession(this.requireClient()),
|
|
6587
|
+
/** Read the decision of the open check; the profile follows a granted tick. */
|
|
6588
|
+
refresh: async () => {
|
|
6589
|
+
const status = await refresh(this.requireClient());
|
|
6590
|
+
this.syncIdentity(status);
|
|
6591
|
+
return status;
|
|
6592
|
+
},
|
|
6593
|
+
/** Take the name on the document as the account name; the profile follows. */
|
|
6594
|
+
acceptName: async () => {
|
|
6595
|
+
const client = this.requireClient();
|
|
6596
|
+
const offered = await getStatus(client);
|
|
6597
|
+
const status = await acceptName(client);
|
|
6598
|
+
if (this.userProfile && offered.document_given_name) {
|
|
6599
|
+
this.setUserProfile({
|
|
6600
|
+
...this.userProfile,
|
|
6601
|
+
givenName: offered.document_given_name,
|
|
6602
|
+
familyName: offered.document_family_name ?? null,
|
|
6603
|
+
isIdentityVerified: status.verified
|
|
6604
|
+
});
|
|
6605
|
+
} else {
|
|
6606
|
+
this.syncIdentity(status);
|
|
6607
|
+
}
|
|
6608
|
+
return status;
|
|
6609
|
+
},
|
|
6610
|
+
/** Remove the tick and erase any open check. */
|
|
6611
|
+
remove: async () => {
|
|
6612
|
+
const status = await remove(this.requireClient());
|
|
6613
|
+
this.syncIdentity(status);
|
|
6614
|
+
return status;
|
|
6615
|
+
}
|
|
6616
|
+
};
|
|
6617
|
+
syncIdentity(status) {
|
|
6618
|
+
if (this.userProfile && this.userProfile.isIdentityVerified !== status.verified) {
|
|
6619
|
+
this.setUserProfile({ ...this.userProfile, isIdentityVerified: status.verified });
|
|
6620
|
+
}
|
|
6621
|
+
}
|
|
6508
6622
|
// ── Workspaces ────────────────────────────────────────────────────────
|
|
6509
6623
|
workspaces = {
|
|
6510
6624
|
list: () => listWorkspaces(this.requireClient()),
|
|
@@ -7170,6 +7284,8 @@ exports.formatWorkspaceChoices = formatWorkspaceChoices;
|
|
|
7170
7284
|
exports.getErrorMessage = getErrorMessage;
|
|
7171
7285
|
exports.getRawWorkspaceKey = getRawWorkspaceKey;
|
|
7172
7286
|
exports.health = health_exports;
|
|
7287
|
+
exports.identityErrorCode = identityErrorCode;
|
|
7288
|
+
exports.identityVerification = identity_exports;
|
|
7173
7289
|
exports.mail = mail_exports;
|
|
7174
7290
|
exports.parseSSEEvents = parseSSEEvents;
|
|
7175
7291
|
exports.parseSlashCommand = parseSlashCommand;
|