Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

canvas-client

Package Overview
Dependencies
Maintainers
3
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-client - npm Package Compare versions

Comparing version
2.0.5
to
2.0.6
+2
-2
lib-esm/canvas.js
import { pLimit, omit, isNotEmpty } from 'txstate-utils';
import { CanvasCourse, CanvasSectionPayload, CanvasEnrollmentTerm, CanvasCourseIncludes, CanvasUser, CanvasAssignment } from './interfaces';
import { throwUnlessValidId, throwUnlessValidUserId } from './utils/utils';
import { stringifyParams, throwUnlessValidId, throwUnlessValidUserId } from './utils/utils';
import { GraphQLError } from './utils/errors';

@@ -33,3 +33,3 @@ import { parseLinkHeader } from './utils/parselink';

if (!isPostOrPut && isNotEmpty(payload))
finalUrl.search = new URLSearchParams(payload).toString();
finalUrl.search = stringifyParams(payload);
const resp = await fetch(finalUrl, {

@@ -36,0 +36,0 @@ method,

import { type CanvasID } from '../interfaces';
export declare function throwUnlessValidId(id: CanvasID | string, prefix: string): void;
export declare function throwUnlessValidUserId(id: CanvasID | string): void;
export declare function stringifyParams(params: Record<string, any>): string;

@@ -10,1 +10,29 @@ export function throwUnlessValidId(id, prefix) {

}
export function stringifyParams(params) {
const flattened = [];
for (const [key, val] of Object.entries(params)) {
if (Array.isArray(val)) {
const arrKey = key.endsWith('[]') ? key : key + '[]';
flattened.push(...val.map(v => [arrKey, String(v)]));
}
else if (typeof val === 'object' && val !== null) {
for (const [subKey, subVal] of Object.entries(val)) {
if (Array.isArray(subVal)) {
flattened.push(...subVal.map((v) => [`${key}[${subKey}][]`, v]));
}
else if (typeof subVal === 'object' && subVal !== null) {
for (const [deepKey, deepVal] of Object.entries(subVal)) {
flattened.push([`${key}[${subKey}][${deepKey}]`, deepVal]);
}
}
else {
flattened.push([`${key}[${subKey}]`, String(subVal)]);
}
}
}
else {
flattened.push([key, String(val)]);
}
}
return '?' + flattened.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join('&');
}

@@ -36,3 +36,3 @@ "use strict";

if (!isPostOrPut && (0, txstate_utils_1.isNotEmpty)(payload))
finalUrl.search = new URLSearchParams(payload).toString();
finalUrl.search = (0, utils_1.stringifyParams)(payload);
const resp = await fetch(finalUrl, {

@@ -39,0 +39,0 @@ method,

import { type CanvasID } from '../interfaces';
export declare function throwUnlessValidId(id: CanvasID | string, prefix: string): void;
export declare function throwUnlessValidUserId(id: CanvasID | string): void;
export declare function stringifyParams(params: Record<string, any>): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.throwUnlessValidUserId = exports.throwUnlessValidId = void 0;
exports.stringifyParams = exports.throwUnlessValidUserId = exports.throwUnlessValidId = void 0;
function throwUnlessValidId(id, prefix) {

@@ -15,1 +15,30 @@ if (typeof id === 'string' && isNaN(parseInt(id)) && !id.startsWith(prefix))

exports.throwUnlessValidUserId = throwUnlessValidUserId;
function stringifyParams(params) {
const flattened = [];
for (const [key, val] of Object.entries(params)) {
if (Array.isArray(val)) {
const arrKey = key.endsWith('[]') ? key : key + '[]';
flattened.push(...val.map(v => [arrKey, String(v)]));
}
else if (typeof val === 'object' && val !== null) {
for (const [subKey, subVal] of Object.entries(val)) {
if (Array.isArray(subVal)) {
flattened.push(...subVal.map((v) => [`${key}[${subKey}][]`, v]));
}
else if (typeof subVal === 'object' && subVal !== null) {
for (const [deepKey, deepVal] of Object.entries(subVal)) {
flattened.push([`${key}[${subKey}][${deepKey}]`, deepVal]);
}
}
else {
flattened.push([`${key}[${subKey}]`, String(subVal)]);
}
}
}
else {
flattened.push([key, String(val)]);
}
}
return '?' + flattened.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join('&');
}
exports.stringifyParams = stringifyParams;
{
"name": "canvas-client",
"version": "2.0.5",
"version": "2.0.6",
"description": "Typescript library to make accessing the Canvas API more convenient.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",