@secrecy/lib 1.86.1-feat-improve-sdk.1 → 1.86.1-feat-improve-sdk.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { decodeJwt } from '../utils/jwt.js';
1
+ import { decode } from 'jsonwebtoken';
2
2
  import { getStorage } from './storage.js';
3
3
  import { publicKeysCache } from '../cache.js';
4
4
  export class SecrecyAppClient {
@@ -7,7 +7,7 @@ export class SecrecyAppClient {
7
7
  #client;
8
8
  constructor(uaJwt, client) {
9
9
  this.jwt = uaJwt;
10
- this.jwtDecoded = decodeJwt(uaJwt);
10
+ this.jwtDecoded = decode(uaJwt);
11
11
  this.#client = client;
12
12
  }
13
13
  get userId() {
@@ -41,7 +41,7 @@ export class SecrecyAppClient {
41
41
  includeEmail: typeof this.jwtDecoded['email'] === 'string',
42
42
  });
43
43
  this.jwt = jwt;
44
- this.jwtDecoded = decodeJwt(jwt);
44
+ this.jwtDecoded = decode(jwt);
45
45
  const sessionStorage = getStorage(true);
46
46
  const localStorage = getStorage(false);
47
47
  const sessionJwt = sessionStorage.jwt.load();
@@ -1 +1 @@
1
- export const SECRECY_LIB_VERSION = '0.0.0-development';
1
+ export const SECRECY_LIB_VERSION = '1.0.0';
@@ -1,5 +1,5 @@
1
1
  import type { SecrecyClient, UserAppNotifications, UserAppSettings } from '../index.js';
2
- import { type JwtPayload } from '../utils/jwt.js';
2
+ import type { JwtPayload } from 'jsonwebtoken';
3
3
  import { type RouterOutputs, type RouterInputs } from '../client.js';
4
4
  export declare class SecrecyAppClient {
5
5
  #private;
@@ -1 +1 @@
1
- export declare const SECRECY_LIB_VERSION = "0.0.0-development";
1
+ export declare const SECRECY_LIB_VERSION = "1.0.0";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@secrecy/lib",
3
3
  "author": "Anonymize <anonymize@gmail.com>",
4
4
  "description": "Client-side end-to-end encryption SDK for Secrecy",
5
- "version": "1.86.1-feat-improve-sdk.1",
5
+ "version": "1.86.1-feat-improve-sdk.2",
6
6
  "engines": {
7
7
  "node": ">=22.21.1"
8
8
  },
@@ -1,16 +0,0 @@
1
- function base64UrlDecode(input) {
2
- const base64 = input.replace(/-/g, '+').replace(/_/g, '/');
3
- const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), '=');
4
- const binary = atob(padded);
5
- const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
6
- return new TextDecoder('utf-8').decode(bytes);
7
- }
8
- // Decode-only: this SDK never verifies a JWT signature, verification
9
- // server-side is what actually matters.
10
- export function decodeJwt(token) {
11
- const payload = token.split('.')[1];
12
- if (payload === undefined) {
13
- throw new Error('Invalid JWT: missing payload segment');
14
- }
15
- return JSON.parse(base64UrlDecode(payload));
16
- }
@@ -1,9 +0,0 @@
1
- export interface JwtPayload {
2
- sub?: string;
3
- aud?: string | string[];
4
- iss?: string;
5
- exp?: number;
6
- iat?: number;
7
- [claim: string]: unknown;
8
- }
9
- export declare function decodeJwt<T = JwtPayload>(token: string): T;