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

@futureverse/asset-registry

Package Overview
Dependencies
Maintainers
15
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@futureverse/asset-registry - npm Package Compare versions

Comparing version 2.9.0 to 2.10.0

2

index.js

@@ -492,2 +492,2 @@ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-028d3a8b.js"),ne=require("io-ts"),a=require("graphql-tag"),oe=require("jsonld"),re=require("graphql-request");require("io-ts/Codec");require("io-ts/Decoder");const g=require("siwe"),k=require("fp-ts/lib/Either");require("io-ts/Encoder");require("fp-ts/function");require("validate-iri");require("iri");require("@fp-ts/schema");require("@fp-ts/data");require("ethers");require("@fp-ts/core/Function");function ae(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const o=ae(ne);var C=(r=>(r.Erc721="ERC721",r.Erc1155="ERC1155",r))(C||{});const G=a`

}
`,ie=(r,e,t)=>r();function Y(r,e=ie){return{assetMutation(t,s){return e(n=>r.request(G,t,{...s,...n}),"assetMutation","mutation")},RegisterCollection(t,s){return e(n=>r.request(D,t,{...s,...n}),"RegisterCollection","mutation")},CreateNamespace(t,s){return e(n=>r.request(T,t,{...s,...n}),"CreateNamespace","mutation")},RegisterOffChainAsset(t,s){return e(n=>r.request($,t,{...s,...n}),"RegisterOffChainAsset","mutation")},CreateSchema(t,s){return e(n=>r.request(E,t,{...s,...n}),"CreateSchema","mutation")},SubmitMutation(t,s){return e(n=>r.request(w,t,{...s,...n}),"SubmitMutation","mutation")},RegisterTokenSchema(t,s){return e(n=>r.request(q,t,{...s,...n}),"RegisterTokenSchema","mutation")},CreateWebhookEndpoint(t,s){return e(n=>r.request(N,t,{...s,...n}),"CreateWebhookEndpoint","mutation")},UpdateWebhookEndpoint(t,s){return e(n=>r.request(W,t,{...s,...n}),"UpdateWebhookEndpoint","mutation")},DeleteWebhookEndpoint(t,s){return e(n=>r.request(O,t,{...s,...n}),"DeleteWebhookEndpoint","mutation")},CreateWebhookSubscription(t,s){return e(n=>r.request(R,t,{...s,...n}),"CreateWebhookSubscription","mutation")},DeleteWebhookSubscription(t,s){return e(n=>r.request(_,t,{...s,...n}),"DeleteWebhookSubscription","mutation")},GetAsset(t,s){return e(n=>r.request(v,t,{...s,...n}),"GetAsset","query")},GetAssetTree(t,s){return e(n=>r.request(F,t,{...s,...n}),"GetAssetTree","query")},GetAssets(t,s){return e(n=>r.request(M,t,{...s,...n}),"GetAssets","query")},GetDomains(t,s){return e(n=>r.request(x,t,{...s,...n}),"GetDomains","query")},GetNamespacesAndSchemas(t,s){return e(n=>r.request(P,t,{...s,...n}),"GetNamespacesAndSchemas","query")},GetNamespaces(t,s){return e(n=>r.request(j,t,{...s,...n}),"GetNamespaces","query")},GetNamespace(t,s){return e(n=>r.request(z,t,{...s,...n}),"GetNamespace","query")},GetNonceForChainAddress(t,s){return e(n=>r.request(H,t,{...s,...n}),"GetNonceForChainAddress","query")},GetOffChainAssets(t,s){return e(n=>r.request(U,t,{...s,...n}),"GetOffChainAssets","query")},GetTokenSchemas(t,s){return e(n=>r.request(K,t,{...s,...n}),"GetTokenSchemas","query")},GetTokenSchema(t,s){return e(n=>r.request(L,t,{...s,...n}),"GetTokenSchema","query")},GetTransaction(t,s){return e(n=>r.request(V,t,{...s,...n}),"GetTransaction","query")},GetWebhookEndpoints(t,s){return e(n=>r.request(B,t,{...s,...n}),"GetWebhookEndpoints","query")},GetWebhookEndpoint(t,s){return e(n=>r.request(J,t,{...s,...n}),"GetWebhookEndpoint","query")},GetWebhookSubscriptions(t,s){return e(n=>r.request(Q,t,{...s,...n}),"GetWebhookSubscriptions","query")},GetWebhookSubscription(t,s){return e(n=>r.request(X,t,{...s,...n}),"GetWebhookSubscription","query")}}}const ce=o.unknown;function ue(){return o.type({signature:c.Signature,transaction:c.AssetTransactionMessage})}function Z(){return o.type({chainId:c.ChainIdT,chainType:c.ChainTypeT,location:c.CollectionLocation})}function de(){return o.type({collection:Z(),tokenId:o.string})}const he=o.keyof({ERC721:null,ERC1155:null});function pe(){return o.type({collectionId:c.CollectionId,schemaIdentifier:c.SchemaIdentifier})}function me(){return o.type({domain:o.string,suffix:o.string})}function le(){return o.type({name:o.string,namespace:c.Namespace,schema:o.string,version:o.number})}function be(){return o.intersection([o.type({url:o.string}),o.partial({retries:o.union([o.null,o.number])})])}function ke(){return o.type({actions:o.array(o.string),collectionId:c.CollectionId,type:o.string,webhookId:o.string})}function Se(){return o.type({webhookId:o.string})}function fe(){return o.type({subscriptionId:o.string,webhookId:o.string})}function ge(){return o.type({transactionHash:c.TransactionHash})}function Ie(){return o.type({chainAddress:c.ChainAddress})}function ye(){return o.type({creatorId:o.string})}function Ae(){return o.intersection([o.type({creatorCollectionId:o.string,creatorId:o.string}),o.partial({tokenId:o.union([o.null,o.string])})])}function Ce(){return o.intersection([o.type({collectionId:c.CollectionId,schemaId:c.SchemaIdentifier}),o.partial({tokenId:o.union([o.null,o.string])})])}function Ge(){return o.intersection([o.type({signature:c.Signature,transaction:c.AssetTransactionMessage}),o.partial({check:o.union([o.null,o.boolean])})])}function De(){return o.intersection([o.type({webhookId:o.string}),o.partial({retries:o.union([o.null,o.number]),url:o.union([o.null,o.string])})])}class f{constructor(e,t,s,n){const i=t.schema;this.client=e,this.raw=t,this.schema=i?.schema,this.pathAssetObjects=n,this.pathAssetIds=s,this.pathAssetTrees={}}static async init(e,t){const s=t.assetTree,{pathAssetIds:n,pathAssetObjects:i}=await this.parse(s.data,s.nodeId);return new f(e,t,n,i)}get paths(){return Object.keys(this.pathAssetIds)}async getPath(e){if(this.paths.includes(e)&&!this.pathAssetTrees[e]){const t=this.pathAssetIds[e];if(t.indexOf(":off-chain:")>=0)this.pathAssetTrees[e]=this.pathAssetObjects[e];else{const[s,n,i,u,h,p]=t.split(":"),d=`${i}:${u}:${h}`,b=await this.client.getAssetTree({collectionId:d,tokenId:p});b&&(this.pathAssetTrees[e]=b)}}return this.pathAssetTrees[e]||null}static async parse(e,t){const s=typeof e=="object"?e:JSON.parse(e),n=await oe.flatten(s),i={},u={};if(Array.isArray(n)){const h=n.filter(d=>d["@id"]===t)[0],p=new Set(["@id","http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]);for(const d in h)p.has(d)||(i[d]=h[d][0]["@id"],u[d]=n.filter(b=>b["@id"]===i[d])[0])}return{pathAssetIds:i,pathAssetObjects:u}}}const Te=r=>Buffer.from(r).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""),I=r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";return Buffer.from(e||"","base64").toString()},m=(r,...e)=>{const t={};let s;for(s in r)e.includes(s)||(t[s]=r[s]);return t},S=Symbol("memoizedResult"),y=Symbol("timeoutId");function ee(r){return function(e,t,s){const n=s.value;return s.value=function(...i){if(this[S]!==void 0)return this[S];const u=n.apply(this,i);return this[S]=u,clearTimeout(this[y]),this[y]=setTimeout(()=>{this[S]=void 0},r),u},s}}class $e extends Error{constructor(e,t,s){super(),this.name=e,this.message=t,this.cause=s}}class l extends $e{constructor(e,t){super("ARError",e,t)}}const Ee=["RegisterOffChainAsset","CreateSchema","GetNamespacesAndSchemas","GetNamespaces","GetDomains","CreateNamespace","RegisterTokenSchema","CreateWebhookEndpoint","UpdateWebhookEndpoint","DeleteWebhookEndpoint","CreateWebhookSubscription","DeleteWebhookSubscription","GetWebhookEndpoints","GetWebhookSubscriptions"],A="AR-Auth-Token",we="2.8.0";var qe=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,We=(r,e,t,s)=>{for(var n=s>1?void 0:s?Ne(e,t):e,i=r.length-1,u;i>=0;i--)(u=r[i])&&(n=(s?u(e,t,n):u(n))||n);return s&&n&&qe(e,t,n),n};const te=we;class se{constructor(e){this.auth=e.auth;const t=new re.GraphQLClient(e.url,{headers:{"Content-Type":"application/json","FVAR-Client":"core-sdk","FVAR-Client-Version":te}}),s=async(n,i,u)=>{const h=Date.now(),p=Ee.includes(i)?await this.getAuthorizationHeader():void 0,d=await n(p);return process.env.NODE_ENV==="development"&&(console.log("request duration (ms)",Date.now()-h),console.log("request result",d)),d};this.sdk=Y(t,s)}setAuthorizationParameters(e){this.auth=e}async transaction(e){return(await this.sdk.GetTransaction(e)).transaction}async nonceForChainAddress(e){return(await this.sdk.GetNonceForChainAddress({input:{chainAddress:e}})).getNonceForChainAddress}async asset(e){const t=await this.sdk.GetAsset(e);return t.asset?m(t.asset,"__typename"):null}async getAssetTree(e){const t=await this.sdk.GetAsset(e);return t.asset?await f.init(this,t.asset):null}async assetTree(e){return(await this.sdk.GetAssetTree({tokenId:e.tokenId,collectionId:[e.collection.chainId.toString(),e.collection.chainType,e.collection.location].join(":")})).asset?.assetTree}async assets(e){return(await this.sdk.GetAssets(e)).assets}async createSchema(e){const t=await this.sdk.CreateSchema({input:e});if(t.createSchema.__typename==="CreateSchemaSuccess")return m(t.createSchema,"__typename");throw new l(t.createSchema.errors[0]?.message)}async registerOffChainAsset(e){const t=await this.sdk.RegisterOffChainAsset({input:e});if(t.registerOffChainAsset.__typename==="RegisterOffChainAssetSuccess")return m(t.registerOffChainAsset.offChainAsset,"__typename");throw new l(t.registerOffChainAsset.errors[0]?.message)}async registerTokenSchema(e){return(await this.sdk.RegisterTokenSchema({input:e})).registerTokenSchema.tokenSchema}async submitTransaction(e){const t=await this.sdk.SubmitMutation({input:e});return m(t.submitTransaction,"__typename")}async domains(e){return(await this.sdk.GetDomains(e)).domains.edges.map(({node:n})=>n)}async createNamespace(e){return(await this.sdk.CreateNamespace({input:e})).createNamespace?.namespace}async getNamespacesAndSchemas(e){return(await this.sdk.GetNamespacesAndSchemas(e)).namespaces.edges.map(({node:n})=>({...n,schemas:n.schemas.edges.map(({node:i})=>i)}))}async getNamespaces(e){return(await this.sdk.GetNamespaces(e)).namespaces}async getNamespace(e){const t=await this.sdk.GetNamespace(e);if(t.namespace)return{...t.namespace,schemas:t.namespace.schemas.edges.map(({node:s})=>s)}}async getOffChainAssets(e){return(await this.sdk.GetOffChainAssets(e)).offChainAssets}async getDomains(e){return(await this.sdk.GetDomains(e)).domains}async getTokenSchemas(e){return(await this.sdk.GetTokenSchemas(e)).tokenSchemas}async getTokenSchema(e){return(await this.sdk.GetTokenSchema(e)).tokenSchema}async getWebhookEndpoints(e){return(await this.sdk.GetWebhookEndpoints(e)).webhookEndpoints}async getWebhookEndpoint(e){return(await this.sdk.GetWebhookEndpoint(e)).webhookEndpoint}async getWebhookSubscriptions(e){return(await this.sdk.GetWebhookSubscriptions(e)).webhookSubscriptions}async getWebhookSubscription(e){return(await this.sdk.GetWebhookSubscription(e)).webhookSubscription}async createWebhookEndpoint(e){return(await this.sdk.CreateWebhookEndpoint({input:e})).createWebhookEndpoint.webhookEndpoint}async deleteWebhookEndpoint(e){return(await this.sdk.DeleteWebhookEndpoint({input:e})).deleteWebhookEndpoint.success}async updateWebhookEndpoint(e){return(await this.sdk.UpdateWebhookEndpoint({input:e})).updateWebhookEndpoint.webhookEndpoint}async createWebhookSubscription(e){return(await this.sdk.CreateWebhookSubscription({input:e})).createWebhookSubscription.webhookSubscription}async deleteWebhookSubscription(e){return(await this.sdk.DeleteWebhookSubscription({input:e})).deleteWebhookSubscription.success}async getAuthorizationHeader(){if(!this.auth)throw new Error("Please set AuthorizationParameters to use this functionality.");let e=this.auth.storage.get(A);if(e){const t=await this.validateToken(e);if(k.isRight(t))return{Authorization:e}}return e=await this.authenticate(),this.auth.storage.set(A,e),{Authorization:e}}async authenticate(){if(!this.auth)throw new Error("Please set AuthorizationParameters to use this functionality.");const e=new Date;e.setDate(e.getDate()+1);const s=new g.SiweMessage({domain:this.auth.domain,address:this.auth.walletAddress,statement:"",uri:this.auth.origin,version:"1",chainId:this.auth.chainId,nonce:g.generateNonce(),expirationTime:e.toISOString()}).prepareMessage(),n=await this.auth.sign(s);return`${btoa(s)}.${btoa(n)}`}async validateToken(e){try{const[t,s]=e.split("."),n=I(t),i=I(s),u=new g.SiweMessage(n),{data:h}=await u.verify({signature:i});if(h.expirationTime){const p=new Date(h.expirationTime);if(p.setSeconds(p.getSeconds()-60),p<new Date)return k.left(new l("Token expired"))}return k.right(h)}catch(t){return console.error("Error occurred:",t),k.left(new l("Invalid signature"))}}}We([ee(1e3)],se.prototype,"getAuthorizationHeader",1);exports.codecFromEnum=c.codecFromEnum;exports.ARError=l;exports.AssetMutationDocument=G;exports.AssetMutationInputSchema=ue;exports.AssetRegistry=se;exports.AssetTreeClass=f;exports.AssetTreeCollectionInputSchema=Z;exports.AssetTreeInputSchema=de;exports.AssetType=C;exports.AssetTypeSchema=he;exports.CollectionInputSchema=pe;exports.CreateNamespaceDocument=T;exports.CreateNamespaceInputSchema=me;exports.CreateSchemaDocument=E;exports.CreateSchemaInputSchema=le;exports.CreateWebhookEndpointDocument=N;exports.CreateWebhookEndpointInputSchema=be;exports.CreateWebhookSubscriptionDocument=R;exports.CreateWebhookSubscriptionInputSchema=ke;exports.DeleteWebhookEndpointDocument=O;exports.DeleteWebhookEndpointInputSchema=Se;exports.DeleteWebhookSubscriptionDocument=_;exports.DeleteWebhookSubscriptionInputSchema=fe;exports.GetAssetDocument=v;exports.GetAssetTreeDocument=F;exports.GetAssetsDocument=M;exports.GetDomainsDocument=x;exports.GetNamespaceDocument=z;exports.GetNamespacesAndSchemasDocument=P;exports.GetNamespacesDocument=j;exports.GetNonceForChainAddressDocument=H;exports.GetOffChainAssetsDocument=U;exports.GetTokenSchemaDocument=L;exports.GetTokenSchemasDocument=K;exports.GetTransactionDocument=V;exports.GetTransactionInputSchema=ge;exports.GetWebhookEndpointDocument=J;exports.GetWebhookEndpointsDocument=B;exports.GetWebhookSubscriptionDocument=X;exports.GetWebhookSubscriptionsDocument=Q;exports.NonceInputSchema=Ie;exports.OffChainAssetsInputSchema=ye;exports.RegisterCollectionDocument=D;exports.RegisterOffChainAssetDocument=$;exports.RegisterOffChainAssetInputSchema=Ae;exports.RegisterTokenSchemaDocument=q;exports.RegisterTokenSchemaInputSchema=Ce;exports.SDK_VERSION=te;exports.SubmitMutationDocument=w;exports.SubmitTransactionInputSchema=Ge;exports.UpdateWebhookEndpointDocument=W;exports.UpdateWebhookEndpointInputSchema=De;exports.base64Decode=I;exports.base64Encode=Te;exports.definedNonNullAnySchema=ce;exports.getSdk=Y;exports.memorize=ee;exports.omit=m;
`,ie=(r,e,t)=>r();function Y(r,e=ie){return{assetMutation(t,s){return e(n=>r.request(G,t,{...s,...n}),"assetMutation","mutation")},RegisterCollection(t,s){return e(n=>r.request(D,t,{...s,...n}),"RegisterCollection","mutation")},CreateNamespace(t,s){return e(n=>r.request(T,t,{...s,...n}),"CreateNamespace","mutation")},RegisterOffChainAsset(t,s){return e(n=>r.request($,t,{...s,...n}),"RegisterOffChainAsset","mutation")},CreateSchema(t,s){return e(n=>r.request(E,t,{...s,...n}),"CreateSchema","mutation")},SubmitMutation(t,s){return e(n=>r.request(w,t,{...s,...n}),"SubmitMutation","mutation")},RegisterTokenSchema(t,s){return e(n=>r.request(q,t,{...s,...n}),"RegisterTokenSchema","mutation")},CreateWebhookEndpoint(t,s){return e(n=>r.request(N,t,{...s,...n}),"CreateWebhookEndpoint","mutation")},UpdateWebhookEndpoint(t,s){return e(n=>r.request(W,t,{...s,...n}),"UpdateWebhookEndpoint","mutation")},DeleteWebhookEndpoint(t,s){return e(n=>r.request(O,t,{...s,...n}),"DeleteWebhookEndpoint","mutation")},CreateWebhookSubscription(t,s){return e(n=>r.request(R,t,{...s,...n}),"CreateWebhookSubscription","mutation")},DeleteWebhookSubscription(t,s){return e(n=>r.request(_,t,{...s,...n}),"DeleteWebhookSubscription","mutation")},GetAsset(t,s){return e(n=>r.request(v,t,{...s,...n}),"GetAsset","query")},GetAssetTree(t,s){return e(n=>r.request(F,t,{...s,...n}),"GetAssetTree","query")},GetAssets(t,s){return e(n=>r.request(M,t,{...s,...n}),"GetAssets","query")},GetDomains(t,s){return e(n=>r.request(x,t,{...s,...n}),"GetDomains","query")},GetNamespacesAndSchemas(t,s){return e(n=>r.request(P,t,{...s,...n}),"GetNamespacesAndSchemas","query")},GetNamespaces(t,s){return e(n=>r.request(j,t,{...s,...n}),"GetNamespaces","query")},GetNamespace(t,s){return e(n=>r.request(z,t,{...s,...n}),"GetNamespace","query")},GetNonceForChainAddress(t,s){return e(n=>r.request(H,t,{...s,...n}),"GetNonceForChainAddress","query")},GetOffChainAssets(t,s){return e(n=>r.request(U,t,{...s,...n}),"GetOffChainAssets","query")},GetTokenSchemas(t,s){return e(n=>r.request(K,t,{...s,...n}),"GetTokenSchemas","query")},GetTokenSchema(t,s){return e(n=>r.request(L,t,{...s,...n}),"GetTokenSchema","query")},GetTransaction(t,s){return e(n=>r.request(V,t,{...s,...n}),"GetTransaction","query")},GetWebhookEndpoints(t,s){return e(n=>r.request(B,t,{...s,...n}),"GetWebhookEndpoints","query")},GetWebhookEndpoint(t,s){return e(n=>r.request(J,t,{...s,...n}),"GetWebhookEndpoint","query")},GetWebhookSubscriptions(t,s){return e(n=>r.request(Q,t,{...s,...n}),"GetWebhookSubscriptions","query")},GetWebhookSubscription(t,s){return e(n=>r.request(X,t,{...s,...n}),"GetWebhookSubscription","query")}}}const ce=o.unknown;function ue(){return o.type({signature:c.Signature,transaction:c.AssetTransactionMessage})}function Z(){return o.type({chainId:c.ChainIdT,chainType:c.ChainTypeT,location:c.CollectionLocation})}function de(){return o.type({collection:Z(),tokenId:o.string})}const he=o.keyof({ERC721:null,ERC1155:null});function pe(){return o.type({collectionId:c.CollectionId,schemaIdentifier:c.SchemaIdentifier})}function me(){return o.type({domain:o.string,suffix:o.string})}function le(){return o.type({name:o.string,namespace:c.Namespace,schema:o.string,version:o.number})}function be(){return o.intersection([o.type({url:o.string}),o.partial({retries:o.union([o.null,o.number])})])}function ke(){return o.type({actions:o.array(o.string),collectionId:c.CollectionId,type:o.string,webhookId:o.string})}function Se(){return o.type({webhookId:o.string})}function fe(){return o.type({subscriptionId:o.string,webhookId:o.string})}function ge(){return o.type({transactionHash:c.TransactionHash})}function Ie(){return o.type({chainAddress:c.ChainAddress})}function ye(){return o.type({creatorId:o.string})}function Ae(){return o.intersection([o.type({creatorCollectionId:o.string,creatorId:o.string}),o.partial({tokenId:o.union([o.null,o.string])})])}function Ce(){return o.intersection([o.type({collectionId:c.CollectionId,schemaId:c.SchemaIdentifier}),o.partial({tokenId:o.union([o.null,o.string])})])}function Ge(){return o.intersection([o.type({signature:c.Signature,transaction:c.AssetTransactionMessage}),o.partial({check:o.union([o.null,o.boolean])})])}function De(){return o.intersection([o.type({webhookId:o.string}),o.partial({retries:o.union([o.null,o.number]),url:o.union([o.null,o.string])})])}class f{constructor(e,t,s,n){const i=t.schema;this.client=e,this.raw=t,this.schema=i?.schema,this.pathAssetObjects=n,this.pathAssetIds=s,this.pathAssetTrees={}}static async init(e,t){const s=t.assetTree,{pathAssetIds:n,pathAssetObjects:i}=await this.parse(s.data,s.nodeId);return new f(e,t,n,i)}get paths(){return Object.keys(this.pathAssetIds)}async getPath(e){if(this.paths.includes(e)&&!this.pathAssetTrees[e]){const t=this.pathAssetIds[e];if(t.indexOf(":off-chain:")>=0)this.pathAssetTrees[e]=this.pathAssetObjects[e];else{const[s,n,i,u,h,p]=t.split(":"),d=`${i}:${u}:${h}`,b=await this.client.getAssetTree({collectionId:d,tokenId:p});b&&(this.pathAssetTrees[e]=b)}}return this.pathAssetTrees[e]||null}static async parse(e,t){const s=typeof e=="object"?e:JSON.parse(e),n=await oe.flatten(s),i={},u={};if(Array.isArray(n)){const h=n.filter(d=>d["@id"]===t)[0],p=new Set(["@id","http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]);for(const d in h)p.has(d)||(i[d]=h[d][0]["@id"],u[d]=n.filter(b=>b["@id"]===i[d])[0])}return{pathAssetIds:i,pathAssetObjects:u}}}const Te=r=>Buffer.from(r).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""),I=r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";return Buffer.from(e||"","base64").toString()},m=(r,...e)=>{const t={};let s;for(s in r)e.includes(s)||(t[s]=r[s]);return t},S=Symbol("memoizedResult"),y=Symbol("timeoutId");function ee(r){return function(e,t,s){const n=s.value;return s.value=function(...i){if(this[S]!==void 0)return this[S];const u=n.apply(this,i);return this[S]=u,clearTimeout(this[y]),this[y]=setTimeout(()=>{this[S]=void 0},r),u},s}}class $e extends Error{constructor(e,t,s){super(),this.name=e,this.message=t,this.cause=s}}class l extends $e{constructor(e,t){super("ARError",e,t)}}const Ee=["RegisterOffChainAsset","CreateSchema","GetNamespacesAndSchemas","GetNamespaces","GetDomains","CreateNamespace","RegisterTokenSchema","CreateWebhookEndpoint","UpdateWebhookEndpoint","DeleteWebhookEndpoint","CreateWebhookSubscription","DeleteWebhookSubscription","GetWebhookEndpoints","GetWebhookSubscriptions"],A="AR-Auth-Token",we="2.9.0";var qe=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,We=(r,e,t,s)=>{for(var n=s>1?void 0:s?Ne(e,t):e,i=r.length-1,u;i>=0;i--)(u=r[i])&&(n=(s?u(e,t,n):u(n))||n);return s&&n&&qe(e,t,n),n};const te=we;class se{constructor(e){this.auth=e.auth;const t=new re.GraphQLClient(e.url,{headers:{"Content-Type":"application/json","FVAR-Client":"core-sdk","FVAR-Client-Version":te}}),s=async(n,i,u)=>{const h=Date.now(),p=Ee.includes(i)?await this.getAuthorizationHeader():void 0,d=await n(p);return process.env.NODE_ENV==="development"&&(console.log("request duration (ms)",Date.now()-h),console.log("request result",d)),d};this.sdk=Y(t,s)}setAuthorizationParameters(e){this.auth=e}async transaction(e){return(await this.sdk.GetTransaction(e)).transaction}async nonceForChainAddress(e){return(await this.sdk.GetNonceForChainAddress({input:{chainAddress:e}})).getNonceForChainAddress}async asset(e){const t=await this.sdk.GetAsset(e);return t.asset?m(t.asset,"__typename"):null}async getAssetTree(e){const t=await this.sdk.GetAsset(e);return t.asset?await f.init(this,t.asset):null}async assetTree(e){return(await this.sdk.GetAssetTree({tokenId:e.tokenId,collectionId:[e.collection.chainId.toString(),e.collection.chainType,e.collection.location].join(":")})).asset?.assetTree}async assets(e){return(await this.sdk.GetAssets(e)).assets}async createSchema(e){const t=await this.sdk.CreateSchema({input:e});if(t.createSchema.__typename==="CreateSchemaSuccess")return m(t.createSchema,"__typename");throw new l(t.createSchema.errors[0]?.message)}async registerOffChainAsset(e){const t=await this.sdk.RegisterOffChainAsset({input:e});if(t.registerOffChainAsset.__typename==="RegisterOffChainAssetSuccess")return m(t.registerOffChainAsset.offChainAsset,"__typename");throw new l(t.registerOffChainAsset.errors[0]?.message)}async registerTokenSchema(e){return(await this.sdk.RegisterTokenSchema({input:e})).registerTokenSchema.tokenSchema}async submitTransaction(e){const t=await this.sdk.SubmitMutation({input:e});return m(t.submitTransaction,"__typename")}async domains(e){return(await this.sdk.GetDomains(e)).domains.edges.map(({node:n})=>n)}async createNamespace(e){return(await this.sdk.CreateNamespace({input:e})).createNamespace?.namespace}async getNamespacesAndSchemas(e){return(await this.sdk.GetNamespacesAndSchemas(e)).namespaces.edges.map(({node:n})=>({...n,schemas:n.schemas.edges.map(({node:i})=>i)}))}async getNamespaces(e){return(await this.sdk.GetNamespaces(e)).namespaces}async getNamespace(e){const t=await this.sdk.GetNamespace(e);if(t.namespace)return{...t.namespace,schemas:t.namespace.schemas.edges.map(({node:s})=>s)}}async getOffChainAssets(e){return(await this.sdk.GetOffChainAssets(e)).offChainAssets}async getDomains(e){return(await this.sdk.GetDomains(e)).domains}async getTokenSchemas(e){return(await this.sdk.GetTokenSchemas(e)).tokenSchemas}async getTokenSchema(e){return(await this.sdk.GetTokenSchema(e)).tokenSchema}async getWebhookEndpoints(e){return(await this.sdk.GetWebhookEndpoints(e)).webhookEndpoints}async getWebhookEndpoint(e){return(await this.sdk.GetWebhookEndpoint(e)).webhookEndpoint}async getWebhookSubscriptions(e){return(await this.sdk.GetWebhookSubscriptions(e)).webhookSubscriptions}async getWebhookSubscription(e){return(await this.sdk.GetWebhookSubscription(e)).webhookSubscription}async createWebhookEndpoint(e){return(await this.sdk.CreateWebhookEndpoint({input:e})).createWebhookEndpoint.webhookEndpoint}async deleteWebhookEndpoint(e){return(await this.sdk.DeleteWebhookEndpoint({input:e})).deleteWebhookEndpoint.success}async updateWebhookEndpoint(e){return(await this.sdk.UpdateWebhookEndpoint({input:e})).updateWebhookEndpoint.webhookEndpoint}async createWebhookSubscription(e){return(await this.sdk.CreateWebhookSubscription({input:e})).createWebhookSubscription.webhookSubscription}async deleteWebhookSubscription(e){return(await this.sdk.DeleteWebhookSubscription({input:e})).deleteWebhookSubscription.success}async getAuthorizationHeader(){if(!this.auth)throw new Error("Please set AuthorizationParameters to use this functionality.");let e=this.auth.storage.get(A);if(e){const t=await this.validateToken(e);if(k.isRight(t))return{Authorization:e}}return e=await this.authenticate(),this.auth.storage.set(A,e),{Authorization:e}}async authenticate(){if(!this.auth)throw new Error("Please set AuthorizationParameters to use this functionality.");const e=new Date;e.setDate(e.getDate()+1);const s=new g.SiweMessage({domain:this.auth.domain,address:this.auth.walletAddress,statement:"",uri:this.auth.origin,version:"1",chainId:this.auth.chainId,nonce:g.generateNonce(),expirationTime:e.toISOString()}).prepareMessage(),n=await this.auth.sign(s);return`${btoa(s)}.${btoa(n)}`}async validateToken(e){try{const[t,s]=e.split("."),n=I(t),i=I(s),u=new g.SiweMessage(n),{data:h}=await u.verify({signature:i});if(h.expirationTime){const p=new Date(h.expirationTime);if(p.setSeconds(p.getSeconds()-60),p<new Date)return k.left(new l("Token expired"))}return k.right(h)}catch(t){return console.error("Error occurred:",t),k.left(new l("Invalid signature"))}}}We([ee(1e3)],se.prototype,"getAuthorizationHeader",1);exports.codecFromEnum=c.codecFromEnum;exports.ARError=l;exports.AssetMutationDocument=G;exports.AssetMutationInputSchema=ue;exports.AssetRegistry=se;exports.AssetTreeClass=f;exports.AssetTreeCollectionInputSchema=Z;exports.AssetTreeInputSchema=de;exports.AssetType=C;exports.AssetTypeSchema=he;exports.CollectionInputSchema=pe;exports.CreateNamespaceDocument=T;exports.CreateNamespaceInputSchema=me;exports.CreateSchemaDocument=E;exports.CreateSchemaInputSchema=le;exports.CreateWebhookEndpointDocument=N;exports.CreateWebhookEndpointInputSchema=be;exports.CreateWebhookSubscriptionDocument=R;exports.CreateWebhookSubscriptionInputSchema=ke;exports.DeleteWebhookEndpointDocument=O;exports.DeleteWebhookEndpointInputSchema=Se;exports.DeleteWebhookSubscriptionDocument=_;exports.DeleteWebhookSubscriptionInputSchema=fe;exports.GetAssetDocument=v;exports.GetAssetTreeDocument=F;exports.GetAssetsDocument=M;exports.GetDomainsDocument=x;exports.GetNamespaceDocument=z;exports.GetNamespacesAndSchemasDocument=P;exports.GetNamespacesDocument=j;exports.GetNonceForChainAddressDocument=H;exports.GetOffChainAssetsDocument=U;exports.GetTokenSchemaDocument=L;exports.GetTokenSchemasDocument=K;exports.GetTransactionDocument=V;exports.GetTransactionInputSchema=ge;exports.GetWebhookEndpointDocument=J;exports.GetWebhookEndpointsDocument=B;exports.GetWebhookSubscriptionDocument=X;exports.GetWebhookSubscriptionsDocument=Q;exports.NonceInputSchema=Ie;exports.OffChainAssetsInputSchema=ye;exports.RegisterCollectionDocument=D;exports.RegisterOffChainAssetDocument=$;exports.RegisterOffChainAssetInputSchema=Ae;exports.RegisterTokenSchemaDocument=q;exports.RegisterTokenSchemaInputSchema=Ce;exports.SDK_VERSION=te;exports.SubmitMutationDocument=w;exports.SubmitTransactionInputSchema=Ge;exports.UpdateWebhookEndpointDocument=W;exports.UpdateWebhookEndpointInputSchema=De;exports.base64Decode=I;exports.base64Encode=Te;exports.definedNonNullAnySchema=ce;exports.getSdk=Y;exports.memorize=ee;exports.omit=m;
{
"name": "@futureverse/asset-registry",
"version": "2.9.0",
"version": "2.10.0",
"main": "./index.js",

@@ -5,0 +5,0 @@ "types": "./index.d.ts",

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