@logto/node 2.5.7 → 2.5.8

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.
package/lib/src/index.cjs CHANGED
@@ -83,7 +83,6 @@ Object.defineProperty(exports, "organizationUrnPrefix", {
83
83
  enumerable: true,
84
84
  get: function () { return BaseClient.organizationUrnPrefix; }
85
85
  });
86
- exports.createSession = session.createSession;
87
86
  exports.unwrapSession = session.unwrapSession;
88
87
  exports.wrapSession = session.wrapSession;
89
88
  exports.CookieStorage = cookieStorage.CookieStorage;
package/lib/src/index.js CHANGED
@@ -2,7 +2,7 @@ import { createRequester } from '@logto/client';
2
2
  export { LogtoClientError, LogtoError, LogtoRequestError, OidcError, PersistKey, Prompt, ReservedResource, ReservedScope, StandardLogtoClient, UserScope, buildOrganizationUrn, getOrganizationIdFromUrn, organizationUrnPrefix } from '@logto/client';
3
3
  import { generateCodeChallenge, generateCodeVerifier, generateState } from '../edge/generators.js';
4
4
  import LogtoNodeBaseClient from './client.js';
5
- export { createSession, unwrapSession, wrapSession } from './utils/session.js';
5
+ export { unwrapSession, wrapSession } from './utils/session.js';
6
6
  export { CookieStorage } from './utils/cookie-storage.js';
7
7
 
8
8
  class LogtoClient extends LogtoNodeBaseClient {
@@ -36,7 +36,7 @@ async function decrypt(ciphertext, iv, password, crypto) {
36
36
  }, secretKey, Buffer.from(ciphertext, 'base64'));
37
37
  return new TextDecoder().decode(cleartext);
38
38
  }
39
- const unwrapSession = async (cookie, secret, crypto = global.crypto) => {
39
+ const unwrapSession = async (cookie, secret) => {
40
40
  try {
41
41
  const [ciphertext, iv] = cookie.split('.');
42
42
  if (!ciphertext || !iv) {
@@ -51,23 +51,10 @@ const unwrapSession = async (cookie, secret, crypto = global.crypto) => {
51
51
  }
52
52
  return {};
53
53
  };
54
- const wrapSession = async (session, secret, crypto = global.crypto) => {
54
+ const wrapSession = async (session, secret) => {
55
55
  const { ciphertext, iv } = await encrypt(JSON.stringify(session), secret, crypto);
56
56
  return `${ciphertext}.${iv}`;
57
57
  };
58
- const createSession = async ({ secret, crypto }, cookie, setCookie) => {
59
- const data = await unwrapSession(cookie, secret, crypto);
60
- const getValues = async () => wrapSession(session, secret, crypto);
61
- const session = {
62
- ...data,
63
- save: async () => {
64
- setCookie?.(await getValues());
65
- },
66
- getValues,
67
- };
68
- return session;
69
- };
70
58
 
71
- exports.createSession = createSession;
72
59
  exports.unwrapSession = unwrapSession;
73
60
  exports.wrapSession = wrapSession;
@@ -9,11 +9,5 @@ export type Session = SessionData & {
9
9
  save: () => Promise<void>;
10
10
  getValues?: () => Promise<string>;
11
11
  };
12
- export declare const unwrapSession: (cookie: string, secret: string, crypto?: Crypto) => Promise<SessionData>;
13
- export declare const wrapSession: (session: SessionData, secret: string, crypto?: Crypto) => Promise<string>;
14
- type SessionConfigs = {
15
- secret: string;
16
- crypto: Crypto;
17
- };
18
- export declare const createSession: ({ secret, crypto }: SessionConfigs, cookie: string, setCookie?: ((value: string) => void) | undefined) => Promise<Session>;
19
- export {};
12
+ export declare const unwrapSession: (cookie: string, secret: string) => Promise<SessionData>;
13
+ export declare const wrapSession: (session: SessionData, secret: string) => Promise<string>;
@@ -34,7 +34,7 @@ async function decrypt(ciphertext, iv, password, crypto) {
34
34
  }, secretKey, Buffer.from(ciphertext, 'base64'));
35
35
  return new TextDecoder().decode(cleartext);
36
36
  }
37
- const unwrapSession = async (cookie, secret, crypto = global.crypto) => {
37
+ const unwrapSession = async (cookie, secret) => {
38
38
  try {
39
39
  const [ciphertext, iv] = cookie.split('.');
40
40
  if (!ciphertext || !iv) {
@@ -49,21 +49,9 @@ const unwrapSession = async (cookie, secret, crypto = global.crypto) => {
49
49
  }
50
50
  return {};
51
51
  };
52
- const wrapSession = async (session, secret, crypto = global.crypto) => {
52
+ const wrapSession = async (session, secret) => {
53
53
  const { ciphertext, iv } = await encrypt(JSON.stringify(session), secret, crypto);
54
54
  return `${ciphertext}.${iv}`;
55
55
  };
56
- const createSession = async ({ secret, crypto }, cookie, setCookie) => {
57
- const data = await unwrapSession(cookie, secret, crypto);
58
- const getValues = async () => wrapSession(session, secret, crypto);
59
- const session = {
60
- ...data,
61
- save: async () => {
62
- setCookie?.(await getValues());
63
- },
64
- getValues,
65
- };
66
- return session;
67
- };
68
56
 
69
- export { createSession, unwrapSession, wrapSession };
57
+ export { unwrapSession, wrapSession };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/node",
3
- "version": "2.5.7",
3
+ "version": "2.5.8",
4
4
  "type": "module",
5
5
  "main": "./lib/src/index.cjs",
6
6
  "module": "./lib/src/index.js",