@bloque/sdk-compliance 0.7.0 → 0.8.1
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/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/wire-types.d.ts +54 -0
- package/dist/tiers/types.d.ts +14 -0
- package/dist/tos-gate/tos-gate-client.d.ts +42 -0
- package/dist/tos-gate/types.d.ts +74 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{VerificationGateClient:()=>VerificationGateClient,mapVerificationFlow:()=>mapVerificationFlow,KycClient:()=>KycClient,ComplianceClient:()=>ComplianceClient,mapRequirementField:()=>mapRequirementField,TiersClient:()=>TiersClient,TosGateClient:()=>TosGateClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class KycClient extends sdk_core_namespaceObject.BaseClient{async startVerification(e){let t=await this.httpClient.request({method:"POST",path:"/api/compliance",body:{urn:e.urn,type:"kyc",accompliceType:"person"}});return{url:t.url,status:t.status,completedAt:null}}async getVerification(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}`});return{status:t.status,url:t.verification_url,completedAt:t.completed_at,result:t.result,documentsStatus:t.documents_status}}async getDocuments(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}/documents`});return{documentsStatus:t.documents_status,documents:t.documents.map(e=>({documentType:e.document_type,side:e.side,imageBase64:e.image_base64,imageSizeBytes:e.image_size_bytes}))}}}function mapRequirementFieldOption(e){return"string"==typeof e?e:{value:e.value,label:{en:e.label.en,es:e.label.es}}}function mapRequirementField(e){return{key:e.key,label:e.label,description:e.description,type:e.type,required:e.required,options:e.options?.map(mapRequirementFieldOption),locale:e.locale}}function mapRequirementStatus(e){return{key:e.key,kind:e.kind,status:e.status,description:e.description,title:e.title,fields:e.fields?.map(mapRequirementField),requiresUpload:e.requires_upload,submittedAt:e.submitted_at}}function mapVerificationFlow(e){if(e)return{type:e.type,method:e.method,startEndpoint:e.start_endpoint,responseUrlField:e.response_url_field}}class TiersClient extends sdk_core_namespaceObject.BaseClient{async getStatus(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}/tier-status`});return{identityUrn:t.identity_urn,effectiveLevel:t.effective_level,policyVersion:t.policy_version,levels:t.levels.map(e=>({level:e.level,name:e.name,satisfied:e.satisfied,requirements:e.requirements.map(mapRequirementStatus)})),nextLevel:t.next_level,missingRequirements:t.missing_requirements??[],pendingRequirements:t.pending_requirements??[],verificationFlow:mapVerificationFlow(t.verification_flow)}}}function mapAcceptance(e){return{id:e.id,identityUrn:e.identity_urn,documentVersionId:e.document_version_id,documentVersionLabel:e.document_version_label,documentHash:e.document_hash,acceptedAt:e.accepted_at,authAssurance:e.auth_assurance}}class TosGateClient extends sdk_core_namespaceObject.BaseClient{async start(e){let t=await this.httpClient.request({method:"POST",path:"/api/tos-gate/start",body:{return_url:e.returnUrl}});return{token:t.token,url:t.url,expiresIn:t.expires_in}}async init(e){let t=await this.httpClient.request({method:"GET",path:"/api/tos-gate/init",authorizationOverride:`Bearer ${e.token}`});return{document:{documentVersionId:t.document.document_version_id,versionLabel:t.document.version_label,contentHash:t.document.content_hash,content:t.document.content},csrfToken:t.csrf_token,returnUrl:t.return_url,showHome:t.show_home,accentColor:t.accent_color}}async accept(e){let t={csrf_token:e.csrfToken,...e.deviceAttestation&&{device_attestation:e.deviceAttestation}},i=await this.httpClient.request({method:"POST",path:"/api/tos-gate/accept",body:t,authorizationOverride:`Bearer ${e.token}`});return{acceptance:mapAcceptance(i.acceptance),returnUrl:i.return_url}}}function mapUploadIntent(e){return{contentType:e.content_type,key:e.key,uploadUrl:e.upload_url,maxSizeBytes:e.max_size_bytes}}function mapRequirement(e){return{key:e.key,kind:e.kind,description:e.description,title:e.title,fields:e.fields?.map(mapRequirementField),uploadable:e.uploadable,uploadIntents:e.upload_intents?.map(mapUploadIntent)}}function mapDocumentToWire(e){return{requirement_key:e.requirementKey,s3_key:e.s3Key,document_type:e.documentType,side:e.side,original_filename:e.originalFilename}}function mapAnswerToWire(e){return{requirement_key:e.requirementKey,values:e.values}}class VerificationGateClient extends sdk_core_namespaceObject.BaseClient{async start(e){let t=await this.httpClient.request({method:"POST",path:"/api/verification-gate/start",body:{return_url:e.returnUrl}});return{token:t.token,url:t.url,expiresIn:t.expires_in}}async init(e){let t=await this.httpClient.request({method:"GET",path:"/api/verification-gate/init",authorizationOverride:`Bearer ${e.token}`});return{requirements:t.requirements.map(mapRequirement),pendingRequirements:(t.pending_requirements??[]).map(e=>({key:e.key,description:e.description,title:e.title,submittedAt:e.submitted_at})),csrfToken:t.csrf_token,returnUrl:t.return_url,accentColor:t.accent_color}}async submit(e){let t={csrf_token:e.csrfToken,documents:e.documents?.map(mapDocumentToWire),answers:e.answers?.map(mapAnswerToWire)},i=await this.httpClient.request({method:"POST",path:"/api/verification-gate/submit",body:t,authorizationOverride:`Bearer ${e.token}`});return{returnUrl:i.return_url,documents:i.documents,answers:i.answers}}}class ComplianceClient extends sdk_core_namespaceObject.BaseClient{kyc;tiers;tosGate;verificationGate;constructor(e){super(e),this.kyc=new KycClient(this.httpClient),this.tiers=new TiersClient(this.httpClient),this.tosGate=new TosGateClient(this.httpClient),this.verificationGate=new VerificationGateClient(this.httpClient)}}for(var __rspack_i in exports.ComplianceClient=__webpack_exports__.ComplianceClient,exports.KycClient=__webpack_exports__.KycClient,exports.TiersClient=__webpack_exports__.TiersClient,exports.TosGateClient=__webpack_exports__.TosGateClient,exports.VerificationGateClient=__webpack_exports__.VerificationGateClient,exports.mapRequirementField=__webpack_exports__.mapRequirementField,exports.mapVerificationFlow=__webpack_exports__.mapVerificationFlow,__webpack_exports__)-1===["ComplianceClient","KycClient","TiersClient","TosGateClient","VerificationGateClient","mapRequirementField","mapVerificationFlow"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{VerificationGateClient:()=>VerificationGateClient,mapVerificationFlow:()=>mapVerificationFlow,KycClient:()=>KycClient,ComplianceClient:()=>ComplianceClient,mapRequirementField:()=>mapRequirementField,TiersClient:()=>TiersClient,TosGateClient:()=>TosGateClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class KycClient extends sdk_core_namespaceObject.BaseClient{async startVerification(e){let t=await this.httpClient.request({method:"POST",path:"/api/compliance",body:{urn:e.urn,type:"kyc",accompliceType:"person"}});return{url:t.url,status:t.status,completedAt:null}}async getVerification(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}`});return{status:t.status,url:t.verification_url,completedAt:t.completed_at,result:t.result,documentsStatus:t.documents_status}}async getDocuments(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}/documents`});return{documentsStatus:t.documents_status,documents:t.documents.map(e=>({documentType:e.document_type,side:e.side,imageBase64:e.image_base64,imageSizeBytes:e.image_size_bytes}))}}}function mapRequirementFieldOption(e){return"string"==typeof e?e:{value:e.value,label:{en:e.label.en,es:e.label.es}}}function mapRequirementField(e){return{key:e.key,label:e.label,description:e.description,type:e.type,required:e.required,options:e.options?.map(mapRequirementFieldOption),locale:e.locale}}function mapRequirementStatus(e){return{key:e.key,kind:e.kind,status:e.status,description:e.description,title:e.title,fields:e.fields?.map(mapRequirementField),requiresUpload:e.requires_upload,submittedAt:e.submitted_at,graceUntil:e.grace_until}}function mapVerificationFlow(e){if(e)return{type:e.type,method:e.method,startEndpoint:e.start_endpoint,responseUrlField:e.response_url_field}}class TiersClient extends sdk_core_namespaceObject.BaseClient{async getStatus(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}/tier-status`});return{identityUrn:t.identity_urn,effectiveLevel:t.effective_level,policyVersion:t.policy_version,levels:t.levels.map(e=>({level:e.level,name:e.name,satisfied:e.satisfied,requirements:e.requirements.map(mapRequirementStatus)})),nextLevel:t.next_level,missingRequirements:t.missing_requirements??[],pendingRequirements:t.pending_requirements??[],verificationFlow:mapVerificationFlow(t.verification_flow),nextRecomputeAt:t.next_recompute_at}}}function mapAcceptance(e){return{id:e.id,identityUrn:e.identity_urn,documentVersionId:e.document_version_id,documentVersionLabel:e.document_version_label,documentHash:e.document_hash,acceptedAt:e.accepted_at,authAssurance:e.auth_assurance,...e.account_activation&&{accountActivation:{attempted:e.account_activation.attempted,state:e.account_activation.state,publicAddress:e.account_activation.public_address,reason:e.account_activation.reason}}}}class TosGateClient extends sdk_core_namespaceObject.BaseClient{async start(e){let t=await this.httpClient.request({method:"POST",path:"/api/tos-gate/start",body:{return_url:e.returnUrl}});return{token:t.token,url:t.url,expiresIn:t.expires_in}}async init(e){let t=await this.httpClient.request({method:"GET",path:"/api/tos-gate/init",authorizationOverride:`Bearer ${e.token}`});return{document:{documentVersionId:t.document.document_version_id,versionLabel:t.document.version_label,contentHash:t.document.content_hash,content:t.document.content},csrfToken:t.csrf_token,returnUrl:t.return_url,showHome:t.show_home,accentColor:t.accent_color,passkey:t.passkey?this._mapPasskeyChallenge(t.passkey):null}}async accept(e){let t={csrf_token:e.csrfToken,...e.deviceAttestation&&{device_attestation:e.deviceAttestation},...!e.deviceAttestation&&e.passkey&&{passkey:{credential_id:e.passkey.credentialId,authenticator_data:e.passkey.authenticatorData,client_data:e.passkey.clientData,public_key:e.passkey.publicKey,context:e.passkey.context}}},i=await this.httpClient.request({method:"POST",path:"/api/tos-gate/accept",body:t,authorizationOverride:`Bearer ${e.token}`});return{acceptance:mapAcceptance(i.acceptance),returnUrl:i.return_url}}_mapPasskeyChallenge(e){return{challenge:e.challenge,context:e.context,expiresAtBlock:e.expires_at_block,userId:e.user_id,userName:e.user_name,publicAddress:e.public_address,rpId:e.rp_id}}}function mapUploadIntent(e){return{contentType:e.content_type,key:e.key,uploadUrl:e.upload_url,maxSizeBytes:e.max_size_bytes}}function mapRequirement(e){return{key:e.key,kind:e.kind,description:e.description,title:e.title,fields:e.fields?.map(mapRequirementField),uploadable:e.uploadable,uploadIntents:e.upload_intents?.map(mapUploadIntent)}}function mapDocumentToWire(e){return{requirement_key:e.requirementKey,s3_key:e.s3Key,document_type:e.documentType,side:e.side,original_filename:e.originalFilename}}function mapAnswerToWire(e){return{requirement_key:e.requirementKey,values:e.values}}class VerificationGateClient extends sdk_core_namespaceObject.BaseClient{async start(e){let t=await this.httpClient.request({method:"POST",path:"/api/verification-gate/start",body:{return_url:e.returnUrl}});return{token:t.token,url:t.url,expiresIn:t.expires_in}}async init(e){let t=await this.httpClient.request({method:"GET",path:"/api/verification-gate/init",authorizationOverride:`Bearer ${e.token}`});return{requirements:t.requirements.map(mapRequirement),pendingRequirements:(t.pending_requirements??[]).map(e=>({key:e.key,description:e.description,title:e.title,submittedAt:e.submitted_at})),csrfToken:t.csrf_token,returnUrl:t.return_url,accentColor:t.accent_color}}async submit(e){let t={csrf_token:e.csrfToken,documents:e.documents?.map(mapDocumentToWire),answers:e.answers?.map(mapAnswerToWire)},i=await this.httpClient.request({method:"POST",path:"/api/verification-gate/submit",body:t,authorizationOverride:`Bearer ${e.token}`});return{returnUrl:i.return_url,documents:i.documents,answers:i.answers}}}class ComplianceClient extends sdk_core_namespaceObject.BaseClient{kyc;tiers;tosGate;verificationGate;constructor(e){super(e),this.kyc=new KycClient(this.httpClient),this.tiers=new TiersClient(this.httpClient),this.tosGate=new TosGateClient(this.httpClient),this.verificationGate=new VerificationGateClient(this.httpClient)}}for(var __rspack_i in exports.ComplianceClient=__webpack_exports__.ComplianceClient,exports.KycClient=__webpack_exports__.KycClient,exports.TiersClient=__webpack_exports__.TiersClient,exports.TosGateClient=__webpack_exports__.TosGateClient,exports.VerificationGateClient=__webpack_exports__.VerificationGateClient,exports.mapRequirementField=__webpack_exports__.mapRequirementField,exports.mapVerificationFlow=__webpack_exports__.mapVerificationFlow,__webpack_exports__)-1===["ComplianceClient","KycClient","TiersClient","TosGateClient","VerificationGateClient","mapRequirementField","mapVerificationFlow"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BaseClient as e}from"@bloque/sdk-core";class t extends e{async startVerification(e){let t=await this.httpClient.request({method:"POST",path:"/api/compliance",body:{urn:e.urn,type:"kyc",accompliceType:"person"}});return{url:t.url,status:t.status,completedAt:null}}async getVerification(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}`});return{status:t.status,url:t.verification_url,completedAt:t.completed_at,result:t.result,documentsStatus:t.documents_status}}async getDocuments(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}/documents`});return{documentsStatus:t.documents_status,documents:t.documents.map(e=>({documentType:e.document_type,side:e.side,imageBase64:e.image_base64,imageSizeBytes:e.image_size_bytes}))}}}function n(e){return"string"==typeof e?e:{value:e.value,label:{en:e.label.en,es:e.label.es}}}function i(e){return{key:e.key,label:e.label,description:e.description,type:e.type,required:e.required,options:e.options?.map(n),locale:e.locale}}function
|
|
1
|
+
import{BaseClient as e}from"@bloque/sdk-core";class t extends e{async startVerification(e){let t=await this.httpClient.request({method:"POST",path:"/api/compliance",body:{urn:e.urn,type:"kyc",accompliceType:"person"}});return{url:t.url,status:t.status,completedAt:null}}async getVerification(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}`});return{status:t.status,url:t.verification_url,completedAt:t.completed_at,result:t.result,documentsStatus:t.documents_status}}async getDocuments(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}/documents`});return{documentsStatus:t.documents_status,documents:t.documents.map(e=>({documentType:e.document_type,side:e.side,imageBase64:e.image_base64,imageSizeBytes:e.image_size_bytes}))}}}function n(e){return"string"==typeof e?e:{value:e.value,label:{en:e.label.en,es:e.label.es}}}function i(e){return{key:e.key,label:e.label,description:e.description,type:e.type,required:e.required,options:e.options?.map(n),locale:e.locale}}function a(e){return{key:e.key,kind:e.kind,status:e.status,description:e.description,title:e.title,fields:e.fields?.map(i),requiresUpload:e.requires_upload,submittedAt:e.submitted_at,graceUntil:e.grace_until}}function s(e){if(e)return{type:e.type,method:e.method,startEndpoint:e.start_endpoint,responseUrlField:e.response_url_field}}class r extends e{async getStatus(e){let t=await this.httpClient.request({method:"GET",path:`/api/compliance/${e.urn}/tier-status`});return{identityUrn:t.identity_urn,effectiveLevel:t.effective_level,policyVersion:t.policy_version,levels:t.levels.map(e=>({level:e.level,name:e.name,satisfied:e.satisfied,requirements:e.requirements.map(a)})),nextLevel:t.next_level,missingRequirements:t.missing_requirements??[],pendingRequirements:t.pending_requirements??[],verificationFlow:s(t.verification_flow),nextRecomputeAt:t.next_recompute_at}}}class o extends e{async start(e){let t=await this.httpClient.request({method:"POST",path:"/api/tos-gate/start",body:{return_url:e.returnUrl}});return{token:t.token,url:t.url,expiresIn:t.expires_in}}async init(e){let t=await this.httpClient.request({method:"GET",path:"/api/tos-gate/init",authorizationOverride:`Bearer ${e.token}`});return{document:{documentVersionId:t.document.document_version_id,versionLabel:t.document.version_label,contentHash:t.document.content_hash,content:t.document.content},csrfToken:t.csrf_token,returnUrl:t.return_url,showHome:t.show_home,accentColor:t.accent_color,passkey:t.passkey?this._mapPasskeyChallenge(t.passkey):null}}async accept(e){var t;let n={csrf_token:e.csrfToken,...e.deviceAttestation&&{device_attestation:e.deviceAttestation},...!e.deviceAttestation&&e.passkey&&{passkey:{credential_id:e.passkey.credentialId,authenticator_data:e.passkey.authenticatorData,client_data:e.passkey.clientData,public_key:e.passkey.publicKey,context:e.passkey.context}}},i=await this.httpClient.request({method:"POST",path:"/api/tos-gate/accept",body:n,authorizationOverride:`Bearer ${e.token}`});return{acceptance:{id:(t=i.acceptance).id,identityUrn:t.identity_urn,documentVersionId:t.document_version_id,documentVersionLabel:t.document_version_label,documentHash:t.document_hash,acceptedAt:t.accepted_at,authAssurance:t.auth_assurance,...t.account_activation&&{accountActivation:{attempted:t.account_activation.attempted,state:t.account_activation.state,publicAddress:t.account_activation.public_address,reason:t.account_activation.reason}}},returnUrl:i.return_url}}_mapPasskeyChallenge(e){return{challenge:e.challenge,context:e.context,expiresAtBlock:e.expires_at_block,userId:e.user_id,userName:e.user_name,publicAddress:e.public_address,rpId:e.rp_id}}}function c(e){return{contentType:e.content_type,key:e.key,uploadUrl:e.upload_url,maxSizeBytes:e.max_size_bytes}}function u(e){return{key:e.key,kind:e.kind,description:e.description,title:e.title,fields:e.fields?.map(i),uploadable:e.uploadable,uploadIntents:e.upload_intents?.map(c)}}function l(e){return{requirement_key:e.requirementKey,s3_key:e.s3Key,document_type:e.documentType,side:e.side,original_filename:e.originalFilename}}function d(e){return{requirement_key:e.requirementKey,values:e.values}}class p extends e{async start(e){let t=await this.httpClient.request({method:"POST",path:"/api/verification-gate/start",body:{return_url:e.returnUrl}});return{token:t.token,url:t.url,expiresIn:t.expires_in}}async init(e){let t=await this.httpClient.request({method:"GET",path:"/api/verification-gate/init",authorizationOverride:`Bearer ${e.token}`});return{requirements:t.requirements.map(u),pendingRequirements:(t.pending_requirements??[]).map(e=>({key:e.key,description:e.description,title:e.title,submittedAt:e.submitted_at})),csrfToken:t.csrf_token,returnUrl:t.return_url,accentColor:t.accent_color}}async submit(e){let t={csrf_token:e.csrfToken,documents:e.documents?.map(l),answers:e.answers?.map(d)},n=await this.httpClient.request({method:"POST",path:"/api/verification-gate/submit",body:t,authorizationOverride:`Bearer ${e.token}`});return{returnUrl:n.return_url,documents:n.documents,answers:n.answers}}}class m extends e{kyc;tiers;tosGate;verificationGate;constructor(e){super(e),this.kyc=new t(this.httpClient),this.tiers=new r(this.httpClient),this.tosGate=new o(this.httpClient),this.verificationGate=new p(this.httpClient)}}export{m as ComplianceClient,t as KycClient,r as TiersClient,o as TosGateClient,p as VerificationGateClient,i as mapRequirementField,s as mapVerificationFlow};
|
|
@@ -106,6 +106,9 @@ export interface TierRequirementStatusWire {
|
|
|
106
106
|
fields?: RequirementFieldWire[];
|
|
107
107
|
requires_upload?: boolean;
|
|
108
108
|
submitted_at?: string;
|
|
109
|
+
/** Present only on `tos` while a rollout `enforcement_starts_at` window
|
|
110
|
+
* is treating the requirement as satisfied. ISO-8601. */
|
|
111
|
+
grace_until?: string;
|
|
109
112
|
}
|
|
110
113
|
/**
|
|
111
114
|
* @internal
|
|
@@ -155,6 +158,9 @@ export interface GetTierStatusResponse {
|
|
|
155
158
|
missing_requirements?: string[];
|
|
156
159
|
pending_requirements?: string[];
|
|
157
160
|
verification_flow?: VerificationFlowHandoffWire;
|
|
161
|
+
/** Earliest ISO-8601 instant this answer could change with no further
|
|
162
|
+
* input (e.g. TOS rollout cutoff). `null` when nothing time-driven is pending. */
|
|
163
|
+
next_recompute_at?: string | null;
|
|
158
164
|
}
|
|
159
165
|
/**
|
|
160
166
|
* @internal
|
|
@@ -176,6 +182,22 @@ export interface TosGateDocumentWire {
|
|
|
176
182
|
content_hash: string;
|
|
177
183
|
content: string;
|
|
178
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* @internal
|
|
187
|
+
* WebAuthn registration challenge minted by ledger for a TOS document that
|
|
188
|
+
* requires account activation. Present on `GET /api/tos-gate/init` only when
|
|
189
|
+
* that document's `requires_account_activation` is set.
|
|
190
|
+
*/
|
|
191
|
+
export interface TosGatePasskeyChallengeWire {
|
|
192
|
+
challenge: string;
|
|
193
|
+
context: number;
|
|
194
|
+
expires_at_block: number;
|
|
195
|
+
user_id: string;
|
|
196
|
+
user_name: string;
|
|
197
|
+
public_address: string;
|
|
198
|
+
/** Only present if the deployment has `TOS_GATE_WEBAUTHN_RP_ID` set. */
|
|
199
|
+
rp_id?: string;
|
|
200
|
+
}
|
|
179
201
|
/**
|
|
180
202
|
* @internal
|
|
181
203
|
* `GET /api/tos-gate/init` response.
|
|
@@ -186,6 +208,24 @@ export interface TosGateInitResponse {
|
|
|
186
208
|
return_url: string;
|
|
187
209
|
show_home: boolean;
|
|
188
210
|
accent_color?: string;
|
|
211
|
+
/**
|
|
212
|
+
* `null` when this document doesn't require account activation, or when
|
|
213
|
+
* minting the challenge failed server-side (fails open).
|
|
214
|
+
*/
|
|
215
|
+
passkey: TosGatePasskeyChallengeWire | null;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* @internal
|
|
219
|
+
* Raw WebAuthn registration parts, as an alternative to `device_attestation`
|
|
220
|
+
* for callers driving `init()`/`accept()` themselves instead of opening the
|
|
221
|
+
* hosted page.
|
|
222
|
+
*/
|
|
223
|
+
export interface TosGatePasskeyRegistrationWire {
|
|
224
|
+
credential_id: string;
|
|
225
|
+
authenticator_data: string;
|
|
226
|
+
client_data: string;
|
|
227
|
+
public_key: string;
|
|
228
|
+
context: number;
|
|
189
229
|
}
|
|
190
230
|
/**
|
|
191
231
|
* @internal
|
|
@@ -194,6 +234,19 @@ export interface TosGateInitResponse {
|
|
|
194
234
|
export interface TosGateAcceptRequest {
|
|
195
235
|
csrf_token: string;
|
|
196
236
|
device_attestation?: string;
|
|
237
|
+
passkey?: TosGatePasskeyRegistrationWire;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* @internal
|
|
241
|
+
* Outcome of handing the identity's Kreivo PassAccount to the device that
|
|
242
|
+
* supplied `device_attestation`/`passkey` on accept. Absent when no
|
|
243
|
+
* attestation was supplied.
|
|
244
|
+
*/
|
|
245
|
+
export interface TosAccountActivationWire {
|
|
246
|
+
attempted: boolean;
|
|
247
|
+
state?: string;
|
|
248
|
+
public_address?: string;
|
|
249
|
+
reason?: string;
|
|
197
250
|
}
|
|
198
251
|
/**
|
|
199
252
|
* @internal
|
|
@@ -207,6 +260,7 @@ export interface TosAcceptanceRecordWire {
|
|
|
207
260
|
document_hash: string;
|
|
208
261
|
accepted_at: string;
|
|
209
262
|
auth_assurance: string;
|
|
263
|
+
account_activation?: TosAccountActivationWire;
|
|
210
264
|
}
|
|
211
265
|
/**
|
|
212
266
|
* @internal
|
package/dist/tiers/types.d.ts
CHANGED
|
@@ -61,6 +61,14 @@ export interface TierRequirementStatus {
|
|
|
61
61
|
/** ISO-8601 timestamp of the submission behind a `'pending_review'`
|
|
62
62
|
* status, for a "submitted on X" line. */
|
|
63
63
|
submittedAt?: string;
|
|
64
|
+
/**
|
|
65
|
+
* ISO-8601. Set only on the `tos` requirement, and only while it reads
|
|
66
|
+
* `'satisfied'` because of a policy rollout `enforcement_starts_at`
|
|
67
|
+
* window — not for prior-version `grace_period_days`, and not from other
|
|
68
|
+
* requirement kinds. Use it to prompt "accept by X" even though
|
|
69
|
+
* `missingRequirements` / `verificationFlow` are quiet for the window.
|
|
70
|
+
*/
|
|
71
|
+
graceUntil?: string;
|
|
64
72
|
}
|
|
65
73
|
export interface TierLevelStatus {
|
|
66
74
|
level: number;
|
|
@@ -95,4 +103,10 @@ export interface TierStatus {
|
|
|
95
103
|
* there is nothing left for your user to do. */
|
|
96
104
|
pendingRequirements: string[];
|
|
97
105
|
verificationFlow?: VerificationFlowHandoff;
|
|
106
|
+
/**
|
|
107
|
+
* Earliest ISO-8601 instant this answer could change with no further
|
|
108
|
+
* input (TOS rollout cutoff, or satisfied evidence reaching `expires_at`).
|
|
109
|
+
* `null` / omitted when nothing time-driven is pending.
|
|
110
|
+
*/
|
|
111
|
+
nextRecomputeAt?: string | null;
|
|
98
112
|
}
|
|
@@ -13,6 +13,14 @@ import type { StartGateResult, StartTosGateParams, TosGateAcceptParams, TosGateA
|
|
|
13
13
|
* Usually you won't call these directly: catch a
|
|
14
14
|
* `BloqueVerificationRequiredError` with `reason === 'tos'` and call its
|
|
15
15
|
* `getVerificationLink()` instead, which calls `start()` for you.
|
|
16
|
+
*
|
|
17
|
+
* Some TOS documents also require handing the identity's Kreivo PassAccount
|
|
18
|
+
* to a passkey on the same request (account activation). When that applies,
|
|
19
|
+
* `init()`'s `passkey` is non-null — the hosted page runs WebAuthn against it
|
|
20
|
+
* automatically; driving `init()`/`accept()` yourself means doing that
|
|
21
|
+
* yourself and passing the result as `accept()`'s `passkey` (or a finished
|
|
22
|
+
* `deviceAttestation`). Declining is fine — `accept()` without either still
|
|
23
|
+
* records the acceptance.
|
|
16
24
|
*/
|
|
17
25
|
export declare class TosGateClient extends BaseClient {
|
|
18
26
|
/**
|
|
@@ -30,11 +38,45 @@ export declare class TosGateClient extends BaseClient {
|
|
|
30
38
|
/**
|
|
31
39
|
* Fetch the active TOS document for the token's identity and mint a
|
|
32
40
|
* single-use acceptance nonce. Authorized solely by `params.token`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const { document, csrfToken, passkey } = await bloque.compliance.tosGate.init({
|
|
45
|
+
* token: gate.token,
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* if (passkey) {
|
|
49
|
+
* // This document requires account activation — run WebAuthn against
|
|
50
|
+
* // the challenge, then pass the result to accept() as `passkey`.
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
33
53
|
*/
|
|
34
54
|
init(params: TosGateInitParams): Promise<TosGateInitResult>;
|
|
35
55
|
/**
|
|
36
56
|
* Record TOS acceptance for the token's identity. Authorized solely by
|
|
37
57
|
* `params.token`; requires the single-use `csrfToken` from `init()`.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* // Plain acceptance, no activation step
|
|
62
|
+
* await bloque.compliance.tosGate.accept({ token: gate.token, csrfToken });
|
|
63
|
+
*
|
|
64
|
+
* // With account activation, after running WebAuthn against init().passkey
|
|
65
|
+
* const { acceptance } = await bloque.compliance.tosGate.accept({
|
|
66
|
+
* token: gate.token,
|
|
67
|
+
* csrfToken,
|
|
68
|
+
* passkey: {
|
|
69
|
+
* credentialId,
|
|
70
|
+
* authenticatorData,
|
|
71
|
+
* clientData,
|
|
72
|
+
* publicKey,
|
|
73
|
+
* context: passkey.context,
|
|
74
|
+
* },
|
|
75
|
+
* });
|
|
76
|
+
* console.log(acceptance.accountActivation?.attempted);
|
|
77
|
+
* ```
|
|
38
78
|
*/
|
|
39
79
|
accept(params: TosGateAcceptParams): Promise<TosGateAcceptResult>;
|
|
80
|
+
/** @internal */
|
|
81
|
+
private _mapPasskeyChallenge;
|
|
40
82
|
}
|
package/dist/tos-gate/types.d.ts
CHANGED
|
@@ -24,6 +24,31 @@ export interface TosGateDocument {
|
|
|
24
24
|
/** Rendered document content (Markdown-templated to HTML server-side). */
|
|
25
25
|
content: string;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* WebAuthn passkey registration challenge for the account-activation step —
|
|
29
|
+
* present on `init()` only when the active TOS document has
|
|
30
|
+
* `requiresAccountActivation` set (see compliance's `TosPolicyConfig`).
|
|
31
|
+
* Build a `PublicKeyCredentialCreationOptions` from this and call
|
|
32
|
+
* `navigator.credentials.create()`, then pass the result to `accept()` as
|
|
33
|
+
* `passkey`. Declining is fine — call `accept()` without it and the
|
|
34
|
+
* acceptance still records; the account is simply left
|
|
35
|
+
* registered-but-not-activated (recoverable later).
|
|
36
|
+
*/
|
|
37
|
+
export interface TosGatePasskeyChallenge {
|
|
38
|
+
/** Base64url — becomes `publicKey.challenge`. */
|
|
39
|
+
challenge: string;
|
|
40
|
+
/** The chain block this challenge is bound to; pass back unchanged in `accept()`'s `passkey.context`. */
|
|
41
|
+
context: number;
|
|
42
|
+
/** Last block the challenge can still be answered at (advisory only — the chain enforces it). */
|
|
43
|
+
expiresAtBlock: number;
|
|
44
|
+
/** Base64url — becomes `publicKey.user.id`. */
|
|
45
|
+
userId: string;
|
|
46
|
+
/** Human-facing credential name, as the authenticator displays it. */
|
|
47
|
+
userName: string;
|
|
48
|
+
publicAddress: string;
|
|
49
|
+
/** Relying Party ID for `navigator.credentials.create()`, if the deployment sets one. */
|
|
50
|
+
rpId?: string;
|
|
51
|
+
}
|
|
27
52
|
export interface TosGateInitResult {
|
|
28
53
|
document: TosGateDocument;
|
|
29
54
|
/** Single-use acceptance nonce — pass as `csrfToken` to `accept()`. */
|
|
@@ -38,6 +63,30 @@ export interface TosGateInitResult {
|
|
|
38
63
|
* useful if you're building your own UI around the gate rather than
|
|
39
64
|
* just opening `url` in a browser/webview. */
|
|
40
65
|
accentColor?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Passkey registration challenge, or `null` when this TOS document
|
|
68
|
+
* doesn't require account activation (or minting the challenge failed
|
|
69
|
+
* server-side — this fails open, so `null` here never blocks acceptance).
|
|
70
|
+
*/
|
|
71
|
+
passkey: TosGatePasskeyChallenge | null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Raw WebAuthn registration parts, as an alternative to `deviceAttestation`
|
|
75
|
+
* on `accept()` — use this when you drive `init()`/`accept()` yourself
|
|
76
|
+
* (rather than opening the hosted page) and ran WebAuthn in-browser against
|
|
77
|
+
* `init()`'s `passkey` challenge.
|
|
78
|
+
*/
|
|
79
|
+
export interface TosGatePasskeyRegistration {
|
|
80
|
+
/** `PublicKeyCredential.rawId`, base64url. */
|
|
81
|
+
credentialId: string;
|
|
82
|
+
/** `response.getAuthenticatorData()`, base64url. */
|
|
83
|
+
authenticatorData: string;
|
|
84
|
+
/** `response.clientDataJSON`, base64url. */
|
|
85
|
+
clientData: string;
|
|
86
|
+
/** `response.getPublicKey()` (SPKI), base64url. */
|
|
87
|
+
publicKey: string;
|
|
88
|
+
/** The `context` from `init()`'s `passkey` challenge — echoed back unchanged. */
|
|
89
|
+
context: number;
|
|
41
90
|
}
|
|
42
91
|
export interface TosGateAcceptParams {
|
|
43
92
|
/** The capability token returned by `start()`. */
|
|
@@ -47,9 +96,31 @@ export interface TosGateAcceptParams {
|
|
|
47
96
|
/**
|
|
48
97
|
* Optional Pass device attestation (0x-hex SCALE-encoded
|
|
49
98
|
* `PassDeviceAttestation`). When present, accepting the terms also hands
|
|
50
|
-
* control of the identity's Kreivo PassAccount to that device.
|
|
99
|
+
* control of the identity's Kreivo PassAccount to that device. Takes
|
|
100
|
+
* precedence over `passkey` if both are set.
|
|
51
101
|
*/
|
|
52
102
|
deviceAttestation?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Alternative to `deviceAttestation` — the raw WebAuthn registration you
|
|
105
|
+
* produced yourself against `init()`'s `passkey` challenge.
|
|
106
|
+
*/
|
|
107
|
+
passkey?: TosGatePasskeyRegistration;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Outcome of handing the identity's Kreivo PassAccount to the device that
|
|
111
|
+
* supplied `deviceAttestation`/`passkey` on `accept()`. Non-throwing: a
|
|
112
|
+
* failed activation never invalidates the (legally meaningful) acceptance
|
|
113
|
+
* record it's attached to — check `attempted`/`reason` and retry via
|
|
114
|
+
* `accept()` again (or the account stays recoverable in its
|
|
115
|
+
* registered-but-not-activated state).
|
|
116
|
+
*/
|
|
117
|
+
export interface TosAccountActivation {
|
|
118
|
+
attempted: boolean;
|
|
119
|
+
/** Provisioning state reported by ledger, when the call succeeded. */
|
|
120
|
+
state?: string;
|
|
121
|
+
publicAddress?: string;
|
|
122
|
+
/** Why activation did not happen or did not succeed. */
|
|
123
|
+
reason?: string;
|
|
53
124
|
}
|
|
54
125
|
export interface TosAcceptanceRecord {
|
|
55
126
|
id: string;
|
|
@@ -59,6 +130,8 @@ export interface TosAcceptanceRecord {
|
|
|
59
130
|
documentHash: string;
|
|
60
131
|
acceptedAt: string;
|
|
61
132
|
authAssurance: string;
|
|
133
|
+
/** Present only when `accept()` was called with `deviceAttestation` or `passkey`. */
|
|
134
|
+
accountActivation?: TosAccountActivation;
|
|
62
135
|
}
|
|
63
136
|
export interface TosGateAcceptResult {
|
|
64
137
|
acceptance: TosAcceptanceRecord;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-compliance",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bloque",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"node": ">=22"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@bloque/sdk-core": "0.
|
|
37
|
+
"@bloque/sdk-core": "0.8.1"
|
|
38
38
|
}
|
|
39
39
|
}
|