You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@crossmint/client-sdk-auth-core

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crossmint/client-sdk-auth-core - npm Package Compare versions

Comparing version

to
1.5.0

dist/chunk-XAYHKNED.js

1

dist/client/index.d.ts

@@ -13,3 +13,2 @@ import * as _crossmint_client_sdk_base from '@crossmint/client-sdk-base';

}>;
getUserFromServer(externalUserId: string): Promise<any>;
getUserFromClient(jwt: string): Promise<any>;

@@ -16,0 +15,0 @@ }

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

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};
import{b as t,c as d}from"../chunk-XAYHKNED.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-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};
import{a as i,c as o}from"../chunk-XAYHKNED.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.4.1",
"version": "1.5.0",
"repository": "https://github.com/Crossmint/crossmint-sdk",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

import { APIErrorService, BaseCrossmintService } from "@crossmint/client-sdk-base";
import { authLogger } from "./logger";
import { CROSSMINT_API_VERSION } from "../utils/constants";
export class CrossmintAuthService extends BaseCrossmintService {

@@ -15,3 +15,3 @@ protected apiErrorService = new APIErrorService<never>({});

const result = await this.fetchCrossmintAPI(
"2024-09-26/session/sdk/auth/refresh",
`${CROSSMINT_API_VERSION}/session/sdk/auth/refresh`,
{ method: "POST", body: JSON.stringify({ refresh: refreshToken }) },

@@ -28,14 +28,10 @@ "Error fetching new refresh and access tokans."

async getUserFromServer(externalUserId: string) {
const result = await this.fetchCrossmintAPI(
`sdk/auth/user/${externalUserId}`,
async getUserFromClient(jwt: string) {
return await this.fetchCrossmintAPI(
`${CROSSMINT_API_VERSION}/sdk/auth/user`,
{ method: "GET" },
"Error fetching user."
"Error fetching user.",
jwt
);
return result.user;
}
async getUserFromClient(jwt: string) {
return await this.fetchCrossmintAPI("sdk/auth/user", { method: "GET" }, "Error fetching user.", jwt);
}
}
export const AUTH_SERVICE = "AUTH_SDK";
export const CROSSMINT_API_VERSION = "2024-09-26";

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