cilantro-sdk 0.0.19 → 0.0.21

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 CHANGED
@@ -809,9 +809,14 @@ var getWallets2 = () => {
809
809
  options
810
810
  );
811
811
  };
812
- const walletControllerStartPasskeyAuthentication2 = (id, options) => {
812
+ const walletControllerStartPasskeyAuthentication2 = (id, startPasskeyAuthenticationDto, options) => {
813
813
  return customInstance(
814
- { url: `/wallets/${id}/signers/passkey/authenticate`, method: "POST" },
814
+ {
815
+ url: `/wallets/${id}/signers/passkey/authenticate`,
816
+ method: "POST",
817
+ headers: { "Content-Type": "application/json" },
818
+ data: startPasskeyAuthenticationDto
819
+ },
815
820
  options
816
821
  );
817
822
  };
@@ -2805,7 +2810,6 @@ __export(helpers_exports, {
2805
2810
  deleteDeviceKey: () => deleteDeviceKey,
2806
2811
  deriveSignerKeypair: () => deriveSignerKeypair,
2807
2812
  detectWallets: () => detectWallets,
2808
- ensureBase64URLCredentialId: () => ensureBase64URLCredentialId,
2809
2813
  exportToSPKI: () => exportToSPKI,
2810
2814
  findAndValidateDeviceKey: () => findAndValidateDeviceKey,
2811
2815
  findDeviceKeyByPublicKey: () => findDeviceKeyByPublicKey,
@@ -5899,31 +5903,73 @@ function platformAuthenticatorIsAvailable() {
5899
5903
  }
5900
5904
 
5901
5905
  // src/signers/passkeyHelpers.ts
5902
- function ensureBase64URLCredentialId(credentialId) {
5903
- if (!credentialId) {
5904
- return credentialId;
5906
+ function toBase64URL(value) {
5907
+ if (typeof value === "string") {
5908
+ if (value.includes("+") || value.includes("/") || value.includes("=")) {
5909
+ return value.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
5910
+ }
5911
+ return value;
5912
+ }
5913
+ let uint8Array;
5914
+ if (Array.isArray(value)) {
5915
+ uint8Array = new Uint8Array(value);
5916
+ } else if (value instanceof ArrayBuffer) {
5917
+ uint8Array = new Uint8Array(value);
5918
+ } else {
5919
+ uint8Array = value;
5905
5920
  }
5906
- let cleaned = credentialId.replace(/=/g, "");
5907
- cleaned = cleaned.replace(/\+/g, "-").replace(/\//g, "_");
5908
- return cleaned;
5921
+ const base64 = btoa(String.fromCharCode(...uint8Array));
5922
+ return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
5923
+ }
5924
+ function isArrayBuffer(value) {
5925
+ if (Array.isArray(value))
5926
+ return true;
5927
+ if (value instanceof ArrayBuffer)
5928
+ return true;
5929
+ if (value instanceof Uint8Array)
5930
+ return true;
5931
+ return false;
5909
5932
  }
5910
5933
  function formatRegistrationResponse(response) {
5911
5934
  const formatted = { ...response };
5912
5935
  if (formatted.id) {
5913
- formatted.id = ensureBase64URLCredentialId(formatted.id);
5936
+ formatted.id = toBase64URL(formatted.id);
5914
5937
  }
5915
5938
  if (formatted.rawId) {
5916
- formatted.rawId = ensureBase64URLCredentialId(formatted.rawId);
5939
+ formatted.rawId = toBase64URL(formatted.rawId);
5940
+ }
5941
+ if (formatted.response) {
5942
+ const formattedResponse = { ...formatted.response };
5943
+ if (isArrayBuffer(formattedResponse.clientDataJSON)) {
5944
+ formattedResponse.clientDataJSON = toBase64URL(formattedResponse.clientDataJSON);
5945
+ }
5946
+ if (isArrayBuffer(formattedResponse.attestationObject)) {
5947
+ formattedResponse.attestationObject = toBase64URL(formattedResponse.attestationObject);
5948
+ }
5949
+ formatted.response = formattedResponse;
5917
5950
  }
5918
5951
  return formatted;
5919
5952
  }
5920
5953
  function formatAuthenticationResponse(response) {
5921
5954
  const formatted = { ...response };
5922
5955
  if (formatted.id) {
5923
- formatted.id = ensureBase64URLCredentialId(formatted.id);
5956
+ formatted.id = toBase64URL(formatted.id);
5924
5957
  }
5925
5958
  if (formatted.rawId) {
5926
- formatted.rawId = ensureBase64URLCredentialId(formatted.rawId);
5959
+ formatted.rawId = toBase64URL(formatted.rawId);
5960
+ }
5961
+ if (formatted.response) {
5962
+ const formattedResponse = { ...formatted.response };
5963
+ if (isArrayBuffer(formattedResponse.clientDataJSON)) {
5964
+ formattedResponse.clientDataJSON = toBase64URL(formattedResponse.clientDataJSON);
5965
+ }
5966
+ if (isArrayBuffer(formattedResponse.authenticatorData)) {
5967
+ formattedResponse.authenticatorData = toBase64URL(formattedResponse.authenticatorData);
5968
+ }
5969
+ if (isArrayBuffer(formattedResponse.signature)) {
5970
+ formattedResponse.signature = toBase64URL(formattedResponse.signature);
5971
+ }
5972
+ formatted.response = formattedResponse;
5927
5973
  }
5928
5974
  return formatted;
5929
5975
  }