@arbidocs/sdk 0.4.70 → 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/README.md +1 -0
- package/dist/{browser-Dhk899kq.d.cts → browser-BWUCi_v2.d.cts} +682 -10
- package/dist/{browser-Dhk899kq.d.ts → browser-BWUCi_v2.d.ts} +682 -10
- package/dist/browser.cjs +129 -5
- 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 +128 -6
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +129 -5
- 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 +128 -6
- 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
|
);
|
|
@@ -6186,10 +6256,18 @@ var Arbi = class {
|
|
|
6186
6256
|
this.options = options;
|
|
6187
6257
|
}
|
|
6188
6258
|
// ── Lifecycle ───────────────────────────────────────────────────────────
|
|
6259
|
+
/**
|
|
6260
|
+
* The deployment domain the user's keys are derived for: `deploymentDomain` when given,
|
|
6261
|
+
* otherwise the hostname of `url`. Signing and password changes re-derive keys with it, so a
|
|
6262
|
+
* host that needs it (the document tools' e-signing) reads it here rather than recomputing it.
|
|
6263
|
+
*/
|
|
6264
|
+
getDeploymentDomain() {
|
|
6265
|
+
return this.options.deploymentDomain ?? new URL(this.options.url).hostname;
|
|
6266
|
+
}
|
|
6189
6267
|
/** Initialize the SDK client and sodium crypto. Called automatically by login(). */
|
|
6190
6268
|
async init() {
|
|
6191
6269
|
if (this.client) return this.client;
|
|
6192
|
-
const domain = this.
|
|
6270
|
+
const domain = this.getDeploymentDomain();
|
|
6193
6271
|
this.client = client.createArbiClient({
|
|
6194
6272
|
baseUrl: this.options.url,
|
|
6195
6273
|
deploymentDomain: domain,
|
|
@@ -6452,7 +6530,8 @@ var Arbi = class {
|
|
|
6452
6530
|
...this.userProfile,
|
|
6453
6531
|
givenName: updated.given_name ?? this.userProfile.givenName,
|
|
6454
6532
|
familyName: updated.family_name ?? null,
|
|
6455
|
-
picture: updated.picture ?? null
|
|
6533
|
+
picture: updated.picture ?? null,
|
|
6534
|
+
isIdentityVerified: updated.is_identity_verified ?? false
|
|
6456
6535
|
});
|
|
6457
6536
|
}
|
|
6458
6537
|
return updated;
|
|
@@ -6484,7 +6563,7 @@ var Arbi = class {
|
|
|
6484
6563
|
{ ...params, email, userExtId: lr2.userExtId },
|
|
6485
6564
|
{
|
|
6486
6565
|
fetchClient: client$1.fetch,
|
|
6487
|
-
deploymentDomain: this.
|
|
6566
|
+
deploymentDomain: this.getDeploymentDomain()
|
|
6488
6567
|
}
|
|
6489
6568
|
);
|
|
6490
6569
|
this.loginResult = { ...lr2, signingPrivateKey: result.newSigningPrivateKey };
|
|
@@ -6497,6 +6576,49 @@ var Arbi = class {
|
|
|
6497
6576
|
return result;
|
|
6498
6577
|
}
|
|
6499
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
|
+
}
|
|
6500
6622
|
// ── Workspaces ────────────────────────────────────────────────────────
|
|
6501
6623
|
workspaces = {
|
|
6502
6624
|
list: () => listWorkspaces(this.requireClient()),
|
|
@@ -7162,6 +7284,8 @@ exports.formatWorkspaceChoices = formatWorkspaceChoices;
|
|
|
7162
7284
|
exports.getErrorMessage = getErrorMessage;
|
|
7163
7285
|
exports.getRawWorkspaceKey = getRawWorkspaceKey;
|
|
7164
7286
|
exports.health = health_exports;
|
|
7287
|
+
exports.identityErrorCode = identityErrorCode;
|
|
7288
|
+
exports.identityVerification = identity_exports;
|
|
7165
7289
|
exports.mail = mail_exports;
|
|
7166
7290
|
exports.parseSSEEvents = parseSSEEvents;
|
|
7167
7291
|
exports.parseSlashCommand = parseSlashCommand;
|