@bloque/sdk-compliance 0.7.0 → 0.8.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/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/wire-types.d.ts +48 -0
- package/dist/tos-gate/tos-gate-client.d.ts +42 -0
- package/dist/tos-gate/types.d.ts +74 -1
- package/package.json +1 -1
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}}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,...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}}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)}}}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};
|
|
@@ -176,6 +176,22 @@ export interface TosGateDocumentWire {
|
|
|
176
176
|
content_hash: string;
|
|
177
177
|
content: string;
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* @internal
|
|
181
|
+
* WebAuthn registration challenge minted by ledger for a TOS document that
|
|
182
|
+
* requires account activation. Present on `GET /api/tos-gate/init` only when
|
|
183
|
+
* that document's `requires_account_activation` is set.
|
|
184
|
+
*/
|
|
185
|
+
export interface TosGatePasskeyChallengeWire {
|
|
186
|
+
challenge: string;
|
|
187
|
+
context: number;
|
|
188
|
+
expires_at_block: number;
|
|
189
|
+
user_id: string;
|
|
190
|
+
user_name: string;
|
|
191
|
+
public_address: string;
|
|
192
|
+
/** Only present if the deployment has `TOS_GATE_WEBAUTHN_RP_ID` set. */
|
|
193
|
+
rp_id?: string;
|
|
194
|
+
}
|
|
179
195
|
/**
|
|
180
196
|
* @internal
|
|
181
197
|
* `GET /api/tos-gate/init` response.
|
|
@@ -186,6 +202,24 @@ export interface TosGateInitResponse {
|
|
|
186
202
|
return_url: string;
|
|
187
203
|
show_home: boolean;
|
|
188
204
|
accent_color?: string;
|
|
205
|
+
/**
|
|
206
|
+
* `null` when this document doesn't require account activation, or when
|
|
207
|
+
* minting the challenge failed server-side (fails open).
|
|
208
|
+
*/
|
|
209
|
+
passkey: TosGatePasskeyChallengeWire | null;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* @internal
|
|
213
|
+
* Raw WebAuthn registration parts, as an alternative to `device_attestation`
|
|
214
|
+
* for callers driving `init()`/`accept()` themselves instead of opening the
|
|
215
|
+
* hosted page.
|
|
216
|
+
*/
|
|
217
|
+
export interface TosGatePasskeyRegistrationWire {
|
|
218
|
+
credential_id: string;
|
|
219
|
+
authenticator_data: string;
|
|
220
|
+
client_data: string;
|
|
221
|
+
public_key: string;
|
|
222
|
+
context: number;
|
|
189
223
|
}
|
|
190
224
|
/**
|
|
191
225
|
* @internal
|
|
@@ -194,6 +228,19 @@ export interface TosGateInitResponse {
|
|
|
194
228
|
export interface TosGateAcceptRequest {
|
|
195
229
|
csrf_token: string;
|
|
196
230
|
device_attestation?: string;
|
|
231
|
+
passkey?: TosGatePasskeyRegistrationWire;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @internal
|
|
235
|
+
* Outcome of handing the identity's Kreivo PassAccount to the device that
|
|
236
|
+
* supplied `device_attestation`/`passkey` on accept. Absent when no
|
|
237
|
+
* attestation was supplied.
|
|
238
|
+
*/
|
|
239
|
+
export interface TosAccountActivationWire {
|
|
240
|
+
attempted: boolean;
|
|
241
|
+
state?: string;
|
|
242
|
+
public_address?: string;
|
|
243
|
+
reason?: string;
|
|
197
244
|
}
|
|
198
245
|
/**
|
|
199
246
|
* @internal
|
|
@@ -207,6 +254,7 @@ export interface TosAcceptanceRecordWire {
|
|
|
207
254
|
document_hash: string;
|
|
208
255
|
accepted_at: string;
|
|
209
256
|
auth_assurance: string;
|
|
257
|
+
account_activation?: TosAccountActivationWire;
|
|
210
258
|
}
|
|
211
259
|
/**
|
|
212
260
|
* @internal
|
|
@@ -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;
|