New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@crossmint/common-sdk-base

Package Overview
Dependencies
Maintainers
5
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crossmint/common-sdk-base - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

src/types/blockchain.ts

76

dist/index.d.ts

@@ -51,2 +51,76 @@ declare const CROSSMINT_API_KEY_SIGNER_PUBLICKEY_STAGING = "3hSfN4dWSwgCg1uf2yytBtK6KxK3ySFKasd2h9J2vSK5";

interface UiConfigColors {
textPrimary?: string;
textSecondary?: string;
accent?: string;
background?: string;
backgroundSecondary?: string;
backgroundTertiary?: string;
border?: string;
danger?: string;
textLink?: string;
}
interface UIConfig {
colors?: UiConfigColors;
fontSizeBase?: string;
spacingUnit?: string;
borderRadius?: string;
fontWeightPrimary?: string;
fontWeightSecondary?: string;
fonts?: UiConfigFonts;
}
type UiConfigFonts = (CssFontSource | CustomFontSource)[];
interface CssFontSource {
cssSrc: string;
family: string;
}
interface CustomFontSource {
family: string;
src: string;
display?: string;
style?: "normal" | "italic" | "oblique";
weight?: string;
}
declare const EVM_CHAINS: readonly ["ethereum", "ethereum-sepolia", "polygon", "bsc", "optimism", "arbitrum", "base", "zora", "arbitrumnova", "zkatana"];
declare const BLOCKCHAIN_TEST_NET: readonly ["goerli", "ethereum-sepolia", "mumbai", "zkatana"];
declare const ALL_CHAINS: readonly ["solana", "cardano", "sui", "ethereum", "ethereum-sepolia", "polygon", "bsc", "optimism", "arbitrum", "base", "zora", "arbitrumnova", "zkatana"];
declare const EVM_BLOCKCHAIN_INCLUDING_TESTNET: readonly ["ethereum", "ethereum-sepolia", "polygon", "bsc", "optimism", "arbitrum", "base", "zora", "arbitrumnova", "zkatana", "goerli", "ethereum-sepolia", "mumbai", "zkatana"];
declare const BLOCKCHAIN_INCLUDING_TESTNET: readonly ["solana", "cardano", "sui", "ethereum", "ethereum-sepolia", "polygon", "bsc", "optimism", "arbitrum", "base", "zora", "arbitrumnova", "zkatana", "goerli", "ethereum-sepolia", "mumbai", "zkatana"];
type Blockchain = (typeof ALL_CHAINS)[number];
type EVMBlockchain = (typeof EVM_CHAINS)[number];
type BlockchainTestNet = (typeof BLOCKCHAIN_TEST_NET)[number];
type EVMBlockchainIncludingTestnet = (typeof EVM_BLOCKCHAIN_INCLUDING_TESTNET)[number];
type BlockchainIncludingTestnet = (typeof BLOCKCHAIN_INCLUDING_TESTNET)[number];
interface Wallet {
chain: string;
publicKey: string;
}
interface EVMNFT {
chain: EVMBlockchain;
contractAddress: string;
tokenId: string;
}
interface SolanaNFT {
mintHash: string;
chain: "solana";
}
interface CardanoNFT {
chain: "cardano";
assetId: string;
}
type NFTLocator<T extends Blockchain> = `${T}:${string}${T extends EVMBlockchain ? `:${string}` : ""}`;
type NFT = SolanaNFT | EVMNFT | CardanoNFT;
type NFTOrNFTLocator = NFT | NFTLocator<"solana"> | NFTLocator<"ethereum"> | NFTLocator<"polygon"> | NFTLocator<"bsc"> | NFTLocator<"cardano">;
interface CommonProps {
uiConfig?: UIConfig;
environment?: string;
}
interface NFTCollectionViewProps extends CommonProps {
wallets: Wallet[];
}
interface NFTDetailProps extends CommonProps {
nft: NFTOrNFTLocator;
}
type UserIdentifierParams = {

@@ -68,2 +142,2 @@ email?: string;

export { APIKeyEnvironmentPrefix, APIKeyPrefix, APIKeyUsageOrigin, APIKeyUsageOriginPrefix, CROSSMINT_API_KEY_SIGNER_PUBLICKEY_PROD, CROSSMINT_API_KEY_SIGNER_PUBLICKEY_STAGING, UserIdentifier, UserIdentifierParams, ValidateAPIKeyPrefixExpectations, ValidateAPIKeyPrefixResult, ValidateAPIKeyPrefixSuccessData, ValidateAPIKeyResult, environmentToExpectedPublicKey, usageOriginToPrefix, validateAPIKey, validateAPIKeyPrefix };
export { ALL_CHAINS, APIKeyEnvironmentPrefix, APIKeyPrefix, APIKeyUsageOrigin, APIKeyUsageOriginPrefix, BLOCKCHAIN_INCLUDING_TESTNET, BLOCKCHAIN_TEST_NET, Blockchain, BlockchainIncludingTestnet, BlockchainTestNet, CROSSMINT_API_KEY_SIGNER_PUBLICKEY_PROD, CROSSMINT_API_KEY_SIGNER_PUBLICKEY_STAGING, CardanoNFT, CssFontSource, CustomFontSource, EVMBlockchain, EVMBlockchainIncludingTestnet, EVMNFT, EVM_BLOCKCHAIN_INCLUDING_TESTNET, EVM_CHAINS, NFT, NFTCollectionViewProps, NFTDetailProps, NFTLocator, NFTOrNFTLocator, SolanaNFT, UIConfig, UiConfigColors, UiConfigFonts, UserIdentifier, UserIdentifierParams, ValidateAPIKeyPrefixExpectations, ValidateAPIKeyPrefixResult, ValidateAPIKeyPrefixSuccessData, ValidateAPIKeyResult, Wallet, environmentToExpectedPublicKey, usageOriginToPrefix, validateAPIKey, validateAPIKeyPrefix };

7

dist/index.js

@@ -1,7 +0,2 @@

var at=Object.defineProperty,ft=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable;var U=Math.pow,Z=(e,t,r)=>t in e?at(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,z=(e,t)=>{for(var r in t||(t={}))dt.call(t,r)&&Z(e,r,t[r]);if(X)for(var r of X(t))lt.call(t,r)&&Z(e,r,t[r]);return e},Q=(e,t)=>ft(e,ht(t));var C="3hSfN4dWSwgCg1uf2yytBtK6KxK3ySFKasd2h9J2vSK5",N="8erZh8YApGck3iUSUHqATBxqMTM1Ukp9mHmvGgUWHtkK";function tt(e){return e==="client"?"ck":"sk"}function et(e){switch(e){case"development":case"staging":return C;case"production":return N;default:return null}}var O={CLIENT:"ck",SERVER:"sk"},P={DEVELOPMENT:"development",STAGING:"staging",PRODUCTION:"production"},$={CLIENT:"client",SERVER:"server"};import*as _ from"@noble/ed25519";function xt(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function F(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function rt(e,t){xt(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var ut=e=>e instanceof Uint8Array;var k=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);var bt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!bt)throw new Error("Non little-endian hardware is not supported");function gt(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function W(e){if(typeof e=="string"&&(e=gt(e)),!ut(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var V=class{clone(){return this._cloneInto()}},te={}.toString;function nt(e){let t=n=>e().update(W(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function pt(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),c=BigInt(4294967295),o=Number(r>>i&c),f=Number(r&c),d=n?4:0,x=n?0:4;e.setUint32(t+d,o,n),e.setUint32(t+x,f,n)}var T=class extends V{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=k(this.buffer)}update(t){F(this);let{view:r,buffer:n,blockLen:i}=this;t=W(t);let c=t.length;for(let o=0;o<c;){let f=Math.min(i-this.pos,c-o);if(f===i){let d=k(t);for(;i<=c-o;o+=i)this.process(d,o);continue}n.set(t.subarray(o,o+f),this.pos),this.pos+=f,o+=f,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){F(this),rt(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:c}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let a=o;a<i;a++)r[a]=0;pt(n,i-8,BigInt(this.length*8),c),this.process(n,0);let f=k(t),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let x=d/4,u=this.get();if(x>u.length)throw new Error("_sha2: outputLen bigger than state");for(let a=0;a<x;a++)f.setUint32(4*a,u[a],c)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:c,destroyed:o,pos:f}=this;return t.length=i,t.pos=f,t.finished=c,t.destroyed=o,i%r&&t.buffer.set(n),t}};var D=BigInt(4294967295),Y=BigInt(32);function it(e,t=!1){return t?{h:Number(e&D),l:Number(e>>Y&D)}:{h:Number(e>>Y&D)|0,l:Number(e&D)|0}}function yt(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:c,l:o}=it(e[i],t);[r[i],n[i]]=[c,o]}return[r,n]}var Pt=(e,t)=>BigInt(e>>>0)<<Y|BigInt(t>>>0),It=(e,t,r)=>e>>>r,At=(e,t,r)=>e<<32-r|t>>>r,Et=(e,t,r)=>e>>>r|t<<32-r,mt=(e,t,r)=>e<<32-r|t>>>r,wt=(e,t,r)=>e<<64-r|t>>>r-32,St=(e,t,r)=>e>>>r-32|t<<64-r,Kt=(e,t)=>t,Lt=(e,t)=>e,Ut=(e,t,r)=>e<<r|t>>>32-r,Ot=(e,t,r)=>t<<r|e>>>32-r,_t=(e,t,r)=>t<<r-32|e>>>64-r,Bt=(e,t,r)=>e<<r-32|t>>>64-r;function Ht(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/U(2,32)|0)|0,l:i|0}}var Ct=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Nt=(e,t,r,n)=>t+r+n+(e/U(2,32)|0)|0,Vt=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),kt=(e,t,r,n,i)=>t+r+n+i+(e/U(2,32)|0)|0,Tt=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),Dt=(e,t,r,n,i,c)=>t+r+n+i+c+(e/U(2,32)|0)|0;var vt={fromBig:it,split:yt,toBig:Pt,shrSH:It,shrSL:At,rotrSH:Et,rotrSL:mt,rotrBH:wt,rotrBL:St,rotr32H:Kt,rotr32L:Lt,rotlSH:Ut,rotlSL:Ot,rotlBH:_t,rotlBL:Bt,add:Ht,add3L:Ct,add3H:Nt,add4L:Vt,add4H:kt,add5H:Dt,add5L:Tt},s=vt;var[Gt,Rt]=(()=>s.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),w=new Uint32Array(80),S=new Uint32Array(80),j=class extends T{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:c,Cl:o,Dh:f,Dl:d,Eh:x,El:u,Fh:a,Fl:l,Gh:b,Gl:g,Hh:p,Hl:y}=this;return[t,r,n,i,c,o,f,d,x,u,a,l,b,g,p,y]}set(t,r,n,i,c,o,f,d,x,u,a,l,b,g,p,y){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=c|0,this.Cl=o|0,this.Dh=f|0,this.Dl=d|0,this.Eh=x|0,this.El=u|0,this.Fh=a|0,this.Fl=l|0,this.Gh=b|0,this.Gl=g|0,this.Hh=p|0,this.Hl=y|0}process(t,r){for(let h=0;h<16;h++,r+=4)w[h]=t.getUint32(r),S[h]=t.getUint32(r+=4);for(let h=16;h<80;h++){let E=w[h-15]|0,m=S[h-15]|0,v=s.rotrSH(E,m,1)^s.rotrSH(E,m,8)^s.shrSH(E,m,7),G=s.rotrSL(E,m,1)^s.rotrSL(E,m,8)^s.shrSL(E,m,7),I=w[h-2]|0,A=S[h-2]|0,B=s.rotrSH(I,A,19)^s.rotrBH(I,A,61)^s.shrSH(I,A,6),R=s.rotrSL(I,A,19)^s.rotrBL(I,A,61)^s.shrSL(I,A,6),H=s.add4L(G,R,S[h-7],S[h-16]),M=s.add4H(H,v,B,w[h-7],w[h-16]);w[h]=M|0,S[h]=H|0}let{Ah:n,Al:i,Bh:c,Bl:o,Ch:f,Cl:d,Dh:x,Dl:u,Eh:a,El:l,Fh:b,Fl:g,Gh:p,Gl:y,Hh:K,Hl:L}=this;for(let h=0;h<80;h++){let E=s.rotrSH(a,l,14)^s.rotrSH(a,l,18)^s.rotrBH(a,l,41),m=s.rotrSL(a,l,14)^s.rotrSL(a,l,18)^s.rotrBL(a,l,41),v=a&b^~a&p,G=l&g^~l&y,I=s.add5L(L,m,G,Rt[h],S[h]),A=s.add5H(I,K,E,v,Gt[h],w[h]),B=I|0,R=s.rotrSH(n,i,28)^s.rotrBH(n,i,34)^s.rotrBH(n,i,39),H=s.rotrSL(n,i,28)^s.rotrBL(n,i,34)^s.rotrBL(n,i,39),M=n&c^n&f^c&f,ct=i&o^i&d^o&d;K=p|0,L=y|0,p=b|0,y=g|0,b=a|0,g=l|0,{h:a,l}=s.add(x|0,u|0,A|0,B|0),x=f|0,u=d|0,f=c|0,d=o|0,c=n|0,o=i|0;let J=s.add3L(B,H,ct);n=s.add3H(J,A,R,M),i=J|0}({h:n,l:i}=s.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:c,l:o}=s.add(this.Bh|0,this.Bl|0,c|0,o|0),{h:f,l:d}=s.add(this.Ch|0,this.Cl|0,f|0,d|0),{h:x,l:u}=s.add(this.Dh|0,this.Dl|0,x|0,u|0),{h:a,l}=s.add(this.Eh|0,this.El|0,a|0,l|0),{h:b,l:g}=s.add(this.Fh|0,this.Fl|0,b|0,g|0),{h:p,l:y}=s.add(this.Gh|0,this.Gl|0,p|0,y|0),{h:K,l:L}=s.add(this.Hh|0,this.Hl|0,K|0,L|0),this.set(n,i,c,o,f,d,x,u,a,l,b,g,p,y,K,L)}roundClean(){w.fill(0),S.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var st=nt(()=>new j);import q from"bs58";function ot(e,t){if(Mt(e))return{isValid:!1,message:"Old API key format detected. Please create a new API key from the Crossmint console."};let r=$t(e);if(r==null)return{isValid:!1,message:`Malformed API key. Must start with '${O.CLIENT}' or '${O.SERVER}'.`};if((t==null?void 0:t.usageOrigin)!=null&&r!==t.usageOrigin)return{isValid:!1,message:`Disallowed API key. You passed a ${r} API key, but a ${t.usageOrigin} API key is required.`};let n=Ft(e);return n==null?{isValid:!1,message:`Malformed API key. Must have a valid environment: '${P.DEVELOPMENT}', '${P.STAGING}' or '${P.PRODUCTION}'.`}:(t==null?void 0:t.environment)!=null&&n!==t.environment?{isValid:!1,message:`Disallowed API key. You passed a ${n} API key, but a ${t.environment} API key is required.`}:{isValid:!0,usageOrigin:r,environment:n,prefix:`${tt(r)}_${n}`}}function Mt(e){return e.startsWith("sk_live")||e.startsWith("sk_test")}function $t(e){return e.startsWith(O.CLIENT+"_")?$.CLIENT:e.startsWith(O.SERVER+"_")?$.SERVER:null}function Ft(e){let t=e.slice(3);return t.startsWith(P.DEVELOPMENT+"_")?P.DEVELOPMENT:t.startsWith(P.STAGING+"_")?P.STAGING:t.startsWith(P.PRODUCTION+"_")?P.PRODUCTION:null}_.etc.sha512Sync=(...e)=>st(_.etc.concatBytes(...e));function me(e,t){let r=ot(e,t);if(!r.isValid)return r;let{prefix:n}=r,{keyData:i,keyDataWithoutPrefix:c,signature:o}=Wt(e,n);if(!Yt(i,o,t))return{isValid:!1,message:"Invalid API key. Failed to validate signature"};let[d]=c.split(".");return Q(z({},r),{projectId:d})}function Wt(e,t){let r=e.slice(`${t}_`.length),n=q.decode(r),i=new TextDecoder().decode(n),[c,o]=i.split(":");return{keyData:`${t}.${c}`,keyDataWithoutPrefix:c,signature:o}}function Yt(e,t,r){let n=et(r==null?void 0:r.environment);function i(c){try{return _.verify(q.decode(t),new TextEncoder().encode(e),q.decode(c))}catch(o){return console.error("Failed to validate API key signature",o),!1}}return n!=null?i(n):i(N)||i(C)}export{P as APIKeyEnvironmentPrefix,$ as APIKeyUsageOrigin,O as APIKeyUsageOriginPrefix,N as CROSSMINT_API_KEY_SIGNER_PUBLICKEY_PROD,C as CROSSMINT_API_KEY_SIGNER_PUBLICKEY_STAGING,et as environmentToExpectedPublicKey,tt as usageOriginToPrefix,me as validateAPIKey,ot as validateAPIKeyPrefix};
/*! Bundled license information:
@noble/hashes/esm/utils.js:
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
*/
var T=Object.defineProperty,O=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var u=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var d=(t,e,r)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,A=(t,e)=>{for(var r in e||(e={}))S.call(e,r)&&d(t,r,e[r]);if(u)for(var r of u(e))C.call(e,r)&&d(t,r,e[r]);return t},p=(t,e)=>O(t,_(e));var l="3hSfN4dWSwgCg1uf2yytBtK6KxK3ySFKasd2h9J2vSK5",I="8erZh8YApGck3iUSUHqATBxqMTM1Ukp9mHmvGgUWHtkK";function E(t){return t==="client"?"ck":"sk"}function m(t){switch(t){case"development":case"staging":return l;case"production":return I;default:return null}}var P={CLIENT:"ck",SERVER:"sk"},n={DEVELOPMENT:"development",STAGING:"staging",PRODUCTION:"production"},g={CLIENT:"client",SERVER:"server"};import y from"bs58";import U from"tweetnacl";function x(t,e){if(V(t))return{isValid:!1,message:"Old API key format detected. Please create a new API key from the Crossmint console."};let r=k(t);if(r==null)return{isValid:!1,message:`Malformed API key. Must start with '${P.CLIENT}' or '${P.SERVER}'.`};if((e==null?void 0:e.usageOrigin)!=null&&r!==e.usageOrigin)return{isValid:!1,message:`Disallowed API key. You passed a ${r} API key, but a ${e.usageOrigin} API key is required.`};let i=v(t);return i==null?{isValid:!1,message:`Malformed API key. Must have a valid environment: '${n.DEVELOPMENT}', '${n.STAGING}' or '${n.PRODUCTION}'.`}:(e==null?void 0:e.environment)!=null&&i!==e.environment?{isValid:!1,message:`Disallowed API key. You passed a ${i} API key, but a ${e.environment} API key is required.`}:{isValid:!0,usageOrigin:r,environment:i,prefix:`${E(r)}_${i}`}}function V(t){return t.startsWith("sk_live")||t.startsWith("sk_test")}function k(t){return t.startsWith(P.CLIENT+"_")?g.CLIENT:t.startsWith(P.SERVER+"_")?g.SERVER:null}function v(t){let e=t.slice(3);return e.startsWith(n.DEVELOPMENT+"_")?n.DEVELOPMENT:e.startsWith(n.STAGING+"_")?n.STAGING:e.startsWith(n.PRODUCTION+"_")?n.PRODUCTION:null}function Q(t,e){let r=x(t,e);if(!r.isValid)return r;let{prefix:i}=r,{keyData:o,keyDataWithoutPrefix:s,signature:a}=h(t,i);if(!L(o,a,e))return{isValid:!1,message:"Invalid API key. Failed to validate signature"};let[f]=s.split(".");return p(A({},r),{projectId:f})}function h(t,e){let r=t.slice(`${e}_`.length),i=y.decode(r),o=new TextDecoder().decode(i),[s,a]=o.split(":");return{keyData:`${e}.${s}`,keyDataWithoutPrefix:s,signature:a}}function L(t,e,r){let i=m(r==null?void 0:r.environment);function o(s){try{let a=y.decode(e),c=new TextEncoder().encode(t),f=y.decode(s);return U.sign.detached.verify(c,a,f)}catch(a){return console.error("Failed to validate API key signature",a),!1}}return i!=null?o(i):o(I)||o(l)}var K=["ethereum","ethereum-sepolia","polygon","bsc","optimism","arbitrum","base","zora","arbitrumnova","zkatana"],N=["goerli","ethereum-sepolia","mumbai","zkatana"],R=["solana","cardano","sui",...K],te=[...K,...N],re=[...R,...N];export{R as ALL_CHAINS,n as APIKeyEnvironmentPrefix,g as APIKeyUsageOrigin,P as APIKeyUsageOriginPrefix,re as BLOCKCHAIN_INCLUDING_TESTNET,N as BLOCKCHAIN_TEST_NET,I as CROSSMINT_API_KEY_SIGNER_PUBLICKEY_PROD,l as CROSSMINT_API_KEY_SIGNER_PUBLICKEY_STAGING,te as EVM_BLOCKCHAIN_INCLUDING_TESTNET,K as EVM_CHAINS,m as environmentToExpectedPublicKey,E as usageOriginToPrefix,Q as validateAPIKey,x as validateAPIKeyPrefix};
//# sourceMappingURL=index.js.map
{
"name": "@crossmint/common-sdk-base",
"version": "0.0.2",
"author": "Paella Labs Inc",
"license": "Apache-2.0",
"repository": "https://github.com/Crossmint/crossmint-sdk",
"type": "module",
"sideEffects": false,
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
"bs58": "5.0.0",
"tweetnacl": "1.0.3"
},
"devDependencies": {
"@types/bs58": "^4.0.4"
},
"exports": {

@@ -21,15 +19,20 @@ "import": "./dist/index.js",

],
"license": "Apache-2.0",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"name": "@crossmint/common-sdk-base",
"publishConfig": {
"access": "public"
},
"repository": "https://github.com/Crossmint/crossmint-sdk",
"scripts": {
"build": "yarn clean && tsup src/index.ts --format esm,cjs --outDir ./dist --minify --dts --sourcemap",
"clean": "shx rm -rf dist/*",
"build": "yarn clean && tsup src/index.ts --format esm,cjs --outDir ./dist --minify --dts --sourcemap",
"test": "vitest"
"test": "vitest run"
},
"dependencies": {
"@noble/ed25519": "2.0.0",
"bs58": "5.0.0"
},
"gitHead": "5fcade2a59e449e3fcdcd176595b1ff08c7e1884"
"sideEffects": false,
"type": "module",
"types": "./dist/index.d.ts",
"version": "0.0.3",
"gitHead": "99beae8a7aafd75edb5ad77eaaf1cc0d632063b3"
}

@@ -0,1 +1,3 @@

export * from "./blockchain";
export * from "./uiconfig";
export * from "./UserIdentifier";

@@ -1,7 +0,7 @@

import * as ed from "@noble/ed25519";
import { sha512 } from "@noble/hashes/sha512";
import base58 from "bs58";
import nacl from "tweetnacl";
import { CROSSMINT_API_KEY_SIGNER_PUBLICKEY_PROD, CROSSMINT_API_KEY_SIGNER_PUBLICKEY_STAGING } from "./consts";
import { APIKeyPrefix } from "./types";
import { environmentToExpectedPublicKey } from "./utils";
import {

@@ -12,7 +12,3 @@ ValidateAPIKeyPrefixExpectations,

} from "./validateAPIKeyPrefix";
import { environmentToExpectedPublicKey } from "./utils";
// Need to shim for methods to work https://www.npmjs.com/package/@noble/ed25519
ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m));
export type ValidateAPIKeyResult =

