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.1.0 to 2.2.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# [2.1.0](https://github.com/futureversecom/fv-asset-registry/compare/core-sdk-v2.0.0...core-sdk-v2.1.0) (2023-12-21)
### Features
* **react-sdk:** move react query to peer dep - ARM-197 ([#689](https://github.com/futureversecom/fv-asset-registry/issues/689)) ([8ba25af](https://github.com/futureversecom/fv-asset-registry/commit/8ba25afe2c7e3524ece80fd59c8932b811e1e660))
# [2.0.0](https://github.com/futureversecom/fv-asset-registry/compare/core-sdk-v1.10.0...core-sdk-v2.0.0) (2023-12-19)

@@ -2,0 +9,0 @@

28

index.js

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

"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-d297333b.js"),se=require("io-ts"),a=require("graphql-tag"),ne=require("graphql-request");require("io-ts/Codec");require("io-ts/Decoder");const S=require("siwe"),b=require("fp-ts/lib/Either"),oe=require("jsonld");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 re(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=re(se);var C=(r=>(r.Erc721="ERC721",r.Erc1155="ERC1155",r))(C||{});const G=a`
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-d297333b.js"),ne=require("io-ts"),a=require("graphql-tag"),oe=require("graphql-request");require("io-ts/Codec");require("io-ts/Decoder");const S=require("siwe"),b=require("fp-ts/lib/Either"),re=require("jsonld");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`
mutation assetMutation($input: AssetMutationInput!) {

@@ -17,3 +17,3 @@ assetMutation(input: $input) {

}
`,T=a`
`,D=a`
mutation RegisterCollection($input: CollectionInput!) {

@@ -34,3 +34,3 @@ registerCollection(input: $input) {

}
`,D=a`
`,T=a`
mutation CreateNamespace($input: CreateNamespaceInput!) {

@@ -104,3 +104,3 @@ createNamespace(input: $input) {

}
`,W=a`
`,N=a`
mutation CreateWebhookEndpoint($input: CreateWebhookEndpointInput!) {

@@ -119,3 +119,3 @@ createWebhookEndpoint(input: $input) {

}
`,N=a`
`,W=a`
mutation UpdateWebhookEndpoint($input: UpdateWebhookEndpointInput!) {

@@ -140,3 +140,3 @@ updateWebhookEndpoint(input: $input) {

}
`,_=a`
`,R=a`
mutation CreateWebhookSubscription($input: CreateWebhookSubscriptionInput!) {

@@ -155,3 +155,3 @@ createWebhookSubscription(input: $input) {

}
`,R=a`
`,_=a`
mutation DeleteWebhookSubscription($input: DeleteWebhookSubscriptionInput!) {

@@ -379,3 +379,3 @@ deleteWebhookSubscription(input: $input) {

}
`,L=a`
`,K=a`
query GetTokenSchemas(

@@ -403,3 +403,3 @@ $collectionId: CollectionId!

}
`,K=a`
`,L=a`
query GetTokenSchema($collectionId: CollectionId!, $tokenId: String) {

@@ -414,3 +414,3 @@ tokenSchema(collectionId: $collectionId, tokenId: $tokenId) {

}
`,B=a`
`,V=a`
query GetTransaction($transactionHash: TransactionHash!) {

@@ -432,3 +432,3 @@ transaction(transactionHash: $transactionHash) {

}
`,J=a`
`,B=a`
query GetWebhookEndpoints($first: Float, $after: String) {

@@ -453,3 +453,3 @@ webhookEndpoints(first: $first, after: $after) {

}
`,Q=a`
`,J=a`
query GetWebhookEndpoint($webhookId: String!) {

@@ -466,3 +466,3 @@ webhookEndpoint(webhookId: $webhookId) {

}
`,V=a`
`,Q=a`
query GetWebhookSubscriptions(

@@ -504,2 +504,2 @@ $webhookId: String!

}
`,ae=(r,e,t)=>r();function Y(r,e=ae){return{assetMutation(t,s){return e(n=>r.request(G,t,{...s,...n}),"assetMutation","mutation")},RegisterCollection(t,s){return e(n=>r.request(T,t,{...s,...n}),"RegisterCollection","mutation")},CreateNamespace(t,s){return e(n=>r.request(D,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(W,t,{...s,...n}),"CreateWebhookEndpoint","mutation")},UpdateWebhookEndpoint(t,s){return e(n=>r.request(N,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(_,t,{...s,...n}),"CreateWebhookSubscription","mutation")},DeleteWebhookSubscription(t,s){return e(n=>r.request(R,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(P,t,{...s,...n}),"GetDomains","query")},GetNamespacesAndSchemas(t,s){return e(n=>r.request(x,t,{...s,...n}),"GetNamespacesAndSchemas","query")},GetNamespaces(t,s){return e(n=>r.request(z,t,{...s,...n}),"GetNamespaces","query")},GetNamespace(t,s){return e(n=>r.request(j,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(L,t,{...s,...n}),"GetTokenSchemas","query")},GetTokenSchema(t,s){return e(n=>r.request(K,t,{...s,...n}),"GetTokenSchema","query")},GetTransaction(t,s){return e(n=>r.request(B,t,{...s,...n}),"GetTransaction","query")},GetWebhookEndpoints(t,s){return e(n=>r.request(J,t,{...s,...n}),"GetWebhookEndpoints","query")},GetWebhookEndpoint(t,s){return e(n=>r.request(Q,t,{...s,...n}),"GetWebhookEndpoint","query")},GetWebhookSubscriptions(t,s){return e(n=>r.request(V,t,{...s,...n}),"GetWebhookSubscriptions","query")},GetWebhookSubscription(t,s){return e(n=>r.request(X,t,{...s,...n}),"GetWebhookSubscription","query")}}}const ie=o.unknown;function ce(){return o.type({signature:c.Signature,transaction:c.AssetTransactionMessage})}function Z(){return o.type({chainId:c.ChainIdT,chainType:c.ChainTypeT,location:c.CollectionLocation})}function ue(){return o.type({collection:Z(),tokenId:o.string})}const de=o.keyof({ERC721:null,ERC1155:null});function he(){return o.type({collectionId:c.CollectionId,schemaIdentifier:c.SchemaIdentifier})}function pe(){return o.type({domain:o.string,suffix:o.string})}function me(){return o.type({name:o.string,namespace:c.Namespace,schema:o.string,version:o.number})}function le(){return o.intersection([o.type({url:o.string}),o.partial({retries:o.union([o.null,o.number])})])}function be(){return o.type({actions:o.array(o.string),collectionId:c.CollectionId,type:o.string,webhookId:o.string})}function ke(){return o.type({webhookId:o.string})}function Se(){return o.type({subscriptionId:o.string,webhookId:o.string})}function fe(){return o.type({transactionHash:c.TransactionHash})}function ge(){return o.type({chainAddress:c.ChainAddress})}function Ie(){return o.type({creatorId:o.string})}function ye(){return o.intersection([o.type({creatorCollectionId:o.string,creatorId:o.string}),o.partial({tokenId:o.union([o.null,o.string])})])}function Ae(){return o.intersection([o.type({collectionId:c.CollectionId,schemaId:c.SchemaIdentifier}),o.partial({tokenId:o.union([o.null,o.string])})])}function Ce(){return o.intersection([o.type({signature:c.Signature,transaction:c.AssetTransactionMessage}),o.partial({check:o.union([o.null,o.boolean])})])}function Ge(){return o.intersection([o.type({webhookId:o.string}),o.partial({retries:o.union([o.null,o.number]),url:o.union([o.null,o.string])})])}const Te=r=>Buffer.from(r).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""),f=r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";return Buffer.from(e||"","base64").toString()},p=(r,...e)=>{const t={};let s;for(s in r)e.includes(s)||(t[s]=r[s]);return t},k=Symbol("memoizedResult"),y=Symbol("timeoutId");function ee(r){return function(e,t,s){const n=s.value;return s.value=function(...i){if(this[k]!==void 0)return this[k];const u=n.apply(this,i);return this[k]=u,clearTimeout(this[y]),this[y]=setTimeout(()=>{this[k]=void 0},r),u},s}}class De extends Error{constructor(e,t,s){super(),this.name=e,this.message=t,this.cause=s}}class m extends De{constructor(e,t){super("ARError",e,t)}}const $e=["RegisterOffChainAsset","CreateSchema","GetNamespacesAndSchemas","GetNamespaces","GetDomains","CreateNamespace","RegisterTokenSchema","CreateWebhookEndpoint","UpdateWebhookEndpoint","DeleteWebhookEndpoint","CreateWebhookSubscription","DeleteWebhookSubscription","GetWebhookEndpoints","GetWebhookSubscriptions"],A="AR-Auth-Token";class g{constructor(e,t,s){const n=t.schema;this.client=e,this.raw=t,this.schema=n?.schema,this.pathAssetIds=s,this.pathAssetTrees={}}static async init(e,t){const s=t.assetTree,n=await this.parse(s.data,s.nodeId);return new g(e,t,n)}get paths(){return Object.keys(this.pathAssetIds)}async getPath(e){if(this.paths.includes(e)&&!this.pathAssetTrees[e]){const t=this.pathAssetIds[e],[s,n,i,u,h,d]=t.split(":"),l=`${i}:${u}:${h}`,I=await this.client.getAssetTree({collectionId:l,tokenId:d});I&&(this.pathAssetTrees[e]=I)}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={};if(Array.isArray(n)){const u=n.filter(d=>d["@id"]===t)[0],h=new Set(["@id","http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]);for(const d in u)h.has(d)||(i[d]=u[d][0]["@id"])}return i}}var Ee=Object.defineProperty,we=Object.getOwnPropertyDescriptor,qe=(r,e,t,s)=>{for(var n=s>1?void 0:s?we(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&&Ee(e,t,n),n};class te{constructor(e){this.auth=e.auth;const t=new ne.GraphQLClient(e.url,{headers:{"Content-Type":"application/json"}}),s=async(n,i,u)=>{const h=Date.now(),d=$e.includes(i)?await this.getAuthorizationHeader():void 0,l=await n(d);return process.env.NODE_ENV==="development"&&(console.log("request duration (ms)",Date.now()-h),console.log("request result",l)),l};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?p(t.asset,"__typename"):null}async getAssetTree(e){const t=await this.sdk.GetAsset(e);return t.asset?await g.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 p(t.createSchema,"__typename");throw new m(t.createSchema.errors[0]?.message)}async registerOffChainAsset(e){const t=await this.sdk.RegisterOffChainAsset({input:e});if(t.registerOffChainAsset.__typename==="RegisterOffChainAssetSuccess")return p(t.registerOffChainAsset.offChainAsset,"__typename");throw new m(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 p(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(b.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 S.SiweMessage({domain:this.auth.domain,address:this.auth.walletAddress,statement:"",uri:this.auth.origin,version:"1",chainId:this.auth.chainId,nonce:S.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=f(t),i=f(s),u=new S.SiweMessage(n),{data:h}=await u.verify({signature:i});if(h.expirationTime){const d=new Date(h.expirationTime);if(d.setSeconds(d.getSeconds()-60),d<new Date)return b.left(new m("Token expired"))}return b.right(h)}catch(t){return console.error("Error occurred:",t),b.left(new m("Invalid signature"))}}}qe([ee(1e3)],te.prototype,"getAuthorizationHeader",1);exports.codecFromEnum=c.codecFromEnum;exports.ARError=m;exports.AssetMutationDocument=G;exports.AssetMutationInputSchema=ce;exports.AssetRegistry=te;exports.AssetTreeCollectionInputSchema=Z;exports.AssetTreeInputSchema=ue;exports.AssetType=C;exports.AssetTypeSchema=de;exports.CollectionInputSchema=he;exports.CreateNamespaceDocument=D;exports.CreateNamespaceInputSchema=pe;exports.CreateSchemaDocument=E;exports.CreateSchemaInputSchema=me;exports.CreateWebhookEndpointDocument=W;exports.CreateWebhookEndpointInputSchema=le;exports.CreateWebhookSubscriptionDocument=_;exports.CreateWebhookSubscriptionInputSchema=be;exports.DeleteWebhookEndpointDocument=O;exports.DeleteWebhookEndpointInputSchema=ke;exports.DeleteWebhookSubscriptionDocument=R;exports.DeleteWebhookSubscriptionInputSchema=Se;exports.GetAssetDocument=v;exports.GetAssetTreeDocument=F;exports.GetAssetsDocument=M;exports.GetDomainsDocument=P;exports.GetNamespaceDocument=j;exports.GetNamespacesAndSchemasDocument=x;exports.GetNamespacesDocument=z;exports.GetNonceForChainAddressDocument=H;exports.GetOffChainAssetsDocument=U;exports.GetTokenSchemaDocument=K;exports.GetTokenSchemasDocument=L;exports.GetTransactionDocument=B;exports.GetTransactionInputSchema=fe;exports.GetWebhookEndpointDocument=Q;exports.GetWebhookEndpointsDocument=J;exports.GetWebhookSubscriptionDocument=X;exports.GetWebhookSubscriptionsDocument=V;exports.NonceInputSchema=ge;exports.OffChainAssetsInputSchema=Ie;exports.RegisterCollectionDocument=T;exports.RegisterOffChainAssetDocument=$;exports.RegisterOffChainAssetInputSchema=ye;exports.RegisterTokenSchemaDocument=q;exports.RegisterTokenSchemaInputSchema=Ae;exports.SubmitMutationDocument=w;exports.SubmitTransactionInputSchema=Ce;exports.UpdateWebhookEndpointDocument=N;exports.UpdateWebhookEndpointInputSchema=Ge;exports.base64Decode=f;exports.base64Encode=Te;exports.definedNonNullAnySchema=ie;exports.getSdk=Y;exports.memorize=ee;exports.omit=p;
`,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(P,t,{...s,...n}),"GetDomains","query")},GetNamespacesAndSchemas(t,s){return e(n=>r.request(x,t,{...s,...n}),"GetNamespacesAndSchemas","query")},GetNamespaces(t,s){return e(n=>r.request(z,t,{...s,...n}),"GetNamespaces","query")},GetNamespace(t,s){return e(n=>r.request(j,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])})])}const Te=r=>Buffer.from(r).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""),f=r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";return Buffer.from(e||"","base64").toString()},p=(r,...e)=>{const t={};let s;for(s in r)e.includes(s)||(t[s]=r[s]);return t},k=Symbol("memoizedResult"),y=Symbol("timeoutId");function ee(r){return function(e,t,s){const n=s.value;return s.value=function(...i){if(this[k]!==void 0)return this[k];const u=n.apply(this,i);return this[k]=u,clearTimeout(this[y]),this[y]=setTimeout(()=>{this[k]=void 0},r),u},s}}class $e extends Error{constructor(e,t,s){super(),this.name=e,this.message=t,this.cause=s}}class m 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";class g{constructor(e,t,s){const n=t.schema;this.client=e,this.raw=t,this.schema=n?.schema,this.pathAssetIds=s,this.pathAssetTrees={}}static async init(e,t){const s=t.assetTree,n=await this.parse(s.data,s.nodeId);return new g(e,t,n)}get paths(){return Object.keys(this.pathAssetIds)}async getPath(e){if(this.paths.includes(e)&&!this.pathAssetTrees[e]){const t=this.pathAssetIds[e],[s,n,i,u,h,d]=t.split(":"),l=`${i}:${u}:${h}`,I=await this.client.getAssetTree({collectionId:l,tokenId:d});I&&(this.pathAssetTrees[e]=I)}return this.pathAssetTrees[e]||null}static async parse(e,t){const s=typeof e=="object"?e:JSON.parse(e),n=await re.flatten(s),i={};if(Array.isArray(n)){const u=n.filter(d=>d["@id"]===t)[0],h=new Set(["@id","http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]);for(const d in u)h.has(d)||(i[d]=u[d][0]["@id"])}return i}}const we="2.1.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 oe.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(),d=Ee.includes(i)?await this.getAuthorizationHeader():void 0,l=await n(d);return process.env.NODE_ENV==="development"&&(console.log("request duration (ms)",Date.now()-h),console.log("request result",l)),l};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?p(t.asset,"__typename"):null}async getAssetTree(e){const t=await this.sdk.GetAsset(e);return t.asset?await g.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 p(t.createSchema,"__typename");throw new m(t.createSchema.errors[0]?.message)}async registerOffChainAsset(e){const t=await this.sdk.RegisterOffChainAsset({input:e});if(t.registerOffChainAsset.__typename==="RegisterOffChainAssetSuccess")return p(t.registerOffChainAsset.offChainAsset,"__typename");throw new m(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 p(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(b.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 S.SiweMessage({domain:this.auth.domain,address:this.auth.walletAddress,statement:"",uri:this.auth.origin,version:"1",chainId:this.auth.chainId,nonce:S.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=f(t),i=f(s),u=new S.SiweMessage(n),{data:h}=await u.verify({signature:i});if(h.expirationTime){const d=new Date(h.expirationTime);if(d.setSeconds(d.getSeconds()-60),d<new Date)return b.left(new m("Token expired"))}return b.right(h)}catch(t){return console.error("Error occurred:",t),b.left(new m("Invalid signature"))}}}We([ee(1e3)],se.prototype,"getAuthorizationHeader",1);exports.codecFromEnum=c.codecFromEnum;exports.ARError=m;exports.AssetMutationDocument=G;exports.AssetMutationInputSchema=ue;exports.AssetRegistry=se;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=P;exports.GetNamespaceDocument=j;exports.GetNamespacesAndSchemasDocument=x;exports.GetNamespacesDocument=z;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=f;exports.base64Encode=Te;exports.definedNonNullAnySchema=ce;exports.getSdk=Y;exports.memorize=ee;exports.omit=p;
import { AssetTreeInput, RegisterTokenSchemaInput, CreateSchemaInput, RegisterOffChainAssetInput, GetTransactionInput, GetNamespacesAndSchemasQueryVariables, SubmitTransactionInput, SubmitTransactionSuccess, CreateNamespaceInput, CreateWebhookEndpointInput, DeleteWebhookEndpointInput, CreateWebhookSubscriptionInput, DeleteWebhookSubscriptionInput, GetAssetQueryVariables, GetAssetsQueryVariables, GetDomainsQueryVariables, GetOffChainAssetsQueryVariables, GetTokenSchemaQueryVariables, GetTokenSchemasQueryVariables, GetWebhookEndpointQueryVariables, GetWebhookEndpointsQueryVariables, GetWebhookSubscriptionQueryVariables, GetWebhookSubscriptionsQueryVariables, GetNamespaceQueryVariables, GetNamespacesQueryVariables } from '../generated';
import { ChainAddress, CollectionId } from '../types';
import { AssetTree } from './AssetTree';
export declare const SDK_VERSION: string;
/**

@@ -5,0 +6,0 @@ * A function that returns a Promise that resolves to a string representing an authentication token.

{
"name": "@futureverse/asset-registry",
"version": "2.1.0",
"version": "2.2.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