Skip to content

Commit

Permalink
add app_id validation check to updateUser
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Oct 25, 2023
1 parent adf4446 commit de428a1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/requestService/RequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import { UpdateUserPayload } from './UpdateUserPayload';
import UserData from '../models/UserData';
import { RequestMetadata } from '../models/RequestMetadata';
import { encodeRFC3986URIComponent } from '../../shared/utils/Encoding';
import OneSignalUtils from '../../shared/utils/OneSignalUtils';
import {
SdkInitError,
SdkInitErrorKind,
} from '../../shared/errors/SdkInitError';

export class RequestService {
/* U S E R O P E R A T I O N S */
Expand Down Expand Up @@ -62,6 +67,10 @@ export class RequestService {
payload: UpdateUserPayload,
): Promise<OneSignalApiBaseResponse> {
const { appId, subscriptionId } = requestMetadata;
if (!OneSignalUtils.isValidUuid(appId)) {
throw new SdkInitError(SdkInitErrorKind.InvalidAppId);
}

const subscriptionHeader = subscriptionId
? { 'OneSignal-Subscription-Id': subscriptionId }
: undefined;
Expand Down

0 comments on commit de428a1

Please sign in to comment.