@@ -70,12 +66,16 @@ | ({

function validateAPIKeySignature(keyData: string, signature: string, expectations?:ValidateAPIKeyPrefixExpectations): boolean {
function validateAPIKeySignature(
keyData: string,
signature: string,
expectations?: ValidateAPIKeyPrefixExpectations
): boolean {
const expectedPublicKey = environmentToExpectedPublicKey(expectations?.environment);
function _validateSignature(expectedPublicKey:string) {
function _validateSignature(expectedPublicKey: string) {
try {
return ed.verify(
base58.decode(signature),
new TextEncoder().encode(keyData),
base58.decode(expectedPublicKey)
);
const signatureBytes = base58.decode(signature);
const keyDataBytes = new TextEncoder().encode(keyData);
const publicKeyBytes = base58.decode(expectedPublicKey);
return nacl.sign.detached.verify(keyDataBytes, signatureBytes, publicKeyBytes);
} catch (e) {

@@ -87,6 +87,9 @@ console.error("Failed to validate API key signature", e);

if(expectedPublicKey != null) {
if (expectedPublicKey != null) {
return _validateSignature(expectedPublicKey);
}
return _validateSignature(CROSSMINT_API_KEY_SIGNER_PUBLICKEY_PROD) || _validateSignature(CROSSMINT_API_KEY_SIGNER_PUBLICKEY_STAGING);
return (
_validateSignature(CROSSMINT_API_KEY_SIGNER_PUBLICKEY_PROD) ||
_validateSignature(CROSSMINT_API_KEY_SIGNER_PUBLICKEY_STAGING)
);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc