@crossmint/client-sdk-auth-core
Advanced tools
Comparing version
@@ -11,3 +11,6 @@ import * as _crossmint_client_sdk_base from '@crossmint/client-sdk-base'; | ||
refreshToken: any; | ||
user: any; | ||
}>; | ||
getUserFromServer(externalUserId: string): Promise<any>; | ||
getUserFromClient(jwt: string): Promise<any>; | ||
} | ||
@@ -17,4 +20,20 @@ | ||
type FarcasterMetadata = { | ||
fid: string; | ||
username: string; | ||
bio: string; | ||
displayName: string; | ||
pfpUrl: string; | ||
custody: string; | ||
verifications: string[]; | ||
}; | ||
type SDKExternalUser = { | ||
id: string; | ||
email?: string; | ||
phoneNumber?: string; | ||
farcaster?: FarcasterMetadata; | ||
}; | ||
declare function getJWTExpiration(token: string): number | undefined; | ||
export { CrossmintAuthService, authLogger, getJWTExpiration }; | ||
export { CrossmintAuthService, type FarcasterMetadata, type SDKExternalUser, authLogger, getJWTExpiration }; |
@@ -1,2 +0,2 @@ | ||
import{b as t,c as d}from"../chunk-4YAE4H7C.js";import{jwtDecode as e}from"jwt-decode";function p(o){return e(o).exp}export{d as CrossmintAuthService,t as authLogger,p as getJWTExpiration}; | ||
import{b as t,c as d}from"../chunk-RO67RGDV.js";import{jwtDecode as e}from"jwt-decode";function n(o){return e(o).exp}export{d as CrossmintAuthService,t as authLogger,n as getJWTExpiration}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{a as i,c as o}from"../chunk-4YAE4H7C.js";import{JsonWebTokenError as l,TokenExpiredError as u,verify as y}from"jsonwebtoken";import{decode as c}from"jsonwebtoken";import{JwksClient as a}from"jwks-rsa";function s(n,e){return i(this,null,function*(){let r=c(n,{complete:!0});if((r==null?void 0:r.header)==null)throw new Error("Invalid Token: Header Formatted Incorrectly");return(yield g(e,r.header.kid)).getPublicKey()})}function g(n,e){return i(this,null,function*(){let r=new a({jwksUri:n,cache:!0});try{return yield r.getSigningKey(e)}catch(t){throw new Error("Unable to retrieve signing key")}})}function b(n,e){return i(this,null,function*(){let r=new o(n);try{return yield m(r,e)}catch(t){throw new Error("Invalid token")}})}function f(n,e){try{let r=y(e,n);if(r==null||typeof r=="string")throw new Error("Invalid token");return r}catch(r){throw r!=null&&r instanceof u?new Error(`JWT provided expired at timestamp ${r.expiredAt.toISOString()}`):r!=null&&r instanceof l&&(r.message.includes("invalid signature")||r.message.includes("invalid algorithm"))?new Error(r.message):new Error("Invalid token")}}function m(n,e){return i(this,null,function*(){let r=yield s(e,n.getJWKSUri());return f(r,e)})}export{b as verifyCrossmintSessionToken}; | ||
import{a as i,c as o}from"../chunk-RO67RGDV.js";import{JsonWebTokenError as l,TokenExpiredError as u,verify as y}from"jsonwebtoken";import{decode as c}from"jsonwebtoken";import{JwksClient as a}from"jwks-rsa";function s(n,e){return i(this,null,function*(){let r=c(n,{complete:!0});if((r==null?void 0:r.header)==null)throw new Error("Invalid Token: Header Formatted Incorrectly");return(yield g(e,r.header.kid)).getPublicKey()})}function g(n,e){return i(this,null,function*(){let r=new a({jwksUri:n,cache:!0});try{return yield r.getSigningKey(e)}catch(t){throw new Error("Unable to retrieve signing key")}})}function b(n,e){return i(this,null,function*(){let r=new o(n);try{return yield m(r,e)}catch(t){throw new Error("Invalid token")}})}function f(n,e){try{let r=y(e,n);if(r==null||typeof r=="string")throw new Error("Invalid token");return r}catch(r){throw r!=null&&r instanceof u?new Error(`JWT provided expired at timestamp ${r.expiredAt.toISOString()}`):r!=null&&r instanceof l&&(r.message.includes("invalid signature")||r.message.includes("invalid algorithm"))?new Error(r.message):new Error("Invalid token")}}function m(n,e){return i(this,null,function*(){let r=yield s(e,n.getJWKSUri());return f(r,e)})}export{b as verifyCrossmintSessionToken}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@crossmint/client-sdk-auth-core", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"repository": "https://github.com/Crossmint/crossmint-sdk", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -23,4 +23,18 @@ import { APIErrorService, BaseCrossmintService } from "@crossmint/client-sdk-base"; | ||
refreshToken: result.refresh, | ||
user: result.user, | ||
}; | ||
} | ||
async getUserFromServer(externalUserId: string) { | ||
const result = await this.fetchCrossmintAPI( | ||
`sdk/auth/user/${externalUserId}`, | ||
{ method: "GET" }, | ||
"Error fetching user." | ||
); | ||
return result.user; | ||
} | ||
async getUserFromClient(jwt: string) { | ||
return await this.fetchCrossmintAPI("sdk/auth/user", { method: "GET" }, "Error fetching user.", jwt); | ||
} | ||
} |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
40982
12.7%104
46.48%