-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move conversions into their own file
- Loading branch information
Showing
6 changed files
with
153 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as core from "./wasm/arcjet_analyze_js_req.component.js"; | ||
import { | ||
DetectedSensitiveInfoEntity, | ||
SensitiveInfoEntity, | ||
} from "@arcjet/protocol"; | ||
export declare function ConvertProtocolEntitiesToAnalyzeEntities( | ||
entity: SensitiveInfoEntity, | ||
): core.SensitiveInfoEntity; | ||
export declare function ConvertDetectedSensitiveInfoEntityToAnalyzeEntity( | ||
entity?: DetectedSensitiveInfoEntity, | ||
): core.SensitiveInfoEntity | undefined; | ||
export declare function ConvertAnalyzeEntitiesToProtocolEntities( | ||
entity: core.SensitiveInfoEntity, | ||
): DetectedSensitiveInfoEntity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
function ConvertProtocolEntitiesToAnalyzeEntities(entity) { | ||
if (entity === "email") { | ||
return { tag: "email" }; | ||
} | ||
if (entity === "phone-number") { | ||
return { tag: "phone-number" }; | ||
} | ||
if (entity === "ip-address") { | ||
return { tag: "ip-address" }; | ||
} | ||
if (entity === "credit-card-number") { | ||
return { tag: "credit-card-number" }; | ||
} | ||
return { | ||
tag: "custom", | ||
val: "custom", | ||
}; | ||
} | ||
function ConvertDetectedSensitiveInfoEntityToAnalyzeEntity(entity) { | ||
if (entity === "email") { | ||
return { tag: "email" }; | ||
} | ||
if (entity === "phone-number") { | ||
return { tag: "phone-number" }; | ||
} | ||
if (entity === "credit-card-number") { | ||
return { tag: "credit-card-number" }; | ||
} | ||
if (entity === "ip-address") { | ||
return { tag: "ip-address" }; | ||
} | ||
if (entity === "custom") { | ||
return { tag: "custom", val: "custom" }; | ||
} | ||
} | ||
function ConvertAnalyzeEntitiesToProtocolEntities(entity) { | ||
if (entity.tag === "email") { | ||
return "email"; | ||
} | ||
if (entity.tag === "ip-address") { | ||
return "ip-address"; | ||
} | ||
if (entity.tag === "credit-card-number") { | ||
return "credit-card-number"; | ||
} | ||
if (entity.tag === "phone-number") { | ||
return "phone-number"; | ||
} | ||
return "custom"; | ||
} | ||
|
||
export { | ||
ConvertAnalyzeEntitiesToProtocolEntities, | ||
ConvertDetectedSensitiveInfoEntityToAnalyzeEntity, | ||
ConvertProtocolEntitiesToAnalyzeEntities, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import * as core from "./wasm/arcjet_analyze_js_req.component.js"; | ||
import { | ||
DetectedSensitiveInfoEntity, | ||
SensitiveInfoEntity, | ||
} from "@arcjet/protocol"; | ||
|
||
export function ConvertProtocolEntitiesToAnalyzeEntities( | ||
entity: SensitiveInfoEntity, | ||
): core.SensitiveInfoEntity { | ||
if (entity === "email") { | ||
return { tag: "email" }; | ||
} | ||
|
||
if (entity === "phone-number") { | ||
return { tag: "phone-number" }; | ||
} | ||
|
||
if (entity === "ip-address") { | ||
return { tag: "ip-address" }; | ||
} | ||
|
||
if (entity === "credit-card-number") { | ||
return { tag: "credit-card-number" }; | ||
} | ||
|
||
return { | ||
tag: "custom", | ||
val: "custom", | ||
}; | ||
} | ||
|
||
export function ConvertDetectedSensitiveInfoEntityToAnalyzeEntity( | ||
entity?: DetectedSensitiveInfoEntity, | ||
): core.SensitiveInfoEntity | undefined { | ||
if (entity === "email") { | ||
return { tag: "email" }; | ||
} | ||
|
||
if (entity === "phone-number") { | ||
return { tag: "phone-number" }; | ||
} | ||
|
||
if (entity === "credit-card-number") { | ||
return { tag: "credit-card-number" }; | ||
} | ||
|
||
if (entity === "ip-address") { | ||
return { tag: "ip-address" }; | ||
} | ||
|
||
if (entity === "custom") { | ||
return { tag: "custom", val: "custom" }; | ||
} | ||
} | ||
|
||
export function ConvertAnalyzeEntitiesToProtocolEntities( | ||
entity: core.SensitiveInfoEntity, | ||
): DetectedSensitiveInfoEntity { | ||
if (entity.tag === "email") { | ||
return "email"; | ||
} | ||
|
||
if (entity.tag === "ip-address") { | ||
return "ip-address"; | ||
} | ||
|
||
if (entity.tag === "credit-card-number") { | ||
return "credit-card-number"; | ||
} | ||
|
||
if (entity.tag === "phone-number") { | ||
return "phone-number"; | ||
} | ||
|
||
return "custom"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters